akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s.push_back('a');
    char before = s[0];
    int cnt = 0;
    vector<int> v;

    rep(i, n + 1) {
        char c = s[i];
        if (c == before) {
            cnt++;
        } else {
            v.push_back(cnt);
            cnt = 1;
            before = c;
        }
    }
    s.pop_back();
    //
    if (s[0] == '1' && s[n - 1] == '0') reverse(all(v));
    int size = v.size();
    int csum[size + 1];
    csum[0] = 0;
    for (int i = 1; i <= size; ++i) {
        csum [i] = csum[i - 1] + v[i - 1];
    }
    int Max = 0;

    if (s[0] == '0' && s[n - 1] == '0') {
        if (k >= (size + 1) / 2) {
            cout << n << endl;
            return 0;
        }
        for (int l = 1, r = 2 * k + 2; r <= size; l += 2, r += 2) {
            Max = max(Max, csum[r] - csum[l]);
        }
        Max = max(Max, csum[2 * k]);
        Max = max(Max, csum[size] - csum[size - 2 * k]);


    } else if (s[0] != s[n - 1]) {
        if (k >= size / 2) {
            cout << n << endl;
            return 0;
        }
        for (int l = 1, r = 2 * k + 2; r <= size; l += 2, r += 2) {
            Max = max(Max, csum[r] - csum[l]);
        }
        Max = max(Max, csum[2 * k]);
    } else {
        if (k >= (size - 1) / 2) {
            cout << n << endl;
            return 0;
        }
        for (int l = 0, r = 2 * k + 1; r <= size; l += 2, r += 2) {
            Max = max(Max, csum[r] - csum[l]);
        }
    }
    cout << Max << endl;
    return 0;
}



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

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		vector<int> taro(n);
		vector<int> hanako(m);
		int sumTaro = 0;
		int sumHanako = 0;
		for(int i = 0; i < n; ++i)
		{
			cin >> taro[i];
			sumTaro += taro[i];
		}
		for(int i = 0; i < m; ++i)
		{
			cin >> hanako[i];
			sumHanako += hanako[i];
		}
		int diff = sumTaro - sumHanako;
		int min = 999999999;
		int ans[2] = {0, 0};
		bool okFlag = false;
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < m; ++j)
			{
				if((taro[i] - hanako[j] == diff / 2.0) && (taro[i] + hanako[j] < min))
				{
					okFlag = true;
					min = taro[i] + hanako[j];
					ans[0] = taro[i];
					ans[1] = hanako[j];
				}
			}
		}
		if(okFlag)
		{
			cout << ans[0] << " " << ans[1] << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
typedef long long ll;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n, 0);
    for(int i = 0; i < q; i++){
        int x;  cin >> x;
        v[--x]++;
    }
    ll sum = accumulate(v.begin(), v.end(), 0ll);
    for(int i = 0; i < n; i++){
        cout << (sum-v[i] >= k ? "No" : "Yes") << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
S = input()
K = int(input())
cnt = 0
ind_f = 0
ind_b = 0
# 全部同じ
import sys
if len(S) == S.count(S[0]):
    print(len(S) * K // 2)
    sys.exit()
# 先頭と後ろ
if S[0] == S[-1]:
    _ = S[0]
    for i, c in enumerate(S):
        if _ != c:
            ind_f = i
            cnt = i
            break
    for i, c in enumerate(S[::-1]):
        if _ != c:
            ind_b = i
            cnt += i
            break
cnt = (cnt // 2) * (K - 1) # 接続部分
cnt += ind_f // 2 + ind_b // 2
prev = ''
cnt2 = 0
if ind_f > 0:
    S = S[ind_f:-ind_b]
for c in S:
    if prev == c:
        cnt2 += 1
        prev = '0'
    else:
        prev = c
cnt += cnt2 * K    
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

vll dpZ;
vll dpW;

ll searchZ(const vll&, ll);
ll searchW(const vll&, ll);

ll searchW(const vll& a, ll start){
  if(a.size()<=start) return -1;
  if(dpW[start]!=INFLL) return dpW[start];
  ll Z = a[start-1];
  ll count = abs(Z-a[a.size()-1]);
  FOR(pos, start+1, a.size()){
    ll tmp = searchZ(a, pos);
    count = min(count, tmp);
  }
  return dpW[start] = count;
};

ll searchZ(const vll& a, ll start){
  if(a.size()<=start) return INFLL;
  if(dpZ[start]!=-1) return dpZ[start];
  ll W = a[start-1];
  ll count=abs(W-a[a.size()-1]);
  FOR(pos, start+1, a.size()){
    ll tmp = searchW(a, pos);
    count = max(count, tmp);
  }
  return dpZ[start] = count;
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, Z, W;
  cin >> N >> Z >> W;
  vll a(N);
  REP(i, N) cin >> a[i];
  a.insert(a.begin(), W);
  a.insert(a.begin(), Z);

  dpZ.resize(N+2, -1);
  dpW.resize(N+2, INFLL);

  searchZ(a, 2);

  cout << dpZ[2] << "\n";

  return 0;
}

Measured memory_bytes: 384
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (input) {
    var num = input.split(' ');
    //??????????????°??????????????????
    var a = parseInt(num[0]);
    var b = parseInt(num[1]);
    var c = parseInt(num[2])
    if ((a < b) & (b < c)) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }
});

Measured memory_bytes: 15640
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

w,h,n = rli()
xl = 0
xh = w
yl = 0
yh = h
for i in range(n):
    x,y,a = rli()
    if(a == 1):
        xl = max(xl, x)
    elif(a == 2):
        xh = min(xh, x)
    elif(a == 3):
        yl = max(yl, y)
    else:
        yh = min(yh, y)
if(xh < xl or yh < yl):
    print(0)
else:
    print((xh-xl)*(yh-yl))


Measured memory_bytes: 3064
from collections import deque
import heapq
import itertools
import math

k,n=map(int,input().split())
a=list(map(int,input().split()))
sum=0
max_root=0
tmp = k-(a[-1]-a[0])
max_root=tmp
sum+=tmp
for i in range(len(a)-1):
    tmp = a[i+1]-a[i]
    if tmp > max_root:
        max_root=tmp
    sum+=tmp

print(k-max_root)


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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;

  if (a >= k) {
    a -= k;
    k = 0;
  } else {
    k -= a;
    a = 0;
  }
  if (b >= k) {
    b -= k;
    k = 0;
  } else {
    k -= b;
    b = 0;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double min = Double.MAX_VALUE;
		double max = Double.MIN_VALUE;
		while(sc.hasNext()){
			double db = sc.nextDouble();
			min = Math.min(min, db);
			max = Math.max(max, db);
		}
		System.out.println(max-min);
		sc.close();
	}
}

