akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split( )))
a.append(-1)
m=int(input())
b=list(map(int,input().split( )))
b.append(-1)
i=0
while True:
    if a[i]<b[i]:
        print(1)
        break
    elif a[i]>b[i]:
        print(0)
        break
    elif a[i] == -1 and b[i] == -1:
        print(0)
        break
    i+=1



Measured memory_bytes: 5624
#include <algorithm>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=100010;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;char ch=getchar();int f=0;
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
struct data{
	int x,y;
	bool operator < (const data &t)const{return x==t.x?y<t.y:x<t.x;}
}tmp;
int n,x,y,t,cnt,f[maxn];
queue<data> q;
set<int> s[maxn];
map<data,int> ma;
set<int>::iterator itr;
inline int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
void input()
{
	int u,v;
	read(n);n=n+n-1;
	for(rg int i=1;i<n;i++)
	{
		read(u);read(v);
		s[u].insert(v);s[v].insert(u);
		ma[(data){u,v}]++;ma[(data){v,u}]++;
		if(ma[(data){u,v}]==2) q.push((data){u,v});
	}
	n=(n+1)>>1;
}
int main()
{
	input();
	for(rg int i=1;i<=n;i++) f[i]=i;
	while(!q.empty())
	{
		tmp=q.front();q.pop();
		x=find(tmp.x);y=find(tmp.y);
		s[x].erase(y);s[y].erase(x);
		if(s[x].size()<s[y].size()) swap(x,y);
		for(itr=s[y].begin();itr!=s[y].end();itr++)
		{
			t=*itr;
			ma[(data){y,t}]=0;ma[(data){t,y}]=0;
			ma[(data){x,t}]++;ma[(data){t,x}]++;
			if(ma[(data){x,t}]==2) q.push((data){x,t});
			s[x].insert(t);s[t].insert(x);s[t].erase(y);
		}
		f[y]=x;s[y].clear();
	}
	for(rg int i=1;i<=n&&cnt<=1;i++) if(find(i)==i) cnt++;
	if(cnt==1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 56192
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		boolean isMMYY = true;
		boolean isYYMM = true;

		String frontStr = s.substring(0,2);
		String backStr = s.substring(2,4);

		int frontInt = Integer.parseInt(frontStr);
		int backInt = Integer.parseInt(backStr);

		if (frontInt == 0 || frontInt > 12) isMMYY = false;
		if (backInt == 0 || backInt > 12) isYYMM = false;

		if (isMMYY && isYYMM) System.out.println("AMBIGUOUS");
		else if (isMMYY) System.out.println("MMYY");
		else if (isYYMM) System.out.println("YYMM");
		else System.out.println("NA");

	}
}

Measured memory_bytes: 21972
o = input()
n1 = len(o)
e = input()
n2 = len(e)
if n1 == n2:
  for i in range(n1):
    print(o[i] + e[i], end = "")
else:
  for i in range(n2):
    print(o[i] + e[i], end = "")
  print(o[n1 - 1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;


signed main(){
  int N,t;cin>>N>>t;
  int ans=t;
  REP(i,0,N-1){
    cin>>t;
    ans=lcm(ans,t);
  }
  print(ans)

}


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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if((A-B)>=C) {
			out.println(0);
		}else {
			out.println(C-(A-B));
		}
		
		
		out.flush();
	}

}

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

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

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

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

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

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

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntsN(int N) {
		int[] ints = new int[N];
		for (int i = 0; i < N; i++) {
			ints[i] = nextInt();
		}
		return ints;
	}
	
	public long[] nextLongsN(int N) {
		long[] longs = new long[N];
		for (int i = 0; i < N; i++) {
			longs[i] = nextLong();
		}
		return longs;
	}
	
	public char[] nextCharsN(int N) {
		char[] chars = new char[N];
		String msg=next();
		for (int i = 0; i < N; i++) {
			chars[i] = msg.charAt(i);
		}
		return chars;
	}

	public char[][] nextCharsHW(int H, int W) {
		char[][] chars = new char[H][W];
		for (int i = 0; i < H; i++) {
			String str = next();
			for (int j = 0; j < W; j++) {
				chars[i][j] = str.charAt(j);
			}
		}
		return chars;
	}

	public int[][] nextIntsNM(int N, int M) {
		int[][] ints = new int[N][M];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				ints[i][j] = nextInt();
			}
		}
		return ints;
	}
}


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int A,B;

	cin >> A >> B;

	int ans=0;
	int cnt=1;
	for(int i=0;;i++)
	{
		if(cnt>=B)break;
		cnt+=A-1;
		ans++;
	}

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



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

