akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#else
#define print(...)
#endif

class UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<vector<int>> group;
public:
    UnionFind(int n = 1) {
        par.resize(n + 1);
        rank.resize(n + 1);
        size.resize(n + 1);
        group.resize(n + 1);
        for (int i = 0; i <= n; ++i) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
            group[i].push_back(i);
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = find(par[x]);
            return par[x] = r;
        }
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        } else {
            if (rank[x] < rank[y]) {
                swap(x, y);
            }
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
            par[y] = x;
            size[x] += size[y];
            return true;
        }
    }

    int get_size(int x) {
        return size[find(x)];
    }

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (group[x].size() > group[y].size()) {
            swap(x, y);
        }
        copy(group[y].begin(), group[y].end(), back_inserter(group[x]));
        group[y].clear();
        par[y] = x;
    }
};

void solve() {
    ll N, M;
    cin >> N >> M;
    UnionFind unionFind(N);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        unionFind.unit(a, b);
    }
    set<ll> used;
    rep(i, N) {
        used.insert(unionFind.find(i));
    }
    cout << used.size() - 1 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<ll> v(n);
  set<ll> st;
  rep(i,n){
    cin>>v[i];
    st.insert(v[i]);
  }
  if(v.size()-st.size()<2){
    cout<<0<<endl;
  }else{
    ll w,h,k=-1,count=0,ans=1;
    sort(v.begin(),v.end(),greater<int>());
    rep(i,n-1){
      
      if(i==k){
        k=-1;
        continue;
      }
      if(v[i]==v[i+1]){
        ans*=v[i];
        k=i+1;
        count++;
      }
      if(count==2){
        cout<<ans<<endl;
        return 0;
      }
      
    }
    
    
    
    
  }
}
///////////////////////////



Measured memory_bytes: 5760
#include<stdio.h>
#define N 25
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
void preorder(int);
void inorder(int);
void postorder(int);
 
Node T[N];
int main(){
  int n, i, j, id, left, right;
  scanf("%d\n",&n);
  for(i = 0 ; i < n ; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d", &id, &left, &right);
    T[id].l = left;
    T[left].p = id;
    T[id].r = right;
    T[right].p = id;
  }
  printf("Preorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      preorder(i);
    }
  }
  printf("\n");
  printf("Inorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      inorder(i);
    }
  }
  printf("\n");
  printf("Postorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].p == -1){
      postorder(i);
    }
  }
  printf("\n");
  return 0;
}
 
void preorder(int u)
{
  if(u == -1) return;
  printf(" %d", u);
  preorder(T[u].l);
  preorder(T[u].r);
}
void inorder(int u)
{
  if(u == -1) return;
  inorder(T[u].l);
  printf(" %d", u);
  inorder(T[u].r);
}
 
void postorder(int u)
{
  if(u == -1) return;
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d", u);
}

Measured memory_bytes: 2720
class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)]
N,M,K = map(int,input().split())
uf = UnionFind(N)
connect = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    connect[a] += 1
    connect[b] += 1
    uf.unite(a,b)
anss = [uf.sizeofset(i)-connect[i]-1 for i in range(N)]
for i in range(K):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
       anss[c] -= 1
       anss[d] -= 1
print(*anss)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