Measured memory_bytes: 18620
n = int(input())
plist = list(map(int, input().split()))

c = 0
for a in range(n-2) :
    if plist[a] < plist[a+1] < plist[a+2] :
        c+=1
    elif plist[a] > plist[a+1] > plist[a+2] :
        c+=1
print(c)

Measured memory_bytes: 2940
using System;
internal class Program
{
    private static void Main(string[] args)
    {
        string text = Console.ReadLine();
        char[] obj = new char[1];
        obj[0] = ' ';
        string[] array = text.Split(obj);
        int num = int.Parse(array[0]);
        int num2 = int.Parse(array[1]);
        int num3 = int.Parse(array[2]);
        int[] array2 = new int[num];
        for (int i = 0; i < num; i++)
        {
            array2[i] = num2 - num3;
        }
        for (int j = 0; j < num3; j++)
        {
            int num4 = int.Parse(Console.ReadLine()) - 1;
            array2[num4]++;
        }
        for (int k = 0; k < num; k++)
        {
            Console.WriteLine((array2[k] <= 0) ? "No" : "Yes");
        }
    }
}

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

using namespace std;

bool goodDis(vector<int>& a, vector<int>& b){
	
	double x = 0 ;
	for(int i = 0; i<(int)a.size(); i++){
		x+= (a[i]-b[i])*(a[i]-b[i]);
		}
	double p = static_cast<double>(sqrt(x));
	double q = static_cast<double>(floor(p));
	if(p - q==0) return true;
	else return false; 	
	
	}

