akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pi;
typedef pair<int, pi> pip;
#define f first
#define s second

const int m = 1e9+7;
int dp[305][305][305];
int N, M, ans;
pip r[305];
bool v[305][305][305];

bool cmp(pip a, pip b) {
	return a.s.s < b.s.s;
}

bool ver(int i, int j, int k, int l) {
	//~ printf("Check %d, %d, %d::", i, j, k);
	if (r[l].f == 1) {
		if ( ( ( (r[l].s.f <= i) && (i < r[l].s.s) ) || ( (r[l].s.f <= j) && (j < r[l].s.s) ) || ( (r[l].s.f <= k) && (k < r[l].s.s) ) )) {
			//~ printf("Failed to meet requirement for 1 colours in range %d to %d\n", r[l].s.f, r[l].s.s);
			return false;
		}
	}
	if (r[l].f == 2) {
		if ( (i < r[l].s.f || i >= r[l].s.s) && (j < r[l].s.f || j >= r[l].s.s) && (k < r[l].s.f || k >= r[l].s.s) ) {
			//~ printf("Failed to meet requirement for 2 colours in range %d to %d, only 1 colour\n", r[l].s.f, r[l].s.s);
			return false;
		}
		if ( ( (i >= r[l].s.f && i < r[l].s.s) && (j >= r[l].s.f && j < r[l].s.s) ) || ( (i >= r[l].s.f && i < r[l].s.s) && (k >= r[l].s.f && k < r[l].s.s) ) || ( (j >= r[l].s.f && j < r[l].s.s) && (k >= r[l].s.f && k < r[l].s.s) ) ) {
			//~ printf("Failed to meet requirement for 2 colours in range %d to %d, found 3 colours\n", r[l].s.f, r[l].s.s);
			return false;
		}
	}
	if (r[l].f == 3) {
		if (!( ( (i >= r[l].s.f && i < r[l].s.s) && (j >= r[l].s.f && j < r[l].s.s) ) || ( (i >= r[l].s.f && i < r[l].s.s) && (k >= r[l].s.f && k < r[l].s.s) ) || ( (j >= r[l].s.f && j < r[l].s.s) && (k >= r[l].s.f && k < r[l].s.s) ) ) ) {
			//~ printf("Failed to meet requirement for 3 colours in range %d to %d\n", r[l].s.f, r[l].s.s);
			return false;
		}
	}
	//~ printf("Successful\n");
	return true;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> r[i].s.f >> r[i].s.s >> r[i].f;
	}
	sort(r, r+M, cmp);
	
	dp[0][0][0] = 1;
	
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < r[i].s.s; j++) {
			for (int k = 0; k < r[i].s.s; k++) {
				if ((r[i].s.s==j && j!=0) || (r[i].s.s==k && k!=0) || (j==k && k!=0) ) continue;
				if (!ver(r[i].s.s, j, k, i)) v[r[i].s.s][j][k] = 1;
				if (!ver(j, r[i].s.s, k, i)) v[j][r[i].s.s][k] = 1;
				if (!ver(j, k, r[i].s.s, i)) v[j][k][r[i].s.s] = 1;
			}
		}
	}
	
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= N; k++) {
				if ((i==j && i!=0) || (i==k && i!=0) || (j==k && k!=0) || (v[i][j][k])) {
					dp[i][j][k] = 0;
					continue;
				}
				
				//~ printf("Legal match to (%d %d %d), going forwards, with base state %d\n", i, j, k, dp[i][j][k]);
				int mx = max({i, j, k});
				dp[mx+1][j][k] += dp[i][j][k];
				dp[i][mx+1][k] += dp[i][j][k];
				dp[i][j][mx+1] += dp[i][j][k];
				
				dp[mx+1][j][k] %= m;
				dp[i][mx+1][k] %= m;
				dp[i][j][mx+1] %= m;
			}
		}
	}
	
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			ans += dp[N][i][j] + dp[i][N][j] + dp[i][j][N];
			ans %= m;
		}
	}
	cout << ans;
}


