akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll H, W, K;
  cin >> H >> W >> K;
  vector<vector<bool>> B(H, vector<bool>(W));
  for (ll i = 0; i < H; i++)
  {
    for (ll j = 0; j < W; j++)
    {
      char c;
      cin >> c;
      B.at(i).at(j) = (c == '1');
    }
  }

  ll ans = INF;
  for (ll b = 0; b < (1LL << (H - 1)); b++)
  {
    bitset<9> bi = b;
    ll tmp = 0;

    vector<vector<ll>> A;
    A.push_back(vector<ll>(W, 0));
    for (ll j = 0; j < W; j++)
    {
      A.back().at(j) += B.at(0).at(j);
    }

    for (ll i = 0; i < H - 1; i++)
    {
      if (bi.test(i))
      {
        A.push_back(vector<ll>(W, 0));
        tmp++;
      }

      for (ll j = 0; j < W; j++)
      {
        A.back().at(j) += B.at(i + 1).at(j);
      }
    }

    ll h = A.size();
    vector<ll> cnt(h, 0);
    for (ll j = 0; j < W; j++)
    {
      bool cut = false;
      for (ll i = 0; i < h; i++)
      {
        cnt.at(i) += A.at(i).at(j);
        if (cnt.at(i) > K)
        {
          cut = true;
          break;
        }
      }
      if (cut)
      {
        for (ll i = 0; i < h; i++)
        {
          cnt.at(i) = A.at(i).at(j);

          if (cnt.at(i) > K)
            goto FIN;
        }

        tmp++;
      }
    }

    chmin(ans, tmp);
    FIN:{}

    /*
    cerr << endl;
    cerr << tmp << endl;
    for (ll i = 0; i < h; i++)
    {
      for (ll j = 0; j < W; j++)
      {
        cerr << A.at(i).at(j) << " ";
      }
      cerr << endl;
    }
    //*/
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while (cur != nil && cur->key != key){
      cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if ( cur == nil ) break;
    if ( isf++ > 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
    if (t==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	   deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 33820
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
#define tm tadsadaagsd
#define next nqweqweeqeqe
#define er erase
#define int ll

using namespace std;
//using namespace __gnu_pbds;

//template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e3 + 40, T = 4 * N, logN = (int)log2(N) + 2, inf = 1e9 + 7, sx[4] = {1, -1, 0, 0}, sy[4] = {0, 0, 1, -1};

int n, m, r, l, e, o, z, ts, id, mx, mn = inf, w;
vector < int > g[N];
queue < pair < int, int > > q;
bool us[N];
int d[N][N], a[N];
int f;

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int bp (int x, int y) {
	if (y == 0) return 1;
	if (y % 2 == 1) return bp(x, y - 1) * x;
	else
    {
		int asd = bp(x, y / 2);
		return asd * asd;
	}
}

main()
{
    int x, y;
    setprecision(9);
    //freop();
    boos();
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            d[i][j] = inf;
        }
    }
    g[x].pb(y);
    g[y].pb(x);
    for (int i = 1; i < n; i++)
    {
        g[i].pb(i + 1);
        g[i + 1].pb(i);
    }
    for (int i = 1; i <= n; i++)
    {
        memset(us, 0, sizeof us);
        q.push({i, 0});
        while (q.ss)
        {
            int v = q.front().fi;
            int wa = q.front().se;
            q.pop();
            d[i][v] = min(wa, d[i][v]);
            d[v][i] = min(wa, d[v][i]);
            us[v] = 1;
            for (int j = 0; j < g[v].ss; j++)
            {
                int to = g[v][j];
                if (us[to]) continue;
                q.push({to, wa + 1});
                us[to] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i == j) continue;
            a[d[i][j]]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        cout << a[i] / 2 << " ";
    }
}


Measured memory_bytes: 32256
#include<iostream>
using namespace std;
int main() {
	int n, x, i, j, k, sum;
	cin >> n >> x;
	while (n != 0 || x != 0) {
		sum = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						sum++;
					}
				}
			}
		}
		cout << sum << endl;
		cin >> n >> x;
	}
	
	
	return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, i; cin >> n >> i;
  cout << n - i + 1 << endl;

  return 0;
}




