akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();

        // Union Find Tree
        UnionFindTree uft = new UnionFindTree(n);

        for (int i = 0; i < m; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            // Put `a` and `b` into the same group
            uft.unite(a, b);
        }
        
        // Number of members of the largest group
        int max = 0;
        for (int i = 0; i < n; ++i) {
            max = Math.max(max, uft.size(i));
        }

        System.out.println(max);
    }
}

class UnionFindTree {
    int size;
    // ancestors[i] is the ancestor node of `i`
    int ancestors[];
    // Number of members of the group
    int counts[];

    public UnionFindTree(int size) {
        this.size = size;
        this.ancestors = new int[this.size];
        this.counts = new int[this.size];

        for (int i = 0; i < this.size; ++i) {
            // initialize a parent of `i` as `i`
            this.ancestors[i] = i;
            this.counts[i] = 1;
        }
    }

    // Put node `a` and node `b` in the same group
    public void unite(int a, int b) {
        int root_a = this.root(a);
        int root_b = this.root(b);

        // already in the same group
        if (root_a == root_b) {
            return;
        }
        else if (this.counts[root_a] > this.counts[root_b]) {
            this.ancestors[root_b] = this.ancestors[root_a];
            this.counts[root_a] += this.counts[root_b];
        }
        else {
            this.ancestors[root_a] = this.ancestors[root_b];
            this.counts[root_b] += this.counts[root_a];
        }
    }

    // Check if `a` and `b` are in the same group
    public boolean same(int a, int b) {
        int root_a = this.root(a);
        int root_b = this.root(b);

        // `a` and `b` are in the same group if the root of `a` == the root of `b`
        return root_a == root_b;
    }

    // Get a root node of `a`
    public int root(int a) {
        // `a` is the root node
        if (this.ancestors[a] == a) {
            return a;
        }

        // Replace the parent of `a` into the root of `a`
        int root = this.root(this.ancestors[a]);
        this.ancestors[a] = root;
        this.counts[a] = this.counts[root];

        return root;
    }

    public int size(int a) {
        int root = this.root(a);
        return this.counts[root];
    }
}



Measured memory_bytes: 61680
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

namespace flow {
  const int maxn = 1e5, maxm = 2e5;
  const int inf = ~0U >> 1;

  int n, m, s, t;
  vector<int> g[maxn];

  struct Edge {
    int v, cap;
  } edge[maxm];

  void Init(int n0, int s0, int t0) {
    n = n0; m = 0; s = s0; t = t0;
  }

  void AddEdge(int u, int v, int cap) {
    g[u].push_back(m);
    edge[m++] = {v, cap};
    g[v].push_back(m);
    edge[m++] = {u, 0};
  }

  int dist[maxn], cur[maxn];

  bool Bfs(void) {
    memset(cur, 0, n * sizeof (int));
    memset(dist, -1, n * sizeof (int));
    queue<int> q;
    q.push(s);
    dist[s] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (u == t) return true;
      for (int i : g[u]) {
        Edge &e = edge[i];
        if (e.cap && dist[e.v] == -1) {
          dist[e.v] = dist[u] + 1;
          q.push(e.v);
        }
      }
    }
    return false;
  }

  int Dfs(int u, int f) {
    if (u == t) return f;
    int sum = 0;
    for (int &i = cur[u]; i < g[u].size(); ++i) {
      Edge &e = edge[g[u][i]], &rev = edge[g[u][i] ^ 1];
      if (e.cap && dist[e.v] == dist[u] + 1) {
        int t = Dfs(e.v, min(f - sum, e.cap));
        e.cap -= t;
        rev.cap += t;
        sum += t;
        if (sum == f) return f;
      }
    }
    return sum;
  }

  int Solve(void) {
    int sum = 0;
    while (Bfs()) {
      sum += Dfs(s, inf);
    }
    return sum;
  }
}

const int maxn = 100;

int n;
int a[maxn], b[maxn], c[maxn], d[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, b + i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", c + i, d + i);
  }
  int s = n + n, t = s + 1;
  flow::Init(t + 1, s, t);
  for (int i = 0; i < n ;++i) {
    flow::AddEdge(s, i, 1);
    flow::AddEdge(n + i, t , 1);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i] < c[j] && b[i] < d[j]) {
        flow::AddEdge(i, n + j, 1);
      }
    }
  }
  printf("%d\n", flow::Solve());
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