Measured memory_bytes: 248064
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[110000];
int main(){
	scanf("%s",in);
	int ret=0;
	for(int i=0;in[i];i++){
		if(i&&in[i]!=in[i-1])ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 256
# import math
# import statistics
a=input()
#b,c=int(input()),int(input())
c=[]
for i in a:
   c.append(i)
#e1,e2,e3,e4 = map(int,input().split())
#f = list(map(int,input().split()))
#g = [input() for _ in range(a)]

d=set(c)

if len(d)<len(c):
    print("no")
else:
    print("yes")

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

#ifdef AZN

#include "Azn.cpp"

#else
#define pln(...)
#endif

using namespace std;

typedef long long ll;
typedef double dd;

const ll MAX = 111000;
bool can[MAX];

void solve(ll test_num) {
  (void) test_num;
  ll N;
  cin >> N;
  vector<ll> a(N), b(N);
  for (ll i = 0; i < N; ++i) {
    cin >> a[i] >> b[i];
  }
  vector<ll> seq;
  for (ll i = 0, off = 0; i < N; ++i) {
    seq.push_back(off % 86400);
    seq.push_back(seq.back() + 86400);
    off += b[i];
    if (i + 1 < N)
      off += a[i + 1];
  }
  sort(seq.begin(), seq.end());
  ll res = 0;
  for (ll i = 0, fr = 0; i < 2 * N; ++i) {
    while (seq[i] - seq[fr] > 10800)
      ++fr;
    res = max(res, i - fr + 1);
  }
  cout << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>

int main(void)
{
  int n;
  int i;
  int a[2000000];
  int buka[2000000];
  scanf("%d", &n);
  for(i=0;i<n-1;i++){
    scanf("%d", &a[i]);
    buka[a[i]] += 1;
  }
  for(i=1;i<=n;i++){
    printf("%d\n", buka[i]);
  }
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> t(N+1);
    vector<int> x(N+1);
    vector<int> y(N+1);
    t.at(0)=x.at(0)=y.at(0);
    for(int i = 0; i<N; i++){
        cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
    }
    
    vector<int> dt(N);
    vector<int> dx(N);
    vector<int> dy(N);
    for(int i = 0; i<N; i++){
        dt.at(i)=abs(t.at(i+1)-t.at(i));
        dx.at(i)=abs(x.at(i+1)-x.at(i));
        dy.at(i)=abs(y.at(i+1)-y.at(i));
    }
    
    bool can = true;
    
    for(int i = 0; i<N; i++){
        if (dt.at(i) < dx.at(i)+dy.at(i)){
            can = false;
            break;
        }
        else{
            if (dt.at(i)%2 != (dx.at(i)+dy.at(i))%2){
                can = false;
                break;
            }
        }
    }
    
    if (can){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n==2)
    {
        cout<<1<<nl;
        return 0;
    }
    vii a;
    ll temp=n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll count=0;
            while(n%i==0)
            {
                n/=i;
                count++;
            }
            a.pb(mp(i,count));
        }
    }
    if(n>1)
        a.pb(mp(n,1));
    n=temp;
    vi fac;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i*i!=n)
            {
                fac.pb(i);
                fac.pb(n/i);
            }
            else
                fac.pb(i);
        }
    }
    fac.pb(n);
    ll ans=0;
    for(ll i:fac)
    {
        ll m=n;
        while(m%i==0)
            m/=i;
        m%=i;
        if(m==1)
            ans++;
    }
    fac.clear();
    n--;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i*i==n)
            {
                fac.pb(i);
            }
            else
            {
                fac.pb(i);
                fac.pb(n/i);
            }
        }
    }
    ans+=sz(fac);
    ans++;
    cout<<ans<<nl;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	int A,B,C;
  	cin >> A >> B >> C; 
  	if(A==B && A==C){
		cout << "No" << endl;
    }
  	else if(A==B){
		cout << "Yes" << endl;
    }
  	else if(A==C){
      cout << "Yes" << endl;
    }
  	else if(B==C){
      cout << "Yes" << endl;
    }
  	else {
      cout << "No" << endl;
    } 	
}

Measured memory_bytes: 256
ans ={'AC':0, 'WA':0, 'TLE':0, 'RE':0}
N = int(input())
for _ in range(N):
    k = input()
    c = ans.setdefault(k)
    ans[k] += 1
for k,v in ans.items():
    print(f'{k} x {v}')


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define mm memset
#define PI 3.14159265358979323846264338327950288419716939937510
#define M 998244353 
#define MAXN   20000001 
#define ll long long int

