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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    lli a,b,c;
    cin3(a,b,c);
    lli l[n];
    ncin1(n, l);
    lli ans = LLONG_MAX;
    REPE(i, 1, n) {
        REPE(j, 1, n) {
            if (i + j > n)
                continue;
            REPE(k, 1, n) {
                if (i + j + k > n)
                    continue;
                sort(l, l+n);
                do {
                    lli total = 0;
                    lli sum = 0;
                    REP(p, 0, i) {
                        sum += l[p];
                        if (p != 0)
                            total += 10;
                    }
                    total += abs(sum - a);

                    sum = 0;
                    REP(p, i, i+j) {
                        sum += l[p];
                        if (p != i)
                            total += 10;
                    }
                    total += abs(sum - b);

                    sum = 0;
                    REP(p, i+j, i+j+k) {
                        sum += l[p];
                        if (p != i+j)
                            total += 10;
                    }
                    total += abs(sum - c);

                    //cout3(i,j,k);
                    //cout1(total);
                    //REP(i,0,n) {
                    //    cout << l[i] << ", ";
                    //}
                    //cout << endl;
                    ans = min(ans, total);

                } while (next_permutation(l, l+n));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(int)ceil(1.0*n/x)*t<<endl;
	return 0;
}

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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }


int main() {
    IOS

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

    unordered_map<ll, ll> mc;
    mc[0] = 1;
    ll cur_s = 0;
    ll ans = 0;
    vector<ll> diffs;
    diffs.push_back(0);
    for (int i = 0; i < n; ++i) {
        if (diffs.size() >= k) {
            mc[diffs[diffs.size() - k]]--;
        }
        cur_s += a[i];
        ll diff = mod(i + 1 - (cur_s % k), k);
        ans += mc[diff];
        mc[diff]++;
        diffs.push_back(diff);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 11708
import collections

n=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)

MAX1=0
MAX2=0

for i,m in c.items():
    if m>=2 and m<4:
        if i>MAX1 and i>MAX2:
            if MAX1>MAX2:
                MAX2=i
            else:
                MAX1=i
        elif MAX1>i and i>MAX2:
            MAX2=i
    elif m>=4:
        if i>MAX1 and i>MAX2:
            MAX1=i
            MAX2=i
        elif MAX1>i and i>MAX2:
            MAX2=i

print(MAX1*MAX2)

Measured memory_bytes: 68760
n,k=map(int,input().split())
if 2*k-1>n:
  print(-1)
else:
  a=[i for i in range(k,k+n)]
  A=[]
  for i in range(len(a)):
    if i%2==0:
      A.append(a[i])
  for i in range(len(a)):
    if i%2==1:
      A.append(a[i])
  b1=[i for i in range(k+n,k+n+(n+1)//2)]
  b2=[i for i in range(k+n+(n+1)//2,k+2*n)]
  b1.reverse()
  b2.reverse()
  B=b1+b2
  C=[i for i in range(k+2*n,k+3*n)]
  for i in range(n):
    print(A[i],B[i],C[i])

Measured memory_bytes: 18648
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;


int main() {

    string S;
    string T;
    cin >> S >> T;

    map<char, char> StoT;
    map<char, char> TtoS;

    bool ok = true;

    for (int i = 0; i < S.size(); i++) {

        char s = S[i];
        char t = T[i];

        if (StoT.find(s) != StoT.end()) {
            if (StoT[s] != t) {
                ok = false;
                break;
            }
        } else {
            StoT[s] = t;
        }

        if (TtoS.find(t) != TtoS.end()) {
            if (TtoS[t] != s) {
                ok = false;
                break;
            }
        } else {
            TtoS[t] = s;
        }


    }

    if (ok) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

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

    valarray<int> A(N);
    rep(i, N) cin >> A[i];
    
    int choosen = 0;
    for(auto& a : A) if(4*M*a >= A.sum()) choosen++;

    Cout(Yes(choosen >= M));
}


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

grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)

grid.sort()

kosu = 0
price = 0
for i in range(N):
    if kosu == M:
        break
    elif kosu+grid[i][1] < M:
        kosu = kosu + grid[i][1]
        price = price + grid[i][0]*grid[i][1]
    else:
        price = price + (M-kosu)*grid[i][0]
        break

print(price)

Measured memory_bytes: 27760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    priority_queue<ll, vector<ll>> pq;
    REP(i, 0, n) {
        int a;
        cin >> a;
        pq.emplace(a);
    }
    REP(i, 0, m) {
        auto p = pq.top();
        pq.pop();
        p /= 2;
        pq.emplace(p);
        //dump(p);
    }
    ll ans = 0;
    REP(i, 0, n) {
        auto p = pq.top();
        pq.pop();
        ans += p;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int res=min(b,d)-max(a,c);
  if(res<0)res=0;
  cout<<res<<endl;

  return 0;

}


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

int main(){
    int k;
    cin >> k;
    if(k%2==1){
        cout << (k/2)*(k/2+1) << endl;
    }else{
        cout << (k/2)*(k/2) << endl;
    }
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
void solve() {
	int n; cin >> n;
	int a[100002] = {};
	set<int> key_num;
	rep (i, n) {
		int in_num; cin >> in_num;
		a[in_num]++;
		key_num.insert(in_num);
	}
	int ans = -1;
	for (auto itr = key_num.begin(); itr != key_num.end(); ++itr) {
		int cnt = a[*itr - 1] + a[*itr] + a[*itr + 1];
		ans = max(cnt, ans);
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  rep(i,n) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

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

int main() {
  int A,B;	
  char op;
  int kekka;
  cin >> A >> op >> B;
  
  if (op=='+') {
    kekka = A+B;
  }
  else {
    kekka = A-B;
  }
  
  
  cout << kekka <<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{

    class Program
    {
        private static Dictionary<int, int> Dict = new System.Collections.Generic.Dictionary<int, int>();
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(fib(n));
        }
        private static int fib(int n) {
            if (n <= 1) return 1;
            if (Dict.ContainsKey(n)) return Dict[n];
            Dict[n] = fib(n - 1) + fib(n - 2);
            return Dict[n];
        }
    }
}




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

before=sum(A)
for n in range(N):
    temp = A[n]
    A[n] = max(0, A[n]-B[n])
    B[n] = max(0, B[n]-temp)
    A[n+1] = max(0, A[n+1]-B[n])
after=sum(A)
print(before-after)


Measured memory_bytes: 19156
#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 10000;
const int MAX_LENGTH = 1000000;
   
long value[MAX_NUM];
long sum,min_num,max_num;  

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

	min_num = value[0];
	max_num = value[0];
	for( int i=0; i<=n-1; i++ )  
	{  
		if ( value[i] < min_num )
		{
			min_num = value[i];
		}
		if ( value[i] > max_num )
		{
			max_num = value[i];
		}
		sum += value[i];
	}  
	cout << min_num << ' ' << max_num << ' ' << sum << endl;    
 
	return 0;  
}  

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

int main()
{
    char a,b,c,d,e,f;
    string s,t;
    cin>>s>>t;
    a = s[0], b = s[1], c = s[2];
    d = t[0], e = t[1], f = t[2];
    if((a==f)&&(b==e)&&(c==d))
        printf("YES\n");
    else
        printf("NO\n");
    //main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i, j, k, n, v;
	int A[1000];
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	printf("%d", A[0]);
	for(k = 1; k < n; k++){
		printf(" %d", A[k]);
	}
	printf("\n");
	for(i = 1; i <= n-1; i++){
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
			A[j+1] = v;
		}
		printf("%d", A[0]);
		for(k = 1; k < n; k++){
			printf(" %d", A[k]);
		}
		printf("\n");
	}
	return 0;
}


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


int main(){
  vector<vector<int>> A(3, vector<int>(3));
  for(auto& row: A){
    for(auto& cell : row){
      cin >> cell;
    }
  }

  int N;
  cin >> N;

  vector<int> B(N);
  for(auto& b : B){
    cin >> b;
  }

  for(auto& b : B){
    for(auto& row: A){
      for(auto& cell : row){
        if(cell==b) cell=-1;
      }
    }
  }

  for(int row=0; row<3; row++){
    int sum=0;
    for(int col=0; col<3; col++){
      if(A[row][col]==-1) sum++;
    }
    if(sum==3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  for(int col=0; col<3; col++){
    int sum=0;
    for(int row=0; row<3; row++){
      if(A[row][col]==-1) sum++;
    }
    if(sum==3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if((A[0][0]==-1)&&(A[1][1]==-1)&&(A[2][2]==-1)){
    cout << "Yes" << endl;
    return 0;
  }

  if((A[0][2]==-1)&&(A[1][1]==-1)&&(A[2][0]==-1)){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
//RAM--RAM!
//number_of_connected_componnents_only__
//only__undirected__edges__
//Works_only_for_1_testcase.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;ll t;
ll b[3000000];

vector<vector<ll> >graph;
vector<bool>vis;
void dfs(ll src,ll &c)
{
    //cout<<src<<" ";
    b[c]=src;
    c++;
    vis[src]=true;

    
    
    for(auto it:graph[src])
    {
    
        
        if(!vis[it])
        {
           
            dfs(it,c);
        
            
        }
    }
    //cout<<"     ";
}
int main()
{  
    ll n,m; //__number_of_nodes_and_edges__
    cin>>n>>m;
    ll kff;
    cin>>kff;
    ll a[n+1111]={0};
    
   // ll i1=1;
  //  while(i1<=n)
 //   {
  //      cin>>a[i1];//__aceepting the values of all nodes!
   //     i1++;
   // }
    map<ll,ll> gf,jf;
    graph.assign(n+3,vector<ll>());
    vis.assign(n+4,false);
    for(ll i=1;i<=m;i++)
    {
        ll x,y;
       cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
        
      
    }
    ll connected=0;

    for(ll i=1;i<=n;i++)
    {
        ll c=0;
        if(!vis[i])
        {
       
//cout<<"Required-guys:--->";     
            dfs(i,c);
            
            
            
           
            
           // cout<<"Elements  ";
            ll j=0;
            while(j<c)
            {   
            
               // cout<<b[j]<<" ";     
                     gf[b[j]]=c;
                     jf[b[j]]=connected+1;
                j++;
            }
            
            
            //cout<<"\n";
            
                         connected++;
             //cout<<c<<"     "<<connected<<"\n";
        }
      
        
      
    }
    
    
    //cout<<"\n";
    map<ll,ll> a1;
   ll i=1;
   while(i<=kff)
   {
        ll x,y;
       cin>>x>>y;
      
       if(jf[x]==jf[y])
       { //cout<<x<<" "<<y<<"\n";
           a1[x]++;
           a1[y]++;
       }
       
       i++;
   }
   
   
    i=1;
   while(i<=n)
   {
     //  cout<<i<<" ";
       ll m1=gf[i];
       m1--;
       ll gfff=graph[i].size();
      // cout<<gfff<<"\n";
       ll m2=abs(m1-gfff);
       ll m3=abs(m2-a1[i]);
       cout<<m3;cout<<" ";
       i++;
   }
    
 return 0;
}

Measured memory_bytes: 28032
N = int(input())
lia= [ [ int(it) for it in input().split() ] for i in range(N)]
lib= [ [ int(it) for it in input().split() ] for i in range(N)]

# Hopcroft-Karp Algorithm
from collections import deque
class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        G = self.G
        bfs = self.bfs; dfs = self.dfs
        while bfs():
            *self.it, = map(iter, G)
            while dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]
    
hop = HopcroftKarp(N,N)

for i in range(N):
  a,b = lia[i]
  for j in range(N):
    c,d = lib[j]
    if ( a<c and b<d ):
      hop.add_edge(i,j)
co = hop.flow()
print ( co )

Measured memory_bytes: 45164
from itertools import accumulate
N, K, *A = map(int, open(0).read().split())

def check(d):
    r = sorted([v % d for v in A])
    r_inv = [d - v for v in r]    
    r_cs = [0] + list(accumulate(r))
    r_inv_cs = list(accumulate(r_inv[::-1]))[::-1] + [0]

    ret = False
    for i in range(N + 1):
        flg1 = r_cs[i] <= K
        flg2 = r_cs[i] == r_inv_cs[i]
        ret = (flg1 and flg2) or ret
    
    return ret

M = sum(A)
ans = 0
for i in reversed(range(1, int(M ** 0.5) + 1)):
    if M % i == 0 and check(i):
        ans = max(ans, i)
    if M % (M // i) == 0 and check(M // i):
        ans = max(ans, M // i)
        
print(ans)


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

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

    int lcnt = 0, rcnt = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') cnt++;
        else if (cnt == 0) lcnt++;
        else cnt--;
    }

    cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == ')') cnt++;
        else if (cnt == 0) rcnt++;
        else cnt--;
    }

    for (int i = 0; i < lcnt; i++) cout << '(';
    cout << s;
    for (int i = 0; i < rcnt; i++) cout << ')';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n, m, tl[10001], tr[10001], i, j, k, befor, maxnum;
 
  while(1){
    scanf("%d %d", &n, &m);
    if(n==0 && m==0) break;

    for(i=0;i<n;i++){
      scanf("%d", &tl[i]);
    }
    tl[i]=1000001;
 
    for(i=0;i<m;i++){
      scanf("%d", &tr[i]);
    }
    tr[i]=1000001;

	j=0;
	k=0;
	maxnum=-1;
	befor=0;
	for(i=0;i<n+m+1;i++){
		if(tl[j]<=tr[k]){
			if(maxnum<tl[j]-befor){
				maxnum = tl[j] - befor;
			}
			befor=tl[j];
			j++;
		}
		else if(tl[j]>tr[k]){
			if(maxnum<tr[k]-befor){
				maxnum = tr[k] - befor;
			}
			befor=tr[k];
			k++;
		}
		if(tl[j]==tr[k]){
			i++;
			k++;
		}
	}
    printf("%d\n", maxnum);
  }
  
  return 0;
}

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

#include<algorithm>
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b){ 
 swap(a,b);
  } if(b>c){
 swap(b,c);
  } if(a>b){
    swap(a,b);
  }

  cout <<  a << " " << b << " " << c << endl;
return 0;
}

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

int main()
{
  int n; cin >> n;
  string s1, s2; cin >> s1 >> s2;

  ll ans = 1;
  int b = 0;
  for (int i=0; i<n; i++) {
    if (s1[i] == s2[i]) {
      if (b == 0) ans *= 3;
      else if (b == 1) ans *= 2;

      b = 1;
    } else {
      if (b == 0) ans *= 6;
      else if (b == 1) ans *= 2;
      else ans *= 3;

      i++;
      b = 2;
    }
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

void kesan(int, int*, int*);
int main(){
  int n, i , j, a;
  while(true){
    cin >> n;
    a = 0;
    if(!n)
      break;
    n = 1000 - n;
    kesan(500, &a, &n);
    kesan(100, &a, &n);
    kesan(50, &a, &n);
    kesan(10, &a, &n);
    kesan(5, &a, &n);
    a += n;

    printf("%d\n", a);
  }
	return 0;
}

void kesan(int coin, int *a, int *n){
  int i = *n / coin;
  *a += i;  
  *n -= i * coin;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int a[25],b[25],c[25];
int main(){
	int n,i,p=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=1;i<=n;i++){
		cin>>b[i];
		p+=b[i];
	}
	for(i=1;i<n;i++){
		cin>>c[i];
	}
	for(i=2;i<=n;i++){
		if(a[i]-1==a[i-1]) p+=c[a[i-1]];
	}
	cout<<p;
	return 0;
}

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

{
    int h,w;
    char a[10][10];
    cin>>h>>w;
    int sum=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')
                sum++;
        }
    }
    int i=0,j=0;
    while(1)
        {
           if(a[i][j]=='#')
             {
                  i++;
              if(a[i][j]!='#')
                 i--,j++;
             }
            else
            {
                 j--;
                 break;
            }

        }
    if(sum==w+h-1&&i==h-1&&j==w-1)
        cout<<"Possible"<<endl;
    else
        cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
s = ''
for i in range(3):
    a, b = input().split()
    s += a + b


if s.count('1')==3:
    print('NO')
elif s.count('2')==3:
    print('NO')
elif s.count('3')==3:
    print('NO')
elif s.count('4')==3:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3060
import scala.io.StdIn._
import scala.collection.mutable

object Main extends App {
  
  def solve(m: Int, a: Array[Int], i: Int = 0, memo: mutable.Map[(Int, Int), Boolean]= mutable.Map()): Boolean = m match {
    case 0 => true
    case _ if i >= a.size => false
    case _ if (memo.get(i, m) != None) => memo((i, m))
    case _ => 
      val r = solve(m, a, i + 1, memo) || solve(m - a(i), a, i + 1, memo)
      memo += ((i, m) -> r)
      r
  }

  val N = readLine.toInt
  val A = readLine.split(" ").map(_.toInt)
  val Q = readLine.toInt
  val M = readLine.split(" ").map(_.toInt)
  M.foreach(m => if (solve(m, A)) println("yes") else println("no"))
}


Measured memory_bytes: 265716
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int r,c;
    cin >> r >> c;
    int a[r+1][c+1];
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            a[i][j] = 0;
        }
    }
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
        }
    }
    for(int i = 0; i < c; i++) a[r][c] += a[r][i];
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            cout << a[i][j];
            if(j != c) cout << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>
 int main(void)
{ int *list; int n,i,j,cnt; 
 while(scanf("%d",&n) != EOF) {  cnt = 0;  list = (int*)calloc(n+1,sizeof(int));
  for(i = 2; i <= n; i++)  {
   if(list[i] != 1) /*prime number:0 no prime numbers:1*/   {     cnt++;
    for(j = i+i; j <= n; j+=i) list[j] = 1;   }  }  printf("%d\n",cnt);
  free(list); }  return 0;}

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
   int n; cin >> n;
   vector<int> a(n);
   vector<vector<int>> x(n),y(n);
    rep(i,n){
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        rep(j,a[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    } 

    int res=0;
    

    for(int bit=0; bit<(1<<n); bit++){
        bool can=true;
        for(int i=0; i<n; i++){
            //iが正直者なら
            if(bit&(1<<i)){
                for(int j=0; j<x[i].size(); j++){
                    //矛盾が生じた時
                    //if((bit&(1<<x[i][j]))^y[i][j]) can=false;
                    if(((bit >> (x[i][j])) & 1) ^ y[i][j]) can = false;
                }
            }
        }
        if(can) chmax(res,__builtin_popcount(bit));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
bool used[100005];
vector<int> b[100005];
long long dp[100005][2];
void dfs(long long u){
	if(used[u]) return;
	used[u]=true;
	for(auto v : b[u]){
		if(!used[v]){
			dfs(v);
			dp[u][0]*=(dp[v][0]+dp[v][1])%mod;
			dp[u][0]%=mod;
			dp[u][1]*=dp[v][0]%mod;
			dp[u][1]%=mod;
		}
	}
}
int main(){
	long long n,u,v;
	scanf("%lld",&n);
	for(long long i=1;i<=n-1;i++){
		scanf("%lld %lld",&u,&v);
		b[u].push_back(v);
		b[v].push_back(u);
	}
	for(long long i=1;i<=n;i++){
		dp[i][0]=1;
		dp[i][1]=1;
	}
	dfs(1);
	printf("%lld",(dp[1][0]+dp[1][1])%mod);
}

Measured memory_bytes: 11520
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static constexpr ll solve(const ll N, const ll A, const ll B) {
  const ll M = N - 2;
  const ll first = A * M;
  const ll last = B * M;
  return last - first + 1;
}

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if (A > B) {
    cout << 0 << endl;
  } else if (N == 1) {
    cout << (A == B ? 1 : 0) << endl;
  } else if (N == 2) {
    cout << (A == B ? 0 : 1) << endl;
  } else {
    cout << solve(N, A, B) << endl;
  }
  return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	double n;
	cin>>n;
	vector<pair<double,double>> town(n);
	for(long long i=0;i<n;i++){
		cin>>town.at(i).first>>town.at(i).second;
	}
	sort(town.begin(),town.end());

	double sum=0;
	double kai=1;
	for(long long i=1;i<=n;i++) kai*=i;

	do{
		for(long long i=1;i<n;i++){
			sum+=sqrt((town.at(i).first-town.at(i-1).first)*(town.at(i).first-town.at(i-1).first)+(town.at(i).second-town.at(i-1).second)*(town.at(i).second-town.at(i-1).second));
		}
	}while(next_permutation(town.begin(),town.end()));

	cout<<fixed<<setprecision(10)<<sum/kai<<endl;

	return 0;
}


Measured memory_bytes: 3752
def main():
    n = int(input())
    max_a, max_b = 0, 0 # type:int
    for _ in range(n):
        a, b = input().split(' ')
        a = int(a)
        if max_a < a:
            max_a = a
            max_b = int(b)
    print(max_a + max_b)


if __name__ == "__main__":
    main()

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

int main(int argc, char const* argv[])
{
    int sum=0,n,k,l[50];

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    sort(l,l+n);
    for (int i = n-1; i >= n-k; i--) {
        sum += l[i];
    }

    cout << sum << endl;
    return 0;
}

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

int bubble(vector<int> &v) {
  int n = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = v.size() - 1; j > i; j--) {
      if (v[j] < v[j - 1]) {
        swap(v[j], v[j-1]);
        n++;
      }
    }
  }
  return n;
}

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  int num = bubble(v);
  for (int i = 0; i < N; i++) {
    cout << v.at(i);
    if (i != N-1) cout << " ";
  }
  cout << endl;
  cout << num << endl;
}


Measured memory_bytes: 3112
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
x, y = 0, 0
flag = True
for i in A:
    if flag:
        if x == i:
            flag = False
        else:
            x = i
    else:
        if y == i:
            break
        else:
            y = i

print(x * y)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll x;
	cin >> x;
	
	ll c = x / 11;
	ll ans = c * 2;
	x %= 11;
	
	if (x) {
		++ans;
		x -= 6;
	}
	if (x > 0) {
		++ans;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,j,n,k,c=0;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++){
  cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<k;i++){
  c+=a[i];
  }
  cout<<c;
}

Measured memory_bytes: 3620
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    long n = s.filter!(c => c == 'x')
        .map!(x => 100)
        .sum();
    writeln(1000 - n);
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	L, R := A+B, C+D
	if L == R {
		fmt.Println("Balanced")
	} else if L > R {
		fmt.Println("Left")
	} else {
		fmt.Println("Right")
	}
}


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

int n,a;
signed main() {
	queue<int> q;
	cin>>n;
	rep(i,(1<<n)){
		cin>>a;
		q.push(a);
	}
	while(q.size()!=1){
		int l=q.front();
		q.pop();
		int r=q.front();
		q.pop();
		if(l<r)q.push(r-l);
		if(l>r)q.push(l-r);
		if(l==r)q.push(l);
	}
	cout<<q.front()<<endl;
	return 0;
}

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

int main(){
 int N;
 cin >> N;
 int i;
 int A[100];
 for(i= 0;i<N;i++){
   cin >> A[i];
 }
 for(i=0;i<N;i++){
   if(A[i]%2==0&&A[i]%3!=0&&A[i]%5!=0){
     cout << "DENIED" << endl;
     return 0;
   }
 }
     cout << "APPROVED" << endl;
 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);

    rep(i, N) { cin >> A[i]; }
    sort(all(A));

    rep(i, N) { cin >> B[i]; }
    sort(all(B));

    rep(i, N) { cin >> C[i]; }
    sort(all(C));

    ll res = 0;
    rep(i, N) {
        auto left = lower_bound(all(A), B[i]) - A.begin();
        auto right = C.end() - upper_bound(all(C), B[i]);
        res += (left * right);
    }

    cout << res << endl;
}

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

