akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

VV<ll> edges;

pair<ll, bool> dfs(ll now, V<ll> &depth, ll d) {
    PLL ret(1, true);
    depth[now] = d;
    for(ll nxt : edges[now]) {
        if(depth[nxt] != -1) {
            ll d1 = depth[nxt];
            ll d2 = depth[now];
            if((d1 % 2) == (d2 % 2)) ret.second = false;
        } else {
            auto tmp = dfs(nxt, depth, d + 1);
            ll t1;
            bool t2;
            tie(t1, t2) = tmp;
            ret.first += t1;
            ret.second &= t2;
        }
    }
    return ret;
}

int main() {
    ll N, M;
    cin >> N >> M;

    edges.resize(N);
    for(ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    V<ll> depth(N, -1);
    V<pair<ll, bool>> subg;
    ll tcnt = 0, lcnt = 0, ocnt = 0;
    for(ll i = 0; i < N; i++) {
        if(depth[i] != -1) continue;
        auto ret = dfs(i, depth, 0);
        ll s;
        bool tree;
        tie(s, tree) = ret;
        if(s == 1) {
            ocnt++;
        } else {
            subg.emplace_back(s, tree);
            (tree ? tcnt : lcnt)++;
        }
    }

    ll ans = 0;
    for(const auto &ele : subg) {
        ll n;
        bool t;
        tie(n, t) = ele;
        ans += tcnt + lcnt;
        ans += (ll)(t) * tcnt;
        ans += n * ocnt;
    }

    DEBUG(ans);

    ans += N * ocnt;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <string>

using namespace std; 

int main(int argc, char* argv[])
{
    string s1, s2; cin >> s1 >> s2;

    bool ans = true;
    auto it = s1.begin();
    auto rit = s2.rbegin();
    while(it != s1.end()) {
        if (*it != *rit) {
            ans = false;
            break;
        }
	it++; rit++;
    }

    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


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

int main(int argc, char **argv)
{
  int input_sec;
  scanf("%d",&input_sec);

  int hh,mm,ss;
  hh = (int)(input_sec/3600);
  mm = (int)((input_sec-hh*3600)/60);
  ss = input_sec - hh*3600 - mm*60;

  printf("%d:%d:%d\n",hh,mm,ss);

  return EXIT_SUCCESS;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll x1=0;
    while (true)
    {
        ll xd=pow(k,x1);
        if (n/xd==0)
        {
            cout<<x1<<"\n";
            return 0;
        }
        x1++;
    }
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n; i++) {
        int now_station = i;
        long long now_time = 0;

        while (now_station < n - 1) {
            if (now_time < s[now_station])
                now_time = s[now_station] + c[now_station];
            else {
                int res = now_time % f[now_station];
                now_time = (now_time / f[now_station]) * f[now_station];
                if (res)
                    now_time += f[now_station];
                now_time += c[now_station];
            }
            now_station++;
        }
        cout << now_time << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		// 範囲内の偶数、奇数の総数を求める
		int maxEven = k / 2;
		int maxOdd = k / 2;
		if (k % 2 != 0) {
			// kが奇数の場合は、奇数の最大値に1加算
			maxOdd++;
		}

		// 組み合わせを求める
		// 全体の組み合わせ
		long totalCombi = calcCombination(k, 2);
		// 偶数のみの組み合わせ(偶数の個数が1以下の場合は組み合わせ不可のため0)
		long evenCombi = 0;
		if (maxEven > 1) {
			evenCombi = calcCombination(maxEven, 2);
		}
		// 奇数のみの組み合わせ(奇数の個数が1以下の場合は組み合わせ不可のため0)
		long oddCombi = 0;
		if (maxOdd > 1) {
			oddCombi = calcCombination(maxOdd, 2);
		}

		System.out.println(totalCombi - evenCombi - oddCombi);

		sc.close();
	}

	static long calcCombination(int n, int r) {
		long sum = 1;
		for (int i = 1; i <= r; i++) {
			sum = sum * (n - i + 1) / i;
		}
		return sum;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

void solve(ll in){
	ll n;
	cin >> n;
	vp64 pos,neg;
	ll sum = 0;
	forn(i,n){
		ll t1;
		cin >> t1;
		if(t1>=0) pos.pb(mp(t1,i));
		else neg.pb(mp(-1*t1,i));
		sum += abs(t1);
	}
	if((ll)pos.size() && (ll)neg.size()){
		cout << sum << ln;
		ll in1 = 1;
		ll in2=1;
		ll num1 = -1*neg[0].fi;
		while(in1<(ll)pos.size()){
			cout << num1 << " " << pos[in1].fi << ln;
			num1 -= pos[in1].fi;
			in1++;
		}
		ll num2 = pos[0].fi;
		while(in2<(ll)neg.size()){
			cout << num2 << " " << -1*neg[in2].fi << ln;
			num2 += neg[in2].fi;
			in2++;
		}
		cout << num2 << " " << num1 << ln;
	}
	else if((ll)pos.size()){
		sort(pos.begin(),pos.end());
		cout << sum-2*pos[0].fi << ln;
		ll in1 = 1;
		ll num2 = pos[0].fi;
		while(in1+1<(ll)pos.size()){
			cout << num2 << " " << pos[in1].fi << ln;
			num2 -= pos[in1].fi;
			in1++;
		}
		cout << pos[in1].fi << " " << num2 << ln;
	}
	else{
		sort(neg.begin(),neg.end());
		cout << sum-2*neg[0].fi << ln;
		ll in1 = 1;
		ll num1 = -1*neg[0].fi;
		while(in1+1<(ll)neg.size()){
			cout << num1 << " " << -1*neg[in1].fi << ln;
			num1 += neg[in1].fi;
			in1++;
		}
		cout << num1 << " " << -1*neg[in1].fi << ln;
	}
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve(i+1);
    }
    return 0;
}

Measured memory_bytes: 3952
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
map<int,int> m;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++){
			int dist=j-i;
			dist=min(abs(i-x)+abs(j-y)+1,dist);
			dist=min(abs(i-y)+abs(j-x)+1,dist);
			m[dist]++;
		}
	for(int i=1;i<n;i++)
		cout<<m[i]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <deque>
#include <iostream>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f

using namespace std;

const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int h, w, sx, sy, ex, ey;

int main() {
  cin >> h >> w >> sx >> sy >> ex >> ey;
  sx--, sy--, ex--, ey--;
  vector<string> a(h);
  for (int i = 0; i < h; ++i)
    cin >> a[i];
  vector<vector<int>> dist(h, vector<int>(w, INF));
  vector<vector<bool>> vis(h, vector<bool>(w, false));
  deque<pair<int, int>> q;
  q.push_back({sx, sy});
  dist[sx][sy] = 0;
  while (!q.empty()) {
    auto f = q.front();
    q.pop_front();
    int ci = f.first, cj = f.second;
    if (ci == ex && cj == ey) {
      cout << dist[ci][cj];
      return 0;
    }
    if (vis[ci][cj])
      continue;
    vis[ci][cj] = true;
    for (int k = 0; k < 4; ++k) {
      int ni = ci + dy[k], nj = cj + dx[k];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w ||
          dist[ni][nj] <= dist[ci][cj] || a[ni][nj] == '#')
        continue;
      dist[ni][nj] = dist[ci][cj];
      q.push_front({ni, nj});
    }
    for (int ni = ci - 2; ni <= ci + 2; ++ni)
      for (int nj = cj - 2; nj <= cj + 2; ++nj) {
        if (ni < 0 || ni >= h || nj < 0 || nj >= w || a[ni][nj] == '#' ||
            dist[ni][nj] <= dist[ci][cj] + 1)
          continue;
        dist[ni][nj] = dist[ci][cj] + 1;
        q.push_back({ni, nj});
      }
  }
  cout << -1;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cerr << x << " ";} cerr << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cerr << x << " ";}cerr << endl;}
