akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

const MOD = 1e9 + 7

func main() {
	N := nextInt()
	IS := make([]int, N)
	SUM := make([]int, N)
	IS[0] = nextInt()
	SUM[0] = IS[0]
	for i := 1; i < N; i++ {
		IS[i] = nextInt()
		SUM[i] = SUM[i-1] + IS[i]
	}
	var ANS int
	for i := 0; i < N; i++ {
		sum := (SUM[N-1] - SUM[i] + MOD) % MOD
		ANS += (IS[i] * sum) % MOD
		ANS %= MOD
	}
	fmt.Println(ANS)
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

ll poww(ll a,ll b){
  ll ans=1;
  while(b>0){
    if(b%2==1) ans=(ans*a);
    a=(a*a);
    b=b/2;
  }
  return ans;
}

/*-----------------------------------------------------------------------*/

double dp[302][302][302];
ll n,one=0,two=0,three=0;

double find(ll one,ll two, ll three){
	if(one<0||two<0||three<0)
		return 0;
	if(one==0&&two==0&&three==0)
	    return 0;
	if(dp[one][two][three]!=0)
		return dp[one][two][three];
	dp[one][two][three]=n*1.0/(one+two+three)*(1+find(one-1,two,three)*one/n+find(one+1,two-1,three)*two/n+find(one,two+1,three-1)*three/n);
	return dp[one][two][three];
}

int main(){

   fastt;

   cin>>n;

   for(ll i=0;i<n;i++){
   	  ll x;
   	  cin>>x;
   	  if(x==1) one++;
   	  if(x==2) two++;
   	  if(x==3) three++;
   }

   cout<<fixed<<setprecision(10);
   cout<<find(one,two,three)<<endl;

   return 0;
}


Measured memory_bytes: 215296
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
const int N=1e6+7;
ll n,s,p[N];
ll check(ll x)
{
	ll ans=0,t=n;
	while(t)
	{
		ans+=t%x;
		t/=x;
	}
	return ans;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%lld%lld",&n,&s);
  if(n==s)
  {
      printf("%lld\n",n+1);
      return 0;
  }
  if(n<s)
  {
  	printf("-1\n");
  	return 0;
  }
  for(int i=2;i<=sqrt(n);i++)
  {
  	if(check(i)==s) 
  	{
  	  printf("%d\n",i);
	  return 0;	
  	}
  }
  ll tmp=sqrt(n);
  for(ll i=min(tmp,n-s)+100;i>=1;i--)
  {
  	if((n-s)%i==0) 
  	{
  		ll ans=(n-s)/i+1;
		if(ans>sqrt(n)&&(s-i)<ans&&check(ans)==s)
  		{   
  			printf("%lld\n",ans);
  			return 0;
  		}
  	}
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
	return 0;
}

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

namespace ARC080
{
    class C
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            int count = 0;
            int secondcount = 0;
            for (int i = 0; i < N; i++)
            {
                if (a[i] % 4 == 0) { count++; }
                if (a[i] % 2 == 0) { secondcount++; }
            }

            secondcount -= count;
            if (2 <= secondcount)
            {
                N -= secondcount;
                if (N % 2 != 0)
                {
                    if ((N / 2) + 1 <= count) { Console.WriteLine("Yes"); }
                    else Console.WriteLine("No");
                    return;
                }
                else if (N / 2 <= count) { Console.WriteLine("Yes"); }
                else Console.WriteLine("No");
            }
            else
            {
                if (N / 2 <= count) { Console.WriteLine("Yes"); }
                else Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 20832
N = int(input())
def length(a,b):
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2)
p = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += length(p[i],p[j])
print(ans*2/N)

Measured memory_bytes: 62392
#include <cstdio>
const int Maxn=2000;
const int Mod=1000000007;
int sum[Maxn+5][Maxn+5];
int f[Maxn+5][Maxn+5];
int n;
int main(){
	scanf("%d",&n);
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		sum[0][i]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=3;j<=n;j++){
			f[i][j]=(f[i][j]+sum[i-1][j-3])%Mod;
		}
		for(int j=1;j<=n;j++){
			sum[i][j]=(sum[i][j-1]+f[i][j])%Mod;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+f[i][n])%Mod;
	}
	printf("%d\n",ans);
	return 0;
}


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



int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
    cout<<7;
    if(s=="MON")
    cout<<6;
    if(s=="TUE")
    cout<<5;
    if(s=="WED")
    cout<<4;
    if(s=="THU")
    cout<<3;
    if(s=="FRI")
    cout<<2;
    if(s=="SAT")
    cout<<1;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    map<char, int> m;
    for (int i = 0; i < N; i++) {
        if (S[i][0] == 'M' || S[i][0] == 'A' || S[i][0] == 'R' || S[i][0] == 'C' || S[i][0] == 'H') {
            m[S[i][0]]++;
        }
    }

    ll ans = 1;
    if (m.size() <= 2) {
        ans = 0;
    } else {
        if (m.size() == 3) {
            for (map<char, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
                ans *= it->second;
            }
        } else if (m.size() == 4) {
            vector<ll> tmp;
            for (map<char, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
                tmp.push_back(it->second);
            }

            ans = 0;
            ans += (tmp[0] * tmp[1] * tmp[2]);
            ans += (tmp[0] * tmp[1] * tmp[3]);
            ans += (tmp[0] * tmp[2] * tmp[3]);
            ans += (tmp[1] * tmp[2] * tmp[3]);
        } else {
            vector<ll> tmp;
            for (map<char, int>::iterator it = m.begin(), end = m.end(); it != end; it++) {
                tmp.push_back(it->second);
            }

            ans = 0;
            ans += (tmp[0] * tmp[1] * tmp[2]);
            ans += (tmp[0] * tmp[1] * tmp[3]);
            ans += (tmp[0] * tmp[1] * tmp[4]);
            ans += (tmp[0] * tmp[2] * tmp[3]);
            ans += (tmp[0] * tmp[2] * tmp[4]);
            ans += (tmp[0] * tmp[2] * tmp[5]);
            ans += (tmp[0] * tmp[3] * tmp[4]);
            ans += (tmp[0] * tmp[3] * tmp[5]);
            ans += (tmp[0] * tmp[4] * tmp[5]);
            ans += (tmp[1] * tmp[2] * tmp[3]);
            ans += (tmp[1] * tmp[2] * tmp[4]);
            ans += (tmp[1] * tmp[2] * tmp[5]);
            ans += (tmp[1] * tmp[3] * tmp[4]);
            ans += (tmp[1] * tmp[3] * tmp[5]);
            ans += (tmp[1] * tmp[4] * tmp[5]);
            ans += (tmp[2] * tmp[3] * tmp[4]);
            ans += (tmp[2] * tmp[3] * tmp[5]);
            ans += (tmp[2] * tmp[4] * tmp[5]);
            ans += (tmp[3] * tmp[4] * tmp[5]);
        }
    }

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

Measured memory_bytes: 5760
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int n, m;
		cin>>n>>m;
		if(n == 0 && m == 0) break;
		vector<vector<pair<ll, P> > > l(m, vector<pair<ll, P> >(0));
		REP(i, n) {
			ll a, b, c, t;
			cin>>a>>b>>c>>t;
			--a;
			--b;
			l[a].pb(pair<ll, P>(b, P(c, t)));
			l[b].pb(pair<ll, P>(a, P(c, t)));
		}
		vector<vector<ll> > d0(m, vector<ll>(m, INF));
		vector<vector<ll> > d1(m, vector<ll>(m, INF));
		REP(i, m) {
			REP(j, l[i].size()) {
				d0[i][l[i][j].first] = l[i][j].second.first;
				d0[l[i][j].first][i] = l[i][j].second.first;
				d1[i][l[i][j].first] = l[i][j].second.second;
				d1[l[i][j].first][i] = l[i][j].second.second;
			}
		}
		REP(k, m) {
			REP(i, m) {
				REP(j, m) {
					d0[i][j] = min(d0[i][j], d0[i][k] + d0[k][j]);
					d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
				}
			}
		}
		int k;
		cin>>k;
		REP(i, k) {
			int p, q, r;
			cin>>p>>q>>r;
			--p;
			--q;
			if(r == 0) {
				cout<<d0[p][q]<<endl;
			} else {
				cout<<d1[p][q]<<endl;
			}
		}
	}
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int df[214514], ds[214514][2]; // 0:mada, 1:nukasi
signed main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	string st;
	cin>>st;
	a--;b--;c--;d--;
	df[b] = true;
	int mf = -1;
	for(int i=b;i<n;i++){
		if( df[i] ){
			if( i+1 <= d && st[i+1] == '.' ){ df[i+1] = true; mf = max(mf,i+1);}
			if( i+2 <= d && st[i+2] == '.' ){ df[i+2] = true; mf = max(mf,i+2);}
		}
	}
	ds[a][0] = true;
	for(int i=a;i<n;i++){
		if( ds[i][0] ){
			if( i+1 <= c && st[i+1] == '.' && mf > i+1 ){ ds[i+1][0] = true; }
			if( i+2 <= c && st[i+2] == '.' && mf > i+2 ){ ds[i+2][0] = true; }
			if( i+2 <= c && st[i+2] == '.' && df[i+1] ){ ds[i+2][1] = true; }
		}
		if( ds[i][1] ){
			if( i+1 <= c && st[i+1] == '.' ){ ds[i+1][1] = true; }
			if( i+2 <= c && st[i+2] == '.' ){ ds[i+2][1] = true; }
		}
	}
	if( df[d] && ( ds[c][0] || ds[c][1] ) ){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define sortv(v) sort(all(v))
#define sortg(v) sort(all(v), greater<int>())
#define countv(v, c) count(all(v), c)
#define gcd __gcd
#define rep(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define _rep(i, n) rep(i, 0, n)
#define rev(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define _rev(i, n) rev(i, n, 0)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
	if(cin >> f){in(r...);return true;}
	else{return false;}
}
#define inv(x) each(i, x) in(i)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define printv(x) each(i, x) out(i), space(); indent()
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
#define YN(x) out((x) ? "YES" : "NO"), indent()
#define Yn(x) out((x) ? "Yes" : "No"), indent()
#define yn(x) out((x) ? "yes" : "no"), indent()
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
const int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1};
const int dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){
	int res = 1;
	rep(i, 1, r + 1){
		res *= n--, res /= i;
	}
	return res;
}
bool isPrime(int n){
	rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		if(!(n % i)){
			return false;
		}
	}
	return true;
}
vector<int> divisor(int n){
	vector<int> ans;
	rep(i, 1, sqrt(n) + 1){
		if(!(n % i)){
			ans.pb(i);
			if(i * i < n){
				ans.pb(n / i);
			}
		}
	}
	return ans;
}
map<int, int> factorization(int n){
	map<int, int> ans;
	rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		while(!(n%i)){
			ans[i]++, n /= i;
		}
	}
	if(n > 1){
		ans[n]++;
	}
	return ans;
}
int n, tmp, res = 0;
string s;
main(){INCANT;
	/*-------------------*/
	
	in(s);
	Yn(!(s=="AAA"||s=="BBB"));
	
	/*-------------------*/
}

