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

int main(){
	int i, j, n;
	bool cards[4][13] ={false};

	cin >> n;

	for (i = 0; i < n; ++i){
		int num;
		char mark;
		cin >> mark >> num;
		switch(mark){
			case 'S': cards[0][num-1] = true; break;
			case 'H': cards[1][num-1] = true; break;			
			case 'C': cards[2][num-1] = true; break;
			case 'D': cards[3][num-1] = true; break;		
		}
	}
	
	for (i = 0; i < 4; ++i){
		for (j = 0; j < 13; ++j){
			if (cards[i][j] == false){
				switch(i){
					case 0: cout << "S "; break;
					case 1: cout << "H "; break;
					case 2: cout << "C "; break;
					case 3: cout << "D "; break;
				}
				cout << j+1 << endl;
			}
		}
	}
}

Measured memory_bytes: 1160
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int N=2000010;
template<typename T>inline T chkmax(T _A,T _B){return _A>_B?_A:_B;}
template<typename T>inline T chkmin(T _A,T _B){return _A<_B?_A:_B;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int n,a[N],rev;
deque<int>q;
int main()
{
	read(n);
	For(i,1,n)read(a[i]);
	For(i,1,n)
	{
		if(rev)
			q.push_front(a[i]);
		else
			q.push_back(a[i]);
		rev^=1;
	}
	if(rev)
	{
		while(!q.empty())
		{
			printf("%d ",q.back());
			q.pop_back();
		}
	}
	else
	{
		while(!q.empty())
		{
			printf("%d ",q.front());
			q.pop_front();
		}
	}
	puts("");
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    bool f = true;
    REP(i,0,A) {
        if(S[i] == '-') f = false;
    }
    if(S[A] != '-') f = false;
    REP(i,A+1,A+B+1) {
        if(S[i] == '-') f = false;
    }

    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
 {
	int n,k,q,h,score;
	cin>>n>>k>>q;
	map<int,int> m;
	for(int i=0;i<q;i++)
	{
	    cin>>h;
	    h--;
	    m[h]++;
	}
	for(int i=0;i<n;i++)
	{
	    score=(k-q)+m[i];
	    if(score<=0) cout<<"No"<<newl;
	    else cout<<"Yes"<<newl;
	}
	
  
	return 0;
}

Measured memory_bytes: 5376
N = int(input())
L = list(map(int,input().split()))
import bisect
L.sort()
ans = 0
for i in reversed(range(2,N)):
    for j in reversed(range(1,i)):
        tmp = bisect.bisect_right(L,L[i]-L[j])
        ans += max(0,j-tmp)
print(ans)

Measured memory_bytes: 44124
n = int(input())
d = list(map(int,input().split()))
d.sort()
m = int(len(d)/2)
ml = d[m-1]
mr = d[m]

if mr - ml < 1:
	print(0)
elif mr- ml ==1:
	print(1)
else:
	print(mr - ml)

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x;
  cin>>a>>b>>c>>x;
  int num_ways=0;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++)
        if((500*i+100*j+50*k)==x)num_ways+=1;
cout<<num_ways;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
    
    int l,r,n;
    cin>>l>>r>>n;
    int count=0;
    for(int i=l;i<r+1;i++){
        if(i%n==0){
            count++;
        }
      
    }
  cout<<count<<endl;

}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A.reverse()
B.reverse()
before = sum(A)
for i in range(N):
    if B[i]<=A[i]:
        A[i]=A[i]-B[i]
    elif A[i]<B[i]<=A[i]+A[i+1]:
        A[i+1]=A[i]+A[i+1]-B[i]
        A[i]=0
    else:
        A[i]=0
        A[i+1]=0
after = sum(A)
print(before-after)

Measured memory_bytes: 18476
A,B,C,D=map(int,input().split())
 
if B<=C or D<=A:
    print(0)
elif A<=C and B<=D:
    print(B-C)
elif C<=A and D<=B:
    print(D-A)
elif A<=C and D<=B:
    print(D-C)
