akhauriyash/Code-Regression huggingface dataset:
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll sm=0, t=0;
    rep(i,N){
        sm= sm^A[i];
    }
    rep(i,N){
        t=sm^A[i];
        cout << t << '\n';
    }

    return (0);
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<double> A(N);
    int work = 0,i = 0,j = 0;
    double sum = 0, line = 0;
    string ret = "No";

    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }

    for(int i = 0; i < N; i++){
        if(A[i] >= sum / (4 * M)){
            work++;
        }
    }

    if(work >= M){
        ret = "Yes";
    }

    cout << ret << endl;

}

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

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

	bool a5b5c7 = (A == 5 && B == 5 && C == 7);
	bool a5b7c5 = (A == 5 && B == 7 && C == 5);
	bool a7b5c5 = (A == 7 && B == 5 && C == 5);

	if(a5b5c7 || a5b7c5 || a7b5c5)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
cin>>x>>y;
if(x+y>=10)cout<<"error";
else cout << x+y;
}



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

namespace IPT1_5C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] inString = Console.ReadLine().Split(' ');
                int numH = int.Parse(inString[0]);
                int numW = int.Parse(inString[1]);

                if ((numH == 0) && (numW == 0)) break;

                for (int i = 0; i < numH; i++)
                {
                    for (int j = 0; j < numW; j++)
                    {
                        int work = i + j;
                        if (work % 2 == 0) Console.Write("#");
                        else Console.Write(".");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 8660
#include <iostream>
#include <vector>
 
int main(int argc, char const *argv[])
{
    std::string input;
    std::cin >> input;
    std::vector <int> freq(26, 0);
    for(char c : input){
        ++freq[c - 'a'];
    }
    bool beautiful = true;
    for(int f : freq){
        if(f % 2){
            beautiful = false;
            break;
        }
    }
    if(beautiful){
        std::cout << "Yes\n";
    } else{
        std::cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
q = deque([])

for i in range(N):
    if B[i]>A[i] and B[i]>B[(i-1)%N]+B[(i+1)%N]:
        q.append(i)

ans = 0

while q:
    i = q.popleft()
    sub = B[(i-1)%N]+B[(i+1)%N]
    
    if B[i]%sub>=A[i]:
        ans += (B[i]-B[i]%sub)//sub
        B[i] %= sub
    else:
        if (B[i]-A[i])%sub==0:
            ans += (B[i]-A[i])//sub
            B[i] = A[i]
        else:
            print(-1)
            exit()
            
    for j in [(i-1)%N, (i+1)%N]:
        if B[j]>A[j] and B[j]>B[(j-1)%N]+B[(j+1)%N]:
            q.append(j)

if A==B:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 115664
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s - x - y;
			if(z >= 0 && z <= k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
counter=0
flag=0
for i in range(N):
     D1, D2=map(int,input().split())
     if D1==D2:
         counter+=1
         if counter>=3:
             flag=1
             break
     else:
         counter=0
if flag==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main(){
    int X,Y;
    bool finished = false;
    cin>>X>>Y;
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++){
            if(i+j==X&&4*i+2*j==Y){
                finished=true;
                break;
            }
           // else if(i==0||j==0){
           //     if()
           // }
        }
        if(finished){
            break;
        }
    }
    if(finished){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n;
	for (long long i=1;i*i<=n;i++)
	{
		if (n%i==0)
		{
			a=i;
			b=n/i;
		}
	}
	cout<<a+b-2<<endl;
	return 0;
} 

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

using namespace std;

bool hoge(string str) {
  string str2 = str;
  reverse(str2.begin(), str2.end());
  return str == str2;
}

int main() {
  string str;
  cin >> str;
  int n = static_cast<int>(str.size());

  if (hoge(str) && hoge(str.substr(0, (n - 1) / 2)) &&
      hoge(str.substr((n + 3) / 2 - 1, (n - 1) / 2)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    int M1, D1, M2, D2;
    std::cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n, x, cnt = 0;
    cin >> n >> x;
    vector<int> m(n);
    for (int i = 0; i < n; ++i) {
        cin >> m[i];
        x -= m[i];
        ++cnt;
    }
    int min = *min_element(m.begin(), m.end());
    while (x >= min) {
        x -= min;
        ++cnt;
    }
    cout << cnt << endl;

    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

const int inf = 1 << 29;

class UnionFind {
public:
  vector<int> r, p;
  UnionFind(int N)
  {
    for (int i = 0; i < N; ++i) {
      r.push_back(0);
      p.push_back(i);
    }
  }
  void unite(int a, int b)
  {
    link(find(a), find(b));
  }
  int find(int a)
  {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool is_same_set(int a, int b)
  {
    return find(a) == find(b);
  }
  void link(int a, int b)
  {
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, l;
  while (cin >> n >> k >> l) {
    UnionFind x(n), y(n);
    vector<pair<int, int>> es;
    for (int i = 0; i < k; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      x.unite(a, b);
      es.push_back(make_pair(a, b));
    }
    for (int i = 0; i < l; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      y.unite(a, b);
      es.push_back(make_pair(a, b));
    }
    for (int i = 0; i < n; ++i) {
      x.find(i);
      y.find(i);
    }
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n; ++i) {
      ++cnt[make_pair(x.p[i], y.p[i])];
    }
    for (int i = 0; i < n; ++i) {
      if (i) cout << ' ' ;
      cout << cnt[make_pair(x.p[i], y.p[i])];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 16656
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(n) for(int i=0; i<n; i++)
void solve()
{
	string s,t;
	cin>>s>>t;
	int l=s.length();
	bool check=true;
	for(int i=0;i<l;i++)
	{
		if(s[i]!=t[i])
		{
			check=false;
			break;
		}
	}
	if(check)cout<<"Yes";
	else cout<<"No";
	return;
}
int32_t main() 
{ 
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0; 
}

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

using namespace std;

using ll = long long;

bool dfs(int cur, int nex_col, vector<int>& color, int n, const vector<string>& g) {
    for (int i = 0; i < n; i++) {
        if (g[cur][i] == '0') continue;
        if (color[i] != -1) {
            if (color[i] != nex_col) return false;
            continue;
        }

        color[i] = nex_col;
        if (!dfs(i, !nex_col, color, n, g)) return false;
    }
    return true;
}

int solve(int src, int n, const vector<string>& g) {
    vector<int> st(n, 0);
    int res = 1;
    queue<int> q;
    q.push(src);
    st[src] = res;

    while (!q.empty()) {
        int cur = q.front();
        q.pop();

        for (int i = 0; i < n; i++) {
            if (g[cur][i] == '0') continue;
            if (st[i] != 0) {
                if (abs(st[i] - st[cur]) != 1) return -1;
                continue;
            }

            st[i] = st[cur] + 1;
            res = max(res, st[i]);
            q.push(i);
        }
    }
    return res;
}

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

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

    vector<int> color(n, -1);
    if (!dfs(0, 0, color, n, g)) {
        cout << -1 << "\n";
        return 0;
    }

    int ans = -1;
    for (int i = 0; i < n; i++) {
        ans = max(ans, solve(i, n, g));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    if(tmp%2==0){
      if(tmp%3!=0){
        if(tmp%5!=0){
          cout << "DENIED" << endl;
          return 0;
        }
      }
    }
  }
  cout << "APPROVED" << endl;
}

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

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

    int N, M; cin >> N >> M;
    vector<pair<int, int>> req(M); // pair(end, start)
    rep(i, M) cin >> req[i].second >> req[i].first;

    sort(req.begin(), req.end());

    int res = 0, now = 0;
    rep(i, M) {
        if (now < req[i].second) {
            now = req[i].first - 1;
            ++res;
        }
    }

    cout << res << "\n";
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 1e9+7;
const int MAX = 1e5+7;

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

	int n; cin >> n;
	
	vi v1(n), v2(n);

	FOR(i, n){
		int a, b; cin >> a >> b;
		v1[i] = a+b;
		v2[i] = a-b;
	}

	sort(all(v1));
	sort(all(v2));

	cout << max(v1.back()-v1[0], v2.back()-v2[0]) << '\n';

	return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;







int main() {
    
    int n;
    cin >> n;
    string line;
    cin >> line;
    int total = 0;
    for(int i = 0;i<n-2;i++){
      if(line[i] == 'A' && line[i+1]=='B' && line[i+2]=='C'){
        total++;
      }
    }
    cout << total;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, x;
    int b[3];
    cin >> x;
    a = x / 1000; x %= 1000;
    b[0] = x / 100; x %= 100;
    b[1] = x / 10; x %= 10;
    b[2] = x;

    for(int bit = 0; bit < 1<<3; ++bit){
        int sum = a;
        for(int i = 0; i < 3; ++i){
            if (bit >> i & 1) sum += b[i];
            else sum -= b[i];
        }
        if (sum == 7){
            cout << a;
            for (int j = 0; j < 3; ++j) {
                if (bit >> j & 1) cout << '+';
                else cout << '-';
                cout << b[j];
            }
            break;
        }
    }
    cout << "=7" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define point pair<double, double>
#define x first
#define y second
#define sqr(x) (x)*(x)
using namespace std;

double cal(double x1, double y1, double x2, double y2) {
	return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

int fac(int n) {
	if (n <= 1) return 1;
	return n * fac(n - 1);
}

int main() {
	int n; cin >> n;
	vector<point> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	double ans = 0;
	sort(p.begin(), p.end());
	do {
		for (int i = 0; i < n - 1; i++) {
			ans += cal(p[i].x, p[i].y, p[i + 1].x, p[i + 1].y);
		}
	} while (next_permutation(p.begin(), p.end()));
	cout << fixed << setprecision(10);
	cout << ans / double(fac(n)) << '\n';
}


Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
work = [list(map(int, input().split())) for _ in range(n)]
work.sort(key=lambda x: (x[0], x[1]))
work.append([10**10, 0])
# print(work)

ans = 0
idx = 0
cand = []
for day in reversed(range(m+1)):
    while work[idx][0] <= m - day and idx < n:
        a, b = work[idx]
        heappush(cand, -b)
        idx += 1

    if len(cand) > 0:
        v = heappop(cand)
        ans += -v
        # print(day, -v)

print(ans)


Measured memory_bytes: 35424
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
 
using namespace std;
 
const int M = 2e3 + 3;
int n, x, y;
int t[M];

int main () {
	cin >> n >> x >> y;
	if (x > y) swap (x, y);
	for (int i = 1; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			if (i == j) continue;
			int a = 1e9, b = 1e9, c = 1e9, d = 1e9;
			a = abs(x-i) + 1 + abs(j-y);
			b = abs(y-i) + 1 + abs(x-j);
			d = j-i;
			t[min (a, min(b, d))]++; 
		}
	}
	for (int i = 1; i < n; i++) cout << t[i] << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)

	var res = 1
	var r = 0
	for {
		a, b, r = judge(a, b)
		if r == 0 {
			break
		}
		res *= r
	}
	fmt.Println(a * b * res)
}

func judge(a, b int) (int, int, int) {
	var n int
	if a >= b {
		n = b
	} else {
		n = a
	}
	for i := 2; i <= n; i++ {
		if a%i == 0 && b%i == 0 {
			return a / i, b / i, i
		}
	}
	return a, b, 0
}


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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(r<=x && x<=W-r)
		if(r<=y && y<=H-r){
			cout << "Yes" << endl;
			return 0;
		}

	cout << "No" << endl;
}


Measured memory_bytes: 3096
N = int(input())
t, x, y = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    tn, xn, yn = map(int, input().split())
    d = abs(xn - x) + abs(yn - y)
    td = tn - t
    if d > td or (d - td)%2 != 0:
        ans = 'No'
    t, x, y = tn, xn, yn
print(ans)

Measured memory_bytes: 9172
/**
 *    author:  tourist
 *    created: 05.01.2020 11:08:10       
**/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll solve(ll n, ll a, ll b, ll m) {
  if (b == 0) return n * (a / m);
  if (a >= m) return n * (a / m) + solve(n, a % m, b, m);
  if (b >= m) return n * (n - 1) / 2 * (b / m) + solve(n, a, b % m, m);
  return solve((a + b * n) / m, (a + b * n) % m, m, b);
}

pair<long long, long long> GetKBest(int k, long long cx, long long cy) {
  long long low = 0, high = 1;
  while (true) {
    long long cnt = solve(high / cx + 1, high % cx, cx, cy) + (high / cx + 1);
    if (cnt >= k) {
      break;
    }
    low = high + 1;
    high = 2 * high;
  }
  while (low < high) {
    long long mid = (low + high) >> 1;
    long long cnt = solve(mid / cx + 1, mid % cx, cx, cy) + (mid / cx + 1);
    if (cnt >= k) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  long long sx = 0, sy = 0;
  for (int x = 0; x * cx <= high; x++) {
    long long cc = (high - x * cx) / cy + 1;
    sx += cc * x;
    sy += cc * (cc - 1) / 2;
  }
  return {sx, sy};
}

bool Solvable(int k, int X, int Y) {
  auto a = make_pair(-1LL, -1LL), b = a;
  long long total = (long long) 1e9 + 7;
  long long low = 0, high = total;
  while (low < high) {
    long long mid = (low + high) >> 1;
    auto p = GetKBest(k, total - mid, mid);
    if (p.first <= X && p.second <= Y) {
      return true;
    }
    if (p.first < X) {
      a = p;
      low = mid + 1;
    } else {
      b = p;
      high = mid;
    }
  }
  return (a.second * (b.first - X) + b.second * (X - a.first) <= Y * (b.first - a.first));
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X > Y) {
    swap(X, Y);
  }
  int low = 3, high = (int) 2e6;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Solvable(mid, X, Y)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ld epsilon = 10e-9;
const ll nax = 0;
ll x;
	
int main(void){
	IOS
	cin >> x;
	ll ans=x/11*2;
	x%=11;
	if(x<7 && x>0) ans++;
	else if(x>=7) ans+=2;
 	cout << ans << '\n';
}


Measured memory_bytes: 3616
using System;
using System.Linq;
class program{
  static void Main(){
    double[] abhk = Array.ConvertAll(Console.ReadLine().Split(' '),double.Parse);
    double arg = abhk[2]/6+abhk[3]/360-abhk[3]/30;
    if(arg > 1){
      arg = 2-arg;
    }
    double ans = abhk[0]*abhk[0]+abhk[1]*abhk[1]-2*abhk[0]*abhk[1]*Math.Cos(Math.PI*arg);
    Console.Write(Math.Sqrt(ans));
  }
}

Measured memory_bytes: 27764
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def cmb(n,r):  #nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n-r+1,n+1):
        retVal *= i
    for i in range(2,r+1):
        retVal //= i
    return retVal
def main():
    from collections import defaultdict
    N = int(input())
    d = defaultdict(lambda:0)
    base = ord('a')
    for _ in range(N):
        s = input().strip()
        num = 0
        for c in s:
            num += 26 ** (ord(c) - base)
        d[num] += 1
    ans = 0
    #print(d.values())
    for n in d.values():
        if n >= 2:
            ans += cmb(n,2)
    print(ans)

        

    





    pass
if __name__ == '__main__':
    main()

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

const int INF = 1e4;
int n, ma, mb;
int a[40], b[40], c[40];
int dp[401][401];

int main() {
    scanf("%d %d %d", &n, &ma, &mb);
    for (int i = 0; i < n; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);
    for (int i = 0; i <= 400; i++) {
        for (int j = 0; j <= 400; j++) dp[i][j] = INF;
    }
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 400; j >= a[i]; j--) {
            for (int k = 400; k >= b[i]; k--) {
                dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
            }
        }
    }
    
    int ans = INF;
    for (int i = 1; i * max(ma, mb) <= 400; i++) {
        ans = min(ans, dp[i * ma][i * mb]);
    }

    printf("%d\n", (ans == INF) ? -1 : ans);
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//qsort(配列, 長さ, sizeof(int), compare_int);
double BS(int array[],int len,int target);

int N,M;
int A[1000000];
int B[1000000];

int main(){
    scanf("%d%d",&N,&M);
    for(int i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    qsort(A,N,sizeof(int),compare_int);

    for(int i = 0;i < M;i++){
        scanf("%d",&B[i]);
    }
    qsort(B,M,sizeof(int),compare_int);

    for(int i = 0;i < N-1;i++){
        if(A[i] == A[i+1]){
            printf("0\n");
            return 0;
        }
    }
    for(int i = 0;i < M-1;i++){
        if(B[i] == B[i+1]){
            printf("0\n");
            return 0;
        }
    }

    long int count = 1;
    
    for(int x = N*M;x > 0;x--){
        double a = BS(A,N,x);
        double b = BS(B,M,x);
        if((int)(a*10.0)%10 == 0 && (int)(b*10.0)%10 == 0){
            count *= 1;
            //printf("%d\t%d",x,1);
        }
        if((int)(a*10.0)%10 == 0 && (int)(b*10.0)%10 != 0){
            count *= (long int)(M - (int)(b + 0.5));
            //printf("%d\t%d",x,M - (int)(b + 0.5));
        }
        if((int)(b*10.0)%10 == 0 && (int)(a*10.0)%10 != 0){
            count *= (long int)(N - (int)(a + 0.5));
            //printf("%d\t%d",x,N - (int)(a + 0.5));
        }
        if((int)(a*10.0)%10 != 0 && (int)(b*10.0)%10 != 0){
            count *= (long int)((N - (int)(a + 0.5))*(M - (int)(b + 0.5)) - (N * M - x));
            //printf("%d\t%d",x,(N - (int)(a + 0.5))*(M - (int)(b + 0.5)) - (N * M - x));
        }
        count = count % 1000000007;
        //printf("\t%ld\n",count);
    }
    printf("%ld\n",count);

    return 0;
}

double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
class Program
{
	//static long[,] dp;
	//static	Dictionary<string, long> dp;
	//static int[] weight, value;
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
		//int N = Int32.Parse(Console.ReadLine()); // 夏休みの日数
		string[] input = Console.ReadLine().Split(' '); // A,B,C
		int A = Int32.Parse(input[0]);
		int B = Int32.Parse(input[1]);
		int C = Int32.Parse(input[2]);
		/*weight = new int[N];
		value = new int[N]; // 重さと価値の入力値
		for(int i=0; i<N; i++){
			string[] items = Console.ReadLine().Split(' ');
			weight[i] = Int32.Parse(items[0]);
			value[i] = Int32.Parse(items[1]);
		}*/
//Console.WriteLine(weight[0] + "");


		Console.WriteLine(Math.Max(C-A+B, 0)+ "");

    }
}


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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))



void solve(){
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


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


// ref : https://drken1215.hatenablog.com/entry/2019/03/03/224100

int main(){
    std::string S;
    std::cin >> S;
    std::stack<char> st;

    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(st.empty() || st.top() == S[i]){
            st.push(S[i]);
        }else{
            st.pop();
            ans++;
        }
    }

    std::cout << 2 * ans << std::endl;
    return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 main()
{
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;

    ll ans = 0;
    ans += min(N, K) * X;
    ans += max(0, N-K)*Y;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	char hyou[3][3];
	while (cin >> hyou[0][0]) {
		if (hyou[0][0] == '0') {
			break;
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != 0 ||  j != 0) {
					cin >> hyou[i][j];
				}
			}
		}
		bool hantei = true;
		for (int i = 0; i < 3; i++) {
			if (hyou[i][0] != '+' && hyou[i][0] == hyou[i][1] && hyou[i][0] == hyou[i][2]) {
				cout << hyou[i][0] << endl;
				hantei = false;
				break;
			}
			if (hyou[0][i] != '+' && hyou[0][i] == hyou[1][i] && hyou[0][i] == hyou[2][i]) {
				cout << hyou[0][i] << endl;
				hantei = false;
				break;
			}
		}
		if (hantei) {
			if (hyou[0][0] != '+' && hyou[0][0] == hyou[1][1] && hyou[0][0] == hyou[2][2]) {
				cout << hyou[0][0] << endl;
				hantei = false;
			}
			if (hyou[0][2] != '+' && hyou[0][2] == hyou[1][1] && hyou[0][2] == hyou[2][0]) {
				cout << hyou[0][2] << endl;
				hantei = false;
			}
			if (hantei) {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1136
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int main(){
    int m,n;
    char a;
    ll count=0;
    ll sumAll=0,sum=0;
    while(cin>>m>>a>>n){
        sumAll+=m*n;
        sum+=n;
        count++;
    }
    cout<<sumAll<<endl;
    cout<<(int)((double)(sum)/count+0.5)<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w, h;
        cin >> w >> h;
        if(h == 0)
            return 0;

        int n = 1;
        vector<vector<int> > py(1), px(1);
        int gy, gx;
        for(int y=0; y<h; ++y){
            for(int x=0; x<w; ++x){
                string s;
                cin >> s;
                if(s == "S"){
                    py[0].push_back(y);
                    px[0].push_back(x);
                }else if(s == "G"){
                    gy = y;
                    gx = x;
                }else if(s != "."){
                    int a = atoi(s.c_str());
                    if(a >= n){
                        n = a + 1;
                        py.resize(n);
                        px.resize(n);
                    }
                    py[a].push_back(y);
                    px[a].push_back(x);
                }
            }
        }
        py.push_back(vector<int>(1, gy));
        px.push_back(vector<int>(1, gx));

        vector<int> dp(1, 0);
        for(int i=0; i<n; ++i){
            vector<int> nextDp(py[i+1].size(), INT_MAX);
            for(unsigned j=0; j<py[i].size(); ++j){
                for(unsigned k=0; k<py[i+1].size(); ++k){
                    nextDp[k] = min(nextDp[k], dp[j] + abs(py[i][j] - py[i+1][k]) + abs(px[i][j] - px[i+1][k]));
                }
            }
            dp.swap(nextDp);
        }
        cout << dp[0] << endl;
    }
}

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

int main()
{
    int d;
    cin >> d;
    int c[26];
    for(int i = 0; i < 26; i++) cin >> c[i];
    int s[400][26];
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    int last[26];
    int t[365];
    for(int i = 0; i < d; i++){
        cin >> t[i];
        t[i]--;
    }
    int m;
    cin >> m;
    while(m--){
        int e, q;
        cin >> e >> q;
        e--; q--;
        t[e] = q;
        for(int i = 0; i < 26; i++) last[i] = -1;
        int ans = 0;
        for(int i = 0; i < d; i++){
            ans += s[i][t[i]];
            last[t[i]] = i;
            for(int j = 0; j < 26; j++) ans -= c[j] * (i - last[j]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n; cin>>n;
    map<string,ll> mp;
    for(ll i=0;i<n;i++)
    {
        string k;  cin>>k;
        if(mp.find(k)!=mp.end()) mp[k]++;
        else mp.insert({k,1});
    }
    cout<<"AC"<<" "<<"x"<<" "<<mp["AC"]<<"\n";
    cout<<"WA"<<" "<<"x"<<" "<<mp["WA"]<<"\n";
    cout<<"TLE"<<" "<<"x"<<" "<<mp["TLE"]<<"\n";
    cout<<"RE"<<" "<<"x"<<" "<<mp["RE"]<<"\n";
    
}

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

int main(){

  stack <int> que;
  int i;
  
  while(cin >> i){
  
    if(i != 0){
      que.push(i);
    }
    else{
      cout << que.top() << endl;
      que.pop();
    }


  }


  return 0;

}

Measured memory_bytes: 1200
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint dif[100005];

int main(void)
{
	cin >> n;
	llint l, r;
	for(int i = 1; i <= n; i++){
		cin >> l >> r;
		dif[l]++, dif[r+1]--;
	}
	for(int i = 1; i < 100005; i++) dif[i] += dif[i-1];
	
	llint ans = 0;
	for(int i = n; i >= 1; i--){
		if(dif[i+1] >= i){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

int main() {

    int N;
    scanf("%d", &N);
    vector<double> p(N);

    // dp[i] : probability of getting i heads so far
    vector<double> dp(N+1);
    dp[0] = 1;
    double p_heads;

    for (int coins = 0; coins < N; ++coins) {
        scanf("%lf", &p_heads);
        for (int i = coins + 1; i >= 0; --i) {
            /*prob of getting i heads when no of coins are (coins+1) =
                prob of getting i-1 heads * prob of getting head +
                prob of getting i heads when no of coins are (coins) * prob of getting tail
             */
            dp[i] = dp[i-1] * p_heads + dp[i] * (1 - p_heads);
        }
    }

    double ans = 0;

    for (int head = 0; head <= N; ++head) {
        int tail = N - head;

        if (head > tail) ans += dp[head];
    }

    printf("%.10lf\n", ans);
}

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


#define ll long long
#define pb push_back
#define mp make_pair

int main() {
    string s;
    cin >> s;
    ll q;
    ll cond=1;
    cin >> q;
    while(q--)
    {
        
        ll t;
        cin >> t;
        
        if(t==1)
        {
            if(cond==1)
            cond=2;
            else
            cond=1;
        }
        
        else
        {
            ll f;
            string s2;
            cin >> f >> s2;
            
            if(f==1)
            {
                ll len=s.size();
                if(cond==1)
                s.insert(0,s2);
                else
                s.insert(len,s2);
            }
            else
            {
                ll len=s.size();
                if(cond==2)
                s.insert(0,s2);
                else
                s.insert(len,s2);
            }
            
        }
    }
    if(cond==1)
    cout << s<< endl;
    else
    {
        for(ll i=s.size()-1;i>=0;i--)
        cout << s[i] ;
        cout << endl;
    }
}

Measured memory_bytes: 900
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
O = [0] + [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A] <= H[B]:
        O[A] = 0
    if H[A] >= H[B]:
        O[B] = 0
print(sum(O))

Measured memory_bytes: 20032
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    k = int(input())
    r = ""
    for se in s:
        if se == 'a':
            r += 'a'
        else:
            if 123 - ord(se) <= k:
                r += 'a'
                k -= (123 - ord(se))
            else:
                r += se
    if k:
        k = k % 26
        lastc = chr(k + ord(r[-1]))
        r = r[:-1] + lastc
    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9428
#include <bits/stdc++.h>
#define N 100003
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

int main() {
	// for fast input output using cin cout
	std::ios_base::sync_with_stdio(false);

	// input
	int r, g;
	cin >> r >> g;

	int ans;
	ans = (g*2) - r;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 2e5 + 60;
int a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", a + i);
    printf("%d", accumulate(a, a + n, -n));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	int t, n, r;
	double x, y;
	
	x = 0.0;
	y = 0.0;
	t = 90;
	while(true){
		scanf("%d,%d", &n, &r);
		if(n == 0 && r == 0){
			break;
		}
		
		x += n*cos(t*M_PI/180.0);
		y += n*sin(t*M_PI/180.0);
		t -= r;
			
	}
	
	printf("%d\n%d\n", (int)x, (int)y);
	
	return 0;
}

Measured memory_bytes: 1032
def myAnswer(H:int,W:int,A:list) -> str:
   counter = 0
   for a in A:
      counter += a.count("#")
   return "Possible" if(counter == H + W - 1) else "Impossible"

   # i = 0
   # j = 0
   # if(A[i][j] == "." or A[H-1][W -1] == "."):return "Impossible"
   # while True:
   #    print(i,j)
   #    if(i == H -1 and j == W - 1):
   #       return "Possible"
   #    else:
   #       tmp = []
   #       if(j != W - 1 and A[i][j + 1] == "#"):
   #          tmp.append([i,j + 1])
   #       if(i != H - 1 and A[i + 1][j] == "#"):
   #          tmp.append([i + 1,j])
   #       if(len(tmp) == 1):
   #          i,j = tmp[0][0],tmp[0][1]
   #       else:
   #          return "Impossible"


def modelAnswer():
   return
def main():
   H,W = map(int,input().split())
   A = []
   for _ in range(H):
      A.append(list(input()))
   print(myAnswer(H,W,A))
if __name__ == '__main__':
   main()

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

typedef long long ll;
const int inf = 1e9;

int k, r, g, b;

int main(){
	cin>>r>>g>>b>>k; // b > g > r
	if(b > g && g > r){
		cout<<"Yes"<<endl;
		return 0;
	}
	while(g <= r && k > 0){g *= 2; k--;}
	while(b <= g && k > 0){b *= 2; k--;}
	if(b > g && g > r){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split(" "))
mod = 10 ** 9 + 7
A = list(map(int, input().split(" ")))
num = [0 for i in range(N)]

trip = 0
for i in range(N):
    for j in range(N):
        if A[i] < A[j]:
            num[j] += 1
        if i < j and A[i] > A[j]:
            trip += 1

ans = (trip * K) % mod
for n in num:
    ans += n * K * (K - 1) // 2
    ans %= mod
print(ans)

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

int main()
{
  int n, k, q, a;
  cin >> n >> k >> q;
  vector<int> X(n, 0);

  for (int i = 0; i < q; i++)
  {
    cin >> a;
    X[a - 1]++;
  }
  for (int i = 0; i < n; i++)
  {
    if (X[i] + k - q > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
# recieve |V| and |E|
V, E = map(int, input().split())
es = [[] for i in range(V)]

for i in range(E):

	# recieve edges
	a, b, c = map(int, input().split())
	a, b = a-1, b-1
	es[a].append((b,c))
	es[b].append((a,c))

T = int(input())

# recieve info
for i in range(T):
	Nnew = int(input())
	for j in range(Nnew):
		new_id, dst = map(int, input().split())

# insert your code here to get more meaningful output
# all stay
for i in range(T) :
	print (-1)


Measured memory_bytes: 52056
N, u, v = map(int, input().split())
target = u-1
v -= 1
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

from collections import deque
def bfs(s):
  lis = [-1]*N
  d = deque([s])
  lis[s]=0
  while len(d)>0:
    v = d.popleft()
    for w in edge[v]:
      if lis[w]<0:
        lis[w]=lis[v]+1
        d.append(w)
  return lis

lis1 = bfs(target)
lis2 = bfs(v)
ans = 0
for i in range(N):
  if lis1[i]<lis2[i]:
    ans = max(ans, lis2[i]-1)
print(ans)

Measured memory_bytes: 90248
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;


int main()
{
 int N,Q,A,B,C;
 long long S = 0;
 cin >> N;
 int oc[100001] = {0};
 for (int i=0; i<N; i++){
    cin >> A;
    oc[A]++;
    S += A;
 }
 cin >> Q;
 for (int j=0; j<Q; j++){
    cin >> B >> C;
    S += (C-B)*oc[B];
    oc[C] += oc[B];
    oc[B] = 0;
    cout << S << "\n";
 }
}



Measured memory_bytes: 4004
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();

        String s = String.valueOf(a) + String.valueOf(b);

        int c = Integer.parseInt(s);

        boolean isSqare = false;

        for (int i = 1; i <= 1000; i++) {
            if (i * i == c) {
                System.out.println("Yes");
                isSqare = true;
                break;
            }
        }

        if (!isSqare)
            System.out.println("No");

    }
}

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

const int MAX = 1e6+10;
const int mod = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void init() {
    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;
}
int main()
{
    long long x,y;
    std::cin>>x>>y;
    bool res1 = true;
    int cnt;
    //座標の合計が3の倍数なら調べる価値がある
    if((x+y)%3!=0)res1 = false;
    cnt = (x+y)/3;
    //移動するかどうかで見ることができるようにする
    x -= cnt;
    y -= cnt;
    if(x<0||y<0)res1 = false;
    init();
    std::cout<<(res1?COM(x+y,x):0)<<std::endl;


}

Measured memory_bytes: 23680
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
x,y=map(int,input().split())
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x==2 and y==2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    HashSet hs = new HashSet();
    for (String s : strs) {
      hs.add(s);
    }
    System.out.println(hs.size());
  }
}

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

int main() {
	int n,m;
	int ans[100][100];
	char a[100][100];
	for(int i = 0;i<100;i++){
		for(int j = 0;j<100;j++){
			ans[i][j]=101;
		}
	}
	cin >> n >> m;
	for(int i = 0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> a[i][j];
		}
	}
	for(int i =0;i<n;i++){
		for(int j = m-1;j>=0;j--){
			if(a[i][j]=='c'){
				int p=0;
				for(int k=j;k<m;k++){
					if(ans[i][k]>p){
						ans[i][k]=p;
					}
					p++;
				}
			}
		}
	}
	for(int i = 0;i<100;i++){
		for(int j = 0;j<100;j++){
			if(ans[i][j]==101){ans[i][j]=-1;}
		}
	}
	for(int i =0;i<n;i++){
		for(int j =0;j<m;j++){
			if(j == 0){
				cout << ans[i][j];
			} 
			else if(j == m-1){
				cout << ' ' << ans[i][j] << endl;
			}
			else{cout << ' '<< ans[i][j];}
			
		}
	}
	return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i=0;i<=N;i++){
        if((i * 108) / 100 == N){
            cout << i <<endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

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

int main() {
	string S;
	cin >> S;
	for (int i = 0;i < S.size() - 1;i ++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 768
def solution(X, Y):
    for n_tsuru in range(X + 1):
        for n_kame in range(X + 1):
            if n_tsuru + n_kame == X and 2 * n_tsuru + 4 * n_kame == Y:
                return 'Yes'
    return 'No'
X, Y = map(int, input().split())
print(solution(X, Y))

Measured memory_bytes: 9176
N = gets.to_i
xs, ys = [], []
N.times do |i|
    xs[i], ys[i] = gets.split.map(&:to_i).sort
end

xsort = N.times.sort_by{|i|xs[i]}
ysort = N.times.sort_by{|i|ys[i]}

xmin, xmax = xs[xsort[0]], xs[xsort[-1]]
ymin, ymax = ys[ysort[0]], ys[ysort[-1]]
ans = (xmax-xmin) * (ymax-ymin)

new_xmin = ymax
yd = ymax - xmin

(N-1).times do |i|
    index = xsort[i]
    xmax = ys[index] if xmax < ys[index]
    new_xmin = ys[index] if new_xmin > ys[index]
    xmin = xs[xsort[i+1]] < new_xmin ? xs[xsort[i+1]] : new_xmin
    result = (xmax-xmin) * yd
    ans = result if ans > result
end
puts ans

Measured memory_bytes: 14516