akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;


// mod_tools
ll fact[500000];

ll mpow(ll x, ll y){
    //d(x)
    if(y==0) return 1;
    if(y%2==0){
        return mpow(x*x%mod,y/2)%mod;
    }
    else{
        return x*mpow(x,y-1)%mod;
    }
}

ll minv(ll x){
    // only available for mod=10^9+7
    return mpow(x,mod-2);
}

// Please run this func for preparation
void mfact(){
    //prepare fact-array
    fact[0]=1;
    rep(i,1,500000){
        fact[i]=fact[i-1]*i%mod;
    }
}

//combiの呼び出しが大きいときはこれを使う
ll combi(ll n, ll k){
    return (fact[n]*minv(fact[k])%mod)*minv(fact[n-k])%mod;
}

//combiを一回呼び出すだけなら直接計算

int main(void){
    ll a,b;
    cin>>n>>a>>b;
    d(mpow(2,n))
    ans=(mpow(2,n)-1)%mod;
    ll x=1,y=1;
    d("debug")
    rep(i,a){
        x=x*(n-i)%mod;
        y=y*(i+1)%mod;
    }
    ans=(ans-x*minv(y)%mod)%mod;
    d(ans)
    x=1;y=1;
    rep(i,b){
        x=x*(n-i)%mod;
        y=y*(i+1)%mod;
    }
    ans=(ans-x*minv(y)%mod)%mod;
    p((ans<0)?mod+ans:ans);
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,d;
    cin >> h >> w >> d;
    vector<pair<int, int> > p(h*w);
    REP(i,h){
        REP(j,w){
            int a;
            cin >> a;
            p[a-1] = make_pair(i,j);
        }
    }
    vint cost(h*w);
    for(int i=0;i<h*w; ++i){
        if(i<d){
            cost[i] = 0;
        }else{
            cost[i] = cost[i-d] + abs(p[i].fi-p[i-d].fi)+ abs(p[i].se-p[i-d].se);
        }
    }
    int q;
    cin >> q;
    REP(i,q){
        int l,r;
        cin >> l >> r;
        l--; r--;
        printf("%lld\n",(ll)cost[r] - cost[l]);
    }
    return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))

nK=len(bin(K))-2
nA=len(bin(max(A)))-2
n=max(nK,nA)

p=[1]*(n+1)
for i in range(n):
    p[i+1]=p[i]*2

XX=[0]*n
temp=0

#calcX
for i in range(nK-1,-1,-1):
    cnt=0
    for j in range(N):
        if A[j]&p[i]==p[i]:#i桁目を見る
            cnt+=1
    if cnt<N-cnt:
        if temp+p[i]<=K:
            XX[i]=1
            temp+=p[i]
    
ans=0
for i in range(N):
    ans+=temp^A[i]
    
print(ans)