elif C<=A and B<=D:
    print(B-A)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int m;	/* ????¨??????° */
	int n_min, n_max;	 /* ?????????????????° ????°?, ?????§ */
	int data[200];
	int i;
	int max = 0;
	int through;

	/* ??\??? */
	while (scanf("%d %d %d", &m, &n_min, &n_max) == 3) {
		if (m == 0 && n_min == 0 && n_max == 0)
			break;

		for (i = 0; i < m; i++) {
			scanf("%d", &data[i]);
		}

		/* ?????? */
		for (i = n_max; i >= n_min; i--) {
			if ((data[i - 1] - data[i]) > max) {
				max = data[i - 1] - data[i];
				through = i;
			}
		}
		
		/* ?????? */
		printf("%d\n", through);

		/* ????????? */
		max = 0;
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n, m;
  cin >> n >> m;
  int gate[n + 5] = {};
  int l, r;
  rep(i,m){
    cin >> l >> r;
    gate[l] ++;
    gate[r + 1] --;
  }
  int ans = 0;
  reps(i,n){
    gate[i] += gate[i - 1];
    if(gate[i] == m){
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

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

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void YES(bool ok){
    cout << (ok ? "YES" : "NO") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,v; cin >> a >> v;
    ll b,w; cin >> b >> w;
    ll t; cin >> t;
    if(a < b){
        a += v * t;
        b += w * t;
        YES(a >= b);
        return 0;
    }
    else{
        a -= v * t;
        b -= w * t;
        YES(a <= b);
        return 0;
    }
}

Measured memory_bytes: 3652
N, W = map(int, input().split())

v = [0] * (N)
w = [0] * (N)

for i in range(N):
    v[i], w[i] = map(int, input().split())

dp = [-1] * (W + 1)
dp[0] = 0

for i in range(N):
    for j in range(W, -1, -1):
        if dp[j] >= 0 and j + w[i] <= W:
            dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i])

ans = 0

for i in range(W + 1):
    ans = max(ans, dp[i])

print(ans)



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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

bitset<2000 * 2000 + 10>b;

int main(){
	b[0] = 1;
	int n, sum = 0;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		b |= b << a;
		sum += a;
	}

	sum = (sum + 1) / 2;
	for (int i = sum;i<=2000*2000; i++) {
		if (b[i]) {
			pr(i);
			return 0;
		}
	}

		return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  long long a;
  double b;

  cin >> a >> b;

  long long bb = b * 100 + 0.5;

  cout << a * bb / 100 << "\n";

  return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int n;
void rec(ll num,int use,ll &res){
    if(num > n)return;
    if(use  == 0b111)res++;
    rec(num*10+7,use | 0b001,res);
    rec(num*10+5,use | 0b010,res);
    rec(num*10+3,use | 0b100,res);
}
signed main()
{   
    gearup;
    cin >> n;
    ll res = 0;
    rec(0,0,res);
    cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x:int(x)*2 ,input().split()))

dam = [0]*N
s = A[0]
for i in range(1,N):
    if i%2 == 1:
        s -= A[i]
    else:
        s += A[i]
dam[0] = s//2
    
for i in range(1,N):
    dam[i] = A[i-1]-dam[i-1]

[print(i,end=" ") for i in dam]

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


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

	ll n,m;
	cin >> n >> m;

	ll a[n][m];
	rep(i,n) rep(j,m){
		cin >> a[i][j];
		a[i][j]--;
	}

	bool used[m] = {};
	ll ans = n;

	// sport
	rep(i,m-1){ 
		vector<ll> b(m,0);

		// decide sport of each participant
		rep(j,n){ 

			// choose from "not used" sports
			rep(k,m){ 
				if(!used[a[j][k]]){
					b[a[j][k]]++;
					//cout << j << "," << k << "," << a[j][k] << "," << b[a[j][k]] << endl;
					break;
				} 
			}
		}

		// calc best sport
		ll mx = -1;
		ll ix = -1;

		rep(i,m){
			if(b[i] >= mx){
				mx = b[i];
				ix = i;
			}
		}
		ans = min(ans,mx);

		// best sport will be "used"
		used[ix] = true;
	}

	cout << ans << endl;
}

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