using namespace std;

int g[505][505];

void solve() {
    int n,m,q;
    cin >> n >> m >> q;
    while (m--) {
        int x,y;
        cin >> x >> y;
        g[x][y]++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            g[i][j] += g[i][j-1];
        }
        for (int j = 1; j <= n; j++) {
            g[i][j] += g[i-1][j];
        }
    }
    auto sum = [&](int x,int y,int u, int v){
        return g[u][v] - g[x-1][v]-g[u][y-1]+g[x-1][y-1];
    };
    while (q--) {
        int x,y;
        cin >> x >> y;
        cout << sum(x,x,y,y) << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
int n,k,d,s;
cin >> n >> k;
vector<int> snk(n,0);
rep(i,k){
    cin >> d;
    rep(j,d){
        cin >> s;
        snk[s-1]++;
    }
}
int ans=0;
rep(i,n){
    if(snk[i]==0)ans++;
}
cout << ans << endl;
return 0;

}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[])
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$t = explode(' ', trim(fgets(STDIN)));
fscanf(STDIN, "%d", $m);
$ret = [];
for($i = 0; $i < $m; $i++) {
    $px = explode(' ', trim(fgets(STDIN)));
    $tmp = $t;
    $tmp[$px[0] - 1] = $px[1];
    echo array_sum($tmp). PHP_EOL;
}

Measured memory_bytes: 5112
#include <cstdio>

using namespace std;

#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)
#define MAX 5000000
#define INFTY 20000000000

typedef long long int ll;
ll L[MAX / 2 + 2], R[MAX / 2 + 2];
int counter = 0;

void merge(ll A[], ll left, ll mid, ll right) {
    ll n1 = mid - left;
    ll n2 = right - mid;
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = R[n2] = INFTY;
    ll i = 0, j = 0;
    REP(k, left, right) {
        counter++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(ll A[], ll left, ll right) {
    if (left + 1 < right) {
        ll mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    ll n;
    scanf("%d", &n);
    ll S[MAX];
    rep(i, n) scanf("%d", &S[i]);
    mergeSort(S, 0, n);

    for (ll i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%lld", S[i]);
    }
    printf("\n");
    printf("%d\n", counter);
    return 0;
}



Measured memory_bytes: 10504
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

vector<int> factorize(int n)
{
	vector<int> v;
	for (int x = 2; x * x <= n; ++x) {
		for (; n % x == 0; n /= x) {
			v.push_back(x);
		}
	}
	if (n != 1) {
		v.push_back(n);
	}
	return v;
}

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> d(1000, 1);
	for (int x = 1; x <= N; ++x) {
		for (int y : factorize(x)) {
			++d[y];
		}
	}
	int ans = accumulate(d.begin(), d.end(), 1, [](int a, int b) -> int {
		return (long long)a * b % MOD;
	});
	cout << ans << endl;
}


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

using namespace std;

string s[51];
int n, m;
int cnt, ans;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool marked[51][51];

int dfs(int x, int y){
	marked[x][y] = 1;
	if(s[x][y] == '#') ans++;
	//cout << x << " " << y << endl;
	//cout << s[x][y] << " ans=" << ans << endl;
	int total = 1;
	for(int mov = 0; mov < 4; mov++){
	  int nx = x + dy[mov];
		int ny = y + dx[mov];
		if(nx < 0) nx = n - 1;
		if(nx >= n) nx = 0;
		if(ny < 0) ny = m - 1;
		if(ny >= m) ny = 0;
		if(!marked[nx][ny] && s[x][y] != '.')
			total += dfs(nx, ny);
	}
	return total;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	cnt = 0, ans = 0;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		for(int j = 0; j < m; j++){
			if(s[i][j] == '#'){
				cnt++;
			}
		}
	}                  	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(s[i][j] == '#' && !marked[i][j])
				if(dfs(i, j) < 2){
					cout << "No\n";
					return 0;
				}
		}
	}
	if(ans == cnt) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

