akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define PER(i,a,b) for(int (i)=(a);(i)>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(x) ((int)((x).size()))
#define ALL(t) t.begin(),t.end()
#define CLR(x) memset(x,0,sizeof(x))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define FLASH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
inline void rwFile(string file) {freopen((file+".in").c_str(),"r",stdin); freopen((file+".out").c_str(),"w",stdout);}
inline bool EQ(ld a,ld b) {return fabs(a-b)<=(1e-7);}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;} return res;}
ll inv(ll a,ll mod) {return powmod(a,mod-2,mod);}
void clk() {cout<<" Execution Time = "<<(int)(clock()*1000./CLOCKS_PER_SEC)<<" ms\n";}
const ll inf=1000000007;
const ld pi=3.141592653589;
//==============================================CUT_BEGINS==========================================================//

int main() {
	string str;
	cin >> str;
	int a[6];
	a[0] = str[0] - '0';
	a[1] = str[1] - '0';
	a[2] = str[2] - '0';
	a[3] = str[3] - '0';
	REP(i,0,(1<<3) - 1) {
		int ans = a[0];
		if(i & (1<<0)) {
			ans += a[1];
		} else {
			ans -= a[1];
		}
		if (i & (1<<1)) {
			ans += a[2];
		} else {
			ans -= a[2];
		}
		if (i & (1<<2)) {
			ans += a[3];
		} else {
			ans -= a[3];
		}
		if (ans == 7) {
			string x = "+", y = "-";
			cout << a[0] << ((i & (1<<0)) ? x:y);
			cout << a[1] << ((i & (1<<1)) ? x:y);
			cout << a[2] << ((i & (1<<2)) ? x:y);
			cout << a[3] << "=7";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

x = 0
y = 0
while True:
    try:
	 a,b,c,d,e,f = map(float,raw_input().split())
	 if a == 0:
	     y = c / b
	     x = (f - e * c / b) / d
	 elif b == 0:
	     x = c / a
	     y = (f - d * c / a) / e
	 elif d == 0:
	     y = f / e
	     x = (c - b * f / e) / a
	 elif e == 0:
	     x = f / d
	     y = (c - a * f / d) / b
	 else:
	     x = (c*e - b*f) / (a*e - b*d)
	     y = (c*d - a*f) / (b*d - a*e)

         if x == 0:
	     x = 0.0
	 if y == 0:
	     y = 0.0
	 print "%.3f %.3f" % (x,y)

    except EOFError:
	break

Measured memory_bytes: 6328
use proconio::input;
use proconio::marker::Chars;
use std::cmp;

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let mut dp = vec![vec![0; n]; n];
    for i in 0..n {
        for j in i + 1..n {
            if s[i] == s[j] {
                if i > 0 && j > 0 && i < j - dp[i - 1][j - 1] {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = 1;
                }
            }
        }
    }

    let mut max = 0;
    for i in 0..n {
        for j in 0..n {
            max = cmp::max(max, dp[i][j]);
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 197616
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count=1;
  for(int i=0;i<n-1;i++)
  {
    if(s[i]!=s[i+1])
      count+=1;
  }
  cout<<count;
}

Measured memory_bytes: 512
#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 n,k,ans=0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(k<=h[i]) ans++;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 640
from bisect import bisect_right


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    answer = 0
    is_changed = False
    if a[0] <= k or b[0] <= k:
        answer = 1
    elif a[0] + b[0] <= k:
        answer = 2
    for i in range(1, n):
        a[i] += a[i - 1]
        if k < a[i] and not is_changed:
            answer = i
            is_changed = True
    if a[-1] <= k:
        answer = n
    is_changed = False
    for i in range(1, m):
        b[i] += b[i - 1]
        if k < b[i] and not is_changed:
            answer = max(answer, i)
            is_changed = True
    if b[-1] <= k:
        answer = max(answer, m)
    if a[-1] + b[-1] <= k:
        answer = n + m
    elif all(k < x for x in [a[0], b[0], a[0] + b[0]]):
        answer = 0
    else:
        for i in range(n):
            l = bisect_right(b, k - a[i])
            if l == 0 or (l == m and b[l - 1] + a[i] > k):
                continue
            answer = max(answer, i + 1 + l)
    print(answer)


if __name__ == '__main__':
    main()



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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;
int P[200050];
bool ok[200050];
int out[200050];

int main(){
    cin >> N;
    FOR(i,1,N+1)cin >> P[i];
    int cnt=1;
    ok[1]=true;
    int pre=1;
    FOR(i,2,N+1)
    {
        if(ok[i-1])
        {
          if(P[i] <= P[i-1]){cnt++;ok[i]=true;pre=i;}
        }
        else{
          if(P[i] <= P[pre]){cnt++;ok[i]=true;pre=i;}

        }
    }
    cout << cnt << endl;
    return 0;
}

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

long long a[100]={2,1,3,4,7,11,18,29,47,76};

int main(){
	int n; cin>>n;
	for(int i=10;i<=n;i++)
		a[i]=a[i-1]+a[i-2];
		cout<<a[n]<<endl;
	return 0;
}

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

using namespace std;

const int N=502;

int n,m,q;
int f[N][N];

int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=m;++i)
	{
		int u,v;
		cin>>u>>v;
		for(int j=v;j<=n;++j)
		{
			f[u][j]++;
		}
	}
	for(int i=1;i<=q;++i)
	{
		int u,v;
		cin>>u>>v;
		int res=0;
		for(int j=u;j<=v;++j)
		{
			res+=f[j][v];
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

std::string solve(std::string s) {
  std::string ret{};
  for (auto const ch : s) {
    switch (ch) {
      case '0':
      case '1':
        ret += ch;
        break;
      case 'B':
        if (!ret.empty()) {
          ret.pop_back();
        }
        break;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  auto const res = solve(s);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int dp[100001];
int p[11];
int c[11];
int main() {
  ll n;
  cin >> n;
  if(n ==0){
    cout << 0 << endl;
    return 0;
  }
  ll i = 1;
  string s = "";
  while(abs(n) > 0){
    if(n%(abs(i)*2)){
      n -= i;
      s += '1';
    }else{
      s += '0';
    }
    i *= -2;
  }
  reverse(all(s));
  cout << s  << endl;
  
}


Measured memory_bytes: 256
// I SEint YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
string d[110];
bool used[110][110]={};
signed main(){
  init_io();
  int h,w;
  int arr[]={6,3,1,4},idx;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    cin >> d[i];
    if(i%4==0) idx = 0;
    else idx = 2;
    for(int j=0;j<w;j++){
      if(i%2==0){
        if((d[i][j]-'0')!=arr[idx]){
          d[i][j]='#';
        }
        if(i%4==0) idx = (idx+1)%4;
        else idx = (idx+3)%4;
      }else{
        if((i+1)%4==0&&(d[i][j]-'0')!=5){
          d[i][j] = '#';
        }else if((i+1)%4!=0&&(d[i][j]-'0')!=2){
          d[i][j] = '#';
        }
      }
    }
  }
  queue<pair<int,int> > que;
  que.push(pair<int,int>(0,0));
  int vx[]={1,0,-1,0},vy[]={0,1,0,-1};
  while(!que.empty()){
    pair<int,int> tmp = que.front();
    que.pop();
    int x = tmp.first, y=tmp.second;
    if(used[x][y]) continue;
    used[x][y] = true;
    for(int i=0;i<4;i++){
      int nx = x + vx[i];
      int ny = y + vy[i];
      if(nx>=0&&ny>=0&&nx<h&&ny<w){
        if(d[nx][ny]!='#'){
          que.push(pair<int,int>(nx,ny));
        }
      }
    }
  }
  if(used[h-1][w-1]){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}



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

using namespace std;
typedef long long ll;
ll mod=1e9+7;
const int N= 2e5+3;
vector<int>vp[N];
map<pair<int,int> , int >mp;
int vis[N];
int dfs(int node)
{
    vis[node]++;
    int sz=vp[node].size();
    int num=1;
    for(int i = 0  ; i < sz ; i++)
    {
        if(!vis[vp[node][i]])
        {
            num+=dfs(vp[node][i]);
        }
    }
    return num;
}
int main()
{
    ll n , m , a , b ;
    cin >> n >> m ;
    for( int i  = 0 ; i< m ; i++)
    {
        cin >> a>> b ;
        if(a>b)
            swap(a , b);
        if(mp[{a, b}]>0)
            continue;
        //pair<int,int>p=make_pair(a , b);
        mp[{a, b}]++;
        vp[a].push_back(b);
        vp[b].push_back(a);
    }
    int ans=0;
    for(int i = 1 ; i <= n  ; i++)
    {
        if(!vis[i])
        {
            ans=max(ans ,dfs(i) );
        }
    }
    cout << ans ;
}



Measured memory_bytes: 37016
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll k,a,b;
    cin>>k>>a>>b;
    bool f=false;
    for(ll i =a;i<=b;i++){
        if(i%k==0) f=true;
    }
    if(f) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n;
    cin >> n;
    ll mx = 0;
    for(ll i = 1; i <= n; i++){
        rep(j, 10){
            if( (1<< j)<= i) mx = max(mx, (ll)(1<<j));
        }
    }
    cout << mx;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1980000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


Measured memory_bytes: 1152
N = int(input())

g = [[0] * 10 for i in range(10)]

for i in range(1, N+1):
    s = str(i)
    a = int(s[0])
    b = int(s[-1])
    g[a][b] += 1

ans = 0

for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j] * g[j][i]
print(ans)


Measured memory_bytes: 3060
n,m=map(int,input().split())
hl=input().split()
shl=[int(x) for x in hl]
vl=set()
for i in range(m):
    a,b=map(int,input().split())
    if shl[a-1]>shl[b-1]:
        vl.add(b-1)
    elif shl[a-1]<shl[b-1]:
        vl.add(a-1)
    else:
        vl.add(a-1)
        vl.add(b-1)
lshl=len(shl)
lvl=len(vl)
ans=lshl-lvl
print(ans)

Measured memory_bytes: 24600
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
const int MAXN=1000010;
const int MOD=1000007;
string st;
string en="123456780";
int head[MAXN],nex[MAXN];
int f[MAXN],top;
string ss[MAXN];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
queue<string> q;
queue<int> qs;
void input()
{
	memset(head,-1,sizeof(head));
	memset(nex,-1,sizeof(nex));
	for(int i=0;i<3;i++)
	    for(int j=0;j<3;j++){
	    	char c;
	        cin>>c;
	        st+=c;
	    }
	//cout<<st<<endl;
}

int has(string s){
	int sum(0);
	for(int i=0;i<9;i++){
		sum*=10;
		sum+=s[i]-'0';
	}
	return sum;
}

void add(string tt){
	int tmp=has(tt);
	nex[top]=head[tmp%MOD];
	head[tmp%MOD]=top;
	ss[top++]=tt;
}

bool ff(string tt){
	int tmp=has(tt);
	int u=head[tmp%MOD];
	while(u!=-1){
		string ttt=ss[u];u=nex[u];
		if(ttt==tt) return true;
	}
	return false;
}

void xxj()
{
	q.push(st);
	add(st);
	qs.push(0);
	while(!q.empty()){
		string tmp=q.front();q.pop();
		int ts=qs.front();qs.pop();
		//if(ts==4) cout<<tmp<<' '<<ts<<endl;
		if(tmp==en) {cout<<ts<<endl;return;}
		int pos=tmp.find('0');
		int x=pos/3,y=pos%3;
		//cout<<x<<' '<<y<<endl;
		for(int k=0;k<4;k++){
			int xx=x+dx[k];
			int yy=y+dy[k];
			if(xx<0 || yy<0 || xx>=3 || yy>=3) continue;
			string tt=tmp;
			swap(tt[xx*3+yy],tt[pos]);
			if(!ff(tt)){
				q.push(tt);
				qs.push(ts+1);
				add(tt);
			}
		}
	}
}

int main()
{
	input();
	xxj();
	return 0;
}

Measured memory_bytes: 27664
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=100,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 100;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10lf\n",used[i]);
  }
  return 0;
}

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}
template<typename T>
vector<T> make_v(size_t a, T b){ return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts){
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
int N, M;
int ans[100000];
bool used[100000];
vector<int> G[100000];
vector<int> sorted;

void toposort(int v){
    if(used[v])return;
    used[v] = true;
    for(int u : G[v])toposort(u);
    sorted.push_back(v);
}

void structure(int v, int p){
    if(used[v])return;
    used[v] = true;
    ans[v] = p + 1;
    for(int u : G[v])structure(u, v);
}

// solve
int main(){

    cin >> N >> M;
    rep(i, N + M - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }

    rep(i, N)toposort(i);
    reverse(all(sorted));
    vector<int> order(N);
    rep(i, N)order[sorted[i]] = i;
    rep(i, N)sort(all(G[i]), [&](int x, int y){
        return order[x] < order[y];
    });

    memset(used, 0, sizeof(used));
    structure(sorted[0], -1);

    rep(i, N)cout << ans[i] << '\n';
    return 0;

}


Measured memory_bytes: 10872
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

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

    vector<char> ans;
    REP(i, S.size()) {
        if(S[i]=='B'&&!ans.empty()) {
            ans.pop_back();
        }
        else if(S[i]!='B') {
            ans.push_back(S[i]);
        }
    }
    REP(i, ans.size()) {
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt(); 
		int area = a*b;
		int length = 2*a+2*b;
		System.out.println(area + " " + length);

	}
}

Measured memory_bytes: 26048
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;

vector<vector<pii>> r;

const int INF = 1<<28;
VI dijkstra(int s){
	priority_queue< pii, vector<pii>, greater<pii> > que;
	VI d(sz(r), INF);
	d[s] = 0; 
	que.push(pii(0, s));
	while(!que.empty()){
		int cost, v; tie(cost, v) = que.top();
		que.pop();
		if(d[v] < cost) continue;
		for(const auto& rp : r[v]){ 
			ll rct, rto; tie(rto, rct) = rp;
			if(d[rto] > d[v] + rct){
				d[rto] = d[v] + rct;
				que.push(pii(d[rto], rto));
			}
		}
	}
	return d;
}




int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k;
	cin >> n;
	r.resize(n+1);
	rep(i,n-1){
		int a,b; cin >>a >>b;
		r[a-1].emplace_back(b-1,1);
		r[b-1].emplace_back(a-1,1);
	}
	VI vc(n+1, -999999);
	cin >>k;
	vector<pii> vp(k);
	rep(i,k){
		int v,p; cin >>v >>p;
		vc[v-1] =p;
		vp[i] = pii(v-1,p);
		r[n].emplace_back(v-1,p);
	}
	
	auto rv = dijkstra(n);
	
	rep(i,n) if(vc[i] !=-999999 && vc[i] != rv[i]){puts("No"); return 0;}
	
	rep(i,n){
		for(auto x:r[i]){
			if(x.first==n) continue;
			if(abs(rv[i] - rv[x.first]) !=1) {puts("No"); return 0;}
		}
	}
	puts("Yes");
	rep(i,n) printf("%d\n", rv[i]);
	//for(auto x :rv) printf("%d, ",x); puts("");
	//for(auto x :vc) printf("%d, ",x); puts("");
	
	return 0;
}


Measured memory_bytes: 10104
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;

deque<int> Solve(ll n){
	if (n==1) return {};
	if (n&1){
		auto dq=Solve(n-1);
		dq.push_front(dq.size()+1);
		return dq;
	}
	auto dq=Solve(n>>1);
	dq.push_back(dq.size()+1);
	return dq;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	auto out=Solve(n+1);
	cout<<out.size()+100<<'\n';
	for (int i=1; i<=100; i++) cout<<i<<' ';
	for (int i:out) cout<<i<<' ';
	
	return 0;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  if (A + K - 1 >= B - K + 1) {
    for (int i = A; i <= B; i++) {
      cout << i << endl;
    }
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << A + i << endl;
    }
    for (int i = 0; i < K; i++) {
      cout << B - K + 1 + i << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[][] cards = new boolean[4][13];
    for (int i = 0; i < n; i++) {
      String str = sc.next();
      int no = sc.nextInt();
      switch (str) {
        case "S" : 
          cards[0][no - 1] = true;
          break;
        case "H" :
          cards[1][no - 1] = true;
          break;
        case "C" :
          cards[2][no - 1] = true;
          break;
        case "D" :
          cards[3][no - 1] = true;
          break;
      }
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 13; j++) {
        if (cards[i][j] == false) {
          switch (i) {
            case 0 :
              System.out.println("S " + (j + 1));
              break;
            case 1 :
              System.out.println("H " + (j + 1));
              break;
            case 2 :
              System.out.println("C " + (j + 1));
              break;
            case 3 :
              System.out.println("D " + (j + 1));
              break;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k, a;
  	cin >> n >> k;
  	for (int i = 0; i<n ; i++){
  		int x;
      	cin >> x;
      	if (x < k-x){
        	a += 2*x;
        }else{
          	a += 2*(k-x);
        }
    }
  	cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define fi first
#define se second
using namespace std;

int dx[8] = { 0,1,0,-1,-1,1,-1,1 };
int dy[8] = { 1,0,-1,0,1,1,-1,-1 };



int main() {

	int a, b;
	
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define Mod 1000000007
#define Max 1000001
#define vt vector<long long>
ll arr[Max];

void func(){
    ll k;
    cin>>k;
    arr[0]=0;
    for(int i=1; i<Max; i++){
        arr[i]=(10*(arr[i-1])+7)%k;
        if(arr[i]==0){
            cout<<i<<endl;
            return;
        }

        
    }
    cout<<-1<<endl;
}   
 
int main(){
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
 
// 
//int t;
//cin >> t;
//for(ll i=1; i<=t; i++)
//{
    
    func();
//    cout<<endl;
//cout<<func()<<endl;
 
//if(func())
//    cout<<"Yes"<< endl;
//else
//    cout <<"No"<<endl; 
//cout<<"Case"<<" "<<"#"<<i<<":"<<" "<<func()<<endl;
//}
return 0;
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
int N;
  cin >>N;
  vec v(N);
  for(int i=0;i<N;i++) cin >>v[i];
  sort(v.begin(),v.end());
  double wa  =v[0];
  for(int i=1;i<=N-1;i++){
   wa =( wa+v[i] )/2;
  }
  cout << wa <<endl;
}
  


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

using namespace std;

void merge_sort(vector<int>& vec, int left, int right, int& count);

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

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

    int count = 0;
    merge_sort(vec, 0, vec.size() - 1, count);

    cout << vec[0];
    for (int i = 1; i < n; ++i)
        cout << ' ' << vec[i];
    cout << '\n';

    cout << count << '\n';
}

void merge_sort(vector<int>& vec, int left, int right, int& count)
{
    if (left < right) {
        int mid = (left + right) / 2;

        merge_sort(vec, left, mid, count);
        merge_sort(vec, mid + 1, right, count);

        // merge
        int left_size = mid - left + 1;
        int right_size = right - mid;
        vector<int> vec_left(left_size);
        vector<int> vec_right(right_size);
        for (int i = 0; i < left_size; ++i) {
            vec_left[i] = vec[left + i];
        }

        for (int i = 0; i < right_size; ++i) {
            vec_right[i] = vec[mid + 1 + i];
        }

        int i = 0, j = 0, k = left;
        while (i < left_size && j < right_size) {
            if (vec_left[i] < vec_right[j]) {
                vec[k] = vec_left[i];
                ++i;
                ++k;
            } else {
                vec[k] = vec_right[j];
                ++j;
                ++k;
            }
            ++count;
        }

        while (i < left_size) {
            ++count;
            vec[k] = vec_left[i];
            ++i;
            ++k;
        }

        while (j < right_size) {
            ++count;
            vec[k] = vec_right[j];
            ++j;
            ++k;
        }
    }
}



Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,x;
    cin >> N >> x;
    
    
    cout << max(2*N-1, max(N + x, 2*x-1)) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin >> N;
  int P = 0;
  int M = 0;
  for (int i = 0; i < N; i++){
    cin >> L;
    P += L;
    M = max(M,L);
  }
  cout << (P > M * 2 ? "Yes" : "No");
}

Measured memory_bytes: 256
W,H,N=map(int,input().split())
A=[0]*4
A[1]=W
A[3]=H
for i in range(N):
	x,y,a=map(int,input().split())
	if a==1:
		if A[0]==-1:A[0]=x
		else:A[0]=max(A[0],x)
	elif a==2:
		if A[1]==-1:A[1]=x
		else:A[1]=min(A[1],x)
	elif a==3:
		if A[2]==-1:A[2]=y
		else:A[2]=max(A[2],y)
	else:
		if A[3]==-1:A[3]=y
		else:A[3]=min(A[3],y)

print(max(A[1]-A[0],0)*max(A[3]-A[2],0))


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

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#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)<<'\n'
#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] << ((i == v.size() - 1) ? "\n" : " ")
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>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;


bitset<4100000>dp;
void solve() {
	int N; cin >> N;
	int sum = 0;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	int mid = (sum + 1) / 2;

	dp[0] = true;
	VSORT(A);
	REP(i, N) {
		//cout << dp << endl;
		dp |= (dp << A[i]);
	}
	//REP(i, 100)print(dp[i]);
	FOR(i, mid, sum + 1) {
		if (dp[i]) {
			print(i); return;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



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

int main() {
  int N,M,k;
  string kari;
  vector<string> a;
  vector<string> b;
  vector<int> a_count(1,1);
  
  cin >> N;
  cin >> kari;
  a.push_back(kari);
  for(int i=1;i<N;i++){
    cin >> kari;//i th input
    k=a.size();
    auto aiueo=[&kari](string species){return kari==species;};
    for(int j=0;j<k;j++){
      if(a.at(j)==kari){
        a_count.at(j)++;
        break;
      }
    }
    if(none_of(a.cbegin(),a.cend(),aiueo)){
      a.push_back(kari);
      a_count.push_back(1);
    }
  }
  vector<int> b_count(a.size(),0);
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> kari;
    for(int j=0;j<a.size();j++){
      if(a.at(j)==kari){
        b_count.at(j)++;
        break;
      }
    }
  }
  k=0;
  for(int i=0;i<a_count.size();i++){
    k=max(k,max(a_count.at(i)-b_count.at(i),0));
  }
  cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<int> adj[N];
int vis[N];
int len = OO;
vector<int> vv, ans;

bool cycle(int node, int par) {
  vis[node] = 1;
  int ret = 0;
  for(auto it: adj[node]) {
    if(it == par) continue;
    if(vis[it] == 0)
      ret |= cycle(it, node);
    else if(vis[it] == 1)
      return 1;
  }
  vis[node] = 2;
  return ret;
}

void cycleAns(int node, int root, bool awlMra) {
  if(!awlMra && root == node) {
    if((int)vv.size() < len) {
      len = vv.size();
      ans = vv;
    }
    return;
  }
  if(vis[node])
    return;
  vis[node] = 1;
  vv.push_back(node);
  for(auto it: adj[node])
    cycleAns(it, root, 0);
  vis[node] = 2;
  vv.pop_back();
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
  }
//  if(!cycle(1, -1)) {
//    cout << -1;
//    return 0;
//  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof vis);
    vv.clear();
    cycleAns(i, i, 1);
  }
  if(len > n) len = -1;
  cout << len;
  if(len != -1) {
    cout << '\n';
    for(int it: ans)
      cout << it << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main(void) {
    int x,y,sum_xy=0,sum_y=0,ave=0,count=0;
    char c;
    while(cin >> x >> c >> y){
        sum_xy=sum_xy+x*y;
        sum_y=sum_y+y;
        ++count;
    }
    ave=sum_y/count + 1;
    cout << sum_xy << endl << ave << endl;
}


Measured memory_bytes: 3072
M=10**9+7
(n,k),*a=[list(map(int,t.split()))for t in open(0)]
r=a if k&1else[[i==j for j in range(n)]for i in range(n)]
d=a
for i in range(1,k.bit_length()):
  p=[]
  for y in d:
    q=[0]*n
    for x,s in zip(y,d):
      for j,t in enumerate(s):
        q[j]+=t*x%M
    p+=q,
  d=p
  if 1<<i&k:
    p=[]
    for y in r:
      q=[0]*n
      for x,s in zip(y,d):
        for j,t in enumerate(s):
          q[j]+=t*x%M
      p+=q,
    r=p
print(sum(t for s in r for t in s)%M)

Measured memory_bytes: 75740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,r;
	cin >> n >> r;

	if(n>=10){
		cout << r << endl;
		return;
	}

	cout << r + 100*(10-n) << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
import copy
n,m=map(int,input().split())
h=list(map(int,input().split()))
H = copy.deepcopy(h)
for _ in range(m):
    a,b=map(int,input().split())
    if H[b-1] - H[a-1] > 0:
        h[a-1] = 0
    elif H[b-1] - H[a-1] == 0:
        h[a-1] = 0
        h[b-1] = 0
    else:
        h[b-1] = 0
print(n-h.count(0))

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

int main(){
    double n;
    cin>>n;
    double x = (n/1.08);
    if((int)(x*10) > 5){
        x= ceil(x);
    }
    else x = floor(x);
    if(int(x*1.08) != n)cout<<":(";
    else cout<<x;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	string s;
	cin>>s;
	
	for(int i=0; i<s.length()-1; i++){
		if(s[i] == s[i+1]){
			writeln("Bad");
			return 0;
		}
	}
	writeln("Good");
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct node{
  int key;
  struct node *next,*prev;

};

struct node *nil;

struct node *search(int);
void init();
void print();
void delnode(struct node *);
void delfirst();
void dellast();
void delkey(int k);
void insert(int key);

int main(){
  int key,i,n,s=0,size=0;
  char a[50];
  int np=0,nd=0;

  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",a,&key);
    if(strcmp(a,"insert")==0){
      insert(key);
      np++;    
      size++;
    }else if(a[0]=='d'){
      if(strlen(a)>6){
	if(a[6]=='F') delfirst();
        else if(a[6]=='L') dellast();			
     }else{
          delkey(key);
          nd++;
       }
        size--;
    }
  }
  print();
      
  return 0;
}

struct node *search(int key){
  struct node *nb;
  nb=nil->next;
  while(nb!=nil&&nb->key!=key){
    nb=nb->next;

  }
  return nb;
}
void init(){
  nil = (struct node *)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void print(){
  struct node *nb;
  int f=0;
  nb=nil->next;
  while(1){
    if(nb==nil)break;
    if(f++ >0) printf(" ");
    printf("%d",nb->key);
    nb=nb->next;
  }
  printf("\n");

}

void delnode(struct node *t){
  if(t == nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void delfirst(){
  delnode(nil->next);
}

void dellast(){
  delnode(nil->prev);

}

void delkey(int key){
  delnode(search(key));
}

void insert(int key){
  struct node *x;
  x=(struct node *)malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev =nil;
  
}



Measured memory_bytes: 33108
#include<stdio.h>
int main()
{
	int x, y;
	for (;;)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
			break;
		if (x < y)
			printf("%d %d\n", x, y);
		else
			printf("%d %d\n", y, x);
	}
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 2e5 + 5, INF = 0x3f3f3f3f;
inline int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int ans[N];
vector <int> G[N], col[2], mod[3];
void dfs(int x, int c, int fa) {
	col[c].push_back(x);
	for (auto y : G[x]) if (y != fa) dfs(y, c ^ 1, x);
}
void sol(int i, int j) {
	while (!col[i].empty() && !mod[j].empty()) {
		ans[col[i].back()] = mod[j].back();
		col[i].pop_back(), mod[j].pop_back();
	}
}
int main() {
	int n = read();
	for (int i = 1; i < n; i++) {
		int x = read(), y = read();
		G[x].pb(y), G[y].pb(x);
	}
	for (int i = 1; i <= n; i++) mod[i % 3].pb(i);
	dfs(1, 0, 0);
	sol(col[0].size() < col[1].size(), 1), sol(col[0].size() < col[1].size(), 2);
	sol(0, 0), sol(1, 0);
	for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
	return 0;
}     



Measured memory_bytes: 22296
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll NINF=1e14;

int a[100005];
int n;
ll dp[100005];

ll solve(int idx){
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    return dp[n-1];
}

int main() {
    fastio

    memset(dp,0,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];

    cout<<solve(0);
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool res = false;
  for (int i = 0; i * 4 <= n; ++i) {
    if ((n-i*4) % 7 == 0) res = true;
  }
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cassert>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef vector<vector<int> > VVI;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;
#define len(a) ((int)(a.size()))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ms(x,c) memset(x,c,sizeof(x))
#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 all(a) (a).begin(),(a).end()
#define fi first
#define se second
template<class T> T sqr(const T &x) { return x*x; }
template<class T> T lowbit(const T &x) { return (x^(x-1))&x; }
template<class T> int countbit(const T &n) { return (n==0)?0:(1+countbit(n&(n-1))); }
template<class T> void ckmin(T &a,const T &b) { if (b<a) a=b; }
template<class T> void ckmax(T &a,const T &b) { if (b>a) a=b; }

const double pi=acos(-1.0);
const double eps=1e-11;
//const int oo=2*(1<<30)+1;

int n,i,j,k,cnt;
int x[100010],y[100010],t[100010];

int dis(int a,int b)
{
    return abs(x[a]-x[b])+abs(y[a]-y[b]);
}

bool check(int a,int b)
{
    int dt=t[b]-t[a];
    int ds=dis(a,b);
    if(ds>dt) return 0;
    else
        if(abs(ds-dt)%2==0) return 1;
        else return 0;
}

priority_queue<ll, vector<ll>, less<ll> > d;

int main()
{
    //freopen("model.in","r",stdin);freopen("1.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    t[0]=0;
    x[0]=y[0]=0;
    rep(i,1,n) cin>>t[i]>>x[i]>>y[i];
    rep(i,1,n)
        if(check(i-1,i)==1) continue;
        else {cout<<"No"<<endl;exit(0);}
    cout<<"Yes"<<endl;
        return 0;
}

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

int main() {
  // 3ビットのビット列をすべて列挙する
  int n;cin >> n;
  vector<vector<pair<int,int>>> veca;
  for(int i=0;i<n;i++){
    vector<pair<int,int>> tmp;
    int a;cin>>a;
    //cout << a << endl;
    for(int j=0; j<a;j++){
      int x,y;cin >> x >> y;
      tmp.push_back(make_pair(x,y));
    }
    veca.push_back(tmp);
  }
  int ans=0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<15> s(tmp);
    //cout << s << endl;
    bool mujun = false;
    for(int i=0;i<n;i++){
      if(s.test(i)){
        //cout << s << endl;
        for(auto p : veca.at(i)){
          //cout << p.first << ' ' << p.second << endl;
          if(p.second==0){if(s.test(p.first-1)!=0)mujun=true;}
          else{if(s.test(p.first-1)!=1)mujun=true;}
        }
      }
    }
    if(mujun){}
    else{ans = max((int)(s.count()),ans);}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256