akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    vector<ll> a(n), b(n);
    rep(i, n){
        rep(j, n){
            if(A[i] > A[j]){
                b[i]++;
                if(j>i)a[i]++;
            }
        }
    }
    ll res = 0;
    rep(i, n){
        ll num = a[i]*k%MOD;
        ll tmp = (b[i]*k%MOD * (k-1))%MOD;
        tmp = tmp * modinv(2, MOD) % MOD;
        num = (num + tmp) %MOD;
        res = (res + num) % MOD;
    }
    cout << res << ln;
}


Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    bool ok = true;
    int cnt = 0;
    int index = 0;
    for (int i = 0; i < (int)s.size(); i++){
        if (i == 0){
            if (s[i] != 'A'){
                ok = false;
            }
        } else if (i >= 2 && i <= (int)s.size()-2){
            if (s[i] == 'C'){
                index = i;
                cnt++;
            }
        }
    }
    if (cnt != 1){
        ok = false;
    }
    for (int i = 0; i < (int)s.size(); i++){
        if (i != 0 && i != index){
            if ((int)s[i] < (int)'a'){
                ok = false;
            }
        }
    }
    if (ok) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }




    return 0;
}


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

int main(){

	int N,M,X,ans;
	cin >> N >> M >> X;
	int leftT=0,rightT=0;

	int temp;
	for (int i = 0; i < M; i++)
	{
		cin >> temp;

		if(temp < X){
			++leftT;
		}else{
			++rightT;
		}

	}



	cout << min(leftT,rightT) << endl;

}



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

int main() {
  int H, W;
  cin >> H >> W;
  
  string s;
  for (int i = 0; i < H; i++) {
    cin >> s;
    
    if (!i) {
      for (int j = 0; j < W+2; j++) {
        cout << '#';
        if (j == W+1) cout << endl;
      }
    }
    
    cout << '#' + s + '#' << endl;
    
    if (i == H-1) {
      for (int j = 0; j < W+2; j++) {
        cout << '#';
        if (j == W+1) cout << endl;
      }
    }
  }
  
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int times[200010];
int num[200010];
int ans=0;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		times[num[i]]++;
	}
	for(int i=1;i<=n;i++)
		ans+=times[i]*(times[i]-1);
	ans/=2;
	for(int i=1;i<=n;i++)
		cout<<ans-times[num[i]]+1<<endl;
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

LL gcd(LL x,LL y){
  if(y%x==0) return x;
  LL tmp;
  while(x%y){
    tmp=x%y;
    x=y;
    y=tmp;
  }
  return y;
}

int main(){
  int n;
  cin >> n;
  LL t,ans;
  cin >> t;
  ans=t;
  for(int i=0;i<n-1;i++){
    cin >> t;
    ans=ans/gcd(ans,t)*t;
  }
  cout << ans << endl;
  return 0;
}


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