const double PI=3.14159265358979323846;

double R;

void solve(){
    cout << 2*PI*R << endl;
}

int main(){
    cin >> R;

    solve();
}


Measured memory_bytes: 3740
a, b, c, d, e, f = map(int, input().split())

memo = {}

for x in range(31):
    for y in range(31):
        for s in range(101):
            for t in range(101):
                water = (100*a)*x + (100*b)*y
                sugar = s*c + t*d
                if water == 0:
                    break
                if water + sugar > f:
                    break
                else:
                    if water/100 * e >= sugar:
                        density = 100*sugar/(water + sugar)
                        memo[x, y, s, t] = density

max_v = max(memo.values())

for k, v in memo.items():
    if v == max_v:
        print((100*a)*k[0] + (100*b)*k[1] + c*k[2] + d*k[3], c*k[2] + d*k[3])
        break


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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
//#define int LLI
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define F1(i,n) FOR(i,1,n)

typedef long long LLI;
typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LLI, LLI> pll;
typedef vector<int> vi;

#ifdef ONLINE_JUDGE
ostream cnull(NULL);
#define cerr cnull
#endif

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define dbgV(R) {cerr << #R << "=["; for(int e : R) cerr << e << ", "; cerr << "E]\n";}
#define dbgA(R, n) {cerr << #R << "=["; for(int i = 0; i <= n; ++i) cerr << R[i] << ", "; cerr << "E]\n";}
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
    boost;
    int n, k; cin >> n >> k;
    LLI wyn = 0;
    for(int a = 1; a <= n; ++a){
		if((a*2) % k == 0){
			int pier = (k - a % k);
			int ile = max(0, (n - pier) / k) + (pier <= n);
			wyn += LLI(ile)*ile;
		}
	}
	cout << wyn;
}



Measured memory_bytes: 256
// clang++ -std=c++14 -stdlib=libc++ -O2 ./*.cpp

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int H, W;
  cin >> H >> W;
  vec2d<char> A(H, W);
  vector<pair<int, int>> ps;
  ps.reserve(H*W);
  cin >> A;
  // cout << A;
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        ps.push_back(pair<int, int>(i, j));
      }
    }
  }
  int d[5] = {-1, 0, 1, 0, -1};
  int ans = 0;
  while(1) {
    vector<pair<int, int>> nps;
    nps.reserve(H*W);
    while (!ps.empty()) {
      pair<int, int> p = ps.back();
      int x = p.first;
      int y = p.second;
      // debug(x);
      // debug(y);
      for (size_t t = 0; t < 4; t++) {
        int dx = x + d[t];
        int dy = y + d[t + 1];
        if (dx >= 0 && dx < H && dy >= 0 && dy < W && A[dx][dy] == '.') {
          A[dx][dy] = '#';
          nps.push_back(pair<int, int>(dx, dy));
        }
      }
      ps.pop_back();
    }
    if (nps.empty()) {
      break;
    } else {
      ans++;
      ps = nps;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
    using namespace std;
    #define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
     
    typedef long long ll; 
     
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } 
     
    int main() {FIN
    	
    	ll i, j, k, t, n, sum = 0;
    	cin >> n;
    	for (i = 1; i <= n; i++) {
    		for (j = 1; j <= n; j++) {
    			t = gcd(i, j);
    			for (k = 1; k <= n; k++)
    				sum += gcd(t, k);
    		}
    	}
    	cout << sum << "\n";
    	return 0;
    }

Measured memory_bytes: 3648
import numpy as np
H,W=map(int,input().split())
S=[list(input()) for h in range(H)]
S=[[1 if s=='.' else 0 for s in S[h]] for h in range(H)]
S=np.array(S)
L=S.copy()
R=S.copy()
U=S.copy()
D=S.copy()
for w in range(1,W):
    L[:,w]=(L[:,w-1]+1)*S[:,w]
    R[:,-(1+w)]=(R[:,-w]+1)*S[:,-(1+w)]
for h in range(1,H):
    U[h,:]=(U[h-1,:]+1)*S[h,:]
    D[-(1+h),:]=(D[-h,:]+1)*S[-(1+h),:]
print(int((L+R+U+D).max())-3)

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

int main(){
    int n; cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        --a[i];
    }

    for(int now = 0, c = 0;;c++){
        if(now == 1){
            cout << c << endl;
            break;
        }

        if(c >= n){
            cout << -1 << endl;
            break;
        }
        
        now = a[now];
    }
}