int main(){
	int n, d;
	cin>>n>>d;
	vector<vector<int>>a;
	for(int i = 0; i<n; i++){
		a.push_back(vector<int>(d));
		for(int j = 0; j<d ; j++){
			cin>>a[i][j];
			}
		}
	int count = 0;	
	for(int i = 0; i<n ;i++){
		for(int j = i+1; j<n; j++){
			if(goodDis(a[i],a[j])) count++;
			}
		}
		cout<<count;
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int i=0;
    while(i<3)
    {
        if(str[i]=='7')
        {
            break;
        }
        i++;
    }  
    if(i==3)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    



    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Inf 0x3f3f3f3f
int main()
{
    ll x;
    cin>>x;
    double money=100;
    ll i=0;
    while(money<x)
    {
        money=floor(money+money*0.01);
        i++;
    }
    cout<<i<<endl;

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	int n,m;
	cin>>n>>m;
	int sum=0;
	for(int i=0;i<m;i++){
		int tmp;
		cin>>tmp;
		sum+=tmp;
	} 
	if(n-sum>=0){
		cout<<n-sum<<endl;
	}else{
		cout<<-1<<endl;
	}
 	return 0;
}







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

class _Class
{
	void _()
	{

		var S = _Ss()[0];

		int c = 0;
		string a = "CODEFESTIVAL2016";
		for (int i = 0; i < S.Length; i++)
			if (S[i] !=a[i])
				c++;
		Console.WriteLine(c);
			
		

	}

	static void Main(string[] args)
  {
    new _Class()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}


Measured memory_bytes: 2648
s = input()
ans = 0
cnt = 0
tmp = 0
pre = '>'
last = '>' if s[-1]=='<' else '<'
for now in s+last:
    if pre==now:
        cnt += 1
    else:
        if now=='<':
            ans += max(cnt, tmp)
            tmp = 0
        else:
            tmp = cnt
        ans += cnt*(cnt-1)//2
        cnt = 1
    pre = now
ans += tmp
print(ans)

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

const int N = 1e5 + 5;

int arr[N];

int main(){
  int n, m;
  map<int, int> mp;
  map<int, int> cnt;
  cin >> n >> m;
  int ac = 0, wa = 0;
  for(int i = 0; i < m; i++){
      int x;
      cin >> x;
      string s;
      cin >> s;
      if(s == "AC"){
          if(mp.find(x) == mp.end()){
              mp[x] = 1;
              ac += 1;
              wa += cnt[x];
          }
      }
      else {
          if(mp.find(x) == mp.end()){
              cnt[x] += 1;
          }
      }
  }
  cout << ac << " " << wa;
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

typedef long long ll;

int n;
int a[101010];

#define N (1<<18)
#define Z (1<<17)
int p[2*N];

void add(int k, int x) {
    k += N;
    p[k] += x;
    for (k /= 2; k >= 1; k /= 2) p[k] = p[2*k]+p[2*k+1];
}

int sum(int a, int b) {
    a += N; b += N;
    int s = 0;
    while (a <= b) {
        if (a%2 == 1) s += p[a++];
        if (b%2 == 0) s += p[b--];
        a /= 2; b /= 2;
    }
    return s;
}

ll calc(ll x) {
    for (int i = 0; i < 2*N; i++) p[i] = 0;
    add(Z+0,1);
    int c = 0;
    ll u = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] <= x) c++;
        else c--;
        u += sum(0,Z+c-1);
        add(Z+c,1);
    }
    return u;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll s = (ll)n*(n+1)/2;
    s = s/2+1;
    int k = 0;
    for (int b = 1e9; b >= 1; b /= 2) {
        while (calc(k+b) < s) k += b;
    }
    cout << k+1 << "\n";
}


Measured memory_bytes: 2688
n, h = gets.split.map(&:to_i)
as = []
bs = []
n.times do |i|
  as[i], bs[i] = gets.split.map(&:to_i)
end

a_max = as.max

bs.reject! { |b| b < a_max }
bs.sort!.reverse!

ans = 0
bs.each do |b|
  h -= b
  ans += 1
  if h <= 0
    puts ans
    exit
  end
end