bool checkPrime(int n){
    for(int i = 2; i * i <= n; ++i){
        if(n % i == 0) return false;
    }
    return true;
}

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

    int now = 11;
    while(N > 0){
        if(checkPrime(now)){
            cout << now;
            --N;
            if(N != 0) cout << " ";
        }
        now += 10;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c;
	while(1){
		scanf("%d%d%d",&a,&b,&c);
		if(a==-1)return 0;
		int d=a*3600+b*60+c;
		int e=7200-d,f=e*3;
		printf("%02d:%02d:%02d\n%02d:%02d:%02d\n",e/3600,e%3600/60,e%60,f/3600,f%3600/60,f%60);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void)
{
    int n;
    int p[20] = {0};

    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < n - 1; ++i)
    {
        if (p[i-1] < p[i] && p[i] <= p[i+1]) ans++;
        else if (p[i-1] >= p[i] && p[i] > p[i+1]) ans++;
    }
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-10 1005: Advanced Algorithm Class
// 2017.8.17 bal4u@uu

#include <stdio.h>

#define N 100
int a[N][N][3], n;

int main()
{
	int r, c, h, t, min, max;

	while (scanf("%d", &n) == 1 && n) {
		for (r = 0; r < n; r++) for (c = 0; c < n; c++) scanf("%d", &a[r][c][0]);

		for (r = 0; r < n; r++) {
			min = a[r][0][0];
			for (c = 1; c < n; c++) {
				if (a[r][c][0] < min) min = a[r][c][0];
			}
			for (c = 0; c < n; c++) a[r][c][1] = (a[r][c][0] == min);
		}

		for (c = 0; c < n; c++) {
			max = a[0][c][0];
			for (r = 1; r < n; r++) {
				if (a[r][c][0] > max) max = a[r][c][0];
			}
			for (r = 0; r < n; r++) a[r][c][2] = (a[r][c][0] == max);
		}

		for (t = 0, r = 0; r < n; r++) for (c = 0; c < n; c++) {
			if (a[r][c][1] && a[r][c][2]) h = a[r][c][0], t++;
		}
		if (t == 0) h = 0;  // t > 1 ????
		printf("%d\n", h);
	}
	return 0;
}

Measured memory_bytes: 600
let () =
  let n = read_float () in
  let rec read minf maxf =
        try let n = read_float () in
            let x = if minf > n then n else minf and
                y = if maxf < n then n else maxf in
            read x y
        with End_of_file ->
          print_float (maxf -. minf);
          print_newline ()
  in read n n;;

Measured memory_bytes: 2240
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,ans = 0,ans2 = 0;
    cin >> n;
    vector<ll> a(n);
    rep0(i, n){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(all(a));
    rep0(i, n)ans += abs(a[i] - a[n/2]);
    rep0(i, n)ans2 += abs(a[i] - a[n/2 + 1]);
    pf(min(ans, ans2))
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  ll ans = 0;
  map<int,int> mp;
  rep(i,n){
    ans += mp[i-a[i]];
    mp[i+a[i]]++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 21020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int n; cin >> n;
  if(n >= 30) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  while(cin >> s >> t){
    bool ans;
    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));
    DUMP(s);
    DUMP(t);
    int i = 0;
    while(true){
      DUMP(i);
      if(SZ(s) == i && SZ(t) == i ){
	ans = false;
	break;
      }
      if(SZ(s) == i){
	ans = true;
	break;
      }
      if(SZ(t) == i){
	ans = false;
	break;
      }

      DUMP(s[i] - t[i]);
      if(s[i] - t[i] > 0){
	ans = false;
	break;
      }

      if(s[i] - t[i] < 0){
	ans = true;
	break;
      }
      DUMP("Hi!");
      i ++;
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    int n,k,m;cin>>n>>k>>m;
    while(n+k+m != 0){
        m--;
        vector<int> list(n, 0);
        for(int i=0; i<n; i++) list[i] = i+1;
        list.erase(list.begin() + m);
        while(list.size() != 1){
            m = (m+k-1)%list.size();
            list.erase(list.begin() + m);
        }
        cout << list[0] << endl;
        cin>>n>>k>>m;
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string N;int K;ll dp0[1010][5],dp1[1010][5];
  cin >> N >> K;
  dp0[1][0] = 1; dp0[1][1] = (N[0]-'0') - 1; dp0[1][2] = 0; dp0[1][3] = 0;
  dp1[1][0] = 0; dp1[1][1] = 1; dp1[1][2] = 0; dp1[1][3] = 0;
  for(int i = 2; i <= N.size();i++){
    dp0[i][0] = dp0[i-1][0];
    for(int j = 1; j <= K; j++){
      dp0[i][j] = dp0[i-1][j-1] * 9 + dp0[i-1][j] + dp1[i-1][j-1]*max(N[i-1]-'0'-1,0)+dp1[i-1][j]*((N[i-1]-'0'>0));
      dp1[i][j] = dp1[i-1][j-1]*min(N[i-1]-'0',1)+dp1[i-1][j]*(((N[i-1]-'0')==0)?(1):(0));
    }
  }
  cout << (dp0[N.size()][K]+dp1[N.size()][K]);
  return 0;
}

Measured memory_bytes: 256
fun main() {
    // 4C2 +    4C1
    val mod = (1e9+7).toLong()
    fun modInv(d:Long, p:Int) : Long {
        if(p == 0) return 1L
        if(p == 1) return d
        var v = modInv(d, p / 2)
        v = (v * v) % mod
        if(p % 2 != 0) {
            v *= d
            v %= mod
        }
        return v
    }

    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val acc = LongArray(n + 1){0L}

    for(i in 1..n) {
        acc[i] = (acc[i - 1] + i) % mod
    }

    val facto = LongArray(n+2)

    fun comb(n:Int, k:Int): Long {
        var r = (facto[k] * facto[n - k]) % mod
        r = facto[n] * modInv(r, (mod - 2).toInt()) % mod
        return r
    }

    facto[0] = 1
    for(i in 1..n + 1) {
        facto[i] = (facto[i-1] * i) % mod
    }
    // 0 1 2 3
    // 0 1 3 6
    var ans = 0L
    for(r in k .. n+1) {
        //첫항
        val from = acc[r - 1]
        val prev = if(n - r < 0) 0 else acc[n-r]
        val to = (acc[n] - prev + mod) % mod
        val d = (to - from + 1 + mod) % mod
        ans += d
        ans %= mod
    }

    println(ans)
    //N+1 C K ... N+1 C K + 1, ... N + 1 C N + 1






}

Measured memory_bytes: 39916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif
 
int main(){
	std::string buf;
	std::string rbuf;
	int counter = 0;


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		rbuf = buf;
		std::reverse(rbuf.begin(), rbuf.end());
			
		if(buf == rbuf){
			counter++;
		}
	}
 
	std::cout << counter << std::endl;

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


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

int main()
{	
	int m, n;

	cin >> m;

	while (m > 0) {
		vector<pair <int, int>> p, q;

		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			p.push_back(make_pair(x, y));
		}

		cin >> n;

		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			q.push_back(make_pair(x, y));
		}

		int xp = p[0].first, yp = p[0].second;

		for (int i = 0; i < n; i++) {
			bool f = 1;
			int xf = q[i].first, yf = q[i].second;

			for (int j = 1; j < m; j++) {
				pair<int, int> pk = make_pair(p[j].first - xp + xf, p[j].second - yp + yf);
				if (find(q.begin(), q.end(), pk) == q.end()) {
					f = 0;
					break;
				}
			}

			if (f) {
				cout << xf - xp << " " << yf - yp << endl;
				break;
			}
		}

		cin >> m;
	}

	return 0;
}



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

int change(string s);

int main(void){
	string S;
	cin>>S;

	cout<<change(S)<<endl;

	return 0;
}

int change(string s){
	string sample = "CODEFESTIVAL2016";
	int res=0;

	for(int i=0;i<s.size();i++){
	if(s[i]!=sample[i])res++;
	}

	return res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e15
#define mx 100005
using namespace std;
ll int N,W,i,j,item,V,v,w;
ll int dp[mx],vi[mx],wi[mx];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    V=0;
    cin>>N>>W;
    for(i=1;i<=N;i++){cin>>wi[i]>>vi[i]; V+=vi[i]; }
    for(i=1;i<=V;i++) dp[i]=INF;
    dp[0]=0;
    for(item=1;item<=N;item++){
        w=wi[item];v=vi[item];
        for(i=V;i>=v;i--){
            dp[i]=min(dp[i],dp[i-v]+w);
        }
    }
    //cout<<dp[140]<<endl;
    for(i=V;i>=0;i--){
        if(dp[i]<=W){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' ';
	int s=a+b;
	if (n>=s)
		cout<<0;
	else
	{
		cout<<s-n;
	}


}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(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) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n; cin>>n;
	 ll a[n];
	forn(i,n) cin>>a[i];

	sort(a,a+n, greater<ll>());
	ll ans = 0;
	int num = 0;
	int ptr = 0;
	n--;

	while(num < n){
		if(ptr == 0){
			num += 1;
			ans += a[ptr];
			ptr++;
			continue;
		}
		if(num+1 == n){
			num += 1;
			ans += a[ptr];
			ptr++;
			continue;
		}
		num += 2;
		ans += 2*a[ptr];
		ptr++;
	}
	cout<<ans<<ln;

	return 0;
}

Measured memory_bytes: 5216
#include <iostream>
using namespace std;
int n, a, d[5][105];
int main() {
	int i, j;
	cin>>n;
	for(i=1; i<=2; i++) for(j=1; j<=n; j++) {
		cin>>a;
		d[i][j] = max(d[i-1][j], d[i][j-1]) + a;
	}
	cout<<d[2][n];
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int n;
long long a[200010];
long long ans;
long long sum;
long long dp[200010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		dp[i]=sum;
	}
	long long res=0;
	long long mid=sum/2;
	for(int i=1;i<=n;i++)
	{
		if(dp[i]<=mid&&(sum-dp[i])>=mid)
		{
			long long x=dp[i];
			long long y=sum-dp[i];
			int res1=sum/2;
			ans=res1-x+y-res1;
			if(sum%2==1)
			{
				res1++;
				ans=min(ans,res1-x+y-res1);
			}
		}
		if(dp[i]>=mid&&(sum-dp[i])<=mid)
		{
			long long x=dp[i];
			long long y=sum-dp[i];
			int res1=sum/2;
			ans=min(ans,x-res1+res1-y);
			if(sum%2==1)
			{
				res1++;
				ans=min(ans,x-y);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

const ll INF = 1LL<<60;

int main(){
    int S, W; cin >> S >> W;

    if (W >= S){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll MOD = 1e9 + 7;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, i, j, k, o, p, l, z,x,y,h,w,sa=0,m;
ll a[200010] = {}, b[200010], inf = 1000000000000;
string s,t;
vector<vector<ll>> v(30);
queue<ll> q;
pair<ll, ll> pp;
ll par[100005];

ll root(ll x) {
	if (par[x] == x) {
		return x;
	 }
	else {
		return par[x] = root(par[x]);
	}
}

bool same(ll x, ll y) {
	return root(x) == root(y);
}

void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	par[x] = y;
}
void shokika(ll* par, ll n) {
	rep(i, n)par[i] = i;
}
int main() {
	cin >>s>>t;
	n = s.size();
	m = t.size();
	rep(i, n) {
		x = int(s[i]) - 'a';
		v[x].push_back(i);
	//	v[x].push_back(i + n);
	}
	rep(i, n) {
		x = int(s[i]) - 'a';
//		v[x].push_back(i);
		v[x].push_back(i + n);
	}
	k = -1;
	int min ,max;
	rep(i, m) {
		x = int(t[i]) - 'a';
		z = v[x].size();
		if (z == 0) {
			cout << -1;
			return 0;
		}
		//sort(v[x].begin(), v[x].end());
	
		min = -1; max = v[x].size()-1;
		while (max - min > 1) {
			int mid = (max + min) / 2;
			if (v[x][mid] <= k)min = mid;
			else max = mid;		
		}
		y = v[x][max];
		if (y >= n) {
			y -= n;
			sa++;
		}
		k = y;
//		cout <<z<<" "<< y <<" "<<sa<< "\n";
	}
	cout <<sa*n+k+1;
	return 0;
	
}

Measured memory_bytes: 2744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC146
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            string s = Console.ReadLine();
            if (s == "SUN")
                Console.WriteLine(7);
            else if (s == "MON")
                Console.WriteLine(6);
            else if (s == "TUE")
                Console.WriteLine(5);
            else if (s == "WED")
                Console.WriteLine(4);
            else if (s == "THU")
                Console.WriteLine(3);
            else if (s == "FRI")
                Console.WriteLine(2);
            else
                Console.WriteLine(1);
        }

    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
                ans++;
            }
            if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

int main(){
  int d, e;
  while(cin >> d >> e, d || e){
    double ans = 1e9;
    double money;
    int path;
    for(int i = 0; i <= 100; i++){
      path = d - i;
      if(path < 0)break;
      money = fabs(sqrt(i * i + path * path) - e);
      ans = min(ans, money);
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
}

Measured memory_bytes: 3220
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    
    ll n,i,j,k,m;
    char c;
    cin>>c;
    c++;
    if(c=='z'+1)cout<<"a";
    else cout<<c;
}
 
 








 



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

baisu = x // 50

a_num = a * 10
b_num = b * 2
c_num = c

count = 0

for i in range(0,a_num + 1,10):
    for j in range(0,b_num + 1,2):
        num = baisu - (i + j)
        if(num >= 0 and num <= c_num):
            count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define in(n) ll n;cin>>n;
#define fo(m,n) for(int i=m;i< n;i++)
#define rfo(m,n) for(ll i =n;i>=m;i--)
#define out(n) cout<<n<<endl;
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
int main ()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   int n ; cin>>n;
   string s;cin>>s;int x=n;int r =0;int w=0;
   fo(0,n)
   {if(s[i]=='R')r++;
    else w++; }
    x= min(w,r);
    int cnt =0;
    if(w==x)
    {
        fo(n-x,n)
        if(s[i]=='R')cnt++;
    }
    else 
    {
        fo(0,x)
        if(s[i]=='W')cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args){
		BufferedReader reader =
				new BufferedReader(new InputStreamReader(System.in));
		
		int count = 0;
		String str = "";
		StringBuilder sb = new StringBuilder("");
		
		try{
			while((str = reader.readLine()) != null){
				sb.append(str);
				if(str.equals(sb.reverse().toString()))count++;
				sb.setLength(0);
			}
			System.out.println(count);
			
			reader.close();
		}catch(IOException e){
		}
	}
}

Measured memory_bytes: 15024
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
#define ll long long 
const int mod = 1e9+7;
const int maxn=105;
const int maxm=10000+100;
const int inf=0x3f3f3f3f;
int n,m;
int mp[maxn][maxn];
struct edge{
    int u,v,c;
}e[maxm];
void floyd (){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                mp[i][j]=min(mp[i][j],mp[i][k]+mp[k][j]);
            }
        }
    }
}
int main(){
    //freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j)    mp[i][j]=0;
            else mp[i][j]=inf;
        }
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        mp[a][b]=mp[b][a]=c;
        e[i].u=a,e[i].v=b,e[i].c=c;
    }
    floyd();
    int ans=m;
    for(int i=0;i<m;i++){
        int u=e[i].u,v=e[i].v,c=e[i].c;
        bool flag=false;
        for(int s=1;s<=n;s++){
            if(mp[s][u]+c==mp[s][v]){
                flag=true;
            }
        }
        if(flag) ans--;

    }
    printf("%d\n",ans);
    return 0;
}

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

