akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int deg[n], dp[n]; for (int i = 0; i < n; i++) {
        deg[i] = 0;
        dp[i] = 0;
    }
    vector<int> adj[n];
    int m; cin >> m;
    while (m--) {
        int x, y; cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        deg[y]++;
    }
    queue<int> q;
    for (int i = 0; i < n; i++) if (deg[i] == 0) q.push(i);
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (int i = 0; i < adj[x].size(); i++) {
            int x2 = adj[x][i];
            dp[x2] = max(dp[x2], dp[x] + 1);
            if (--deg[x2] == 0) {
                q.push(x2);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;
constexpr int64 INF = 1LL << 60;

struct edge {
    int from;
    int to;
    int64 score;
    edge() {}
    ~edge() {}

    edge(int a, int b, int64 c): from(a), to(b), score(c) {}
};

int N, M;
vector<edge> g, rg[1000];

int main() {
    cin >> N >> M; for (int j = 0; j < M; ++j) {
        int a, b, c; cin >> a >> b >> c; --a; --b;
        g.emplace_back(a, b, c);
        rg[b].emplace_back(-1, a, c);
    }

    bool reachable[1000]; fill(reachable, reachable+N, false);
    queue<int> q;
    q.push(N-1);
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (const edge& e: rg[x]) {
            if (!reachable[e.to]) {
                reachable[e.to] = true;
                q.push(e.to);
            }
        }
    }

    int64 max_score[1000]; fill(max_score, max_score+N, -INF);
    max_score[0] = 0;
    
    bool updated = true;
    bool updated_at[1000];
    for (int j = 0; updated && j <= N; ++j) {
        fill(updated_at, updated_at+N, false);
        updated = false;
        for (const edge& e : g) {
            if (max_score[e.from] + e.score > max_score[e.to]) {
                updated = true;
                updated_at[e.to] = true;
                max_score[e.to] = max_score[e.from] + e.score;
            }
        }
    }

    bool inf = updated;
    if (inf) {
        inf = false;
        for (int j = 0; j < N; ++j) {
            if (updated_at[j] && reachable[j]) {
                inf = true;
            }
        }
    }

    if (inf) {
        cout << "inf" << endl;
    } else {
        cout << max_score[N-1] << endl;
    }
    return 0;
}


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

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

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  ll n, i;
  cin >> n;
  vector<ll> T(n);
  rep(i, n) cin >> T[i];
  ll  m = T[0];
  for(i=1; i<n; i++){
    m = lcm(m, T[i]);
  }
  cout << m << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpi = vector<pii>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
 
    int n;
    cin >> n;
    cout << !n << "\n";

    return 0;
}

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