#define printP(p) cerr << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

ll powmod (ll a, ll p) {
	ll ans = 1ll;
	ll mul = a;
	for (; p > 0ll; p >>= 1ll, mul = (mul * mul) % mod) {
		if ((p & 1ll) == 1ll) ans = (ans * mul) % mod;
	}
	return ans;
}

const int MAX_N = 500000;
ll fact[MAX_N];
ll revFact[MAX_N];
// !!!!!!!!SET FACT!!!!!!!
void setFact(int N) {
	fact[0] = 1ll;
	for (int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	revFact[N - 1] = powmod(fact[N - 1], mod - 2);
	for (int i = N - 2; i >= 0; i--) {
		revFact[i] = revFact[i + 1] * (i + 1);
		revFact[i] %= mod;
	}
}

ll getC(int a, int b) {
	return (((fact[a] * revFact[b]) % mod) * revFact[a - b]) % mod;
}

int H, W;
int A, B;
inline bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

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

    setFact(300000);
    cin >> H >> W >> A >> B;

    int r = H - A;
    int c = B - 1;
    int ans = 0ll;
    while (true) {
        r--;
        c++;
        if (!inside(r, c)) break;
        // cout << r << " " << c << endl;

        ans += ((getC(r + c, r) * getC(W + H - 2ll - r - c, H - r - 1ll)) % mod);
        ans %= mod;
    }
    cout << ans << endl;
    // printf("%lld\n", ans);
}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