Measured memory_bytes: 3712
n,m=map(int,input().split())
X=sorted(list(map(int,input().split())))
ans=[]
if m<n:
  print(0)
  exit()
for i in range(m-1):
  ans.append(X[i+1]-X[i])
ans=sorted(ans)
print(sum(ans[:m-n]))

Measured memory_bytes: 13960
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)
template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s){
     
  int n = g.size();
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = numeric_limits<T>::max();
  vector<T> dist(n, inf);

  using P = pair<T, int>;
  // 小さい順に取り出せる
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()){
    T cost;
    int node;
    tie(cost, node) = que.top();
    que.pop();
    if(dist[node] < cost) continue;
    for(auto &e : g[node]){
      auto next_cost = cost + e.second;
      int next_node = e.first;
      if(dist[next_node] <= next_cost) continue;
      dist[next_node] = next_cost;
      que.emplace(next_cost, next_node);
    }
  }

  return dist;
}

int main() {
  
  int n, m, s, t; cin >> n >> m >> s >> t;
  s--;
  t--;

  vector<vector<pair<int, lint>>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    lint d; cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    g[a].push_back({b, d});
    g[b].push_back({a, d});

    g[a].push_back({c, d});
    g[c].push_back({a, d});

    g[b].push_back({c, d});
    g[c].push_back({b, d});
  }

  cout << dijkstra(g, s)[t] << endl;
  return 0;
}



Measured memory_bytes: 23648
#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
int main()
{
    int n,i,q,b,c,j;
    long long sum1,sum;
    sum1=0;
    cin>>n;
    int arr[n];
    unordered_map<int,int> map;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        map[arr[i]]++;
        sum1+=arr[i];
       

    }
     
    cin>>q;
    for(i=0;i<q;i++)
    {
        
        cin>>b;
        cin>>c;
        
        sum1=sum1+(c-b)*map[b];
        map[c]+=map[b];
        map[b]=0;
        sum=sum1;
       
        cout<<sum<<endl;

    }


}

Measured memory_bytes: 7480
word = list(map(int,input().split()))
hyoko = list(map(int,input().split()))
road = [0]*word[1]
for i in range(word[1]):
    road[i] = list(map(int,input().split()))
tenbo = [1]*word[0]

for j in range(word[1]):
    if hyoko[road[j][0]-1] > hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] *= 1
        tenbo[road[j][1]-1] = 0
    elif hyoko[road[j][0]-1] < hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] *= 1
    else:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] = 0
answer = word[0] - tenbo.count(0)
print(answer)

Measured memory_bytes: 93952
h,w,k = map(int,input().split())
line = [input() for i in range(h)]
ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for ii in range(h):
            if i&(1<<ii):continue
            for jj in range(w):
                if j&(1<<jj):continue
                if line[ii][jj] == "#":
                    cnt += 1  
        if cnt == k:
            ans += 1
print(ans)

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

// Data structure for Max Heap
struct PriorityQueue 
{
private:
	// vector to store heap elements
	vector<int> A;

	// return parent of A[i]
	// don't call this function if i is already a root node
	int PARENT(int i) 
	{ 
		return (i - 1) / 2; 
	}

	// return left child of A[i]	
	int LEFT(int i) 
	{ 
		return (2 * i + 1); 
	}

	// return right child of A[i]	
	int RIGHT(int i) 
	{ 
		return (2 * i + 2); 
	}

	// Recursive Heapify-down algorithm
	// the node at index i and its two direct children
	// violates the heap property
	void heapify_down(int i)
	{
		// get left and right child of node at index i
		int left = LEFT(i);
		int right = RIGHT(i);

		int largest = i;

		// compare A[i] with its left and right child
		// and find largest value
		if (left < size() && A[left] > A[i])
			largest = left;

		if (right < size() && A[right] > A[largest])
			largest = right;

		// swap with child having greater value and 
		// call heapify-down on the child
		if (largest != i) {
			swap(A[i], A[largest]);
			heapify_down(largest);
		}
	}