#define ll long long

int n,t;
int a[100000],b[100000];
int dp1[3001][3001];
int dp2[3001][3001];

void solve(){
    cin>>n>>t;
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    a[n]=0;b[n]=0;

    for(int i=0; i<3001; i++){
        for(int j=0; j<3001; j++){
            dp1[i][j]=0;
            dp2[i][j]=0;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<=t; j++){
            if(j>=a[i]){
                dp1[i+1][j]=max(dp1[i][j], dp1[i][j-a[i]]+b[i]);
            }else{
                dp1[i+1][j]=dp1[i][j];
            }
        }
    }
    for(int i=n; i>0; i--){
        for(int j=0; j<=t; j++){
            if(j>=a[i]){
                dp2[i-1][j]=max(dp2[i][j], dp2[i][j-a[i]]+b[i]);
            }
            else{
                dp2[i-1][j]=dp2[i][j];
            }
        }
    }
    /*
    for(int i=0; i<=n; i++){
        for(int j=0; j<=t; j++){
            printf("%2d", dp1[i][j]);
        }
        cout<<endl;
    }
    cout<<endl<<endl;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=t; j++){
            printf("%2d", dp2[i][j]);
        }
        cout<<endl;
    }
    */
    int ans=-1;
    for(int i=0; i<n; i++){
        for(int j=0; j<t; j++){
            ans=max(ans, dp1[i][j]+b[i]+dp2[i][t-j-1]);
        }
    }
    cout<<ans<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 70656
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int main() { 
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int con = 0;
        for (int i = 1; i*2 <= n; ++i) {
            int temp = n, ti = i;
            while (temp > 0) {
                temp -= ti;
                ++ti;
            }
            if (temp == 0) ++con;
        }
        cout << con << endl;
    }
    
    return 0;
}


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