int main()
{
	string S;
	cin >> S;
	if (S.length() == 2) {
		cout << S << endl;
	}
	else {
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}





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

  ll N , K ; cin >> N >> K;

  ll now = 1;

  rep(i,N){
    if(now < K) now *= 2;
    else now += K; 
  }

  cout << now << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > vec;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> k)
    {
        vec.clear();

        for(i = 0; i < n; i++)
        {
            slld(input);

            vec.push_back(input);
        }

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


        if(n <= k)
        {
            cout << 0 << endl;
            continue;
        }

        ll sum = 0;

        for(i = 0; i < (n - k); i++)
        {
            sum += vec[i];
        }

        cout << sum << endl;


    }


}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
#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 SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int r;
  cin >> r;
  double PI = M_PI;
  cout << SYOU(5) << 2 * r * PI << '\n';
  return 0;
}


Measured memory_bytes: 3756
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	vector<int>v(5);
	int id = 5;
	int M = 10;
	for (int i = 0; i < 5; i++) {
		cin >> v[i];
		if (v[i] % 10 != 0 && M > v[i] % 10) {
			M = v[i] % 10;
			id = i;
		}
	}
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		if (i == id) {
			ans += v[id];
		}
		else {
			if (v[i] % 10 != 0) {
				int m = 10 - v[i] % 10;
				ans += v[i] + m;
			}
			else {
				ans +=v[i];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool b = true;
  for(int i = 0; i < s.size(); i++) {
    if(i % 2 == 0 && s.at(i) == 'L')
      b = false;
    if(i % 2 == 1 && s.at(i) == 'R')
      b = false;
  }
  cout << (b? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b,c; cin >> a >> b >> c;
	if ( (b - a) == (c - b) ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,a[100005];
bool ok=1;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        ++a[x],++a[y];
    }
    for(int i=1;i<=n;++i)if(a[i]&1)ok=0;
    if(ok)puts("YES");
    else puts("NO");
    //system("pause");
    return 0;
}


Measured memory_bytes: 640
/**    epsileer 01 September 2019  17:51:59  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    LL n; cin>>n;
    LL ans = (n*(n-1))/2;
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}

/*Library End!*/
int n, c[505], s[505], f[505], cnt;
signed main(){
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i; j < n; j++) {
			if (cnt <= s[j])cnt = s[j] + c[j];
			else cnt = (cnt + f[j] - 1) / f[j] * f[j] + c[j];
		}
		cout << cnt << endl;
		cnt = 0;
	}
end:;
	system("PAUSE");
	return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll> dp(n+1,0);
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin >> a.at(i);
  }
  
  auto itr = find(a.begin(),a.end(),1);
  if(itr == a.end()){
    dp.at(1) = 1;
  }
  
  itr = find(a.begin(),a.end(),2);
  if(n>1){
    if(itr != a.end()){
      dp.at(2) = 0;
    }else{
      dp.at(2) = dp.at(1) + 1;
    }
  }
  
  for(int i=3;i<n+1;i++){
    itr = find(a.begin(),a.end(),i);
    if(itr == a.end()){
      dp.at(i) = (dp.at(i-1) + dp.at(i-2)) % nmax;
    }else{
      dp.at(i) = 0;
    }
  }
	
  cout << dp.at(n) << endl;
  return(0);
}

Measured memory_bytes: 4260
using System;

namespace _055_Sequence
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				decimal num = decimal.Parse (inputStr);

				decimal sum = num;	//1
				sum += num *= 2;	//2
				sum += num /= 3;	//3
				sum += num *= 2;	//4
				sum += num /= 3;	//5
				sum += num *= 2;	//6
				sum += num /= 3;	//7
				sum += num *= 2;	//8
				sum += num /= 3;	//9
				sum += num *= 2;	//10

				Console.WriteLine (sum);
			}
		}
	}
}

Measured memory_bytes: 9296
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>



