akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

//#define debug(...)   printf( __VA_ARGS__ )
#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)
int n,i,j,cnt,ar[100007],flag[100007];
vector<int> conseq;

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    while(cin>>n)
    {
        fr(i,0,n-1)
        scanf("%d",ar+i);

        fr(i,1,n)
        if(ar[i]!=ar[i-1])
            conseq.pb(ar[i-1]);

        for(auto von:conseq)
            debug("%d ",von);

        debug("\n");

        cnt=0;
        n=conseq.size();

        for(i=1; i<n;)
            if(conseq[i-1]<conseq[i])
            {
                while(i<n&&conseq[i-1]<conseq[i])
                {
                    flag[i]=flag[i-1]=-1;
                    i++;
                }


                cnt++;
                i++;
            }
            else if(conseq[i-1]>conseq[i])
            {
                while(i<n&&conseq[i-1]>conseq[i])
                {
                    flag[i]=flag[i-1]=-1;
                    i++;
                }
                i++;
                cnt++;
            }

        if(flag[n-1]!=-1)
            cnt++;

        cout<<cnt<<'\n';
        conseq.clear();

        fr(i,0,n-1)
         flag[i]=0;
    }



    return 0;
}

/*
10
1 1 1 3 2 2 1 1 2 3
1 3 2 1 2 3
3

3
1 1 2
1 3 2 1 2 3 3

8
1 2 3 3 4 1 2 3
*/




Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

vector<bool> sieve(int x) { // range...[0,x]
    vector<bool> flags(x + 1, true);
    flags[0] = false, flags[1] = false;
    for(int i = 2; i * i <= x; i++) {
        if(!flags[i])
            continue;
        for(int mult = i * i; mult <= x; mult += i)
            flags[mult] = false;
    }
    return flags;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    sort(All(A));
    ll c = A[0];
    auto primes = sieve(1000100);
    rep(i, N) { c = __gcd(c, A[i]); }
    if(c != 1) {
        cout << "not coprime" << endl;
    } else {
        vector<int> check(1000100, 0);
        rep(i, N) check[A[i]]++;
        int ok = 0;
        for(int i = 0; i < primes.size(); i++) {
            if(primes[i]) {
                int cnt = 0;
                for(int j = i; j < check.size(); j += i) {
                    cnt += check[j];
                }
                if(cnt >= 2)
                    ok = 1;
            }
            if(ok)
                break;
        }
        if(ok) {
            cout << "setwise coprime" << endl;
        } else {
            cout << "pairwise coprime" << endl;
        }
    }
}

Measured memory_bytes: 15144
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFindWeighted:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.weight = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            root = self.find(self.parents[x])
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = root
            return root

    def union(self, x, y, w):
        w += -self.weight[x] + self.weight[y]

        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y, w = y, x, -w

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        self.weight[y] = -w

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