ans += (h.to_f/a_max).ceil
puts ans


Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(int p)
{
    int i=0;
    for(int j=0;j<k;++j)
    {
        llong s=0;
        while(s+T[i]<=p)
        {
            s+=T[i];
            i++;
            if(i==n)return n;
        }
    }
    return i;
}

int solve()
{
    llong left=0;
    llong right=100000*10000;
    llong mid;
    while(right-left>1)
    {
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n)right=mid;
        else left=mid;
    }
    return right;
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;++i)
    {
        cin>>T[i];
    }
    llong ans=solve();
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
      cout<<s.substr(0,k)+"..."<<endl;
  }
}

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

struct UnionFind{
	vector<int> par,gsize;
	int sz;
	
	UnionFind(int N) : par(N) ,gsize(N), sz(N) {
		for(int i=0;i<N;i++) {
			par[i]=i;
			gsize[i]=1;
		}
	}
	
    //root:子xの根を返す
	int root(int x){
		if(par[x]==x) return x;
		else{
			return par[x]=root(par[x]); 
		}
	}
	
    //unite:要素xとyを結ぶ
	void unite(int x,int y){
		int rx=root(x);
		int ry=root(y);
		if(rx==ry) return;
		else {
			if(gsi(rx)>gsi(ry))swap(rx,ry);
			par[ry]=rx; sz--; 
			gsize[rx]+=gsize[ry];
		}
	}
	
    //same:要素xとyの親が同じか判定する
	bool same(int x,int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}
	
    //size:全体のグループの数を返す
	int size() { return sz; }

	//gsize:要素xが属するグループの大きさを返す
	int gsi(int x) {return gsize[root(x)]; }
};