//bit全探索
vector<ll>bitSearch(int bit,int n){
    vector<ll>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    S.push_back(1e9);
    return S;
}

int main(){
   int h, w, k;
   cin >> h >> w >> k;
   vector<string> s(h);
   rep(i, h)cin >> s[i];
   vector<ll> cnts(15, 0);

   ll res = INF;
   for(int bit = 0; bit < (1 << (h - 1)); bit++){
      
      ll sum = 0;
      auto S = bitSearch(bit, h);
      sum += S.size() - 1;

      int now = 0;
      rep(j, w){
         vector<ll> cnt(15, 0);
         now = 0;
         bool f = false;
         rep(i, h){
            if(i - 1 == *lower_bound(ALL(S), i - 1)){
               now++;
            }
            if(s[i][j] == '1')cnt[now]++;

            
            if(cnts[now] + cnt[now] > k){
               f = true;
            }
         }
         if(f){
            cnts = vector<ll> (15, 0);
            sum++;
         }
         rep(hh, h){
            cnts[hh] += cnt[hh];
            if(cnts[hh] > k)sum = INF;
         }
      }
      
      res = min(res, sum);
      cnts = vector<ll>(15, 0);
   }
   cout << res << endl;
}

Measured memory_bytes: 3204
X = int(input()) 

if X >= 1800:
    print(1)
elif X >= 1600:
    print(2)
elif X >= 1400:
    print(3)

elif X >= 1200:
    print(4)
elif X >= 1000:
    print(5)

elif X >= 800:
    print(6)
elif X >= 600:
    print(7)
elif X >= 400:
    print(8)

Measured memory_bytes: 9176
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,n,i,j,y,smallest=1e6,val=-1;
    cin>>x>>n;
    int p[102]={0};
    for(i=0;i<n;++i){
    	cin>>y;
    	p[y]++;
	}
	for(i=x;i<=101;++i){
	    if(p[i]==0 && abs(i-x)<=smallest){
	    	smallest=abs(i-x);
	    	val=i;
	    	break;
		}
	}
	for(i=x;i>=0;--i){
		if(p[i]==0 && abs(i-x)<=smallest){
			smallest=abs(i-x);
			val=i;
			break;
		}
	}
	cout<<val;
}

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