	// Recursive Heapify-up algorithm
	void heapify_up(int i)
	{
		// check if node at index i and its parent violates 
		// the heap property
		if (i && A[PARENT(i)] < A[i]) 
		{
			// swap the two if heap property is violated
			swap(A[i], A[PARENT(i)]);
			
			// call Heapify-up on the parent
			heapify_up(PARENT(i));
		}
	}
	
public:
	// return size of the heap
	unsigned int size()
	{
		return A.size();
	}

	// function to check if heap is empty or not
	bool empty()
	{
		return size() == 0;
	}
	
	// insert key into the heap
	void push(int key)
	{
		// insert the new element to the end of the vector
		A.push_back(key);

		// get element index and call heapify-up procedure
		int index = size() - 1;
		heapify_up(index);
	}

	// function to remove element with highest priority (present at root)
	void pop()
	{
		try {
			// if heap has no elements, throw an exception
			if (size() == 0)
				throw out_of_range("Vector<X>::at() : "
						"index is out of range(Heap underflow)");

			// replace the root of the heap with the last element
			// of the vector
			A[0] = A.back();
			A.pop_back();

			// call heapify-down on root node
			heapify_down(0);
		}
		// catch and print the exception
		catch (const out_of_range& oor) {
			cout << "\n" << oor.what();
		}
	}

	// function to return element with highest priority (present at root)
	int top()
	{
		try {
			// if heap has no elements, throw an exception
			if (size() == 0)
				throw out_of_range("Vector<X>::at() : "
						"index is out of range(Heap underflow)");

			// else return the top (first) element
			return A.at(0);	// or return A[0];
		}
		// catch and print the exception
		catch (const out_of_range& oor) {
			cout << "\n" << oor.what();
		}
	}
};

// Max Heap C++ implementation
int main()
{
	PriorityQueue pq;

  string operacao; int valor;
  while(cin >> operacao){
    if (operacao == "insert"){
      cin >> valor;
      pq.push(valor);
    } else if (operacao == "extract"){
      cout << pq.top() << endl;
      pq.pop();
    } else {
      break;
    }
  }
	return 0;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string n;cin>>n;
  string ans="ABC"+n;
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const inputs = input.trim().split('\n');

const COLORS = ['r','g','b'];
class Worm {
  constructor(id, depth) {
    this.id = id;
    this.depth = depth;
    this.colors = id.split('');
  }
  getNextWormIds() {
    const nextWormIds = [];
    for (let i = 0; i < this.colors.length - 1; i++) {
      const [ current, next ] = this.colors.slice(i, i + 2);
      if (current === next) {
        continue;
      }
      const changed = COLORS.filter(s => s !== current && s !== next)[0];
      const changedColors = this.colors.slice(); // copy
      changedColors.splice(i, 2, changed, changed); // 置き換え
      nextWormIds.push(changedColors.join(''));
    }
    return nextWormIds;
  }
}

class Graph {
  constructor() {
    this.map = new Map();
  }
  has(id) {
    return this.map.has(id);
  }
  get(id) {
    return this.map.get(id);
  }
  set(id, depth) {
    this.map.set(id, new Worm(id, depth));
  }
  bfs(wormId) {
    this.queue = [];
    this.map.set(wormId, new Worm(wormId, 0));
    this.queue.push(wormId);
    while(this.queue.length) {
      const wormId = this.queue.shift();
      const worm = this.map.get(wormId);
      const wormIds = worm.getNextWormIds();
      if (!wormIds.length) {
        return worm;
      }
      wormIds.forEach(wormId => {
        if (this.map.has(wormId)) {
          return;
        }
        this.map.set(wormId, new Worm(wormId, worm.depth + 1));
        this.queue.push(wormId);
      })
    }
  }
}

inputs.forEach(wormId => {
  if (wormId === '0') {
    return;
  }
  const graph = new Graph();
  const worm = graph.bfs(wormId);
  console.log(worm ? worm.depth : 'NA');
});



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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> dp(n+k, 1e9), h(n);
    for(int i=0; i<n; i++) cin >> h[i];
    
    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int j=1; j<=k; j++){
            if(i+j < n) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;



string S;

ll N;



bool isOK(ll index, ll key) {
	if (index*index<=key)return true;//ここの配列名を適宜変えよう！
	else return false;
}



ll binary_search(ll key) {

	ll left = 1, right =  1e9+1;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(mid, key))left = mid;
		else right = mid;
	}
	return right;
}