def main():
    N, M, *LRD = map(int, read().split())

    uf = UnionFindWeighted(N)
    for l, r, d in zip(*[iter(LRD)] * 3):
        l -= 1
        r -= 1
        if uf.same(l, r) and uf.diff(l, r) != d:
            print('No')
            return
        else:
            uf.union(l, r, d)

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 148572
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
constexpr long long int mod = 1000000007LL;
long long int count_uf_lf(const int digit) {
	if (digit < 0) return 1;
	else {
		return 3 * count_uf_lf(digit - 1) % mod;
	}
}
long long int count_uf_lc(const int digit, const long long int lower) {
	if (digit < 0) return 1;
	else {
		if (((1LL << digit) & lower) != 0) {
			return count_uf_lc(digit - 1, lower);
		}
		else {
			return (count_uf_lf(digit - 1) + count_uf_lc(digit - 1, lower) * 2) % mod;
		}
	}
}
long long int count_uc_lf(const int digit, const long long int upper) {
	if (digit < 0) return 1;
	else {
		if (((1LL << digit) & upper) != 0) {
			return (count_uf_lf(digit - 1) + count_uc_lf(digit - 1, upper) * 2) % mod;
		}
		else {
			return count_uc_lf(digit - 1, upper);
		}
	}
}
long long int count_uc_lc(const int digit, const long long int upper, const long long int lower) {
	if (digit < 0) return 1;
	else {
		if (((1LL << digit) & upper) > ((1L << digit) & lower)) {
			return (count_uc_lc(digit - 1, upper, lower) + count_uc_lf(digit - 1, upper) + count_uf_lc(digit - 1, lower)) % mod;
		}
		else if (((1LL << digit) & upper) == ((1L << digit) & lower)) {
			return count_uc_lc(digit - 1, upper, lower);
		}
		else return 0LL;
	}
}
int main() {
	long long int l, r; std::cin >> l >> r;
	long long int bit = 1;
	int digit = 0;
	while (l >= bit * 2) {
		bit *= 2;
		digit += 1;
	}
	long long int pattern = 0;
	while (r >= bit) {
		pattern += count_uc_lc(digit, std::min(bit * 2 - 1, r), std::max(bit, l));
		bit *= 2;
		digit += 1;
		pattern %= mod;
	}
	std::cout << pattern << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll solve1(vector<ll> a, int n) {
  deque<ll> dq;
  dq.push_back(a[0]);
  int s=1;
  int e=n-1;
  for(int k=0; k<(n-1)/2; k++) {
    if(k%2==0) {
      ll f = dq.front();
      ll b = dq.back();
      ll t1 = abs(a[e]-f)+abs(a[e-1]-b);
      ll t2 = abs(a[e]-b)+abs(a[e-1]-f);
      if(t1<t2) {
        dq.push_back(a[e]);
        dq.push_front(a[e-1]);
      } else {
        dq.push_front(a[e]);
        dq.push_back(a[e-1]);
      }
      e-=2;
    } else {
      ll f = dq.front();
      ll b = dq.back();
      ll t1 = abs(a[s]-f)+abs(a[s+1]-b);
      ll t2 = abs(a[s]-b)+abs(a[s+1]-f);
      if(t1<t2) {
        dq.push_back(a[s]);
        dq.push_front(a[s+1]);
      } else {
        dq.push_front(a[s]);
        dq.push_back(a[s+1]);
      }
      s+=2;
    }
  }
  if(n%2==0) {
    if(abs(dq.front()-a[s])>abs(dq.back()-a[s])) {
      dq.push_front(a[s]);
    } else {
      dq.push_back(a[s]);
    }
  }
  // for(auto x : dq) cout << x << " ";
  // cout << endl;
  ll prev = dq.front();
  dq.pop_front();
  ll ans=0;
  for(auto x : dq) {
    ans+=abs(x-prev);
    prev=x;
  }
  return ans;
}

ll solve2(vector<ll> a, int n) {
  deque<ll> dq;
  dq.push_back(a[n-1]);
  int s=0;
  int e=n-2;
  for(int k=0; k<(n-1)/2; k++) {
    if(k%2==1) {
      ll f = dq.front();
      ll b = dq.back();
      ll t1 = abs(a[e]-f)+abs(a[e-1]-b);
      ll t2 = abs(a[e]-b)+abs(a[e-1]-f);
      if(t1<t2) {
        dq.push_back(a[e]);
        dq.push_front(a[e-1]);
      } else {
        dq.push_front(a[e]);
        dq.push_back(a[e-1]);
      }
      e-=2;
    } else {
      ll f = dq.front();
      ll b = dq.back();
      ll t1 = abs(a[s]-f)+abs(a[s+1]-b);
      ll t2 = abs(a[s]-b)+abs(a[s+1]-f);
      if(t1<t2) {
        dq.push_back(a[s]);
        dq.push_front(a[s+1]);
      } else {
        dq.push_front(a[s]);
        dq.push_back(a[s+1]);
      }
      s+=2;
    }
  }
  if(n%2==0) {
    if(abs(dq.front()-a[s])>abs(dq.back()-a[s])) {
      dq.push_front(a[s]);
    } else {
      dq.push_back(a[s]);
    }
  }
  // for(auto x : dq) cout << x << " ";
  // cout << endl;
  ll prev = dq.front();
  dq.pop_front();
  ll ans=0;
  for(auto x : dq) {
    ans+=abs(x-prev);
    prev=x;
  }
  return ans;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(a.begin(),a.end());
  cout << max(solve1(a,n),solve2(a,n)) << endl;
  return 0;
}


Measured memory_bytes: 3396
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  string S, T;
  cin >> S >> T;
  map<char,char> nice, ecin;
  rep(i, 0, S.size()){
    if(nice[S[i]]=='\0'){
      nice[S[i]] = T[i];
    }
    else if(nice[S[i]]!=T[i]){
      cout << "No" << rt;
      return 0;
    }
    if(ecin[T[i]]=='\0'){
      ecin[T[i]] = S[i];
    }
    else if(ecin[T[i]]!=S[i]){
      cout << "No" << rt;
      return 0;
    }
  }
  cout << "Yes" << rt;
}