signed main(){
    int a,b,q;
    cin >> a>>b>>q;
    int s[a+1],t[b+1];
    for(int i=0;i<a;i++)cin >> s[i];
    for(int i=0;i<b;i++)cin >> t[i];
    s[a]=100000000000;t[b]=100000000000;
   int st[a+b],dis[a+b],x=0,y=0 ,mins=s[0],mint=t[0];
   while(x+y<a+b){
       if(y<b&&s[x]>t[y]){
           dis[x+y]=min(abs(t[y]-mins),s[x]-t[y]);
           st[x+y]=t[y];
           mint=t[y];
           y++;
       }else{
           dis[x+y]=min(abs(s[x]-mint),t[y]-s[x]);
           st[x+y]=s[x];
           mins = s[x];
           x++;

       }
   }
  // for(int i=0;i<a+b;i++)cerr << st[i]<<' '<<dis[i]<<endl;

    int k,ok,ng,mid;
    for(int i=0;i<q;i++){
        cin >>k;
        ok=0;ng=a+b;
        while(abs(ok-ng)>1){
            mid=(ok+ng)/2;
            if(st[mid]<=k)ok=mid;
            else ng=mid;

        }
        //cerr <<ok<< ' '<<st[ok] <<' ' <<ng<<' '<<st[ng]<<endl;
        cout <<min(abs(st[ok]-k)+dis[ok],abs(st[ng]-k)+dis[ng])<<endl;
    }

    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
using namespace std;
#define lli long long int 
int main() {
	// your code goes here
	lli i,k,m,x,y;
	cin>>x>>y;
	if(y%2==0)
	{
	if(y>=2*x&&y<=4*x)
	cout<<"Yes";
	else
	cout<<"No";
	}
	else
	cout<<"No\n";

	return 0;
}

Measured memory_bytes: 3636
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    vector<bool> ok(n, true);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (h[a] <= h[b]) ok.at(a) = false;
        if (h[b] <= h[a]) ok.at(b) = false;
    }
    int ans = 0;
    rep(i, n) {
        if (ok.at(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
  #ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
  fastio
  string s,t;
  cin>>s>>t;
  lli i,d=0;
  for(i=0;i<s.length();i++)
  {
  	if(s[i]!=t[i])
  		d++;
  }
  cout<<d;
	return 0;
}


Measured memory_bytes: 3796
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ret = (n + x - 1) / x * t;
  cout << ret << endl;
  return 0;
}


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

int main(){
    int n, c, k; cin >> n >> c >> k;
    vector<int> t;
    for(int i=0; i<n; i++){
        int tmp; cin >> tmp;
        t.push_back(tmp);
    }
    sort(t.begin(), t.end());
    int ans = 0;
    int stock=0;
    int time=0;
    for(int i=0; i<n; i++){
        if(stock==0){
            time = t[i]; // 残っている一番古い人の到着時間
        }
        stock++; // たまってる人数
        if(stock==c){ // 満タンになったら送り出す
            ans++;
            stock=0;
        }else if(t[i+1]-time >k && i!=n-1){ // 切れだす前に送り出す
            ans++;
            stock = 0;
        }
    }
    if(stock!=0) ans++;
    cout << ans << endl;
    return 0;
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

  int p,q,r;
  cin >> p >> q >> r;

  if((p+q)<=(r+q) && (p+q)<=(p+r)){
    cout << p+q << endl;
  }
  else if((r+q)<=(p+q) && (r+q)<=(p+r)){
    cout << r+q << endl;
  }
  else if((p+r)<=(r+q) && (p+r)<=(p+q)){
    cout << p+r << endl;
  }

  return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a; int b;
    int temp =0;
    bool flag = false;
    for(int i =0; i<n; i++){
        if(temp ==3){
        cout<<"Yes"<<endl;
        flag = true;
        break;
        }
        cin>>a;
        cin>>b;
        if(a==b)
        temp++;
        else
        temp =0;
    }
    if(!flag){
   if(temp==3)
   cout<<"Yes"<<endl;
   else 
   cout<<"No"<<endl;
    }
   return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main (){
    int a, b;
    while (1){
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        if (a < b){
            cout << a << " " << b <<endl;
        }
        else if (a > b){
            cout << b << " " << a << endl;
        }
        else if (a == b){
            cout << a << " " << b << endl;
        }
    }return 0;
}


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

public class Main {
	int H,W;
	char[][] ch;
	boolean[][] passed;
	int[] dx = {1,0};
	int[] dy = {0,1};

	public boolean check(){
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(ch[i][j] == '#' && !passed[i][j]){
					return false;
				}
			}
		}
		return true;
	}

	public boolean dfs(int y,int x){
		if(y == H - 1 && x == W - 1){
			return check();
		}
		boolean ret = false;

		if(y + 1 < H && ch[y + 1][x] == '#'){
			passed[y + 1][x] = true;
			ret |= dfs(y + 1,x);
			passed[y + 1][x] = false;
		}
		if(x + 1 < W && ch[y][x + 1] == '#'){
			passed[y][x + 1] = true;
			ret |= dfs(y,x + 1);
			passed[y][x + 1] = false;
		}
		return ret;
	}

	public void solve() {
		H = nextInt();
		W = nextInt();

		ch = new char[H][];
		for(int i = 0;i < H;i++){
			ch[i] = next().toCharArray();
		}

		passed = new boolean[H][W];
		passed[0][0] = true;
		if(dfs(0,0)){
			out.println("Possible");
		}else{
			out.println("Impossible");
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

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

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 9096
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    int N;
    int a[100];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    
    int count=0;
    if(N%2==0){
      
        for(int i=0;i<(N/2);i++){
            count+=a[2*i+1]-a[2*i];
        }
        
    }else{
        count+=a[0];
        
        for(int i=1;i<=(N-1)/2;i++){
            count+=a[2*i]-a[2*i-1];
            
        }
        
    }

    cout<<count<<endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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


int dp[1000010] = { 0 };
int dpodd[1000010] = { 0 };


int N = 0;
int C[191];
int Codd[51];

void input(void) {
	CI N;

	return;
}


int main(void) {
	int C_N;
	for (int i = 1; i <= 190;i++) {
		C[i - 1] = i * (i + 1) * (i + 2) / 6;
	}
	int ii = 1, jj = 0;
	while (true) {
		if (ii * (ii + 1) * (ii + 2) / 6 > 1000000) {
			break;
		}
		if ((ii * (ii + 1) * (ii + 2) / 6) % 2 == 1) {
			Codd[jj] = ii * (ii + 1) * (ii + 2) / 6;
			jj++;
		}
		ii++;
	}

	for (int i = 1; i <= 1000009; i++) {
		dp[i] = 1001000;
	}
	for (int i = 1; i <= 1000009; i++) {
		dpodd[i] = 1001000;
	}

	for (int j = 1; j <= 189; j++) {
		for (int i = 1; i <= 1000002; i++) {
			if (i < C[j - 1]) {
				dp[i] = dp[i];
			}
			else {
				dp[i] = min(dp[i], dp[i - C[j - 1]] + 1);
			}
		}

	}

	for (int j = 1; j <= 50; j++) {
		for (int i = 1; i <= 1000002; i++) {
			if (i < Codd[j - 1]) {
				dpodd[i] = dpodd[i];
			}
			else {
				dpodd[i] = min(dpodd[i], dpodd[i - Codd[j - 1]] + 1);
			}
		}
	}

	while (true) {
		input();
		if (N == 0) {
			break;
		}
		/*for (int i = 0; i < 190; i++) {
			if (C[i] > N) {
				C_N = i;
				break;
			}
		}*/
	

		

		CO dp[N] << " ";

		
		/*for (int i = 0; i < 50; i++) {
			if (Codd[i] > N) {
				C_N = i;
				break;
			}
		}*/
		

		CO dpodd[N] E
		
		
	}
	
	
	return 0;
}

Measured memory_bytes: 10816
def main():
    S = input()
    K = int(input())
    ans = ""
    for i, s in enumerate(S):
        tmp = ord(s) - ord('a')
        if i == len(S) - 1:
            ans += chr((tmp + K) % 26 + ord('a'))
        elif s == 'a':
            ans += s
        elif 26 - tmp <= K:
            ans += 'a'
            K -= 26 - tmp
        else:
            ans += s

    print(ans)
            


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
Ln = list(map(int, input().split()))
Ln.sort()
Lc = collections.Counter(Ln)
ans = 0
Cmb = combinations(Lc, 3)
for Cm in Cmb:
    l1, l2, l3 = Cm
    if (l1 + l2 <= l3):
        continue
    ans += Lc[l1] * Lc[l2] * Lc[l3]
print(ans)



Measured memory_bytes: 27124
nm = input().split()
n = int(nm[0])
m = int(nm[1])

matrix = []

for i in range(n):
    row = []
    A = input().split()
    for a in A:
        row.append(int(a))

    matrix.append(row)

column = []
for i in range(m):
    column.append(int(input()))

for i in range(n):
    sum_list = []
    for j in range(m):
        sum_list.append(column[j]*matrix[i][j])
    print(sum(sum_list))

Measured memory_bytes: 8028
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>

int main(int argc, char *argv[])
{
    char s[500001];
    int n[500001];

    std::cin >> s;
    int len = std::strlen(s);

    for(int i = 0; i <= len; i++) {
        n[i] = -1;
    }

    // 両端の処理
    if (s[0] == '<') {
        n[0] = 0;
        for (int i = 0, x = 1; (i < len) && (s[i] == '<'); i++, x++) {
            n[i + 1] = x;
        }
    }

    if (s[len - 1] == '>') {
        n[len] = 0;
        for (int i = len - 1, x = 1; i >= 0 && s[i] == '>'; i--, x++) {
            n[i] = x;
        }
    }

    // 内部の処理
    for (int i = 0; i < len; i++) {
        if (s[i] == '>' && s[i + 1] == '<') {
            n[i + 1] = 0;
            for (int j = i, x = 1; j >= 0 && s[j] == '>'; j--, x++) {
                n[j] = std::max(n[j], x);
            }
            for (int j = i + 1, x = 1; j < len && s[j] == '<' ; j++, x++) {
                n[j + 1] = std::max(n[j + 1], x);
            }
        }
    }

#ifdef _DEBUG
    for (int i = 0; i <= len; i++) {
        std::cout << n[i] << ", ";
    }
    std::cout << std::endl;
#endif

    long long sum = 0;
    for (int i = 0; i <= len; i++) {
        sum += n[i];
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main(void){
    int m , f , r ;
    
    while(1){
        scanf("%d %d %d" , &m , &f , &r);
        if(m == -1 && f == -1 && r == -1){break;}
        
        else if(m == -1 || f == -1){
            printf("F");
        }
        else if(m + f >= 80){
            printf("A");
        }
        else if(m + f >= 65 && m + f < 80){
            printf("B");
        }
        else if(m + f >= 50 && m + f < 65){
            printf("C");
        }
        else if(m + f >= 30 && m + f < 50){
            if(r >= 50){
                printf("C");
            }
            else
                printf("D");
        }
        
        else if(m + f < 30){
            printf("F");
        }
        printf("\n");
    }
    return 0;
}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    string S;
    cin >> S;
    int ans = 1e9;
    for(int i = 0; i < S.size() - 2; i++){
        ans = min(ans, abs((S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0') - 753));
    }
    cout << ans << endl;
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;

  vector<int> A(M);
  rep(i, 0, M) cin >> A.at(i);

  vector<bool> flag(N+1, false);
  rep(i, 0, M) flag.at(A.at(i)) = true;

  int temp1 = 0, temp2 = 0;

  for (int i=X; i<N; i++) {
    if (flag.at(i)) temp1++;
  }

  for (int i=X; i>0; i--) {
    if (flag.at(i)) temp2++;
  }

  cout << min(temp1, temp2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[10001],cur;
int chk[55555];
int main(){
    int n; cin>>n;
    for(int i=2;i<55555;i++){
        if(!chk[i]){
            p[cur++] = i;
            for(int j=2;(i*j)<=55555;j++) chk[i*j] = 1;
        }
    }
    for(int i=0;i<cur;i++){
        if((p[i]%5)==1){ cout<<p[i]<<' '; n--;}
        if(n==0) break;
    }
    return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int digit(ll n){

    int k = 0;

    while(n > 0){
        n = n / 10;
        k++;
    }

    return k;
}

ll mypow(ll a, ll x){

    ll y = 1;

    rep(i, x){
        y = y * a;
    }

    return y;
}

int main(){

    ll n;
    cin >> n;

    int d = digit(n);
    ll maxdigit = n / mypow(10, d - 1);

    for(ll i = maxdigit; i >= 0; i--){
        ll tmp = i * mypow(10, d - 1) + mypow(10, d - 1) - 1;

        if(tmp <= n){
            cout << i + (d - 1) * 9 << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int b1[2] = { 0,1 };
int b2[2] = { 1,0 };
int bfs[100][100];
bool bfs1[100][100] = { false };
int main() {
	deque<int> que, que1;
	int co, co1;
	int h, w;
	string c[500];
	pair<int, int> p;
	cin >> h >> w;
	for (int i = 0; i < h; i++) cin >> c[i];
	for (int i1 = 0; i1 < h; i1++) {
		for (int j1 = 0; j1 < w; j1++) {
			bfs[i1][j1] = 1000000007;
		}
	}
	que.push_front(0);
	que1.push_front(0);
	bfs[0][0] = 0;
	while (!que.empty()) {
	 p = make_pair(que.front(), que1.front());
		que.pop_front();
		que1.pop_front();
		for (int k = 0; k < 2; k++) {
			if (p.first + b1[k] < 0 || p.first + b1[k] >= h || p.second + b2[k] < 0 || p.second + b2[k] >= w) continue;
			int d2 = bfs[p.first][p.second];
				if (c[p.first][p.second] == '#'&& c[p.first + b1[k]][p.second + b2[k]]=='.') {
					d2++;
				}
				bool wall = (c[p.first][p.second] == '#');
			if (bfs[p.first + b1[k]][p.second + b2[k]] > d2) {
				bfs[p.first + b1[k]][p.second + b2[k]] = d2;
				if (wall) {
					que.push_back(p.first + b1[k]);
					que1.push_back(p.second + b2[k]);
				}
				else {
					que.push_front(p.first + b1[k]);
					que1.push_front(p.second + b2[k]);
				}
			}
		}
	}
	if (c[h-1][w-1] == '#') {
			bfs[h - 1][w - 1]++;
	}
	cout << bfs[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 384
n = gets
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
s = 0
c = a[-1]
(b.size-1).downto(0) { |i|
  s += x = [b[i], c+a[i]].min
  c = a[i] - [x-c, 0].max
}
p s

Measured memory_bytes: 19356
var arr = [(Int, String, Int)]()
for i in 1...Int(readLine()!)! {
  let input = readLine()!.characters.split(" ").map{String($0)}
  arr += [(i, input[0], Int(input[1])!)]
}
for element in arr.sort({if $0.1==$1.1{return $0.2>$1.2};return $0.1<$1.1}) {
  print(element.0)
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vvl G(n);
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vl vv(n,-1);
	vv[0] = 0;
	queue<ll> q;
	q.push(0);
	vl cnt(2,0);
	cnt[0]++;
	while(!q.empty()){
		ll u = q.front(); q.pop();
		for(auto v : G[u]){
			if(vv[v] != -1) continue;
			vv[v] = 1 - vv[u];
			cnt[vv[v]]++;
			q.push(v);
		}
	}
	vl ans(n);
	if(cnt[0] <= n/3){
		ll now = 1;
		ll rev = 1;
		rep(i,n){
			if(vv[i]==0){
				ans[i] = 3 * now;
				now++;
			}else{
				if(rev % 3 == 0 && rev <= cnt[0] * 3) rev++;
				ans[i] = rev;
				rev++;
			}
		}
	}else if(cnt[1] <= n/3){
		ll now = 1;
		ll rev = 1;
		rep(i,n){
			if(vv[i]==1){
				ans[i] = 3 * now;
				now++;
			}else{
				if(rev % 3 == 0 && rev <= cnt[1] * 3) rev++;
				ans[i] = rev;
				rev++;
			}
		}
	}else{
		ll now1 = 0, now2 = 0, now = 1;
		rep(i,n){
			ll t;
			if(vv[i]==0){
				if(n >= 3*now1 + 1){
					t = 3 * now1 + 1;
					now1++;
				}else{
					t = 3 * now;
					now++;
				}
				ans[i] = t;
			}else{
				if(n >= 3*now2 + 2){
					t = 3 * now2 + 2;
					now2++;
				}else{
					t = 3 * now;
					now++;
				}
				ans[i] = t;
			}
		}
	}
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 18280
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    int n, m;
    
    std::cin >> n >> m;

    if (n == m) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    string temp;
    vector<string> strs;
    
    for (int i = 0; i < 3; i++)
    {
        cin >> temp;
        strs.emplace_back(temp);
    }
    cout << strs[0][0] << strs[1][1] << strs[2][2] << endl;

    return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	unsigned long long  Q,H,S,D,N;
	cin >> Q >> H >> S >> D >> N;
	
	if(4*Q < S) S = 4*Q;
	if(2*H < S) S = 2*H;
	
	if(2*S > D) cout << (N%2==1?S:0) + (N-(N%2==1?1:0))/2 * D;
	else cout << S * N;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    double R;
    cin >> R;
    outset(10);
    cout << 6.28318530717958623200*R << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,m;
int a[100005],b;
ll memo[100005];
ll dp(int now){
  if(memo[now]!=-1) return memo[now];
  if(a[now]==1) return memo[now]=0;
  if(now==n) return 1;
  else if(now>n) return 0;
  else return memo[now]=(dp(now+1)+dp(now+2))%1000000007;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  memset(memo,-1,sizeof(memo));
  FOR(i,m){
    cin>>b;
    a[b]=1;
  }
  cout<<dp(0)<<endl;
  return 0;
}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;


const int CASES = 3;
const ll MOD = 1000000007;

void solve() {
    ll n; cin >> n;
    string s = to_string(n);
    ll m = 0;
    for (int i = 0; i < s.size(); ++i) {
        m += (ll)(s[i]-'0');
    }
    string ans = "No";
    if(n%m==0) ans = "Yes";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;

int a[100];
int k;

bool cmp(int a,int b)
{
    return (a%10)<(b%10);
}
int main()
{
    for (int i=1; i<=5; ++i)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+5,cmp);
    int flag=1; 
    for (int i=1; i<=5; ++i)
    {
        if (a[i]%10==0)
        {
            k+=a[i];
        }else
        {
            if (flag==0)
            k+=((a[i]/10)+1)*10;
            else
            {
                flag=0;
                k+=a[i];
            }
        }
    }
    cout<<k<<endl;

    return 0;
}



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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))



void solve(){
    int n;
    cin>>n;
    double m;
    cin>>m;
    double a[n];
    double su=0;
    rep(i,0,n){
        cin>>a[i];
        su+=a[i];
    }
    double cnt=0;
    double check=1/(4*m);
    check*=su;
    rep(i,0,n){
        if(a[i]>=check)cnt++;
    }
    if(cnt>=m)cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256