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

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

	if (s == u) {
		--s_n;
	}
	else {
		--t_n;
	}

	cout << s_n << " " << t_n << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	string S;
	cin >> S;
	bool valid = true;

	if (S[0] != 'A')
	{
		valid = false;
	}

	int c_cnt = 0;
	int c_pos = 0;
	for (int i = 2; i < S.length() - 1; i++)
	{
		if (S[i] == 'C')
		{
			c_cnt++;
			c_pos = i;
		}
	}
	if (c_cnt != 1)
	{
		valid = false;
	}

	for (int i = 1; i < S.length(); i++)
	{
		if (i == c_pos) continue;
		if (!islower(S[i]))
		{
			valid = false;
		}
	}

	cout << (valid ? "AC" : "WA") << endl;
}

//
//const int MOD = 998244353;
//int m_add(int a, int b)
//{
//	return (a + b) % MOD;
//}
//int m_sub(int a, int b)
//{
//	return (a + MOD - b) % MOD;
//}
//int m_mul(int a, int b)
//{
//	return (a * b) % MOD;
//}
//int m_pow(int x, int n)
//{
//	if (n == 0) return 1;
//	ll res = m_pow((x * x) % MOD, n / 2);
//	if (n & 1) res = (res * x) % MOD;
//	return res;
//}
//int m_divide(int a, int b)
//{
//	return m_mul(a, m_pow(b, MOD - 2));
//}
//int m_comb(int n, int r)
//{
//	int i;
//	int p = 1;
//	for (i = 1; i <= r; i++)
//	{
//		p = m_mul(p, (n - i + 1));
//		p = m_divide(p, i);
//	}
//	return p;
//}
//int m_comb_with_rep(int n, int r)
//{
//	return m_comb(n + r - 1, r);
//}
//
//
//
//signed main()
//{
//	int N, M, K;
//	cin >> N >> M >> K;
//
//
//	int ans = 0;
//
//	int xx = m_pow(M - 1, N - 1);
//	int yy = m_comb_with_rep(2, 0);
//	int zz = m_mul(xx, yy);
//	zz = m_mul(zz, M);
//	ans = m_add(ans, zz);
//
//	int x = 0;
//	int y = 0;
//	for (int k = 1; k <= K; k++)
//	{
//		int a = max(0LL, k + 1);
//		int b = max(0LL, N - (k * 3) + 1);
//		if (k <= 1)
//		{
//			x = m_pow(M - 1, N - 1);
//		}
//		else
//		{
//			x = m_sub(x, M - 1);
//		}
//
//		if (k <= 1)
//		{
//			y = m_comb_with_rep(a, b);
//		}
//		else
//		{
//			int q = ((N - 3 * k + 1) * k) % MOD;
//			int w = (N - 2 * k + 1) % MOD;
//			y = m_mul(y, q);
//			y = m_divide(y, w);
//		}
//
//		int z = m_mul(x, y);
//		z = m_mul(z, M);
//		ans = m_add(ans, z);
//	}
//
//	cout << ans << endl;
//}



Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