Measured memory_bytes: 256
import java.util.*;

/**
 * A
 */
public class Main {

    void run() {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[][] matrix = new int[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                matrix[i][j] = 0;
            }
        }
        
        for(int i=0; i<n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j=0; j<k; j++) {
                int v = sc.nextInt()-1;
                matrix[i][v] = 1;
            }
        }

        sc.close();

        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(j!=n-1) {
                    System.out.print(matrix[i][j]+" ");
                } else {
                    System.out.println(matrix[i][j]);
                }
            }
        }

    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

map<string, int> dict;
int total = 0;

int convert(string s) {
	if (dict.find(s) == end(dict)) {
		dict[s] = total++;
	}
	return dict[s];
}

using pii = pair<int, int>;
vector<pii> doc[1010];
bool used[1010];

bool rel[310][310];
vector<int> tri[310][310];

int main(void) {
	string p, q;
	cin >> p >> q;

	const int pidx = convert(p), qidx = convert(q);
	rel[pidx][qidx] = true;

	int n;
	cin >> n;

	rep(i, n) {
		int m;
		cin >> m;
		rep(j, m) {
			string a, b;
			cin >> a >> b;
			const int aidx = convert(a), bidx = convert(b);
			doc[i].push_back(pii(aidx, bidx));
			tri[aidx][bidx].push_back(i);
		}
	}

	queue<pii> que;
	que.push(pii(pidx, qidx));

	while (!que.empty()) {
		pii cur = que.front(); que.pop();

		for (auto &idx : tri[cur.first][cur.second]) {
			if (used[idx]) continue;
			used[idx] = true;
			for (auto &elem : doc[idx]) {
				if (rel[elem.first][elem.second]  == false) {
					rel[elem.first][elem.second] = true;
					que.push(pii(elem.first, elem.second));
				}
			}
		}

		rep(i, total) {
			if (rel[cur.second][i] == true and rel[cur.first][i] == false) {
				rel[cur.first][i] = true;
				que.push(pii(cur.first, i));
			}
		}
	}

	bool ok = true;
	rep(i, total)rep(j, total) if (rel[i][j] == true and rel[j][i] == true) ok = false;
	puts(ok ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 9136
n=input()
s=len(n)
n=int(n)
k=9
ans=0
if s==2: print(9)
elif s==4: print(909)
elif s==6: print(90909)
else:
  if s==1: print(n)
  elif s==3: print(9+n-99)
  elif s==5: print(909+n-9999)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int h, w;
    cin >> h >> w;
    string c[400];
    for(int i = 0; i < h; i++){
        cin >> c[h - 1 - i];
    }
    int ans = 0;
    for(int i = 0; i < w - 1; i++){
        int dp[400][400];
        for(int j = 0; j < 400; j++){
            for(int k = 0; k < 400; k++){
                dp[j][k] = 0;
            }
        }
        for(int j = 1; j <= h; j++){
            for(int k = 1; k <= h; k++){
                dp[j][k] = dp[j - 1][k - 1];
                if(c[h - j][i] == c[h - k][i + 1]){
                    dp[j][k]++;
                }
                //cout << j << " " << k << " " << dp[j][k] << endl;
            }
        }
        int dp2[400][400];
        for(int j = 0; j < 400; j++){
            for(int k = 0; k < 400; k++){
                dp2[j][k] = 0;
            }
        }
        for(int j = 1; j <= h; j++){
            for(int k = 1; k <= h; k++){
                dp2[j][k] = min(dp2[j - 1][k], dp2[j][k - 1]);
                dp2[j][k] += dp[j][k];
                //cout << j << " " << k << " " << dp[j][k] << endl;
            }
        }
        ans += dp2[h][h];
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>

int main(){
	char aa,bb,cc,dd;
	int a,b,c,d;
	scanf("%c%c%c%c",&aa,&bb,&cc,&dd);
	a=aa-'0';b=bb-'0';c=cc-'0';d=dd-'0';
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				int x=a;
				if(i)x+=b;else x-=b;
				if(j)x+=c;else x-=c;
				if(k)x+=d;else x-=d;
				if(x==7){
					printf("%d%c%d%c%d%c%d=7",a,i?'+':'-',b,j?'+':'-',c,k?'+':'-',d);
					goto A;
				}
			}
		}
	}
	A:
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a, b = [int(x) for x in input().split()]
for _ in range(n - 1):
	c, d = [int(x) for x in input().split()]
	k = max((a - 1) // c + 1, (b - 1) // d + 1)
	a, b = c * k, d * k
print(a + b)


Measured memory_bytes: 3060
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, readline().split())
    (*L,) = map(int, read().split())

    ans = INF
    for p in product(range(4), repeat=N):
        num = [0] * 3
        length = [0] * 3
        for i, j in enumerate(p):
            if j < 3:
                num[j] += 1
                length[j] += L[i]
        res = 0
        for j in range(3):
            if num[j] == 0:
                res = INF
                break
            else:
                res += (num[j] - 1) * 10 + abs(length[j] - A[j])
        if ans > res:
            ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
N, K = [int(x) for x in input().split(' ')]

counter = 0

for i in range(N + 1, K - 1, -1):
  # m = sum(range(N, N - i, -1)) - sum(range(i)) + 1
  m = (i * (2 * N - (i - 1)) - (i - 1) * i) / 2 + 1
  counter += int(m)

print(counter % (10 ** 9 + 7))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  long long A, B, C; cin>>A>>B>>C;
  vector<long long> a={A, B, C};
  sort(a.begin(), a.end());
  long long X=a[0];
  long long Y=a[1];
  long long Z=a[2]; //Zが最大
  int x=X%2;
  int y=Y%2;
  int z=Z%2;
  if((x*y*z)%2==0) cout<<0<<endl;
  else cout<<X*Y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  string s;
  cin>>s;

  ll l=s.size()-1;
  ll te=0;
  ll ans=0;
  while(l>=0){
    if(s[l]=='C'){
      if(l-1>=0&&s[l-1]=='B'){
        l-=2;
        te+=1;
      }
      else {
        l-=1;
        te=0;
      }
    }
    else if(s[l]=='A'){
      ans+=te;
      l-=1;
    }
    else {
      l-=1;
      te=0;
    }
  }
  cout<<ans<<endl;

  return 0;
}

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