//


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BTravelingAtCoDeerProblem {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }
	    sort(a.begin(), a.end());
	    out << a[n-1] - a[0] << endl;
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < S.size(); ++i) {
    if (i % 2 == 0 && S[i] != 'h' || i % 2 == 1 && S[i] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
      

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))

dp=[float('inf') for i in range(n)]

dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
 dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

int n = in(), k = in();
vector<int> a(n);
vector<int> fact(n + 1, 1);

const int mod = 1e9 + 7;

int dp[110][256][110];
int dfs(int idx = 0, int xsum = 0, int cnt = 0) {
  if (idx == n) {
    return (xsum == k) * fact[cnt];
  }

  int &res = dp[idx][xsum][cnt];
  if (~res) return res;

  return res = (dfs(idx + 1, xsum, cnt) + dfs(idx + 1, xsum ^ a[idx], cnt + 1)) % mod;
}

signed main(int argc, char *argv[]) {
  cin >> a;
  for (int i = 1; i <= n; ++i) {
    fact[i] = 1ll * fact[i - 1] * i % mod;
  }

  memset(dp, -1, sizeof(dp));

  cout << dfs() << endl;
}


Measured memory_bytes: 12416
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int count = 0;
	int point = 0;
	long long int total = 1;
	int a[100001];

	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
	}
	sort(a, a + n + 1);
	if (n % 2 == 0) {
		point = 1;
		FOR(i, 1, n) {
			if (a[i] == point&&a[i + 1] == point) {
				count++;
				point += 2;
				i++;
			}
			else {
				count = 0;
				break;
			}
		}
	}
	else {
		point = 0;
		if (a[1] == point) {
			point = 2;
			count = -1;
			FOR(i, 2, n) {
				if (i == 2) {
					count = 0;
				}
				if (a[i] == point&&a[i + 1] == point) {
					count++;
					point += 2;
					i++;
				}
				else {
					count = 0;
					break;
				}
			}
		}
		else {
			count = 0;
		}
	}
	FOR(i, 1, count) {
		total *= 2;
		if (total > MOD) {
			total %= MOD;
		}
	}
	if (count == 0) {
		total = 0;
	}
	if (count == -1) {
		total = 1;
	}

	cout << total << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 7)

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = map(int, input().split())
comb = Combination(N + K)
MOD = 10**9 + 7

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

def dfs(now, pr):
    ret = 1

    cnt = 0
    for to in edges[now]:
        if to == pr:
            continue
        cnt += 1
        ret = (ret * dfs(to, now)) % MOD

    color = K - 1 if pr == -1 else K - 2
    ret = (ret * comb.npr(color, cnt)) % MOD

    return ret

print(dfs(0, -1) * K % MOD)


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

using namespace std;

#define MAX 15
#define INF 1e9

int N,M,light,swt[MAX];
vector<int> G[MAX];

void init(){
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
    swt[i] = 0;
  }
}

struct State{
  int v,l;
  State(){}
  State(int v,int l) : v(v),l(l) {}
};