int main() {
	cin >> N;
	if (N == 1e18)cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
	else {
	ll KEY = binary_search(N);
	cout << 0 << " " << 0 << " " << KEY << " " << 1 << " " << KEY * KEY - N << " " << KEY << endl;
}

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author himkha_100
 */

#include <bits/stdc++.h>

#define MOD 1000000007
#define INFI 1e15
#define INFIM 1e18
#define ll long long int
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define pb push_back
#define f(t) for(int i=0;i<t;i++)
#define fi first
#define se second
#define all(t) t.begin(),t.end()
#define ci(t) cin>>t
#define co(t) cout<<t
#define mii map<int,int>
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
struct node{
    int val;
    int pos;
};
bool ac(int x,int y)
{
    return x>y;
}
class DRGBTriplets {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        string s;
        cin>>s;
        vector<int> r,g,b;
        f(n) {
            if(s[i]=='R') r.pb(i);
            if(s[i]=='G') g.pb(i);
            if(s[i]=='B') b.pb(i);
        }
        ll ans=0;
        for(int i=0;i<n;i++) {
            for(int j=i+1;j<n;j++) {
                if(s[i]==s[j]) continue;
                int f1=0, f2=0, f3=0;
                if(s[i]=='R' || s[j]=='R') f1=1;
                if(s[i]=='G' || s[j]=='G') f2=1;
                if(s[i]=='B' || s[j]=='B') f3=1;
                if(f1==0) {
                    int e = upper_bound(all(r), j)-r.begin();
                    e=r.size()-e;
                    if(binary_search(all(r),j+(j-i))) {
                        e--;
                    }
                    ans+=e;
                }
                if(f2==0) {
                    int e = upper_bound(all(g), j)-g.begin();
                    e=g.size()-e;
                    if(binary_search(all(g),j+(j-i))) {
                        e--;
                    }
                    ans+=e;
                }if(f3==0) {
                    int e = upper_bound(all(b), j)-b.begin();
                    e=b.size()-e;
                    if(binary_search(all(b),j+(j-i))) {
                        e--;
                    }
                    ans+=e;
                }
            }
        }
        cout<<ans<<endl;
	}
};

int main() {
	DRGBTriplets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	double x1,x2,y1,y2,x,y,z;
	cin>>x1>>y1>>x2>>y2;
	x=x2-x1;
	y=y2-y1;
	x *=x;
	y *=y;
	z=sqrt(x+y);
	printf("%lf\n",z);
	return 0;
}

Measured memory_bytes: 1236
MOD = 998244353

N = int(input())

ans = pow(3, N, MOD)

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs

def getCombNs(n, invs, MOD):
    combNs = [1] * (n//2+1)
    for x in range(1, n//2+1):
        combNs[x] = (combNs[x-1] * (n-x+1) * invs[x]) % MOD
    return combNs + combNs[:(n+1)//2][::-1]

invs = getInvs(N, MOD)
combNs = getCombNs(N, invs, MOD)

pow2 = 1
for i in range((N-1)//2+1):
    num = combNs[i] * pow2
    ans -= num*2 % MOD
    ans %= MOD
    pow2 *= 2
    pow2 %= MOD

print(ans)


Measured memory_bytes: 778228
def main():
    from sys import stdin, stdout
 
    def read():
        return stdin.readline().rstrip('\n')
 
    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)
 
    def read_int():
        return int(read())
 
    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]
 
    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)
 
    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)
 
    n = read_int()
    b_starts = 0
    a_ends = 0
    both = 0
    count = 0
 
    for i in range(n):
        word = read().strip()
        for i in range(1, len(word)):
            if word[i-1] == 'A' and word[i] == 'B':
                count += 1
 
        if word[0] == 'B' and word[-1] == 'A':
            both += 1
        elif word[-1] == 'A':
            a_ends += 1
        elif word[0] == 'B':
            b_starts += 1
 
    if a_ends > 0 and b_starts > 0:
        count += both + 1
        a_ends -= 1
        b_starts -= 1
    elif a_ends > 0:
        count += both
        a_ends -= 1
    elif b_starts > 0:
        count += both
        b_starts -= 1
    elif both:
        count += both - 1
    count += min(a_ends, b_starts)
 
    write(count)
 