Measured memory_bytes: 63760
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;cin>>n;
	vector<int> a(n),l(n),r(n);
	for(auto&& w:a)cin>>w;
	for(int i=0;i<n;i++){
		l[i]=i;
		while(l[i]>0 && a[l[i]-1]>a[i]){
			l[i]=l[l[i]-1];
		}		
	}
	for(int i=n-1;i>=0;i--){
		r[i]=i;
		while(r[i]<n-1 && a[r[i]+1]>a[i]){
			r[i]=r[r[i]+1];
		}		
	}
	int ans=0ll;
	for(int i=0;i<n;i++){
		ans+=a[i]*(i-l[i]+1)*(r[i]-i+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
n ,c = map(int,input().split())
wt =[]; val=[]

for _ in range(n):
  wi , vi = map(int,input().split())
  wt.append(wi)
  val.append(vi)
  
# dp [n][c+1] = 0 
dp = [[0 for i in range(c+1)]for j in range(n)]

for w in range(c+1):
  wi = wt[0]
  if wi<=w:
    dp[0][w]=val[0]
  else:
    dp[0][0]=0

for i in range(1,n):
  wi = wt[i];vi = val[i]
  for w in range(1,c+1):
    if wi<=w:
      dp[i][w] = max(vi+dp[i-1][w-wi] , dp[i-1][w])
    else:
      dp[i][w] = dp[i-1][w]

print(dp[n-1][c])
  
  
  
  


Measured memory_bytes: 171784
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = input()

ans = 0
bCount = 0
for i in s:
  if i=="B":
    bCount += 1
  else:
    ans+=bCount
print(ans)

Measured memory_bytes: 9528
using System;

class Program
{
    static void Main(string[] args)
    {
        var x = long.Parse(Console.ReadLine());
        if (x % 11 == 0)
        {
            Console.WriteLine(x / 11 * 2);
        }
        else if (x % 11 <= 6)
        {
            Console.WriteLine(x / 11 * 2 + 1);
        }
        else
        {
            Console.WriteLine(x / 11 * 2 + 2);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    long double a , b ;
    cin >> a >> b ;
    long double x = (a + b)  / 2 ;
    long double xx = floor(x) ;
    long double diff = abs(x - xx) ;
    if(diff >=0.50) {
        cout << xx+1  << el ;
        ro ;
    }
    else {
        cout << xx << el ; ro ;
    }
}





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

const int all = 10;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
enum status {
	a0, a1, su, b0, b1, c0, c1
} ;
int out[all][2], dp[2][all];
char buf[300010];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	out[a0][0] = b0; out[a0][1] = a1;
	out[a1][0] = b1; out[a1][1] = su;
	out[su][0] = su; out[su][1] = su;

	out[b0][0] = c0; out[b0][1] = a0;
	out[b1][0] = c1; out[b1][1] = a1;

	out[c0][0] = b0; out[c0][1] = b0;
	out[c1][0] = b1; out[c1][1] = b1;

	int now = 1, lst = 0;
	dp[now][a0] = 1;
	std::cin >> buf; int n = strlen(buf);
	for (int i = 1; i <= n; ++i) {
		std::swap(now, lst);
		memset(dp[now], 0, all * 4);
		if (buf[i - 1] == '0' || buf[i - 1] == '?')
			for (int j = 0; j < all; ++j)
				reduce(dp[now][out[j][0]] += dp[lst][j] - mod);
		if (buf[i - 1] == '1' || buf[i - 1] == '?')
			for (int j = 0; j < all; ++j)
				reduce(dp[now][out[j][1]] += dp[lst][j] - mod);
	}
	int ans = 0;
	reduce(ans += dp[now][a1] - mod);
	reduce(ans += dp[now][su] - mod);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] X = new int[w];
		for (int i = 0; i < X.length; i++) {
			X[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c = X[a];
			X[a] = X[b];
			X[b] = c;
		}
		for (int i = 0; i < X.length; i++) {
			System.out.println(X[i]);
		}
	}
}

Measured memory_bytes: 25820
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const ll INF = 1e18 + 0;
const ll mod = 1e9 + 7;
//const int mod = 998244353;

ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll K=k;
    vector<ll>pos,neg,zero;
    vector<pair<ll,ll>>v(n);
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        if(d>0)pos.push_back(d);
        else if(d<0)neg.push_back(abs(d));
        else zero.push_back(d);
        ll s;
        if(d>=0)s=1;
        else s=-1;
        v[i]={abs(d),s};
    }
    sort(pos.begin(),pos.end());sort(neg.begin(),neg.end());sort(v.begin(),v.end());
    ll ans=1;
    ll pcur=(ll)pos.size()-1,ncur=(ll)neg.size()-1;
    if(k%2){
        if(pos.size()){
            ans=mul(ans,pos[pcur]);
            pcur--;
            k--;
        }
    }
    while(k && (pcur>0 || ncur>0)){
        ll val1=-INF,val2=-INF;
        if(pcur>=1){
            val1=pos[pcur] * pos[pcur-1];
        }
        if(ncur>=1){
            val2=neg[ncur] * neg[ncur-1];
        }
        if(val1>val2){
            ans=mul(ans,val1);
            pcur-=2;
        }
        else{
            ans=mul(ans,val2);
            ncur-=2;
        }
        k-=2;
    }
    if(k){
        if(!zero.empty()){
            ans=0;
        }
        else{
            ans=1;
            for(ll i=0;i<K;i++){
                ans=mul(ans,v[i].first * v[i].second);
            }
        }
    }
    cout<<ans<<endl;
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}