int main(){
    int A,B;
    cin >> A >> B;
    int ans=0;
    
    rep(z,2){
        if(A>=B){
            ans += A;
            A--;
        }else{
            ans += B;
            B--;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
S = list(input())

head = int("".join(S[:2]))
tale = int("".join(S[2:]))

if 1 <= head <= 12:
    if 1 <= tale <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= tale <= 12:
    print("YYMM")
else:
    print("NA")



Measured memory_bytes: 3064
object Main {
  def main(args: Array[String]): Unit = {
    val nums    = scala.io.StdIn.readInt
    val lengths = scala.io.StdIn.readLine.split( " " ).map{ _.toLong }.sorted
    var check_length = Array.empty[ Long ]
    var count = 0

    ( 0 until nums ).foreach{ i =>
      ( i + 1 until nums ).foreach{ j =>
        ( j + 1 until nums ).foreach{ k =>
          if( lengths( k ) < lengths( i ) + lengths( j ) &&
              lengths( j ) != lengths( k ) &&
              lengths( i ) != lengths( j )
            ) {
              count += 1
            }
        }
      }
    }
    println( count )
  }
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for (auto& a : as)
    {
        cin >> a;
    }
    int index_1 = 0;
    for (int i = 0; i < n; i++)
    {
        if (as[i] == 1)
        {
            index_1 = i;
        }
    }

    int unit = k - 1;
    cout << ((n - 1 + unit - 1) / unit) << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N), B(N + 1);
    rep(i, N){cin >> A.at(i);}
    B.at(0) = 0; rep(i, N){B.at(i + 1) = (B.at(i) + A.at(i));}
    map<ll, ll> x;
    rep(i, N + 1){
        ll remainder = B.at(i) % M;
        if (x.find(remainder) == x.end()){x[remainder] = 1;}else{x[remainder]++;}
    }
    ll ans = 0;
    for (auto a: x){
        ans +=  a.second * (a.second - 1) / 2;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>

using namespace std;

void ini(int a[],int b,int c){
	for(int i=0;i<c;i++){
		a[b+i]=0;
	}
}

bool check(int a[],int size){
	for(int i=0;i<size;i++){
		if(((i!=4&&i!=0)&&a[i]!=1)||((i==4||i==0)&&a[i]!=2)) return false;
	}
	return true;
}

int main(){

	string D;
	string data="AIDUNY";
	string deco="AIZUNYAN";
	int f[6];

	cin>>D;

	if(D.size()<8){
		cout<<D<<endl;
		return 0;
	}
	for(int i=0;i<=D.size()-8;i++){
		ini(f,0,6);
		for(int j=0;j<8;j++){
			if(data.find(D[i+j])!=-1) f[data.find(D[i+j])]++;
		}
		if(check(f,6)){
			for(int j=0;j<8;j++){
				D[i+j]=deco[j];
			}
			i+=7;
		}
	}

	cout<<D<<endl;

}

Measured memory_bytes: 1192
N=int(input())

A=list(map(int,input().split()))

flag=1
count=0

while flag>0:
    for i in range(N):
        if A[i]%2==0:
            A[i]=A[i]//2
        else:
            flag=-1
    if flag>0:
        count+=1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, sum = 0, t;
  cin >> a;
  t = a;
  for(; a > 0; a /= 10) sum += (a % 10);
  printf("%s\n", (t % sum == 0) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


int main(){
  int N;
  cin >> N;
  bool f = true;
  map<ll,ll> mp;
  rep(i,N){
    ll b;
    cin >> b;
    if(mp[b]){
      f = false;
      break;
    }
    mp[b]++;
  }
  cans(f);
  return 0;
}




Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
namespace Lesson02
{
    class MainClass
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }



        public static void Main (string[] args)
        {
            List<string[]> arr_result = new List<string[]>();
            arr_result = getinputdata ();

            int a = int.Parse(arr_result[0][0]);
            int b = int.Parse(arr_result[0][1]);

            Console.WriteLine(a * b + " " + (a + b) * 2);



        }
    }
}

Measured memory_bytes: 9308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>

#define INF 100100100

using namespace std;

int main() {
	vector<vector<int>>c(3,vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[j][i];
		}
	}
	for (int i = 0; i < 101; i++) {
		int b0 = c[0][0] - i;
		int b1 = c[1][0] - i;
		int b2 = c[2][0] - i;
		int a0 = i;
		int a1 = c[0][1] - b0;
		int a2 = c[0][2] - b0;
		if (b0 > *max_element(c[0].begin(), c[0].end()))continue;
		if (b1 > *max_element(c[1].begin(), c[1].end()))continue;
		if (b2 > *max_element(c[2].begin(), c[2].end()))continue;
		if (b0+a0 == c[0][0]&&b1+a0 == c[1][0]&&b2+a0 == c[2][0]
			&&b0+a1 == c[0][1] && b1+a1 == c[1][1] && b2+a1 == c[2][1]
			&&b0+a2 == c[0][2] && b1+a2 == c[1][2] && b2+a2 == c[2][2]) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    K = in_n()
    A = in_nl()[::-1]

    min_n = 2
    max_n = 2

    for group in A:

        cnt = -(-min_n // group)
        next_min = group * cnt
        if not (min_n <= next_min <= max_n):
            print(-1)
            exit()

        cnt = max_n // group
        next_max = cnt * group + (group - 1)

        min_n, max_n = next_min, next_max

    print(min_n, max_n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

void solve()
{
    string S;
    cin>>S;

    if(S.length() == 1)
    {
        if(S[0] == 's')
            S = S + "es";
        else
            S = S + "s";
        
    }
    
    else
    {
        int len = S.length();

        if(S[len - 1] == 's')
            S = S + "es";
        else
            S = S + "s";
    }

    cout<<S<<endl;
    
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();

    return 0;
}

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

int main() {
        long long int n,x,t;
        cin>>n>>x>>t;
        long long int i = n%x;
        long long int y=0;
        if(i>0)
        y=1;
        cout<<t*(n/x+y)<<endl;
	return 0;
}

Measured memory_bytes: 3640
using System;

class main{
	static void Main(){
		string str = Console.ReadLine().Trim();
		int[] num = new int[3];
		for(int i = 0; i < 3; i++){
			num[i] = 0;
		}
		for(int i = 0; i < 3; i++){
			num[str[i] - 'a']++;
		}
		if(num[0] == 1 && num[1] == 1 && num[2] == 1){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
	}
}

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

int main(){
  string s;
  cin >> s;
  
  vector<int> dir(4);
  for(int i = 0; i < (int)s.size(); i++){
    if(s.at(i) == 'N') dir.at(0) = 1;
    else if(s.at(i) == 'W') dir.at(1) = 1;
    else if(s.at(i) == 'S') dir.at(2) = 1;
    else dir.at(3) = 1;
  }
  
  bool ok = true;
  if(dir.at(0) ^ dir.at(2)) ok = false;
  if(dir.at(1) ^ dir.at(3)) ok = false;
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll s[300010], t[300010];
vector<ll> tree[610];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    rep(i,0,M){
        cin >> s[i] >> t[i];
        s[i]--; t[i]--;
        tree[s[i]].push_back(t[i]);
    }
    double ans = INF;
    rep(n,-1,N){ // n番目の部屋から出る通路を塞ぐ
        double dp[610] = {};
        bool ok = true;
        rrep(i,N-1,0){
            if(i == n){
                ll sz = tree[i].size();
                if(sz <= 1){
                    ok = false;
                    continue;
                }
                double v = 0.0;
                ll idx = -1;
                for(auto &e: tree[i]){
                    if(v < dp[e]){
                        v = dp[e];
                        idx = e;
                    }
                }
                for(auto &e: tree[i]){
                    if(idx != e) dp[i] += 1.0/(double)(sz-1) + dp[e] / (double) (sz-1);
                }


            }else{
                ll sz = tree[i].size();
                for(auto &e: tree[i]){
                    dp[i] += 1.0/(double)sz + dp[e] / (double) sz;
                }
            }
        }
        if(ok) ans = min(ans, dp[0]);
    }
    cout << setprecision(10) << ans << endl;

}

Measured memory_bytes: 6016
import java.io.IOException;

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

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println((1 + N) * N /2);
        }
    }
}


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

int main(){
  long long n,k;

  while(1) {
    long long ans=-1000000000;
    cin>>n>>k;
    if(n == 0 and k == 0) break;
    long long a[n];for(int i=0;i<n;i++)cin>>a[i];

    for(int i=0;i<n-k+1;i++){
      long long temp=0;
      for(int j=i;j<i+k;j++){
        temp+=a[j];
      }
      ans=max(temp,ans);
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void solve()
{
   int n,ct=0;
   cin>>n;
   int A[n];
   for (int i = 1; i <=n; ++i)
   {
     cin>>A[i];
     if(i%2!=0&&A[i]%2!=0)
     ct++;

   }
   cout<<ct;
 }
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {solve();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

Measured memory_bytes: 3772
#include <stdio.h>

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
  int has[N];
  for (int n = 0; n < N; ++n) has[n] = 0;
  
  for (int i = 0; i < K; ++i) {
    int d;
    scanf("%d", &d);
    for (int di = 0; di < d; ++di) {
      int A;
      scanf("%d", &A);
      ++has[A - 1];
    }
  }
  
  int hasNothing = 0;
  for (int n = 0; n < N; ++n) {
    //fprintf(stderr, "has[%d] = %d\n", n, has[n]);
    if (has[n] == 0) ++hasNothing;
  }
  printf("%d\n", hasNothing);
  return 0;
}

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

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n-1);
  rep(i,n-1) cin >> b[i];
  a[0] = b[0];
  for (int i = 0; i < n - 2; ++i) {
    a[i + 1] = min(b[i], b[i + 1]);
  }
  a[n-1] = b[n-2]; 
  int ans = 0;
  rep(i, n) {
    ans += a[i];
  }
  cout << ans << endl;
}

int main () {
  solve();
  return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"

int main()
{
	double a, b, t;
	int i,ans=0;
	cin >> a >> b >> t;
	t += 0.5;
	for (i = 1; a*i <= t; i++)
	{
		ans += b;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,c,k,s
    
    integer(8),allocatable :: b(:),a(:)
  
    read(*,*) n,m,c
    allocate(b(m))
    allocate(a(m))
    read(*,*)b
    k=0
    do i=1,n
        read(*,*)a
        s=0
        do j=1,m
            s=s+a(j)*b(j)
        end do
        if (s+c>0)then
            k=k+1
        end if
    end do


    write(*,*) k  
    stop
end program sample
  



Measured memory_bytes: 384
from itertools import permutations
*T, = map(int, open(0).read().split())
ans = 10**20
for p in permutations(T):
    r = 0
    for i, t in enumerate(p):
        if i < 4:
            r += (t+9)//10*10
        else:
            r += t
    ans = min(ans, r)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans;
  ans=0;
  cin>>n;
  for(int i=1;i<n;i++){
   for(int j=1;j<n;j++){
     if(i*j>=n){
       break;
     }
     else{
       ans++;
     }    
   }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<math.h>
int main(void){
    int n,i,count=0;
    scanf("%d",&n);
    int num[n];
    for(i=0;i<n;i++){
        scanf("%d",&num[i]);
    }
    for(i=1;i<n-1;i++){
        if(num[i]>num[i-1]&&num[i]<num[i+1]){
            count++;
        }else if(num[i]>num[i+1]&&num[i]<num[i-1]){
            count++;
        }
    }
    printf("%d",count);
}

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

#define N 500001
#define NIL NULL
struct Binary{
  int key;
  struct Binary *right;
  struct Binary *left;
  struct Binary *p;
};

void insert(int);
void inordertree(struct Binary *);
void preordertree(struct Binary *);

int n;
struct Binary *root;

int main(){
  int i,a;
  char c[20];
  char dummy;
  scanf("%d",&n);
  scanf("%c", &dummy);
  for(i=0 ; i<n ; i++){
    scanf("%s",c);
     
    if(strcmp(c,"insert")==0){
      scanf("%d",&a);
      insert(a);
    }
    else if(strcmp(c,"print")==0){    
      inordertree(root);
      printf("\n");
      preordertree(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int a){
  struct Binary *y=NIL,*x=root,*z;
  z = malloc(sizeof(struct Binary));
  z->left = NIL;
  z ->right = NIL;
  z->key = a;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inordertree(struct Binary *a){
  if(a!=NIL){
    inordertree(a->left);
    printf(" %d",a->key);
    inordertree(a->right);
  }
}

void preordertree(struct Binary *a){
  if(a!=NIL){
    printf(" %d",a->key);
    preordertree(a->left);
    preordertree(a->right);
  }
}



Measured memory_bytes: 25136
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
lisA = [0] + list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
# j-i == Ai+Aj => i+Ai == j-Aj
lisI = []
for i,num in enumerate(lisA):
    lisI.append(i+num)

cnt = Counter(lisI[1:])
ans = 0
for j,num in enumerate(lisA):
    if j == 0:
        continue
    elif j-num in cnt:
        ans += cnt[j-num]
    else:
        continue

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 0;
  rep(i,s.size()) {
    char c = s[i];
    if (c=='A' || c=='C' || c=='G' || c=='T') {
      cnt ++;
      ans = max(ans,cnt);
    }
    else {
      cnt = 0;
    }
  }
  cout << ans << endl;
}


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
#define MOD 1000000007
ll H,W;
char arr[1010][1010];
ll dp[1010][1010];
ll solve(ll i,ll j){
	if(i==H and j==W){
		return 1;
	}
	if(i>H or j>W){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	ll xx=0;
	if(arr[i+1][j]=='.'){
		xx=(xx+solve(i+1,j))%MOD;
	}
	if(arr[i][j+1]=='.'){
		xx=(xx+solve(i,j+1))%MOD;
	}
	dp[i][j]=xx%MOD;
	return dp[i][j];
}
int main(){
	cin>>H>>W;
	for(ll i=1;i<=H;i++){
		for(ll j=1;j<=W;j++){
			cin>>arr[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,1)%MOD<<endl;
	// cout<<dp[H][W]<<endl;
	return 0;
}

Measured memory_bytes: 9216
from scipy.sparse.csgraph import shortest_path as sp
n, m = map(int, input().split())
G = [[0 for i in range(n)] for i in range(n)]
edges = []
for i in range(m):
    a,b,c = map(int, input().split())
    G[a-1][b-1] = c
    edges.append((a-1,b-1,c))
dist = sp(G, method='D', directed=False)

ans = m
for a,b,c in edges:
    for s in range(n):
        if dist[s, a] + c == dist[s, b]:
            ans -= 1
            break
print(ans)


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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if (a < b) {
    if (a + W < b) {
      cout << b - a - W;
    }
    else {
      cout << 0;
    }
  }
  else {
    if (a > b + W) {
      cout << a - b - W;
    }
    else {
      cout << 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    stack<int> st;
    int n = s.size();
    //cout<<n<<endl;
    for(int i=0;i<n;i++){
        if(st.empty()){
            st.push(s[i]);
            continue;
        }
        int tmp=st.top();
        if(tmp=='S' && s[i]=='T'){
            st.pop();
        }
        else st.push(s[i]);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 1300
#include <stdio.h>

int main(void)
{
  	int	n;
  
  	scanf("%d", &n);
  
  	if(n >= 1800)
      printf("1");
  	else if (n >= 1600)
      printf("2");
  	else if (n >= 1400)
      printf("3");
    else if (n >= 1200)
      printf("4");
  	else if (n >= 1000)
      printf("5");
  	else if (n >= 800)
      printf("6");
  	else if (n >= 600)
      printf("7");
  	else if (n >= 400)
      printf("8");
  
  	return (0);
}

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

string s;
bool flag;

int main()
{
	cin >> s;
	int t, q;
	cin >> q;
	while (q--)
	{
		cin >> t;
		if (t == 1) flag = !flag;
		else 
		{
			int f;
			cin >> f;
			if (f == 2)
			{
				if (flag)
				{
					char c;
					cin >> c;
					s.insert(s.begin(), c);	
				}
				else
				{
					char c;
					cin >> c;
					s.insert(s.end(), c);
				}
			}
			else
			{	
				if (flag)
				{
					char c;
					cin >> c;
					s.insert(s.end(), c);	
				}
				else
				{
					char c;
					cin >> c;
					s.insert(s.begin(), c);
				}
			}
		}
	}
	if (flag) 
	{
		reverse(s.begin(), s.end());
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e18;
int main(){
  ll h, w;
  cin >> h >> w;
  ll res = INF;
  for (int k = 0; k < 2; k++) {
      for (int i = 1; i < h; i++) {
         ll a = i*w; 
         ll b = (w/2) * (h-i);
         ll c = ((w+1)/2) * (h-i);
         res = min(res, abs(max({a, b, c}) - min({a, b, c})));
         
         b = ((h-i)/2) * w;
         c = ((h-i+1)/2) * w;
         res = min(res, abs(max({a, b, c}) - min({a, b, c})));
      }
      swap(h, w);
   }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import math
list = input().split()
a = float(list[0])
b = float(list[1])
C = float(list[2])

C = math.radians(C)

S = a * b * math.sin(C) / 2
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(C))
L = a + b + c
h = 2 * S / a

print("{:.5f}".format(S))
print("{:.5f}".format(L))
print("{:.5f}".format(h))



Measured memory_bytes: 5692
import Control.Applicative
import Control.Monad
import Data.List
import System.IO
import Text.Printf

infixl 0 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  e <- isEOF
  when (not e) $ do
    [a, b] <- map read . words <$> getLine
    print $ solve a b
    main

solve :: Int -> Int -> Int
solve = length . show `dot` (+)



Measured memory_bytes: 3992
import java.util.LinkedList;
import java.util.Scanner;

class Graph_MST {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph_MST() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		for (int j = 0; j < totalVertex; j++) {
			ifSettled[j] = false;
			for (int i = 0; i < totalVertex; i++) {
				int weight = in.nextInt();
				if (weight != -1) {
					adjMatrix[i][j] = 1;
					adjWeight[i][j] = weight;
				}
				else {
					adjMatrix[i][j] = adjWeight[i][j] = 0;
				}
			}
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Prim(int s) {
		LinkedList<Integer> S = new LinkedList<Integer>();
		int[] dist = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++) {
			dist[i] = Integer.MAX_VALUE;
		}
		dist[s] = 0;
		while (S.size() < totalVertex) {
			int v = getUnsettledNearest(dist);
			S.add(v);
			LinkedList<Integer> neighbors = getUnsettledNeighbors(v);
			for (int x : neighbors) {
				dist[x] = Math.min(getWeight(v,x), dist[x]);
			}
			ifSettled[v] = true;
		}
		return dist;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph_MST g = new Graph_MST();
		g.loadAdjMatrix();
		int[] dist = g.Prim(0);
		int sum = 0;
		for(int d : dist) {
			sum = sum + d;
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 41048
from itertools import combinations 

N=input()
L=[int(x) for x in input().split()]
comb = combinations(L, 3)
c = 0
for x in comb:
    t=list(x)
    t.sort()
    if t[0]!=t[1] and t[1]!=t[2] and t[0]!=t[2] and t[0]+t[1]>t[2]:
        c += 1
print(c)

Measured memory_bytes: 9188
#include <stdio.h>
#define MAX 100005
#define NIL -1
typedef struct node{
    int p,l,r;
} node;
 
node T[MAX];
int n,D[MAX];
 
void print(int u){
    int i,c;
    printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
    if(T[u].p == NIL)
        printf("root, ");
    else if(T[u].l == NIL)
        printf("leaf, ");
    else
        printf("internal node, ");
    printf("[");
    for(i=0,c=T[u].l;c != NIL;i++,c=T[c].r){
        if(i)
            printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}
 
int rec(int u,int p){
    D[u]=p;
    if(T[u].r != NIL)
        rec(T[u].r,p);
    if(T[u].l != NIL)
        rec(T[u].l,p+1);
}
 
int main(void){
    int i,o,d,v,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        T[i].p=T[i].l=T[i].r=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d",&v,&d);
        for(o=0;o<d;o++){
            scanf("%d",&c);
            if(!o)
                T[v].l=c;
            else
                T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++)
        if(T[i].p == NIL)
            r=i;
    rec(r,0);
    for(i=0;i<n;i++)
        print(i);
    return 0;
}


Measured memory_bytes: 6476
#include<map>
#include<cstdio>
#include<string>
#include<vector>

#define	mp		make_pair
#define	pb		push_back

using namespace std;

typedef	pair<int,int>	pii;

const int inf=1<<29;

int main(){
	for(int n;scanf("%d",&n),n;){
		int unum=0;
		pair<pii,int> edge[100];
		map<string,int> name;
		for(int i=0;i<n;i++){
			int pw;
			char u1[17],u2[17];
			scanf("%*d %s %*c %*d%*c%d %s",u1,&pw,u2);

			int id1,id2;
			if(name.count(u1)==0)	name[u1]=unum++;
			id1=name[u1];
			if(name.count(u2)==0)	name[u2]=unum++;
			id2=name[u2];

			edge[i]=mp(mp(id1,id2),pw);
		}

		bool ok=true;
		static int wf[200][200];
		for(int i=0;i<unum;i++)for(int j=0;j<unum;j++)	wf[i][j]=(i==j?0:inf);
		for(int k=0;k<n;k++){
			int from=edge[k].first.first,to=edge[k].first.second,dis=edge[k].second;
			if(wf[from][to]==inf){
				wf[from][to]=dis;
				wf[to][from]=-dis;
				for(int i=0;i<unum;i++)for(int j=0;j<unum;j++){
					if(wf[i][from]==inf || wf[to][j]==inf)	continue;
					wf[i][j]=min(wf[i][j],wf[i][from]+dis+wf[to][j]);
					wf[j][i]=-wf[i][j];
				}
			}
			else{
				if(wf[from][to]!=dis){
					ok=false;
					break;
				}
			}
		}
		puts(ok?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
   int i,n,x;
   cin >>n;
   for(i=1;i<=n;i++){
       x=i;
       if(x%3==0) cout <<" "<<i;
       else{
           while(1){
               if(x%10==3) {
                   cout <<" "<<i;
                   break;
               }
               x/=10;
               if(x==0) break;
           }
       }
   }
   cout << endl;
  
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
// Seiranchan!
    int H,W;
    cin >> H >> W;

    vector<string> A(H);
    REP(i,H) cin >> A[i];

    vector<bool> row(H,false);
    vector<bool> col(W,false);

    REP(i,H){
        REP(j,W){
            if(A[i][j]=='#'){
                row[i]=true;
                col[j]=true;
            }
        }
    }

    REP(i,H){
        if(row[i]){
            REP(j,W){
                if(col[j]){
                    cout << A[i][j];
                }
            }
            cout << endl;
        }
}

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c;

  scanf("%d %d %d",&a,&b,&c);

  if(a==b)
    printf("%d\n",c);
  else if(b==c)
    printf("%d\n",a);
  else
    printf("%d\n",b);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define MAX 300

int main() {
    //変数の宣言
    int h[MAX], w[MAX];
    int count = 0; //箱用
    int i, a, b, c; //処理用
    
    //入力
    while (1) {
        scanf("%d %d", &h[count], &w[count]);
        
        if (h[count] == 0 && w[count] == 0) { //どちらも0だった場合
            break;  //ループ終了
        }
        
        count++; //カウンター増やす
    }
    
    for (i=0; i<count; i++) { //箱を回す
        for (a=0; a<h[i]; a++) { //縦
            for (b=0; b<w[i]; b++) { //横
                if (a == 0 || a == h[i] - 1 || b == 0 || b == w[i] - 1) { //最初または最後の列：全部#
                    printf("#");
                }else{          //それ以外（間）
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2104
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(isPalindrom(S,0,S.length()-1)) {
			if(isPalindrom(S,0,(S.length()-2)/2)) {
				if(isPalindrom(S,(S.length()+2)/2,S.length()-1)) {
					System.out.println("Yes");
				}
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}
		
	
	}
	public static boolean isPalindrom(String S,int minIdx,int maxIdx) {
//		int minIdx = 0;
//		int maxIdx = S.length()-1;
		while(minIdx<maxIdx) {
			if(S.charAt(minIdx++)!=S.charAt(maxIdx--)) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 21844
n,m=map(int,input().split())
l=list(map(int,input().split()))
not_good=[]
for i in range(m):
  a,b=map(int,input().split())
  if l[a-1]>l[b-1]:
      not_good.append(b)
  if l[a-1]<l[b-1]:
      not_good.append(a)
  if l[a-1]==l[b-1]:
    not_good.append(a)
    not_good.append(b)

not_good=set(not_good)
print(n-len(not_good))


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

int main() { 
  int r,g,b;
  cin >> r >> g >> b;
  
  int sum = 100 * r + 10 * g + b;
  
  if(sum % 4 == 0) {
    cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  }
}

Measured memory_bytes: 3576
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    LL N, A, B;
    cin >> N >> A >> B;

    LL ans = 0;
    if ((B-A)%2) {
        if (A-1 < N-B) {
            ans = A + (B-A-1)/2;
        } else {
            ans = N-B+1 + (B-A-1)/2;
        }
    } else {
        ans = (B-A) / 2;
    }

    cout << ans << endl;


    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

struct P {
  int cost, value;
  int grass;
};

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  vector<P> X(N);
  rep(i, N) cin >> X[i].value;
  rep(i, N) cin >> X[i].cost;
  rep(i, N) {
    X[i].grass = X[i].value - X[i].cost;
  }
  int sum {};
  rep(i, N) {
    if (X[i].grass > 0) sum+=X[i].grass;
  }
  cout << sum << '\n';
}


Measured memory_bytes: 256