main()


Measured memory_bytes: 43060
def solve(h, w, k, C):
    total = 0
    for r in range(h):
        for c in range(w):
            if C[r][c] == "#":
                total += 1
    ans = 0
    for mask in range(1<<(h+w)):
        num = 0
        for r in range(h):
            for c in range(w):
                ok = ((mask & (1<<c)) or (mask & (1<<(w+r)))) and (C[r][c] == "#")
                if ok:
                    num += 1
        if total - num == k:
            ans += 1
    return ans

h, w, k = map(int, input().split())
C = [input() for r in range(h)]
print(solve(h, w, k, C))

Measured memory_bytes: 9164
#include<stdio.h>

main(){
    int a,b,i,j=0,c[10000];
    char op;
    for(i=0;i<10000;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        if(op=='+'){
            c[i]=a+b;
        }else if(op=='-'){
            c[i]=a-b;
        }else if(op=='*'){
            c[i]=a*b;
        }else if(op=='/'){
            c[i]=a/b;
        }
		j++;
     }
	for (i = 0;i < j;i++) {
		printf("%d\n", c[i]);
	}
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
int go(int i,int n)
{
    int last_number=n/i;
    last_number=last_number*i;
    int nott=(last_number-i)/i;
    nott+=1;
    int ans=(nott*(i+last_number))/2;
    return ans;
}
signed main()
{
    fastio;
    R(n);
    int ans=0;
    fr(i,1,n+1)
    {
        ans+=go(i,n);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>

int main()
{
  ll a,b,x,y;
  cin>>x>>y;
  ll ans=1;
  if(y%2==1)
    ans=0;
  if(y<2*x)
    ans=0;
  if(4*x<y)
    ans=0;
  
  if(ans==0)
    cout<<"No"<<endl;
  else
   	cout<<"Yes"<<endl; 
 
}


Measured memory_bytes: 3584
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    int n;
    ll ans=0;
    cin>>n;
    string s;
    map<string, ll> mp;
    rep(i,0,n){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto ite=mp.begin();ite!=mp.end();ite++){
        auto cn=*ite;
        ans+=cn.second*(cn.second-1)/2;
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  string S, T;
  cin >> S >> T;
  vector<int> sumS(S.size() + 1), sumT(T.size() + 1);
  for (int i = 0; i < S.size(); i++) {
    sumS[i + 1] = (sumS[i] + (S[i] == 'A' ? 1 : 2)) % 3;
  }
  for (int i = 0; i < T.size(); i++) {
    sumT[i + 1] = (sumT[i] + (T[i] == 'A' ? 1 : 2)) % 3;
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b; --c; --d;
    int s = (sumS[b + 1] - sumS[a] + 3) % 3; 
    int t = (sumT[d + 1] - sumT[c] + 3) % 3;
    cout << (s == t ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
int n;
vector <int> g[N];
pair <int, int> dfs(int u, int p) {
    pair <int, int> ans = {0, u};
    for (int v : g[u]) {
        if (v != p) {
            auto t = dfs(v, u); ++t.first;
            ans = max(ans, t);
        }   
    }   
    return ans;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v); g[v].push_back(u);
    }       
    auto t1 = dfs(0, 0);
    auto t2 = dfs(t1.second, t1.second);
    int d = t2.first + 1;
    if (d % 3 <= 1) {
        cout << "First\n";
    }   
    else {
        cout << "Second\n";
    }   
}  

Measured memory_bytes: 26880
import sys
N,M = map(int,input().split())

ans = []

q = []

for i in range(1,M+1):

    if i % 2 == 1:
        q.append(N-i)
    else:
        q.append(i)

q.sort()
ind = 0
q.reverse()
q.append(float("inf"))
ind = 0

use = [True] * (N+1)

cnt = 0
for i in range(1,N//2+1):

    if use[i + q[ind]]:
        print (i , i+q[ind])
        ind += 1
        cnt += 1

    if cnt == M:
        sys.exit()


Measured memory_bytes: 13892
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()

min_ = 0
for i in range(K):
    min_ += i

max_ = 0
for i in range(K):
    max_ += N-i

ans = max_-min_+1
last_max = max_
for i in range(K+1,N+2):
    min_ += i-1
    max_ += N-i+1
    ans += max_-min_+1
    ans %= mod

print(ans)

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

int main() {
  string w;
  cin >>w;
  vector<char>S(w.size());
  for(int i=0; i<w.size(); i++){
    S.at(i)=w.at(i);
  }
  sort(S.begin(), S.end());
  
  string ans="Yes";
  for(int i=1; i<w.size()/2; i+=2){
    if(S.at(i)!=S.at(i-1))ans="No";
  }
  if(w.size()%2==1)ans ="No";
  
  cout << ans <<endl;
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];
ll path[ten52];

int main(void)
{
    //double ans=0.0,d,d1,d2;
    long long int m,n,i,j,k=0,h,save;
    long long int a,a1,a2,a3,sum,sum2,sum1;
    string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    ll h1,h2,m1,m2;
    cin>>h1>>m1>>h2>>m2>>k;
    sum1=h1*60+m1;
    sum2=h2*60+m2;
    if(sum2>sum1)
    {
        a=sum2-sum1;
        if(a>k)
            cout<<a-k;
        else
            cout<<0;
    }
    else if(sum2==sum1) cout<<0;
    else
    {
        a=sum2+1440-sum1;
        if(a>k) cout<<a-k;
        else cout<<0;

    }
    return 0;
}





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

int main(void)
{
    long long int L, R;
    std::cin >> L >> R;

    int ans = 2018;
    for(long long int i = L; i < R; i++)
    {
        for(long long int j = i + 1; j <= R; j++)
        {
            int res = (i * j) % 2019;
            ans = std::min(ans, res);

            if(ans == 0)
            {
                i = R;
                j = R + 1;
            }
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
 using namespace std;
 int main(){
 int N,T;
 cin>>N>>T;
 int m=99999;
 for(int i=0;i<N;i++)
 {
 	int c,t;
 	cin>>c>>t;
 	if(T>=t)
 	{
	 m=min(c,m);
	}
  } 
  if(m==99999)
  cout<<"TLE"<<endl;
  else
  cout<<m<<endl;
 return 0; 
  }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>

using namespace std;

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

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return (0);
        }
    }

    cout << "NG" << endl;

}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h> 
#include<string.h>
int main(){
	char a[300];
	scanf("%s",a);
	int t = strlen(a);
	for(int i = t/2-1;i>=1;i--){
	//	printf("%d\n",i);
		int flag = 0;
		for(int j = 0;j<i;j++){
			if(a[j]!=a[i+j]){
				flag = 1;
			}
		}
		if(flag==0){
			printf("%d\n",i*2);
			break;
		}
	}
	
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,i;
    cin>>a>>b>>c;
    i=0;
    while(1){
    if(1000==c){
        if(a>=b*2){i=i+b*2;c=c-1000;}
        else {i=i+a;c=c-1000;}
    }
    else if(c>=1000){
    if(a>=b*2){i=i+b*2;c=c-1000;}
    else {i=i+a;c=c-1000;}}
    else if(c>500){
        if(a>=b*2){i=i+b*2;c=c-1000;}
    else {i=i+a;c=c-1000;}}
    else if(c<=500){if(a>=b){i=i+b;c=c-500;}else{i=i+a;c=-1000;}}
    if(c<=0){break;}
    }
    cout<<i<<endl;
}



Measured memory_bytes: 3112
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):
    count = 0
    for i in range(1, n-1):
        if p[i-1] <= p[i] and p[i] <= p[i+1]:
            count += 1
        elif p[i+1] <=p[i] and p[i] <= p[i-1]:
            count += 1
    print(count)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n,q = map(int, input().split())

A = []

for i in range(n):
  A.append(input())

i = 0

time = 0

while not A == []:
  x,y = map(str, A[i].split())
  y = int(y)
  if y <= q:
    time += y
    times = str(time)
    A[i] = x + " " + times
    print(A.pop(i))
  else:
    z = y-q
    z = str(z)
    time += q
    A.append(x + " " + z)
    del A[i]


Measured memory_bytes: 9264
#include <iostream>
#include <string>
#include <set>
using namespace std;

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

    set<int> pas;
    int cnt = 0;
    for (int i = 0; i < 1000; i++) {
        string tmp;
        if (i < 10) tmp = "00" + to_string(i);
        else if (i < 100) tmp = '0' + to_string(i);
        else tmp = to_string(i);

        int idx = 0;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == tmp[idx]) idx++;
            if (idx == 3) {
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
    // for (int i = 0; i < s.size()-2; i++) {
    //     for (int j = i + 1; j <=s.size()-1; j++) {
    //         for (int k = j + 1; k < s.size(); k++) {
    //             // cout << (s[i] - '0')*100 + (s[j] - '0')*10 + (s[j] - '0') << endl;
    //             pas.insert((s[i] - '0')*100 + (s[j] - '0')*10 + (s[k] - '0'));
    //         }
    //     }
    // }

    // cout << pas.size() << endl;

}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] aggs){

	Scanner stdIn = new Scanner(System.in);
	int D = stdIn.nextInt();
	int T = stdIn.nextInt();
	int S = stdIn.nextInt();

	if(D<=T*S) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}

	}
}


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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize,
    }
    println!("{}",
        if x < 1200 { "ABC" } else { "ARC" });
}