Measured memory_bytes: 8416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll N;
  cin >> N;
  vector<string> s(N);
  for(ll i=0;i<N;++i) cin >> s[i];
  map<vector<int>,int> m;
  for(ll i=0;i<N;++i){
    vector<int> tmp_m(26,0);
    for(ll j=0;j<10;++j){
      tmp_m[s[i][j]-'a']++;
    }
    m[tmp_m]++;
  }
  ll ans=0;
  for(auto& x : m){
    if(ll(x.second)>1) ans+=ll(x.second)*(ll(x.second)-1)/2;
  }
  cout << ans << endl;
  }

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

using namespace std;

signed main(){
  string s;
  cin >> s;
  if(s.length()&1) return cout << "No",0;
  else{
    for(int i=0;s[i];i+=2){
      if(s[i]!='h' || s[i+1]!='i'){
        return cout << "No",0;
      }
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> a(N + 1), b(N);
    for (auto &&i : a) {
        cin >> i;
    }
    for (auto &&i : b) {
        cin >> i;
    }

    reverse(ALL(a));
    reverse(ALL(b));

    ll ans = 0;
    ll res = 0;
    REP(i, N) {
        a[i] -= res;
        ans += res;
        res = 0;
        if (a[i] <= 0) {
            res = b[i];
            ans += a[i];
            continue;
        }
        a[i] -= b[i];
        ans += b[i];
        if (a[i] < 0) {
            res = -a[i];
            ans -= res;
        }
    }
    a[N] -= res;
    ans += res;
    if (a[N] < 0)
        ans += a[N];

    print(ans);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,o=0;
	cin>>a>>b>>c>>d;
	while(a>0||c>0){
		if(o%2==0)c-=b;
		else a-=d;
		o++;
		if(a<=0){cout<<"No";
		break;
		}
		else if(c<=0){
			cout<<"Yes";
			break;
		}
	}
	
return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int D;
intvec C(26);
intmat S;
intvec last(26,-1);
ll score;

void input() {
	cin>>D;
	init(C);
	S.resize(D);
	for(int i=0; i<D; i++) init(S[i],26);
}

ll calc(int d, int c, intvec &lst) {
	ll res=S[d][c];
	for(int i=0; i<26; i++) {
		res-=C[c]*(d-lst[c]);
	}
	return res;
}

void solve() {
	srand(time(NULL));
	for(int d=0; d<D; d++) {
		ll temps=-LLINF;
		int c=rand()%26,oldc,oldd;
		while(c<26) {
			oldd=last[c];
			last[c]=d;
			chmax(temps,calc(d,c,last));
			last[c]=oldd;
			oldc=c;
			if(temps<-2000) c=rand()%26;
			else c=rand()%27;
		}
		score+=temps;
		last[oldc]=d;
		cout<<oldc+1<<endl;
	}
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3688
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
vector<Point> convex_hull(vector<Point> v) {
	if (v.size() < 3) return v;
	sort(v.begin(), v.end());
	vector<Point> u = { v[0], v[1] }, l = { v[v.size() - 1], v[v.size() - 2] };
	for (int i = 2; i < v.size(); i++) {
		for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], v[i]) >= 0; n--) u.pop_back();
		u.push_back(v[i]);
	}
	for (int i = v.size() - 3; i >= 0; i--) {
		for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], v[i]) >= 0; n--) l.pop_back();
		l.push_back(v[i]);
	}
	reverse(l.begin(), l.end());
	for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
	return l;
}
// ------ Main ------ //
int n; vector<Point> v;
int main() {
	while (scanf("%d", &n), n) {
		v.resize(n);
		for (int i = 0; i < n; i++) scanf("%Lf,%Lf", &v[i].px, &v[i].py);
		printf("%d\n", n - (int)convex_hull(v).size());
	}
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    int n;
    string buf;
    cin>>buf;
    buf[0]++;
    
    cout << buf << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<string> counter;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        counter.insert(s);
    }
    cout << counter.size() << endl;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