using namespace std;




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

	const int nmmax = 50;
	char A[nmmax][nmmax], B[nmmax][nmmax];


	for (int y = 0; y < N; ++y) {
		for (int x = 0; x < N; ++x) {
			cin >> A[y][x];
		}
	}

	for (int y = 0; y < M; ++y) {
		for (int x = 0; x < M; ++x) {
			cin >> B[y][x];
		}
	}

	bool exist = false;

	for (int ly = 0; ly < N; ++ly) {
		for (int lx = 0; lx < N; ++lx) {
			if (ly + M - 1 >= N or lx + M - 1 >= N) continue;

			bool match = true;
			for (int y = 0; y < M; ++y) {
				for (int x = 0; x < M; ++x) {
					if (A[ly + y][lx + x] != B[y][x]) match = false;
				}
			}
			if (match) exist = true;
		}
	}

	if (exist)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1;
    }
    else if(n == 1){
        cout << m - 2;
    }
    else if(m == 1){
        cout << n - 2;
    }
    else{
        cout << (n - 2) * (m - 2);
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
	// write your code here
        FastReader fr = new FastReader();
        int temp = fr.nextInt();
        int math = temp / 3;
        System.out.println(math);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    //SOURCE: https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll f(ll x, int c, int d) {
    ll res = x;
    res -= x / c;
    res -= x / d;
    res += x / lcm(c, d);
    return res;
}

int main() {
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b, c, d) - f(a - 1, c, d);
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		int tmp = 0;
		vector<int> ans;
		for(int i = 9; i >= 0; i--){
			if(n - pow(2, i) >= 0){
				ans.push_back(pow(2, i));
				n -= pow(2, i);
			}
		}
		sort(ans.begin(), ans.end());
		for(int i = 0; i < ans.size() - 1; i++){
			cout << ans[i] << " ";
			tmp = i + 1;
		}
		cout << ans[tmp] << endl;
	}
}

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