void solve(){

  ll n;
  cin>>n;
  ll arr[n];
  map<ll,ll> mp;
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    mp[arr[i]]++;
    sum+=arr[i];
  }
  ll q;
  cin>>q;
  while(q--){
    ll b,c;
    cin>>b>>c;
    sum=sum-mp[b]*b+mp[b]*c;
    mp[c]+=mp[b];
    mp[b]=0;
    cout<<sum<<endl;
  }
}

int main() {

  #ifndef ONLINE_JUDGE
    freopen("./input.txt", "r", stdin  );
  #endif   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
      solve();
    }
    return 0;
}

Measured memory_bytes: 10336
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, m;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	ll s = 1;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0;
		return 0;
	}
	for (int i=1; i<=n; i++) {
		s = s * (ll) i % MOD;
	}
	for (int i=1; i<=m; i++) {
		s = s * (ll) i % MOD;
	}
	if (abs(n - m) == 0) s = s * 2ll % MOD;
	
	cout << s;
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int n,k;cin>>n>>k;int ans = 1;
  rep(i,n){
    ans = min(ans+k, ans*2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var counter int
	for _, char := range nextLine() {
		if string(char) == "1" {
			counter++
		}
	}
	fmt.Println(counter)
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

    vector<int> dp(n);
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++)
        dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h, w;
	char m[51][51];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> m[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '#') {
				bool f = false;
				int a = i - 1, b = j;
				if (a >= 0 && a < h) {
					if (b >= 0 && b < w) {
						if (m[a][b] == '#') {
						
							f = true;
						}
					}
				}
				
				a = i;
				b = j - 1;
				if (a >= 0 && a < h) {
					if (b >= 0 && b < w) {
						if (m[a][b] == '#') {
					
							f = true;
						}
					}
				}
				b = j + 1;
				if (a >= 0 && a < h) {
					if (b >= 0 && b < w) {
						if (m[a][b] == '#') {
				
							f = true;
						}
					}
				}
				a = i + 1;
				b = j;
				if (a >= 0 && a < h) {
					if (b >= 0 && b < w) {
						if (m[a][b] == '#') {
						
							f = true;
						}
					}
				}

				if (!f) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    string s, t;
    cin>>s>>t;
    ll n = s.size(), ans = inf, m = t.size();
    forn(i, 0, n-m+1){
        ll c = 0;
        forn(j, 0, m){
            if(t[j] == s[i+j]){
                c++;
            }
        }
        ans = min(ans, m-c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0

def janken(r: int, s: int, p: int, i: str):
    if i == 'p':
        return s, 's'
    elif i == 'r':
        return p, 'p'
    elif i == 's':
        return r, 'r'

for i in range(K):
    sans = janken(R, S, P, T[i])
    tmp = sans[1]
    ans += sans[0]
    #print(ans)
    
    for j in range(i + K, N, K):
        # print(i, j)
        sans = janken(R, S, P, T[j])
        if tmp != sans[1]:
            ans += sans[0]
            tmp = sans[1]
        else:
            tmp = ''
        #print(ans)
        
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
#define lli                                 long long int
#define lb                                  long double
#define pi                                  acos(-1)
#define FindDistance(ax,ay,bx,by)           sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)                            __gcd(a,b)
#define lcm(a,b)                           (a/gcd(a,b))*b
#define T                                  int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define all(v)                             v.begin(),v.end()
#define pb                                 push_back
#define inf                                999999999999999
#define mod                                1000000007
#define maxn                               100003
#define FastIO                             ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    FastIO;
    lli n,i,x,ans=0;
    vector<lli>a,b,c;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.pb(x);
    }
    for(i=0;i<n;i++)
    {
        cin>>x;
        ans+=x;
    }
    for(i=0;i<n-1;i++)
    {
        cin>>x;
        c.pb(x);
    }
    for(i=1;i<n;i++)
    {
        if(a[i]-1==a[i-1])
        ans+=c[a[i-1]-1];
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3584
#include <stdio.h>
#define N 10000

int n, A[N];
int linearSearch(int key){
    int i = 0;
    A[n] = key;
    while( A[i]!=key){
    i++;
    if(i>=n) return 0;
    }
    return 1;
}

int main(void){
    int q, key, c=0, j;
    scanf("%d", &n);
	for(j=0; j<n; j++) scanf("%d", &A[j]);
	
	scanf("%d", &q);
	for(j=0; j<q; j++){
	    scanf("%d", &key);
	    if(linearSearch(key)) c++;
	}
	printf("%d\n", c);
	return 0;
}


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

int dp[100][400][400];

int main(){
  int tc; cin >> tc;
  while(tc--){
    int L; cin >> L;
    vector<int>vec(L);
    for(int i = 0 ; i < L ; i++)cin >> vec[i];

    for(int i = 0 ; i < L ; i++)
      for(int j = 0 ; j < 400 ; j++)
	for(int k = 0 ; k < 400 ; k++)
	  dp[i][j][k] = -1;

    
    dp[0][vec[0]][vec[1]] = vec[2];
    vec.push_back(0);
    
    int res = vec[L-1];
    for(int i = 0 ; i < L-2 ; i++){
      for(int j = 0 ; j <= 320 ; j++){
	for(int k = 0 ; k <= 320 ; k++){
	  if(dp[i][j][k] == -1)continue;
	  dp[i+1][k][dp[i][j][k]] = vec[i+3];
	  if(k-1 >= 0){
	    dp[i+1][k-1][dp[i][j][k]+j] = vec[i+3];
	    if(i+3 == L){
	      res = max(res,dp[i][j][k]+j);
	    }
	  }
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int p[1010], pp[1100000];

int main() {
    int n, m;
    while (1) {
        cin >> n >> m;
        if (n == 0 && m == 0) return 0;
        for (int i = 0; i < n; i++) cin >> p[i];

        p[n] = 0;
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                pp[i * (n + 1) + j] = p[i] + p[j];
            }
        }
        sort(pp, pp + (n + 1) * (n + 1));

        int res = 0;
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                if (p[i] + p[j] <= m) {
                    res = max(res, p[i] + p[j] + pp[upper_bound(pp, pp + (n + 1) * (n + 1), m - p[i] - p[j]) - pp - 1]);
                }
            }
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 7032
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int plus = 0;
  int minus = 0;
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] == '+')
    {
      plus++;
    } else{
      minus++;
    }
  }
  cout << plus - minus << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
#define LL long long 
using namespace std;
const int N=1e5+10;
int MAX=8007;
int dp[4007][16014];
vector<int>s[2];
int main()
{
	string str;
	cin>>str;
	int dirx=1;
	int cnt=0;
	
	rep(i,0,str.size())
	{
		if(str[i]=='F'&&i==str.size()-1)
		{
			cnt++;
			s[dirx].push_back(cnt);
		}
		else if(str[i]=='F')cnt++;
		else if(str[i]=='T')
		{
			s[dirx].push_back(cnt);
			cnt=0;
			dirx=dirx^1;
		}
	}
	//rep(i,0,s[0].size())printf("%d ",s[0][i]);cout<<endl;
	//rep(i,0,s[1].size())printf("%d ",s[1][i]);cout<<endl;
	int resx;
	int resy;
	cin>>resx>>resy;
	memset(dp,0,sizeof(dp));
	rep(i,0,s[1].size())
	{
		int tmp=s[1][i];
		if(i==0)
		{
			dp[i][tmp+MAX]=1;
			//dp[i][-tmp+MAX]=1;
			continue;
		}
		rep(j,0,MAX*2)
		{
			if(j-tmp>=0)dp[i][j]=dp[i][j]|dp[i-1][j-tmp];
			if(j+tmp<MAX*2)dp[i][j]=dp[i][j]|dp[i-1][j+tmp];
		}
	}
	//if(s[1].size()==0)dp[0][0]=1;
	if((s[1].size()==0&&resx!=0)||(s[1].size()!=0&&dp[s[1].size()-1][resx+MAX]==0))
	{
		//debug(s[1].size()-1);
		//debug(abs(resx));
		printf("No");
	}
	else 
	{
		memset(dp,0,sizeof(dp));
		rep(i,0,s[0].size())
		{
			int tmp=s[0][i];
			if(i==0)
			{
				dp[i][tmp+MAX]=1;
				dp[i][-tmp+MAX]=1;
				continue;
			}
			rep(j,0,MAX*2)
			{
				if(j-tmp>=0)dp[i][j]=dp[i][j]|dp[i-1][j-tmp];
				if(j+tmp<MAX*2)dp[i][j]=dp[i][j]|dp[i-1][j+tmp];
			}
		}
		if((s[0].size()==0&&resy!=0)||(s[0].size()!=0&&dp[s[0].size()-1][resy+MAX]==0))printf("No");
		else printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 251008
n, m, v, p = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
mi = 0
ma = n - 1


def ok(i):
    if n - i <= p:
        return True
    if a[n - p] > a[i] + m:
        return False
    b = a[:]
    s = m * v - m
    b[i] += m
    for j in range(n - min(p-1, v-1), n):
        b[j] += m
        s -= m
    for j in range(n):
        if b[j] < b[i]:
            aa = min(b[i] - b[j], s, m)
            b[j] += aa
            s -= aa
    return s <= 0


while mi != ma:
    mm = (mi + ma) // 2
    if ok(mm):
        ma = mm
    else:
        mi = mm + 1
print(n - mi)


Measured memory_bytes: 72344
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	vector<vector<int>>dp(n + 1, vector<int>(m + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				if (dp[i + 1][j] > dp[i][j + 1]) {
					dp[i + 1][j + 1] = dp[i + 1][j];
				}
				else {
					dp[i + 1][j + 1] = dp[i][j + 1];
				}
			}
		}
	}
	string ans;
	while (n > 0 && m > 0) {
		if (dp[n - 1][m] == dp[n][m])n--;
		else if (dp[n][m - 1] == dp[n][m])m--;
		else {
			n--;
			m--;
			ans.push_back(s[n]);
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35584
#include<iostream>

using namespace std;

int arr[2];

int main(){
    int  N;
    cin >> N;
    for(int i=1 ; i<=N; i++){
        int num ;
        cin >> num;
        arr[num%2]++;
    }
    if(arr[1] % 2 == 1){
        cout << "NO" << endl;
    } else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1e9+7;
signed main(){
  string s;
  cin>>s;
  Int x=0,y=0,z=0,r=1;
  Int inv=(1+MOD)/3;
  for(char c:s){
    Int f=c=='?';
    if(c=='C'||f) z+=y*(f?inv:1);
    if(c=='B'||f) y+=x*(f?inv:1);
    if(c=='A'||f) x+=1*(f?inv:1);
    if(f) r*=3;
    x%=MOD;y%=MOD;z%=MOD;r%=MOD;
  }
  cout<<z*r%MOD<<endl;
  return 0;
}


Measured memory_bytes: 512
// AtCoder Grand Contest 012
// A - AtCoder Group Contest

#include <cstdio>
#include <algorithm>
#define MAX_N 100000
using namespace std;
typedef long long int ll;


int N;
ll a[3 * MAX_N];
ll ans;

int main() {

  scanf("%d", &N);
  for (int i = 0; i < 3 * N; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + 3 * N, [](ll a, ll b) { return a > b; });

  ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a[2 * i + 1];
  }
  printf("%lld\n", ans);


  return 0;

}




Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()

	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1092
while True:
    num_cards, num_repeat = map(int, input().split())

    if num_cards == 0 and num_repeat == 0:
        break

    # ??±??? [n, n-1, ... , 1]
    cards = list(range(num_cards, 0, -1))

    for _ in range(num_repeat):
        p, c = map(int, input().split())
        cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]

    print(cards[0])

Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
string s;
signed main() {
    INCANT;
    int n, ans = 0;
    cin>>n>>s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 1000; i++) {
        int key = i;
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            char c = key % 10 + '0';
            if (s[j] == c) {
                key /= 10;
                cnt++;
                if (cnt == 3) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]int, N)
	prev := 0
	for i := 0; i < N; i++ {
		a[i] = prev + nextInt()
		prev = a[i]
	}
	ans := 2020202020
	for i := 0; i < N; i++ {
		ans = minInt(ans, absInt(a[i]-(a[N-1]-a[i])))
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5824
#include <iostream>
#include<cmath>
using namespace std;
#define ll long long int 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
bool is_integer(double k)
{
  return std::floor(k) == k;
}
 
int main()
{
	

 	fastio;
 	ll n;
 	cin>>n;
 	ll index=1;
 	ll t=n;
 	while(t--)
 	{
 		ll x=sqrt(index);
 		ll num;
 		
 		ll cnt=0;
 		for(int i=1;i<=x;i++)
	 	{
	 		for(int j=1;j<=x;j++)
	 		{
	 			
	 			double discriminant=((i+j)*(i+j))-4*(((i*i)+(j*j)+(i*j))-index);
	 			if(discriminant<=0)
	 				continue;
	 			if(!is_integer(sqrt(discriminant)))
	 				continue;
	 			 num=(sqrt(discriminant)-(i+j))/2;
	 			
	 			if(num>=1)
	 			{
	 				
	 				cnt++;
	 				 			
	 			}
	 		}
	 	}
	 	
	 	index++;
 
 		cout<<cnt<<endl;
 	}
 	
 		
 	
	return 0;
	
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll dp[n][3][2][2];
    REP(i,n)REP(j,3)REP(s,2)REP(t,2) dp[i][j][s][t] = -INF;
    //dp[i][j][s][t]はi番まで見たとき,カッコがj個ひらいていて,sはfirst(の前がminusなら1,tはsecond(の前がminusなら1のときの最大値
    ll a; cin >> a;
    dp[0][0][0][0] = a;
    REP(i, n - 1){
        char c; ll a; cin >> c >> a;
        int z = (c == '+' ? 0 : 1);

        //カッコを変化させない場合
        REP(j,3)REP(s,2)REP(t,2)
        chmax(dp[i+1][j][s][t], dp[i][j][s][t] + (s xor t xor z ? -a : a) );

        //カッコを増やす場合
        chmax(dp[i+1][1][z][0], dp[i][0][0][0] + (z ? -a : a) );
        REP(s,2) chmax(dp[i+1][2][s][z], dp[i][1][s][0] + (s xor z ? -a : a) );

        //カッコを減らす場合
        REP(s,2)REP(t,2) chmax(dp[i+1][1][s][0], dp[i][2][s][t] + (s xor t xor z ? -a : a) );
        REP(s,2) chmax(dp[i+1][0][0][0], dp[i][1][s][0] + (s xor z ? -a : a) );

    }
    cout << dp[n-1][0][0][0] << endl;
}

Measured memory_bytes: 13044
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		int h = sc.nextInt();
		while(w != 0 && h != 0){
			int sx = -1;
			int sy = -1;
			int[][] tile = new int[h][w];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					tile[i][j] = sc.nextInt();
					if(tile[i][j] == 2){
						sy = i;
						sx = j;
					}
				}
			}
			System.out.println(func(tile, sx, sy, 1));
			w = sc.nextInt();
			h = sc.nextInt();
		}
		
		sc.close();
	}
	static int func(int[][] tile, int x, int y, int n){
		if(n > 10){
			return -1;
		}
		int[][] cptile = new int[tile.length][tile[0].length];
		for(int i = 0; i < tile.length; i++){
			for(int j = 0; j < tile[0].length; j++){
				cptile[i][j] = tile[i][j];
			}
		}
		int[] mx = {0, 0, 1,-1};
		int[] my = {1,-1, 0, 0};
		int res = -1;
		for(int i = 0; i < 4; i++){
			int tx = x + mx[i];
			int ty = y + my[i];
			if(tx >= 0 && tx < tile[0].length && ty >= 0 && ty < tile.length && tile[ty][tx] != 1){
				while(tx >= 0 && tx < tile[0].length && ty >= 0 && ty < tile.length){
					if(tile[ty][tx] == 3){
						return n;
					}
					if(tile[ty][tx] == 1){
						cptile[ty][tx] = 0;
						int tmp = func(cptile, tx - mx[i], ty - my[i], n + 1);
						if(res == -1 || res > tmp && tmp != -1){
							res = tmp;
						}
						cptile[ty][tx] = 1;
						break;
					}
					tx = tx + mx[i];
					ty = ty + my[i];
				}
			}
		}
		return res;
	}
}

Measured memory_bytes: 161096
import java.util.*;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int m=(int) Math.sqrt(n);

	    int[] ans=new int[n+1];
	    
	   
	    
	    for(int s=1;s<=n;s++) {
	    
	    	for(int x=1;x<=m;x++) {
	    		if(x*x>=s)break;
		    	for(int y=x;y<=m;y++) {
		    		if(x*x+y*y+x*y>=s)continue;
		    		for(int z=y;z<=m;z++) {
		    			if((x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x)==s) {
		    				if(x==y && y==z)ans[s]++;
		    				else if(x!=y && y!=z && z!=x)ans[s]+=6;
		    				else ans[s]+=3;
		    			}
		    		}
		    		
		    	}
		    	
		    }
	    
	    }
	    
	    for(int s=1;s<=n;s++) {
	    	System.out.println(ans[s]);
	    }

	    
	}
}


Measured memory_bytes: 39252
from collections import deque

n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=deque()
queue.append(0)
visited = [False]*n

while queue:
    x = queue.popleft()
    for g in map_li[x]:
        if ans_li[g]==-1:
            ans_li[g]=x
            queue.append(g)
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35444
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    l = -1
    r = N
    while (r-l) > 1:
        mid = (r+l)//2
        if A[mid] < b:
            l = mid
        else:
            r = mid
    top = l+1
    l = -1
    r = N
    while (r-l) > 1:
        mid = (r+l)//2
        if C[mid] <= b:
            l = mid
        else:
            r = mid
    bottom = N-r
    ans += top*bottom
print(ans)


Measured memory_bytes: 29348
#include<iostream>
#include<algorithm>
#include<cmath>
using std::cin;
using std::cout;
int main()
{
    long long int N, D;
    cin >> N >> D;
    int sum = 0;
    while(N > 0)
    {
        long long int arr[2];
        for(int i = 0; i < 2; ++i) cin >> arr[i];
        double ans = sqrt((arr[0] * arr[0]) + (arr[1] * arr[1]));
        if(ans <= D)
            sum++;
        N--;
    }
    cout << sum;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;
int n;
int a[100010];
signed main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  string ans="Yes";
  a[0]--;
  rep(i,n-1){
    if(a[i+1]<a[i]){
      ans="No";break;
    }
    if(a[i+1]>a[i])a[i+1]--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4396
#!/usr/bin/env python3
import sys
import itertools

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


def dist(p, q):
    xdist = p[0] - q[0]
    ydist = p[1] - q[1]
    return (xdist**2 + ydist**2)**0.5


def main():
    N = int(readline())
    ps = [list(map(int, x.split())) for x in readlines()]
    total_dist = 0
    for p, q in itertools.combinations(ps, 2):
        total_dist += dist(p, q)

    ans = total_dist * 2 / N
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int D = max(A,B) - min(A,B);
  int E = max(A,C) - min(A,C);
  if(D > E){
    cout << "B" << endl;
  }
  else{
cout << "A" << endl;
  }
}


Measured memory_bytes: 3580
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//数列を入力し、逆順にして出力
		//入力する数値の個数

		//キーボード入力準備
		Scanner sc = new Scanner(System.in);

		//宣言
		ArrayList<String> array = new ArrayList<String>();

		//入力(入力する数値の個数)
		int count_num = sc.nextInt();

		//入力する数値の個数ぶんだけ繰り返す
		for(int i=0; i<count_num; i++) {
			//配列に数値を加えていく
			array.add(sc.next());
		}

		//出力
		for(int i=count_num-1; i>=0; i--) {
			System.out.print(array.get(i));
			if(i!=0) {
				System.out.print(" ");
			}else {
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 26340
#include<stdio.h>
int main()
{
	int a[100000],h,n;
	scanf("%d %d",&h,&n);
	int i;
	int s=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	
	}
	if(s<h)
	printf("No");
	else
	printf("Yes");
	
 } 

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

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

  
  int rest;
  
  rest = N % 500;
  
//  cout << rest<< endl;

  if(rest <=A){
    cout << "Yes"<<endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# unionfind
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

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

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

uf = Uf(N+1)
M = [-1] * (N+1)
for a, b in AB:
    uf.unite(a, b)
    M[a] -= 1
    M[b] -= 1
for c, d in CD:
    if uf.same(c, d):
        M[c] -= 1
        M[d] -= 1
for i in range(1, N+1):
    M[i] += uf.count(i)
print(" ".join(map(str, M[1:])))


Measured memory_bytes: 59716
N = int(input())
A = tuple(map(int, input().split(' ')))
MOD = 10 ** 9 + 7

zeros = [0] * 60
ones = [0] * 60

for a in A:
    for i, bit in enumerate(reversed(format(a, '060b'))):
        if bit == '0':
            zeros[i] += 1
        else:
            ones[i] += 1

base = 1
ans = 0

for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD

print(ans)


Measured memory_bytes: 124340
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  lint n; cin >> n;
  vector<lint> a(n + 1, 0);
  lint sum = 0;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    a[i] += a[i - 1];
  }

  lint ans = INF;
  for(int i = 1; i < n; i++) {
    lint l = a[i];
    lint r = sum - a[i];
    lint tmp = (lint)abs(r - l);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)
INF = 1<<29

def main():
    n,k = map(int,input().split())
    ans = 1
    while k ** ans <= n:
        ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38484
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
struct bimatch{
	int n;
	vector<vector<int> >G;
	vector<int>match;
	vector<bool>used;
	bimatch(int _n=0):n(_n),G(n),match(n),used(n){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int u:G[v])
		
		{
			int w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int count()
	{
		int ans=0;
		bool flag=true;
		fill(match.begin(),match.end(),-1);
		while(flag)
		{
			flag=false;
			fill(used.begin(),used.end(),false);
			for(int v=0;v<n;v++)if(match[v]<0&&dfs(v))ans++,flag=true;
		}
		return ans;
	}
};
int X,Y,E;
main()
{
	cin>>X>>Y>>E;
	bimatch P(X+Y);
	for(int i=0;i<E;i++)
	{
		int x,y;cin>>x>>y;
		P.add_edge(x,X+y);
	}
	cout<<P.count()<<endl;
}


Measured memory_bytes: 3292
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int R;

int main()
{
    cin >> R;
    cout << 3.1415926535 * double(R) * double(2) << endl;
}

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

const string YES = "Yes";

const string NO = "No";

void solve(int N)
{
    bool res = false;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (i * j == N)
                res = true;
        }
    }
    cout << (res ? YES : NO) << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
ll n,a[(1<<18)];
ll fi[(1<<18)],sc[(1<<18)];
int main(){
  cin>>n;
  for(int i=0;i<(1<<n);i++){
      cin>>a[i];
      fi[i]=a[i];
      sc[i]=-1;
  }
  ll rui=-1;
  for(int j=0;j<n;j++)for(int i=0;i<(1<<n);i++){
      if((i&(1<<j))>0){
          if(fi[i]<fi[i-(1<<j)]){
              sc[i]=fi[i];
              fi[i]=fi[i-(1<<j)];
          }
          else if(sc[i]<fi[i-(1<<j)]){
              sc[i]=fi[i-(1<<j)];
          }
          if(fi[i]<sc[i-(1<<j)]){
              sc[i]=fi[i];
              fi[i]=sc[i-(1<<j)];
          }
          else if(sc[i]<sc[i-(1<<j)]){
              sc[i]=sc[i-(1<<j)];
          }
      }
  }
  for(int i=1;i<(1<<n);i++){
      chmax(rui,fi[i]+sc[i]);
      cout<<rui<<endl;
  }
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	long long mod = 1000000007;
	vector<int> v[100000];
	for (int i = 0; i < N; i++) {
		v[A[i]].push_back(i);
	}
	long long d;
	switch(v[0].size()) {
		case 0:
			d = 0;
			break;
		case 1:
			d = 3;
			break;
		case 2:
			d = 6;
			break;
		case 3:
			d = 6;
			break;
		default:
			d = 0;
	}
	for (int i = 1; i < N; i++) {
		long long dd = 1;
		for (int j = 0; j < (v[i].size()); j++) {
			dd *= (lower_bound(v[i-1].begin(), v[i-1].end(), v[i][j]) - v[i-1].begin()) - j;
		}
		d = (d * dd) % mod;
	}
	cout << d << endl;
}

Measured memory_bytes: 6528
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,M;
    cin >> N >> M;
    veci X(M);
    REP(i,M) cin >> X[i];
    ll ans = 0;
    sort(X.begin(),X.end());
    if(N >= M) ans = 0;
    else {
        veci S(M-1);
        REP(i,M-1) S[i] = X[i+1] - X[i];
        sort(S.begin(),S.end(),greater<int>());
        //REP(i,M-1) cout << S[i] << endl;
        for(int i = 0; i < M - 1; i++) {
            ans += S[i];
        } 
        for(int i = 0; i < N - 1; i++) {
            ans -= S[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
man = [list(map(int,input().split())) for _ in range(n)]
point = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
  ans = 0
  mdist = 10**9
  for j in range(m):
    if abs(man[i][0] - point[j][0]) + abs(man[i][1] - point[j][1]) < mdist:
      ans = j+1
      mdist = abs(man[i][0] - point[j][0]) + abs(man[i][1] - point[j][1])
  print(ans)

Measured memory_bytes: 3064