void solve(){
  int d[MAX][1<<MAX];
  State path[MAX][1<<MAX];
  fill(d[0],d[0]+MAX*(1<<MAX),INF);

  bool found = false;
  d[0][light] = 0;
  queue<State> Q;
  Q.push(State(0,light));
  while(!Q.empty()){
    State s = Q.front(); Q.pop();
    int v = s.v;
    if(v == N-1 && s.l == (1<<(N-1))){
      found = true;
      break;
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(d[v][s.l] + 1 < d[to][s.l] && (s.l >> to & 1)){
        d[to][s.l] = d[v][s.l] + 1;
        path[to][s.l] = s;
        Q.push(State(to,s.l));
      }
    }
    for(int i = 0 ; i < N ; i++){
      if(i == v){ continue; }
      if(swt[v] >> i & 1){
        int nl = s.l;
        if(s.l >> i & 1){
          nl -= (1<<i);
        }else{
          nl |= (1<<i);
        }
        if(d[v][s.l] + 1 < d[v][nl]){
          d[v][nl] = d[v][s.l] + 1;
          path[v][nl] = s;
          Q.push(State(v,nl));
        }
      }
    }
  }
  if(found){
    cout << "You can go home in " << d[N-1][1<<(N-1)] << " steps." << endl;
    int v = N-1,l = 1<<(N-1);
    vector<State> vec;
    vec.push_back(State(N-1,(1<<(N-1))));
    while(true){
      if(v == 0 && l == light){ break; }
      State next = path[v][l];
      vec.push_back(next);
      v = next.v; l = next.l;
    }
    reverse(vec.begin(),vec.end());
    int size = vec.size();
    for(int i = 0 ; i < size-1 ; i++){
      State cs = vec[i],ns = vec[i+1];
      if(cs.v == ns.v){
        int j;
        bool on = false, off = false;
        for(j = 0 ; j < N ; j++){
          if((cs.l >> j & 1) && !(ns.l >> j & 1)){
            off = true;
            break;
          }
          if(!(cs.l >> j & 1) && (ns.l >> j & 1)){
            on = true;
            break;
          }
        }
        if(on){
          cout << "Switch on room " << j+1 << "." << endl;
        }else if(off){
          cout << "Switch off room " << j+1 << "." << endl;
        }
      }else{
        cout << "Move to room " << ns.v+1 << "." << endl;
      }
    }
  }else{
    for(int i = 0 ; i < (1<<N) ; i++){
      if(d[N-1][i] != INF){
        cout << "You can not switch off all lights." << endl;
        return;
      }
    }
    cout << "Help me!" << endl;
  }
}

int main(){
  int s,t,k,r;
  while(cin >> N >> M, (N | M)){
    init();
    for(int i = 0 ; i < M ; i++){
      cin >> s >> t; s--; t--;
      G[s].push_back(t);
      G[t].push_back(s);
    }
    int x;
    light = 0;
    for(int i = 0 ; i < N ; i++){
      cin >> x;
      if(x == 1){ light |= (1<<i); }
    }
    for(int i = 0 ; i < N ; i++){
      cin >> k;
      for(int j = 0 ; j < k ; j++){
        cin >> r; r--;
        swt[i] |= (1<<r);
      }
    }
    solve();
  }
  return 0;
}

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

int main() {
  int n;
  double ans=0;
  cin >> n;
  vector<pair<double,string>> money(n);
  for(int i=0;i<n;i++){
  cin >> money[i].first >> money[i].second;
  }
  for(int i=0;i<n;i++){
  if(money[i].second=="JPY"){
  ans+=money[i].first;
  }
  else{
  ans+=(money[i].first)*380000.0;
  }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		System.out.println(Math.min(A * N, B));
	}
}

Measured memory_bytes: 22228
#include <stdio.h>
int main(){
int a, b, c, d;
  scanf("%d %d",&a, &b);
  scanf("%d %d",&c, &d);
  
  if(a == c){
    printf("%d\n",0);
  }
  
  else {
    printf("%d\n",1);
  }
  
  return 0;
}

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

