akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

// https://atcoder.jp/contests/abc126/tasks/abc126_b

string solver(string iStr){
    string result;
    int intDis;
    int aDigit,bDigit;
    bool aMonth=false;
    bool bMonth=false;
    intDis = stoi(iStr);
    aDigit = intDis / 100;
    bDigit = intDis % 100;
    if( 0 < aDigit and aDigit <= 12){
        aMonth = true;
    }
    if( 0 < bDigit and bDigit <= 12){
        bMonth = true;
    }
    if( aMonth == true and bMonth == true){
        result ="AMBIGUOUS";
    }
 if( aMonth == true and bMonth == false){
        result ="MMYY";
    }
     if( aMonth == false and bMonth == true){
        result ="YYMM";
    }
     if( aMonth == false and bMonth == false){
        result ="NA";
    }

    return result;
}

int main(void){
    string answer;
    string S;
    cin >> S ;
    answer = solver(S);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

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

    rep(i, -119, 120){
        rep(j, -119, 120){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(x == a-b){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }
  if(0 < a) {
    cout << "Positive" << endl;
    return 0;
  }
  cout << ((b - a) % 2 ? "Positive" : "Negative") << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i;i<j;i++)
#define print(t) cout<<t<<endl
typedef long long ll;
typedef string str;


int main(){
	int n;
	cin >> n;
	int up=n/100,dn=n%100;
	if(up>12||up==0){
		if(dn<=12&&dn>0){
			cout << "YYMM" << endl;
		}else{
			cout << "NA" << endl;
		}
	}else{
		if(dn>12||dn==0){
			cout << "MMYY" << endl;
		}else{
			cout << "AMBIGUOUS" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
s=1
c=0
if N>=2:
  for i in range(N-1,1,-1):
    if H[i-1]<=H[i]:
      c=0
    elif H[i-1]-1==H[i]:
      H[i-1]-=1
    else:
      s=0
      break

print("Yes" if s==1 else "No")

Measured memory_bytes: 63856
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int color[100001];
 int n,m;
vector<vector<int>> v(100001);
vector<int> p(100001);
int net[100001];
vector<bool> s(100001);
int cl=0;

int next(int g){
    for(int i=net[g];i<v[g].size();i++){
        int nextv = v[g][i];
         net[g]++;
        if(color[nextv]==0){
            return nextv;
        }
    }
    return -1;
}
void solve(){
    for(int i=0;i<n;i++){
        if(color[p[i]]==0){
            stack<int> q;
            q.push(p[i]);cl++;
            color[p[i]]=cl;
            while(!q.empty()){
                int g=q.top();
                int u=next(g);
                if(u==-1){
                    q.pop();
                }else{
                    q.push(u);
                    color[u]=cl;
                }
            }
        }
    }
    
}
int main(){
    cin>>n>>m;
    //v[0].push_back(2);
    rep(i,n){
        cin>>p[i];
        if(i+1==p[i]){
            s[i+1]=true;
        }
    }
    rep(i,m){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
   // rep(i,n){cout<<i<<" ";rep(j,v[i].size()){cout<<v[i][j];}cout<<endl;}
    solve();
    int long long ans=0;
   /* rep(i,n+1){
        cout<<color[i]<<endl;
    }*/
    for(int i=1;i<=n;i++){
        if(s[i]==false){
            int yy=p[i-1];
            if(color[yy]==color[p[yy-1]]){
                ans++;
            }
        }else{
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>
int max(int x[], int num){
    int m = -100;
    for(int i = 0; i < num; i++){
        if(m < x[i]){m = x[i];}
    }
    return m;
}

int min(int x[], int num){
    int m = 100;
    for(int i = 0; i < num; i++){
        if(m > x[i]){m = x[i];}
    }
    return m;
}

int main(void){
    int N, M, X, Y;
    scanf("%d %d %d %d", &N, &M, &X, &Y);
    int x[N+1];
    for(int i = 0; i < N; i++){
        scanf("%d", &x[i]);
    }
    x[N] = X;
    X = max(x, N+1);

    int y[M+1];
    for(int i = 0; i < M; i++){
        scanf("%d", &y[i]);
    }
    y[M] = Y;
    Y = min(y, M+1);
    if(X < Y){
        printf("%s ", "No");
    }
    printf("%s\n", "War");
    return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const int MAX_N=100005;
int L[MAX_N],R[MAX_N];
int N,K;
vec G[MAX_N];
int id[MAX_N];
bool res=true;
void DFS(int v=1,int p=-1)
{
	rep(i,0,G[v].size())
	{
		int to=G[v][i];
		if(to==p)continue;
  		DFS(to,v);
  		if(L[to]<-INF/2)continue;
		if(L[v]<-INF/2)
		{
			L[v]=L[to]-1;
			R[v]=R[to]+1;
		}
		else if(abs(L[v])%2==abs(L[to])%2)
		{
			res=false;
			return;
		}
		L[v]=max(L[v],L[to]-1);
		R[v]=min(R[v],R[to]+1);
	}
	if(L[v]>R[v])
	{
		res=false;
	}
}
void DFS2(int v=1,int p=-1)
{
	if(v==1 && id[v]==-1)
	{
		id[v]=L[v];
	}
	rep(i,0,G[v].size())
	{
		int to=G[v][i];
		if(to==p)continue;
		if(id[to]==-1)
		{
			if(L[to]<=id[v]-1 && id[v]-1<=R[to])id[to]=id[v]-1;
			else id[to]=id[v]+1;
		}
		DFS2(to,v);
	}
}
int main()
{
	cin>>N;
//	rep(i,0,N)
	For(i,1,N)
	{
		L[i]=-INF;
		R[i]=INF;
		id[i]=-1;
	}
	rep(i,0,N-1)
	{
		int a,b;
		cin>>a>>b;
		G[a].pb(b);
		G[b].pb(a);
	}
	cin>>K;
	rep(i,0,K)
	{
		int v,p;
		cin>>v>>p;
		id[v]=L[v]=R[v]=p;
	}
	DFS();
	if(res)
	{
		puts("Yes");
		DFS2();
        For(i,1,N)cout<<id[i]<<endl;
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int A,B,C,X,Y;
ll cost;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>A>>B>>C>>X>>Y;
    
    
    if(X>=Y&&A>2*C)cost=2*X*C;
    else if(X<Y&&B>2*C)cost=2*Y*C;
    else if(A+B>2*C)cost=2*min(X,Y)*C+(X>Y?(X-Y)*A:(Y-X)*B);
    else cost=A*X+B*Y;
    
    cout<<cost<<"\n";
    
    return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll n,m,ans=0;
  cin>>n>>m;
  pair<int,int> rui[n+100]={};
  vector<int>po;
  vector<vector<int> >del(n+10);
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    rui[a-1].F++;
    rui[b-1].S++;
    del[a-1].pb(b-1);
  }
  for(int i=0;i<n;i++){
    if(rui[i].S>0){
      ans++;
      for(int j=0;j<po.size();j++)
	for(int k=0;k<del[po[j]].size();k++)
	  rui[del[po[j]][k]].S--;
      po.clear();
    }
    if(rui[i].F)
      po.pb(i);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6912
read_string(Str) :-
  current_input(Input),
  read_string(Input, '\n', ' ', _, Str).

result_y('Yes').
result_n('No').

solve(S, T, Ret) :-
  string_chars(S, Ss),
  string_chars(T, Ts),
  sort(0, @=<, Ss, Ss2),
  sort(0, @>=, Ts, Ts2),
  compare(<, Ss2, Ts2) ->
    result_y(Ret);
    result_n(Ret).

main :-
  read_string(S),
  read_string(T),
  solve(S, T, Ret),
  writeln(Ret).

:- main.


Measured memory_bytes: 8040
N = gets.to_i
L = gets.split.map(&:to_i)
L.sort!
r = 0
(0 .. N - 3).each{|i|
    (i + 1 .. N - 2).each{|j|
        next if L[i] == L[j]
        (j + 1 .. N - 1).each{|k|
            next if L[j] == L[k]
            break if L[i] + L[j] <= L[k]
            r += 1
        }
    }
}
puts r


Measured memory_bytes: 14372
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int d,n;
	int t[210],a[210],b[210],c[210],dp[210][210];
	bool suit[210][210];
	scanf("%d%d",&d,&n);
	for(int i=0;i<d;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=0;i<d;i++)for(int j=0;j<n;j++){
		suit[i][j]=(a[j]<=t[i]&&t[i]<=b[j]);
	}
	for(int i=0;i<d;i++)for(int j=0;j<n;j++){
		dp[i][j]=-1;
	}
	for(int j=0;j<n;j++){
		if(suit[0][j])dp[0][j]=0;
	}
	for(int i=0;i<d-1;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(suit[i+1][k]&&dp[i][j]>=0){
					if(dp[i+1][k]<dp[i][j]+abs(c[j]-c[k])){
						dp[i+1][k]=dp[i][j]+abs(c[j]-c[k]);
					}
				}
			}
		}
	}
	int ans=-1;
	for(int j=0;j<n;j++){
		if(ans<dp[d-1][j])ans=dp[d-1][j];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1400
//Problem ID: AtCoder - dp_d (Knapsack 1)
//Programmer: IQBAL HOSSAIN     Description: Dynamic Programming
//Date: 27/05/19
//Problem Link: https://atcoder.jp/contests/dp/tasks/dp_d
#include <bits/stdc++.h>
#define MAX 105
using namespace std;

typedef long long ll;
const int inf = 2147483647;
int n, W, w[MAX], v[MAX];

ll dp[MAX][100005];

ll solve(int pos, int weight)
{
    if(pos >= n){
        return 0;
    }
    if(dp[pos][weight] != -1)
        return dp[pos][weight];
    ll ret = 0;
    if(weight + w[pos] <= W)
        ret = max(ret, v[pos] + solve(pos + 1, weight + w[pos]));
    ret = max(ret, solve(pos + 1, weight));

    return dp[pos][weight] = ret;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    cin>>n>>W;

    for(int i = 0; i < n; i++){
        cin>>w[i]>>v[i];
    }

    memset(dp, -1, sizeof(dp));
    ll result = solve(0, 0);

    cout<<result<<endl;

    return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
using P = pair<Int, Int>;
P dp[1024][1024];
Int sz[1024]={};

Int vv[1<<18];
Int ww[1<<18];

Int dep[1<<18]={};
const Int INF = 1e18;

Int query(Int v,Int l){
  return (lower_bound(dp[v],dp[v]+sz[v],P(l,INF))-1)->second;
}

Int dfs(Int v,Int l){
  if(l<0) return -INF;
  if(dep[v]<=10) return query(v,l);
  return max(dfs(v/2,l),dfs(v/2,l-ww[v])+vv[v]);
}

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

  Int n;
  cin>>n;
  for(Int i=1;i<=n;i++) cin>>vv[i]>>ww[i];

  Int q;
  cin>>q;
  vector<Int> xs(q),ys(q);
  for(Int i=0;i<q;i++) cin>>xs[i]>>ys[i];

  dep[1]=1;
  for(Int i=2;i<=n;i++)
    dep[i]=dep[i/2]+1;

  for(Int i=1;i<=min(n,1023LL);i++){
    vector<Int> rs;
    for(Int j=0;j<dep[i];j++)
      rs.emplace_back(i>>j);

    Int s=1<<dep[i];
    vector<P> vp;
    for(Int b=0;b<s;b++){
      Int p=0,q=0;
      for(Int j=0;j<dep[i];j++){
        if((~b>>j)&1) continue;
        p+=ww[rs[j]];
        q+=vv[rs[j]];
      }
      vp.emplace_back(p,q);
    }

    sort(vp.begin(),vp.end());
    vector<P> nx;
    for(auto p:vp)
      if(nx.empty() or nx.back().second<p.second)
        nx.emplace_back(p);

    sz[i]=nx.size();
    for(Int j=0;j<sz[i];j++) dp[i][j]=nx[j];
  }

  for(Int i=0;i<q;i++)
    cout<<dfs(xs[i],ys[i])<<newl;

  return 0;
}


Measured memory_bytes: 23620
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    int now = 1;
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        if(now == x)now++;
    }
    if(now > 1)cout << n - now + 1<< endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
ans = (-1, -1, -1)
for x in range(N + 1):
    over = False
    for y in range(N + 1):
        z = N - x - y
        if z < 0:
            over = True
            break
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = (x, y, z)
            break
    else:
        continue
    if over:
        continue
    break

print(*ans)


Measured memory_bytes: 3060
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define ll long long int
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int main() {
int a,b;
cin>>a>>b;
int n;
cin>>n;
int x[101]={0};
for(int i=1;i<=100;i++){
	if(a%i==0&&b%i==0)x[i]=1;
}
int as=0;
for(int i=100;i>=0;i--){
	if(x[i]==1)as++;
	if(as==n){
		cout<<i;
		return 0;
	}
}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int main(){
	long long N,X;
	long long A[100];
	cin>>N>>X;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N);
	long long sum=0;
	long long now=0;
	long long ans=0;
	while(now<N&&sum+A[now]<=X){
		sum+=A[now];
		now++;
		ans++;
	}
	if(now==N&&sum<X){
		ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    int a=input.nextInt();
    int b=input.nextInt();
    if(a>=1 && b>=1 && a<=10000 && b<=10000)
    {
      a=a*b;
      if(a%2==0)
      {
        System.out.println("Even");
      }else
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false;
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s;
  cin >> s;
  lli k;
  cin >> k;
  int i=0;
  for (; s[i]=='1' && i<k-1; ++i);
  cout << s[i] << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
    }

    long long ans = 1e15, keep;
    for (int i = 1; i <= 100; i++) {
        keep = 0;
        for (int j = 0; j < N; j++) {
            keep += (X.at(j) - i) * (X.at(j) - i);
        }
        if (keep < ans) {
            ans = keep;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
(function Main(input){
	var input = input.split('\n'),
		bingo = input.slice(0,3).join(' ').split(' ');

	input.splice(0, 4);

	for(var i=input.length; i--;){
		for(var j=bingo.length; j--;){
			if(input[i] === bingo[j]){
				bingo[j] = 'bingo';
				break;
			}
		}
	}

	function check(){
		if(bingo[0] == 'bingo' && bingo[1] == 'bingo' && bingo[2] == 'bingo'){ return true; }
		if(bingo[3] == 'bingo' && bingo[4] == 'bingo' && bingo[5] == 'bingo'){ return true; }
		if(bingo[6] == 'bingo' && bingo[7] == 'bingo' && bingo[8] == 'bingo'){ return true; }
		if(bingo[0] == 'bingo' && bingo[3] == 'bingo' && bingo[6] == 'bingo'){ return true; }
		if(bingo[1] == 'bingo' && bingo[4] == 'bingo' && bingo[7] == 'bingo'){ return true; }
		if(bingo[2] == 'bingo' && bingo[5] == 'bingo' && bingo[8] == 'bingo'){ return true; }
		if(bingo[0] == 'bingo' && bingo[4] == 'bingo' && bingo[8] == 'bingo'){ return true; }
		if(bingo[2] == 'bingo' && bingo[4] == 'bingo' && bingo[6] == 'bingo'){ return true; }
		return false;
	}

	console.log(check() ? 'Yes': 'No');

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

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
def bellmanFord(e,n,s):
    inf = 10**18
    d = [inf]*n
    d[s] = 0

    loop = False
    for i in range(n):
        updated = False
        for v in range(n):
            for u,c in e[v]:
                if d[v]!=inf and d[u]>d[v]+c:
                    d[u] = d[v]+c
                    updated = True
                    if i==n-1 and u==n-1:
                        loop = True
        if not updated:
            break
    return d,loop


n,m = map(int, input().split())
e = [[] for _ in range(n)]
for _ in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    e[a].append((b,-c))

d,loop = bellmanFord(e,n,0)
if loop:
    print("inf")
else:
    print(-d[n-1])

Measured memory_bytes: 3316
import sys
from collections import Counter
input=sys.stdin.readline

N=int(input())
D=list(map(int,input().split()))

cnt=[0]*(max(D)+1)
mod=998244353
for i in D:
    cnt[i]+=1
if cnt[0]!=1 or D[0]!=0:
    print(0)
    exit(0)
ans=1
for i in range(1,len(cnt)):
    if cnt[i]==0:
        print(0)
        exit()
    ans*=pow(cnt[i-1],cnt[i],mod)
    ans%=mod
print(ans)

Measured memory_bytes: 14140
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 100010
using namespace std;
typedef long long LL;
int x[maxn];
int main() {
    int n;
    scanf("%d", &n);
    x[0] = 0;
    F2(i, 1, n) scanf("%d", &x[i]);
    x[n+1] = 0;
    LL sum=0;
    F2(i, 1, n+1) sum += abs(x[i]-x[i-1]);
    F2(i, 1, n) {
        int a=x[i-1], b=x[i], c=x[i+1];
        LL ans = sum;
        if ((c>=a&&a>=b) || (b>=a&&a>=c)) ans -= abs(a-b)<<1;
        else if ((b>=c&&c>=a) || (a>=c&&c>=b)) ans -= abs(b-c)<<1;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(string X, string Y) {
  if (X == Y) cout << "=" << endl;
  else if (X < Y) cout << "<" << endl;
  else cout << ">" << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string Y;
	string X;
	cin >> X;
	cin >> Y;
	solve(X, Y);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	ll val = n;
	ll ct = 0;
	vector<ll> vt;
	REP(i,2,sqrt(n) + 1){
		ll c = 0;
		while(val % i == 0){
			val /= i;
			c++;
		}
		if(c > 0){
			vt.push_back(c);
		}
	}
	if(val > 1) vt.push_back(1);

	REP(i,0,vt.size()){
		ll curr = 1;
		ll val = vt[i];
		while(val - curr >= 0){
			ct++;
			val -= curr;
			curr++;
		}
	}
	cout<<ct<<endl;
	return 0;
}




Measured memory_bytes: 3720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars,
        mut t: chars
    }
    t.reverse();
    println!("{}", if s == t {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    double T,A;
    double H[1001];
    pair<double,int> ans;
    cin>>N>>T>>A;
    for(int i=0;i<N;i++) cin>>H[i];
    
    for(int i=0;i<N;i++){
        double tmp=T-H[i]*0.006;
        if(i==0){
            ans.first=abs(tmp-A);
            ans.second=1;
        }
        else if(ans.first>abs(tmp-A)){
            ans.first=abs(tmp-A);
            ans.second=i+1;
        }
    }
    
    cout<<ans.second<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}

		out.println(set.size());
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int sum = 0;
    int p=0;
    int q_1=0;
    int q_2=0;
    for(int i=0;i<n;i++){
        cin >> x.at(i);
        sum += x.at(i);
    }

    p = sum / n;

    for(int i=0;i<n;i++){
        q_1 += (x.at(i)-p)*(x.at(i)-p);
    }

    p = p+1;

    for(int i=0;i<n;i++){
        q_2 += (x.at(i)-p)*(x.at(i)-p);
    }
    cout << min(q_1,q_2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[20];
int main(){
	ll n,s;
	while(scanf("%lld%lld",&n,&s),n){
		rep(i,0,20)a[i]=0;
		rep(i,0,n){
			ll p,q;
			scanf("%lld%lld",&p,&q);
			a[q]+=p;
		}
		ll ans=0;
		for(int i=10;i>0;i--){
			ans+=max(0,a[i]-s)*i;
			s-=min(a[i],s);
		}
		printf("%lld\n",ans);
	}
}




Measured memory_bytes: 2024
#include<stdio.h>
int main(void)
{
    int a=0;
    
    scanf("%d", &a);
    if(a%2==0){
    printf("%d",(a/2)*(a/2));
    }
    if(a%2 == 1){
    printf("%d",((a-1)/2)*(((a-1)/2)+1));
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        String line;
        
        String keyence = "keyence";
        String s = "";
        
        ArrayList<Integer> n = new ArrayList<Integer>();
        
        for(int i = 0; cin.hasNext(); i++){
	        line = cin.nextLine();
	        
	        if(i == 0) {
	            s = line;
	            
	        } else {
	            
	        }
	        
        }
        
        
        
        String res = "NO";
        
        if(s.equals(keyence)) {
            res = "YES";
        }
        
        for(int i = 0; i < s.length(); i++) {
            for(int j = i + 1; j < s.length(); j++) {
                if((s.substring(0, i) + s.substring(j, s.length())).equals(keyence)) {
                    res = "YES";
                    
                }
            }
        }
        
        System.out.println(res);
        
    }
    
}


Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k, s;
	scanf("%d%d%d", &n, &k, &s);
	int d = s == (int)(1e9) ? s - 1 : s + 1;
	for(int i(1); i <= n; i++) printf("%d%c", i <= k ? s : d, i == n ? '\n' : ' ');
}


Measured memory_bytes: 1280
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		string ans = "";
		while(n>0)
		{
			int rem = (n)%26;
			char c;
			if(rem==0)
				c = 'z';
			else
				c = 'a' + rem - 1;
			ans += c;
			n = (n-1)/26;
		}
		reverse(all(ans));
		cout << ans;
	}
}



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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	string x[n];
	bool check = true;
	loop(n)
	{
		cin >> x[i];
		if(i != 0)
		{	
			int len1 = x[i-1].length();
			if (x[i-1][len1 - 1] != x[i][0])
				check = false;
		}
	}
	if (!check)
	{
		cout << "No" << endl;
		return 0;
	}
	loop(n)
	{
		lp(j,i + 1,n)
		{
			if (x[i] == x[j])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n%i==0){
            res.push_back(i);
            if(n/i != i)res.push_back(n/i);
        }
    }
    return res;
}

int main() {
  ll n;
  cin >> n;
  auto div = divisor(n);


  auto ok = [&](ll x, ll cur){
    while (cur % x == 0) {
      cur /= x;
    }
    return cur % x == 1;
  };
  int res = 0;
  for (auto e : div) {
    if (e == 1) continue;
    res += ok(e, n);
  }

  auto div2 = divisor(n - 1);

  cout << res + div2.size() - 1 << endl;

  return 0;
} 

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			push_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl; }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define re 			resize
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a <<"   ";
	err(++it, args...);
}
string to_string(string s) {
	return '"' + s + '"';
}
string to_string(const char* s) {
	return to_string((string) s);
}
string to_string(bool b) {
	return (b ? "true" : "false");
}
string to_string(char ch) {
	return string("'")+ch+string("'");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}
template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}
template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

int n,m;
vi adj[(ll)1e5+1];
bool vis[(ll)1e5+1];
int dp[(ll)1e5+1];
void dfs(int s)
{
	vis[s]=1;
	for(int i:adj[s])
		if(!vis[i])
			dfs(i);
	for(int i:adj[s])
		dp[s]=max(dp[s],dp[i]);
	dp[s]++;
}
signed main(void)
{ios
	cin>>n>>m;
	rep(i,0,m)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
	}
	rep(i,1,n+1)
	if(!vis[i])
		dfs(i);
	int ans=0;
	rep(i,1,n+1)
	ans=max(ans,dp[i]);
	cout<<ans-1	<<endl;
}

Measured memory_bytes: 8704
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
long long a[2010];
pair<long long,long long> p[2010];
long long dp[2010][2010];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		p[i]=make_pair(a[i],i);
	}
	sort(p+1,p+n+1);
	reverse(p+1,p+n+1);
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		for(int l=1;l<=n;l++){
			int r=n-(i-l);
			if(r>n)continue;
			dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(p[i].second-l)*p[i].first);
			dp[l][r-1]=max(dp[l][r-1],dp[l][r]+abs(p[i].second-r)*p[i].first);
		}
	}
	long long mx=0;
	for(int i=1;i<=n+1;i++){
		mx=max(mx,dp[i][i-1]);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 35264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int[] input = new int[9];
		String k = "No";
		for (int i = 0; i < 9; i++) {
			input[i] = kb.nextInt();
		}
		int n = kb.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			int j = kb.nextInt();
			a[i] = j;
		}
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < n; j++) {
				if (input[i] == a[j]) {
					input[i] = 0;
					break;
				}
			}
		}
		if (input[0] == 0 && input[1] == 0 && input[2] == 0)
			k = "Yes";
		else if (input[3] == 0 && input[4] == 0 && input[5] == 0)
			k = "Yes";
		else if (input[6] == 0 && input[7] == 0 && input[8] == 0)
			k = "Yes";
		else if (input[0] == 0 && input[3] == 0 && input[6] == 0)
			k = "Yes";
		else if (input[1] == 0 && input[4] == 0 && input[7] == 0)
			k = "Yes";
		else if (input[2] == 0 && input[5] == 0 && input[8] == 0)
			k = "Yes";
		else if (input[0] == 0 && input[4] == 0 && input[8] == 0)
			k = "Yes";
		else if (input[2] == 0 && input[4] == 0 && input[6] == 0)
			k = "Yes";
		System.out.println(k);
		kb.close();
	}

}


Measured memory_bytes: 22996
import bisect

n = int(input())
l = sorted(list((map(int, input().split()))))

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<int> numbers = new List<int> { };      //int 2tu WA kakunou

        

        while (true)
        {
            string stringg = Console.ReadLine();

            if (stringg == null)
                break;

            string[] str = stringg.Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);


            numbers.Add(x + y);

        }


        for ( int i=0;i < numbers.Count;i++)
        {
            int x = numbers[i];
            int digit = 0;

            while(true)
            {
                x = x / 10;

                digit += 1;

                if (x == 0)
                    break;
            }

            Console.WriteLine(digit);
        }

    }
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mod=1e9+7;
int n,x[100010],s[100010];
int fac[100010]={1},inv[100010]={1};
int modpow(int a, long long n) {
	int r = 1, b = a;
	while(n > 0) {
		if(n & 1) r = 1ll * r * b % mod;
		b = 1ll * b * b % mod;
		n >>= 1;
	}
	return r;
}
int nCr(int n,int r) {
	if(r<0||n<r) return 0;
	return (ll)fac[n]*inv[r]%mod*inv[n-r]%mod;
}
int main() {
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		scanf("%d",x+i);
		fac[i]=(ll)fac[i-1]*i%mod;
		inv[i]=modpow(fac[i],mod-2);
	}
	ll ans=0;
	for(i=0;i<=n-2;i++) {
		if(i==0) s[i]=fac[n-1];
		else { 
			s[i]=(ll)fac[i]*nCr(n-1,i+1)%mod*fac[n-2-i]%mod;
			s[i]=(s[i]+s[i-1])%mod;
		}
		ans+=(ll)(x[i+2]-x[i+1])%mod*s[i]%mod;
		ans%=mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const long long MOD = 1000000007;


int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    //solve(N, K);
    vector<ll> acc(N+1);
    vector<ll> racc(N+1);
    for (long long i = 1; i <= N; i++) {
        acc[i]=acc[i-1]+i;
    }
    for (long long i = N; i >= 0; i--) {
        racc[i]=racc[i+1]+i;
    }
    // if(N==3){
    // vout(acc);
    // vout(racc);
    // }
    ll sum=0;
    for (long long i = K; i <= N+1; i++) {
        sum += racc[N-i+1] - acc[i-1] +1;
        sum%=MOD;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6272
import java.util.Scanner;

class Main {
	int[][] c;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		c = new int[3][3];
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				c[i][j] = sc.nextInt();
			}
		}
	}
	void solve(){
		int[] a = new int[3];
		int[] b = new int[3];
		int min = Math.min(c[0][0], Math.min(c[0][1], c[0][2]));
		for(int i=0;i<=min;i++){
			a[0] = i;b[0] = c[0][0] - a[0];b[1] = c[0][1] - a[0];b[2] = c[0][2];
			a[1] = c[1][0] - b[0];a[2] = c[2][1] - b[1];
			//System.out.printf("a1=%-2d a2=%-2d a3=%-2d b1=%-2d b2=%-2d b3=%-2d\n",a[0],a[1],a[2],b[0],b[1],b[2]);
			check:for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(c[j][k]!=a[j]+b[k]) break check;
					if(j==2&&k==2){
						System.out.println("Yes");
						System.exit(0);
					}
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 25172