akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n,a;
	while(~getII(n,a)){
		n%=500;
		printf("%s\n",n<=a?"Yes":"No");
	}
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	
	const string constIn = "DEFGHIJKLMNOPQRSTUVWXYZABC";
	const string constOut = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	string input, answer;

	cin >> input;

	for(auto i = input.begin(), endi = input.end();
		i != endi;
		i++){
	for(unsigned int ii = 0; ii < 26; ii++){
		if(*i == constIn[ii]){
			answer.push_back(constOut[ii]);
			break;
		}
	}
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;



int main()
{
    ll n;
    cin >> n;
    vvll F(n, vll(10));
    rep(i, n) rep(j, 10) cin >> F[i][j];
    vvll P(n, vll(11));
    rep(i, n) rep(j, 11) cin >> P[i][j];
    ll ans = -infl;
    repf(choice,1,1<<10){
        vll cnt(n, 0);
        rep(i,n){
            rep(j,10){
                if (((choice>>j)&1) && (F[i][j]==1)){
                    cnt[i]++;
                }
            }
        }
        ll now = 0;
        rep(i, n) now += P[i][cnt[i]];
        ans = max(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define rep(i,n) for(int i=0;(i)<(n);i++)
typedef long long ll;
using namespace std;
ll fact(ll n,ll skip){
    if(n<=1) return 1;
    else if(n==skip) return fact(n-1,skip);
    else return ((n%mod)*fact(n-1,skip))%mod;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll modinv(ll a) {
    return modpow(a, mod - 2);
}
int main(void){
    ll n; cin >> n;
    ll x[100000];
    rep(i,n) cin >> x[i];
    ll p[100000]; p[0] = fact(n-1,0);
    rep(i,n-2){
        p[i+1] = (p[i] + p[0]*modinv(i+2))%mod;
    }
    ll ans = 0;
    rep(i,n-1){
        ans = (ans + ((x[i+1]-x[i]) * p[i])%mod)%mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
string s;
signed main(){
	cin>>s;
	int ans=0;
	if(s[0]=='2')ans++;
	if(s[1]=='2')ans++;
	if(s[2]=='2')ans++;
	if(s[3]=='2')ans++;
	cout<<ans<<endl;
    return 0;
}

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

int main(){
    int a, b, m;
    cin >> a >> b >> m;

    vector<int> fridge(a), microwave(b);
    int minf = 1e6, minm = 1e6;
    for(int i=0; i<a; i++){ cin >> fridge[i]; minf = min(minf, fridge[i]); }
    for(int i=0; i<b; i++){ cin >> microwave[i];  minm = min(minm, microwave[i]); }

    int ans = minf + minm;
    for(int i=0; i<m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x -= 1;
        y -= 1;
        ans = min(ans, fridge[x] + microwave[y] - c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3928
# coding: utf-8
# Your code here!

N = int(input())
arr = list(map(int,input().split()))
#print(N,arr)
print(" ".join(str(x) for x in arr))
def insertionSort(N,arr):
    for i in range(1,N):
        v = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > v:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = v
        
        #arr = " ".join(arr)
        print(" ".join(str(x) for x in arr))
    return arr
    

        
ans = insertionSort(N,arr) 


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

vector<vector<pair<int, int>>> Tree;
vector<int> colBranches;

void paint(int v, int parent, int numBranch, int color){
    if(numBranch >= 0)colBranches[numBranch] = color;
    int usdColor;
    for(auto child: Tree[v]){
        if(child.second == parent){
            usdColor=colBranches[numBranch];
        }
    }
    int bufColor = 1;
    for(auto child: Tree[v]){
        if(child.second == parent)continue;
        if(usdColor == bufColor)bufColor++;
        paint(child.second, v, child.first, bufColor);
        bufColor++;
    }
}

int main(void){

    int N;
    int abuf, bbuf;
    cin >> N;
    Tree.assign(N, vector<pair<int, int>>());
    colBranches.assign(N-1, 0);

    for(int i=0; i<N-1; i++){
        cin >> abuf >> bbuf;
        abuf--;
        bbuf--;
        Tree[abuf].push_back(pair<int, int>(i, bbuf));
        Tree[bbuf].push_back(pair<int, int>(i, abuf));
    }

    paint(0, -1, -1, -1);

    int size = 0;
    for(auto Branches: Tree){
        size = max(size, (int)Branches.size());
    }

    cout << size << endl;

    for(int i: colBranches)cout << i << endl;

    return 0;
}

Measured memory_bytes: 8320
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	string s;
	cin>>s;
	string ans="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			ans+="9";
		}else if(s[i]=='9'){
			ans+="1";
		}else{
			ans+=s[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll k;
	cin >>k;
	ll turn =k/50LL;
	ll mod=k-turn*50LL;
	clog<<turn<<" "<<mod<<endl;
	ll out=0;
	cout<<50<<endl;
	V ans(50,0LL);
	ll start=turn-mod;
	if(turn==0){
		rep(i,mod){
			ans[i]=50;
		}
	}else{
		rep(i,50){
			ans[i]=turn+49-mod;
		}
		rep(i,mod){
			ans[i]+=50;
		}
	}
	rep(i,50){
		cout<<ans[i];
		if(i!=49){
			cout<<" ";
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, n, m, X, Y);
	vec(int, x, n);
	vec(int, y, m);
	print(max(*maxi(all(x)), X) < min(*mini(all(y)), Y) ? "No War" : "War");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define N1 102
#define N2 102
#define INF 2000000000
using namespace std;
void DP();
int D,N,a[N1],e[N1],r[N1];
int dp[N1+N1+N1+N1][N2],minv;
int main(){
  while(1){
    cin >> D >> N;
    if(D==0&&N==0) break;
    for(int i=0;i<N;i++) cin >> a[i] >> e[i] >> r[i];
    DP();
  }
  return 0;
}
void DP(){
  for(int i=0;i<N1+N1;i++){
    for(int j=0;j<N2;j++){
      dp[i][j]=INF;
    }
  }
  for(int i=1;i<N2;i++) dp[0][i]=i-1;
  for(int i=D,k=1;i>=0;i--,k++) dp[k][0]=i;
  dp[1][1]=0;
  for(int i=1;i<=D+1;i++){
    for(int j=1;j<N2;j++){
      if(dp[i][j]!=INF){
	for(int k=0;k<N;k++){
	  if(dp[0][j]>=r[k]){
	    if(j+e[k]>=N2){
	      if(dp[i+a[k]][N2-1]>dp[i][j]+1) dp[i+a[k]][N2-1]=dp[i][j]+1;
	    }
	    else if(dp[i+a[k]][j+e[k]]>dp[i][j]+1) dp[i+a[k]][j+e[k]]=dp[i][j]+1;
	  }
	}
      }
    }
  }
  minv=INF;
  for(int i=D+1;i<N1+N1;i++){
    for(int j=1;j<N2;j++){
      minv=min(minv,dp[i][j]);
    }
  }
  if(minv!=INF) cout << minv << endl;
  else cout << "NA" << endl;
}

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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

bool isprime[101010];


int main(){
  rep(i,101010)isprime[i]=true;
  isprime[0]=isprime[1]=false;
  vector<int> prime;
  rep(i,101010){
    if(isprime[i]){
      if(i%5==1)prime.push_back(i);
      for(int j=2;i*j<101010;j++)isprime[i*j]=false;
      }
    }
  int n;cin>>n;
  rep(i,n)cout<<prime[i]<<" ";
  cout<<endl;
  return 0;   

  }

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long d[200][200];
long dp[1<<10][10];
int n,m,r;
int R[10];
main()
{
	cin>>n>>m>>r;
	for(int i=0;i<r;R[i++]--)cin>>R[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)if(i!=j)d[i][j]=1e15;
	}
	for(int i=0;i<m;i++)
	{
		long a,b,c;cin>>a>>b>>c;
		a--,b--;
		d[a][b]=d[b][a]=c;
	}
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=0;i<1<<r;i++)for(int j=0;j<r;j++)dp[i][j]=1e15;
	for(int i=0;i<r;i++)dp[(1<<r)-1][i]=0;
	for(int i=(1<<r)-1;i--;)
	{
		for(int j=0;j<r;j++)
		{
			for(int k=0;k<r;k++)
			{
				if(!(i&(1<<k)))
				{
					dp[i][j]=min(dp[i][j],dp[i|(1<<k)][k]+d[R[k]][R[j]]);
				}
			}
		}
	}
	long ans=1e15;
	for(int i=0;i<r;i++)ans=min(ans,dp[0][i]);
	cout<<ans<<endl;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	string t;
	cin >> s >> t;
	n = s.size();
	m = t.size();

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if(s<t) cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 256
n = input()
a = map(int, raw_input().split())

b = [0, 0, 0, 0, 0, 0, 0, 0]
c = 0

for i in a:
	if i < 3200:
		b[int(i / 400)] = 1
	else:
		c += 1

s = sum(b)
if s == 0:
	s = 1

print s, sum(b) + c

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=(1e5)+10;
const ll mod=(1e9)+7;
int n;
ll ans,mi[maxn],t1[3][maxn],t2[3][maxn];
char s[maxn];
void add1(int i,int x) {
	for (;x<=n;x+=x&(-x)) t1[i][x]++;
}
void add2(int i,int x,int delta) {
	for (;x<=n;x+=x&(-x)) t2[i][x]+=delta,t2[i][x]%=mod;
}
int q1(int i,int x) {
	int res=0;
	for (;x>0;x-=x&(-x)) res+=t1[i][x];
	return res;
}
int q2(int i,int x) {
	int res=0;
	for (;x>0;x-=x&(-x)) res+=t2[i][x];
	return res;
}
int main() {
	scanf("%s",s+1); n=strlen(s+1);
	mi[0]=1;
	for (int i=1;i<=n;i++)
		mi[i]=mi[i-1]*3%mod;
	int cnt=0;
	for (int i=1;i<=n;i++)
		if (s[i]=='?') cnt++;
	for (int i=1;i<=n;i++)
		if (s[i]=='A') add1(0,i);
		else if (s[i]=='?') add1(1,i);
	for (int i=1;i<=n;i++)
		if (s[i]=='B') add2(0,i,q1(0,i-1)),add2(1,i,q1(1,i-1));
		else if (s[i]=='?') add2(1,i,q1(0,i-1)),add2(2,i,q1(1,i-1));
	for (int i=1;i<=n;i++)
		if (s[i]=='C') {
			ans+=q2(0,i-1)*mi[cnt],ans%=mod;
			ans+=q2(1,i-1)*mi[cnt-1],ans%=mod;
			ans+=q2(2,i-1)*mi[cnt-2],ans%=mod;			
		} else if (s[i]=='?') {
			ans+=q2(0,i-1)*mi[cnt-1],ans%=mod;
			ans+=q2(1,i-1)*mi[cnt-2],ans%=mod;
			ans+=q2(2,i-1)*mi[cnt-3],ans%=mod;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5120
#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	vector< string > a(n);
	for (auto& e:a)
		cin >> e;
	vector< string > b(m);
	for (auto& e:b)
		cin >> e;
	for (int i=0; i<=n-m; i++) {
		for (int j=0; j<=n-m; j++) {
			bool equal = 1;
			for (int k=i; k<i+m && equal; k++) {
				for (int l=j; l<j+m && equal; l++) {
					equal &= a[k][l] == b[k-i][l-j];
				}
			}
			if (equal) return cout << "Yes", 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc061.contest.atcoder.jp/tasks/arc061_c>
問題文============================================================
 すぬけ君の住んでいる街には地下鉄が走っています。駅は全部で N 個あり、路線は全部で M 本あります。
 駅には 1 から N までの整数が付けられています。
 また、それぞれの路線はある 1 つの会社によって運営されており、
 それぞれの会社には会社をあらわす整数がつけられています。
 
 i 番目 ( 1≤i≤M ) の路線は、駅 pi と 駅 qi を相互に結んでいます。途中に他の駅はありません。
 また、この路線は会社 ci によって運営されています。
 同じ駅を通る路線が複数あるときは、その駅で乗り換えることができます。
 
 それぞれの会社について、同じ会社の路線を使い続ける限り料金は 1 ですが、
 別の会社の路線に乗り換えるたびに新たに料金が 1 かかります。
 ある会社を利用し、別の会社を利用してからまた最初の会社を利用する場合でも、再び料金を払う必要があります。
 
 すぬけ君は、駅 1 を出発し、地下鉄を利用して駅 N に行きたいです。移動にかかる料金の最小値を求めてください。
=================================================================

解説=============================================================

================================================================
*/

struct edge{
    int u,v,c;
    edge(){}
    edge(int u,int v,int c):u(u),v(v),c(c){}
};
int solve(){
    int N,M; cin >> N >> M;
    vector<edge> G(M);
    vector<vector<int>> com(N);
    for(int i = 0; i < M;i++){
        int p,q,c; cin >> p >> q >> c; p--; q--; c--;
        G[i] = edge(p,q,c);
        com[p].push_back(c); com[q].push_back(c);
    }
    
    for(int i = 0; i < N;i++){
        sort(com[i].begin(),com[i].end());
        com[i].erase(unique(com[i].begin(),com[i].end()),com[i].end());
    }
    int idx = 0;
    map<pii,int> mp;
    for(int i = 0; i < N;i++) mp[pii(i,-1)] = idx++;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < (int)com[i].size();j++){
            mp[pii(i,com[i][j])] = idx++;
        }
    }
    vector<vector<edge>> nG(idx);
    for(int i = 0; i < N;i++){
        int v1 = mp[pii(i,-1)];
        for(int j = 0; j < (int)com[i].size();j++){
            int v2 = mp[pii(i,com[i][j])];
            nG[v1].push_back(edge(v1,v2,1));
            nG[v2].push_back(edge(v2,v1,0));
        }
    }
    for(int i = 0; i < M;i++){
        edge& e = G[i];
        int v1 = mp[pii(e.u,e.c)], v2 = mp[pii(e.v,e.c)];
        nG[v1].push_back(edge(v1,v2,0));
        nG[v2].push_back(edge(v2,v1,0));
    }
    vector<int> dist(idx,INF);
    priority_queue<pii,vector<pii>,greater<pii>> pq;
    dist[0] = 0; pq.push(pii(0,0));
    while(pq.size()){
        pii p = pq.top(); pq.pop();
        int d,n; tie(d,n) = p;
        if(d > dist[n]) continue;
        for(edge& e:nG[n]){
            if(dist[e.v] > dist[e.u] + e.c){
                dist[e.v] = dist[e.u] + e.c;
                pq.push(pii(dist[e.v],e.v));
            }
        }
    }
    return (dist[N-1] == INF ? -1 :dist[N-1]);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 75760
from collections import deque
n,q=map(int,input().split())
s=input()
AC=deque()
count=0
for i in range(n):
    if i!=0:
        if s[i-1:i+1]=="AC":
            count+=1
    AC.append(count)
for _ in range(q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

Measured memory_bytes: 6420
c = input().split()
a = c[0]
b = c[1]


def main():
    if int(a) > 12:
        return int(b)
    elif int(a) > 5 and int(a) < 13:
        return int(int(b)/2)
    else:
        return 0
                

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

//#include"atcoder/all"


#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
//using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


void solve() {
	int N, M, X; cin >> N >> M >> X;
	vector<int>C(N + 1);
	REP(_, M) {
		int a; cin >> a;
		C[a] = 1;
	}
	int ans = INF;
	{
		int res = 0;
		FOR(i, X, N + 1)res += C[i];
		chmin(ans, res);
	}
	{
		int res = 0;
		REPR(i, X)res += C[i];
		chmin(ans, res);
	}
	print(ans);
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3604
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    long long n;
    cin >> n;

    int res = 1 << 20;

    auto len = [&](long long x) {
        int res = 0;
        while (x > 0) {
            ++res;
            x /= 10;
        }
        return res;
    };
    for (int i = 1; i * 1LL * i <= n; ++i) {
        if (n % i == 0) {
            res = min(res, max(len(i), len(n / i)));
        }
    }

    cout << res << '\n';

    return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s[m];
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int t;
      cin >> t;
      t--;
      s[i].push_back(t);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool all = true;
    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); ++j) {
        if (bit >> s[i][j] & 1) cnt++;
      }
      if (cnt % 2 != p[i]) all = false;
    }
    if (all) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
rank = ["AAA","AA","A","B","C","D","E"]
ref0 = [35.5,37.5,40.0,43.0,50.0,55.0,70.0]
ref1 = [71.0,77.0,83.0,89.0,105.0,116.0,148.0]
while True:
	try:
		t = map(float, raw_input().split())
		for i in range(7):
			if t[0]<ref0[i] and t[1]<ref1[i]:
				print rank[i]
				break
		else:
			print "NA"
	except:
		break

Measured memory_bytes: 4244
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
G = [[] for _ in range(n)]
win_against = [[] for _ in range(n)]
A = IR(n - 1)
for i in range(n - 1):
    win_against[A[i] - 1] += [i + 1]

def f(x):
    ret = 0
    s = sorted([f(u) for u in win_against[x]])
    for k in range(1, len(win_against[x]) + 1):
        ret = max(ret, s.pop() + k)
    return ret

print(f(0))


Measured memory_bytes: 240304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 18;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 19;
char dn[dm], *di = dn;

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

	fread(cn, 1, cm, stdin);
	ci = cn;
	int S[100000], T[100000];
	*S = 0;
	*T = 0;
	char C;
	int k = 0;
	while ((C = *ci++) != '\n') { 
		k++;
		*(S + k) = *(S + k - 1) + C - '@';
		if (*(S + k) > 2) *(S + k) -= 3;
	}
	k = 0;
	while ((C = *ci++) != '\n') {
		k++;
		*(T + k) = *(T + k - 1) + C - '@';
		if (*(T + k) > 2) *(T + k) -= 3;
	}

	int Q = getint();
	char n[3] = { 'N', 'O', '\n' };
	char y[4] = { 'Y', 'E', 'S', '\n' };
	rep(i, Q) {
		int a = getint();
		int b = getint();
		int c = getint();
		int d = getint();

		int kotae = *(S + b) - *(S + a - 1) - *(T + d) + *(T + c - 1) + 6;
		while (kotae > 2) kotae -= 3;

		if (kotae == 0) {
			memcpy(di, y, 4);
			di += 4;
		}
		else {
			memcpy(di, n, 3);
			di += 3;
		}
	}

	fwrite(dn, di - dn, 1, stdout);
	
	Would you please return 0;
}

Measured memory_bytes: 1920
package main

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

func ScanStringLines(size int) []string {
    scanner := bufio.NewScanner(os.Stdin)
    lines := make([]string, 0, size)
    for i := 0; i < size; i++ {
        scanner.Scan()
        lines = append(lines, scanner.Text())
    }
    return lines
}

func main() {
    ST := ScanStringLines(2) 
    acc := 0
    for i := 0; i < 3; i ++ {
        if ST[0][i] == ST[1][i] {
            acc += 1
        }
    }
    fmt.Println(acc)
}

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

int main(){
  char in[3][4];
  
  for(int i = 1; i <= 2; i++){
    for(int j = 1; j <= 3; j++){
      cin >> in[i][j]; 
    }
  }

  if(in[1][1] == in[2][3] && in[1][2] == in[2][2] && in[2][1] == in[1][3]){
    cout << "YES" << endl;
  }else cout << "NO" << endl;
  
  
  return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    while (true) {
        int N;
        cin >> N;
        if (N == 0) { break; }

        VVI data;
        FOR(i, 0, N) {
            VI v;
            FOR(j, 0, N + 1) {
                int t;
                cin >> t;
                v.emplace_back(t);
            }
            data.emplace_back(v);
        }

        VI dp(1 << N, INT_MAX);
        dp[0] = 0;

        FOR(b, 0, (1 << N)) {
            FOR(i, 0, N) {
                if ((b & (1 << i)) != 0) { continue; }

                int to = (b | (1 << i));
                dp[to] = min(dp[to], dp[b] + data[i][0]);
                FOR(j, 0, N) {
                    if ((b & (1 << j)) != 0) {
                        dp[to] = min(dp[to], dp[b] + data[i][j + 1]);
                    }
                }
            }
        }

        print(dp[(1 << N) - 1]);
    }

    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 (b<a) { a=b; return 1; } return 0; }

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

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
ll h, w;
bool grid[2000][2000];

int main(){
  cin >> h >> w;
  REP(i, h){
    string s; cin >> s;
    REP(j, w){
      if(s[j] == '#') grid[i][j] = true;
      else grid[i][j] = false;
    }
  }
  // REP(i, h){
  //   string s; cin >> s;
  //   REP(j, w){
  //     (s[j] == '#') ? (grid[i][j] = true) : (grid[i][j] = false;
  //   }
  // }
  VVi r(h, Vi({-1, w})), c(w, Vi({-1, h}));
  REP(i, h) REP(j, w){
      if(grid[i][j] == true) {
        r[i].push_back(j);
        c[j].push_back(i);
    }
  }
  REP(i, h) SORT(r[i]);
  REP(j, w) SORT(c[j]);
  ll ans = 0;
  REP(i, h) REP(j, w){
    if(grid[i][j]) continue;
    ll x = *(lower_bound(ALL(r[i]), j)) - *(lower_bound(ALL(r[i]), j) - 1) - 1;
    ll y = *(lower_bound(ALL(c[j]), i)) - *(lower_bound(ALL(c[j]), i) - 1) - 1;
    chmax(ans, x + y - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 71040
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;

int main(){
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i, n)   cin >> p[i];
    ll s = 0;
    for(int i = 0; i < k; ++i){
        s += p[i];
    }

    vector<double> sum(n + 1, s);
    ll max_sum = s;
    ll index = k - 1;
    for(int i = k; i < n; ++i){
        sum[i + 1] = sum[i] + p[i] - p[i - k];
        if(max_sum < sum[i+1]){
            max_sum = sum[i+1];
            index = i;
        }
    }

    double ans = 0;
    for(int i = 0; i < k; ++i){
        if(p[index] == 1) ans += 1;
        else ans += (1 + p[index]) / 2;
        index--;
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 3328
#include<iostream>
#include <algorithm>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	string s;// a,b;
	cin >> s; 
    //a = "AAA";
    //b = "BBB";
    if(s=="AAA" || s=="BBB"){
      	cout << "No";
    }else{
    	cout << "Yes";
    }   
	return 0;
}

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

typedef long long ll;

int main() {
    int K, S, ans = 0;
    cin >> K >> S;
    rep(X, K + 1) {
        rep(Y, K + 1) {
            int Z = S - X - Y;
            if (0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
sum1 = sum(L)
sum2 = 0

if n == 2:
    print(abs(L[1]-L[0]))
    exit ()
ans = 10**20
for i in range(n-1):
    sum2 +=L[i]
    sa = abs(sum1 - sum2- sum2)
    ans = min(ans,sa)
print(ans)

Measured memory_bytes: 24828
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long sum = 0;
        
        for(int i=1; i<=N; i++){
            if(i%3 != 0 && i%5 != 0)
                sum += i;
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 35804
let input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
let data = input.split('\n');
data.shift()
let cards = data;
let shapes = ['S', 'H', 'C', 'D'];
let str = '';
for (let i=0; i<4; i++) {
  for (let j=1; j<=13; j++) {
    let card = shapes[i] + ' ' + j;
    if (!cards.includes(card)) str += card + '\n';
  }
}
if (str !== '') console.log(str.trim());


Measured memory_bytes: 15112
#! /usr/bin/python3

A, B, C = map(int, input().split())

iter = 0

while True:
    if (A % 2 == 1) or (B % 2 == 1) or (C % 2 == 1):
        break

    X, Y, Z = (B + C) / 2, (A + C) / 2, (B + C) / 2
    A, B, C = X, Y, Z
    iter += 1

    if iter > 1000000:
        iter = -1
        break

print(iter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a=2;
	double o=0,k=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		k++;
		if(i%2==1)o++;
	}	
	cout<<fixed<<setprecision(10)<<o/k<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
l, r = 0, N
while l + 1 != r:
    m = (l + r) // 2
    if m * (m - 1) // 2 < N - m:
        l = m
    else:
        r = m
s = r * (r - 1) // 2 - (N - r)
for n in range(1, r + 1):
    if n != s:
        print(n)

Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int a;
            cin>>a;
            mp[a]++;
        }
    }
    int ans=0;
    for(auto x : mp)
    {
        if(x.second==n)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
 
int32_t main()
{
 int n;
 cin>>n;
 int a[n];
 forn(i,n)cin>>a[i];
 int ans=a[0];
 for(int i=1;i<n;i++)
 {
  ans^=a[i];
 }
 forn(i,n)
 {
  int h=ans^a[i];
  cout<<h<<" ";
  }
  }


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K;
    cin >> N >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<ll> A;
    REP(i, N-1){
        ll t = 0;
        Rep(j, i, N){
            t += a[j];
            A.pb(t);
        }
    }
    SORT(A);

    ll ans = 0;
    int n = A.size();
    for (int i = 41; i >= 0; i--)
    {
        int k = 0;
        REP(j, n){
            if(((ans|(1LL<<i))&A[j])==(ans|(1LL<<i))) k++;
        }
        if(k>=K) ans |= (1LL<<i);
    }
    
    pr(ans);

    // ll l=0,r=MAXINF;
    // int n = A.size();
    // while(r-l>1){
    //     ll mid = (r+l)/2;
    //     int k = 0;
    //     REP(i, n){
    //         if((A[i]&mid)==mid)k++;
    //     }
    //     if(k<K)r=mid;
    //     else l=mid;
    // }
    // pr(l);
}

Measured memory_bytes: 6388
using System;


public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
                alice += a[i];
            else
                bob += a[i];
        }
        Console.WriteLine(alice - bob);
    }
}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N;
    cin>>N;
    vector<int> v(N);
    rep(i,N){
        int a,b;
        cin>>a>>b;
        if(a==b) v[i] = 1;
        else v[i] = 0;
    }
    bool ok = false;
    rep(i,N-2){
        if(v[i]&&v[i+1]&&v[i+2]) ok = true;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
typedef long long ll;

void print(vector<int> src, string prefix) {
    reps(i,13) {
    if(src[i] == 0) {
      cout << prefix << " " << i << endl;
    }
  }
}

int main(){
  int N; cin >> N;
  vector<int> S(14),H(14),C(14),D(14);
  string prefix;
  rep(i,N) {
    int num;
    cin >> prefix >> num;
    if(prefix == "S") S[num] = 1;
    if(prefix == "H") H[num] = 1;
    if(prefix == "C") C[num] = 1;
    if(prefix == "D") D[num] = 1;
  }

  print(S,"S");
  print(H,"H");
  print(C,"C");
  print(D,"D");

}



Measured memory_bytes: 3236
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
#include <iostream>
#include<algorithm>
#include <stdio.h>

using namespace std;

int main() {

	int a, b, c;
	bool tmp;

	cin >> a >> b >> c;

	if ((a == b&&b==c&&a==c)||(a!=b&&a!=c&&c!=b)){
		cout << "No";
	}
	else {
		cout << "Yes";
	}


	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 1000000;
int main(int argc, char *argv[])
{
  vector<bool> primes(N + 1,true);
  primes[0] = false;
  primes[1] = false;
  for(int i = 0; i <= N; i++) {
    if(primes[i]) {
      for(int j = i+i; j <= N; j+=i) {
        primes[j] = false;
      }
    }
  }
  vector<int> ps;
  for(int i = 0; i <= N; i++) {
    if(primes[i]) ps.push_back(i);
  }
  for(;;) {
    int a, b;
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    auto key = [&ps](int n) {
      int p = 0;
      int s = 0;
      for(int i = 0; i < ps.size() && n >= ps[i]; i++) {
        if((n % ps[i]) == 0) {
          s += ps[i];
          p = ps[i];
        }
      }
      return p*2 - s;
    };
    int ka = key(a);
    int kb = key(b);
    cout << (ka > kb ? "a" : "b") << endl;
  }
  return 0;
}

Measured memory_bytes: 3372
#include<stdio.h>

int main(void){
	int N, a, b, c, i, k;

	scanf("%d", &N);

	for(i = 0; i < N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a > b){
			k = a;
			a = b;
			b = k;
		}
		if(b > c){
			k = b;
			b = c;
			c = k;
		}

		if(c*c == a*a + b*b){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 580
import itertools

num_book, num_algo, target_score = map(int, input().split())

book_info_list = []
for i in range(num_book):
    book_info_list.append(list(map(int, input().split())))

all_comb_book_info_list = []
for n in range(1, len(book_info_list) + 1):
    for conb in itertools.combinations(book_info_list, n):
        all_comb_book_info_list.append(list(conb))

price = -1
for comb_book_info_list in all_comb_book_info_list:
    book_info_total = [0] * (num_algo + 1) # cost + アルゴリズム数
    for book_info in comb_book_info_list:
        book_info_total = [x + y for (x, y) in zip(book_info_total, book_info)]
    is_score_satisfied = True
    for total_score in book_info_total[1:]:
        if total_score < target_score:
            is_score_satisfied = False
        if not is_score_satisfied:
            break
    if not is_score_satisfied:
        continue
    if price == -1 or book_info_total[0] < price:
        price = book_info_total[0]

print(price)

Measured memory_bytes: 9280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A = 0;
    int B = 0;
    int C = 0;
    int D = 0;
    int total = 0;
    
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    
    if( A <= B ){
        total = A;
    }
    else{
        total = B;
    }
    
    if( C <= D ){
        total += C;
    }
    else{
        total += D;
    }
    
    cout << total;
    
    return 0;
}


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

int main () {
  int x ,s4,s3,s2,s1;
  cin >> x;
  s4 = x / 1000;
  s3 = (x % 1000) / 100;
  s2 = (x % 100) / 10;
  s1 = x % 10;
  if ((s4 == s3 && s3== s2) ||(s3 == s2 && s2== s1)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int n; cin >>n;
  vector<int> s(n);
  int sum = 0;
  rep(i,n) {
    cin >>s[i];
    sum += s[i];
  }
  if(sum%10!=0){
    cout << sum << endl;
    return 0;
  }
  sort(s.begin(), s.end());
  rep(i,n) {
    int ans = sum-s[i];
    if(ans%10!=0){
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0; 
}

Measured memory_bytes: 3552
let encode = function
  |'N' -> 0x1
  |'S' -> 0x2
  |'E' -> 0x4
  |'W' -> 0x8
  | _ -> 0

let s = read_line ()

let rec solve acc i = if i = String.length s then acc else solve (acc lor encode s.[i]) (i+1)

let () = let r = solve 0 0 in
  let a = (r lxor (r lsr 1)) land 0x5 in
    print_string (if a = 0 then "Yes" else "No")

Measured memory_bytes: 384
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc173/tasks/abc173_d
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n;
    cin >> n;
    vector<ll> v(n+1);
    for(int i = 1;i<=n;i++)
        cin >> v[i];
    sort(all(v));
    ll ans = 0;
    for(int i = 1;i<=n-1;i++){
        ans += v[n-i/2];
    }
    cout << ans;

	return 0;
}


Measured memory_bytes: 4764
a,v=map(int,input().split())
b,w = map(int,input().split())
t=int(input())


if a<=b:

    dist_a = a + t*v

    dist_b = b + t*w

    if dist_a>=dist_b:
        print('YES')
    else:
        print('NO')
else:

    dist_a = a - t*v

    dist_b = b - t*w

    if dist_a<=dist_b:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9196