int main(){
	char pattern;
	int n, val;
	bool card[4][13] = {false};
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> pattern >> val;
		if(pattern == 'S') {
			card[0][val - 1] = true;
		} else if(pattern == 'H') {
			card[1][val - 1] = true;
		} else if(pattern == 'C') {
			card[2][val - 1] = true;
		} else if(pattern == 'D') {
			card[3][val - 1] = true;
		}
	}
	for(int j = 0; j < 4; ++j) {
		for(int i = 0; i < 13; ++i) {
			if((j == 0) && (card[j][i] == false)) {
				cout << "S " << i + 1 << endl;
			} else if((j == 1) && (card[j][i] == false)) {
				cout << "H " << i + 1 << endl;
			} else if((j == 2) && (card[j][i] == false)) {
				cout << "C " << i + 1 << endl;
			} else if((j == 3) && (card[j][i] == false)) {
				cout << "D " << i + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3096
import math

def main():
    n,d=map(int,input().split())
    x=[]
    for _ in range(n):
        x.append(list(map(int,input().split())))
    count = 0
    for ai in range(len(x)-1):
        for bi in range(ai+1, len(x)):
            a = x[ai]
            b = x[bi]
            dist = 0
            for i, v in enumerate(a):
                dist += (v - b[i])**2
            dist = math.sqrt(dist)
            #print("d", dist)
            if dist.is_integer():
                #print(a, b)
                count += 1
    print(count)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
vector<int> G[1000005];
void dfs(const int &v, const int &par, int a, vector<int> &dist) {
	dist[v] = a;
	for (auto nv : G[v]) {
		if (nv != par) dfs(nv, v, a + 1, dist);
	}
	return;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, u, v;
	cin >> n >> u >> v;
	u--, v--;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> d1(100005), d2(100005);
	dfs(u, -1, 0, d1);
	dfs(v, -1, 0, d2);
	int p = 0;
	rep(i, n) {
		if (d1[i] < d2[i]) p = max(p, d2[i]);
	}
	cout << p - 1 << endl;
	return 0;
}

Measured memory_bytes: 36972
n = int(input())
a = [0] + list(map(int, input().split())) + [0]


total = sum(abs(a[i+1]-a[i]) for i in range(n+1))
for i in range(1, n+1):
    print(total + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]))


Measured memory_bytes: 65516
import numpy as np

N,W = map(int,input().split())
item = []
V_MAX = 0
for _ in range(N):
    w, v = map(int,input().split())
    V_MAX += v
    item.append([w,v])
dp = np.array([float('inf')]*(V_MAX+1))
dp[0] = 0
pos = np.array([0]*(V_MAX+1))
pos[0] = 1
for w,v in item:
    dp = np.minimum(dp, np.concatenate([np.array([np.inf]*v),np.roll(dp,v)[v:]]) + np.dot(np.concatenate([np.zeros(v),np.roll(pos,v)[v:]]),w))
    pos = (pos + np.concatenate([np.zeros(v),np.roll(pos,v)[v:]]))
    pos[pos > 0] = 1
res = 0
for i in range(V_MAX + 1):
    if dp[i]<=W and res < i : res = i
print(res)

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    long long n;
    cin >> n;

    long long best_sum = INTMAX_MAX;

    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            best_sum = min(best_sum, i + (n / i));
        }
    }
    cout << best_sum - 2;
}


Measured memory_bytes: 3624
n=int(input())
l=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
for i in range(n):
    if (i+1<n):
        dp[i+1]=min(dp[i+1],dp[i]+abs(l[i+1]-l[i]))
    if (i+2<n):
        dp[i+2]=min(dp[i+2],dp[i]+abs(l[i+2]-l[i]))
print(dp[n-1])  

Measured memory_bytes: 13924
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() {

    string s;
    int Max = 0;
    int n;
    int x = 0;
    cin >> n >> s;
    for(int i = 0; i < n; i ++){
        if(s[i] == 'I') x ++;
        if(s[i] == 'D') x --;
        Max = max(x,Max);
    }
    cout << Max;
    return 0;
}

Measured memory_bytes: 3600
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    s=sum(A)
    if N>=s:
        print(N-s)
    else:
        print(-1)

resolve()

Measured memory_bytes: 67976
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, a;
    cin >> n >> a;
    if (n % 500 <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S;cin>>S;

    int minD=INT_MAX;
    rep(i,0,S.size()-2){
        string subS="";
        subS.append(1,S.at(i));
        subS.append(1,S.at(i+1));
        subS.append(1,S.at(i+2));
        minD=min(minD,abs(753-stoi(subS)));
    }

    cout<<minD<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    int ans = min(a + b, b + c);
    ans = min(ans, c + a);
    cout << ans << endl;
    return 0;
}

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