int main(void)
{
	int Acount = 0, Bcount = 0, Ccount = 0, flag = 0;
	char A[110], B[110], C[110];
	scanf("%s", A);  scanf("%s", B);  scanf("%s", C);

	while (flag != 4)
	{
		switch (flag)
		{
		case 0:
			if (Acount == strlen(A)) { printf("A"); flag = 4; break; }
			if (A[Acount] == 'a') { flag = 0; }
			else if (A[Acount] == 'b') { flag = 1; }
			else { flag = 2; }
			Acount++;
			break;
		case 1:
			if (Bcount == strlen(B)) { printf("B"); flag = 4; break; }
			if (B[Bcount] == 'a') { flag = 0; }
			else if (B[Bcount] == 'b') { flag = 1; }
			else { flag = 2; }
			Bcount++;
			break;
		case 2:
			if (Ccount == strlen(C)) { printf("C"); flag = 4; break; }
			if (C[Ccount] == 'a') { flag = 0; }
			else if (C[Ccount] == 'b') { flag = 1; }
			else { flag = 2; }
			Ccount++;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 128
x, y = map(int, input().split())

l = [4, 6, 9, 11]

if x == 2 or y == 2:
    print('No')
elif (l.count(x) > 0 and l.count(y) == 0) or (l.count(x) == 0 and l.count(y) > 0):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())

sum = 0

if A+B<=2*C:
    sum = (A * X) + (B * Y)
else:
    if X<=Y:
        y = Y - X
        sum += X * 2 * C
        if B<=2*C:
            sum += B * y
        else:
            sum += C * 2 * y
    else:
        x = X - Y
        sum += Y * 2 * C
        if A<=2*C:
            sum += A * x
        else:
            sum += C * 2 * x

print(sum)
    





Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int a,b,c;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	a=read();
	b=read();
	c=read();
	printf("%d",min((c+a-1)/a,(c+b-1)/b));
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int X;
  scanf("%d", &X);
  
  if (X == 3) {
    printf("YES");
  } else if (X == 5) {
    printf("YES");
  } else if (X == 7) {
    printf("YES");
  } else {
    printf("NO");
  }
  
  return 0;
  
}


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

int main() {
  int x;
  cin >> x;
  int maxn = x / 100, minn = x / 105;
  for (int i = minn; i <= maxn; i++) {
    int r = x - i * 100;
    if (r >= 0 && r <= 5 * i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x -= b*(x / b);
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

A = [[str(input())] for _ in range(h)]

for i in range(h):
    A[i].insert(0, '#')
    A[i].append('#')

A.insert(0, ['#'*(w+2)])
A.append(['#'*(w+2)])

for j in range(h+2):
    print(''.join(A[j]))

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

int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i = 0; i < m; i++)
  {
    cin >> a[i];
  }
  int ans = n;
  for(int i = 0; i < m; i++)
  {
    ans -= a[i];
  }
  if(ans >= 0)
  {
    cout << ans << endl;
  }else
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main(){
	string s1;
	string s2;
	string s3;
	cin>>s1>>s2>>s3;
	s1[0]=s1[0]-32;
	cout<<s1[0];
		s2[0]=s2[0]-32;
	cout<<s2[0];
		s3[0]=s3[0]-32;
	cout<<s3[0];
	
	
}

Measured memory_bytes: 256
#!/usr/bin/perl -w

while(<>) {
    chomp;
    @s = split //, $_;
}

$dup = 0;
foreach (@s) {
    $e{$_}++;
    if($e{$_} >= 2) {
        $dup = 1;
    }
}

if($dup) {
    print "no\n";
} else {
    print "yes\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

const int N = (int)(2e5 + 500);

int x[N], y[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifndef _LOCAL          
    #endif // _LOCAL

    int n;
    int mx1, mx2, mx3, mx4;

    mx1 = mx2 = mx3 = mx4 = -2e9;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        mx1 = max(mx1, -x[i] - y[i]);
        mx2 = max(mx2, -x[i] + y[i]);
        mx3 = max(mx3, x[i] - y[i]);
        mx4 = max(mx4, x[i] + y[i]);
    }

    int ans = -2e9;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, x[i] + y[i] + mx1);
        ans = max(ans, x[i] - y[i] + mx2);
        ans = max(ans, -x[i] + y[i] + mx3);
        ans = max(ans, -x[i] - y[i] + mx4);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


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

	int N;
	cin >> N;

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

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


	ll ans = 0;
	for (int i = 0; i < N-1; ) {
		ll temp = 0;
		for (int j = i + 1; j < N; j++) {
			if (S[i] == S[j]) {
				temp++;
			}
			else {
				ans += ((temp + 1)*temp) / 2;
				i = j;
				break;
			}

			if (j == N - 1) {

				ans +=( (temp + 1)*temp) / 2;
				i = j;
			}
		}
	}

	cout << ans;


}




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

int main() {

        int n;
        std::cin >> n;

        std::vector<int> x(n);
        std::vector<int> y(n);
        std::vector<int> h(n);

        for (auto i = 0; i < n; ++i) {
                std::cin >> x[i] >> y[i] >> h[i];
        }

        for (auto cx = 0; cx <= 100; ++cx) {
                for (auto cy = 0; cy <= 100; ++cy) {
                        auto infH = 0;
                        for (auto an = 0; an < n; ++an) {
                                if (h[an] != 0) {
                                        if (infH == 0) {
                                                infH = h[an] + std::abs(cx - x[an]) + std::abs(cy - y[an]);
                                        }
                                        else {
                                                auto infHn = h[an] + std::abs(cx - x[an]) + std::abs(cy - y[an]);

                                                if (infH != infHn) {
                                                        infH = -1;
                                                        break;
                                                }
                                        }
                                }
                        }
                        if (infH == -1) {
                                continue;
                        }

                        for (auto an = 0; an < n; ++an) {
                                if (h[an] == 0 && infH - std::abs(cx - x[an]) - std::abs(cy - y[an]) > 0) {
                                        infH = -1;
                                        break;
                                }
                        }
                        if (infH == -1) {
                                continue;
                        }
                        std::cout << cx << " " << cy << " " << infH << std::endl;
                        return 0;
                }
        }
        return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int pop(void);
void push(int);

int main(){
  int x, y, top, n[101];
  char s[100];
  top = 0;

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      x = n[top];
      y = n[top-1];
      top--;
      n[top] = x+y;
    }
 else if(s[0] == '-'){
      y = n[top];
      x = n[top-1];
      top--;
      n[top] = x-y;
    }
 else if(s[0] == '*'){
      x=n[top];
      y=n[top-1];
      top--;
      n[top] = x*y;
    }
 else{
      top++;
      n[top] = atoi(s);
    }
  }
  printf("%d\n",n[top]);
  return 0;
}

Measured memory_bytes: 0
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){
    int n,c;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    REP(i,n){
        if(a[i] % 2 == 0){
            while(a[i] % 2 == 0){
                a[i] /= 2;
                c++;
            }
        }
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector> 
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n;
int main()
{
	scanf("%d", &n);
	{
		multiset<int>sot;
		for (int i = 1; i <= n; ++i)
		{
			int x;
			scanf("%d", &x);
			sot.insert(x);
		}
		bool flag = 1;
		int m;
		scanf("%d", &m);
		while (m--)
		{
			int x; scanf("%d", &x);
			if (!sot.count(x))
			{
				flag = 0;
				break;
			}
			sot.erase(sot.find(x));
		}
		puts(flag ? "YES" : "NO");
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】


【数据】


*/

Measured memory_bytes: 9600
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    list<int> A;
    string s;
    int tmp;
    REP(i, n){
        cin >> s;
        if(s == "insert"){
            cin >> tmp;
            A.push_front(tmp);
        }else if(s == "delete"){
            cin >> tmp;
            for(auto itr = A.begin(); itr != A.end(); ++itr){
                if(*itr == tmp){
                    A.erase(itr);
                    break;
                }
            }
        }else if(s == "deleteFirst") A.pop_front();
        else if(s == "deleteLast") A.pop_back();
    }

    vector<int> B;
    for(auto itr = A.begin(); itr != A.end(); ++itr){
        B.push_back(*itr);
    }
    REP(i, B.size()){
        if(i != B.size() - 1) cout << B[i] << " ";
        else cout << B[i] << endl;
    }


    return 0;
}


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

int main(){
	long long int a,b,x,y,z,st;
	
	while(cin >> a >> b,a,b){
		x=max(a,b);
		y=min(a,b);
		st=0;
		while(1){
			if(y==0) break;
			z=x%y;
			x=y;
			y=z;
			st++;
		}
		
		
		cout << x << ' ' << st << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define inf 0x40000000
#define reps(i, n) for(size_t i = 0; i < (size_t)(n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    reps(i, n) { cin >> v.at(i); }
    sort(v.begin(), v.end());
    int min = inf, c;
    for(int i = v.at(0); i <= v.at(n - 1); ++i) {
        c = 0;
        for(int j = 0; j < v.size(); ++j) {
            c += (v.at(j) - i) * (v.at(j) - i);
        }
        min = ::min(min, c);
    }
    if(min == inf)
        min = 0;
    cout << min << "\n"s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
#define yuri puts("niconiconi")
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
int dp[42][450][450],n=read(),ma=read(),mb=read(),a[55],b[55],c[55];

int main(){
int i,j,k;
memset(dp,0x3f,sizeof dp);
for (i=0;i<n;++i){
  a[i]=read();
  b[i]=read();
  c[i]=read();
  }
dp[0][0][0]=0;
for (i=0;i<n;++i){
  for (j=0;j<=400;++j){
    for (k=0;k<=400;++k){
      if (dp[i][j][k]^inf){
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
	    }
	  }
    }
  }
int ans=inf;
for (i=1;i<=400;++i){
  for (j=1;j<=400;++j){
    if (i*ma==j*mb){
      ans=min(ans,dp[n][j][i]);
	  }
    }
  }write(ans>=inf?-1:ans);
}

Measured memory_bytes: 33408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		sc.close();
		
		if((N%500) <= A)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == 5 && B ==5 && C == 7){
    cout << "YES" << endl;
  }
  else if(A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
  }
  else if (A == 5 && B == 7 && C == 5) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    ans=0
    for i in a:b
        s=string(i)
        if s[1]==s[5] && s[2]==s[4]
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 122676
#include<iostream>
#include<stdlib.h>
#include<cstdio>
using namespace std;

int top,S[1010];

void push(int x) {
    S[++top]=x;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a,b;
    char s[110];
    top = 0;
    while(cin>>s) {

        if(s[0]=='+') {
            a=pop();
            b=pop();
            push(a+b);
        } else if(s[0]=='-') {
            a=pop();
            b=pop();
            push(b-a);
        } else if(s[0]=='*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }

    }
    cout<<pop()<<endl;
    
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};

int main() {
    int n, m; cin >> n >> m;
    int a[m], b[m];
    rep(i, m) cin >> a[i] >> b[i];
    int c = 0;
    rep(i, m) {
        UnionFind uni(n + 1);
        rep(j, m) {
            if (i == j) continue;
            uni.connect(a[j], b[j]);
        }
        set<int> se;
        rrep(k, 1, n + 1) {
            //cout << uni.root(k) << " ";
            se.insert(uni.root(k));
        }
        //cout << endl;
        if (se.size() >= 2) {
            c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d

//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)

//method1
//memoization
ll dp[1000][100001];
ll maxVal(int w[], ll v[], int n, int W)
{
  //  cout<<wtSum<<" "<<n<<endl;
    if(n==0 || W==0) return 0;
    //if(W<0) return INT_MIN;
    if(dp[n][W]!=-1) return dp[n][W];

    
    //if( W > wtSum+w[n-1]); 
    if(W-w[n-1]>=0)
    return dp[n][W]=max( maxVal(w,v,n-1,W), v[n-1]+maxVal(w,v,n-1,W-w[n-1]) ); 
    else return dp[n][W]= maxVal(w,v,n-1,W);

}

//method 2
//table
// ll dptable(int w[], ll v[], int n, int W, int S)
// {
//     ll dp[n+1][W+1];

//     memset(dp,0,sizeof(dp));

//     FOR(i,1,n+1){
//         FOR(j,1,W+1){
//             if(w[i-1]<=j) {
//                 dp[i][j] = max( dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]] );  
//             } 
//             else dp[i][j] = dp[i-1][j];
//         }
//     }
//     return dp[n][W];
// }

//1
int main()
{
    fastio;
    int t=1; //cin>>t;
    while(t--)
    {
        int n,W; cin>>n>>W;

        int w[n];
        ll v[n];

        FOR(i,0,n) cin>>w[i]>>v[i];
        memset(dp,-1,sizeof(dp));
        cout<<maxVal(w,v,n,W);
        //cout<<dptable(w,v,n,W, 0);
    }
    return 0;
}   

Measured memory_bytes: 784900
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    members = []
    sales  = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in members:
            members.append(e)
            sales[e] = 0
        sales[e] += int(p) * int(q)
    ret = [member for member in members if sales[member] >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")

Measured memory_bytes: 7752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	pair<int,int> vp[N]; int x[N];
	rep(i,0,N){
		cin>>x[i]; x[i]--;
        vp[i] = {x[i], i};
	}
	sort(vp, vp+N);
	int a[N*N];
	rep(i,0,N*N) a[i] = -1;
	rep(i,0,N) a[vp[i].first] = vp[i].second;
	int k = 0;
	rep(i,0,N){
		rep(j,0,vp[i].second){
			while(a[k] != -1) k++;
			a[k] = vp[i].second;
		}
	}
	k = N * N - 1;
	for(int i = N-1; i >= 0; i--){
		for(int j = N-1; j > vp[i].second; j--){
			while(a[k] != -1) k--;
			a[k] = vp[i].second;
		}
	}
	int cnt[N] = {};
	rep(i,0,N*N){
		cnt[a[i]]++;
		if(cnt[a[i]] == a[i] + 1){
            if(x[a[i]] != i){ cout<<"No"<<endl; return 0; }
        }a[i]++;
	}
	cout<<"Yes"<<endl;
	print(a,,N*N);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string m="MARCH";
    int n; cin>>n;
    vector<string>s(n);
    vector<int>x(5,0);
    rep(i,n){
        cin>>s[i];
        rep(j,5){
            if(s[i][0]==m[j])x[j]++;
        }
    }
    ll ans=0;
    for(int i=0; i<5; ++i){
        for(int j=i+1; j<5; ++j){
            for(int k=j+1; k<5; ++k){
                ans+=(ll)x[i]*x[j]*x[k];
            }
        }
    }
    cout<<ans<<endl;
}

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

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
#define ll long long

using namespace std;

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

int main(void){
	int n;
	scanf("%d", &n);

	int temp = (int) sqrt((double) n);

	printf("%d\n", temp*temp);

	return 0;
}


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

int main(){
    int n,key1,key2,i,j;scanf("%d%d%d",&n,&key1,&key2);
    int a[n+1][n+1]/*最短距離の行列*/,ans[n+1];

    for(i=1;i<=n-1;i++){
        ans[i]=0;
    }

    for(i=1;i<=n;i++){
        for(j=1;j<i;j++){
            if(i>=key2 && j<=key1){//いずれもkeyの外
                a[i][j]=i-j-(key2-key1-1);
            }else if(((key1<=i && i<=key2) && (j<=key1)) && (i-j>=key1+key2-i-j+1)){//大きい方がkeyの中
                a[i][j]=key1+key2-i-j+1;
            }else if(((key1<=j && j<=key2) && (i>=key2)) && i-j>=j-key1-key2+i+1){//小さい方がkeyの中
                a[i][j]=j-key1-key2+i+1;
            }else if(key1<=j && i<=key2 && i-j>=key2+j-i-key1+1){//どちらもkeyの中
                a[i][j]=key2+j-i-key1+1;
            }else{//それ以外
                a[i][j]=i-j;
            }
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<i;j++){
            ans[a[i][j]]++;
        }
    }
    for(i=1;i<=n-1;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 15744
// Problem : D - Caracal vs Monster
// Contest : AtCoder - AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define cs(ans) setprecision(10)<<fixed<<ans

 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359;
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll H;
	cin>>H;
	ll ans=0,mul=1;
	while(H!=0)
	{
		ans+=mul;
		H/=2;
		mul*=2;
	}
	cout<<ans<<endl;
	return 0;
	//CHECK CORNER CASES
}
// read the question correctly (ll vs int)
// template by bqi343




Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {


  val s = readLine()

  def solve() = {
    val map = Map(
      "MON" -> 6,
      "TUE" -> 5,
      "WED" -> 4,
      "THU" -> 3,
      "FRI" -> 2,
      "SAT" -> 1,
      "SUN" -> 7
    )
    map(s)
  }

  println(solve())

}



Measured memory_bytes: 55004
import java.util.Scanner;

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

        for (long m = 1; m * m <= n; m++) {
            if (n % m == 0) {
                if (m > 1) {
                    if (n / (m - 1) == n % (m - 1))
                        ans += m - 1;
                }
                if (n / m > 1) {
                    if (n / (n / m - 1) == n % (n / m - 1))
                        ans += n / m - 1;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23764
#define DEBUG 0

/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2/24/2019, 9:06:24 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000007;

int N;
ll A[3];
ll l[10];

int main()
{
  cin >> N >> A[0] >> A[1] >> A[2];
  for (auto i = 0; i < N; i++)
  {
    cin >> l[i];
  }
  ll ans = infty;
  for (auto i = 0; i < (1 << 2 * N); i++)
  {
    vector<ll> V[3];
    for (auto j = 0; j < N; j++)
    {
      bool x = (i >> (2 * j)) & 1;
      bool y = (i >> (2 * j + 1)) & 1;
      if (x && y)
      {
        V[0].push_back(l[j]);
      }
      else if (!x && y)
      {
        V[1].push_back(l[j]);
      }
      else if (x && !y)
      {
        V[2].push_back(l[j]);
      }
    }
    bool ok = true;
    for (auto j = 0; j < 3; j++)
    {
      if (V[j].empty())
      {
        ok = false;
        break;
      }
    }
    if (!ok)
    {
      continue;
    }
    ll t = 0;
    for (auto j = 0; j < 3; j++)
    {
      /*
#if DEBUG == 1
      cerr << "j = " << j << ": ";
      for (auto x : V[j])
      {
        cerr << x << " ";
      }
      cerr << endl;
#endif
*/
      ll sum = 0;
      for (auto x : V[j])
      {
        sum += x;
      }
      t += ((ll)V[j].size() - 1) * 10 + abs(A[j] - sum);
    }
    ans = min(ans, t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

if N == 2 or M == 2:
    ans = 0
elif N == 1 and M == 1:
    ans = 1
elif N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2
else:
    ans = (N-2) * (M-2)
print(ans)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
long N,Q;
long X,Y;
char S[200010],S2[200010],T[200010],D[200010];


long sub11(long x,long y);
long sub12(long x,long y);
long sub2(long x);

int main(){
  cin >> N >> Q >> S2;
  for (int i=1;i<=Q;i++){
    cin >> T[i] >> D[i];
  }
  for (int i=1;i<=N;i++){
    S[i]=S2[i-1];
  }
  X=sub11(1,N);
  Y=sub12(1,N);
  long ans=N;
  if (sub2(1)==-1)ans-=X;
  if (sub2(N)==1) ans-=(N+1-Y);
  /*
  cout << endl;
  cout << sub2(1) << endl;
  cout << sub2(N) << endl;
  cout << X << endl;
  cout << Y << endl;
  */

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


long sub11(long x,long y){
  if (x==y){
    return x;
  }
  long z=(x+y+1)/2;
  if (sub2(z)==-1){
    return sub11(z,y);
  }else{
    return sub11(x,z-1);
  }
}

long sub12(long x,long y){
  if (x==y){
    return x;
  }
  long z=(x+y)/2;
  if (sub2(z)==1){
    return sub12(x,z);
  }else{
    return sub12(z+1,y);
  }
}

long sub2(long x){
  for (int i=1;i<=Q;i++){
    if (S[x]==T[i]){
      if (D[i]=='L'){
        x--;
        if (x==0)return -1;
      }else{
        x++;
        if (x==N+1)return 1;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
   int a[3],i,max,min;

   for(i=0;i<3;i++)
      scanf("%d",&a[i]);

   max=min=a[0];

   for(i=1;i<3;i++){
      if      (a[i]<min) min=a[i];
      else if (a[i]>max) max=a[i];
   }

   printf("%d\n",max-min);

   return 0;
}



Measured memory_bytes: 128
# ABC103C - Modulo Summation
def main():
    # L = LCM(A) -> (L - 1) mod Ai = Ai - 1
    # -> max of f (f(L - 1)) = (A1 - 1) + (A2 - 1) + ... + (An - 1)
    N, *A = map(int, open(0).read().split())
    ans = sum(A) - N
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
// Aizu Vol-5 0576: Homework
// 2017.8.30 bal4u@uu

#include <stdio.h>

int main()
{
	int L, A, B, C, D;
	int a, b;

	scanf("%d%d%d%d%d", &L, &A, &B, &C, &D);
	a = (A-1)/C + 1, b = (B-1)/D + 1;
	if (b > a) a = b;
	printf("%d\n", L - a);
	return 0;
}

Measured memory_bytes: 596
// finish date: 

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int M = Integer.parseInt(br.readLine().trim());
        System.out.println(48 - M);
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
#include <string.h>
#include <cstdio>
using namespace std;
int main(){
  char c[1111];
  int len=0;
  int k=0;
  char maxc;
  int iti[1111]={0};//頻度高いよう
  char ans[1111];
  int sai=0;
  char ans1[1111];
  char cpy[1111][1111];
  while(scanf("%s",c)!=EOF){
    if(len<strlen(c)){//最長のもの
      len=strlen(c);
      strcpy(ans,c);
    }
    
    for(int i=0;i<k+1;i++){
      if(strcmp(cpy[i],c)==0){//すでに一度でていたら
	iti[i]++;
	break;
      }else if(i==k){//一度もでていなかったら
	strcpy(cpy[i],c);
      }
    }
    k++;
  }
  
  strcpy(ans1,cpy[0]);
  sai=iti[0];
  for(int i=0;i<k;i++){
    if(sai<iti[i]){
      sai=iti[i];
      strcpy(ans1,cpy[i]);
    }
  }
  /*for(int i=0;i<k;i++){
    cout << cpy[i] << " ";
    }*/

  cout << ans1 << " " << ans << endl;
}
    

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ans;
int n;
int a[311111];

signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    int repu=1;
    rep(i,60){
        int num=1LL<<i;
        int t=0,f=0;
        rep(j,n){
            if(a[j] & num)t++;
            else f++;
        }
        num%=MOD;
        int tf=t*f%MOD;
        ans+=(tf*num)%MOD;
        ans%=MOD;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
wordarr = gets.chomp.split("").map do |s| s.to_s end
time = gets.chomp.to_i
time.times do
    oparr = gets.chomp.split(" ").map do |s| s.to_s end
    if oparr[0] == "replace"
        wordarr[oparr[1].to_i..oparr[2].to_i] = oparr[3].split("")
    elsif oparr[0] == "reverse"
        wordarr[oparr[1].to_i..oparr[2].to_i] = wordarr[oparr[1].to_i..oparr[2].to_i].reverse
    elsif oparr[0] == "print"
        puts wordarr[oparr[1].to_i..oparr[2].to_i].join("")
    end
end

Measured memory_bytes: 8980
//It is made by Awson on 2018.1.28
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int M = 200000;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void write(int x) {
    if (x > 9) write(x/10);
    putchar(x%10+48);
}

int n, m, path[N+5], tot, u, v, c, flag;
int dist[N+5], vis[N+5];
struct tt {int to, cost, next; }edge[(M<<1)+5];
void add(int u, int v, int c) {edge[++tot].to = v, edge[tot].cost = c, edge[tot].next = path[u], path[u] = tot; }

bool dfs(int o) {
    vis[o] = 1;
    for (int i = path[o]; i; i = edge[i].next)
	if (dist[edge[i].to] > dist[o]+edge[i].cost) {
	    if (vis[edge[i].to]) return true;
	    dist[edge[i].to] = dist[o]+edge[i].cost;
	    if (dfs(edge[i].to)) return true;
	}
    vis[o] = 0; return false;
}
void work() {
    read(n), read(m);
    for (int i = 1; i <= m; i++) {read(u), read(v), read(c); add(u, v, c), add(v, u, -c); }
    for (int i = 1; i <= n; i++) if (dfs(i)) {flag = 1; break; }
    if (flag) puts("No");
    else puts("Yes");
}
int main() {
    work(); return 0;
}


Measured memory_bytes: 8576
#include<iostream>
using namespace std;
static const int MAX_N = 3000;
static const int MAX_T = 3000;

int N, T, S;
int A[MAX_N], B[MAX_N];
int memo[MAX_N + 1][MAX_T + 1];

int main(){
	cin >> N >> T >> S;
	for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
	for(int i = 0; i < N + 1; i++){
		for(int j = 0; j <= T; j++){
			if(i == 0 || j == 0) memo[i][j] = 0;
			else if(B[i - 1] > j || (j > S && j - B[i - 1] < S)) memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
			else memo[i][j] = max(max(memo[i - 1][j], memo[i][j - 1]), memo[i - 1][j - B[i - 1]] + A[i - 1]);
		}
	}
	cout << memo[N][T] << endl;
	return 0;
}


Measured memory_bytes: 38268
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
#define MAX 3009
double dp[MAX][MAX];
double fun(double p[], int N, int heads, int heads_required){
    //cout << N << " " << heads << '\n';
    /*if(dp[N][heads] != -1.0) return dp[N][heads];
    if(N == 0){
        if(heads > heads_required) return dp[N][heads] = 1.0;
        else return 0.0;
    }
    else return dp[N][heads] = p[N]*fun(p, N-1, heads+1, heads_required) + (1-p[N])*fun(p, N-1, heads, heads_required);*/
    /*Hint: make probability tree starting from last coin. Each coin can be either heads or tails
    If on a path from root to leaf there are more than N/2 heads then the path is valid else invalid*/

    vector<double> dp(N+1);
    dp[0] = 1;
    /*dp[i] = probability that there are i heads so far(how many ever coins we may have seen -- doesn't matter)*/
    for(int coin = 1; coin <= N; coin++){
        /*If you have seen coin coins so far, there can be [0...coin] heads*/
        for(int j = coin; j >= 0; j--){
            if(j == 0) dp[j] = 0 + dp[j]*(1-p[coin]);
            else dp[j] = dp[j-1]*p[coin] + dp[j]*(1-p[coin]);
        }
    }
    /*p-bility that there are j heads = p(j-1 heads)*p(heads) + p(j heads)*p(tail)
    There could already be j heads before we saw this coin, so this one is allowed to land tails
    If we iterate from 0 to coin, then recurrence relation would be same but ...? */
    double ans = 0.0;
    for(int i = N/2 + 1; i <= N; i++){
        ans += dp[i];
    }
    return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T = 1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
		int N; cin >> N;
        double p[N+1];
        FOR1(i, N) cin >> p[i];
        cout << fixed << setprecision(10);
        FOR(i, MAX){
            FOR(j, MAX){
                dp[i][j] = -1.0;
            }
        }
        cout << fun(p, N, 0, N/2);
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 71040
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int solve()
{
    ll N;

    cin >> N;

    vector<int> ai = fetch_vec<int>(N + 1);
    vector<int> bi = fetch_vec<int>(N);

    ll counter = 0;

    for (int i = 0; i < N; ++i)
    {
        ll tmp  = std::min(bi[i], ai[i]);
        counter += tmp;
        bi[i] -= tmp;
        ai[i] -= tmp;

        if (bi[i] > 0)
        {
            tmp = std::min(bi[i], ai[i + 1]);
            counter += tmp;
            bi[i] -= tmp;
            ai[i + 1] -= tmp;
        }
    }

    cout << counter << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  int N;
  ll A,B;
  cin >> N >> A >> B;
  ll X[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    ll cost = min(B,A*(X[i]-X[i-1]));
    ans += cost;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n)cin>>d[i];

    ll sum=0;
    rep(i,n){
        for(int j=i+1;j<n;++j){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
}





Measured memory_bytes: 3580