int main(){
    ll N,M; cin>>N>>M;
    UnionFind G(N);
    ll a,b,ans=1LL; 
    for(ll i=0;i<M;i++){
        cin>>a>>b; a--; b--;
        G.unite(a,b);
        ans=max(int(ans),G.gsi(a));
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4824
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N,K;

int Main() {
    cin >> N >> K;
    set<ll> values;
    rep(i, K) {
        ll d;
        cin >> d;
        rep (j, d) {
            ll hoge;
            cin >> hoge;
            values.insert(hoge);
        }
    }

    cout << N-values.size() << endl;

    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3656
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#define ll long long 
#define d double
using namespace std;

int main()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    size_t n=s.size();
    n=n-1;
    int l=0;
    while(n>l)
    {
    	if(s[l++]!=s[n--])
    	{
    		cout<<"No"<<endl;
    		return 0;
    		
		}
    	
	}
	
	n=s.size();
	int n1=((n-1)/2);
	n1=n1-1;
	int l1=0;
	while(n1>l1)
	{
    	if(s[l1++]!=s[n1--])
    	{
    		cout<<"No"<<endl;
    		return 0;
    		
		}
		
	}
    
    n=s.size();
    int l2=((n+3)/2);
    l2=l2-1;
    size_t n3=s.size();
    n3=n3-1;
    while(n3>l2)
    {
    	if(s[l2++]!=s[n3--])
    	{
    		cout<<"No"<<endl;
    		return 0;
    		
		}
    	
	}
		
 
    cout<<"Yes"<<endl;
    
    
    return 0;   
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

C = [-1] * N


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


dfs(0, 0)
for c in C:
    print(c)


Measured memory_bytes: 79408
N = int(input())
#num = [1]
#print("a")
"""
#memo = [[ -1 for i in range(12)]for j in range(100000)]
n = 6
while True:
    num.append(n)
    n *= 6
    if n > 100000:
        break
n = 9
while True:
    num.append(n)
    n *= 9
    if n > 100000:
        break
num.sort()

ans = 0
print(num)
#while N > 6:

def DP(n , index):
    if index == 0:
        return  n
    elif n == 0:
        return 0
    min_ = 10000000
    if n < num[index]:
        #print(n,num[index])
        return DP(n,index - 1)
    can = num[index]
    #print(index)
#    print(n//can)
    for i in range(n // can+1):
        min_ = min(min_ , DP(n - i * can,index - 1) + i)
 #       print(i,n,index,DP(n - i*can,index-1))
    
     #   print(min_)
    #print(min_)
    memo[n][index] = min_
    return min_
    
print(DP(N,11))
"""

def ninep(N):
    if N <9:
        return N
    ans = 0
    while N > 0:
        ans += N % 9
        N =N // 9
    return ans


def sixp(N):
    if N <6:
        return N
    ans = 0
    while N > 0:
        ans += N % 6
        N = N // 6
    return ans


ans = 1000000
for i in range(N+1):
    ans = min(ans,ninep(i) + sixp(N - i))
#    print(ninep(i), sixp(N - i),i)

print(ans)


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(cs: String);
    match cs.as_ref() {
        "SUN" => println!('7'),
        "MON" => println!('6'),
        "TUE" => println!('5'),
        "WED" => println!('4'),
        "THU" => println!('3'),
        "FRI" => println!('2'),
        "SAT" => println!('1'),
        _ => println!('e'),
    }
}


Measured memory_bytes: 4352
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

bounds x y 1 = [(a,b) | a <- [0..9], b <- [0..9], abs (x-a) + abs (y-b) <= 1]
bounds x y 2 = [(a,b) | a <- [0..9], b <- [0..9], max (abs (x-a)) (abs (y-b)) <= 1]
bounds x y 3 = [(a,b) | a <- [0..9], b <- [0..9], abs (x-a) + abs (y-b) <= 2]

main = do
    arr <- newArray ((0,0),(9,9)) 0 :: IO (IOUArray (Int,Int) Int)
    map (map readInt . wordsBy (==',')) . lines <$> getContents >>= mapM_ (\[x,y,s] -> forM (bounds x y s) (\p -> (+1) <$> readArray arr p >>= writeArray arr p))
    vl <- map snd <$> getAssocs arr
    print $ length $ filter (==0) vl
    print $ maximum vl

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

int main() {
  int A;
  cin >> A;
  if(A == 4 || A == 6 || A == 9 || A == 10 || A == 14 || A == 21|| A == 22 || A == 25 || A == 26) {
    cout<<"2"<<endl;
  }
  else if(A == 8 || A == 12 || A == 18 || A == 20 || A ==27) {
    cout<<"5"<<endl;
  }
  else if (A == 16) {
    cout<<"14"<<endl;
  }
  else if(A == 24) {
    cout<<"15"<<endl;
    
  }
  else if(A==32) {
  
  cout << "51" << endl;
  }
  else if(A == 30 || A == 28) {
    cout<<"4"<<endl;
  }
  else {
    cout<<"1"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    char ch;
    int n, x, i, j;
    int all[4][13];
    for (i=0;i<4;i++) {
        for (j=0;j<13;j++) {
            all[i][j] = 0;
        }
    }
    cin >> n;
    for (i=0;i<n;i++) {
        cin >> ch >> x;
        if (ch=='S') {
            all[0][x-1] = 1;
        } else if (ch=='H') {
            all[1][x-1] = 1;
        } else if (ch=='C') {
            all[2][x-1] = 1;
        } else if (ch=='D') {
            all[3][x-1] = 1;
        } 
    }
    for (i=0;i<4;i++) {
        for (j=0;j<13;j++) {
            if (all[i][j] == 0) {
                if (i==0) {
                    cout << "S " << j+1 << endl;
                } else if (i==1) {
                    cout << "H " << j+1 << endl;
                } else if (i==2) {
                    cout << "C " << j+1 << endl;
                } else if (i==3) {
                    cout << "D " << j+1 << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
a, b, c = (int(i) for i in input().split())

if a > c:
    a = a - c
    print(a, b)
elif a <= c:
    c = c - a
    a = 0
    if b > c:
        b = b - c
        print(a, b)
    else:
        print(0, 0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	reverse(s.begin(), s.end());
	int M = 2019;
	int pre[n+1];
	int cur = 1;
	pre[0] = 0;
	for(int i=1; i<=n; i++)
	{
		pre[i] = (pre[i-1] + cur*(s[i-1]-'0'))%M;
		cur = (cur*10)%M;
		
	}
	sort(pre, pre+n+1);
	ll answer = 0;
	//for(int i=0; i<=n; i++)
		//cout<<pre[i]<<" ";
	//cout<<endl;
	for(int i=0; i<=n;)
	{
		int temp = pre[i];
		ll count = 0;
		while(i<=n && pre[i] == temp)
		{
			count ++;
			i++;
		}
		answer += count*(count-1)/2;
	}
	cout<<answer<<nl;
	return 0;
}


Measured memory_bytes: 4572
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e3+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int a[N] , dp[N][N];

int sum(int l ,int r ) 
{
	int now = 0;	
	for( ; l <= r; l++ ) now += a[l];
	return now;
}

int makeAns( int i = 1, int j = n)
{
	if( i >= j ) return 0;

	int& ans = dp[i][j];
	if( ~ans ) return ans;

	ans = INF;

	fo(k,i,j)
	{
		int now = sum(i,k) + sum(k+1,j);
		ans = min( ans , now + makeAns(i,k) + makeAns(k+1,j) );
	}

	return ans;
}

void go()
{
	cin >> n;

	fo(i,1,n+1) cin >> a[i];

	memset( dp ,-1 , sizeof dp );
	int ans = makeAns();

	cout << ans << endl;


}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 31744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;

		for (int i = 0; i < M; i++) {
			max = Math.max(max, sc.nextInt());
			min = Math.min(min, sc.nextInt());
		}

		if (min < max) {
			System.out.println(0);
		} else {
			System.out.println(min - max + 1);
		}

	}
}


Measured memory_bytes: 63312
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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")
}

fn main() {
    let n: usize = read();
    let a: usize = read();
    let b: usize = read();
    println!("{}", std::cmp::min(n * a, b));
}


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

const int MAX = 10; // H
int main() {
	int H, W;
	string A[MAX];
	cin >> H >> W;
	for (int i = 0;i <= W + 1;++ i) {
		A[0] += '.';
		A[H + 1] += '.';
	}
	for (int i = 1;i <= H;++ i) {
		cin >> A[i];
		A[i] = '.' + A[i] + '.';
	}
	A[0][1] = A[H][W + 1] = '#';
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			if (A[i - 1][j] + A[i][j - 1] < '.' + '#' || A[i + 1][j] + A[i][j + 1] < '.' + '#') { // あり得ない移動
				cout << "Impossible";
				return 0;
			}
		}
	}
	cout << "Possible";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

この方法で移動したとき、左上と右下を除く任意のマスについて自分より左か上のどちらかと右か下のどちらかに#があり、もう片方に.があるはず
また、左上と右下は隣接2マス中どちらかに#があり、もう片方に.がある
これを判定すれば良い
*/

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    static int mod = 1000000007;

    static long power(int m , int n){
        if(n == 1){
            return m;
        }else if(n % 2 == 0){
            long s = power(m, n/2);
            return ( (s % mod) * (s % mod) ) % mod;
        }else{
            return ( (m % mod) * (power(m, n-1) % mod) ) % mod;
        }
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");

        int m = Integer.parseInt(input[0]);
        int n = Integer.parseInt(input[1]);

        System.out.println(power(m,n));
    }
}


Measured memory_bytes: 24452
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int n;
int h[MAX_N];

int L[MAX_N], R[MAX_N];
int st[MAX_N];

long long calc(){
    // Lの計算
    int t = 0;
    for(int i = 0; i < n; i++){
        while(t > 0 && h[st[t-1]] >= h[i]) t--;
        L[i] = t == 0 ? 0 : (st[t-1] + 1);
        st[t++] = i;
    }

    // Rの計算
    t = 0;
    for(int i = n - 1; i >= 0; i--){
        while(t > 0 && h[st[t-1]] >= h[i]) t--;
        R[i] = t == 0 ? n : st[t-1];
        st[t++] = i;
    }

    long long res = 0;
    for(int i = 0; i < n; i++){
        res = max(res, (long long)h[i] * (R[i] - L[i]));
    }
    return res;
}

int main() {
    cin >> n;
    rep(i,n)cin >> h[i];
    ll ans = calc();
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 4660
from collections import Counter
from collections import deque
n, k = map(int, input().split())
a = Counter(list(map(int, input().split())))
a = [tuple(i) for i in a.items()]
a.sort(key=lambda x: x[1])
a = deque(a)
ans = 0
while k<len(a):
    ans += a.popleft()[1]
print(ans)

Measured memory_bytes: 39784
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn to_vec(s: String, offset: u64) -> Vec<u64> {
    s.split_whitespace()
        .map(|s| s.parse::<u64>().unwrap() - offset)
        .collect()
}

fn main() {
    read_line();
    let dishes = to_vec(read_line(), 1);
    let bs = to_vec(read_line(), 0);
    let cs = to_vec(read_line(), 0);

    let cps: u64 = dishes
        .windows(2)
        .filter(|w| w[0] + 1 == w[1])
        .map(|w| cs[w[0] as usize])
        .sum();
    let bps: u64 = dishes.into_iter().map(|a| bs[a as usize]).sum();

    println!("{}", cps + bps);
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll t[2],a[2],b[2];
  rep(i,2)cin >> t[i];
  rep(i,2)cin >> a[i];
  rep(i,2)cin >> b[i];
  if(a[0]*t[0]+a[1]*t[1] == b[0]*t[0]+b[1]*t[1]){
    cout << "infinity" << endl;
    return 0;
  }
  if(a[0]*t[0]+a[1]*t[1] < b[0]*t[0]+b[1]*t[1])rep(i,2)swap(a[i],b[i]);
  if(a[0] <= b[0] && a[1] >= b[1]){
    ll one = abs(t[0]*(-b[0]+a[0])+t[1]*(a[1]-b[1]));
    __int128_t left = -1,right = 1e18;
    while(right-left > 1){
      __int128_t mid = (right+left)/2;
      if(one*mid < t[0]*(b[0]-a[0]))left = mid;
      else right = mid;
    }
    ll l = left,r = right;
    if(one*r == t[0]*(b[0]-a[0]))cout << r*2 << endl;
    else cout << l*2+1 << endl;
  }else{
    cout << 0 << endl;
  }





  


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
pair<long long,long long> job[200100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>job[i].second>>job[i].first;
	sort(job+1,job+n+1);
	long long cur=0;
	for(int i=1;i<=n;i++){
		cur+=job[i].second;
		if(cur>job[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class COtoshidama {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int tot = in.nextInt();
            int yukichi = -1;
            int higuchi = -1;
            int noguchi = -1;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n - i; j++) {
                    if (i * 10000 + j * 5000 + (n - i - j) * 1000 == tot) {
                        yukichi = i;
                        higuchi = j;
                        noguchi = n - i - j;
                        break;
                    }
                }
            }
            out.println(yukichi + " " + higuchi + " " + noguchi);
        }

    }
}



Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	int ans=700;
	
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')
			ans+=100;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;    
 int main()
{
    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a)
        cout << k;
    else if(k<=(a+b))
        cout << a;
    else
        cout << a-(k-(a+b));
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int x, y;
	cin >> x >> y;
	int a = 0;
	int xi = x;
	while (xi) {
		if (2 * xi + a == y) {
			cout << "Yes" << endl;
			return;
		}
		xi--;
		a += 4;
	}
	xi = x;
	a = 0;
	while (xi) {
		if (4 * xi + a == y) {
			cout << "Yes" << endl;
			return ;
		}
		xi--;
		a += 2;
	}
	cout << "No" << endl;
}

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

	solve();
}


Measured memory_bytes: 3648
def main():
    N = int( input() )
    A = [int(i) for i in input().split()]
    
    b_flag = False
    n_div = 0
    while True:
        for a in A:
#            print(a % 2)
            if(a % 2 != 0):
                b_flag = True
            
        if(b_flag):
            break
        else:
            A = [i / 2 for i in A]
            n_div += 1
    print(n_div)
    
    
if __name__=="__main__":
    main()

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll COM(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 gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int x[N];
    int y[N];
    int h[N];
    REP(i,N){
        cin>>x[i]>>y[i]>>h[i];
    }
    REP(i,101){
        REP(j,101){
            int H;H=0;
            REP(k,N){
                if(h[k]>0&&H==0){
                    H=h[k]+abs(x[k]-i)+abs(y[k]-j);
                    break;
                }
            }
            REP(k,N){
                if(h[k]!=max(0,H-abs(x[k]-i)-abs(y[k]-j))){
                    break;
                }
                if(k==N-1){
                    cout<<i<<" "<<j<<" "<<H<<endl;
                }
            }

        }
    }
    return 0;
}


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

int main() {
  int a,b,c,x;
  cin >> a >> b;
  c = (a+b) % 2;
  if(c == 0) 
    cout << (a+b) / 2 << endl;
  else
    cout << (a+b) / 2 + 1 << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n,pos=1ll,sumv=0;
int a[300005],dp[300005][65],ans[65];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	for (int i=1;i<=n;i++)
	{
		int k=a[i],pos=0;
		while (k!=0)  dp[i][++pos]=k%2,k/=2;
	}
	for (int i=1;i<=60;i++)
	{
		int zero=0,one=0;
		for (int j=1;j<=n;j++)
		{
			if (dp[j][i]==1)  one++;
			else zero++;
		}
		ans[i]=(one*zero)%mod;
	}
	for (int i=1;i<=60;i++)
	{
		sumv=(sumv+ans[i]*pos)%mod;
		pos=(pos*2ll)%mod;
	}
	cout<<sumv<<endl;
	
	return 0;
}

Measured memory_bytes: 154880
// JAI SHREE RAM
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{


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

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll c = 1000000007;
    ll x; cin>>x;
    ll a=1, b=1, d=1;
    rep(i,x){
        a *= 10;
        b *= 8;
        d *= 9;
        if(a%c == 0) a=c;
        else a = a%c;
        if(b%c == 0) b=c;
        else b = b%c;
        if(d%c == 0) d=c;
        else d = d%c;
    }
    //cout << a<< b<< d<<endl;
    while(a-2*d+b<0) a+=c;
    cout << a-2*d+b << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int n, nb=0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
    cin >> a[i];
  a[0]--;
  for(int i = 1; i < n; i++)
  {
      if(a[i] < a[i-1])
      {
          cout << "No\n";
          return 0;
      }
      if(a[i] > a[i-1])
        a[i]--;
  }
  cout << "Yes\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    string S; cin >> S;
    if(S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    map<char, int> mp;
    int N = S.size();
    for(int i = 0; i < S.size(); i++) {
        mp[S[i]] ++;
    }
    if(N != 26) {
        rep(i, 26) {
            if(mp['a' + i] == 0) {
                S += ('a' + i);
                break;
            }
        }
        cout << S << endl;
        return 0;
    } else {
        set<char> s;
        per(i, N) {
            if(S[i] < S[i - 1]) {
                s.insert(S[i]);
            } else {
                s.insert(S[i]);
                string t;
                rep(k, i - 1) {
                    t += S[k];
                }
                rep(k, 26) {
                    char a = 'a' + k;
                    if(a > S[i - 1] && s.find(a) != s.end()) {
                        t += a;
                        break;
                    }
                }
                cout << t << endl;
                return 0;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll power(ll a, int b) {
  if(!b) return 1;
  ll c = power(a, b/2);
  if(b%2) return c*c%INF*a%INF;
  return c*c%INF;
}

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  
  vl fac(N*M+1);
  fac[0]=1;
  rep(i,N*M) fac[i+1]=fac[i]*(i+1)%INF;
  
  ll ans=0;
  rep(i,N) {
    rep(j,M) {
      if(i==0&&j==0) continue;
      if(i==0) ans+=(ll)N*(M-j)*j%INF*fac[N*M-2]%INF*power(fac[K-2]*fac[N*M-K]%INF,INF-2)%INF;
      else if(j==0) ans+=(ll)M*(N-i)*i%INF*fac[N*M-2]%INF*power(fac[K-2]*fac[N*M-K]%INF,INF-2)%INF;
      else ans+=(ll)(N-i)*(M-j)*2*(i+j)%INF*fac[N*M-2]%INF*power(fac[K-2]*fac[N*M-K]%INF,INF-2)%INF;
      ans%=INF;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4816
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n  = int(input())

def pcheck(num):
  # 1, num is divisor
  nd=1
  if num>1:
    nd=2
  for i in range(2,num):
    if num%i==0:
      nd=nd+1
  return nd==8

res=0
for i in range(1,n+1):
  if i%2==0:
    continue
  if pcheck(i):
    res=res+1
print(res)
  
  


Measured memory_bytes: 2940