class UnionFind {
private:
    vector<int> parent_;
    vector<int> node_rank_;
    vector<int> sizes_;
public:
    UnionFind(int node_num):
    parent_(vector<int>(node_num)), node_rank_(vector<int>(node_num)), sizes_(vector<int>(node_num)) {
        for (int i = 0; i < node_num; ++i) {
            parent_[i] = i;
            node_rank_[i] = 0;
            sizes_[i] = 1;
        }
    }
    int getRoot(int u) {
        return parent_[u] == u ? u : parent_[u] = getRoot(parent_[u]);
    }
    bool isSame(int u, int v) {
        return getRoot(u) == getRoot(v);
    }
    void unite(int u, int v) {
        u = getRoot(u);
        v = getRoot(v);
        if (u == v) return;
        if (node_rank_[u] < node_rank_[v]) {
            parent_[u] = v;
            sizes_[v] += sizes_[u];
        }
        else {
            parent_[v] = u;
            sizes_[u] += sizes_[v];
            if (node_rank_[u] == node_rank_[v]) {
                node_rank_[u]++;
            }
        }
    }
    int getSize(int u) {
        return sizes_[getRoot(u)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, 0, M) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    UnionFind uf(N);
    vector<ll> ans(M);
    ll now = N * (N - 1) / 2;
    rrep(i, M, 0) {
        ans[i] = now;
        if (!uf.isSame(A[i], B[i])) {
            ll s1 = uf.getSize(A[i]);
            ll s2 = uf.getSize(B[i]);
            now -= s1 * s2;
            uf.unite(A[i], B[i]);
        }
    }
    rep(i, 0, M) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int MOD;

struct Mat {
	vector<vector<ll> > dat;
	int n;

	Mat(int n) : n(n), dat(n, vector<ll>(n)) {}

	Mat(vector<vector<ll> > dat) : n(dat.size()), dat(dat) {}

	Mat I(int n) {
		Mat ret(n);
		rep(i, n) ret.dat[i][i] = 1;
		return ret;
	}

	Mat mul(Mat &b) {
        Mat ret(n);
		rep(i, n) rep(j, n) rep(k, n) (ret.dat[i][j] += dat[i][k] * b.dat[k][j]) %= MOD;
        return ret;
	}

	Mat pow(ll b) {
		Mat ret = I(n);
        for (Mat A = *this; b > 0; A = A.mul(A) , b /= 2) if (b & 1) ret = A.mul(ret);
        return ret;
	}
};

int main() {
	int n, m, a, b, c, t;
	while(cin >> n >> m >> a >> b >> c >> t) {
		if(n == 0 && m == 0 && a == 0 && b == 0 && c == 0 && t == 0) break;

		MOD = m;

		vector<int> s(n);
		rep(i, n) cin >> s[i];

		int s1 = -1, s2 = 0, s3 = 1;
		Mat mat(n);
		rep(i, n) {
			if(s1 >= 0) {
				mat.dat[i][s1] = a;
			}
			mat.dat[i][s2] = b;
			if(s3 < n) {
				mat.dat[i][s3] = c;
			}
			
			s1++; s2++; s3++;
		}

		Mat ret = mat.pow(t);

		rep(i, n) {
			ll sum = 0;
			rep(j, n) {
				sum += s[j] * ret.dat[i][j];
				sum %= MOD;
			}

			cout << sum;

			if(i == n-1) cout << endl;
			else cout << " ";
		}
	}

	return 0;
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define MOD 1000000007

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n, a[100001] = {}, b, ans = 0, g = false;
  cin >> n;
  rep(i, 0, n) {
    cin >> b;
    a[b]++;
  }
  
  rep(i, 0, 100001) {
    if(!a[i]) continue;
    if(a[i] % 2 == 1) ans++;
    else {
      if(g) ans += 2, g = false;
      else g = true;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll a[100010];
ll A[100010];
ll B[100010];
ll C[100010];
ll cnt[100010];

int main(){
  int n,m;
  cin >> n >> m;
  REP(i,m) {
    cin >> a[i];
    a[i]--;
  }
  REP(i,n - 1) {
    cin >> A[i] >> B[i] >> C[i];
  }
  REP(i,m-1) {
    ll from = a[i];
    ll to = a[i+1];
    if (from > to) swap(from,to);
    cnt[from]++;
    cnt[to]--;
  }
  REP(i,n + 1) {
    cnt[i+1] += cnt[i];
  }
  ll ans = 0;
  REP(i,n-1) {
    ans += min(A[i] * cnt[i], B[i] * cnt[i] + C[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int x, a, b;

int main(void){
  cin >> x >> a >> b;
  if(-a + b <= 0){
    cout << "delicious" << endl;
  }
  else if(-a + b <= x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#define EMP -1000
 
using namespace std;

int stage[11][11]={};
int h;


void outStage(){
	for(int i=0;i<h;i++){
		for(int j=0;j<5;j++){
			cout<<stage[i][j];
		}
		cout<<endl;
	}
}

bool delStage(){
	bool conti=false;
	for(int i=0;i<h;i++){
		for(int j=0;j<3;j++){
			int samecount=1;
			int now=-1;
			for(int k=0;;k++){
				if(now==-1){					
					now=stage[i][j+k];
				}
				else if(now==stage[i][j+k] && now!=EMP){
					samecount++;
				}
				if( (now!=-1 && now!=stage[i][j+k]) || k==4){
					if(samecount>=3){
						conti=true;
						for(int l=0;l<samecount;l++){
							stage[i][j+l]=EMP;
						}
						samecount=1;
					}
					goto end;
				}
			}
			end:;
		}
	}
	return conti;
}


void downNum(){
	for(int t=0;t<h;t++){
		for(int i=1;i<h-t;i++){
			for(int j=0;j<5;j++){
				if( i-1>=0 && stage[i][j]==EMP){
					swap(stage[i][j],stage[i-1][j]);
				}
			}
		}
	}
}

int countScore(){
	int sum=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<5;j++){
			if(stage[i][j]!=EMP)
				sum+=stage[i][j];
		}
	}
	return sum;
}

int main(){
	while(1){
		int sum=0;
		cin>>h;
		if(h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				cin>>stage[i][j];
				sum+=stage[i][j];
			}
		}
//end input;

		while(1){
			if(delStage()==false)break;
			downNum();
		}
		cout<<sum-countScore()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
act = [list(map(int, input().split())) for _ in range(N)]

import numpy as np
act = np.array(act)
act = np.concatenate([[[0]*3], act])  # 0日目は0にする

# DPテーブル
dp = np.zeros([N+1, 3], dtype='int')

for i in range(1, N+1):  # 1日目からN日目までの幸福度を順番に計算する
    for j in range(3):  # i日目は海か山か家を選択する
        for k in range(3):  # i日目にjの活動をする場合、i-1日目はj以外の活動
            if k == j:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k] + act[i][j])
            
print(np.max(dp[-1]))

Measured memory_bytes: 42124
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ll = long long int;
using itpl = tuple<int,int,int>;
int wi[4] = {0,-1,0,1};
int hi[4] = {-1,0,1,0};

//https://atcoder.jp/contests/agc033/tasks/agc033_a
int main(){
    int H,W,cnt=0;
    cin >> H >> W;
    vector<vector<char>> c(H,vector<char> (W,'a'));
    string S;
    vector<vector<int>> check(H,vector<int>(W,0));
    rep(i,0,H){
        cin >> S;
        rep(j,0,W) c[i][j]=S[j];
    }

    queue<itpl> q;
    rep(i,0,H) rep(j,0,W) if(c[i][j]== '#') q.push(make_tuple(j,i,0));        

    int now_x,now_y,now_dist;
    while (!q.empty()){
        tie(now_x,now_y,now_dist) = q.front();
        q.pop();
        for(int moveIdx=0;moveIdx<4;moveIdx++){
            int x = now_x + wi[moveIdx];
            int y = now_y + hi[moveIdx];
            if(x<0||x>=W||y<0||y>=H) continue;
            if(c[y][x]=='.'){
                q.push(make_tuple(x,y,now_dist+1));
                c[y][x] = '#';
            }
        }
    }
    cout << now_dist << endl;
}

Measured memory_bytes: 17296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  long long int ans;
  ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int ij;
      ij=gcd(i+1,j+1);
      for(int k=0;k<n;k++){
        int p;
        p=gcd(ij,k+1);
        ans=ans+p;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 400

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int flag = 1;
  int N[4];
  int cnt[4] = {};
  rep(i, 4) cin >> N[i];
  rep(i, 4) {
    switch(N[i]) {
      case 1: ++cnt[0];
              break;
      case 9: ++cnt[1];
              break;
      case 7: ++cnt[2];
              break;
      case 4: ++cnt[3];
              break;
    }
  }
  rep(i, 4) {
    if(cnt[i]!=1) {
      flag = 0;
      break;
    }
  }

  if(flag==1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Text.Printf

main :: IO ()
main = solve <$> f >>= printf "%.10f\n"
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Double
solve [a, b, h, m] = sqrt $ fromIntegral a * fromIntegral a +
                     fromIntegral b * fromIntegral b
                     - 2.0 * fromIntegral a * fromIntegral b * cos (tm - th)
  where
    tm = pi * fromIntegral m / 30.0
    th = pi * (fromIntegral h / 6.0 + fromIntegral m / 360.0)


Measured memory_bytes: 4468
N = int(input())
A = list(map(int, input().split()))

B = []

count = 0
for x in A:
  if x < 0:
    count += 1
  B.append(abs(x))

if count % 2 == 0:
  print(sum(B))
else:
  print(sum(B)-min(B)*2)

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int s=0;
  int m=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    s+=a;
    m+=a*a;
  }
  cout<<(s*s-m)/2<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int amari = 0;
        String ans = "";
        long kari = 0;
        //System.out.println(N);
        List<String> list = Arrays.asList("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
        while(0 < N){
            kari = N % 26;
            if(kari == 0){
                kari = 26;
                N -= 1;
            }
            N /= 26;
            //System.out.println(kari);
           amari = (int)kari;
           ans += list.get(amari - 1);
        }
        StringBuffer sb = new StringBuffer(ans);
		String dst = sb.reverse().toString();
        System.out.println(dst);
    }
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

struct P {
	int x, y;
};
 
int W, H, N;
vector<int> x, y, a;

void solve() {
	int p[4] = {0, W, 0, H};
	
	for (int i = 0; i < N; i++) {
		switch (a[i]) {
		case 1:
			if (p[0] < x[i]) p[0] = x[i];
			break;
		case 2:
			if (p[1] > x[i]) p[1] = x[i];
			break;
		case 3:
			if (p[2] < y[i]) p[2] = y[i];
			break;
		case 4:
			if (p[3] > y[i]) p[3] = y[i];
			break;
		}
	}
	
	int dx = (p[1] - p[0]);
	int dy = (p[3] - p[2]);
	int S = dx > 0 && dy > 0 ? dx * dy : 0;
	
	cout << S;
}
 
int main() {
	
	while (cin >> W >> H >> N) {
		x.resize(N);
		y.resize(N);
		a.resize(N);
		
		for (int i = 0; i < N; ++i) {
			cin >> x[i] >> y[i] >> a[i];
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;
typedef pair<int, int> ii;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FORE(x,xs) for (auto& x : xs)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define STATION first
#define ROUTE second

const int MAX = 1e5+10;
const int INF = 1e9+9;
int N, M;
map<ii, vector<pair<ii, int>>> rails;
map<ii, int> dist;

int main() {
    cin >> N >> M;
    REP (i, M) {
        ii p1, p2, out1, out2;
        int p, q, c;
        cin >> p >> q >> c;
        p1.STATION = out1.STATION = p;
        p2.STATION = out2.STATION = q;
        p1.ROUTE = p2.ROUTE = c;
        out1.ROUTE = out2.ROUTE = -1;
        
        rails[p1].push_back(MP(p2, 0));
        rails[p1].push_back(MP(out1, 0));

        rails[p2].push_back(MP(p1, 0));
        rails[p2].push_back(MP(out2, 0));

        rails[out1].push_back(MP(p1, 1));
        rails[out2].push_back(MP(p2, 1));

        dist[p1] = dist[p2] = dist[out1] = dist[out2] = INF;
    }
    
    ii start, goal;
    start.STATION = 1, start.ROUTE = -1;
    goal.STATION = N, goal.ROUTE = -1;
    if (dist[goal] == 0) {
        cout << -1 << endl;
        return 0;
    }
    priority_queue<pair<int, ii>> q;
    q.push(MP(0, start));
    while (!q.empty()) {
        int d;
        ii p;
        tie(d, p) = q.top(); q.pop();
        if (dist[p] != INF) continue;
        dist[p] = -d;
        FORE (e, rails[p])
            q.push(MP(d-e.second, e.first));
    }
    if (dist[goal] == INF) dist[goal] = -1;
    cout << dist[goal] << endl;
}

Measured memory_bytes: 93876
from heapq import heapify, heappop, heappush, heappushpop
import sys
input = sys.stdin.readline
N,X,Y=map(int, input().split())
def f(i,j):
  ret1 = abs(j-i)
  ret2 = abs(j-Y)+1+abs(i-X)
  ret3 = abs(i-Y)+1+abs(j-X)
  return min(ret1,ret2,ret3)
  
dp=[0]*N
for i in range(1,N+1):
  for j in range(i+1,N+1):
    dp[f(i,j)] += 1
for i in range(1,N):
  print(dp[i])

Measured memory_bytes: 3572
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;

#define MAXN 100005
#define INF 999999999
int nums[MAXN];

struct big {
	int val;
	int nums;
};

big bigs[MAXN];

bool operator <(big a, big b) {
	return a.val < b.val;
}

signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n, m;
	int a, b;
	LL ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &nums[i]);
	}
	sort(nums + 1, nums + n + 1);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &bigs[i].nums, &bigs[i].val);
	}
	sort(bigs + 1, bigs + m + 1);
	int count = n;
	int poi1 = n;
	int poi2 = m;
	while (count > 0) {
		if (nums[poi1] > bigs[poi2].val) {
			ans += nums[poi1];
			poi1--;
		}
		else {
			ans += bigs[poi2].val;
			bigs[poi2].nums--;
			if (bigs[poi2].nums == 0) {
				poi2--;
			}
		}
		count--;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1408
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
for i in ['+','-']:
  for j in ['+','-']:
    for k in ['+','-']:
      f = a+i+b+j+c+k+d
      if eval(f) == 7:
        print(f+'=7')
        exit()


Measured memory_bytes: 38384
a,b,c,d=map(int,input().split())
if a==b:
    if c==d:
        print("yes")
    else:
        print("no")
elif a==c:
    if b==d:
        print("yes")
    else:
        print("no")
elif a==d:
    if b==c:
        print("yes")
    else:
        print("no")
else:
    print("no")


Measured memory_bytes: 5596
#include<stdio.h>

int main(void){
	int tapnum = 1, cnt = 0;
	int outlet;  scanf("%d",&outlet);
	int noutlet; scanf("%d",&noutlet);

	while(tapnum < noutlet){
		tapnum--;
		tapnum += outlet;
		cnt++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var L = sc.ArrayInt(N).OrderByDescending(i => i).ToArray();
        var max = L[0];
        if (max < L.Skip(1).Sum()) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13396
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())
a = list(map(int,input().split()))
flag = True
for x in a:
    if x%2==0:
        if x%3 and x%5:
            flag = False
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import math
N = int(input())
sieve = [-1] * (N + 1)
sieve[0] = sieve[1] = 0
maxPrime = int(math.sqrt(N))
for i in range(maxPrime + 1):
    if sieve[i] != -1:
        continue
    else:
        index = i * i
        while True:
            if index > N:
                break
            sieve[index] = i
            index += i

ans = 1
for i in range(2,N+1):
    if sieve[i] == -1:
        ans += 2 * i
    else:
        primeFactorList = []
        index = i
        while sieve[index] != -1:
            primeFactorList.append(sieve[index])
            index //= sieve[index]
        primeFactorList.append(index)
        primeFactorList.sort()
        lastIndex = 0
        curans = 1
        for j in range(1,len(primeFactorList)):
            if primeFactorList[j] != primeFactorList[j-1]:
                curans *= (j - lastIndex + 1)
                lastIndex = j
        curans *= len(primeFactorList) - lastIndex + 1
        ans += curans * i
print(ans)
    


Measured memory_bytes: 146784
#include <bits/stdc++.h>
using namespace std;
long long f(long long a, long long b)
{
    if(a>b) swap(a,b);
	long long d=b/a;
	if(b%a) return d*2*a+f(a,b%a);
	return a*(2*d-1);
}
long long n,x;
int main()
{
    scanf("%lld%lld",&n,&x);
    printf("%lld\n",n+f(x,n-x));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
using ll = long long;
using ld = long double;
const int Mod = 1e9 + 7;
using namespace std;

#define Get_Abs(a) ((a) >= 0 ? (a) : -(a))
#define Get_Max(a, b) ((a) > (b) ? (a) : (b))
#define Get_Min(a, b) ((a) < (b) ? (a) : (b))
#define Get_Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define Get_Limit(a, b, c) ((a) = ((a) > (c)) ? (c) : (((a) < (b)) ? (b) : (a)))

ll Power(ll a, ll b)
{
	ll Ans = 1;
	while (b) 
	{
		if (b & 1)
		{
			Ans = (Ans * a) % Mod;
		}
		a = (a * a) % Mod;
		b >>= 1;
	}
	return Ans;
}

int main()
{
	ll n, Ans;
	cin >> n;
	if (n == 1)
	{
		Ans = 0;
	}
	else if(n == 2)
	{
		Ans = 2;
	}
	else
	{ 
		Ans = Power(10, n) - Power(9, n) * 2 + Power(8, n);
		while (Ans < 0)
		{
			Ans += Mod;
		}
		Ans = Ans % Mod;
	}
	cout << Ans;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 1e6+1;

int main() {
	fastio();

	LL a;
	cin >> a;
	cout << a + a*a + a*a*a << "\n";


}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;
int main()
{
	string s;
	cin >> s;
	int arr['z'-'a'+1]{};
	for(int i = 0; i < s.size(); i++)
		arr[ s[i] - 'a' ]++;
	for(int i = 0; i <= 'z' - 'a'; i++)
		if( arr[i] == 0 )
		{
			cout << (char)(i+'a');
			return 0;
		}
	cout << "None";
	return 0;
}

Measured memory_bytes: 3704
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

bool is[maxn];
int pri[maxn],cnt,a[maxn],n,c[maxn],pos[maxn];

inline void pre()
{
	for(int i=2;i<=maxn-5;i++)
	{
		if(!is[i]) pri[++cnt]=i;
		for(int j=1;j<=cnt;j++)
		{
			int k=pri[j]*i; if(k>maxn-5) break; is[k]=1;
			if(i%pri[j]==0) break;
		}
	}
}


int main()
{
	pre(); n=read(); int F=0;
	rep(i,1,cnt) pos[pri[i]]=i;
	rep(i,1,n) a[i]=read();
	rep(i,1,n)
	{
		int p=a[i];
		rep(j,1,cnt)
		{
			if(pri[j]*pri[j]>p) break;
			if(p%pri[j]==0)
			{
				if(c[j]) {F=1; break;}
				c[j]++; while(p%pri[j]==0) p/=pri[j];
			}
		}
		if(p==1) continue;
		if(c[pos[p]]) {F=1; break;}
		else c[pos[p]]++;
		if(F) break;
	}
	if(!F) return puts("pairwise coprime"),0;
	int tmp=a[1];
	rep(i,2,n) tmp=__gcd(tmp,a[i]);
	if(tmp==1) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}

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

int main()
{
	char s[100] = { 0, }, t[100] = { 0, };
	cin >> s >> t;
	int sl, tl;
	for (sl = 0; s[sl]; sl++);
	for (tl = 0; t[tl]; tl++);
	sort(s, s + sl);
	sort(t, t + tl);
	reverse(t, t + tl);
	if (strcmp(s, t) < 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int W,H,x,y,r;
    std::scanf("%d %d %d %d %d" ,&W,&H,&x,&y,&r);

    if(W - r >= x && H - r >= y && x - r >= 0 && y - r >= 0) {
        std::printf("Yes\n");
    }

    else {
    {std::printf("No\n");
}
return 0;}
}


Measured memory_bytes: 2616
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    map<int,int> mp[200010];
    REP(i,M){
        int a,b; cin>>a>>b;
        mp[a][b]=1;
    }
    for(int i=2;i<=N-1;i++){
        if(mp[1][i] and mp[i][N]){ 
            cout<<"POSSIBLE"<<endl; 
            return 0; 
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
 
}


Measured memory_bytes: 34560
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
int main() {
	ll ans = 0, minn = 1e9 + 5;
	int N; scanf("%d", &N);
	bool ok = 1;
	for(int i = 1; i <= N; ++i) {
		int a, b; scanf("%d%d", &a, &b); ok &= (a == b);
		ans += a; if(a > b) minn = min(minn, (ll)b);
	}
	if(minn != 1e9 + 5) ans -= minn;
	if(ok) ans = 0;
	printf("%lld\n", ans);
	return 0;
}

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

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

  int ans = 0;
  for(int i=0; i<n; i++) {
    int64_t x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100010],dp[500][500];

int main(){
  cin >> n >> m >> l;
  n -= m;
  ll p = n/l;
  n -= l*p;
  print(n);
  return 0;
}

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


int main() {
    string S;
    cin >> S;
    deque<char> deq;
    for (char c : S) deq.push_back(c);

    int Q;
    cin >> Q;
    bool forward = true;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            forward = !forward;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if (F == 1) {
                if (forward) deq.push_front(C);
                else deq.push_back(C);
            } else {
                if (forward) deq.push_back(C);
                else deq.push_front(C);
            }
        }
    }


    for (int i = 0; i < deq.size(); i++) {
        if (forward) cout << deq[i];
        else cout << deq[deq.size() - 1 - i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ffl(i,a,b) for(int i=a; i<b; i++)
#define fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fast;
    int n,k;
    cin>>n>>k;
    int arr[n],cnt[n-1][k];
    ffl(i,0,n)
        cin>>arr[i];
    ffl(i,1,n)
        ffl(j,0,k)
            if (i-j > 0)
                cnt[i-1][j] = abs(arr[i] - arr[i-j-1]);
            else
                cnt[i-1][j] = 99999;
    ffl(i,1,n-1)
        ffl(j,0,k)
            if (i-j > 0)
            {
                int min = 1e9;
                ffl(p,0,k)
                    if (min > cnt[i-j-1][p])
                        min = cnt[i-j-1][p];
                cnt[i][j] += min;
            }
    int min = 1e9;
    ffl(p,0,k)
        if (min > cnt[n-2][p])
            min = cnt[n-2][p];
    cout<<min<<endl;
}

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

int main(){
  int N; cin >> N;
  int s[100];
  int sum=0;
  for(int i=0; i<N; i++){
    cin >> s[i];
    sum+=s[i];
  }
  if(sum%10!=0){
    cout << sum << endl;
  }else{
    sort(s,s+N);
    for(int i=0; i<N; i++){
      if(s[i]%10!=0){
        cout << sum-s[i] << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (((h2 * 60 + m2) - (h1 * 60 + m1)) - k) << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
ll in[2],d;

struct State{
  ll x,y,diff;
  bool operator <(const State &s) const {
    if(x+y != s.x+s.y) return x+y < s.x+s.y;
    return in[0]*x+in[1]*y < in[0]*s.x+in[1]*s.y;
  }
};

int main(){

  while(cin >> in[0] >> in[1] >> d && in[0]+in[1]+d){
    queue<State> Q;
    set<int>vis;
    vector<State> V;
    State s;
    s.x = s.y = 0;
    s.diff = d;
    Q.push(s);
    vis.insert(s.diff);
    while(!Q.empty()){
      State st = Q.front();
      Q.pop();

      for(int i = 0; i < 2; i++){
	State tmp = st;
	if(tmp.diff > 0)tmp.diff-=in[i];
	else tmp.diff+=in[i];

	if(i == 0) tmp.x++;
	else tmp.y++;
	if(tmp.diff == 0) {
	  V.push_back(tmp);
	  continue;
	}
	if(vis.count(tmp.diff)) continue;
	vis.insert(tmp.diff);
	Q.push(tmp);
      }
    }
    sort(V.begin(), V.end());
    cout << V[0].x << " " << V[0].y << endl;
  }
  return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;

int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
vector<bool> sieve(N,true);
void help()
{
    for(int i=2;i*i<=N-5;++i)
    {
        if(sieve[i])
        for(int j = i*i;j<=N-5;j+=i)
            sieve[j] = false;
    }
}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        help();
        vi v;
        for(int i=2;i<=(int)1e5+5;++i)
            if(sieve[i])
            v.pb(i);
        int n;
        cin>>n;
        auto x = lower_bound(all(v),n);
        cout<<(*x);
   }
        return 0;
    }


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;
const ll mod = 1e9 + 7;

int main(void)
{
	string s;
	cin >> s;
	int n = s.size();
	rep(i,n) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
int a,b,c,x,cnt,sum;
int main() {
	scanf("%d %d %d %d",&a,&b,&c,&x);
	cnt=x/50;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++) {
			int mon=500*i+100*j;
			if(mon<=x&&(x-mon)/50<=c)
				sum++;
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
    int A, B;
    std::cin >> A >> B;

    int cnt = 0;
    for (int i = A; i <= B; ++i) {
        const std::string s = std::to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int max_l = 0;
    int sum_l = 0;
    for (int i = 0; i < N; i++)
    {
        int l;
        cin >> l;
        max_l = max(max_l, l);
        sum_l += l;
    }
    if (sum_l - max_l > max_l)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	string s;
	cin >> s;
	int n = s.length();
	bool flag = true;
	if (n % 2 != 0)flag = false;
	else if (n % 2 == 0) {
		rep(i, n) {
			if (i % 2 == 0 && s[i] != 'h')flag = false;
			else if (i % 2 != 0 && s[i] != 'i')flag = false;
		}
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    string s[400'000];
    int j = 0;
    char moji,moji2;

    while (cin >> moji)
    {
        if (moji == 'A')
        {
            s[j].append("X");
        }else if (moji == 'B'){
            if (cin >> moji2){
            //cout << "MOJI2 " << moji2 << endl;
            if (moji2 == 'C')
            {
                s[j].append("Y");
            }else if (moji2 == 'A'){
                j++;
                s[j].append("X");
            }
            else if (moji2 == 'B')
            {
                j++;
            }
            }
        }else if (moji == 'C'){
            j++;
        }
    }
    if (s[j].size() == 0)j--;
    ll ans=0;
    REP(i, j+1)
    {
        int ypos = 0;
        REP(k,s[i].size())
        {
            if (s[i][k] == 'Y'){
                ans += k - ypos;
                ypos++;
            }
        }
    }
    //REP(i,j+1)
    //cout << s[i] << endl;
    cout << ans << endl;
}


Measured memory_bytes: 5504
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,r=map(int,input().split())
r=list(map(int,input().split()))
abc=[list(map(int,input().split())) for i in range(m)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n,w = n,m

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = abc[i]
    x,y=x-1,y-1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
d=warshall_floyd(d)

# print(range(r))
lst=list(permutations(r))
# print(lst)
ans=float('inf')
for i in lst:
    tmp=0
    for j in range(len(i)-1):
        tmp+=d[i[j]-1][i[j+1]-1]
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 84248
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a > b) {
			System.out.println("a > b");
		}else if (b > a) {
			System.out.println("a < b");
		}else {
			System.out.println("a == b");
		}
		

	}
}


Measured memory_bytes: 26324
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<list>
#include<fstream>

#define REP(i,n) for(int i = 0; i < n ; ++i)
#define LL long long 
using namespace std;

#define int LL

bool func(int x)
{
	if (x < 2)
		return false;

	for (int i = 2; i*i <= x;++i){
		if (x%i == 0)
			return false;
	}

	return true;
}

signed main()
{
	//ifstream cin("Ain.txt");
	//ofstream cout("Aout.txt");

	int a, d, n;

	do{
		cin >> a >> d >> n;

		if (!(a&&d&&n))break;

		a -= d;

		while (n){
			a += d;
			if (func(a))n--;
		}
		cout << a << endl;
	} while (!(a&&d&&n));

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

#define ll long long
using namespace std;

vector<pair<ll, ll>> flower;


ll Binary_search(ll key) {
    ll ng = -1;
    ll ok = 9000000000000000000;

    while (abs(ok - ng) > 1) {
        ll mid = ng + (ok - ng) / 2;
        ll count = 0;
        for (int i = 0; i < flower.size(); i++) {
            if (mid >= flower[i].first)
                count += (mid - flower[i].first) / flower[i].second + 1;
            if (count >= key)break;
        }
        if (count >= key) ok = mid;
        else ng = mid;
    }

    return ok;
}

int main() {
    ll n, k;
    cin >> n >> k;
    flower = vector<pair<ll, ll>>(n);
    for (int i = 0; i < n; i++) {
        ll w, d;
        cin >> w >> d;
        flower[i] = make_pair(w, d);
    }
    cout << Binary_search(k) << endl;
    return 0;
}

Measured memory_bytes: 1920
def find(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    return (array_sum_square - 
            individual_square_sum) // 2
n=int(input())
arr=list(map(int,input().split()))
ans=find(arr,n)
mod=1000000007
print(ans%mod)


Measured memory_bytes: 31608
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 50;

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

    int A[MAX_N];
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] != i + 1) {
            count++;
        }
    }

    if (count > 2) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N, A, B;
  cin >> N >> A >> B;
  vector<int64> X(N);
  cin >> X;
  int64 distance;
  int64 hirou_sum = 0;
  for (int64 i = 0; i < N - 1; i++) {
    distance = X[i + 1] - X[i];
    hirou_sum += min(distance * A, B);
  }
  cout << hirou_sum << endl;
  return 0;
}

Measured memory_bytes: 1024
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
 
 
def main():
    N = int(input())
    S = input()
    l=0
    r=len(S)-1
    ans=0
    while(1):
        for i in range(l,len(S)):
            if S[i]=='W':
                l=i
                break
        for j in range(r,-1,-1):
            if S[j]=='R':
                r=j
                break
        if i<j:
            ans+=1
            l=i+1
            r=j-1
        else:
            break
    print(ans)

 
if __name__ == '__main__':
    main()
    

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

long long int n,i;
vector<long long int> a,b,c;


int main(){
    cin>>n;
    a.resize(n+1);
    b.resize(n+1);
    c.resize(n+1);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        cin>>c[i];
    }
    a[n]=b[n]=c[n]=5000000000;//番兵

    long long int ans=0,ans_part1=0,ans_part2=0;
    long long int key=0;
    vector<long long int>::iterator position;

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    for(i=0;i<n;i++){//b[i]で探すと答えを計算しやすい
        //lowerはb[i]以上の最小の位置を探す・upperはb[i]より大きい最小の要素の位置を探す
        position=lower_bound(a.begin(),a.end(),b[i]);//b[i]より小さい数の個数
        key=distance(a.begin(),position);
        ans_part1=key;

        position=upper_bound(c.begin(),c.end(),b[i]);//b[i]より大きい数の個数
        key=distance(c.begin(),position);
        if(c[key]==5000000000){break;}//番兵に遭遇したら終わり
        ans_part2=(n-key);
        
        ans+=(ans_part1*ans_part2);
    }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[m];
  rep(i,m) cin >> a[i];
  sort(a,a+m);
  vector<int> v;
  rep(i,m-1) v.pb(a[i+1]-a[i]);
  sort(all(v));
  ll ans=0;
  if(n<m) rep(i,m-n) ans+=v[i];
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

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

const int N = 100010;

int a[N];
bool mark[N];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int n , m , x , y , ans = 0;
	cin >> n >> m;

	fill(a , a+n , 1);
	mark[0] = 1;

	for(int i = 0 ; i < m ; i++){
	   cin >> x >> y;
	   x-- , y--;
	   a[x]--;
	   a[y]++;

	   if(mark[x])
		  mark[y] = 1;

		if(!a[x])  
		   mark[x] = 0;
	}

	for(int i = 0 ; i < n ; i++)
	   ans += mark[i];
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768