int main() {
  long X;

  std::cin >> X;

  double r = std::sqrt(X);
  long f = std::floor(r);

  long ans = 1;

  for (long i=2; i<=X; i++) {
    for (long j=i*i; j<=X; j*=i) {
      ans = ans < j ? j : ans;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n;
	cin >> s;
	string a ="", b = "";
	for (int i = 0; i < (n / 2); i++) {
		a += s[i];
	}
	for (int i = n / 2; i < n; i++) {
		b += s[i];
	}
	if (a == b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Graph_II
{
    class Minimum_Spanning_Tree
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var graph = new int[n][];

            for (int i = 0; i < n; i++)
                graph[i] = Console.ReadLine().Trim(' ').Split(' ').Select(s => int.Parse(s)).ToArray();

            var res = 0;
            var used = new bool[n];
            var mincost = Enumerable.Repeat(int.MaxValue, n).ToArray();
            mincost[0] = 0;

            while (true)
            {
                var v = -1;
                for (int i = 0; i < n; i++)
                    if (!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;

                if (v == -1) break;
                used[v] = true;
                res += mincost[v];

                for (int i = 0; i < n; i++)
                    if(graph[v][i] != -1) mincost[i] = Math.Min(mincost[i], graph[v][i]);
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 18368
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


class UnionFind:
    def __init__(self, N):
        self.tree = list(range(N))

    def root(self, N):
        if self.tree[N] == N:
            return N
        else:
            self.tree[N] = self.root(self.tree[N])
            return self.tree[N]

    def same(self, x, y):
        return self.root(self.tree[x]) == self.root(self.tree[y])

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.tree[x] = y


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    P = il()

    uf = UnionFind(N)
    for m in range(M):
        x, y = il()
        uf.unite(x - 1, y - 1)

    ret = 0
    for i, v in enumerate(P):
        if uf.same(i, v-1):
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14488
S = input()

counter = 0
diff1 = 0
diff2 = 0
    
for i in range(len(S)):
    # 0スタートの場合
    if i % 2 == 0:
        if S[i] == '1':
            diff1 += 1
    else:
        if S[i] == '0':
            diff1 += 1
    # 1スタートの場合
    if i % 2 == 0:
        if S[i] == '0':
            diff2 += 1
    else:
        if S[i] == '1':
            diff2 += 1

# print(diff1)
# print(diff2)

if diff1 > diff2:
    print(diff2)
else:
    print(diff1)


Measured memory_bytes: 3188
import bisect
import sys
sys.setrecursionlimit(1<<30)
def dfs(i,LIS):
    if a[i] > LIS[-1]:
        LIS.append(a[i])
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS.pop()
    else:
        index = bisect.bisect_left(LIS, a[i])
        x = LIS[index]
        LIS[index] = a[i]
        ans[i] = len(LIS)
        for j in edges[i]:
            if parent[i] != j:
                parent[j] = i
                dfs(j,LIS)
        LIS[index] = x

N = int(input())
a = [0]+list(map(int,input().split()))
edges = [[] for _  in range(N+1)]
ans = [-1]*(N+1)
parent = [-1]*(N+1)
for i in range(N-1):
    u,v = map(int,input().split())
    edges[u].append(v)
    edges[v].append(u)
LIS = [a[1]]
dfs(1,LIS)
for i in ans[1:]:
    print(i)

Measured memory_bytes: 550540
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N, A, B, C, D = map(int, input().split())
    B -= A
    for i in range(N):
        j = N - i - 1
        large1 = C * i
        small1 = D * j
        small = large1 - small1

        large2 = D * i
        small2 = C * j
        large = large2 - small2
        if small <= B <= large:
            print("YES")
            return
    print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
n = int(input())
l = list(map(int,input().split()))

l.sort()
ans = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] != l[j] != l[k]:
                if l[i] + l[j] > l[k] :
                    ans += 1

print(ans)


Measured memory_bytes: 9084
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
ll n,x,y;
int main(){
    in(n);in(x);in(y);
    if((y-x)%2==0){
        printf("%lld\n",(y-x)/2);
        return 0;
    }
    ll ans=min(y-1,n-x);
    ll ny=y-x;
    ll nx=1;
    ans=min(ans,(ny-nx)/2+x);
    nx=x+n-y+1;
    ny=n;
    ans=min(ans,(ny-nx)/2+n-y+1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
vector<pair<int,int> > v;
 
int n,W;
int dp[102][100005];
int solve(int i,int w){
    if(i==n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    int ans = 0;
    if(v[i].ff<=w)
        ans = v[i].ss + solve(i+1,w-v[i].ff);
    ans = max(ans,solve(i+1,w));
    return dp[i][w]=ans;
}
int32_t main()
{
    
    fastio
   
    cin>>n>>W;
    for(int i=0;i<n;i++){
        pii p;
        cin>>p.ff>>p.ss;
        v.pb(p);
    }
    // ans = max(v[i] + dp[i+1][W-w[i]],dp[i+1][W]);
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,W);
 
    return 0;
}

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

int main()
{
    int n, tmp;
    vector<vector<int>> a(3, vector<int> (3));

    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            cin >> a[i][j];

    cin >> n;
    
    for(int k = 0; k < n; ++k)
    {
        cin >> tmp;
        for(int i = 0; i < 3; ++i)
            for(int j = 0; j < 3; ++j)
            {
                if(a[i][j] == tmp)
                    a[i][j] = 0;
            }
    }

    bool bingo = false;
    for(int i = 0; i < 3; ++i)
    {
        if(!a[i][0] && !a[i][1] && !a[i][2])
            bingo = true;
    }
    for(int j = 0; j < 3; ++j)
    {
        if(!a[0][j] && !a[1][j] && !a[2][j])
            bingo = true;
    }

    if(!a[0][0] && !a[1][1] && !a[2][2])
        bingo = true;
    if(!a[0][2] && !a[1][1] && !a[2][0])
        bingo = true;

    cout << (bingo ? "Yes" : "No") << "\n";
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long

using namespace std;

int32_t main() {
	fast
	string s; cin >> s;
	int ans = 0;
	for (char c : s) {
		ans += c - '0';
		ans %= 9;
	}
	cout << (ans ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
char a[5][5],b[5][5];
int main()
{
	for(int i=1;i<=2;i++)
		for(int j=1;j<=3;j++)
		     cin>>a[i][j];
	for(int i=1;i<=2;i++)
	    for(int j=1;j<=3;j++)
	         b[3-i][4-j]=a[i][j];
	for(int i=1;i<=2;i++)
	    for(int j=1;j<=3;j++)
	        if(a[i][j]!=b[i][j])
	        {
	        	cout<<"NO"<<endl;
	        	return 0;
			}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    for j in idx:
      A = A + L[j]
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)

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

void solve(int N, int X, int Y)
{
    // vector<vector<int>> D(N, vector<int>(N, 0));
    vector<int> A(N, 0);
    for (int i = 1; i <= N - 1; i++)
    {
        for (int j = i + 1; j <= N; j++)
        {
            A[min(abs(i - X) + abs(j - Y) + 1, abs(i - j))]++;
        }
    }

    for (int i = 1; i <= N - 1; i++)
    {
        cout << A[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using Graph = vector<vector<int>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    ll n, m;
    cin >> n >> m;
    Graph G(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    queue<int> q;
    vector<int> dist(n, INF); // 全頂点を「未訪問」に初期化
    vector<int> pre(n, -1); //今回の問題で必要な部分、一つ戻った頂点がどこか

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    q.push(0);

    // BFS 開始 (キューが空になるまで探索を行う)
    while(!q.empty()){
        int v = q.front(); // キューから先頭頂点を取り出す
        q.pop();

        // v から辿れる頂点をすべて調べる
        // G[v]はvの隣接頂点が入った配列
        for(int u : G[v]){
            if(dist[u] != INF) continue; // すでに発見済みの頂点は探索しない

            // 新たな頂点uについて距離情報を更新してキューに追加する
            dist[u] = dist[v] + 1;
            pre[u] = v; //uはvから辿れるので1つ戻った頂点としてvを記録する
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    REP(i, n){
        if(i == 0) continue;
        int ans = pre[i] + 1;
        cout << ans << endl;
    }

}


Measured memory_bytes: 10580
#include <stdio.h>

int main(void){
  int n, i, a, b;
  int sum, dig, sum_a, sum_b, result= 100000000;

  scanf("%d", &n);
  for(i=1; i<=(n/2+1); i++){
    a = i;
    b = n - i;

      sum = 0;
      while(a){
        dig = a % 10;
        sum += dig;
        a = a / 10;
      }
      sum_a = sum;
      sum = 0;
      while(b){
        dig = b % 10;
        sum += dig;
        b = b / 10;
      }
      sum_b = sum;
      if(result>(sum_a+sum_b))  result = sum_a + sum_b;
    
  }

  printf("%d\n", result);

  return (0);
}


Measured memory_bytes: 1708
# coding: utf-8
blue = []
red = []
point = 0
N = int(input())
for i in range(N):
    blue.append(input())
M = int(input())
for i in range(M):
    red.append(input())
for str in blue:
    a_point = 0
    for b_str in blue:
        if str == b_str:
            a_point += 1
    for r_str in red:
        if str == r_str:
            a_point -= 1
    if a_point > point:
        point = a_point
print(point)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    String Ns = N.substring(0,1);
    String Ne = N.substring(N.length() - 1);

    if (Ns.equals(Ne)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 21588
#include <stdio.h>

int main()
{
	int W=0, H=0, x=0, y=0, r=0;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if ((x >= r) && (W >= (x+r)) && (y >= r) && (H >= (y+r))) {
		printf("Yes\n");
	}	
	else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b;
    cin >> a >> b;

    cout << max(0, a - 2 * b) << endl;
}   

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[])
{
	int N; cin >> N;
	if (N == 7 || N == 5 || N == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256