#include <iostream>
#include <fstream>

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

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

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

#endif //INCLUDE_DEBUG_HPP

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

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

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

class CVacation {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    vector<int> a(n), b(n), c(n);
	    for(int i=0; i<n; i++){
	        in >> a[i] >> b[i] >> c[i];
	    }

	    ll dp[100010][3];
	    Fill(dp, 0);
	    for(int i=0; i<n; i++){
	        for(int j=0; j<3; j++){
                if(j!=0) chmax(dp[i+1][j], dp[i][0] + a[i]);
                if(j!=1) chmax(dp[i+1][j], dp[i][1] + b[i]);
                if(j!=2) chmax(dp[i+1][j], dp[i][2] + c[i]);
	        }
	    }

	    ll res = 0;
	    for(int j=0; j<3; j++){
	        chmax(res, dp[n][j]);
	    }

	    out << res << endl;
	}
};


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


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  ll A,B,N;
  cin >> A >> B >> N;
  ll x  = B - 1;
  if(x > N) x = N;
  cout << (A*x)/B << endl;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <math.h>
#define SQR(n) (n)*(n)
int main(void){
	int n;
	double xa,ya,ra,xb,yb,rb;
	scanf("%d",&n);
	while(n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		double r=sqrt(SQR(xa-xb)+SQR(ya-yb));
		if(r>ra+rb)puts("0");
		else if(r+ra<rb)puts("-2");
		else if(r+rb<ra)puts("2");
		else puts("1");
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n) {
    string s = to_string(i+1);
    if (s.size() % 2 != 0) {
      ans++;
    }
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>



int main(){
  
  long long int N, A_max, i_max, A_max2, i_max2, A_tmp;
  A_max = 0;
  A_max2 = 0;
  
  scanf("%lld", &N);
  for(int i = 1; i <= N; i++){
    // read A
    scanf("%lld", &A_tmp);
    // update max
    if(A_tmp >= A_max){
      i_max2 = i_max;
      A_max2 = A_max;
      i_max = i;
      A_max = A_tmp;
    }
    // update second max
    else if(A_tmp >= A_max2){
      i_max2 = i;
      A_max2 = A_tmp;
    }
  }
  
  std::cerr << "Answer: " << std::endl;
  for(int i = 1; i <= N; i++){
    if(i == i_max){
      std::cout << A_max2 << std::endl;
    }
    else{
      std::cout << A_max << std::endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1664
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1

s = int(input())
r = set([s])
for i in range(1000000):
    s = f(s)
    if s in r:
        print(i+2)
        break
    r.add(s)


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    char s[5];
    int i;
    scanf("%s", s);
    if(s[0]==s[1]){
        if(s[0]!=s[2] && s[2]==s[3]){
            printf("Yes\n");
            return 0;
        }
    }
    else if(s[0]==s[2]){
        if(s[0]!=s[1] && s[1]==s[3]){
            printf("Yes\n");
            return 0;
        }
    }
    else if(s[0]==s[3]){
        if(s[0]!=s[1] && s[1]==s[2]){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}
    


Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll INF = 1e18 ; 
int main(){
    fastio
    ll n , m ; 
    cin >> n >> m ; 
    vector<ll> v[n+1] ; 
    vector<bool> vis(n+1) ; 
    vector<int> indegree(n+1) ;
    for(ll i=0;i<m;i++){
    	ll x , y ; 
    	cin >> x >> y ; 
    	v[x].push_back(y) ; 
    	indegree[y]++;
    }
    ll s , t ;
    cin >> s >> t ; 
    if ( indegree[t] == 0 ){
    	cout << -1 << endl;
    	return 0;
    }
    vector<ll> dist(n+1,INF) ; 
    dist[s] = 0 ; 
    vis[s] = true ; 
    queue<ll> q; 
    q.push(s) ; 
    while(!q.empty()){
    	ll f = q.front() ; q.pop() ; 
    	for(ll c : v[f]){
    		for(ll k : v[c]){
    			for(ll h : v[k]){
    				if ( !vis[h] ){
    					dist[h] = dist[f] + 1 ;
    					if ( h == t ){
    						cout << dist[h] << endl;
    						return 0 ; 
    					}
    					vis[h] = true ; 
    					q.push(h) ; 
    				}
    			}
    		}
    	}
    }
    cout << -1 << endl;
    return 0 ;
}


Measured memory_bytes: 6912
n=int(input())
a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
a.sort(reverse=True)

asum=0
for i in range(1,n):
    ii=(i+2)//2
#    print(ii,a[ii-1])
    asum+=a[ii-1]
    
print(asum)


Measured memory_bytes: 31444
#include<bits/stdc++.h>
#define ll long long
#define P pair<int ,int>
using namespace std;

struct edge{
    ll to ,cost;
};

ll pow(ll a ,ll n){
    if(n==0) return a;
    else return a*pow(a ,n-1);
}
int main(){
    ll n;
    cin >> n;
    ll m = pow(2 ,n);
    ll k;
    cin >> k;
    if(n==1 && k==0){
        cout << "0 0 1 1" << endl;
        return 0;
    }if((n==1 && k== 1)|| k >= m) {
        cout << "-1" << endl;
        return 0;
    }

    for(int i=0;i<m;i++){
        if(i==k)continue;
        cout << i <<" ";
    }
    cout << k << " ";
    for(int i=m-1;i>=0;i--){
        if(i==k)continue;
        cout << i << " ";
    }
    cout << k <<endl;

}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    struct stQuery {
        int a,b,c,d;
        void read() {
            cin >> a >> b >> c >> d;
            a--; b--;
        }
    };
    //int ntest; cin >> ntest; while(ntest--)
    {
        int N,M,Q; cin >> N >> M >> Q;
        vector<stQuery> queries(Q);
        fori(i,Q) queries[i].read();

        int ans = 0;
        vector<int> v(N);
        function<void(int)> recursive = [&](int i) {
            if(i == N) {
                int score = 0;
                for(auto qu: queries) {
                    if(v[qu.b]-v[qu.a] == qu.c)
                        score += qu.d;
                }
                mmax(ans, score);
                return;
            }
            int j = (i) ? v[i-1] : 1;
            fore(val,j,M) {
                v[i] = val;
                recursive(i+1);
            }
        };
        recursive(0);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3664