int main(){
	int n,c;
	while(cin >> n >> c){
		vector<int> cost(n);
		vector<vector<int> > v(3, vector<int>(n));
		for(int i=0; i<n; i++){
			string s;
			getline(cin, s);
			getline(cin, s);
			cin >> cost[i] >> v[0][i] >> v[1][i] >> v[2][i];
		}
		
		int ans = 0;
		for(int d=0; d<3; d++){
			vector<int> dp(c+1, 0);
			for(int i=0; i<n; i++){
				for(int j=0; j<c; j++){
					if(j +cost[i] <= c){
						dp[j+cost[i]] = max(dp[j+cost[i]], dp[j]+v[d][i]);
					}
				}
			}
			ans = max(ans, *max_element(dp.begin(), dp.end()));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i;
    ll ans=0;
    for(i=1;i<=N;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout << ans;
    return 0;
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> l(n);
rep(i, n){
  cin >> l[i];
}
vector<ll> a(2010);
vector<ll> sum(2010);
rep(i,n){
  a[l[i]]++;
}
rep(i,a.size()-1){
  sum[i+1]=sum[i]+a[i+1];
}
for (ll i = 0; i < n-1; i++)
{
  for (ll j = i+1; j < n; j++)
  {
    ll a=l[i];
    ll b=l[j];
    if(b>a)swap(a,b);
    ans+=sum[a+b-1]-sum[a-b];
    if(a-b<a)ans--;
    if(a-b<b)ans--;
  }
}


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

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    set<string> s;
    char lst = ' ';
    REP(i, 0, N) {
        string w;
        cin >> w;
        if (s.count(w)) {
            cout << "No" << endl;
            return 0;
        }
        if (lst == ' ') {
            lst = w[0];
        }
        if (w[0] != lst) {
            cout << "No" << endl;
            return 0;
        }
        s.insert(w);
        lst = w[w.size() - 1];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int calcScore(vector<int> &plan, vector<int> &c, vector<vector<int>> &s) {
	int D = 365;
	int score = 0;
	vector<int> last(26, -1);
	for (int i = 0; i < D; i++) {
		score += s[i][plan[i]];
		last[plan[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}

int main() {
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0; i < 26; i++)cin >> c[i];
	vector<vector<int>> s(365,vector<int>(26,0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++)cin >> s[i][j];
	}
	
	vector<int> plan(365, 0);
	for (int i = 0; i < 365; i++) {
		int mi = 0, m = -1;
		for (int j = 0; j < 26; j++) {
			if (m < s[i][j]) {
				mi = j;
				m = s[i][j];
			}
			plan[i] = j;
		}
	}
	int sc = calcScore(plan, c, s);

	for (int n = 0; n < 100000; n++) {
		int i = rand() % 365, j = rand() % 26, old = plan[i];
		plan[i] = j;
		int nsc = calcScore(plan, c, s);
		if (nsc > sc) {
			sc = nsc;
		}
		else {
			plan[i] = old;
		}
	}

	for (int i = 0; i < 365; i++) {
		cout << plan[i] + 1 << endl;
	}
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        int start = Integer.parseInt(str[0]);
        int end = Integer.parseInt(str[1]);
        int ans = 0;
        for(int i = start; i <= end; i++){
            if(isValid(i)){
                ans++;
            }
        }
        System.out.println(ans);
    }
    
    static boolean isValid(int num){
        int digit1 = num % 10;
        int tmp2 = num - digit1;
        int digit2 = tmp2/10 % 10;
        int tmp3 = tmp2 - digit2 * 10;
        int digit3 = tmp3/100 % 10;
        int tmp4 = tmp3 - digit3 * 100;
        int digit4 = tmp4/1000 % 10;
        int tmp5 = tmp4 - digit4 * 1000;
        int digit5 = tmp5/10000 % 10;
        if(digit1 == digit5 & digit2 == digit4){
            return true;
        }else{
            return false;
        }
    }
   
}


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

using namespace std;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  swap(a, b);
  swap(c, d);
  cout << ((d + a - 1) / a <= (b + c - 1) / c ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int n, S, G, d;
string line[31];

bool solve(){
  int row = S;
  for(int i = 0 ; i < d ; i++){
    if(line[i][row] == '1') row++;
    else if(line[i][row-1] == '1') row--;
  }
  if(row == G) return true;
  else return false; 
}

int main(){
  while(cin >> n, n){
    //    if(n == 0) break;
    cin >> S >> G >> d;
    for(int i = 0 ; i < d ; i++){      
      cin >> line[i];
      line[i] = "0" + line[i] + "0";
    }
    
    if(solve()){
      cout << 0 << endl;
      continue;
    }
    
    bool flag = false;
    for(int i = 0 ; i < d ; i++){
      for(int j = 1 ; j < n ; j++){
	if(line[i][j] == '1' ||
	   line[i][j-1] == '1' || line[i][j+1] == '1') continue;
	line[i][j] = '1';
	if(solve()){
	  flag = true;
	  cout << i+1 << ' ' << j << endl;
	  i = d, j = n;
	}
	else line[i][j] = '0';
      }
    }
    if(!flag) cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<int> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(ALL(a), greater<int>());
    sort(ALL(b), greater<int>());
    sort(ALL(c), greater<int>());

    vector<int> bc(y * z);
    rep(i, y){
        rep(j, z){
            bc[i*z+j] = b[i] + c[j];
        }
    }
    sort(ALL(bc), greater<int>());

    vector<int> abc(x * k);
    rep(i, x){
        rep(j, min(k, y * z)){
            abc[i*k+j] = a[i] + bc[j];
        }
    }
    sort(ALL(abc), greater<int>());

    rep(i, k){
        cout << abc[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 32504
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>



int main()

{
    int n;
    scanf("%d",&n);
    printf("%d\n",n+n*n+n*n*n);



    return 0;
}


/*
presented by codeRumi
thanks for watching & being here,thank me later... :)
*/



Measured memory_bytes: 1736
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main(int argc, char const *argv[]) {

  char s[5];
  int n, count=0, ret;

  ret = scanf("%d", &n);
  sprintf(s, "%d", n);
  for(int i=0; i<4; i++){
    if(s[i]=='2') count++;
  }
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

llong x;

bool read()
{
	if (scanf("%lld", &x) != 1)
		return false;

	return true;
}

void solve()
{
	llong ans = 2ll * (x / 11ll);
	x %= 11;
	if (x > 0) x -= 6, ++ans;
	if (x > 0) x -= 5, ++ans;
	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)


constexpr lint mod = 1000000007;
vector<vector<lint>> matmul(const vector<vector<lint>> &A, const vector<vector<lint>> &B)
{
    int H = A.size(), W = B[0].size(), K = B.size();
    vector<vector<lint>> C(H, vector<lint>(W));
    REP(i, H) REP(j, W) REP(k, K) (C[i][j] += A[i][k] * B[k][j]) %= mod;
    return C;
}
vector<lint> matmul(const vector<vector<lint>> &A, const vector<lint> &v)
{
    vector<lint> res(A.size());
    REP(i, A.size()) REP(j, v.size()) (res[i] += A[i][j] * v[j]) %= mod;
    return res;
}
vector<vector<lint>> matpower(vector<vector<lint>> X, lint n)
{
    vector<vector<lint>> res(X.size(), vector<lint>(X.size()));
    REP(i, res.size()) res[i][i] = 1;
    while (n)
    {
        if (n & 1) res = matmul(res, X);
        X = matmul(X, X); n >>= 1;
    }
    return res;
}

int N, M;
vector<lint> X;


int main()
{
    vector<vector<lint>> trans{
        {1, 1, 2, 1},
        {1, 1, 2, 1},
        {1, 0, 1, 1},
        {1, 0, 0, 1}};

    cin >> N >> M;
    X.resize(M + 1);
    REP(i, M) cin >> X[i + 1];
    X.push_back(N);

    vector<lint> st{1, 0, 0, 0};
    FOR(i, 1, X.size())
    {
        st = matmul(matpower(trans, X[i] - X[i - 1]), st);
        st[0] = 0;
    }
    cout << st[1] << endl;
}


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

#define MAX 36

typedef struct card{
  char mark;
  int value;
}CARD;

void swap(CARD *x,CARD *y){

  CARD temp;
  temp=*x;
  *x=*y;
  *y=temp;

}


void bubbleSort(CARD *A,int n){
  int i,j;
  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(A[j].value < A[j-1].value) swap(&A[j],&A[j-1]);
    }
  }

}

void selectionSort(CARD *A,int n){
  int i,j;
  int minj;
  int flag;
 
    for ( i = 0 ; i < n ; i++ ) {
        minj = i;
        flag = 0;
        for ( j = i ; j < n ; j++ ) {
            if ( A[j].value < A[minj].value ) {
                minj = j;
                flag = 1;
            }
        }
        if (flag) {
            swap(&A[i], &A[minj]);
        }
    }
}
void printStable(CARD *A1, CARD *A2, int N)
{
  int i;
  int cnt = 0;
  for ( i = 0 ; i < N ; i++ ) {
    if (A1[i].mark == A2[i].mark) {
      cnt++;
    }
    }
    printf("%s\n", ((cnt == N) ? "Stable" : "Not stable"));
}

int main(){

  CARD R1[MAX];
  CARD R2[MAX];
  
  int i,j,n;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf(" %c%d",&R1[i].mark,&R1[i].value);
    R2[i]=R1[i];
  }
  
  bubbleSort(R1,n);

  for(i=0; i<n; i++){
    printf("%c%d",R1[i].mark,R1[i].value);
    if(i!=n-1)printf(" ");
  }
  printf("\n");

  printf("Stable\n");

  selectionSort(R2,n);

  for(i=0; i<n; i++){
    printf("%c%d",R2[i].mark,R2[i].value);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  printStable(R1, R2, n);
  
  

  return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 2500;
const int INF = 1 << 30;

int main(){
    int N,M,P;
    vector<pair<int,int> > G[MAX];
    

    cin >> N >> M >> P;
    for(int i = 0;i < M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        G[a-1].push_back(pair<int,int>(b-1,-(c-P)));
    }


    priority_queue<pair<int,int> > q;
    int v = 0;
    int minPath[MAX];
    
    for(int i = 0;i < N;i++)minPath[i] = INF;
    minPath[0] = 0;

    for(int i = 0;i < N * 2;i++){
        for(int j = 0;j < N;j++){
            for(int k = 0;k < G[j].size();k++){
                if(minPath[j] != INF && minPath[G[j][k].first] > minPath[j] + G[j][k].second){
                    minPath[G[j][k].first] = minPath[j] + G[j][k].second;

                    if(i >= N){
                        minPath[G[j][k].first] = -INF;
                    }
                }
            }
        }
    }

    if(minPath[N-1] == -INF)cout << -1 << endl;
    else cout << max(0,-minPath[N-1]) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[300008], sum1[100008], sum2[100008];

int main() {
	cin >> n;
	for(ll i = 0; i < 3*n; i++){cin >> a[i];}
	sum1[0] = 0;
	sum2[n] = 0;
	priority_queue<ll, vector<ll>, greater<ll>> q1;
	priority_queue<ll> q2;
	
	for(ll i = 0; i < n; i++){sum1[0] += a[i]; q1.push(a[i]);}
	for(ll i = 2*n; i < 3*n; i++){sum2[n] += a[i]; q2.push(a[i]);}
	//
	for(ll i = 1; i <= n; i++){
		ll min = q1.top();
		if(a[n-1+i] > min){sum1[i] = sum1[i-1]+(a[n-1+i]-min); q1.pop(); q1.push(a[n-1+i]);}
		else{sum1[i] = sum1[i-1];}
	}
	for(ll i = 1; i <= n; i++){
		ll max = q2.top();
		if(a[2*n-1-(i-1)] < max){sum2[n-i] = sum2[n-i+1]+(a[2*n-1-(i-1)] - max); q2.pop(); q2.push(a[2*n-1-(i-1)]);}
		else{sum2[n-i] = sum2[n-i+1];}
	}
	
	ll best = sum1[0]-sum2[0];
	for(ll i = 1; i <= n; i++){best = max(sum1[i]-sum2[i], best);}
	//for(ll i = 0; i <= n; i++){cout << sum1[i];} cout << endl;
	//for(ll i = 0; i <= n; i++){cout << sum2[i];} cout << endl;
	cout << best;
	return 0;
}

Measured memory_bytes: 5876
import itertools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a, b, c in itertools.product(range(A + 1), range(B + 1), range(C + 1)):
    if 500 * a + 100 * b + 50 * c == X:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int num[3];
  rep(i,3){
    cin >> num[i];
  }

  rep(i,1){
    int x = 100*num[i]+10*num[(i+1)%3]+num[(i+2)%3];
    if(x%4==0){
      puts("YES");
      return 0;
    }
  }

  puts("NO");
  return 0;
}

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

int main(void){
	char s[11],t[12];
	int i=0,j=0,k=0,flag=0;

	scanf("%s",s);
	scanf("%s",t);

	while(s[i]!=0){
		i++;
	}
	if( i <1 || i >10 ){
		flag++;
	}

	while(t[j]!=0){
		j++;
	}
	if( j!=i+1 ){
		flag++;
	}

	while(s[k]!=0){
		if(s[k]!=t[k]){
			flag++;
		}
		k++;
	}

	if(flag==0){
		printf("Yes");
	}else{
		printf("No");
	}

	return 0;
}


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

string s;

int main(){
	cin >> s;
	if(s.size()&1){
		cout << "No\n";
		return 0;
	}
	for(int i=0;i<s.size();i+=2){
		if(s[i] != 'h' || s[i+1] != 'i'){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define LD long double
using namespace std;
const int MAXN=5e5+10;
int n; 
int read(){int sss=0,fff=1;char ccc=getchar();while(ccc<'0'||ccc>'9'){if(ccc=='-') fff=-1;ccc=getchar();}while(ccc>='0'&&ccc<='9'){sss=sss*10+ccc-'0';ccc=getchar();}return sss*fff;}
void solve()
{
	int ans=0;
	n=read();
	for(int i=1;i<n;i++)
		if(i!=n-i) ans++;
	printf("%d\n",ans/2);
}
int main()
{
//	freopen("123.in","r",stdin);
//	freopen("123.out","w",stdout);
	int T=1;
	while(T--)
		solve();
	return 0;
}

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

int n;
int ad_list[101][101];

void print(){
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            cout << ad_list[i][j];
            if(j==n)cout << "\n";
            else cout << " ";
        }
    }
}

int main(){
    cin  >> n;
    for(int i=1;i<n+1; i++){
        for(int j=1; j<n+1; j++){
            ad_list[i][j]=0;
        }
    }
    int v,k, in;
    for(int i=1; i<n+1; i++){
        cin >> v >> k;
        for (int j=0;j<k;j++){
            cin >> in;
            ad_list[v][in]=1;
        }
    }
    print();
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

template <typename T>
struct edge {
	int from, to;
	T cost;
	edge (int f, int t, T c) : from(f), to(t), cost(c) {}
};

template <typename T>
struct BellmanFord {
	T INF;
	int V;
	vector<edge<T>> edges;
	vector<T> d;
	BellmanFord(vector<edge<T>> e, int v, T inf) : edges(e), V(v), INF(inf), d(v, inf) {}

	bool find_negative_loop() {
		for (int i = 0; i < V; ++i) { d[i] = 0; }
		for (int i = 0; i < V; ++i) {
			for (auto e : edges) {
				if (d[e.to] > d[e.from] + e.cost) {
					if (i == V - 1) { return true; }
					d[e.to] = d[e.from] + e.cost;
				}
			}
		}
		return false;
	}

	void run(int s) {
		if (find_negative_loop()) { return; }
		for (int i = 0; i < V; ++i) { d[i] = INF; }
		d[s] = 0;

		for (int i = 0; i < V; ++i) {
			bool update = false;
			for (auto e : edges) {
				if (d[e.from] == INF || d[e.to] <= d[e.from] + e.cost) {
					continue;
				}
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
			if (!update) { break; }
		}
	}
};

void f(int s, const vector<vector<int>>& g, vector<bool>& memo) {
	deque<int> que;
	que.push_back(s);
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		if (memo[u]) { continue; }
		memo[u] = true;
		for (auto v : g[u]) {
			if (!memo[v]) { que.push_back(v); }
		}
	}
}

int main() {
	int N, M; Int P;
	cin >> N >> M >> P;
	vector<vector<int>> G(N), rG(N);
	vector<edge<Int>> E;
	for (int i = 0; i < M; ++i) {
		int a, b; Int c;
		cin >> a >> b >> c;
		--a; --b;
		G[a].push_back(b);
		rG[b].push_back(a);
		E.emplace_back(a, b, -(c - P));
	}

	vector<bool> s(N, false), t(N, false);
	f(0, G, s);
	f(N - 1, rG, t);
	for (int i = 0; i < N; ++i) { s[i] = s[i] && t[i]; }
	vector<edge<Int>> edges;
	for (auto e : E) {
		if (s[e.from] && s[e.to]) { edges.push_back(e); }
	}
	BellmanFord<Int> bf(edges, N, 1e10);
	if (bf.find_negative_loop()) {
		cout << -1 << endl;
	} else {
		bf.run(0);
		cout << max(Int(0), -bf.d[N - 1]) << endl;
	}

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    cin >> s;
    int n = (int)s.length();
    int ans = 0;
    char mae;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans ++ ;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int i = 1;
  int ans = 0;
  while(A*i%B != 0){
    if(A*i%B == C){
      ans++;
      break;
    }
    i++;
  }
  if(ans>0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
h,w = map(int,raw_input().split())
c = []
dist = []
for i in xrange(10):
    c.append(map(int,raw_input().split()))
    dist.append([100000000]*10)
a = []
for i in xrange(h):
    a.append(map(int,raw_input().split()))

for i in xrange(10):
    for j in xrange(10):
        dist[i][j] = c[i][j]
for k in xrange(10):
    for i in xrange(10):
        for j in xrange(10):
            if dist[i][j] > dist[i][k] + dist[k][j]:
                dist[i][j] = dist[i][k] + dist[k][j]

cost = 0
for i in xrange(h):
    for j in xrange(w):
        if a[i][j] != -1:
            cost += dist[a[i][j]][1]
print cost

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

int main()
{
    string s,t;
    cin>>s>>t;
    int sl= s.length();
    int tl = t.length();
    int mini=1005;
    for(int i=0;i<=sl-tl;i++)
    {
       int k=0;
       int count=0;
        for(int j=i;j<=sl && k<tl;j++)
        {
            if(t[k]!=s[j])
            {
               count++;
            }
            k++;
        }
        // cout<<"count after "<<i<<" "<<count<<endl;
        mini = min(count,mini);
    }
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
  
using namespace std;

/********** TEMPLATE STARTS HERE ***********/
  
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
  
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
  
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
 
/*********** TEMPLATE ENDS HERE *************/

vi dr;
vi st;

main()
{
	IOS
	
	int n, x;
	cin >> n >> x;
	
	dr.pb(x);
	st.pb(x);
	
	for(int i = 1; i <= n; i++)
	{
		int p;
		cin >> p;
		if(p > x)
			dr.pb(p);
		else
			st.pb(p);
	}
	
	sort(all(st));
	sort(all(dr));
	
	int ans = 0;
	
	for(int i = 1; i < dr.size() && ans != 1; i++)
	{
		int dist = dr[i] - dr[i - 1];
		ans = gcd(ans, dist);
	}
	
	for(int i = 1; i < st.size() && ans != 1; i++)
	{
		int dist = st[i] - st[i - 1];
		ans = gcd(ans, dist);
	}
	
	cout << ans;
	
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll x, y, z, n;
vector<ll> ans;
int main() {
	cin >> x >> y >> z >> n;
	vector<ll> a(x), b(y), c(z), d;
	REP(i, x)cin >> a[i];
	REP(i, y)cin >> b[i];
	REP(i, z)cin >> c[i];
	REP(i, x) {
		REP(j, y) {
			d.push_back(a[i] + b[j]);
		}
	}
	sort(ALL(d),greater<ll>());
	REP(i, z) {
		REP(j, min((ll)d.size(), n)) {
			ans.push_back(c[i] + d[j]);
		}
	}
	sort(ALL(ans), greater<ll>());
	REP(i, n)cout << ans[i] << endl;
}




Measured memory_bytes: 43112
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll H,N;
  cin>>H>>N;
  vector<ll>A(N);
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  if(H<=sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1024
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N, K;
	LL ans = 0;
	cin >> N >> K;

	FOR(i, 0, N) {
		if (i == 0) {
			ans = K;
		}
		else {
			ans *= (K - 1);
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
badSign = set()
oldroute = []

for i in range(M):
  nowRoute = list(map(int, input().split()))
  if nowRoute == oldroute:
    badSign.add(nowRoute[0])
    badSign.add(nowRoute[1])
  else:
    if Hlist[nowRoute[0]-1] < Hlist[nowRoute[1]-1]:
      badSign.add(nowRoute[0])
    elif Hlist[nowRoute[0]-1] > Hlist[nowRoute[1]-1]:
      badSign.add(nowRoute[1])
    else:
      badSign.add(nowRoute[0])
      badSign.add(nowRoute[1])
    oldroute = nowRoute
print(N-len(badSign))

Measured memory_bytes: 20132