int main(){
  int n,a,b;cin>>n>>a>>b;
  int x[n];
  for(int i=0;i<n;i++) cin>>x[i];
  long long ans=0;
  for(int i=1;i<n;i++){
    ans+=min((long long)a*(long long)(x[i]-x[i-1]),(long long)b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();
        TreeSet<String> set = new TreeSet<>();
        for (int i = 0; i < s.length(); i++) {
             for (int j = i, x = 0; j < s.length() && x < 5; j++, x++) {
                  set.add(s.substring(i, j + 1));
             }
        }
        set.stream().skip(k-1).findFirst().ifPresent(System.out::println);
    }
}

Measured memory_bytes: 29012
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::collections::HashSet;

fn divisors(N: i32) -> HashSet<i32> {
  let mut ds = vec![];
  let mut d = 1;
  while d * d <= N {
    if N % d == 0 {
      ds.push(d);
      ds.push(N / d);
    }
    d += 1;
  }
  let uniq: HashSet<i32> = ds.into_iter().collect();
  uniq
}

use std::cmp::{max, min};
use std::collections::BinaryHeap;

fn main() {
  let n = read::<i32>();
  let mut memo = vec![];

  for _ in 0..n {
    let a_i = read::<i32>();
    memo.push(a_i);
  }

  // println!("memo:{:?}", memo);

  for i in 0..n {
    let rev_i = (n - i - 1) as usize;
    let rev_num = n - i;

    if (memo[rev_i]) % 2 == 1 {
      let yakusuu = divisors(rev_num);
      // println!("yakusuu: {:?}", yakusuu);
      for j in yakusuu {
        if j != rev_num {
          memo[(j - 1) as usize] = (memo[(j - 1) as usize] + 1) % 2;
        }
      }
      // println!("{:?}", memo);
    }
  }

  // println!("memo: {:?}", memo);

  let mut ans = String::from("");
  let mut sum = 0;


  for (i, v) in memo.iter().enumerate() {
    if *v != 0 {
      sum += 1;
      ans.push_str(&(i + 1).to_string());
      if i + 1 != n as usize {
        ans.push(' ');
      }
    }
  }

  // TODO 合成を出す
  println!("{}", sum);
  if sum != 0 {
    println!("{}", ans);
  }

}



Measured memory_bytes: 7164
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  int N,M,ac,wa;
  ac=0;
  wa=0;
  cin>>N>>M;
vector<int> P(M,0);
vector<int> ok(N+1,0);
vector<int> clear(N+1,0);
string S[M];
for(int i=0;i<M;i++){
  cin>>P[i]>>S[i];
  if(S[i]=="AC"){clear[P[i]]=1;}
}
for(int i=0;i<M;i++){

if(ok[P[i]]==0&S[i]=="WA"&clear[P[i]]==1){
  wa++;
    }else if(ok[P[i]]==0&S[i]=="AC"){
  ac++;
  ok[P[i]]=1;
}
}


   cout<<ac<<" "<<wa;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

int main() {
  ll N,M;
  cin >> N >> M;
  int A[M],B[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  UnionFind uf(N);
  ll ans[M+1];
  ans[M] = (N * (N-1))/2LL;
  for (int i = M-1; i >= 0; i--) {
    if (uf.same(A[i],B[i])) {
      ans[i] = ans[i+1];
    } else {
      ans[i] = ans[i+1] - ((ll)uf.size(A[i]) * (ll)uf.size(B[i]));
      uf.unite(A[i],B[i]);
    }
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 5496
#include <iostream>

int main() {
    using namespace std;
    int a[9];
    for (int i=0; i<9; i++){
        cin >> a[i];
    }
    int n, b;
    cin >> n;
    for (int j=0; j<n; j++) {
        cin >> b;
        for (int i=0; i<9; i++){
            if (a[i] == b) {
                a[i] = -1;
            }
        }
    }
    if ((a[0]+a[1]+a[2]==-3) || (a[3]+a[4]+a[5]==-3) || (a[6]+a[7]+a[8]==-3) || 
        (a[0]+a[3]+a[6]==-3) || (a[1]+a[4]+a[7]==-3) || (a[2]+a[5]+a[8]==-3) ||
        (a[0]+a[4]+a[8]==-3) || (a[2]+a[4]+a[6]==-3)) {
            cout << "Yes";
        }
    else cout << "No";
}

Measured memory_bytes: 3560
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

int main() {
    long long n,k;
    cin>>n>>k;
    n=n%k;
    long long prevn=n;
    while (true) {
        if (abs(n-k) < prevn) {
            prevn=n;
            n=abs(n-k);
        } else {
            cout << n;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
ans=0
for i in range(n):
  count=0
  for ii in range(n):
    if s[i]==s[ii]:
      count+=1
  for jj in range(m):
    if s[i]==t[jj]:
      count-=1
  ans=max(count,ans)
print(ans)

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

int main(){
    int N;
    cin >> N;
    double p[3000];
    for(int i=1;i<=N;i++)
        cin >> p[i];

    double dp[N+1][N+1]; // dp[i][j] : i枚目までのコインにおいて、表がj枚である確率
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for(int i=2;i<=N;i++){
        for(int j=0;j<=i;j++){
            // 表裏 + 裏表
            dp[i][j] = dp[i-1][j]*(1 - p[i]);   // j枚 → J枚
            if(j != 0)
                dp[i][j] += dp[i-1][j-1]*p[i];  // j-1枚 → J枚
        }
    }

    double ans = 0;
    for(int i=N/2+1;i<=N;i++)
        ans += dp[N][i];

    printf("%.10lf\n", ans);

}


Measured memory_bytes: 70400
h,w,a,b = map(int,input().split())

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,h+w+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

ans = 0

for i in range(100000):
    x = h-a-i
    y = b+1+i
    
    if 0 >= x or y > w:
        break
    
    ans += nCr(h+w-x-y,h-x,mod)*nCr(x+y-2,x-1,mod)%mod
    ans %= mod
print(ans)




Measured memory_bytes: 27024
#include <stdio.h>

int main(void)
{
    int i,j,k,n,x,count;
   
 do{
    scanf("%d %d",&n,&x);
  
    if(n == 0 && x == 0)
    break;
   
    count = 0;
   
    for(i = 1;i < n-1;i++){
    	for(j = i+1;j < n;j++){
    		for(k = j+1;k < n+1;k++){
    			if(i+j+k==x){
    				count = count + 1;
    			}
    		}
    	}
    }
   	 printf("%d\n",count);
   }while(1);
		
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CINVEC(A, 3);
  sort(A.begin(), A.end());

  ANS(A.at(0) + A.at(1));

  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    if (n % 2 > 0) {
        puts("0");
        return 0;
    }
    li wari = 5;
    li res = 0;
    n /= 2;
    while (wari <= n) {
        res += n / wari;
        wari *= 5;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define BLACK 1
#define INF 2001
#define NIL -1

int G[MAX][MAX],n,d[MAX],pi[MAX],color[MAX];

void Prim(int r){
  int i;
  for(i=1;i<=n;i++){
    d[i]=INF;
    pi[i]=NIL;
  }
  d[r]=0;
  while(1){
	int u,mincost = INF;
	for(i=1;i<=n;i++){
  	if(color[i]!=BLACK && d[i]<mincost){
    mincost = d[i];
    u = i;
  	}
	}

	if(mincost==INF)break;
  //printf("min:%d\n",mincost);
	color[u]=BLACK;

	for(i=1;i<=n;i++){
  	if(color[i]!=BLACK && G[u][i]<d[i] && G[u][i]!=-1){
    pi[i] = u;
    d[i] = G[u][i];
  	}
	}
  }
}

int main(){
  int i,j,sum=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
	   for(j=1;j<=n;j++){
  	    scanf("%d",&G[i][j]);
  	}
  }
  Prim(1);
  for(i=1;i<=n;i++){
	//printf("%d %d %d\n",G[i][pi[i]],d[i],pi[i]);
		sum+=d[i];
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2108
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;

    ll st=0,cnt=0;
    while(st<n)
    {
        st=st+power(10,cnt)*7;
        cnt++;
    }
   ll tot=10000000;
   ll p=cnt;
    ll fl=1;
    while(p<tot)
    {
       ll rem=st%n;
        if(rem==0)
        {
            fl=0;
            break;
        }
        st=rem*10+7;
        p++;
    }
    if(fl==0)
    cout<<p<<endl;
    else
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3636
// 2011/07/12 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		string str;
		cin >> str;
		if(cin.eof())
			break;

		for(int i=0; i<str.size(); i++)
			if(str[i]==',')
				str[i] = ' ';

		istringstream ist(str);
		int num[5];
		for(int i=0; i<5; i++)
			ist >> num[i];

		for(int i=0; i<4; i++)
			for(int j=i+1; j<5; j++)
				if(num[i]>num[j]){
					int tmp = num[i];
					num[i] = num[j];
					num[j] = tmp;
				}

		if(num[0]==num[1]&&num[1]==num[2]&&num[2]==num[3])
			cout << "four card" << endl;
		else if(num[1]==num[2]&&num[2]==num[3]&&num[3]==num[4])
			cout << "four card" << endl;
		else if(num[0]==num[1]&&num[1]==num[2]&&num[3]==num[4])
			cout << "full house" << endl;
		else if(num[0]==num[1]&&num[2]==num[3]&&num[3]==num[4])
			cout << "full house" << endl;
		else if(num[0]+1==num[1]&&num[1]+1==num[2]&&num[2]+1==num[3]&&num[3]+1==num[4])
			cout << "straight" << endl;
		else if(num[0]==1&&num[1]==10&&num[2]==11&&num[3]==12&&num[4]==13)
			cout << "straight" << endl;
		else if(num[0]==num[1]&&num[1]==num[2])
			cout << "three card" << endl;
		else if(num[1]==num[2]&&num[2]==num[3])
			cout << "three card" << endl;
		else if(num[2]==num[3]&&num[3]==num[4])
			cout << "three card" << endl;
		else if(num[0]==num[1]&&num[2]==num[3])
			cout << "two pair" << endl;
		else if(num[0]==num[1]&&num[3]==num[4])
			cout << "two pair" << endl;
		else if(num[1]==num[2]&&num[3]==num[4])
			cout << "two pair" << endl;
		else if(num[0]==num[1])
			cout << "one pair" << endl;
		else if(num[1]==num[2])
			cout << "one pair" << endl;
		else if(num[2]==num[3])
			cout << "one pair" << endl;
		else if(num[3]==num[4])
			cout << "one pair" << endl;
		else
			cout << "null" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			char[] c = br.readLine().toCharArray();
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < c.length; i++) {
				if(i == 4){
					System.out.print(" ");
				}

				System.out.print(c[i]);
			}
			System.out.println();
		} catch (Exception e) {
			System.err.println("Error:" + e.getMessage());
		}
	}
}

Measured memory_bytes: 8148
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> P(N);
    for (int& x : P) cin >> x;
    int res = 0;
    for (int i = 0; i + 2 < N; i++) {
      if (P[i] < P[i + 1] && P[i + 1] < P[i + 2]) {
        ++res;
      } else if (P[i] > P[i + 1] && P[i + 1] > P[i + 2]) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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


int main() {

  int n;
  cin>>n;

  vector<int> A(n);
  map<int, int> dup;
  for(int i=0;i<n;i++){
    cin>>A.at(i);
    if(dup.count(A.at(i)))
      dup.at(A.at(i))++;
    else
      dup[A.at(i)]=1;
  }

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

  int A_max=A.at(n-1);
  vector<bool> check(A_max+1,false);
  for(int i=0;i<n;i++){
    for(int j=2*A.at(i);j<=A_max;j+=A.at(i)){
        check.at(j)=true;
    }
  }

int cnt=0;
for(int i=0;i<n;i++){
  if(check.at(A.at(i))==false&&dup.at(A.at(i))<=1)
    cnt++;
}

  cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 13384
import sys
from cmath import pi, rect

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

A, B, H, M = map(int, read().split())

H += M / 60

t1 = 2 * pi * H / 12
t2 = 2 * pi * H

z1 = rect(A, t1)
z2 = rect(B, t2)

print(abs(z1 - z2))


Measured memory_bytes: 9556
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.trim();
    var A = input.split(' ')[0];
    A = parseInt(A);
    var B = input.split(' ')[1];
    B = parseInt(B);
    var C = input.split(' ')[2];
    C = parseInt(C);
    var K = input.split(' ')[3];
    K = parseInt(K);
    var count = 0;
    Number(count);
    if (K >= A) {
        count = count + A;
        K = K - A;
    } else {
        count = count + A - (A - K);
        K = K - A;
    }
    if (K - B > 0) {
        K = K - B;
        if (K >= C) {
            count = count - C;
        } else {
            count = count - C + (C - K);
        }
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29884
#include <stdio.h>

typedef struct{
	int sum_v;
	int sum_w;
}tre;

int max_w, n, v[1000], w[1000];
int sum_w;
tre memo[1001][1001];

tre dp(int i, int j);

int main(void){
	int num = 1;
	int i, j;
	tre treasure;

	while(1){
		scanf("%d", &max_w);
		if(max_w == 0) break;
		scanf("%d", &n);
		for(i=0; i<n; i++){
			scanf("%d,%d", &v[i], &w[i]);
		}

		for(i=0; i<1001; i++){
			for(j=0; j<1001; j++){
				memo[i][j].sum_v = -1;
				memo[i][j].sum_w = -1;
			}
		}

		treasure = dp(0, max_w);
		printf("Case %d:\n", num);
		printf("%d\n", treasure.sum_v);
		printf("%d\n", treasure.sum_w);
		num++;
	}

	return 0;
}

tre dp(int i, int j){
	if((memo[i][j]).sum_v >= 0){
		return memo[i][j];
	}

	tre t;
	tre temp_1, temp_2;
	if(i == n){
		t.sum_v = 0;
		t.sum_w = 0;
	}else if(j < w[i]){
		temp_1 = dp(i+1, j);
		t.sum_v = temp_1.sum_v;
		t.sum_w = temp_1.sum_w;
	}else{
		temp_1 = dp(i+1, j);
		temp_2 = dp(i+1, j-w[i]);

		if(temp_2.sum_v + v[i] > temp_1.sum_v){
			t.sum_v = temp_2.sum_v + v[i];
			t.sum_w = temp_2.sum_w + w[i];
		}else if(temp_2.sum_v + v[i] < temp_1.sum_v){
			t.sum_v = temp_1.sum_v;
			t.sum_w = temp_1.sum_w;
		}else{
			if(temp_2.sum_w + w[i] > temp_1.sum_w){
				t.sum_v = temp_1.sum_v;
				t.sum_w = temp_1.sum_w;
			}else{
				t.sum_v = temp_2.sum_v + v[i];
				t.sum_w = temp_2.sum_w + w[i];
			}
		}
	}
	return memo[i][j] = t;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll ang; cin>>ang;
        cout<<360/__gcd((ll)360,ang);
    }   
}


Measured memory_bytes: 3660