string o= "RUD";
string e= "LUD";

int main() {
    string s;
    cin >> s;

    REP(i,s.size()){
        bool f = false;
        int index = i + 1;
        REP(j,3){
            if(index%2 == 0 && s[i] == e[j]){
                f = true;
            }else if(index%2 == 1 && s[i] == o[j]){
                f = true;
            }   
        }
        if(!f){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}

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

using namespace std;

int main() {
	int a;
	int b;
  int takahashi = 0;
	
	cin >> a >> b;
	
  for (int i = 1; i < a; i++) {
    takahashi++;
  }

  if (a <= b) {
    takahashi++;
  }

  cout << takahashi << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
long long a[N], s[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
    int cnt = 0;
    for (int i = n; i >= 1; i--) {
        if (s[i] * 2 >= a[i + 1]) cnt++;
        else {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}


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


int main()
{
	cin>>s;
	if(s[0]>'1'){
		if(s[2]>'1'){cout<<"NA"<<endl;return 0;}
		else if(s[2]=='1' && s[3]<'3'){cout<<"YYMM"<<endl; return 0;}
		else if(s[2]=='1' && s[3]>'2'){cout<<"NA"<<endl;  return 0;}
		else if(s[2]=='0' && s[3]=='0'){cout<<"NA"<<endl; return 0;}
		else if(s[2]=='0' && s[3]!='0'){cout<<"YYMM"<<endl; return 0;}
	}
	else{
		if(s[0]=='1'){
			if(s[1]>'2'){
				if(s[2]>'1'){cout<<"NA"<<endl;return 0;}
				else if(s[2]=='1' && s[3]<'3'){cout<<"YYMM"<<endl; return 0;}
				else if(s[2]=='1' && s[3]>'2'){cout<<"NA"<<endl;  return 0;}
				else if(s[2]=='0' && s[3]=='0'){cout<<"NA"<<endl; return 0;}
				else if(s[2]=='0' && s[3]!='0'){cout<<"YYMM"<<endl; return 0;}		
			}
			else{
				if(s[2]>'1'){cout<<"MMYY"<<endl;return 0;}
				else if(s[2]=='1' && s[3]<'3'){cout<<"AMBIGUOUS"<<endl; return 0;}
				else if(s[2]=='1' && s[3]>'2'){cout<<"MMYY"<<endl;  return 0;}
				else if(s[2]=='0' && s[3]=='0'){cout<<"MMYY"<<endl; return 0;}
				else if(s[2]=='0' && s[3]!='0'){cout<<"AMBIGUOUS"<<endl; return 0;}
			}
		}
		else{
			if(s[1]=='0'){
				if(s[2]>'1'){cout<<"NA"<<endl;return 0;}
				else if(s[2]=='1' && s[3]<'3'){cout<<"YYMM"<<endl; return 0;}
				else if(s[2]=='1' && s[3]>'2'){cout<<"NA"<<endl;  return 0;}
				else if(s[2]=='0' && s[3]=='0'){cout<<"NA"<<endl; return 0;}
				else if(s[2]=='0' && s[3]!='0'){cout<<"YYMM"<<endl; return 0;}	
			}
			else{
				if(s[2]>'1'){cout<<"MMYY"<<endl;return 0;}
				else if(s[2]=='1' && s[3]<'3'){cout<<"AMBIGUOUS"<<endl; return 0;}
				else if(s[2]=='1' && s[3]>'2'){cout<<"MMYY"<<endl;  return 0;}
				else if(s[2]=='0' && s[3]=='0'){cout<<"MMYY"<<endl; return 0;}
				else if(s[2]=='0' && s[3]!='0'){cout<<"AMBIGUOUS"<<endl; return 0;}
			}
		}
	}
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    from scipy.sparse.csgraph import connected_components  # https://note.nkmk.me/python-scipy-connected-components/
    from scipy.sparse import csr_matrix
    
    N, M = map(int, input().split())  # 頂点数、辺数
    A, B, C = [0] *  M, [0] * M, [1] * (M-1)
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i]-=1
        B[i]-=1
    
    cnt = 0
    for i in range(M):
        #print(B[:i] + B[i + 1:i + M] + B[i + M + 1:])
        #print(A[:i] + A[i + 1:i + M] + A[i + M + 1:])
        csr = csr_matrix((C, (A[:i] + A[i + 1:], B[:i] + B[i + 1:])), shape=(N, N))
        #print(csr)
        #print('haha')
        n, labels = connected_components(csr)
        if n == 2:
           cnt += 1
    print(cnt)


resolve()


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

int main(){
        int n, k;
        cin>>n>>k;
        long long num;
        if(k%2==0){
                int e1=n/k;
                int e2=n/(k/2)-e1;
                num=pow(e1, 3)+pow(e2, 3);
        }
        else{
                int e=n/k;
                num=pow(e, 3);
        }
        cout<<num<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 100000000 
#define N 100
 
int n;
int size[N];
int to[N][N];
int cost[N][N];
int dist[N];
  
void DFS(int,int);
  
main(int argc,char *argv[]){
  int i, j;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int u;
    scanf("%d", &u);
    scanf("%d", &size[u]);
    for(j=0;j<size[u];j++){
      scanf("%d", &to[u][j]);
      scanf("%d", &cost[u][j]);
    }
  }
  for(i=0;i<n;i++) dist[i] = INF;
  DFS(0, 0);
  for(i=0;i<n;i++){
    printf("%d %d\n", i, dist[i]);
  }
  return 0;
}
void DFS(int p, int c){
  int i;
  dist[p] = c;
  for(i=0;i<size[p];i++){
    if(dist[to[p][i]] > c + cost[p][i])
      DFS(to[p][i], c + cost[p][i]);
  }
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

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

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

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

//////////////////////////////////////////////

const int N = 2e5;

struct datt{
	int ti, en;
}dat[N + 5];

int n;

bool cmp(datt a, datt b){
	return a.en < b.en;
}

bool solve(){
	sort(dat, dat+n, cmp);
	int now = 0;
	FOR(i,n){
		now += dat[i].ti;
		if(now > dat[i].en) return false;
	}
	return true;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i,n) cin >> dat[i].ti >> dat[i].en;
	if(solve()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1792
#こんなんでいいのかな
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    def addPath(d,a,b):
        if a in d:
            d[a].add(b)
        else:
            d[a]={b}
    dT = {}
    for a,b in aData:
        addPath(dT,a,b)
        addPath(dT,b,a)

    def dfs(dT,iStart,iC):
        if len(dsVisited) == iN:
            iC += 1
            return iC
        for i in dT[iStart] - dsVisited:
            dsVisited.add(i)
            iC = dfs(dT,i,iC)
            dsVisited.remove(i)
        return iC

    dsVisited = {1}
    print(dfs(dT,1,0))
解()


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



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

    int n;
    cin >> n;
    if (n <= 999)
        cout<< "ABC" << endl;
    else
        cout << "ABD" << endl;




    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n;
    cin >> n;
 	int h[n];
  	int count = 0;
  	int maxcount = 0;
  	for(int i = 0; i < n; i++ ) {
      cin >> h[i];
    }
  	for(int i = 0; i < n-1; i++ ) {
      if( h[i] >= h[i+1] ){
        count++;
        if(count > maxcount) {
          maxcount = count;
        }
      } else {
        count = 0;
      }
    }
  cout << maxcount << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            cout << a;
        }
    } else {
        for (int i = 0; i < a; ++i) {
            cout << b;
        }
    }
    cout << endl;
}


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

long long gcd(long long int a,long long int b){
    long long int tmp,r;
    
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 return b;

}


int main(void){
    int T;
    scanf("%d",&T);
    for(int i=0;i<T;i++){
        long long A,B,C,D;
        scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
        if(A<B)printf("No\n");
        else if(B>D)printf("No\n");
        else if(B==D){
            if(A%B<=C)printf("Yes\n");
            else printf("No\n");
        }
        else{
            if(A>C){
            long long po=(A-C-1)/B;
            A-=po*B;
            long long buri=gcd(B,D);
            long long unko=(A-C-1)/buri;
            A-=unko*buri;
            if(A<B)printf("No\n");
            else printf("Yes\n");
            }
            else{
                printf("Yes\n");
            }
            
        }
    }
    
    
    
    
    return 0;
}


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

int main() {
	string S;
	cin >> S;
	sort(S.begin(),S.end());
	if (S[0]!=S[1]) {
		cout << "No" << endl;
		return 0;
	}
	if (S[2]!=S[3]) {
		cout << "No" << endl;
		return 0;
	}
	if (S[1]==S[2]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#define N 100
#define WHITE 0
#define BLACK 1
#define INF 10000

using namespace std;

int M[N][N],n,d[N];

void prim(){
  int color[n],p[n];
  for(int i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INF;
  }
  d[0]=0;
  p[0]=-1;
  while(1){
    int mincost=INF;
    int u;
    for(int i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }
    if(mincost==INF) break;
    //connect u to p[u]
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=-1){
        if(M[u][v]<d[v]){
          d[v]=M[u][v];
          p[v]=u;
        }
      }
    }
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) cin >> M[i][j];
  }
  prim();
  int sum=0;
  for(int i=0;i<n;i++) sum+=d[i];
  cout << sum << endl;
}

Measured memory_bytes: 3096
import numpy as np

def main():
    n = int(input())
    a = np.zeros([n], dtype=int)
    # box = np.array(range(1,n+1))
    a = list(map(int, input().split(" ")))
    b = np.zeros_like(a)

    for i in range(n//2, n):
        if a[i] == 1:
            b[i] = 1

    for i in range(1,n//2+1)[::-1]:
        if np.sum(b[i-1::i])%2 != a[i-1]:
            b[i-1] = 1

    ball = np.where(b==1)[0]
    print(len(ball))
    for i in ball:
        print(i+1, end=" ")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 18456
#include <iostream>

using namespace std;

int main(void)
{

	int a, b;
	cin >> a >> b;
	if (a + b == 15)
	{
		cout << "+" << endl;
		return 0;
	}
	if (a * b == 15)
	{
		cout << "*" << endl;
		return 0;
	}
	cout << "x" << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    char c;
    cin >> c;
    if(c == 'a' or c == 'i' or c == 'o' or c == 'u' or c == 'e'){
    cout << "vowel";

    }
else{
    cout << "consonant";
}




}


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


int main(){
	int a, b;
	bool flag, ini=false;
	
	while(cin>>a>>b, a!=0&&b!=0){
		flag = false;
		if(ini)cout<<"\n";
		else   ini = true;
		while(a<=b){//cout<<a<<' '<<b<<"\n";
			if(a%4==0&&a%100!=0 || a%400==0){
				cout<<a<<"\n";
				flag = true;
			}
			a++;
		}
		if(!flag)cout<<"NA\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
#define inf 1 << 28
const int maxn = 1e5 + 5;
typedef long long ll;

int const N = 55557;
bool vis[N];
void isprime()
{
    memset(vis, false, sizeof vis);
    vis[1] = true;
    for (int i = 2; i < 55555; i++)
    {
        if (!vis[i])
        {
            for (int j = i + i; j < 55555; j += i)
            {
                vis[j] = true;
            }
        }
    }
}
int n;
void solv()
{
    cout << 11 <<' ';
    int sum=2,ans=1;
    for (int i=12;i<55555;i++)
    {
        if(!vis[i]&&i%10==1)
        {
            cout<<i<<' ';
            ans++;
        }
        if(ans==n)
        break;
    }
    cout<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    isprime();
    cin >> n;
    solv();
}
/* 
8
2 3 13
2 6 6
3 5 7
4 4 14
5 2 21
5 6 4
6 3 15
7 2 14
0 0 0
67 
*/

Measured memory_bytes: 256
n,m,*x = map(int,open(0).read().split())
x.sort()
if n >= m:
  print(0)
  exit()
a = sorted([x[i+1]-x[i] for i in range(m-1)],reverse=True)
ans = x[-1]-x[0]
for i in range(n-1):
  ans -= a[i]
print(ans)

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int w = sc.nextInt();

		int[][] c = new int[10][10];

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (c[i][j] > c[i][k] + c[k][j])
						c[i][j] = c[i][k] + c[k][j];
				}
			}
		}

		int res = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int A = sc.nextInt();
				if (A >= 0)
					res += c[A][1];
			}
		}

		System.out.println(res);
	}
}

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

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

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

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

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

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

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

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

}


