akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<functional>
using namespace std;
#define LL long long
#define MOD 1000000007

int v,e,r,cost[100002];

vector<pair<int, int>>edge[100002];//node,cost
priority_queue< pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > P;//cost,node

int main(){
	cin >> v >> e >> r;
	for(int i=0; i<v; i++) cost[i] = MOD;
	for(int i=0; i<e; i++){
		int s,t,d;
		cin >> s >> t >> d;
		edge[s].push_back(make_pair(t, d));
	}
	cost[r] = 0;
	P.push(make_pair(0, r));
	while(!P.empty()){
		pair<int, int> now = P.top();
		P.pop();
		for(int i=0; i<edge[now.second].size(); i++){
			if(cost[ edge[now.second][i].first ] > now.first + edge[now.second][i].second){
				cost[ edge[now.second][i].first ] = now.first + edge[now.second][i].second;
				P.push(make_pair(cost[ edge[now.second][i].first ], edge[now.second][i].first));
			}
		}
	}
	for(int i=0; i<v; i++){
		if(cost[i] == MOD) cout << "INF" <<endl;
		else cout << cost[i] << endl;
	}
	return 0;
}




Measured memory_bytes: 13032
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;

long n;
std::map<P, long> mp;
std::string s;

void write(){
	long a, b;
	scanf("%ld%ld", &a, &b);
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second == -1){
			long l = it->first.first;
			long r = std::min(it->first.second, l + b);
			long rr = it->first.second;
			if(b > rr - l){
				it->second = a;
				b -= r - l;
			}else{
				mp.erase(it);
				mp[P(l, r)] = a;
				if(r < rr){
					mp[P(r, rr)] = -1;
				}
				break;
			}
		}
	}
}

void del(){
	long a;
	scanf("%ld", &a);
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second == a){
			it->second = -1;
		}
	}
}

void ref(){
	long a;
	scanf("%ld", &a);
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->first.first <= a && a < it->first.second){
			printf("%ld\n", it->second);
		}
	}
}

int main(){
	while(true){
		scanf("%ld", &n);
		if(n == 0){
			return 0;
		}
		mp.clear();
		mp[P(0, 1000000009)] = -1;
		for(int i = 0; i < n; i++){
			s.clear();
			std::cin >> s;
			if(s[0] == 'W'){
				write();
			}else if(s[0] == 'D'){
				del();
			}else{
				ref();
			}
			/*
			for(auto it = mp.begin(); it != mp.end(); it++){
				printf("[%ld, %ld)  %ld\n", it->first.first, it->first.second, it->second);
			}
			printf("--------\n");
			//*/
		}
		printf("\n");
	}
}



Measured memory_bytes: 3432
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var S = cin.ReadStrArray(N);
            WriteLine(S.Distinct().Count() == 3 ? "Three" : "Four");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt(); B[i] = ReadInt(); }}
    }
}


