akhauriyash/Code-Regression huggingface dataset:
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl R;

void solve(void) {
  cout << R * R << endl;
}

int main(void) {
  cin >> R;
  solve();
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let vec: Vec<u32> = read_vec();
    let n = vec[0];
    let ms: Vec<u32> = (0..n)
        .map(|_| read())
        .collect();
    let sum: u32 = ms.iter().sum();
    let min = ms.iter().min().unwrap();
    let answer = n + (vec[1] - sum) / min;
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,n-1){
        int X[26]={0},Y[26]={0};
        for(int j=0;j<=i;j++) X[s[j]-'a']++;
        for(int j=i+1;j<n;j++) Y[s[j]-'a']++;
        int m=0;
        rep(j,26) if(X[j]&&Y[j]) m++;
        ans=max(m,ans);
    }
    cout<<ans;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
maxsugar=f*e/(100+e)
maxwater=f*100/(100+e)
#print(maxsugar,maxwater)
sugar=[]
for i in range(int(maxsugar)//min(c,d)+2):
    for j in range(int(maxsugar)//min(c,d)+2):
        x=i*c+j*d
        if x<=maxsugar:
            sugar.append(x)
#print(sugar)
water=[]
for i in range(int(maxwater//100+2)//min(a,b)+2):
    for j in range(int(maxwater//100+2)//min(a,b)+2):
        y=i*a+j*b
        water.append(y)
#print(water)
water.remove(0)
ansl=[]
for i in sugar:
    for j in water:
        z=i/(j*100+i)
        xyz=i+j*100
        if xyz<=f and z<=e/(100+e):
            ansl.append((i,j,z))
s,t,r=sorted(ansl,key=lambda x:x[-1])[-1]
print(s+t*100,s)

Measured memory_bytes: 92184
# coding: utf-8

n = int(input())
s = tuple(map(int, input().rstrip().split()))
q = int(input())
t = tuple(map(int, input().rstrip().split()))
# print("s:",s)
count = 0

def binary_search(array, value):
    ''' array must be sorted'''
    # print("value:{}".format(value))
    size = len(array)
    start = 0
    end = size - 1
    found = False
    while True:
        middle = (start + end)//2
        # print("s:{0}, e:{1}, m:{2}".format(start, end, middle))
        v = array[middle]
        if v == value:
            # print("v[{}]={} == {}".format(middle, v, value))
            return True
        elif start == end:
            # print("s:{} == e:{}".format(start, end)) 
            return False
        elif v > value:
            # print("v[{}]={} > {}".format(middle, v, value))
            end = middle
        elif v < value:
            # print("v[{}]={} < {}".format(middle, v, value))
            start = middle + 1

for i in range(q):
    if binary_search(s, t[i]):
        count += 1
print(count)

Measured memory_bytes: 18920
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
// #include <fstream>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SIZE(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (int)(UB(c,x)-LB(c,x))

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

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

signed main()
{
  // string filename; cin >> filename;
  // ifstream in(filename);
  // cin.rdbuf(in.rdbuf());

  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }

  int A = 0, B = 0;
  rep(i, 0, N) {
    if (a[i] % 4 == 0) {
      A++;
    } else if (a[i] % 2 == 0) {
      B++;
    }
  }

  if (2*A + max((int)1, B) >= N) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main () {
  ios::sync_with_stdio(false);
  ll X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1;
  } else cout << X;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	int n, a[100], ans=0;
	cin >> n;
	 for(int i=0; i<n; i++){
		 cin >> a[i];
	 }
	 int cnt=1;
	 for(int i=0; i<n-1; i++){
		 if(a[i]==a[i+1]){
			 cnt++;
		 } else {
			 ans+=cnt/2;
			 cnt=1;
		 }
		 if(i==n-2){
			 ans+=cnt/2;
		 }
	 }
	 cout << ans << endl;

	return 0;
}


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

int main() {

int H,W;
  cin>>H>>W;
  vector<string> A(H);
  for(int i=0;i<H;i++){
    cin>>A.at(i);}

  for(int j=0;j<A.size();j++){
  for(int i=0;i<W;i++){
    if(A.at(j).at(i)=='#')break;
    else if (i==W-1){A.erase(A.begin()+j);j--;}
  }
  }


  for(int j=0;j<A.at(0).size();j++){
  for(int i=0;i<A.size();i++){
    if(A.at(i).at(j)=='#')break;
    if (i==A.size()-1){
      for(int k=0;k<A.size();k++){
      A.at(k).erase(A.at(k).begin()+j);}j--;}
  }
  }

      for(int i=0;i<A.size();i++){
    cout<<A.at(i)<<endl;}
}

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

int main() 
{
	int R, G, B, N, ans = 0;
	cin >> R >> G >> B >> N;
	for (int r = 0; r <= 3000; r++)
	{
		for (int g = 0; g <= 3000; g++)
		{
			int sum = R * r + G * g;
			if (sum <= N && (N - sum) % B == 0)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX (int)10e5
using namespace std;


int main()
{


int n;
cin >> n;

vector<int> v1;

for(int i = 0 ; i < n ; i++)
{
    int x;
    cin >> x;
    v1.push_back(x);
    
}


sort(v1.rbegin(),v1.rend());

long long ans = 0;

for(int i = 0 ; i < n ; i++)
{
    
    int r  = i + 1;
    if(r & 1) ans+=v1[i];
    else ans-=v1[i];

}
    
    cout << ans;
    

return 0;		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define VI  vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
const ll mod=1e9+7;
double pi = 2 * acos(0.0);
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return (a.first)<(b.first);
}
ll power(ll a,ll b)
{
        ll p=1;
        for(ll i=1;i<=b;i++)
        p*=a;

        return p;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }
void bfs(map<ll,vector<ll> > &g,ll src,vector<ll> &c)
{
    queue<ll> q;
    map<ll,ll> p;
    q.push(src);
    p[src]=src;
    c[src]=1;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        ll i=1;
        for(auto v:g[u])
        {
            if(c[v]==-1)
            {
                q.push(v);
                p[v]=u;
                if(i==c[u]||i==c[p[u]])
                    i++;
                if(i==c[u]||i==c[p[u]])
                    i++;
                c[v]=i;
                i++;
            }
        }
    }
}
int main()
{
    FASTIO;
    ll n,i,x,y,z;
    cin>>n;
    ll a[n],dp[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    x=0;
    y=x+abs(a[1]-a[0]);
    z=y;
    for(i=2;i<n;i++)
    {
        z=min(x+abs(a[i]-a[i-2]),y+abs(a[i]-a[i-1]));
        x=y;
        y=z;
    }
    cout<<z<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

vector<int> P = {11, 31, 41, 61, 71,
                 101, 131, 151, 181, 191,
                 211, 241, 251, 271, 281,
                 311, 331, 401, 421, 431,
                 461, 491, 521, 541, 571,
                 601, 631, 641, 661, 691,
                 751, 811, 821, 881, 911,
                 941, 971, 991, 1021, 1031,
                 1051, 1061, 1091, 1151, 1171,
                 1181, 1201, 1231, 1301, 1321,
                 1361, 1381, 1451, 1471, 1481
                };

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

  for (int i = 0; i < N; i++)
  {
    cout << P.at(i);
    if (i < N - 1) cout << " ";
  }
}

Measured memory_bytes: 256
N, K = map(int,input().split())
A = sorted(list(map(int,input().split())))

p = 0
while 2**(p+1) < max(max(A),K):
    p += 1

D = [0]*(p+1)

for k in range(N):
    s = (bin(A[k])[2:]).zfill(p+1)
    for d in range(p+1):
        if s[d] == "0":
            D[d] -= 1
        else:
            D[d] += 1

m = 0
for k in range(p+1):
    if D[k] <= 0:
        if m + 2**(p-k) <= K:
            m += 2**(p-k)

ans = 0
for k in range(N):
    ans += m^A[k]
print(ans)


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

int main(void){

    long i,n,x,min=1000000,max=-1000000,total=0;
    
    
    cin >> n;
    
    for (i=0; i<n;i++){
        cin >> x;
        if (x < min) min = x;
        if (x > max) max = x;
        total += x;
        
    }
    
    cout << min << " " << max << " " << total << endl;
    return 0;
}    



Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
  int n, x; cin >> n >> x;
  int d = 0, l, c=1;
  for(int i=0;i<n;++i) {
    cin >> l; d+=l;
    if(d>x) break;
    ++c;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String s = n();
		if ("RRR".contentEquals(s)) {
			out(3);
		} else if ("RRS".contentEquals(s)) {
			out(2);
		} else if ("SRR".contentEquals(s)) {
			out(2);
		} else if (s.contains("R")) {
			out(1);
		} else {
			out(0);
		}

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#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) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n;
    cin >> n;
    vector<long double> p(n + 1);
    repA(i, 1, n){
        cin >> p[i];
    }

    vector<vector<long double> > dp(n + 1, vector<long double>(n + 1, 0));
    // dp[i][j] : total i coins are used and heads has come up j times;
    dp[0][0] = 1;
    repA(i, 1, n){
        rep(j, n + 1){
            if(j > i)  break;
            dp[i][j] = dp[i - 1][j]*(1 - p[i]);
            if(j > 0)
                dp[i][j] += dp[i - 1][j - 1]*p[i];
            error(i, j, dp[i][j]);
        }
    }
    long double ans = 0.0;
    repA(i, (n + 1) / 2, n){
        // error(i, dp[n][i]);
        ans += dp[n][i];
    }
    cout << std::setprecision(10) << ans << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 141056
#include<iostream>
using namespace std;
int main(){
	int sinpan,a[100],i,min,max,mini,maxi,sum=0;
	while(1){
		cin>>sinpan;
		if(sinpan==0) break;
		min=1001;
		max=0;
		for(i=0;i<sinpan;i++){
			cin>>a[i];
			if(max<a[i]){
				max=a[i];maxi=i;
			}
			if(min>a[i]){
				min=a[i];mini=i;
			}
		}
		a[maxi]=-1;
		a[mini]=-1;
		for(i=0;i<sinpan;i++){
			if(a[i]!=-1)
			sum+=a[i];
		}
		sum/=(sinpan-2);
		cout<<sum<<endl;
		sum=0;
	}
		return 0;
}

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

using namespace std;

using hint32 = int32_t;
using hint64 = int64_t;
using huint32 = uint32_t;
using huint64 = uint64_t;
using hint = hint32;
using huint = huint32;


#define hrep( i, n )		for( hint i = 0; i < ( hint )( n ); ++i )
#define hrepr( i, n )		for( hint i = ( hint )( n ); i >= 0; --i)
#define hfor( i, a, n )		for( hint i = ( hint )( a ); i < ( hint )( n ); ++i )
#define hforr( i, a, n )	for( hint i = ( hint )( n ); i >= ( hint )( a ); --i)


#define all(x)	(x).begin(),(x).end()


#define dump(x)			std::cout << #x << " = " << x << "\n";
#define hout(x)			std::cout << x << "\n";
#define hout2(x,y)		std::cout << x << "," << y << "\n";
#define hout3(x,y,z)	std::cout << x << "," << y << "," << z << "\n";

#define ini	std::cin.tie(0);std::ios::sync_with_stdio(false)



int main()
{
	ini;
	hint a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d)
	{
		hout("Yes");
		return 0;
	}
	if (abs(a - b) <= d && abs(b - c) <= d)
	{
		hout("Yes");
		return 0;
	}
	hout("No");

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

/**
 * @author ishihara
 *
 */
public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A <= C) {
            if (C <= B) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
        x=(e*c-b*f)/(a*e-b*d);
        y=(d*c-a*f)/(d*b-a*e);
		if ((int)(x*10000)==0) x=0.0;
		if ((int)(y*10000)==0) y=0.0;
        printf("%.3f %.3f\n",x,y);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a, b, n, m;
	cin >> n >> m;
	a = max(m, n);
	b = min(m, n);
	for (int i = 0; i < a; i++)
	{
		cout << b;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main() {
  map<char,int> mp;
  string S;
  cin >> S;
  for (int i = 0; i < 4; i++) {
    mp[S[i]] = 0;
  }
  if (mp.size() == 2) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string sa,sb;
int a[10001],b[10001],c[10001];
int main()
{
	cin>>sa>>sb;
	int lena=sa.size();
	sb.erase(sb.begin()+sb.find('.'));
	int lenb=sb.size(),lenc;
	for(int i=1;i<=sa.size();i++)a[sa.size()-i+1]=sa[i-1]-'0';
	for(int i=1;i<=sb.size();i++)b[sb.size()-i+1]=sb[i-1]-'0';
	int x=0;
	for(int i=1;i<=lena;i++)
	{
		int x=0;
		for(int j=1;j<=lenb;j++)
		{
			c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
			x=c[i+j-1]/10;
			c[i+j-1]%=10;
		}
		c[i+lenb]=x;
	}
	lenc=lena+lenb;
	while(!c[lenc]&&lenc>1)
		lenc--;
	for(int i=lenc;i>=3;i--)cout<<c[i];
	if(lenc<=3)cout<<0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
    int P,Q,R;
    int min;
    scanf("%d",&P); //a-b
    scanf("%d",&Q); //b-c
    scanf("%d",&R); //a-c
    
    int a = P + R;
    int b = P + Q;
    int c = Q + R;
    
    min = a;
    if (b < min){
        min = b;
    }
    if (c < min){
        min = c;
    }
    
    
    printf("%d",min);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

struct edge{int f,t; ll c;};
int V,E;
int MAX_E = 2020, MAX_V = 1010;

vector<edge> es(MAX_E);
vector<ll> d(MAX_V, INF);
vector<bool> n(MAX_V, false);

int main(){
    cin>>V>>E;
    rep(i,E){cin>>es[i].f>>es[i].t>>es[i].c; es[i].c *= -1;}

    d[1] = 0;
    for(int i = 0; i<V; ++i){
        rep(j,E){
            edge e = es[j];
            if(d[e.f] != INF && d[e.t]>d[e.f]+e.c){
                d[e.t] = d[e.f]+e.c;
            }
        }
    }

    for(int i = 0; i<V; ++i){
        rep(j,E){
            edge e = es[j];
            if(d[e.f] != INF && d[e.t]>d[e.f]+e.c){
                d[e.t] = d[e.f]+e.c;
                n[e.t] = true;
            }
            if(n[e.f])n[e.t] = true;
        }
    }

    if(n[V])cout<<"inf"<<endl;
    else cout<<-d[V]<<endl; return 0;

    //REP(i,V)cout<<"[V."<<i<<"] => "<<d[i]<<endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define ll long long
#define N 100005
#define inf 0x3f3f3f3f
using namespace std;
ll sum,a[N],t,tmp,n;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        t+=i;
    }
    if(sum%t)cout<<"NO";
    else{
        tmp=a[1];
        for(int i=1;i<n;i++)a[i]=a[i+1]-a[i];
        a[n]=tmp-a[n];
        ll d=sum/t,ok=1;
        for(int i=1;i<=n&&ok;i++){
            a[i]-=d;
            if(a[i]%n||a[i]>0)ok=0;
        }
        if(ok)cout<<"YES";
        else cout<<"NO";
    }
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**9+1
n = int(input())
graph = [[] for _ in range(n+1)]

for _ in range(n-1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))

q, k = map(int, input().split())
dist = [INF]*(n+1)


def dfs(v1, parent, add):
    dist[v1] = add
    for v2, d in graph[v1]:
        if v2 == parent:
            continue
        dfs(v2, v1, add + d)

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    print(dist[x]+dist[y])


Measured memory_bytes: 131760
// file name: 求两个集合的差异(A中有B中无, B中有A中无)
// Written by: by_sknight
// Date: 2019/6/12

#include <bits/stdc++.h>
using namespace std;

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

	set<int> A, B, result;
	set<int>::iterator it;
	int n, m, x;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		A.insert(x);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		B.insert(x);
	}

	for (it = A.begin(); it != A.end(); it++) {
		if (B.find(*it) == B.end()) {
			result.insert(*it);
		}
	}
	for (it = B.begin(); it != B.end(); it++) {
		if (A.find(*it) == A.end()) {
			result.insert(*it);
		}
	}
	
	for (it = result.begin(); it != result.end(); it++) {
		cout << *it << endl;
	}

	return 0;
}


Measured memory_bytes: 40680
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        static final int MAXC = (int) 2e5 + 1;
        static final long MODULO = (long) (1e9 + 7);

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] sum = new long[MAXC];
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            sum[a[0]] = 1;
            long w = 1;
            for (int i = 0; i < n; ++i) {
                w = sum[a[i]];
                if (i + 1 == n) break;
                if (a[i] != a[i + 1]) {
                    sum[a[i + 1]] += w;
                    if (sum[a[i + 1]] >= MODULO) sum[a[i + 1]] -= MODULO;
                }
            }
            out.println(w);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int H, W, K, ans = 0;
int rows[8], cols[8];
bool grid[8][8];

void dfs_cols(int col, int curr_black) {
	if (curr_black < K) return;

	if (col < W) {
		dfs_cols(col+1, curr_black);
		dfs_cols(col+1, curr_black - cols[col]);
	}
	else {
		ans += curr_black == K;
	}
}

void dfs_rows(int row, int curr_black) {
	// no point in searching this branch anymore
	if (curr_black < K) return;

	if (row < H) {
		// do nothing (dont fill the row)
		dfs_rows(row+1, curr_black);
		// fill the row and make sure we dont overcount the cols
		for (int c = 0; c < W; ++c)
			cols[c] -= grid[row][c];
		dfs_rows(row+1, curr_black - rows[row]);
		for (int c = 0; c < W; ++c)
			cols[c] += grid[row][c];
	}
	else {
		// consider cols now
		dfs_cols(0, curr_black);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> H >> W >> K;

	int total_black = 0;
	for (int r = 0; r < H; ++r) {
		for (int c = 0; c < W; ++c) {
			char square; cin >> square;
			grid[r][c] = square == '#';
			rows[r] += square == '#';
			cols[c] += square == '#';
			total_black += square == '#';
		}
	}

	dfs_rows(0, total_black);
	cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cmath>
#include <cstdlib>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;
typedef long long ll;

int N;
ll a[105];


int main() {
  ll max = -1;
  scanf("%d", &N);
  REP(i,N) scanf("%lld", &a[i]);

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (j != i && abs(a[i] - a[j]) > max) {
        max = abs(a[i] - a[j]);
      }
    }
  }

  printf("%lld\n", max);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<pair<long long, long long>, null_type, less<pair<long long, long long> >, rb_tree_tag, tree_order_statistics_node_update>
const int N = 2e5 + 10;
ordered_set st;
long long ps[N], ans;
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> ps[i + 1];
		ps[i + 1] += ps[i] - k;
	}
	for (int i = 0; i <= n; i++) {
		auto x = st.order_of_key({ps[i], i});
		ans += x;
		st.insert({ps[i], -i});
	}
	cout << ans;
	return 0;
}


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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = -n;
  for(int i = 0 ; i < n; i++){
  	cin >> a.at(i);
    sum += a.at(i);
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
s = input()
q = int(input())
for i in range(q):
    c = input().split()
    if c[0] == "print":
        a = int(c[1])
        b = int(c[2])
        print(s[a:b + 1])
    elif c[0] == "reverse":
        a = int(c[1])
        b = int(c[2])
        ns = ""
        for j in range(0, a):
            ns += s[j]
        for j in range(b, a - 1, -1):
            ns += s[j]
        for j in range(b + 1, len(s)):
            ns += s[j]
        s = ns
    elif c[0] == "replace":
        a = int(c[1])
        b = int(c[2])
        ns = ""
        for j in range(0, a):
            ns += s[j]
        ns += c[3]
        for j in range(b + 1, len(s)):
            ns += s[j]
        s = ns


Measured memory_bytes: 5620
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto 杯 = new long[](n);
    杯[] = 1;
    // writeln(杯);
    auto 色 = new bool[](n); //赤色true
    // writeln(色);
    色[0] = true;
    // writeln(色);
    foreach (_; 0 .. m)
    {
        long x, y;
        scan(x, y);
        // writeln(x, y);
        // writeln("杯", 杯);
        杯[x - 1] -= 1;
        杯[y - 1] += 1;
        // writeln(杯);
        if (色[x - 1])
        {
            色[y - 1] = true;
        }
        if (杯[x - 1] == 0)
        {
            色[x - 1] = false;
        }
        // writeln("色", 色);
    }
    long cnt;
    foreach (i; 0 .. n)
    {
        if ((杯[i] > 0) && (色[i] == true))
        {
            cnt += 1;
        }
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 5548
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n=0,m=0;
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            n++;
        }else{
            n=0;
        }
        if(m<n)m=n;
    }
    cout<<m;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	int a[102];
	int mn=101, mx=-101;
	cin>>n;
	for (int i=1; i <= n; i++)
		{
			cin>>a[i];
			mn=min(mn,a[i]);
			mx=max(mx,a[i]);
		}
	int res=1000000;
	for (int i=mn; i <= mx; i++)
		{
			int s=0;
			for (int j=1; j <= n; j++)
				s+=((a[j]-i)*(a[j]-i));
			res=min(res,s);
		}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
char s[200010],t[200010];
int main()
{
	int h,w,n,sr,sc;
	scanf("%d%d%d%d%d",&h,&w,&n,&sr,&sc);
	scanf("%s%s",s,t);
	bool ok = true;
    int l=1,r=w;
	int u=1,d=h;
    for(int i=n-1;i>=0;i--)
    {
        if(t[i]=='R')l=max(1,l-1);
        if(t[i]=='L')r=min(r+1,w);
        if(t[i]=='U')d=min(h,d+1);
        if(t[i]=='D')u=max(1,u-1);

        if(s[i]=='R')r--;
        if(s[i]=='L')l++;
        if(s[i]=='U')u++;
        if(s[i]=='D')d--;
        ok = ok && (l <= r);
		ok = ok && (u <= d);
    }
    ok=ok&&(l <= sc) && (sc <= r)&&(u <= sr) && (sr <= d);
    puts(ok?"YES":"NO");
	return 0;
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  char X, Y;
  cin >> X >> Y;
  if((int) X > (int) Y){
    cout << '>' << endl;
  } else if ((int) X < (int) Y) {
    cout << '<' << endl;
  } else {
    cout << '=' << endl;
  }

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

void debug_vec(string name, vector<long> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_mat(string name, vector<vector<long>> mat) {
    cout << name << endl;
    for (auto vec: mat) {
        for (auto e: vec) cout << e << "   ";
        cout << endl;
    }
}

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (int n = 0; n < N; n++) cin >> A[n];
    sort(A.begin(), A.end());

    int res = 0;
    for (int k = 0; k < K; k++) res += A[k];

    cout << res << endl;

    return 0;
}


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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	vector<vector<int> > V;
	V.resize(m);
	for(int i = 0;i < m;i++){
		int k;
		cin>>k;
		V[i].resize(n);
		fill(V[i].begin(),V[i].end(),0);
		for(int j = 0;j < k;j++){
			int x;
			cin>>x;
			V[i][x-1]=1;
		}
	}
	vector<int> P;
	P.resize(m);
	for(int i = 0;i < m;i++){
		cin>>P[i];
	}
	
	int ans = 0;
	
	for(int i = 0;i < (1<<n);i++){
		int gog = 0;
		for(int j = 0;j < m;j++){
			int cnt = 0;
			for(int k = 0;k < n;k++){
				if(V[j][k] == 0) continue;
				if((i&(1<<k)) != 0){
					cnt++;
				}
			}
			if((cnt%2) == P[j]) gog++;
		}
		if(gog == m) ans++;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
 
struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint& operator=(const mint a) { x = a.x; return *this; }
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll p = (n + 999) / 1000;
    mint b=1;
    mint a=b;
    a = p * 1000 - n;
    cout << a.x << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans =0;
    String[] week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for (int i=0; i<7; i++) {
      if(week[i].equals(S)) {
        ans = 7-i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i=0;i<n;i++)
		cin >> x[i];
	
	vector<pair<int,int> > xx(n);
	for(int i=0;i<n;i++)
		xx[i]=make_pair(x[i],i);
	sort(xx.begin(),xx.end());

	vector<int> ord(n);
	for(int i=0;i<n;i++)
		ord[xx[i].second]=i;



	sort(x.begin(),x.end());
	int mid=(n+1)/2-1;
	for(int i=0;i<n;i++)
	{
		if(ord[i]<=mid)
			cout << x[mid+1] << endl;
		else
			cout << x[mid] << endl;
	}


	
}

Measured memory_bytes: 5376
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    num = [0] * (1 + 10**5)
    ans = 0
    for a in A:
        num[a] += 1
        ans += a

    Q = int(input())
    for _ in range(Q):
        b, c = map(int, input().split())
        num[c] += num[b]
        ans += (c - b) * num[b]
        print(ans)
        num[b] = 0


if __name__ == "__main__":
    main()


Measured memory_bytes: 82672
#include<stdio.h>
#define N 100
#define WHITE 0
#define BLACK 1
#define INFTY 100000

int n,m[N][N];

int prim(){
  int color[N],d[N],p[N],i,j,min,u,sum=0;
  for(i=0;i<n;i++){
    d[i] = 2001;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] =0;

  while(1){
    min = 2001;
    for(i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
	u = i;
	min = d[i];
      }
    }
    if(min == 2001)break;
    color[u] = BLACK;
    for(j=0;j<n;j++){
      if(color[j]!=BLACK){
	if(d[j]>m[u][j] && m[u][j]!= -1){
	  d[j] = m[u][j];
	  p[j] = u;
	 
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum += m[i][p[i]];
    }
  }
    return sum;

}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&m[i][j]);
    }
  }
  printf("%d\n",prim());
  return 0;
}

Measured memory_bytes: 636
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <set>
#include <cstdlib>
#include <ctime>

using namespace std;
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)

void say(string const& s){
    printf("?%s\n",s.c_str()); fflush(stdout);
}

string ask(){
    char str[3];
    scanf("%s", str);
    return string(str);
}

void out(){
    printf("!OUT\n"); fflush(stdout);
}

int main(){
    srand(time(0));
    set<string> s;
    string me="x";
    say(me);
    s.insert(me);
    while(1){
        string w=ask();
        if(s.count(w) || w[0]!=me.back()){
            out();
            return 0;
        }else{
            s.insert(w);
            me.clear();
            me.push_back(w[1]);
            rep(i,8){
                me.push_back(rand()%26+'a');
            }
            me.push_back('x');
            say(me);
            s.insert(me);
        }
    }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,i,j,p=1000000007,temp=0,count=0,flag=0,a,b;
string s;
cin>>n;
count+=1000*(n/500);
temp=n%500;
count+=5*(temp/5);

cout<<count<<endl;
            
return 0; 
 
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define vp  vector<pii>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1|1
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
#define sf scanf
#define pf printf
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int MAXN=1e5+5;
const int MAXM=2e6+5;
const int MOD=1e9+7;
int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
void inc(ll &a,ll b){a+=b;if(a>=MOD)a-=MOD;}
void dec(ll &a,ll b){a-=b;if(a<0)a+=MOD;}
int mul(int x, int y){ll z=1ll*x*y;return z-z/MOD*MOD;}
//head

const int sed=13331;
int n; char s[50];
map<pii,int>hs;
void add(int x){
    int t1=0,t2=0;
    rep(i,0,n)if(x&(1<<i))t1=t1*sed+(s[n+i]-'a'+1);
    per(i,0,n)if(!(x&(1<<i)))t2=t2*sed+(s[n+i]-'a'+1);
    //pf("%d %d\n",t1,t2);
    hs[mp(t2,t1)]++;
}
int gao(int x){
    int t1=0,t2=0;
    rep(i,0,n)if(x&(1<<i))t1=t1*sed+(s[i]-'a'+1);
    per(i,0,n)if(!(x&(1<<i)))t2=t2*sed+(s[i]-'a'+1);
    //pf("x=%d %d %d\n",x,t1,t2);
    return hs[mp(t1,t2)];
}
int main(){
    sf("%d%s",&n,s);
    rep(i,0,(1<<n))add(i);
    ll ans=0;
    rep(i,0,(1<<n))ans+=gao(i);
    pf("%lld\n",ans);
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,L;
  cin >> N >> L;
  vector<string> C(N);
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  } 
  
  sort(C.begin(),C.end());
  
  for(int k=0;k<N;k++){
    cout << C.at(k);
  }
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    if (n % 10 == 3) {
        printf("bon\n");
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        printf("pon\n");
    }
    else {
        printf("hon\n");

    }


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll m,k;
    cin>>m>>k;
    if(m==0){
        if(k>=1){
            cout<<-1<<endl;
        } else{
            cout<<"0 0"<<endl;
        }
        return 0;
    }
    if(m==1){
        if(k>=1){
            cout<<-1<<endl;
        } else{
            cout<<"0 0 1 1"<<endl;
        }
        return 0;
    }
    ll a[400000];
    ll n=pow(2,m+1);
    if(k>=pow(2,m)){
        cout<<-1<<endl;
    }
    else {
        a[0]=k;
        a[n/2]=k;
        ll now=0;
        rep2(i,1,n/2){
            if(now==k) now++;
            a[i]=now;
            now++;
        }
        rep2(i,n/2+1,n){
            a[i]=a[n-i];
        }
        rep(i,n){
            cout<<a[i];
            if(i!=n-1) cout<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 4992
class vertex : 
    def __init__(self) : 
        self.edges = []

    def add_edge(self, v, weight) : 
        self.edges.append((v, weight))



def dfs(graph, V, memo, d) : 
    for node in [i for (i, b) in enumerate(memo) if not b and i in d] :
        travelled = [0 for _ in xrange(V)]
        if travelled[node] : 
            continue
        
        stack = []
        stack.append((node, 0))
        
        while stack : 
            index, full_weight = stack.pop()
            d[index] = True
            
            for dst, weight in graph[index].edges :
                if travelled[dst] :
                    if travelled[dst] != travelled[index] + weight : 
                        return False
                    continue
                
                travelled[dst] = travelled[index] + weight
                stack.append((dst, travelled[index] + weight))
    
    return True


V, E = map(int, raw_input().strip().split(' '))

graph = [vertex() for _ in xrange(V)]

memo  = [False for _ in xrange(V)]
di    = {}
for _ in xrange(E) : 
    l, r, d = map(int, raw_input().strip().split(' '))
    l -= 1
    r -= 1
    graph[l].add_edge(r, d)
    memo[r] = True
    di[l] = False
    di[r] = False

if dfs(graph, V, memo, di) :
    for k in di : 
        if not di[k] : 
            print "No"
            break
    else : 
        print "Yes"
else : 
    print "No"



Measured memory_bytes: 85284