Measured memory_bytes: 23776
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main () {
int N;
cin >> N;
vector<int> vec(N-1);
map<int,int> sya;
for (int i = 0;i < N-1;i++) {
    cin >> vec.at(i);
    if (sya.count(vec.at(i))) {
        sya.at(vec.at(i)) += 1;
    } else {
        sya[vec.at(i)] = 1;
    }
}
for (int i = 1;i < N+1;i++) {
    if (sya.count(i)) cout << sya.at(i) << endl;
    else cout << 0 << endl;
}

return 0;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >>A>>B;
    if (A+B>=10) cout<<"error"<<endl;
    else cout<<A+B<<endl;
    
}


Measured memory_bytes: 256
n, m = map(int, input().split(' '))
ans = [0 for _ in range(m)]
f = 0 
for _ in range(n):
  tmp = map(int, input().split(' ')[1:])
  for num in tmp:
    ans[num - 1] += 1

for num in ans:
  if num == n:
    f += 1
print(f)


Measured memory_bytes: 38256
#include<stdio.h>

int main() {
    int X, a, b, r;
    scanf("%d", &X);

    a = X/500;
    X = X-(a*500);
    b = X/5;
    r = (a*1000) + (b*5);

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


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

static class CodeJam
{
    static double Solve(double a, double b, double x)
    {
        double rad1 = Math.Atan(2 * b / a - 2 * x / (a * a * a));
        double rad2 = Math.PI / 2 - Math.Atan(2 * x / (a * b * b));
        double rad = (x / a < a * b / 2) ? rad2 : rad1;
        return rad * 180 / Math.PI;
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
        Console.WriteLine(Solve(V[0], V[1], V[2]));
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;

const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll INF = 1e14;
const ll mod =1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    freopen("error.txt", "w", stderr); 
    #endif      
    int T = 1;
    // cin>>t;
    while(T--){
        ll n;cin>>n;
        ll a[n];
        for(int i = 0;i<n;i++){
            cin>>a[i];
        }
        ll ans = 0 ;
        for(int i = 1;i<n;i++){
            ans+=max(a[i-1]- a[i],0ll);
            a[i] = max(a[i-1],a[i]);
        }
        cout<<ans<<'\n';

    }
}

Measured memory_bytes: 5148
from itertools import combinations 
N = int(input())
L = list(map(int,input().split()))


ans = list(combinations(L,3))
ans1 = 0
for i in ans:
    if (i[0]+i[1]>i[2] and i[0]+i[2]>i[1] and i[1]+i[2]>i[0] and i[0]!=i[1] and i[0]!=i[2] and i[1]!=i[2]):
        ans1+=1

print(ans1)


Measured memory_bytes: 20584
#include <iostream>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(T[i] == 'r'){
      ans += P;
      if(i+K < N && T[i+K] == 'r'){
        T[i+K] = 'n';
      }
    }
    else if(T[i] == 's'){
      ans += R;
      if(i+K < N && T[i+K] == 's'){
        T[i+K] = 'n';
      }
    }
    else if(T[i] == 'p'){
      ans += S;
      if(i+K < N && T[i+K] == 'p'){
        T[i+K] = 'n';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[x] = y
        else:
            if self.same_check(x, y) != True:
               self.size[x] += self.size[y]
               self.size[y] = 0
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
               self.rank[x] += 1

    def siz(self, x):
        x = self.find(x)
        return self.size[x]

def getlist():
    return list(map(int, input().split()))

N, M = getlist()
U = UnionFind(N)
for i in range(M):
    X, Y, Z = getlist()
    U.union(X, Y)

D = defaultdict(int)


for i in range(1, N + 1):
    n = U.find(i)
    D[n] += 1

print(len(D))

Measured memory_bytes: 20964
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()
ans = 0
for i in range(len(a)):
	if a[a[i]-1]==i+1:
		ans+=1
print(ans//2)

Measured memory_bytes: 20628
/* Problem Description:

*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define RREP(i,a,b) for (int i = (a); i > (b); i--)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define TRvi(it, c) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define inf 0x3f3f3f3f
#define EPS 1e-10
#define PI acos(-1.0)
#define scan(x) scanf("%d",x)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define LSOne(x) x&(-x)
#define debug(x) cout << #x << " " << x << endl;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
   //  freopen("in" , "r" , stdin);
   //  freopen("out" , "w" , stdout);
    #endif
    long n;
    cin >> n;

    long ans = 0;

    for (long i = 1; i*i <= n; i++)
      if (n % i == 0 && i < (n/i)-1) ans += (n/i) - 1L;
    cout << ans << endl;
    return 0;
 }


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=2e5;

int n,Ia[N+3],Elas[N+3],Enxt[N+3],Elen[N+3],Ecnt[N+3],Estk[N+3];
long long Ik,Evis[N+3];

int main(){
	scanf("%d%lld",&n,&Ik);
	for(int i=1;i<=n;i++)
		scanf("%d",&Ia[i]);
	for(int i=n;i>=1;i--){
		if(Elas[Ia[i]]){
			Enxt[i]=Elas[Ia[i]]+1;
			if(Enxt[i]>n) Enxt[i]-=n;
			Elen[i]=Elas[Ia[i]]+1-i;
		}
		Elas[Ia[i]]=i;
	}
	for(int i=n;i>=1;i--)
		if(Enxt[i]==0){
			Enxt[i]=Elas[Ia[i]]+1;
			if(Enxt[i]>n) Enxt[i]-=n;
			Elen[i]=n+Elas[Ia[i]]+1-i;
		}
	int u=1;
	long long Ncnt=0,Ncir;
	memset(Evis,-1,sizeof Evis);
	while(true){
		if(Evis[u]!=-1){
			Ncir=Ncnt-Evis[u];
			break;
		}
		Evis[u]=Ncnt;
		Ncnt+=Elen[u];
		u=Enxt[u];
	}
	Ik*=n;
	Ik%=Ncir;
	u=1;
	while(true){
		if(Ik<Elen[u]){
			int Vtop=0;
			for(int i=0;i<Ik;i++){
				int v=i+u;
				while(v>n) v-=n;
				if(Ecnt[Ia[v]]){
					while(Ecnt[Ia[v]]){
						Ecnt[Estk[Vtop]]--;
						Estk[Vtop--]=0;
					}
				}
				else{
					Ecnt[Ia[v]]++;
					Estk[++Vtop]=Ia[v];
				}
			}
			for(int i=1;i<=Vtop;i++){
				if(i>1) printf(" ");
				printf("%d",Estk[i]);
			}
			printf("\n");
			break;
		}
		Ik-=Elen[u];
		u=Enxt[u];
	}
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

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

  int sum = 0;
  rep(i, n) sum ^= a[i];
  rep(i, n) {
    int ans = sum ^ a[i];
    cout << ans << ' ';
  }
  cout << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3984