Measured memory_bytes: 13408
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
inline int ty()
{
	register int a=0,b=1,c=getchar();
	while(!isdigit(c))b^=c=='-',c=getchar();
	while(isdigit(c))a=a*10+c-48,c=getchar();
	return b?a:-a;
}
const int _ = 200007 , __ = _<<1;
int to[__],ne[__],he[_]={0},ecnt=1;
void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
void addde(int a,int b){adde(a,b),adde(b,a);}
struct node
{
	int num,cnt0,cnt1;
	node(int _num=0,int _cnt0=0,int _cnt1=0){num=_num,cnt0=_cnt0,cnt1=_cnt1;}
	inline friend int operator < (node a,node b)
	{
		return 1ll*a.cnt1*b.cnt0>1ll*b.cnt1*a.cnt0;
	}
	inline friend int operator == (node a,node b)
	{
		return a.cnt0==b.cnt0 && a.cnt1==b.cnt1;
	}
	inline friend int operator != (node a,node b)
	{
		return !(a==b);
	}
	inline friend node operator + (node a,node b)
	{
		return node(a.num,a.cnt0+b.cnt0,a.cnt1+b.cnt1);
	}
};
int bfa[_];
int findbfa(int x){return x==bfa[x]?x:bfa[x]=findbfa(bfa[x]);}
int n,val[_],fa[_]={0};
node va[_];
int main()
{
	register int i,a,b;
	register node x,y,z;
	register lint ans=0;
	priority_queue<node> q;
	n=ty();
	for(i=2;i<=n;i++)fa[i]=ty();
	for(i=1;i<=n;i++)
	{
		val[i]=ty();
		if(val[i]==1)va[i]=node(i,0,1);
		else va[i]=node(i,1,0);
		if(i>1)q.push(va[i]);
	}
	for(i=1;i<=n;i++)bfa[i]=i;
	while(!q.empty())
	{
		x=q.top(),q.pop(),a=findbfa(x.num);
		if(x!=va[a])continue;
		b=findbfa(fa[a]),bfa[a]=b;
		ans+=1ll*va[b].cnt1*va[a].cnt0;
		va[b]=va[b]+va[a];
		if(b!=1)q.push(va[b]);
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
	int n;
	scanf("%d",&n);
	int ans=0;
	int tmp=0;
	for(int i=1;i<=n;i++){
		int pi;
		scanf("%d", &pi);
		if(pi==i){
			tmp++;
		}else{
			if(tmp!=0){
				ans += tmp / 2 + tmp % 2;
				tmp=0;
			}
		}
	}
	ans += tmp / 2 + tmp % 2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,ans; string s; cin>>n>>s; ans=1;
  rep(i,n-1) { if(s[i]!=s[i+1]) ans++; }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int h, w, n; cin >> h >> w >> n;
    vector<P> x(n);
    map<P, int> mp;
    rep(i, n) {
        cin >> x[i].fr >> x[i].sc;
        x[i].fr --;
        x[i].sc --;
        rep(a, 3) {
            rep(b, 3) {
                if(x[i].fr - a >= 0 && x[i].sc - b >= 0 && x[i].fr - a + 2 < h && x[i].sc - b + 2 < w) mp[P(x[i].fr - a, x[i].sc - b)] ++;
            }
        }
    }
    vector<int> cnt(10, 0);
    for(auto p: mp) {
        int co = p.sc;
        if(p.sc >= 10) continue;
        cnt[p.sc] ++;
    }
    cnt[0] = (h - 2) * (w - 2);
    rep1(j, 9) {
        cnt[0] -= cnt[j];
    }
    cout << cnt[0] << endl;
    rep1(j, 9) {
        cout << cnt[j] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 57344
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define mod 1000000007
#define mod1 1000000009
#define mod2 1000000021
#define INF 500001
#define MAX 1000000001
using namespace std;

/* 🐣🐥 */
int dp[3002][3002], cp;
char ans[3002];
int main() {
	char a[3002], b[3002];
	int al, bl, ap, bp;
	scanf("%s %s", a + 1, b + 1);
	al = strlen(a + 1), bl = strlen(b + 1);
	for (int i = 1; i <= al; i++) {
		for (int j = 1; j <= bl; j++) {
			dp[i][j] = max({ dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + (a[i] == b[j]) });
		}
	}
	ap = al, bp = bl;
	while (ap >= 1 && bp >= 1) {
		if (dp[ap - 1][bp] == dp[ap][bp]) ap--;
		else if (dp[ap][bp - 1] == dp[ap][bp]) bp--;
		else {
			ans[cp++] = a[ap];
			ap--, bp--;
		}
	}
	
	for (int i = cp - 1; i >= 0; i--) printf("%c", ans[i]);

	return 0;
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int a,b;
  cin>>a>>b;
  out(a*b);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
pl bfs(vvl g,ll n,ll s){
    vl dist(n,-1);
    queue<ll> que;
    que.push(s);dist[s]=0;
    while(!que.empty()){
        ll v=que.front();que.pop();
        for(auto nv:g[v]){
            if(dist[nv]!=-1)continue;
            dist[nv]=dist[v]+1;
            que.push(nv);
        }
    }
    ll p=-1,ns=-1;
    rep(i,n)if(chmax(p,dist[i]))ns=i;
    return {ns,p};
}
int main(){
    ll n;cin >> n;
    vvl g(n);
    rep(i,n-1){
        ll a,b;cin >> a >> b;
        a--;b--;
        g[a].pb(b);g[b].pb(a);
    }
    ll s=bfs(g,n,0).fi;
    ll len=bfs(g,n,s).se;
    vl dp(n);
    dp[0]=1,dp[1]=0;
    repl(i,2,n){
        ll t=3;
        dp[i]=t^dp[i-1]^dp[i-2];
    }
    //rep(i,n)cout << dp[i] <<endl;
    if(dp[len])cout << "First" <<endl;
    else cout << "Second" <<endl;
} 

Measured memory_bytes: 31336
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char *argv[]) {
  vector<int> p(3);
  cin >> p[0] >> p[1] >> p[2];

  sort(p.begin(), p.end(), greater<int>());
  cout << p[0] * 10 + p[1] + p[2] << endl;
  return 0;
}


Measured memory_bytes: 888
N = int(input())
A, B = list(map(int, input().split()))
P = list(map(int, input().split()))
E = []
S = []
D = []

for i in range(N):
	if P[i] >= B+1:
		D.append(P[i])
	elif P[i] <= B and P[i] >= A+1:
		S.append(P[i])
	else:
		E.append(P[i])


print(min(len(E), len(S), len(D)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

//parent[i]:ノード番号iの親のノード番号
//親が存在しないときは-(属するグループのサイズ)を格納
//parent = vector<int>(N, -1);で初期化
vector<int> parent;
//ノードXの根を返す
int root(int X){
	if(parent[X] < 0)return X;
	return parent[X] = root(parent[X]);
}
//ノードXが属するグループのサイズ(属するノード数)を返す
int size(int X){
	return -parent[root(X)];
}
//Xの属するグループとYの属するグループを繋ぐ
//それぞれの根どうしを繋ぐ
bool connect(int X, int Y){
	//根同士をつなぐため指すノードを根にする
	X = root(X);
	Y = root(Y);
	//すでに繋がっているときは繋がずにfalseを返す
	if(X == Y){
		return false;
	}
	//大きいほうに小さいほうを繋ぎたいので逆ならスワップ
	if(size(X) < size(Y))swap(X, Y);
	//繋がれる方のサイズを更新
	parent[X] += parent[Y];
	//繋ぐ方の親を設定
	parent[Y] = X;
	return true;
}
int main(){

	int N, M;
	cin >> N >> M;
	parent = vector<int>(N, -1);
	int x, y, z;
	for(int i = 0; i < M; i ++){
		cin >> x >> y >> z;
		x --;
		y --;
		connect(x, y);
	}
	vector<int> cnt(N, 0);
	for(int i = 0; i < N; i ++){
		cnt[root(i)] ++;
	}
	int ans = 0;
	for(int i = 0; i < N; i ++){
		if(cnt[i] > 0)ans ++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

N,X,Y=map(int,input().split())

d=defaultdict(int)


for i in range(1,N):
    for j in range(i+1,N+1):
        d[min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))]+=1

for i in range(1,N):
    print(d[i])

Measured memory_bytes: 3956
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
p = na()
ans = 0
for i in range(n):
    if p[i] == i + 1:
        if i == n - 1:
            ans += 1
            continue
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1

print(ans)

Measured memory_bytes: 14068
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }

  long check[n];
  for (long i = 0; i < n; i++) {
    check[i] = 0;
  }
  for (long i = 0; i < n; i++) {
    check[a[i]-1]++;
  }

  long combinations = 0;
  for (long i = 0; i < n; i++) {
    combinations += check[i]*(check[i]-1)/2;
  }

  for (long i = 0; i < n; i++) {
    printf("%ld\n", combinations-check[a[i]-1]+1);
  }

  return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>
int main (void){
int a,b,r,d;
 
scanf("%d",&a) ;
scanf("%d",&b);
double f ;
 d=a/b ;
 r=a%b ;
 f=(double)a/(double)b ;
 printf("%d %d %lf",d,r,f) ;
 return 0;
 }    

Measured memory_bytes: 636
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::vector<std::vector<long long>> a, long long n, std::vector<long long> b){
    vector<vector<int>> v(3, vector<int>(3, 0));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3; ++j)
            for(int k = 0; k < 3; ++k)
                if(a[j][k] == b[i])
                    v[j][k] = 1;
    }
    for(int i = 0; i < 3; ++i)
        if(v[i][0] + v[i][1] + v[i][2] == 3){
            cout << "Yes" << endl;
            return;
        }
    for(int i = 0; i < 3; ++i)
        if(v[0][i] + v[1][i] + v[2][i] == 3){
            cout << "Yes" << endl;
            return;
        }
    if(v[0][0] + v[1][1] + v[2][2] == 3){
        cout << "Yes" << endl;
        return;
    }
    if(v[0][2] + v[1][1] + v[2][0] == 3){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}


signed main(){
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
vector<int>G[50];
int a[20],b[20];
int parent[10][50];
int depth[50];
long subtree[50];
long dfs(int u,int p,int d)
{
	parent[0][u]=p;
	depth[u]=d;
	subtree[u]=1LL<<u;
	for(int v:G[u])
	{
		if(v!=p)
		{
			subtree[u]|=dfs(v,u,d+1);
		}
	}
	return subtree[u];
}
int lca(int u,int v)
{
	if(depth[u]<depth[v])swap(u,v);
	for(int k=0;k<10;k++)
	{
		if(depth[u]-depth[v]>>k&1)u=parent[k][u];
	}
	if(u==v)return u;
	for(int k=10;k--;)
	{
		if(parent[k][u]!=parent[k][v])
		{
			u=parent[k][u];
			v=parent[k][v];
		}
	}
	return parent[0][u];
}
int u[50],v[50];
int check[50];
main()
{
	cin>>N;
	for(int i=0;i<N-1;i++)
	{
		cin>>u[i]>>v[i];u[i]--,v[i]--;
		G[u[i]].push_back(v[i]);
		G[v[i]].push_back(u[i]);
	}
	dfs(0,-1,0);
	cin>>M;
	for(int i=0;i<M;i++)
	{
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		long test=1LL<<a[i]|1LL<<b[i];
		for(int j=0;j<N-1;j++)
		{
			int U=depth[u[j]]<depth[v[j]]?v[j]:u[j];
			if((test&subtree[U])!=test&&(test&subtree[U])!=0)
			{
				check[j]|=1<<i;
			}
		}
	}
	for(int k=1;k<10;k++)
	{
		for(int i=0;i<N;i++)
		{
			if(parent[k-1][i]>=0)parent[k][i]=parent[k-1][parent[k-1][i]];
			else parent[k][i]=-1;
		}
	}
	long ans=0;
	for(int i=0;i<1<<M;i++)
	{
		int cnt=N-1;
		for(int j=0;j<N-1;j++)
		{
			if(check[j]&i)cnt--;
		}
		long now=1LL<<cnt;
		ans+=__builtin_parity(i)?-now:now;
	}
	cout<<ans<<endl;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[22];
int x[22][22], y[22][22];
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    rep(i, bit(N)) {
        int cnt = 0;
        rep(j, N) {
            if ((i & bit(j)) == 0) { continue; }
            cnt++;
            rep(k, A[j]) {
                if ((i & bit(x[j][k])) != y[j][k] * bit(x[j][k])) { goto label; }
            }
        }
        chmax(ans, cnt);
        label:;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

Measured memory_bytes: 26012
N, M = map(int, input().split())
H = list(map(int, input().split()))
d = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[b].append(a)
    d[a].append(b)

ans = 0
cnt = 0
for i in d:
    if i != []:
        cntF = True
        for j in i:
            if H[cnt] <= H[j]:
                cntF = False
                break
        if cntF:
            ans += 1
    else:
        ans += 1
    cnt += 1

print(ans)

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

int main(){
    int n;
    int out=1;
    string s;
    cin>>n>>s;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])out++;
    }
    cout<<out<<endl;
	return 0;
}


Measured memory_bytes: 512
import sys
import itertools

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    
    H, W, K = MI()
    c = [0 for i in range(H)]
    for i in range(H):
        q = str(input())
        c[i] = list(q)
    ans = 0

    numh = list(range(H))
    numw = list(range(W))
    for i in range(H):
        for h_kumi in itertools.combinations(numh,i):
            h_kumi = list(h_kumi)
            #print(h_kumi)
            for j in range(W):
                for w_kumi in itertools.combinations(numw,j):
                    w_kumi = list(w_kumi)
                    
                    c_blk = 0


                    if (not h_kumi) and (not w_kumi):
                        for x in numh:
                            for y in numw:
                                if c[x][y] == "#":
                                    c_blk += 1
                    elif not h_kumi:
                        for x in numh:
                            for y in w_kumi:
                                if c[x][y] == "#":
                                    c_blk += 1


                    elif not w_kumi:
                        for x in h_kumi:
                            for y in numw:
                                if c[x][y] == "#":
                                    c_blk += 1

                    else:
                        for x in h_kumi:
                            for y in w_kumi:
                                if c[x][y] == "#":
                                    c_blk += 1


                    if c_blk == K:
                        ans += 1
                        #print(h_kumi, w_kumi)



    print(ans)
    #print(c)
    #print(c[1])
    #print(c[0][1])

if __name__ == "__main__":
	main()

Measured memory_bytes: 9204
#include <iostream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <climits>
#include <cmath>
#include <stdlib.h>
using namespace std;

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



Measured memory_bytes: 3972
#include<stdio.h>
int main(){
int n,m;
int i;
int p = 1,x;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
	p *= 2;
}

x = (1900*m + (n - m) * 100)*p;

printf("%d\n",x);

return 0;
}

Measured memory_bytes: 128
//AtCoder
//パナソニックプログラミングコンテスト2020
//D問題
//https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d

//input
//2
//output
//aa
//ab


//input
//4
//output
//aaaa
//aaab
//aaba
//aabb
//aabc
//abaa
//abab
//abac
//abba
//abbb
//abbc
//abca
//abcb
//abcc
//abcd


import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    public static void main (String[] args) {
        new Main().run();
    }

    void run() {
        dfs("", 'a');
    }

    void dfs(String s, char c) {
        if (s.length()==n) {
            System.out.println(s);
        } else {
            for (char ch='a'; ch<=c; ch++) {
                dfs(s+ch, (ch==c) ? (char)(c+1) : c);
            }
        }
    }

}

