akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> vec1(M);
  vector<int> vec2(M);
  for (int i=0;i<M;i++){
    cin >> vec1.at(i) >> vec2.at(i);
  }
  for(int i=1;i<=N;i++){
    int x=0;
    for(int j=0;j<M;j++){
      if(i==vec1.at(j)||i==vec2.at(j)){
        x++;
      }
    }
    cout << x <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N,ans;

void dfs(long long x, bool flag3,bool flag5,bool flag7)
{if(x > N){ return;}
 if(flag3 && flag5 && flag7) {ans++;}
 
 dfs(10*x + 3, true, flag5, flag7);
 dfs(10*x + 5, flag3, true, flag7);
 dfs(10*x + 7, flag3, flag5, true);
}
int main(void)
{cin >> N;
 ans = 0;
 
 dfs(0,0,0,0);
 
 cout << ans << endl;}
 

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

int main(void) {
  long long n=100, x, tmp, cnt=0;
  cin >> x;
  
  while (n < x) {
    tmp = n / 100;
    n += tmp;
    cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	numbers := make([]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		numbers[i] = a
	}
	sort.Sort(sort.Reverse(sort.IntSlice(numbers)))
	// goに#slice.sum()など存在しない
	ans := 0
	for _, v := range numbers[:k] {
		ans += v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; vector<vector<pair<ll,ll>>> table(n);
  
  rep(i,n){
    ll x; cin >> x;
    
    rep(j,x){
      ll a,b; cin >> a >> b;
      table[i].push_back(make_pair(a-1,b));
    }
  }
  
  ll ans = 0;
  
  for (int bit = 0; bit < (1<<n); ++bit) {
    vector<int> S;
    
    for (int i = 0; i < n; ++i){ 
      if (bit & (1<<i)) S.push_back(i);
    }
    
    bool flag = true;
    for(ll x : S){
      for(auto p : table[x]){
        ll a = p.first; ll b = p.second;
        
        if(b == 1){
          bool fflag = false;
          for(ll x : S){
            if(x == a) fflag = true;
          }
          if(!fflag) flag = false;
        }
        else{
          for(ll x : S){
            if(x == a) flag = false;
          }
        }
      }
    }

    
    if(flag){
      ans = max(ans,(ll)S.size());
    }
  }
  
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> c(m,0);
    for(int i = 0; i < m; i++){
        int b;
        cin >> a[i] >> b;
        for(int j = 0; j < b; j++){
            int ky;
            cin >> ky;
            ky--;
            c[i] += (1<<ky);
        }
    }

    int dp[m+1][1 << n+1];

    for(int i = 0; i <= m; i++){
        for(int j = 0; j < (1<<n+1); j++){
            dp[i][j] = mod;
        }
    }

    for(int i = 0; i <= m; i++) dp[i][0] = 0;

    for(int i = 0; i < m; i++){
        for(int j = 0; j < (1<<n); j++){
            if(j - (c[i]&j) >= 0)
                dp[i+1][j] = min(dp[i][j],dp[i][j-(c[i]&j)]+a[i]);
            //cout << dp[i+1][j] << " " << i << " " << j << endl;
        }
    }

    if(dp[m][(1<<n)-1] == mod) cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
}

Measured memory_bytes: 35648
import sys
x,y = list(map(int, input().split()))

cnt = 1
xy = [0,0]
xy2 = [1,1]
if xy[0] <= x < xy2[0] and xy[1] <= y < xy2[1]:
    print(cnt)
    sys.exit(0)
while 1:
    if cnt % 4 == 1:
        xy2[0] += xy2[1] - xy[1]
    elif cnt % 4 == 2:
        xy2[1] += xy2[0] - xy[0] 
    elif cnt % 4 == 3:
        xy[0] -= xy2[1] - xy[1]
    elif cnt % 4 == 0:
        xy[1] -= xy2[0] - xy[0]
    if xy[0] <= x < xy2[0] and xy[1] <= y < xy2[1]:
        print((cnt % 3) + 1)
        break
    cnt += 1
    

        


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    int n,k;
    cin >> n >>k;
    int rs = 0;
    for (int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        if (temp >= k){
            rs++;
        }
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<map>
#include<algorithm>
#include<sstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;

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

map<string, int> dict;
void init() {
  dict[ "yotta" ] = 24;
  dict[ "zetta" ] = 21;
  dict[ "exa" ] = 18;
  dict[ "peta" ] = 15;
  dict[ "tera" ] = 12;
  dict[ "giga" ] = 9;
  dict[ "mega" ] = 6;
  dict[ "kilo" ] = 3;
  dict[ "hecto" ] = 2;
  dict[ "deca" ] = 1;
  dict[ ""] = 0;
  dict[ "deci" ] = -1;
  dict[ "centi" ] = -2;
  dict[ "milli" ] = -3;
  dict[ "micro" ] = -6;
  dict[ "nano" ] = -9;
  dict[ "pico" ] = -12;
  dict[ "femto" ] = -15;
  dict[ "ato" ] = -18;
  dict[ "zepto" ] = -21;
  dict[ "yocto" ] = -24;
}

int getYuukou(string s) {
  int rz = 1;
  int res = 0;
  for (int i = 0; i < (int)s.size(); i++)
      if (isdigit(s[i])) {
          if (s[i] == '0' && rz) {
              ;
          } else {
              rz = 0;
              res++;
          }
      }
  return res;
}

void solve() {
  string line; getline(cin, line);
  stringstream ss(line);
  string value; ss >> value;
  string prefix; ss >> prefix >> ws;
  string unit;
  if (ss.eof()) {
      unit = prefix;
      prefix = "";
  } else {
      ss >> unit;
  }
  int yuukou = getYuukou(value);
  int kurai = dict[prefix];
  if (value[0] == '0') {  // 0.xxxx
      int i;
      for (i = 0; ; i++) {
          if (isdigit(value[i])) {
              if (value[i] == '0') kurai--;
              else break;
          }
      }
      cout << value[i] << (i + 1 == value.size() ? "" : ".") << value.substr(i + 1) << " * 10^" << kurai << " " << unit << endl;
  } else if (count(value.begin(), value.end(), '.') == 0) { // 42
      kurai += value.size() - 1;
      cout << value[0] << (1 == value.size() ? "" : ".") << value.substr(1) << " * 10^" << kurai << " " << unit << endl;
  } else { // 31.45
      int m = value.find('.');
      kurai += m - 1;
      value.erase(value.begin() + m);
      cout << value[0] << (1 == value.size() ? "" : ".") << value.substr(1) << " * 10^" << kurai << " " << unit << endl;
  }
}
int main() {
  init();
  int T; cin >> T >> ws;
  for (;T--;) solve();
  return 0;
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  long long maxi = 0;
  
  if(b>0 && a>0 && d>0 && c>0)
    maxi = b*d;
  else if(b>0 && a>0 && c<=0 && d>0)
    maxi = b*d;
  else if(b>0 && a>0 && c<=0 && d<=0)
    maxi = a*d;
  else if(b>0 && a<=0 && c>0 && d>0)
    maxi = b*d;
  else if(b>0 && a<=0 && c<=0 && d>0)
    maxi = max(b*d,a*c);
  else if(b>0 && a<=0 && c<=0 && d<=0)
    maxi = a*c;
  else if(b<=0 && a<=0 && c>0 && d>0)
    maxi = b*c;
  else if(b<=0 && a<=0 && c<=0 && d>0)
    maxi = a*c;
  else if(b<=0 && a<=0 && c<=0 && d<=0)
    maxi = a*c;
  
  cout << maxi << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
int main (){
    int k;
    char vet[16];
    scanf("%d", &k);
    strcpy(vet,"ACL");
    while(k > 1){
        strcat(vet,"ACL");
        k--;
    }
    printf("%s\n", vet);
    return 0;
}

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

using namespace std;

int arr[105];
int n;

int sq(int x)
{
	return x*x;
}

int calc(int x)
{
	int ans=0;
	for(int i=0;i<n;i++)
		ans+=sq(arr[i]-x);
	return ans;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> arr[i];
	int ans=(1<<30);
	for(int i=1;i<=100;i++)
		ans=min(ans,calc(i));
	cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> Nums(10001);

	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int n = x * x + y * y + z * z + x * y + y * z + z * x;
				if (n <= 10000) Nums[n]++;
			}
		}
	}
	for (int i = 1; i <= N; i++) cout << Nums[i] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
	int H,W,i;
	cin >> H >> W;
	char a[H][W+1];
	for(i=0;i<H;i++){
		cin >> a[i];
	}
	for(i=0;i<W+2;i++)cout << "#";
	cout << endl;
	for(i=0;i<H;i++){
		cout << "#";
		cout <<a[i];
		cout << "#" << endl;
	}
	for(i=0;i<W+2;i++)cout << "#";
	cout << endl;
	return 0;
}

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


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


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define br cout<<"\n";
#define ull unsigned long long int
#define ld long double
#define loop1(i,a,b) for(int i=a;i<b;i++)
#define loop2(i,a,b) for(int i=a;i<=b;i++)
#define loop3(i,a,b) for(int i=a;i>b;i--)
#define loop4(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define test(t) ll t; cin >> t; while(t--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define fi first
#define se second
signed main() 
{
    FASTIO
     ll n;
     cin >> n;
     string s;
     cin >> s;
     int w=0;
     loop1(i,0,n)
     {
        if(s[i] == 'W')
        w++;
     }
     //cout << w << "\n";
     string res="";
     loop1(i,0,n-w) res += "R";
     loop1(i,0,w) res += "W";
     int count = 0;
    //   cout << s << "\n";
    //   cout << res << "\n";
     loop1(i,0,n-w)
     {
         if( s[i] != res[i] ) count++;
     }
     cout << count << "\n";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 3832
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

//143 A
int main(void) {
	ll a, b;
	cin >> a >> b;
	cout << max((ll)0, a - b * 2) << endl;
}


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

using namespace std;

int main(void){
	
	int N;
	cin >> N;
	int i;
	int ans = 0;
	for(i = 1; i < 10; i++){
		if(N%i == 0 && N / i < 10){
			ans = 1;
		}
	}
	if(ans == 1){
		cout <<"Yes"<<endl;
	}
	else{
		cout <<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  int n, x, y, z, count = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  
  for(int i = 0; i < n - 2; i++){
    x = a[i];
    for(int j = i + 1; j < n - 1; j++){
      y = a[j];
      
      for(int k = j + 1; k < n; k++){
        z = a[k];
        if(x != y && y != z && z != x && x + y > z) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3600
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]
ans = 2000
flag = False
for i in ct:
    if i[1] <= t and ans >= i[0]:
        ans = i[0]
        flag = True

if flag:
    print(ans)
else:
    print("TLE")


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class RMQ {
    int n;
    vector<int> dat;
    
public:
    RMQ(int _n) {init(_n);}
    RMQ(){}
    
    void init(int _n) {
        n=1;
        while (n<_n) n*=2;
        dat.resize(2*n-1, INT_MAX);
    }
    
    void update(int k, int a) {
        k += n-1;
        dat[k] = a;
        while (k>0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    
    int size() {
        return n;
    }
    
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INT_MAX;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a, b, k*2+1, l, (l+r)/2);
            int vr = query(a, b, k*2+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }
 
    int query(int l, int r)
    {
        return query(l, r, 0, 0, n);
    }
};


typedef pair<int, pair<int, int>> State;

int main()
{
    ios::sync_with_stdio(false);

    RMQ rmq_odd, rmq_even;
    map<int, int> num2idx;
    int N; cin >> N;
    rmq_odd.init(N);
    rmq_even.init(N);

    rep(i, N) {
        int A; cin >> A;
        if (i%2 == 1) rmq_odd.update(i, A);
        else          rmq_even.update(i, A);
        num2idx[A] = i;
    }

    priority_queue<State, vector<State>, greater<State>> Q;
    Q.emplace(rmq_even.query(0, N), PII(0, N));
    bool first = true;
    while (Q.size()) {
        if (!first) {
            cout << " ";
        } else {
            first = false;
        }

        State s = Q.top(); Q.pop();
        int l = s.second.first, r = s.second.second;
        RMQ *rmq_f, *rmq_s;

        if (l >= r) continue;

        if (l%2 == 0) {
            rmq_f = &rmq_even;
            rmq_s = &rmq_odd;
        } else {
            rmq_f = &rmq_odd;
            rmq_s = &rmq_even;
        }

        int ln, li, rn, ri;
        ln = rmq_f->query(l, r);
        li = num2idx[ln];
        rn = rmq_s->query(li+1, r);
        ri = num2idx[rn];

        Q.emplace(rmq_f->query(l, li), PII(l, li));
        Q.emplace(rmq_s->query(li+1, ri), PII(li+1, ri));
        Q.emplace(rmq_f->query(ri+1, r), PII(ri+1, r));

        cout << ln << " " << rn;
    }
    cout << endl;
}

Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
int main(){
  double D,T,S;
  cin >> D;
  cin >> T;
  cin >> S;
  double time = D/S;
  if(time <= T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3736
n, k = map(int, raw_input().split())
W = [input() for _ in xrange(n)]

def check(p):
    i = 0
    for j in xrange(k):
        s = 0
        while s + W[i] <= p:
            s += W[i]
            i += 1
            if (i == n):
                return n
    return i

def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = int((right + left) / 2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    return right

def main():
    ans = solve()
    print ans
    return 0

main()

Measured memory_bytes: 9456
local n = io.read("*n", "*l")
local str = io.read()
local a = {}
for v in str:gmatch("(%-?%d+)") do
  table.insert(a, tonumber(v))
end
local stepmin = nil
for type = -1, 1, 2 do
  local step = 0
  local sum = 0
  local flag = type
  for i = 1, n do
    sum = sum + a[i]
    if flag == 1 then
      if sum <= 0 then
        step = step + 1 - sum
        sum = 1
      end
    else
      if 0 <= sum then
        step = step + 1 + sum
        sum = -1
      end
    end
    flag = -flag
  end
  if type == -1 then stepmin = step else stepmin = math.min(stepmin, step) end
end
print(stepmin)


Measured memory_bytes: 6144
#include <bits/stdc++.h>
	
using namespace std;
	
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef pair<pair<int,int>,bool> piib;
	
const ll N=501;
const int MOD=1e9+7;

int t;
int n;
int arr[N];
int arr2[N];
	
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	
	int n;
    cin >> n;
    if(n%1000)
        cout << (((n/1000)+1)*1000)-n << endl;
    else
        cout << n%1000 << endl;
    

	
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>

using namespace std;

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
  int N;
  vector<int> A(9);
  vector<int> bingo(9);
  for(int i=0; i<9; i++){
    cin >> A.at(i);
  }
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  for(int i=0; i<9; i++){
    bingo.at(i) = vector_finder(vec, A.at(i));
  }
  vector<int> B(9);
  B.at(0) = bingo.at(0) + bingo.at(1) + bingo.at(2);
  B.at(1) = bingo.at(3) + bingo.at(4) + bingo.at(5);
  B.at(2) = bingo.at(6) + bingo.at(7) + bingo.at(8);
  B.at(3) = bingo.at(0) + bingo.at(3) + bingo.at(6);
  B.at(4) = bingo.at(1) + bingo.at(4) + bingo.at(7);
  B.at(5) = bingo.at(2) + bingo.at(5) + bingo.at(8);
  B.at(6) = bingo.at(0) + bingo.at(4) + bingo.at(8);
  B.at(7) = bingo.at(2) + bingo.at(4) + bingo.at(6);
  if(vector_finder(B, 3)==1){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int p=1000000007;
  int64_t a=1,b=1,c=1;
  for(int _=0;_<n;_++){
    a=a*10%p;
    b=b*9%p;
    c=c*8%p;
  }
  cout<<(a-b*2+c+p*2)%p<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
W S(V<W>&p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(4,W(3));c[3]=W(3,1);R(2){for(W x:T[i]){L Q=(2*x[0]+x[1])%3;c[i][Q]^=1;}}R(2){if(c[!i]==c[2]||c[!i]==c[3]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

inline void Qread(int &x){
	char ch;x = 0;
	while(ch = getchar(), ch < '0' || ch > '9');x = ch - 48;
	while(ch = getchar(), ch >= '0' && ch <= '9')x = (x << 1) + (x << 3) + ch - 48;
}

const int maxn = 100010;
int n, sum, A[maxn], flag[maxn];
inline bool Solve1(){
	if(flag[n - 1])return 1;
	for(int i = 1;(i << 1) <= n;++i){
		if(flag[i])return 1;
	}
	return 0;
}
inline bool Solve2(){
	int a = 0, b = 0, sa = 0, sb = 0;
	for(int i = 1;i <= n;++i){
		if(flag[i]){
			if(!sa)a = i, sa = flag[i];
			else b = i, sb = flag[i];
		}
	}
	if(b - a != 1)return 0;
	return b >= sa + 1 && b <= sa + (sb >> 1);
}
int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;++i){
		scanf("%d", &A[i]);
		if(!flag[A[i]])sum ++;
		flag[A[i]]++;
	}
	if(sum == 1 && Solve1())puts("Yes");
	else if(sum == 2 && Solve2())puts("Yes");
	else puts("No");
	return 0;
}

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

int s[4], f[100005][4];
int main() {
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		for (int j=0; j<3; j++) scanf("%d", &s[j]);
		for (int j=0; j<3; j++) 
		for (int k=0; k<3; k++) if (k!=j) f[i][j]=max(f[i][j], f[i-1][k]+s[j]);
	}
	printf("%d\n", max(max(f[n][0], f[n][1]), f[n][2]));
	return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLunlunNumber solver = new DLunlunNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLunlunNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            Deque<Long> h = new ArrayDeque<>();
            if (k < 10) {
                out.println(k);
                return;
            }
            for (long i = 1; i < 10; i++) {
                h.addLast(i);
            }
            int cnt = 9;
            while (true) {
                long x = h.pollFirst();
                long b = x % 10;
                if (b != 0) {
                    h.addLast(x * 10 + b - 1);
                    cnt++;
                    if (cnt == k) break;
                }
                h.addLast(x * 10 + b);
                cnt++;
                if (cnt == k) break;
                if (b != 9) {
                    h.addLast(x * 10 + b + 1);
                    cnt++;
                    if (cnt == k) break;
                }
            }
            out.println(h.peekLast());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

void del(int x, int y);

vector< vector<int> > arr;
int w, h;

int main(){
	
	while(cin >> w >> h, w | h){
		int ans = 0;
		arr.resize(h);
		for(int i = 0; i < h; i++){
			arr[i].resize(w);
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> arr[i][j];
			}
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(arr[i][j] == 1){
					del(i, j);
					ans++;
				}
			}
		}
				
		
		cout << ans << endl;
		arr.clear();
	}
	
	return 0;
	
}

void del(int x, int y){
	arr[x][y] = 0;	
	
	if(x + 1 < h && arr[x + 1][y] == 1){
		del(x + 1, y);
	}
	if(y + 1 < w && arr[x][y + 1] == 1){
		del(x, y + 1);
	}
	if(x - 1 > -1 && arr[x - 1][y] == 1){
		del(x - 1, y);
	}
	if(y - 1 > -1 && arr[x][y - 1] == 1){
		del(x, y - 1);
	}
	if(x + 1 < h && y + 1 < w && arr[x + 1][y + 1] == 1){
		del(x + 1, y + 1);
	}
	if(x - 1 > -1 && y + 1 < w && arr[x - 1][y + 1] == 1){
		del(x - 1, y + 1);
	}
	if(x - 1 > -1 && y - 1 > -1 && arr[x - 1][y - 1] == 1){
		del(x - 1, y - 1);
	}
	if(x + 1 < h && y - 1 > -1 && arr[x + 1][y - 1] == 1){
		del(x + 1, y - 1);
	}
	
	return;
}

Measured memory_bytes: 1472
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;
bitset<55560> primes;
int n;
inline void Oprime()
{
	primes.set();
	primes.reset(0);
	primes.reset(1);
	for(int i=2;i<=int(sqrt(55555));i++)
	{
		if(primes[i])
		{
			for(int j=i+i;j<=55555;j+=i)
			{
				primes.reset(j);
			}
		}
	}
	return ;
}
int main()
{
	Oprime();
	scanf("%d",&n);
	for(int i=11;n>0;i+=10)
	{
		if(primes.test(i))
		{
			n--;
			printf("%d",i),printf(" ");
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++)
        ans+=i%d==0;
    cout<<ans;
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 4; i++)
    if (s[i] == '2')
      ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static long count;
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int q = int.Parse(Console.ReadLine());
        bool first = true;
        bool oneLengthStr = (s.Length == 1) ? true : false;
        int firstInd = 0;
        int queryCount = 0;
        StringBuilder right = new StringBuilder();
        StringBuilder left = new StringBuilder();
        for (int i = 0; i < q; i++)
        {
            string query = Console.ReadLine();
            if(query.Length > 1)
            {
                if(oneLengthStr && first)
                {
                    firstInd = i;
                    first = false;
                }
                string[] queryArr = query.Split(' ');
                int f = int.Parse(queryArr[1]);
                string p = queryArr[2];
                if((i - queryCount + f) % 2 == 0)
                {
                    right.Append(p);
                } else
                {
                    left.Append(p);
                }
                queryCount++;
            }
        }
        s = new string(left.ToString().Reverse().ToArray()) + s + right.ToString();
        if ((q - queryCount - firstInd) % 2 == 1)
        {
            s = new string(s.Reverse().ToArray());
        }
        Console.WriteLine(s);
    }

  

}




Measured memory_bytes: 23348
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    let d:i64 = read();

    println!("{}", min(a,b)+min(c,d));
    
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   double x1,y1,x2,y2,x3,y3;
   for(int i=0;i<n;i++){
      cin>>x1>>y1>>x2>>y2>>x3>>y3;
      double  d1 = x1*x1+y1*y1;
      double  d2 = x2*x2+y2*y2;
      double  d3 = x3*x3+y3*y3;
      double  u = 0.5/(x1*y2-x2*y1+x2*y3-x3*y2+x3*y1-x1*y3);
      double  xp = u*(d1*y2-d2*y1+d2*y3-d3*y2+d3*y1-d1*y3);
      double  yp = u*(x1*d2-x2*d1+x2*d3-x3*d2+x3*d1-x1*d3);
      double  r = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
      printf("%.3f %.3f %.3f\n",xp,yp,r);
   }
   return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int N, sum = 0;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
    sum += L[i];
  }
  sort(L.begin(), L.end());
  if(sum > L[N-1]*2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q,va[200010],ans[200010];
vector <int > my_map[200010];
bool visited[200010];

void dfs(int now,int value)
{
	value+=va[now];
	ans[now]=value;
	int t=my_map[now].size();
	for(int i=0;i<t;++i)
	{
		if(visited[my_map[now][i]])
			continue;
		visited[now]=1;
		dfs(my_map[now][i],value);
	}
}

int main()
{	cin>>n>>q;
	memset(va,0,sizeof(va));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<n;++i)
	{
		int x,y;
		cin>>x>>y;
		my_map[x].push_back(y);
		my_map[y].push_back(x);
	}
	for(int i=1;i<=q;++i)
	{
		int x,y;
		cin>>x>>y;
		va[x]+=y;
	}
	visited[1]=1;
	dfs(1,0);
	for(int i=1;i<=n;++i)
	    cout<<ans[i]<<' ';
	cout<<endl;
	return 0;
}

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

typedef long long ll;

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

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int count[(int)1e5 + 1] = {};
    for(int i=0;i<n; i++){
        int anumber;
        cin >> anumber;

        if(anumber == 0){
            count[0] ++;
            count[1] ++;
        }else{
            count[anumber-1]++;
            count[anumber]++;
            count[anumber+1]++;
        }
    }

    sort(count, count + (int)1e5 + 1, greater<>());

    cout << count[0] << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int dx[]={1,1,-1,-1};
int dy[]={-1,1,1,-1};
int Con(char c){
  if(c=='S')return 3;
  if(c=='E')return 0;
  if(c=='N')return 1;
  if(c=='W')return 2;
}
int x,y,X,Y,n,w,h,l,r,d,cnt,ans=1e7;
char c;
map<P,int>m;
void init(){
  r(i,w+1)m[P(0,i)]=cnt++;
  r(i,h+1)m[P(i,w)]=cnt++;
  r(i,w+1)m[P(h,w-i)]=cnt++;
  r(i,h+1)m[P(h-i,0)]=cnt++;
}
signed main(){
  vector<P>v;
  cin>>n>>w>>h;
  init();
  r(i,n){
    cin>>X>>Y>>c;
    d=Con(c);
    x=X;y=Y;
    while(0<x&&x<w&&0<y&&y<h){
      x+=dx[d];
      y+=dy[d];
    }
    l=m[P(y,x)];
    x=X;y=Y;
    while(0<x&&x<w&&0<y&&y<h){
      x+=dx[(d+1)%4];
      y+=dy[(d+1)%4];
    }
    r=m[P(y,x)];
    v.push_back(P(r,l));
  }
  sort(v.begin(),v.end());
  r(i,n){
    int now=v[i].first,count=1;
    for(int k=0,j=i;k<n;k++,j=(j+1)%n){
      r=v[j].first;
      l=v[j].second;
      if(l>r){
        if(!((l<=now&&now<=cnt)||(0<=now&&now<=r))){
          now=r;
          count++;
        }
      }
      else{
        if(!(l<=now&&now<=r)){
          now=r;
          count++;
        }
      }
    }
    ans=min(ans,count);
  }
  r(i,n)swap(v[i].first,v[i].second);
  r(i,n){
    v[i].first=cnt-v[i].first+1;
    v[i].second=cnt-v[i].second+1;
  }
  sort(v.begin(),v.end());
  r(i,n){
    int now=v[i].first,count=1;
    for(int k=0,j=i;k<n;k++,j=(j+1)%n){
      r=v[j].first;
      l=v[j].second;
      if(l>r){
        if(!((l<=now&&now<=cnt)||(0<=now&&now<=r))){
          now=r;
          count++;
        }
      }
      else{
        if(!(l<=now&&now<=r)){
          now=r;
          count++;
        }
      }
    }
    ans=min(ans,count);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 28124
class DisjointSet:
    def __init__(self, no):
        self.parent = None
        self.rank = 0
        self.size = 1
        self.no = no

    def getRoot(self):
        if self.parent is None:
            return self
        else:
            self.parent = self.parent.getRoot()
            return self.parent

    def getSize(self):
        return self.getRoot().size

    def union(self, x):
        r = self.getRoot()
        xr = x.getRoot()
        if xr.rank > r.rank:
            r.parent = xr
            xr.size += r.size
        elif xr.rank < r.rank:
            xr.parent = r
            r.size += xr.size
        elif xr != r:
            xr.parent = r
            r.rank += 1
            r.size += xr.size

N, M = map(int, input().split())
V = list(map(int, input().split()))
s = []
for i in range(N):
    s.append(DisjointSet(i+1))

for i in range(M):
    u, v = map(int, input().split())
    s[u-1].union(s[v-1])

dic = {}
for i in range(N):
    gid = s[i].getRoot().no
    if gid not in dic:
        A = set()
        B = set()
        dic[gid] = (A, B)
    else:
        A, B = dic[gid]
    A.add(i+1)
    B.add(V[i])
    # print(i+1, gid, V[i])

ans = 0
for key in dic.keys():
    aa = len(dic[key][0] & dic[key][1])
    # print(key, dic[key], aa)
    ans += aa

print(ans)




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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


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

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
    string s;
    cin >> s;
    s[5]=' ', s[13] = ' ';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,q;
    cin>>n>>q;
    vvi G(n);
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    vi v(n);
    REP(i,q){
        int a,b;
        cin>>a>>b;
        a--;
        v[a]+=b;
    }
    vi f(n);
    queue<int> que;
    que.push(0);
    f[0]=true;
    while(que.size()){
        int t=que.front();que.pop();
        REP(i,G[t].size()){
            if(!f[G[t][i]]){
                que.push(G[t][i]);
                v[G[t][i]]+=v[t];
                f[G[t][i]]=true;
            }
        }
    }
    REP(i,n){
        if(i)cout<<" ";cout<<v[i];
    }cout<<endl;
    return 0;
}

Measured memory_bytes: 16372
#include <stdio.h>
int main(){
  int i,j,k,num,change,array[100000];

  scanf("%d",&num);
  for(i=0;i<num;i++) scanf("%d",&array[i]);
  i=-1;
  for(j=0;j<num-1;j++){
    if(array[j]<=array[num-1]){
      i++;
      change=array[i];  /*exchange array[i] array[j]*/
      array[i]=array[j];
      array[j]=change;
    }
  }
  change=array[i+1];   /*exchange array[i+1] array's last num*/
  array[i+1]=array[num-1];
  array[num-1]=change;
  k=i+1;
  for(i=0;i<num;i++){
    if(i>0) printf(" ");
    if(i==k)printf("[");
    printf("%d",array[i]);
    if(i==k)printf("]");
  }
  printf("\n");
  return 0;
}



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

#define ll long long
#define ull unsigned long long

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >

#define pii pair < int, int >
#define pll pair < ll, ll >

#define pb push_back

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

int main()
{
    fast;

    int n;

    cin >> n;

    int a[n + 5], xr = 0;

    for(int i = 0; i < n; i++) cin >> a[i], xr ^= a[i];

    for(int i = 0; i < n; i++) cout << (xr ^ a[i]) << ' ';

    cout << endl;

    return 0;
}




Measured memory_bytes: 4448
'use strict';
(function(stdin) {

  var f = function(a, b, c) {
    if (a < b && b < c){
      return 'Yes';
    }
    return'No';
  };
  var inputs  = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ');
  var a = parseInt(cols[0], 10);
  var b = parseInt(cols[1], 10);
  var c = parseInt(cols[2], 10);

  
  console.log(f(a, b, c));




}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15448
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s,t;
    ll ans=INF;
    cin>>s>>t;
    rep(i,0,sz(s)-1){
        ll st=i;
        ll curr=0;
        if(st+sz(t)-1>=(sz(s))) break;
        rep(j,0,sz(t)-1){
            if(s[i+j]!=t[j]){
                curr++;
            }
        }
        ans=min(ans,curr);
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

int a = 0 , b = 0 ;

int main()
{
	std::cin >> a >> b ;
	if( a == b )
	{
		std::cout << "a == b" <<std::endl ;
	}
	else if( a > b )
	{
		std::cout << "a > b" <<std::endl ;
	}
	else if( a < b)
	{
		std::cout << "a < b" <<std::endl ;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }

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

const int N = 1e5 + 20, M = 2e1 + 2;

int cnt[N];

int32_t main() {

    sync;
    
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; i++) {
        int k; cin >> k;
        while(k--) {
            int x; cin >> x;
            cnt[x]++;
        }
    }

    int ans = 0;
    for(int i = 1; i <= m; i++) if (cnt[i] == n) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	int N;
	cin >> N;
	int now = 0;
	for(int i=0; i<N; i++){
		int a;
		cin >> a;
		now ^= a;
	}
	if(now == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int x,y;
    cin>>x>>y;
    if (y%2==0&&y>=2*x&&y<=4*x)
        cout<<"Yes\n";
    else
        cout<<"No\n";


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3640