Measured memory_bytes: 900
a=int(input())
b,d,e=[],[],[0]
for i in range(a):
    b.append(str(input()))
c=int(input())
up,down=0,0
for j in range(c):
    d.append(str(input()))
for k in set(b):
    up+=b.count(k)
    down+=d.count(k)
    e.append(up-down)
    up,down=0,0
print(max(e))

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;

#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair


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

void solve() {
    int n; cin >> n;
    int k; cin >> k;
    vi a(n);
    for (auto &i : a) cin >> i, i *= 2;
    ll l = 0, r = 2e9 + 5;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        ll sum = 0;
        for (auto &z : a) sum += max(0LL, (z + m - 1) / m - 1);
        if (sum > k) l = m;
        else r = m;
    }
    cout << (r + 1) / 2;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<char> se;
    for (auto i = s.begin(); i != s.end(); i++)
        se.insert(*i);
    for (char i = 'a'; i <= 'z'; i++){
        if (se.find(i) == se.end()){
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
void init(int n){
    par.resize(n);
    depth.resize(n,0);
    rep(i,n) par[i]=i;
}

int find(int n){
    if(par[n]==n) return n;
    return par[n]=find(par[n]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(par[x]==par[y]) return;
    if(depth[x]<depth[y]) par[x]=par[y];
    else{
        par[y]=par[x];
        if(depth[x]==depth[y]) depth[x] ++;
    }
}

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

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<P> e(m);
    int cnt=0;
    int x,y;
    rep(i,m){
        cin>>x>>y;
        x --,y --;
        e[i]=P(x,y);
    }
    rep(i,m){
        init(n);
        rep(j,m){
            if(i!=j) unite(e[j].first,e[j].second);
        }
        bool ok=1;
        REP(i,1,n){
            if(!same(0,i)){
                ok=0;
                break;
            }
        }
        if(ok) cnt ++;
        par={};
        depth={};
    }
    cout<<m-cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int H,W,K; cin >> H >> W >> K;
    vector<string> masu(H);
    REP(i,H) cin >> masu[i];

    int ans = 0;
    for(int mask = 0; mask < (1 << (H+W)); mask++){

        vector<string> tmp;
        tmp = masu;
        REP(i,H+W){
            if((mask >> i)&1){
                if(i >= H){
                    REP(j,H) tmp[j][i-H] = 'x';
                }else{
                    REP(j,W) tmp[i][j] = 'x';
                }
            }
        }

        int acc = 0;
        REP(i,H) REP(j,W){
            if(tmp[i][j] == '#') acc++;
        }
        if(acc == K) ans++;

        //dump(mask)
        //REP(i,H){
        //    cout << tmp[i] << endl;
        //}
        //cout << endl;
    }
    cout << ans << endl;

}

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

int main(){
  int n;
  int b,prv;
  int p[50];

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> p[i];

    prv = p[0];
    b = p[0];
    for(int i=1;i<n;i++){
      if(prv+1!=p[i]){
	if(prv == b){
	  cout << b << " ";
	}else{
	  cout << b << "-" << prv << " ";
	}
	b = p[i];
      }
      prv = p[i];
    }
  
    if(prv == b){
      cout << b << endl;
    }else{
      cout << b << "-" << prv << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

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

    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    string ans; 
    while(n){
        if(n % -2){
            ans = '1' + ans;
            n -= abs(n%-2);
        }else ans = '0' + ans;
        n /= -2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# ABC065b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
a = [int(input()) for _ in range(n)]

count = 0
used = [False]*n


def push(i):
    # print('push'+str(i))
    global count
    count += 1
    if (i == 2):
        print(count)
        exit()
    if (used[i-1]):
        print('-1')
        exit()
    used[i-1] = True
    push(a[i-1])


push(a[0])

Measured memory_bytes: 91408
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;

void sayNo() {
	cout << "No" << endl;
}

void sayYes() {
	cout << "Yes" << endl;
}

int main() {
	 int r;
	 cin >> r;
	 cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
s = 0
for i in range(1,101):
    temp = 0
    for j in range(N):
        temp += (i - X[j])**2
    if i == 1:
        s = temp
    elif s < temp:
        pass
    elif s >= temp:
        s = temp
print(s)
    

Measured memory_bytes: 3060
N,D=map(int,input().split())

X=[list(map(int,input().split())) for i in range(N)]

ANS=0
import math

for i in range(N-1):
    for j in range(i+1,N):
        DIS=math.sqrt(sum([(X[i][k]-X[j][k])**2 for k in range(D)]))

        if DIS==int(DIS):
            ANS+=1

print(ANS)
        


Measured memory_bytes: 3060
H, W = map(int,input().split())

S = [[]]

for h in range(H):
    S.append([])
    S[-1] = list(input())

del S[0]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.': S[i][j] = 0
        if S[i][j] == '#': S[i][j] = -100
            
for i in range(H):
    for j in range(W):
        if S[i][j] < 0:
            
            if i != 0:
                try: S[i-1][j] += 1
                except: x=1


                try: S[i-1][j+1] += 1
                except: x=1
                    
            if j != 0:
                try: S[i][j-1] += 1
                except: x=1

                try: S[i+1][j-1] += 1
                except: x=1
                
                if i != 0:
                    try: S[i-1][j-1] += 1
                    except: x=1

                
            try: S[i+1][j] += 1
            except: x=1
            
            try: S[i][j+1] += 1
            except: x=1
            
            try: S[i+1][j+1] += 1
            except: x=1
            
            
for i in range(H):
    for j in range(W):
        if S[i][j] < 0: S[i][j] = '#'

for i in range(len(S)):
    for j in range(len(S[i])):
        print(S[i][j], end="")
    print()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 ll n ;
 cin >> n;
  int m=0;
 rep(i,sqrt(n)){
   if(n%(i+1)==0){
     m=max(m,i+1);
   }
 }
   cout << n/m+m-2 <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,x,y,z;
	
	int b,f,r,v;		//b?£?f??????r???????????¨?±????v????????????
	int count[4][3][10]={0};
	
	scanf("%d\n",&n);
	
	for( i=0 ; i<n ; i++){
		
		scanf("%d%d%d%d",&b,&f,&r,&v);
		
		count[b-1][f-1][r-1]=count[b-1][f-1][r-1]+v;
		
	}
	
	for( x=0 ; x<4 ; x++){
		for( y=0 ; y<3 ; y++){
			for( z=0 ; z<10 ; z++){
				
				printf(" %d",count[x][y][z]);
				if(z==9){
					printf("\n");
				}
			}
		}if(x!=3){
				printf("####################\n");
			}
	}
	
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m, a[MAXN];
bool visit[MAXN];
vector<int> A[MAXN], B, C;

void dfs(int u) {
    visit[u] = true;
    B.emplace_back(u);
    C.emplace_back(a[u]);
    FOR(i,0,SZ(A[u])-1) {
        int v = A[u][i];
        if (!visit[v]) dfs(v);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,m) {
        int u, v;
        cin >> u >> v;
        A[u].emplace_back(v);
        A[v].emplace_back(u);
    }
    int res = 0;
    FOR(i,1,n)
        if (!visit[i]) {
            B.clear();
            C.clear();
            dfs(i);
            int I = 0, J = 0;
            sort(ALL(B));
            sort(ALL(C));
            while (I < SZ(B) && J < SZ(C)) {
                if (B[I] < C[J]) I++;
                else if (B[I] > C[J]) J++;
                else {
                    I++;
                    J++;
                    res++;
                }
            }
            //cout << i << " " << res << endl;
        }
    cout << res;
    return 0;
}

Measured memory_bytes: 10156
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MaxSize 100005
int n;
int a[MaxSize],b[MaxSize];
int ans=0;
int Divisor(int x1,int x2){
    int res=1;
    while(x2){
        res=x1%x2;
        x1=x2;
        x2=res;
    }
    return x1;
}
void fun(){
    memset(b,0,sizeof(b));
    for(int i=0;i<n-1;i++){
        if(b[i]==0){
            for(int j=i+1;j<n;j++)
                if(a[j]%a[i]==0||a[i]%a[j]==0)
                    b[j]=1;
            }
    }
}
int DivisorX(int rec,int rev,int now){
    int m=Divisor(rec,rev);
    if(now==n-1) return Divisor(rec,rev);
    else return DivisorX(Divisor(rec,rev),a[now+1],now+1);
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    fun();
    if(n==2) cout<<max(a[0],a[1])<<endl;
    else if(n==3) cout<<max(Divisor(a[0],a[1]),max(Divisor(a[0],a[2]),Divisor(a[1],a[2])))<<endl;
    else if(n>3){
        for(int i=0;i<n;i++){
            if(b[i]==0){
                int m=a[i];
                if(i<n-1) a[i]=a[i+1];
                else if(i==n-1) a[i]=a[0];
                int t=DivisorX(a[0],a[1],1);
                if(t>ans) ans=t;
                a[i]=m;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  if (s[0]==s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
 
class Main {
	int n;
	LinkedList<Integer> a;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		a = new LinkedList<Integer>();
		for(int i=0;i<3*n;i++){
			a.add(sc.nextInt());
		}
	}
	void solve(){
		Collections.sort(a,Collections.reverseOrder());
		long sum = 0;
		for(int i=0;i<n;i++){
			a.remove(0);
			sum += a.remove(0);
		}
		System.out.println(sum);
	}
}

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

int main(){
    int N;cin>>N;
    int info[N],copy[N];
    rep(i,N){
        cin>>info[i];
        copy[i]=info[i];
    }
    sort(copy,copy+N);
    int a=copy[N/2-1],b=copy[N/2];
    rep(i,N){
        if(info[i]<=a)cout<<b<<endl;
        else cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
def solve(A, B, C, K):
    count = 0
    a = min(A, K)
    count += a
    K -= a
    b = min(B, K)
    K -= b
    c = min(C, K)
    count -= c
    K -= a
    return count

if __name__ == "__main__":
    A, B, C, K = tuple(map(int, input().split(" ")))

    print(solve(A, B, C, K))


Measured memory_bytes: 9192
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
l.sort()
l.append(10000000000000000000000)
f=1
ans=0
for i in range(n):
    if l[i]==l[i+1]:
        f+=1
    else:
        ans+=f%2
        f=1
print(ans)

Measured memory_bytes: 7388
n = int(input())
w = list(map(int,input().split()))
sum_w = sum(w)
min_abs = sum_w
left = 0

for i in range(n):
	left += w[i]
	right = sum_w - left
	abs_num = abs(right-left)
	if abs_num < min_abs:
		min_abs = abs_num
	else:
		break

print(min_abs)

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

int main(){

    string s;
    cin >> s;

    bool ev;
    if(s.size()%2==0){
        ev=true;
    }else{
        ev=false;
    }

    bool f;
    if(s[0]==s.back()){
        if(ev){
            f=true;
        }else{
            f=false;
        }
    }else{
        if(ev){
            f=false;
        }else{
            f=true;
        }
    }

    if(f){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long int llint;
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	llint A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	llint ans1 = A * X + B * Y;
	llint ans2 = 2*C * min(X, Y);
	if (min(X, Y) == X)ans2 += (Y - X)*B;
	else ans2 += (X - Y)*A;
	llint ans3 = 2 * C*max(X, Y);
	cout << min(ans1, min(ans2, ans3)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    int N; cin >> N;
    int K; cin >> K;

    vector<int> A;
    rep(i, N) {
        int atmp; cin >> atmp; A.push_back(atmp);
    }

    // バケット
    int b[N+1];
    rep(i, N+1) b[i] = 0;
    
    set<int> st;
    rep(i, N) {
        st.insert(A[i]);
        b[A[i]]++;
    }

    int k = st.size();
    int diff = k - K;
    if (diff <= 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(b, b + N + 1);
    
    int count = 0;
    int diff2 = 0;
    rrep(i, 1, N) {
        if (b[i] == 0) continue;
        diff2++;
        count+=b[i];
        if (diff2 == diff) break;
    }

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


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

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using graph = vector<vector<Edge>>;

vector<int> weight;
void DFS(const graph &G, int v, int sum){
  weight[v] = sum;
  for(auto e : G[v]){
    if(weight[e.to] == -1) DFS(G,e.to,sum+e.weight);
  }
}

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

  graph G(N);
  for(int i = 0; i < N-1; i++){
    int u,v,w;
    cin >> u >> v >> w;
    G[u-1].push_back(Edge(v-1,w));
    G[v-1].push_back(Edge(u-1,w));
  }
  weight.assign(N,-1);
  for(int v = 0; v < N; v++){
    if(weight[v] == -1){
      DFS(G,v,0);
    }
  }
  for(auto w : weight){
    if(w%2 == 0) cout << 0 << endl;
    else cout << 1 << endl;
  }
}

Measured memory_bytes: 10716
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;
use std::io::{Write, BufWriter};

// static MOD: usize = 998244353;
static MOD: usize = 1000000007;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

macro_rules! println_stderr(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn solve() {
    input! {
        n: i32,
        m: i32,
    }  
    let ans = max(0,n-2*m);
    println!("{}", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
if 1<=n<=999:
    print("ABC")
else:
    print("ABD")


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { 
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); 
    if (sum >= A && sum <= B) {
      total += i;
    }
  }
  cout << total << endl;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n, x = 0;  cin >> n;
    string s;   cin >> s;
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'I') x++;
        else x--;

        ans = max(ans, x);
    }

    cout << ans;

}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int a[10101010],b[10101010];

int main(){
	int n=read(),m=read();
	a[0]=read(),b[0]=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	} 
	for(int i=1;i<=m;i++){
		b[i]=read();
	}
	sort(a,a+n+1);sort(b,b+m+1);
	if(a[n]<b[0]) cout<<"No War";
	else cout<<"War";
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  long long num[200010] = {};
  for (int i = 1; i <= N; i++) num[i % K]++;

  long long ans = 0;
  for (int a = 0; a < K; a++) {
    int b = (K - a) % K, c = (K - a) % K;
    if ((b + c) % K != 0) continue;
    ans += num[a] * num[b] * num[c];
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
// Author: 23forever
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, k, h[MAXN + 5], dp[MAXN + 5];

void init() {
  n = read();
  k = read();
  for (int i = 1; i <= n; ++i) h[i] = read();
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  //freopen("test.out", "w", stdout);
#endif
  init();

  memset(dp, 0x3f, sizeof(dp));
  dp[1] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      int nxt_state = j + i;
      if (nxt_state > n) break;
      
      int w = fabs(h[nxt_state] - h[i]);
      dp[nxt_state] = min(dp[nxt_state], dp[i] + w);
    }
  }

  printf("%d\n", dp[n]);
  return 0;
}

Measured memory_bytes: 1408
def sol(_inp=input):
    n=int(_inp())
    tree={i+1:set() for i in range(n)}
    assigned=[0 for _ in range(n)]
    for _ in range(n-1):
        i,j=map(int,_inp().split())
        tree[i].add(j)
        tree[j].add(i)
    cs=sorted(list(map(int,_inp().split())))
    tree_orig={i:tree[i].copy() for i in tree}
    for c in cs[:-1]:
        for v in tree:
            if len(tree[v])==1:
                assigned[v-1]=c
                w=list(tree[v])[0]
                tree[v]=set()
                tree[w].remove(v)
                break
    else:
        assigned[w-1]=cs[-1]
    res=sum(min(assigned[v-1],assigned[w-1]) for v in tree_orig for w in tree_orig[v])//2
    return '{}\n{}'.format(res,' '.join(str(c) for c in assigned))
print(sol())

Measured memory_bytes: 59224
import numpy as np
n, k = list(map(int, input().split()))
hs = []
for _ in range(n):
    hs.append(int(input()))

hs.sort()
hs = np.array(hs)
ans = hs[k - 1:] - hs[:-(k - 1)]
ans = ans.min()
print(ans)

Measured memory_bytes: 17092
// "for if God is with them who can be against them."
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
int ans = 0;
int cnt[400004];
void solve() {
	char c;
	cin >> c;
	if (c >= 'A' and c <= 'Z') {
		cout << "A";
	}
	else
		cout << "a";
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	IOS;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}


#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
alphabet = 'abcdefghijklmnopqrstuvwxyz'
N = int(input())

n = N
name = []
while n != 0:
    name.append(alphabet[(n%26)-1])
    if n%26==0:
        n = int(n/26)-1
    else:
        n = int(n/26)


print(''.join(name[::-1]))

Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;
#define inf 1e4+1

template<typename T> T mygcd(T a, T b)
{
	return b ? mygcd(b, a%b) : a;
}

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

	vector<ll> a((int)n);
	vector<ll> r((int)n);
	vector<ll> l((int)n);

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (i == 0)
			l[i] = a[i];
		else
			l[i] = mygcd(l[i - 1], a[i]);
		//cout << i << ":" << l[i] << endl;
	}

	for (int i = n - 1; i >= 0; --i)
	{
		if (i == n - 1)
			r[i] = a[i];
		else
			r[i] = mygcd(r[i + 1], a[i]);
		//cout << i << ":" << r[i] << endl;
	}

	ll val = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i == 0)
			val = max(val, r[i + 1]);
		else if (i == n - 1)
			val = max(val, l[i - 1]);
		else
			val = max(val, mygcd(r[i + 1], l[i - 1]));
	}

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int n;
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from collections import Counter

def resolve():
    it = iter(sys.stdin.read().split())
    N = int(next(it))
    cc = Counter(it)

    for s in ["AC", "WA", "TLE", "RE"]:
        print(f"{s} x {cc[s]}")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 74840
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

using ll = long long int;
using ha = pair<int, int>;
struct RollingHash {
	static const ll mul0 = 10009, mul1 = 10007;
	static const ll add0 = 1000010007, add1 = 1003333331;
	size_t len;
	//vector<ll> hash_, hash2_;
	vector<ha>hash_;
	//static vector<ll> pmo_, pmo2_;
	static vector<ha>pmo_;
	void init(const vector<ll>& s) {
		len = s.size();
		hash_.resize(len + 1);
		hash_[0] = make_pair(0, 0);

		if (pmo_.empty()) {
			pmo_.push_back(make_pair(1, 1));
		}
		while (pmo_.size() <= len) {
			pmo_.push_back(make_pair(pmo_.back().first*mul0, pmo_.back().second*mul1));
		}
		for (unsigned int i = 0; i < len; ++i) {
			hash_[i + 1] = make_pair((hash_[i].first * mul0 + s[i]), (hash_[i].second*mul1 + s[i]));
		}
		return;
	}
	void init(const string& s) {
		vector<ll>v;
		for (char c : s) {
			v.push_back(c);
		}
		init(v);
	}
	ha hash(const int l, const int r)const { // s[l..r]
		return make_pair(hash_[r + 1].first - hash_[l].first * pmo_[r + 1 - l].first,
			hash_[r + 1].second - hash_[l].second * pmo_[r + 1 - l].second);
	}
	ha  hash()const { // s[all]
		return hash(0, len - 1);
	}

	//hash????????????
	static ha concat(const ha L, const ha R, const int RLength) { // hash(L+R) 
		return make_pair((R.first + L.first*pmo_[RLength].first), (R.second + L.second*pmo_[RLength].second));
	}

	//index????????????from??????to????????????????????????????????\????????????
	ha get_changed_hash(const int index, const ll from, const ll to)const {
		const ha p(hash());
		return make_pair(
			p.first + (to - from) * pmo_[len - index - 1].first,
			p.second + (to - from) * pmo_[len - index - 1].second);
	}
};
vector<ha> RollingHash::pmo_;

int main() {
	string s, t; cin >> s >> t;
	RollingHash base_rh;
	base_rh.init(t);
	vector<ha>hs;
	for (int i = 0; i < t.size(); ++i) {
		for (int c = 0; c < 26; ++c) {
			char ch = 'a' + c;
			if (ch == t[i])continue;
			else {
				ha ahash = base_rh.get_changed_hash(i, t[i], ch);
				hs.emplace_back(ahash);
			}
		}
		for (int c = 0; c < 26; ++c) {
			char ch = 'A' + c;
			if (ch == t[i])continue;
			else {
				ha ahash = base_rh.get_changed_hash(i, t[i], ch);
				hs.emplace_back(ahash);
			}
		}
	}
	sort(hs.begin(), hs.end());
	hs.erase(unique(hs.begin(), hs.end()),hs.end());
	RollingHash s_rh;
	s_rh.init(s);
	long long int ans = 0;
	for (int i = 0; i < s.size() - t.size() + 1; ++i) {
		ha h = s_rh.hash(i, i + t.size()-1);
		if (binary_search(hs.begin(), hs.end(), h)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 75536
from collections import deque

def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node)


n = int(input())
gl = [ [] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w = map(int, input().split())
    gl[u].append((v,w))
    gl[v].append((u,w))
visited = [-1] * (n+1)
bfs(1, gl, visited)

for v in visited[1:]:
    if v%2 == 0: print(0)
    else: print(1)

Measured memory_bytes: 95588
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$s = $key->A[0];
$c = $key->A[1];

//sの数だけsccを作る
if ($c >= ($s * 2)) {
  $t = $c - ($s * 2);
}
else {
  //cが足りない?
  $s = $c / 2;
}
//t には cのあまり
//c4つでsccができる
printf("%d\n",$s+(int)($t/4));


Measured memory_bytes: 3704
object Main extends App{
  import scala.io.StdIn.readInt
  
  val m = readInt
  
   def isPrime(n: Int): Boolean = {
     n > 1 && (2 until n).forall(n % _ != 0)
   }
  val primes = Stream.range(m , 3*m+1).filter(isPrime(_))
  println(primes.head.toString)
}


Measured memory_bytes: 55672
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main() {

  ll n;
  cin>>n;
  vector<ll> v;

  ll xo;
  cin>>xo;
  v.push_back(xo);
  for(ll i=1;i<n;i++)
  {
      ll x;
      cin>>x;
      v.push_back(x);
      xo=xo^x;
  }
    vector<ll> ans;

    for(ll i=0;i<n;i++)
    {
        ans.push_back(xo^v[i]);
    }
    
    for(ll i=0;i<n;i++)
    cout<<ans[i]<<" ";

    return 0;
}


Measured memory_bytes: 7748
fn main() {
    let r: i32 = read();
    let mut g: i32 = read();
    g -= r-g;
    println!("{}", g);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i, n) cin >> a[i];

  int ng = 0, ok = 1e9 + 1;
  while (ok - ng > 1) {
    int m = (ok + ng) / 2;
    int cnt = 0;
    rep(i, n) { cnt += (a[i] + m - 1) / m - 1; }
    if (cnt <= k)
      ok = m;
    else
      ng = m;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 4332