Measured memory_bytes: 4352
import collections

def test():
    n = int(input())
    a = [int(input()) for i in range(n)]
    b = collections.Counter(a)
    ans = 0
    for i in b.values():
        if i % 2 != 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    test()


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h),ans(h);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans[i].push_back('0');
        }
    }
    for(int i=0;i<h;i++){
        cin>>a[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i].at(j)=='#'){
                ans[i].at(j)='#';
                if(j>0){
                   ans[i].at(j-1)++;
                }
                if(j<w-1){
                   ans[i].at(j+1)++;
                }
                if(i>0){
                    if(j>0){
                      ans[i-1].at(j-1)++;
                    }
                    ans[i-1].at(j)++;
                    if(j<w-1){
                        ans[i-1].at(j+1)++;
                    }
                }

                if(i<h-1){
                   if(j>0){
                      ans[i+1].at(j-1)++;
                    }
                   ans[i+1].at(j)++;
                   if(j<w-1){
                      ans[i+1].at(j+1)++;
                    }
                }
            }             
        }

    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans.at(i).at(j)<'0'||'9'<ans.at(i).at(j)){
                ans.at(i).at(j)='#';
            }
        }
    }
    for(int i=0;i<h;i++){
        cout<<ans[i]<<endl;
    }
}

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