Measured memory_bytes: 40556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<vector<ll> > g(n,vector<ll>(n));
    vector<vector<bool> > c(n,vector<bool>(n,true));
    rep0(i, n)rep0(j, n)cin >> g[i][j];
    rep0(k, n)rep0(i, n)rep0(j, n){
        if(k == i || k == j)continue;
        if(g[i][k] + g[k][j] < g[i][j]){
            pf(-1);
            return 0;
        }
        if(g[i][k] + g[k][j] == g[i][j]){
            c[i][j] = false;
            c[j][i] = false;
        }
    }
    ll ans = 0;
    rep0(i, n - 1)nfor(j, i + 1, n)if(c[i][j])ans += g[i][j];
    pf(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if((a < b) && (b < c)){
	    printf("Yes\n");
	}else{
	    printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll husho(ll x, ll y){
    return ( x%y>=0 ? x/y : x/y-1 );
}
ll hujoyo(ll x, ll y){
    return ( x%y>=0 ? x%y : (x%y)+y );
}
//--MAIN-----------------------------------
void Main() {
    ll N,X,D; cin>>N>>X>>D;
    if(D==0){
        if(X==0) cout<< 1 <<"\n";
        else cout<< N+1 <<"\n";
        return;
    }
    if(D<0){
        D=-D;
        X=-X;
    }
    unordered_map<ll,vector<P>> mp;
    rep(k,N+1){
        ll left=husho(k*X,D)+(k*(k-1))/2;
        ll right=husho(k*X,D)+((2*N-k-1)*k)/2;
        mp[hujoyo(k*X,D)].emplace_back(left,right);
        //cout<<hujoyo(k*X,D)<<" "<<left<<" "<<right<<" "<< 0 <<"\n";
    }
    ll ans=0;
    for(auto& x: mp){
        auto& pev=x.second;
        SORT(pev);
        ll right=-INF2;
        for(auto& pe: pev){
            ll le=pe.first;
            ll ri=pe.second;
            if(ri<=right) continue;
            if(le>right){
                ans+=ri-le+1;
            }
            else{
                ans+=ri-right;
            }
            right=ri;
        }
    }
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 17864
package main

import(
  "fmt"
)

func selectionSort(a []int, n int) {
  var count int

  for i := 0; i < n; i++ {
    minj := i
    for j := i; j < n; j++ {
      if a[j] < a[minj] {
        minj = j
      }
    }
    if minj != i {
      tmp := a[i]
      a[i] = a[minj]
      a[minj] = tmp
      count++
    }
  }

  for i := 0; i < n; i++ {
    fmt.Print(a[i])
    if i < n - 1 {
      fmt.Print(" ")
    } else {
      fmt.Println()
    }
  }
  fmt.Println(count)
}

func main() {
  var n int
  fmt.Scanf("%d", &n)

  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &a[i])
  }

  selectionSort(a, n)
}


Measured memory_bytes: 1140
n = int(input())

heights = list(map(int,input().split()))

dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(1,n):
    for j in range(1,3):
        if(i-j >=0):
            dp[i] = min(dp[i],dp[i-j]+ abs(heights[i] - heights[i-j]))

print(dp[n-1])


Measured memory_bytes: 13924
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <set>
#include <sstream>

using namespace std;

const int N = 1e5+1;
int a[N],b[N];

int Gcd(int a,int b)
{
    if(b == 0) return a;
    return Gcd(b,a%b);
}

int main()
{
    int n,x;
    while(cin>>n>>x)
    {
        int temp,ans,tp;
        for(int i = 0;i < n;i++)
        {
            scanf("%d",&a[i]);
            if(i==0)
            {
                temp = abs(x-a[i]);
                continue;
            }
            tp = abs(a[i]-a[i-1]);
            ans = Gcd(tp,temp);
            temp = ans;
        }

        if(n == 1)
            printf("%d\n",abs(a[0]-x));
        else
            printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main (){
string a,b;
int x,y;
bool z=0;
cin>>a;
cin>>b;
x=a.size();
y=b.size();
if(x>y)
printf("GREATER\n");
else if (y>x)
printf("LESS\n");
else
{

    for (int i=0;i<x;++i){
	    if(a.at(i)>b.at(i)){
	     z=1;
	    printf("GREATER\n");
	    break;
	    }
	else if (a.at(i)<b.at(i)){
     z=1;
	printf("LESS\n");
	break;
		}
    }
if (z==0)
printf("EQUAL\n");	


}
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct BellmanFord {
private:
    struct Edge {
        int from, to;
        T cost;
    };
    
    int n;
    vector<vector<int>> graph;
    vector<bool> used;
    vector<Edge> edges;
    
    void dfs(int v) {
        if (used[v]) return;
        used[v] = true;
        for(auto u : graph[v]) {
            dfs(u);
        }
    }
    
public:
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    
    BellmanFord(){};
    BellmanFord(int _n) {
        n = _n;
        graph.resize(n);
        used.resize(n);
        dist.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        edges.push_back((Edge){from, to, cost});
        graph[from].push_back(to);
    }
    
    bool get_distance(int from, int to = -1) {
        vector<bool> reach(n, true);
        for(int i = 0; i < n; i++) {
            fill(used.begin(), used.end(), false);
            dfs(i);
            if (to != -1) reach[i] = used[to];
        }
        fill(dist.begin(), dist.end(), inf);
        dist[from] = 0;
        for(int i = 0; i < n; i++) {
            bool update = false;
            for(auto e : edges) {
                if ((!reach[e.from]) || (!reach[e.to]) || (dist[e.from] == inf)) continue;
                if (dist[e.to] > (dist[e.from] + e.cost)) {
                    dist[e.to] = dist[e.from] + e.cost;
                    update = true;
                }
            }
            if (!update) break;
            if (i == (n - 1)) {
                return true;
            }
        }
        return false;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, -c);
    }
    if (bf.get_distance(0, n - 1)) cout << "inf" << endl;
    else cout << -bf.dist[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=20;
int n,a[N],x[N][N],y[N][N],ans;
int check(bitset<20>bits)
{
    for(int i=0;i<n;i++)if(bits[i])for(int j=0;j<a[i];j++)if(bits[x[i][j]]!=y[i][j])return 0;
    return bits.count();  
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++)cin>>x[i][j]>>y[i][j],x[i][j]--;;
    }
    for(int i=0;i<1<<n;i++)ans=max(ans,check(i));

    return cout<<ans,0;
}

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

void solve() {
  int n; cin >> n;
  if (n == 0) exit(0);
  vector<int> l(n), h(n);
  for (int i = 0; i < n; i++) cin >> l[i] >> h[i];

  vector<unordered_map<int, int>> dp(2);
  dp[0][1] = 1;
  int ans = 0;
  for (int i = 0; i < 2 * n + 1; i++) {
    for (const auto& p : dp[0]) {
      const int S = p.first;
      if (S >> (4 * n) & 1) ans += p.second;
      for (int x = 0; x < 10; x++) {
        int T = 0;
        for (int j = 0; j < 25; j++) {
          int k = j / 4;
          if ((S >> j & 1) == 0 || k >= n) continue;
          if (j % 4 == 0) {
            // k個目はじめから
            if (l[k] <= x && x <= h[k]) T |= 1 << (j + 4);
            if (x == 0) continue;
            if (l[k] / 10 == x) {
              T |= 1 << (j + 1);
            } else if (h[k] / 10 == x) {
              T |= 1 << (j + 3);
            } else if (l[k] / 10 < x && x < h[k] / 10) {
              T |= 1 << (j + 2);
            }
          } else if (j % 4 == 1) {
            // k個目10の位最小を使った
            int up = l[k] / 10 == h[k] / 10 ? h[k] % 10 : 9;
            if (l[k] % 10 <= x && x <= up) T |= 1 << (j + 3);
          } else if (j % 4 == 2) {
            // k個目10の位真ん中を使った
            T |= 1 << (j + 2);
          } else {
            // k個目10の位最大を使った
            if (x <= h[k] % 10) T |= 1 << (j + 1);
          }
        }
        dp[1][T] += p.second;
      }
    }
    swap(dp[0], dp[1]);
    dp[1].clear();
  }
  cout << ans << endl;
}
signed main() {
  while (1) solve();
}



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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int h,w,k;
vector<string> inp;

int main() {
	cin >> h >> w >> k;
	string s;
	for(int i=0;i<h;i++) {
		cin >> s;
		inp.push_back(s);
	}

	int ans = 0;
	for(int i=0;i<(1<<h);i++) {
		for(int j=0;j<(1<<w);j++) {

			int cnt = 0;
			for(int a=0;a<h;a++) {
				for(int b=0;b<w;b++) {

					if(i & (1<<a)) continue;
					if(j & (1<<b)) continue;

					if(inp[a][b] == '#') cnt++;
				}
			}

			if(cnt == k) ans++;
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3644
import itertools
h, w = map(int, input().split())
s = [input() for i in range(h)]
for i, j in itertools.product(range(h), range(w)):
  if s[i][j] == '#' and (i == 0 or s[i - 1][j] == '.') and (j == 0 or s[i][j - 1] == '.') and (i == h - 1 or s[i + 1][j] == '.') and (j == w - 1 or s[i][j + 1] == '.'):
    print('No')
    break
else:
  print('Yes')


Measured memory_bytes: 3064
import java.util.*;

class Main {
	
	static double EPS = 1e-9;
	
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		while(n-- > 0){
			double x1 = in.nextDouble(), y1 = in.nextDouble(), r1 = in.nextDouble(),
					x2 = in.nextDouble(), y2 = in.nextDouble(), r2 = in.nextDouble();
			double d = getDist(x1, y1, x2, y2);
			if(d > r1 + r2 + EPS){
				System.out.println(0);
			}
			else if(d > Math.abs(r1-r2) - EPS){
				System.out.println(1);
			}
			else{
				if(r1 > r2){
					System.out.println(2);
				}
				else{
					System.out.println(-2);
				}
			}
		}
	}
	
	private static double getDist(double x1, double y1, double x2, double y2){
		return Math.hypot(x2-x1, y2-y1);
	}

}

Measured memory_bytes: 12000
<?php
$N = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));

if (($N % 2) == 0) {
  //var_dump(solv($N));
  printf("%d\n",solv3($N));
}
else {
  //var_dump(solv($N));
  printf("%d\n",0);
}

function solv($N) {
  $res = $N;
  while(1) {
     if ($N <= 2) break;
     $res =  bcmul($res , ($N - 2));
     $N=$N-2;
  }
  $len = strlen($res);
  $cnt=0;
  for($i=$len-1;$i>0;$i--) {
    if ($res[$i]=="0") $cnt++;
    else break;
  }
  return $cnt;
}

function solv2($N) {
  $res = 0;
  $xx = 5;
  while(1) {
    $res += intdiv($N,$xx);
    $xx = $xx * 5;
    if ($xx >= intdiv($N,10)) break;
  }
  return intdiv($res,2);
}
//https://atcoder.jp/contests/abc148/submissions/9070856
function solv3($N) {
  $r=0;
  for($i=1;2*5**$i<10**18;$i++) {
    $r+=intdiv($N,2*5**$i);
  }
  return $r;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
int H,W;
ll K;
string s[1000];
ll ex(ll x,ll p){
	ll a=1;
	while(p){
		if(p%2) a=a*x%mod;
		x=x*x%mod;
		p/=2;
	}
	return a;
}
ll inv(ll x){
	return ex(x,mod-2);
}
int main(){
	cin>>H>>W>>K;
	rep(i,H) cin>>s[i];
	if(K==0){
		puts("1");
		return 0;
	}
	K--;
	bool cw=0,ch=0;
	rep(i,H) if(s[i][0]=='#' && s[i][W-1]=='#') cw=1;
	rep(i,W) if(s[0][i]=='#' && s[H-1][i]=='#') ch=1;
	if(cw&&ch){
		puts("1");
		return 0;
	}
	ll n=0;
	rep(i,H) rep(j,W) if(s[i][j]=='#') n++;
	if(!cw&&!ch){
		cout<<ex(n,K)<<endl;
		return 0;
	}
	if(ch){
		string tmp[1000];
		rep(i,H) rep(j,W) tmp[j].pb(s[i][j]);
		rep(i,W) s[i]=tmp[i];
		swap(H,W);
	}
	ll x=0;
	rep(i,H) if(s[i][0]=='#'&&s[i][W-1]=='#') x++;
	ll t=0;
	rep(i,H) rep(j,W-1){
		if(s[i][j]=='#'&&s[i][j+1]=='#') t++;
	}
	ll p=n*inv(x)%mod;
	t=t*inv(x)%mod;
	ll A,B,C;
	if(p==1){
		B=(1-t*(K%mod))%mod;
	}else{
		C=(1-t*inv(p-1)%mod)*ex(p,K)%mod;
		B=(C+t*inv(p-1))%mod;
	}
	A=B*ex(x,K)%mod;
	if(A<0) A+=mod;
	cout<<A<<endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

char c;

void solve() {
	cin >> c;
	if(c >= 'a') cout << "a\n";
	else cout << "A\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int par[200001], rank_[200001];
void init() {
	rep(i, 200001) {
		par[i] = i; rank_[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank_[x] < rank_[y])par[x] = y;
	else {
		par[y] = x;
		if (rank_[x] == rank_[y])rank_[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
struct edge { int u, v; ll cost; };
bool comp(const edge&e1, const edge&e2) {
	return e1.cost < e2.cost;
}
edge es[100000];
int n, m, k; int cnt = 0;
int c[100000];
ll kruskal() {
	sort(es, es + m, comp);
	init();
	ll res = 0;
	rep(i, m) {
		edge e = es[i];
		if (!same(e.u,e.v)) {
			unite(e.u,e.v);
			res += e.cost;
			cnt++;
		}
		if (cnt == k - 1)break;
	}
	return res;
}
int main(){
	cin >> n>>m>>k;
	rep(i, n) {
		cin >> c[i];
	}
	rep(i, m) {
		int u, v; ll w; cin >> u >> v >> w; u--; v--;
		int c1 = c[u]; int c2 = c[v];
		if (c1 == 0)c1 = u + k + 1;
		if (c2 == 0)c2 = v + k + 1;
		es[i] = { c1,c2,w };
	}
	ll out=kruskal();
	if (cnt == k - 1)cout << out << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3712
use std::cmp;

fn main() {
    let n = read_values::<usize>()[0];
    let a = (0..2).map(|_| read_values::<usize>()).collect::<Vec<_>>();
    let mut dp = vec![vec![0; n]; 2];
    dp[0][0] = a[0][0];
    for i in 1..n {
        dp[0][i] = dp[0][i - 1] + a[0][i];
    }
    dp[1][0] = dp[0][0] + a[1][0];
    for i in 1..n {
        dp[1][i] = cmp::max(dp[1][i - 1], dp[0][i]) + a[1][i];
    }

    println!("{}", dp[1][n - 1]);
}

fn read_line() -> String {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}


Measured memory_bytes: 4352
N = int(input())
H = list(map(int, input().split()))

max_count = 0
count = 0
for i in range(0, N-1):
  if int(H[i]) >= int(H[i+1]):
    count += 1
  else:
    if max_count < count:
      max_count = count
    count = 0
  if i == N-2:
    if max_count < count:
      max_count = count
    
print(max_count)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    cout << (a+b+c)-max(a,max(b,c)) << endl;
    return 0;
}

Measured memory_bytes: 256