map<pair<int, int>, int> half_enum(vector<tuple<int, int, int>>& arr) {
  map<pair<int, int>, int> mp;
  REP(state, 1 << arr.size()) {
    int sum_a = 0, sum_b = 0, cost = 0;
    REP(i, arr.size()) {
      if (state >> i & 1) {
        int a, b, c; tie(a, b, c) = arr[i];
        sum_a += a;
        sum_b += b;
        cost += c;
      }
    }
    pair<int, int> p = make_pair(sum_a, sum_b);
    auto it = mp.find(p);
    if (it == mp.end()) {
      mp[p] = cost;
    } else if (cost < it->second){
      it->second = cost;
    }
  }
  return mp;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, Ma, Mb; cin >> N >> Ma >> Mb;
  vector<tuple<int, int, int>> arr(N);
  REP(i, N) {
    int a, b, c; cin >> a >> b >> c;
    arr[i] = make_tuple(a, b, c);
  }

  int N1 = N / 2, N2 = N - N1;
  vector<tuple<int, int, int>> arr1(arr.begin(), arr.begin() + N1);
  vector<tuple<int, int, int>> arr2(arr.begin() + N1, arr.end());

  map<pair<int, int>, int> mp1 = half_enum(arr1), mp2 = half_enum(arr2);
  const int INF = 1e5;
  int cost = INF;
  for (auto p : mp1) {
    int a, b, c = p.second; tie(a, b) = p.first;
    for (int k = 1; k * Ma <= 400 and k * Mb <= 400; k++) {
      int res_a = k * Ma - a, res_b = k * Mb - b;
      pair<int, int> res = make_pair(res_a, res_b);
      auto it = mp2.find(res);
      if (it == mp2.end()) continue;
      cost = min(cost, c + it->second);
    }
  }

  cout << (cost == INF ? -1 : cost) << endl;
  return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,a,mx,mm;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a;
		if(i==0)
		{
			mx=mm=a;
		}
		mx=max(mx,a);
		mm=min(mm,a);
	}
	cout<<mx-mm<<endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> P[i];
	}

	vector<int> order(N);
	iota(order.begin(), order.end(), 0);

	sort(order.begin(), order.end(), [&](int i, int j) {
		if (S[i] == S[j]) { // 文字列が同じなら数値が大きい方を優先させる
			return P[i] >= P[j];
		} else { // それ以外なら文字列の辞書順が小さい方を優先させる
			return S[i] <= S[j];
		}
	});

	for (int i = 0; i < N; i++) {
		cout << order[i] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            if(N % saiki(N, 0) == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        static long saiki(long N,long f)
        {
            
            long j = N / 10;
                f += N % 10;

            if (N != 0)
            {
              return saiki(j, f);
            }
            else
            {
                return  f;
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 27512
using System;
using System.Linq;

public class Problem_B
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var K = int.Parse(Console.ReadLine());
    int A = inputs[0], B = inputs[1], C = inputs[2];
    var max = Math.Max(A, Math.Max(B, C));
    var n = max;
    for (var i = 0; i < K; i++) n *= 2;
    Console.WriteLine($"{inputs.Sum() - max + n}");
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll H, W, A[200010], B[200010];

signed main(){
    cin >> H >> W;
    REP(i, H){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    set<pll> st;
    multiset<ll> ms;
    REP(i, W){
        st.insert(pll(i, i));
        ms.insert(0);
    }
    REP(i, H){
        auto l = st.lower_bound(pll(A[i], -1));
        auto r = st.lower_bound(pll(B[i] + 1, -1));
        ll h = LONG_LONG_MIN;
        while(l != r){
            h = max(h, l->second);
            auto itr = ms.find(l->first - l->second);
            if(itr != ms.end()) ms.erase(itr);
            l = st.erase(l);
        }
        if(h >= 0 && B[i] < W - 1){
            st.insert(pll(B[i] + 1, h));
            ms.insert(B[i] + 1 - h);
        }
        if(ms.empty()) PRINT("-1");
        else PRINT(i + 1 + *ms.begin());
    }
    return 0;
}

Measured memory_bytes: 28492
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
constexpr double INF = 1e9;
constexpr double eps = 1e-9;

int main()
{
  const double pi = acos(-1);
  int n;
  cin>>n;
  vector<std::tuple<double, double, double>> vp;
  for(int i:irange(0,n)) {
    double x,y;
    cin>>x>>y;
    double theta = atan2(y, x);
    vp.emplace_back(theta, x, y);
    vp.emplace_back(theta+2*pi, x, y);
  }
  sort(vp);
  double mx = 0;
  for(int i:irange(0,n)) {
    double theta = get<0>(vp[i]);
    int idx = lower_bound(vp, make_tuple(theta+pi-eps, -INF, -INF)) - std::begin(vp);
    double sx = 0;
    double sy = 0;
    for (int j : irange(i, idx)) {
      double t,x,y;
      std::tie(t,x,y) = vp[j];
      sx += x;
      sy += y;
      mx = max(mx, sx*sx + sy*sy);
    }
  }
  cout<<fixed<<setprecision(15)<<sqrt(mx)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    ll A[N];
    ll count[200010];
    for(int i = 0; i < 200010; i++) count[i] = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        count[A[i]]++;
    }
    ll ans_base = 0;
    for(int i = 0; i < 200010; i++) {
        if(count[i] <= 0) continue;
        ans_base += count[i] * (count[i] - 1) / 2;
    }

    for(int i = 0; i < N; i++) {
        if(count[A[i]] <= 1)
            cout << ans_base << "\n";
        else {
            cout << ans_base - count[A[i]] * (count[A[i]] - 1) / 2 + (count[A[i]] - 1) * (count[A[i]] - 2) / 2 << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if(a >= 13){
        cout << b;
    }
    else if(a >= 6){
        cout << b/2;
    }
    else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first

const int N=102000;
ll dp[102][N];
int a[102],v[102];
int n,w;
ll go(int idx,int s){
    if(s>w)
        return -1e18;
    if(idx==n)
        return 0;
    ll &ret = dp[idx][s];
    if(ret != -1)
        return ret;
    ret = -1e18;
    ret = max(ret , max( go(idx+1,s+a[idx])+v[idx] ,go(idx+1,s) ) );
    return ret;
}
int main(){
    memset(dp,-1,sizeof dp);
    cin>>n>>w;
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i],&v[i]);
    cout<<go(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 81536
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<string>V(N);
    rep(i,0,N){

        rep(j,0,N){
            V[i].push_back((i+j)%2 ? '_' : '@');
        }
    }
    vector<int> A,B;
    int cnt = 0;
    rep(j,0,N){
        if(j % 3 != 1)continue;
        rep(i,0,N){
            if(j % 6 == 1 && i % 2 == 0 ||
               j % 6 == 4 && i % 2 == 1){
            cnt++;
            V[i][j] = '@';
            }
        }
    }
    rep(i,0,N){
        if(V[i][0] != '@'){
            cnt++;
            V[i][0] = '@';
        }
        if(V[i][N-1] != '@'){
            cnt++;
            V[i][N-1] = '@';
        }
    }
    rep(j,0,N){
        if(V[0][j] != '@'){
            cnt++;
            V[0][j] = '@';
        }
        if(V[N-1][j] != '@'){
            cnt++;
            V[N-1][j] = '@';
        }
    }
    //rep(i,0,N)cout << V[i] << endl;
    cout << cnt << endl;
    rep(i,0,N)rep(j,0,N){
        if((i+j) % 2 && V[i][j] == '@'){
            cout << i << " " << j << endl;
        }
    }
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))
memo = {}
for i in range(n - 1):
    if a[i] not in memo:
        memo[a[i]] = 1
    else:
        memo[a[i]] += 1
        
for i in range(n):
    if i + 1 in memo:
        print(memo[i + 1])
    else:
        print(0)

Measured memory_bytes: 111440
#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()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;

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 n;
   cin >> n;
   vector<ll> a(n);
   rep(i, n)cin >> a[i];
   bool f = true;
   ll now = -1;
   rep(i, n){
      if(a[i] > now + 1)f = false;
      now = a[i];
   }
   if(!f){
      cout << -1 << endl;
      return 0;
   }
   else {
      ll res = 0;
      now = 0;
      rep(i, n){
         if(i == 0)continue;
         if(a[i] == a[i - 1] + 1)continue;
         res += a[i - 1];
      }
      res += a[n - 1];
      cout << res << endl;
   }
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long x;
  cin >> x;
  long long res = x/11*2;
  if(x%11 == 0){
    cout << res << endl;
    return 0;
  }
  if(x <= res*11/2+6LL)
    cout << res+1LL << endl;
  else
    cout << res+2LL << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int i,j;
    ll keta=1;
    ll ans=0;
    ll one=0; ll zero=0;
    rep(j,60){
        rep(i,n){
            if(a[i]%2==0){
                zero++;
            }else{
                one++;
            }
            a[i]=a[i]/2;
        }
        ll tmp=zero*one%MOD;
        tmp=tmp*keta%MOD;
        ans+=tmp;
        ans=ans%MOD;
        keta=(keta*2)%MOD;
        one=0; zero=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
vector<ll> a,b;

void input(){
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  ll ans = 0;
  for(int i=n-1;i>=0;i--){
    ll r = (a[i] + ans) % b[i];
    if(r) ans += b[i] - r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
  int MAX =55556;
  int flag[MAX]= {false};
  int N;
  cin>>N;
  FOR(i,2,MAX){
    flag[i] = true;
  }
  FOR(i,2,sqrt(MAX)){
    if(flag[i]){
      for(int j=2*i;j <= (MAX);j+=i ){
        flag[j]=false;
      }
    }

  }
  int count =0;
  FOR(i,2,MAX){
    if(flag[i] && i%5 ==1){
      if(count < N-1){
        cout<<i<<" ";
        count++;
      }else{
        cout<<i<<endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 512
N=gets.to_i
red = []
blue = []
ans = 0
N.times do
  red << gets.split.map(&:to_i)
end
N.times do
  blue << gets.split.map(&:to_i)
end

blue.sort_by!{|pos| pos[0]}
red.sort_by!{|pos| -pos[1]}
ans = 0
blue.each do |b|
  red.each do |a|
    if b[0] > a[0] && b[1] > a[1]
      red.delete(a)
      ans += 1
      break
    end
  end
end
puts ans

Measured memory_bytes: 1788
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=200005;

void solve()
{
    
    int MX=1e16;
    int N;
    cin>>N;
    
    int pr[15];;
    pr[0]=1;
    for(int i=1;i<15;i++)
    {
        pr[i]=pr[i-1]*26;
        if(pr[i]>MX)
            pr[i]=MX;
    }
    int len=1;int s=26;
    while(s<N)
    {
        len++;
        s+=pr[len];
    }
    for(int j=1;j<=len-1;j++)
        N-=pr[j];
    vi ans;
    
    for(int j=1;j<=len;j++)
    {
        
        for(int k=0;k<26;k++)
        {
        int z=pr[len-j];
        if(N>z)
            N-=z;
            else
            {
                ans.pb(k);
                break;
            }
        }
    }
    for(int i:ans)
    {
        cout<<(char)(i+'a');
    }
    cout<<endl;
    
    
    
    
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){

	int n,a,b,c;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
			
		if(c*c==a*a+b*b||b*b==a*a+c*c||a*a==b*b+c*c){
			cout<<"YES"<<endl;
		}
		
		else {
			cout<<"NO"<<endl;
		}

	}
	
		
	
	
return 0;
}
	


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

#define int long long

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; ++i) {
        int l, r;
        cin >> l >> r;
        ans += (r-l)+1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
class Main
{
  
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int p[]=new int[3];
    p[0]=sc.nextInt();
    p[1]=sc.nextInt();
    p[2]=sc.nextInt();
    Arrays.sort(p);
    System.out.println(p[0]+p[1]);
  }
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if(s=="RRR") ans = 3;
    else if(s=="RRS") ans = 2;
    else if(s=="RSR") ans = 1;
    else if(s=="RSS") ans = 1;
    else if(s=="SRR") ans = 2;
    else if(s=="SRS") ans = 1;
    else if(s=="SSR") ans = 1;
    else if(s=="SSS") ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 3608
// https://atcoder.jp/contests/abc079/tasks/abc079_b

#include <bits/stdc++.h>
using namespace std;

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

    vector<long long> xs(n + 1);
    xs[0] = 2;
    xs[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        xs[i] = xs[i - 1] + xs[i - 2];
    }
    cout << xs[n] << endl;
    return 0;
}


Measured memory_bytes: 3640
rolls = int(input())
dices = []
for _ in range(rolls):
  dices.append(list(map(int, input().split())))
 
doubles = [d1 == d2 for d1,d2 in dices]
 
for i in range(1,rolls):
  doubles[i] *= (doubles[i] + doubles[i-1])
  if doubles[i] == 3:
    print('Yes')
    exit()
 
print('No')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std; 
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
    int n,k=0;
    cin>>n;
    ll ans=0;
    for(int i=0; i<n; i++){
    	int a;
    	cin>>a;
    	if(i==0) k=a;
    	else if(a>=k) k=a;
    	else ans=ans+k-a;
	}
	cout<<ans;
}

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

using namespace std;

const int INF = 1 << 30;

int S, N, M, X[2000], T[2000];
int sum[2001][2001], dp[2001][2001];

void rec(int idx, int left, int right, int latte, int malta)
{
  if(left >= right) return;
  int mid = (left + right) >> 1;
  dp[idx][mid] = INF;
  int best = -1;
  for(int k = latte; k < min(mid, malta); k++) {
    int cost = dp[idx - 1][k] + sum[k][mid - 1]; // cost[k, mid)
    if(cost < dp[idx][mid]) {
      dp[idx][mid] = cost;
      best = k;
    }
  }
  rec(idx, left, mid, latte, best + 1);
  rec(idx, mid + 1, right, best, malta);
}


int main()
{
  cin >> S >> N >> M;
  for(int i = 0; i < S; i++) {
    cin >> X[i];
  }
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    T[i] = a - X[--b];
  }
  sort(T, T + N);

  for(int right = N - 1; right >= 0; right--) {
    for(int left = right - 1; left >= 0; left--) {
      sum[left][right] = sum[left + 1][right] + T[right] - T[left];
    }
  }

  fill_n(*dp, 2001 * 2001, INF);
  dp[0][0] = 0;
  for(int i = 1; i <= M; i++) rec(i, 0, N + 1, 0, N + 1);

  fill_n(*dp, 2001 * 2001, INF);
  dp[0][0] = 0;
  for(int i = 1; i <= M; i++) {
    rec(i, 0, N + 1, 0, N + 1);
    for(int j = 0; j <= N; j++) dp[i][j] = min(dp[i][j], dp[i - 1][j]);
  }

  cout << dp[M][N] << endl;
}

Measured memory_bytes: 32588
P,Q,R=map(int,input().split())
if P<Q<R or Q<P<R:
    print(P+Q)
if Q<R<P or R<Q<P:
    print(Q+R)
if R<P<Q or P<R<Q:
    print(R+P)
if P==Q==R:
    print(P+Q)
if P==Q<R:
    print(P+Q)
if P==Q>R:
    print(R+P)
if Q==R<P:
    print(Q+R)
if Q==R>P:
    print(P+Q)
if R==P<Q:
    print(R+P)
if R==P>Q:
    print(Q+R)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<int,int>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














const int N=1005;
int dp[N][N];
int h,w;
int main()
{
     cin>>h>>w;
     char str[h+2][w+2];
     for(int i=1;i<=h;i++)
     for(int j=1;j<=w;j++)cin>>str[i][j];
     dp[1][1]=1;
     for(int i=1;i<=h;i++)
     {
          for(int j=1;j<=w;j++)
          {
               if(i==1&&j==1)continue;
               if(str[i][j]=='#')dp[i][j]=0;
               else dp[i][j]=(1LL*dp[i-1][j]+dp[i][j-1])%mod;
          }
     }
     cout<<dp[h][w];
}























 

Measured memory_bytes: 5120
def m():
    sx, sy, tx, ty = map(int, input().split())
    X = tx-sx
    Y = ty-sy
    ans = ""

    # 一周
    ans += "U" * Y
    ans += "R" * X
    ans += "D" * Y
    ans += "L" * X

    # 左に一つずらして目的地まで
    ans += "L"
    ans += "U" * (Y+1)
    ans += "R" * (X+1)
    ans += "D"

    # 右にずれて開始地点まで
    ans += "R"
    ans += "D" * (Y+1)
    ans += "L" * (X+1)
    ans += "U"

    return ans


print(m())

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

int main(){
	int N;
	cin >> N;
	
	vector<int> An(N);
	for(int i = 0; i < N; i++){
		cin >> An.at(i);
	}
	
	int c = 0;
	int d;
	for(int i = 0; i < N; ){
	d = An.at(i);
	
	if(d%2 == 1)
		c++;
		
	i = i + 2;
	}
	
	cout << c << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,t1,t2,ans,max;
    cin>>a;
    ans=0;
    max=0;
    for (int i = 0; i < a; i++)
    {
        cin>>t1>>t2;
        if(t1==t2) ans++;
        else ans=0;
        if(ans>max) max=ans;
    }
    if(max>=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n){
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(ALL(a));
  ll cen = (n%2==1 ? a[n/2] : (a[n/2 - 1] + a[n/2])/2);
  ll res = 0;
  REP(i,n){
    res += abs(a[i]-cen);
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

string s[605];

bool judge(int sh, int sw, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (s[sh + i][sw + j] != s[sh + j][sw + i]) return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        s[i] += s[i];
        s[i + n] = s[i];
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (judge(i, 0, n)) ans += n - i;
        if (i > 0) if (judge(0, i, n)) ans += n - i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 +7;
typedef long long ll;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

int main()
{
    int a = read(), b = read(), c = read();
    int k = read();
    while (b <= a && k > 0) {
        b *= 2;
        k--;
    }
    while (c <= b && k > 0) {
        c *= 2;
        k--;
    }
    if(a < b && b < c) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

    int a;
    int b;
    int c;

    cin >> a >> b >>c;

    if(a == b && b == c){
    	cout << 1 << endl;
    }else if(a == b || b==c || c == a){
    	cout << 2 << endl;
    }else{
    	cout << 3 << endl;
    }


	return 0;

}

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

int main(){
    ll d;
    cin >> d;
    cout << "Christmas";
    rep(i, 0, 25-d) cout << " Eve";
    cout << endl;
    return 0;
}

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

int main() {
  int n,x;
  cin>>n>>x;
  vector<long long>a;
  for(int i=0;i<n;i++){
    long long b;
    cin>>b;
    a.push_back(b);
  }
  long long ans=0;
  for(int i=0;i<n-1;i++){
    if(a.at(0)>x){
      ans+=a.at(0)-x;
      a.at(0)=x;
    }
    if(a.at(i)+a.at(i+1)>x){
      ans+=a.at(i+1)+a.at(i)-x;
      a.at(i+1)=x-a.at(i);
    }
  }
  cout <<ans;
        
  
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
    int n,m;cin >> n >> m;
    int ball[n];
    bool red[n];
    REP(i,n){
        ball[i] = 1;
        red[i] = false;
    }
    red[0] = true;
    REP(i,m){
        int x,y; cin >> x >> y;x--; y--;
        if(red[x]){
            red[y] = true;
        }
        ball[y]++;
        ball[x]--;
        if(ball[x]==0){
            red[x] = false;
        }
    }
    int ans=0;
    REP(i,n){
        if(red[i]) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 768
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll eulerPhi(ll n) {
	ll res = n;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}

		res -= res / i;
		while (n % i == 0) {
			n /= i;
		}
	}

	if (n > 1) {
		res -= res / n;
	}

	return res;
}

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

	ll n;
	cin >> n;

	cout << eulerPhi(n) << endl;
	return 0;
}



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

struct unionFind {
  int n;
  vector<int> pr;

  unionFind(){};
  unionFind(int _n) {
    n = _n;
    pr.resize(n, -1);
  };
  int root(int a) {
    if (pr[a] == -1)
      return a;
    else
      return pr[a] = root(pr[a]);
  }
  void unify(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b) return;
    pr[a] = b;
  }
  int same(int a, int b) { return root(a) == root(b); }
};

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> l(n);
  vector<bool> used(m, false);

  for (int i = 0; i < n; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      x--;
      l[i].push_back(x);
    }
  }

  unionFind uf(m);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k[i]; j++) {
      used[l[i][j]] = true;
      uf.unify(l[i][0], l[i][j]);
    }
  }
  int r = uf.root(l[0][0]);

  for (int i = 0; i < m; i++) {
    if (used[i]) {
      if (r != uf.root(i)) {
        cout << "NO" << endl, exit(0);
      }
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 7296
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOR(i, x) for (auto &i : x)
#define ALL(v) (v.begin()), (v.end())
#define pb(x) emplace_back(x)
#define mp(x, y) make_pair(x, y)
#define mt make_tuple
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const long long LINF = 1e18;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using vstring = vector<string>;
template <class T> using vv = vector<vector<T>>;
#define vvint(A, H, W) vvint A(H, vint(W))
template <class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return 1;}return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return 1;}return 0;}
#define print(x){cout<<x<<endl;}
// clang-format on

int main() {
    int v, e, r;
    cin >> v >> e >> r;
    vector<tuple<int, int, int>> edges(e);

    FOR(edge, edges) {
        int s, t, d;
        cin >> s >> t >> d;
        edge = mt(s, t, d);
    }

    vint ok(v);
    vvint tos(v);
    FOR(edge, edges) {
        int s, t, d;
        tie(s, t, d) = edge;
        tos[s].pb(t);
    }
    stack<int> stk;
    stk.push(r);
    for (stk.push(r); !stk.empty();) {
        int now = stk.top();
        stk.pop();
        ok[now] = true;
        FOR(to, tos[now]) {
            if (!ok[to]) stk.push(to);
        }
    }

    vll ans(v, LINF);
    ans[r] = 0;

    bool changed;
    REP(cnt, v + 1) {
        changed = false;
        FOR(edge, edges) {
            int s, t, d;
            tie(s, t, d) = edge;
            if (!ok[s]) continue;
            changed |= chmin(ans[t], ans[s] + d);
        }
        if (cnt == v && changed) {
            print("NEGATIVE CYCLE");
            return 0;
        }
    }

    REP(v) {
        if (ok[i]) {
            print(ans[i]);
        } else {
            print("INF");
        }
    }
}



Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	ll ans = 0;

	if(x % 11 == 0) ans = x / 11;
	else ans = x / 11 + 1;

	if(6 * ans + 5 * (ans - 1) >= x) cout << 2 * ans - 1 << endl;
	else cout << 2 * ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n);
	int s=0;
	for(auto &i:v){cin>>i; s+=i;}
	int mn=10000000,now=0;
	For(i,0,n-1)
	{
		now+=v[i];
		mn=min(mn,abs(s-now-now));
	}
	cout<<mn<<"\n";
	return 0;
}















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define llin(a) ll a;cin>>a;
#define llin2(a,b) ll a,b;cin>>a>>b; 
#define llin3(a,b,c) ll a,b,c;cin>>a>>b>>c;
// #define vecin(n,v) for(ll i=0;i<n;i++) cin>>v[i];
#define vecout(n,v) for(ll i=0;i<n;i++) cout<<v[i]<<" "; cout<<endl;
#define fr(i,s,n) for(ll i=s;i<n;i++ )
// #define endl "\n "
#define test cout<<"test line"<<endl;
#define pll pair<ll,ll>
#define vpll vector<pll>
#define mod 1000000007
// #define pb push_back;
// #define mp make_pair;
#define endl "\n"
using namespace std;
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void swapper(ll* a,ll* b) {ll temp=*a;*a=*b;*b=temp;}
using namespace std;
int main(){
	llin3(a,b,k);
	if((a-k)>=0) cout<<a-k<<" "<<b<<endl;
	else {k=k-a; if((b-k)>0) cout<<"0 "<<b-k<<endl; else cout<<"0 0"<<endl;}
	return 0;
}

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

void makePrimeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime[0] = prime[1] = false;
    for(int i=2; i*i<=N; ++i){
        if(prime[i]){
            for(int j=i; i*j<=N; ++j){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(123456 * 2, prime);

    for(;;){
        int a;
        cin >> a;
        if(a == 0)
            return 0;

        int ret = 0;
        for(int i=a+1; i<=2*a; ++i){
            if(prime[i])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



Measured memory_bytes: 3216
import java.util.*;

public class Main {

	private static List<Integer> getStrings(Scanner sc, int num) {
		List<Integer> stringList = new ArrayList<>();
		while(num>0) {
			int nextInt = sc.nextInt();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> array = getStrings(sc, n);
		array.sort(Integer::compareTo);
		Set<Integer> set = new HashSet<>();
		int max = array.get(array.size()-1);
		int count = 0;
		for (int i = 0; i < array.size(); i++) {
			for (int j = 2; j <= max/array.get(i) + 1; j++) {
				set.add(array.get(i) * j);
			}
			if (i != array.size()-1 && array.get(i).intValue() == array.get(i+1).intValue()) {
				continue;
			} else if (i != 0 && array.get(i).intValue() == array.get(i-1).intValue()) {
				continue;
			}
			if (!set.contains(array.get(i))) {
				count++;
//				System.out.print(array.get(i) + ", ");
			}
		}
		System.out.println(count);
		return;
	}

}
//12, 18, 28, 44, 47, 61, 76, 81, 86, 102, 105, 158, 159, 201, 205, 219, 236, 238, 239, 253, 254, 257, 261, 268, 272, 275, 283, 285, 298, 299, 314, 350, 398, 406, 421, 454, 455, 473, 513, 520, 548, 556, 565, 590, 613, 617, 641, 677, 697, 699, 734, 749, 755, 772, 834, 851, 866, 871, 873, 877, 885, 916, 921, 938, 951, 965, 994,
//12, 18, 28, 44, 47, 61, 76, 81, 86, 102, 105, 158, 159, 201, 205, 219, 236, 238, 239, 253, 254, 257, 261, 268, 272, 275, 283, 285, 298, 299, 314, 350, 398, 406, 421, 454, 455, 473, 513, 520, 548, 556, 565, 590, 613, 617, 641, 677, 697, 699, 734, 749, 755, 772, 814, 814, 834, 851, 866, 871, 873, 877, 885, 913, 913, 916, 921, 938, 951, 965, 994, 999, 999

Measured memory_bytes: 135604
//#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int n;
vvpi g;
bitset<100100> col;
void dfs(int v, ll d = 0, int p = 0) {
	if (d & 1)
		col.set(v);
	for (auto i : g[v])
		if (i.first != p)
			dfs(i.first, d + i.second, v);
}

int main() {
	doin();
	cin >> n;
	g.resize(n + 1);
	for (int f, t, w, i = 1; i < n; i++) {
		cin >> f >> t >> w;
		g[f].pb( { t, w });
		g[t].pb( { f, w });
	}
	dfs(1);
	for (int i = 1; i <= n; i++)
		cout << col.test(i) << "\n";
	return 0;
}



Measured memory_bytes: 8832