bool solve(string S){
  bool cexists = false;
  for(int i = 0; i < (int)S.size(); i++){
    if(i == 0){
      if(S[i] != 'A'){
        return false;
      }
    } else if(i < 2){
      if(!islower(S[i])){
        return false;
      }
    }else if(i < (int)S.size() - 1){
      if(S[i] == 'C'){
        if(cexists == false){
          cexists = true;
        }else{
          return false;
        }
      }else if(!islower(S[i])){
        return false;
      }
    }else if(i == (int)S.size() - 1){
      if(!islower(S[i])){
        return false;
      }
    }
  }
  return cexists;
}

int main(void){
  string S;
  cin >> S;
  if(solve(S)){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200100
using namespace std;
vector<int> g[N];
vector<int> v[3];
int c[N],ans[N];
bool used[N];
void DFS(int u,int cc){
	v[cc].push_back(u);
	c[u]=cc;
	for(int i=0;i<g[u].size();i++){
		if(!c[g[u][i]]) DFS(g[u][i],3-cc);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	DFS(1,1);
	int mc=1,cur=1;
	if(v[2].size()<v[1].size()) mc=2;
	if(n/3>=v[mc].size()){
		for(int i=0;i<v[mc].size();i++){
			ans[v[mc][i]]=(i+1)*3;
			used[(i+1)*3]=true;
		}
		for(int i=0;i<v[3-mc].size();i++){
			while(used[cur]) cur++;
			used[cur]=true;
			ans[v[3-mc][i]]=cur;
		}
	}
	else{
		for(int j=1;j<=2;j++){
			for(int k=j;k<=n;k+=3){
				ans[v[j][k/3]]=k;
				used[v[j][k/3]]=true;
			}
		}
		for(int j=3;j<=n;j+=3){
			while(used[cur]) cur++;
			used[cur]=true;
			ans[cur]=j;
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 19956
n, k=map(int, input().split())
s=input()
u=s+s[::-1]
ans=min(u[i:i+n] for i in range(n+1))
c=ans[0]
i=min(i for i in range(n) if c!=ans[i])
h=(i<<min(k-1, 13))
ret=(h*c+ans[i:i+n-h])[:n]
print(ret)

Measured memory_bytes: 9076
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

char s[100017];

void solve(){
    int len=strlen(s);
    if(len<2){
        printf("-1 -1\n");
        return ;
    }
    for(int i=0;i<len;i++){
        if(s[i]==s[i+1]){
            printf("%d %d\n",i+1,i+2);
            return ;
        }else if(s[i]==s[i+2]){
            printf("%d %d\n",i+1,i+3);
            return ;
        }
    }
    printf("-1 -1\n");
        return ;
}

int main(){
    memset(s,0,sizeof(s));
    scanf("%s",s);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    
    vector<int> c(n); for(int i = 0; i < n; i++) { cin >> c[i]; }
    
    for(int i = 1; i <= 100000000; i++)
    {
        bool ok = true;
        
        for(int j = 0; j < n; j++)
        {
            if(c[j] % i != 0)
            {
                ok = false;
            }
        }
        
        if(ok) { cout << i <<endl; }
    }
    
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

ll n, ans;
string s;
map<pair<string, string>, ll> mp;

void f(int p) {
	ll i, j;
	for(i=0; i<1<<n; i++) {
		string r, b;
		for(j=0; j<n; j++) {
			if(i & 1<<j) r.push_back(s[j]);
			else b.push_back(s[j]);
		}
		p<1 ? mp[{r,b}]++ : ans += mp[{r,b}];
	}
}

int main() {
	cin >> n >> s;
	f(0);
	reverse(s.begin(), s.end());
	f(1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 91904
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
long long D[100010];
int cnt[100010];
int ansu[100010], ansv[100010];
int idx[100010];
long long Dv[100010];

int bsrch(int ll, int rr, long long vv)
{
	int l=ll, r=rr;
	int m;
	while(l<r){
		m = (l+r)/2;
		if(D[idx[m]] >= vv){
			r = m;
		}
		else
			l = m+1;
	}
	return l;
}

bool cmp(int aa, int bb)
{
	return D[aa] < D[bb];
}

int solve()
{
	int i, j=0;
	int ii;
	for(i=0; i<N; i++)
		idx[i] = i;
	sort(idx, idx+N, cmp);
	for(ii=N-1; ii>0; ii--){
		i = idx[ii];
		int p = bsrch(0, ii, D[i]-(N-2-cnt[i]*2) );
		if(p>=ii || D[idx[p]]!=D[i]-(N-2-cnt[i]*2) )
			return 0;
		cnt[idx[p]] += cnt[i]+1;
		Dv[idx[p]] += Dv[i] + (cnt[i]+1);
		ansu[j] = idx[p];
		ansv[j] = i;
		j ++;
	}
	if(Dv[idx[0]] != D[idx[0]])
		return 0;
	for(i=0; i<N-1; i++){
		printf("%d %d\n", ansu[i]+1, ansv[i]+1);
	}
	return 1;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%lld", &D[i]);
	if(solve() == 0)
		printf("-1\n");
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

char str1[100][100], str2[100][100];
signed main(){
	int n, m, ans = 0;
	scanf("%lld%lld", &n, &m);
	rep(i,n)scanf("%s", str1[i]);
	rep(i,m)scanf("%s", str2[i]);
	rep(y,n-m+1)rep(x,n-m+1){
		int f = 1;
		rep(i,m)rep(j,m)
		if(str1[y+i][x+j] != str2[i][j])f = 0;
		ans = max(ans, f);
	}
	if(ans)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
/**
 * @author yuichirw
 *
 */
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int a,b,rel,sum;
		String c;

		for(int i = 0; i < 9; i++) {
			c = sc.next(); a = sc.nextInt(); b = sc.nextInt();
			sum = a + b;
			rel = a * 200 + b * 300;
			System.out.println(c + " " + sum + " " + rel);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int N;
ll a[100010][3];
ll dp[100010][3];

int main() {
    int N; cin >> N;
    
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    /*
    REP(i,N+1){
        REP(j,3){
            cout << dp[i][j] << " " ;
        }
        cout << endl;
    }
    */
    cout << res << endl;
}


Measured memory_bytes: 4992
S = input()
T = input()
Ls = [0]*26
Lt = [0]*26
for s in S:
    Ls[ord(s)-97] += 1
for t in T:
    Lt[ord(t)-97] += 1
Ls.sort()
Lt.sort()
if Ls==Lt:
    print("Yes")
else:
    print("No")


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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int mx_cupA = F / (100*A); // 操作１の回数の上限
  int mx_cupB = F / (100*B); // 操作２の回数の上限
  int mx_cupC = (F*E) / ((100+E)*C); // 操作３の回数の上限
  int mx_cupD = (F*E) / ((100+E)*D); // 操作４の回数の上限
  
  int sugared_water = 0, water = 0, sugar = 0;
  int ans_sw = 100 * A, ans_s = 0;
  
  for (int cupA = 0; cupA <= mx_cupA; cupA++) {
    for (int cupB = 0; cupB <= mx_cupB; cupB++) {
      water = 100 * A * cupA + 100 * B * cupB;
      if (water > F) break; // water > max_sugared_water はダメ
      
      for (int cupC = 0; cupC <= mx_cupC; cupC++) {
        for (int cupD = 0; cupD <= mx_cupD; cupD++) {
          sugar = C * cupC + D * cupD;
          if (sugar > (F*E) / (100+E)) break; // sugar > max_sugar はダメ
          
          sugared_water = water + sugar;
          if (sugared_water > F) break; // sugared_water > max_sugared_water はダメ
          
          // conc = sugar / sugared_water;
          // conc <= (E / (100+E)) であってほしい
          if (sugar * (100+E) > E * sugared_water) break;
          
          // ans_conc = ans_s / ans_sw;
          // ans_conc < conc だったら ans_conc = conc
          if (ans_s * sugared_water < ans_sw * sugar) {
            ans_sw = sugared_water;
            ans_s = sugar;
          }
          
        }
      }
      
    }
  }
  cout << ans_sw << " " << ans_s << endl;
  return 0;  
}

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

int main()
{
	int N, Y;
	cin >> N >> Y;

	for ( int i = 0; i <= N; ++i ) {
		for ( int j = 0; j <= N; ++j ) {
			int a = N - ( i + j );
			if ( a < 0 ) continue;

			int total = 10000 * i + 5000 * j + 1000 * a;
			if ( total == Y ) {
				cout << i << " " << j << " " << a;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		for(int i = 0 ; i < N ; i++) {
			for(int j = i + 1 ; j < N ; j++) {
				if(s.charAt(i) == s.charAt(j)) {
					System.out.println("no");
					return;
				}
			}
		}
		System.out.println("yes");
	}
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    int bit = 0;
    string a, b;
    while(q--){
        int ch;
        cin >> ch;
        if(ch == 1){
            bit = 1 - bit;
        }
        else{
            int x;
            char y;
            cin >> x >>y;
            if(x == 1){
                if(bit) b += y;
                else a += y;
            }
            else{
                if(bit) a += y;
                else b += y;
            }
        }
    }
    if(bit){
        reverse(b.begin(), b.end());
        reverse(s.begin(), s.end());
        cout << b + s + a <<endl;
    }
    else{
        reverse(a.begin(), a.end());
        cout << a + s + b << endl;
    }
    return 0;
}


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

typedef long long ll;

using namespace std;
int main()
{
	// Time Complexity: O(NS) Space Complexity: O(S)
	int n, s, mod(998244353);
	cin >> n >> s;
	int a[3000];
	for (int i = 0; i < n; ++i) cin >> a[i];

	ll ans = 0;

	//dp - the sum of left endpoints of all subsequences with weight j that end at i
	vector<ll> dp(s + 1, 0);
	for (int i = 1; i <= n; ++i)
	{
		dp[0]++;
		for (int j=s; j >= a[i-1]; --j)
		{
			dp[j] = (dp[j] + dp[j - a[i-1]]) % mod;
		}
		ans = (ans + dp[s]) % mod;
	}



	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b;

  scanf("%d %d", &a, &b);
  if((a - b) > 0)
    {
      printf("a > b\n");
    }
  else if((a - b) < 0)
    {
      printf("a < b\n");
    }
  else
    {
      printf("a == b\n");
    }

  return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int N;
  string S;
  cin >> N >> S;
  int cnt[26] = {};
  for (int i = 0; i < N; i++)
    cnt[S[i] - 'a']++;
  long long ans = cnt[0] + 1;
  for (int i = 1; i < 26; i++)
    ans = ans * (cnt[i] + 1) % MOD;
  cout << (ans + MOD - 1) % MOD << endl;

  return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		// 県、年でソート
		PriorityQueue<City> city = new PriorityQueue<>(m, new Comparator<City>() {
			@Override
			public int compare(City o1, City o2) {
				if ( o1.pref != o2.pref ) {		// 県でソート
					return o1.pref - o2.pref;
				} else {						// 同じ県の時は年でソート
					return o1.year - o2.year;
				}
			}
		});
		for ( int id = 1; id <= m; id++ ) {
			city.add(new City(id, in.nextInt(), in.nextInt()));
		}

		// 県ごとに年でナンバー付けしてidでソート
		String citycode[] = new String[m + 1];
		int p = 0;
		int num = 0;
		while ( city.size() > 0 ) {
			City c = city.poll();
			// 新出の県の場合
			if ( p != c.pref ) {
				p = c.pref;
				num = 1;
			} else {
				num++;
			}
			citycode[c.id] = String.format("%06d%06d", p, num);
			// System.out.println("id:" + c.id + " pref:" + c.pref + " year:" + c.year);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for ( int i = 1; i<=m; i++ ) {
			pw.println(citycode[i]);
		}
		pw.flush();
		in.close();
	}
}

class City {
	int	id		= 0;
	int	pref	= 0;
	int	year	= 0;
	public City(int id, int pref, int year) {
		this.id = id;
		this.pref = pref;
		this.year = year;
	}
}


Measured memory_bytes: 139376
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def binarySearchIterative(list: Array[Double], target: Double): Int = {
    var left = 0
    var right = list.length - 1
    while (left <= right) {
      val mid = left + (right - left) / 2
      if (list(mid) > target)
        right = mid - 1
      else
        left = mid + 1
    }
    left
  }

  def binarySearchIterative2(list: Array[Double], target: Double): Int = {
    var left = 0
    var right = list.length - 1
    while (left <= right) {
      val mid = left + (right - left) / 2
      if (list(mid) >= target)
        right = mid - 1
      else
        left = mid + 1
    }
    left
  }

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    val A = Array.fill[Double](N)(sc.nextDouble)
    val B = A.sorted
    for (i <- 0 until N) (println(binarySearchIterative2(B, A(i)) * (2) + (N - binarySearchIterative(B, A(i))) * (-1) + N * 1 - 1))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 315436
n, d = map(int, input().split())
pl = []
for i in range(n):
  p = list(map(int, input().split()))
  pl.append(p)
dc = 0
for i in range(n):
  p = pl[i]
  if ((p[0]**2 + p[1]**2)**0.5 <= d):
    dc += 1
print(dc)

Measured memory_bytes: 45588
import sys
def 解():
    iN = int(input())
    aS = [_.rstrip() for _ in sys.stdin.readlines()]

    sABC = "abcdefghijklmnopqrstuvwxyz"
    iL = len(sABC)
    aC = [0]*iL
    for i in range(iL):
        aC[i] = aS[0].count(sABC[i])
    for s in aS[1:]:
        b0 = True
        for i in range(iL):
            if aC[i]:
                iC = s.count(sABC[i])
                if iC :
                    b0 = False
                aC[i] = min(aC[i] ,iC)

        if b0:
            print("")
            exit()

    sR = ""
    for i in range(iL):
        if aC[i]:
            sR += sABC[i] * aC[i]
    print(sR)
解()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a,b;
    cin>>a>>b;
    int x=a*3+b;
    if(x<2)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<x/2<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	string T = S;
	reverse(all(S));
	dunk(S == T ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sosu(int n){
    int num[n+1],i,j,count=0;
    for(i=0;i<=n;i++) num[i]=1;
    num[0]=num[1]=0;
    for(i=2;i<=n;i++){
        if(num[i]==1){
            for(j=2;i*j<=n;j++) num[i*j]=0;
        }
    }
    for(i=0;i<=n;i++){
        if(num[i]==1) count++;
    }
    return count;
}

int main(void){
    int n;
    while(scanf("%d",&n)!=EOF){
        printf("%d\n",sosu(n));
    }
    return 0;
}


Measured memory_bytes: 5636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		int points = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 1; i++) {
			if(a[i + 1] - a[i] == 1) {
				points += c[(a[i] - 1)];
			}
		}
		for(int i = 0; i < n; i++) {
			points += b[i];
		};
		System.out.println(points);
		

	}

}


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

int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i]--;
  }
  
  vector<int> trans(N,-1);
  trans[0]=0;
  int b=0;
  int p,q;
  for(int i=1; i<=N; i++){
    int n=A[b];
    if(trans[n]<0){
      trans[n]=i;
    }else{
      p=trans[n];
      q=i-trans[n];
      break;
    }
    b=n;
  }
  int r=0;
  for(int i=0; i<N; i++){
    if(K<p){
      if(trans[i]==K) r=i;
    }else{
      if(trans[i]-p==(K-p)%q) r=i;
    }
  }
  cout << r+1 << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi p(N);
  rep(i,N) {
    cin >> p[i];
  }
  v(double) expe(N);
  rep(i,N) {
    expe[i] = 1.0 * ((p[i] * (p[i]+1)) / 2 ) / p[i];
  }
  v(double) sum(N+1,0);
  rep(i,N) {
    sum[i+1] = sum[i] + expe[i];
  }
  double ans = 0;
  rep(i,N-K+1) {
    ans = max(ans,sum[i+K]-sum[i]);
  }
  cout << setprecision(16) << ans << endl;
  return 0;
}

Measured memory_bytes: 4096