int main(){
    double N,K;
    scanf("%lf %lf",&N,&K);
    int cnt=0;
    if(N < K){
        printf("1");
    }else{
        while(N >= 1){
            cnt++;
            N /= K;
        }
        printf("%d",cnt);
    }

    return 0;
}

Measured memory_bytes: 128
while True:
    n,x = map(int,input().split())

    if n == 0 and x ==0 :
        break
    t=0
    for i in range(n,2,-1):
        for j in range(n-1,1,-1):
            if i >j:
                for k in range(n-2,0,-1):
                    if j > k:
                        if i+j+k == x:
                            t += 1
    print(t)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define pii pair<int,int>

using namespace std;
using ll  = long long;

const int N = 100002;

vector<int>graph[N];
bitset<N>vis;
int dp[N],n,m,a,b;

int call(int u)
{
    //dp[u] = 1;
    vis[u] = 1;
    for(int v: graph[u]){
        if(!vis[v]){
            dp[u] = max(dp[u],call(v));
        }
        else dp[u] = max(dp[u],dp[v]);
    }
    dp[u]++;
    return dp[u];
}

int main(int argc, char const *argv[])
{
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m;i++){
        scanf("%d %d",&a,&b);
        graph[a].push_back(b);
    }
    int ans = 0;
    for(int i = 1; i <= n;i++){
        if(!vis[i])ans = max(ans,call(i));
    }

    printf("%d\n",ans-1);

    
    return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
const int maxn = 1e6;
double a[maxn];
int main()
{
    double n,k;
    scanf("%lf%lf",&n,&k);
    for(int i = 1; i <= n; i++)
        scanf("%lf",&a[i]);
        double ans = ceil((n-k)/(k-1)) + 1;
        printf("%0.lf\n",ans);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define ppb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
#define endl '\n'
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
	string s; cin >> s;
	bool flag = 0;
	for (int i = 0; i < 3; i++)
		if (s[i] == s[i + 1]) flag = true;
	if (flag) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256