akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        double a = (double)scan.nextInt();
        double b = (double)scan.nextInt();
        double x = (double)scan.nextInt();

        double answer = 0;
        if(x >= a*a*b/2) {
            double tana = 2*(a*a*b-x)/(a*a*a);
            double radian = Math.atan(tana);
            answer = Math.toDegrees(radian);
        } else {
            double tana = a * b * b / (2 * x);
            double radian = Math.atan(tana);
            answer = Math.toDegrees(radian);
        }

        os.println(answer);

    }
}

Measured memory_bytes: 23892
def ReRooting(nodeCount, edges, identity, merge, addNode):
  adjacents = [[] for _ in range(nodeCount)]
  indexForAdjacents = [[] for _ in range(nodeCount)]
  for u,v in edges:
    indexForAdjacents[v].append(len(adjacents[u]))
    indexForAdjacents[u].append(len(adjacents[v]))
    adjacents[u].append(v)
    adjacents[v].append(u)
  childSubtreeRes = [[identity]*len(adjacents[i]) for i in range(nodeCount)]
  nodeRes = [identity]*nodeCount
  parents = [-1]*nodeCount
  order = [0]*nodeCount
  index = 0
  stack = [0]
  for node in stack:
    order[index] = node
    index += 1
    for adjacent in adjacents[node]:
      if adjacent == parents[node]:
        continue
      stack.append(adjacent)
      parents[adjacent] = node
  for node in order[::-1]:
    parent = parents[node]
    result = identity
    parentIndex = -1
    for j in range(len(adjacents[node])):
      if adjacents[node][j] == parent:
        parentIndex = j
        continue
      result = merge(result, childSubtreeRes[node][j])
    if parentIndex >= 0:
      childSubtreeRes[parent][indexForAdjacents[node][parentIndex]] = addNode(result, node)
  for node in order:
    accumsFromTail = [identity]*len(adjacents[node])
    for j in range(len(accumsFromTail)-1, 0, -1):
      accumsFromTail[j-1] = merge(childSubtreeRes[node][j], accumsFromTail[j])
    accum = identity
    for j in range(len(accumsFromTail)):
      result = addNode(merge(accum, accumsFromTail[j]), node)
      childSubtreeRes[adjacents[node][j]][indexForAdjacents[node][j]] = result
      accum = merge(accum, childSubtreeRes[node][j])
    nodeRes[node] = addNode(accum, node)
  return nodeRes

n, mod = map(int, input().split())
for i in ReRooting(n, [list(map(lambda x:int(x)-1,input().split()))for _ in range(n-1)], 1, lambda a,b:a*b%mod, lambda a,id:a+1):
  print(i-1)


Measured memory_bytes: 72416
let n = Int(readLine()!)!

let tasks = (1...n).map { _ in
    return readLine()!.split(separator: " ").map { Int($0)! }
}

var dpA = [Int](repeating: 0, count: n)
var dpB = [Int](repeating: 0, count: n)
var dpC = [Int](repeating: 0, count: n)

dpA[0] = tasks[0][0]
dpB[0] = tasks[0][1]
dpC[0] = tasks[0][2]
for i in 1..<n {
    dpA[i] = tasks[i][0] + max(dpB[i-1], dpC[i-1])
    dpB[i] = tasks[i][1] + max(dpA[i-1], dpC[i-1])
    dpC[i] = tasks[i][2] + max(dpA[i-1], dpB[i-1])
}

print(max(dpA[n-1], dpB[n-1], dpC[n-1]))

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

int main()
{
  int a,b;
  cin >> a >> b;
  if(a == b) cout << "a == b" << endl;
  else if(a > b) cout << "a > b" << endl;
  else if(a < b) cout << "a < b" << endl;
  return 0;
}

Measured memory_bytes: 1156
N=int(input())
X={"U":[],"D":[],"L":[],"R":[]}
for _ in range(N):
 x,y,u=input().split()
 X[u].append((int(x),int(y)))
r=10**9
def z(A):
 global r
 A.sort()
 n=p=-10**9
 for k,c,a in A:
  if k!=n:
   if a==1:n,p=k,c
  elif a==1:p=c
  elif (c-p)*5<r:r=(c-p)*5
z([(x,y,1) for x,y in X["U"]]+[(x,y,-1) for x,y in X["D"]])
z([(y,x,1) for x,y in X["R"]]+[(y,x,-1) for x,y in X["L"]])
z([(x+y,x-y,1) for x,y in X["R"]]+[(x+y,x-y,-1) for x,y in X["U"]])
z([(x+y,x-y,1) for x,y in X["D"]]+[(x+y,x-y,-1) for x,y in X["L"]])
z([(x-y,x+y,1) for x,y in X["U"]]+[(x-y,x+y,-1) for x,y in X["L"]])
z([(x-y,x+y,1) for x,y in X["R"]]+[(x-y,x+y,-1) for x,y in X["D"]])
print(r if r<10**9 else "SAFE")

Measured memory_bytes: 63652
n, k= map(int,input().split())
x = list(map(int, input().split()))
if 0 not in x:
    k += 1
    x.append(0)
    x = sorted(x)
x = [abs(i) for i in x]

orig = x.index(0)

ans = float("inf")
for i in range(k):
    f = orig + i
    s = orig + i - k + 1
    if (s >= 0) and (f <= n):
        temp1 = x[s]
        temp2 = x[f]
        ans = min([ans, 2*temp1+temp2, temp1+2*temp2])

print(ans)

Measured memory_bytes: 14224
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

#W-F法でiからjへの最小移動コストを求める
res = [c for c in C]
for k in range(10):
    for i in range(10):
        for j in range(10):
            wf = res[i][k] + res[k][j]
            res[i][j] = min(wf,res[i][j])
cost = [r[1] for r in res]

#合計の最小コストを計算
ans = 0
for a in A:
    for x in a:
        if x != -1:
            ans += cost[x]
print(ans)

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

int main() {
    int ans = 700, cnt = 0;
    string str;
    cin >> str;
    rep(i, 3) if(str.at(i) == 'o') cnt++;
    ans += 100 * cnt;
    cout << ans << endl;
}

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

int main(){ 
    int H,W;
    cin >> H >> W;
    while(H!=0 || W!=0){
        for(int i=0; i<H; ++i){
        	for(int j=0; j<W; ++j){
        		cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
}


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);

	int ans=0,mn=n;
	rep(i,n){
		int p; scanf("%d",&p);
		if(p<=mn) ans++;
		mn=min(mn,p);
	}
	printf("%d\n",ans);

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ac=0,wa=0,tle=0,re=0;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(s == "AC"){
      ac++;
    }else if(s == "WA"){
      wa++;
    }else if(s == "TLE"){
      tle++;
    }else{
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;  
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl; 
  return(0);
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    // freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    scanf("%d %d", &n, &k);
    vi p(n);
    rep(i, 0, n)
    {
        scanf("%d", &p[i]);
    }
    sort(all(p));
    printf("%d", accumulate(p.begin(), p.begin()+k, 0));
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <vector>
#include <algorithm>
 
int main(){
    std::vector<int> a(4);
     
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
        int hit = 0, blow = 0;
         
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
             
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i) ++hit;
            else if(it != a.end()) ++blow;
        }
         
        std::cout << hit << " " << blow << std::endl;
         
    }
     
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=1e5+10;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

int N,M,eg[maxn][2],K;

int main(){
    //freopen("","r",stdin);
    N=rd(),K=rd();
    int now=(N-1)*(N-2)/2-K;
    if(now<0) {puts("-1");return 0;}
    for(int i=1;i<=N-1;i++) eg[++M][0]=N,eg[M][1]=i;
    for(int i=1;i<=N-1&&now;i++){
    	for(int j=i+1;j<=N-1&&now;j++){
    		now--;
    		eg[++M][0]=i,eg[M][1]=j;
    	}
    }
    printf("%d\n",M);
    for(int i=1;i<=M;i++) printf("%d %d\n",eg[i][0],eg[i][1]);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  int A,B;
  cin >> A >> B;
  rep(k,10000) {
    int a = floor(k*0.08);
    int b = floor(k*0.10);
    if(a==A&&b==B) {
      cout << k << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = [0] * N
for i in range(N): a[i] = int(input())
table = [0] * N
for i in range(N):
  x = a[i]
  bn = list(bin(x)[2: ])
  bn.reverse()
  for j in range(len(bn)):
    if bn[j] == "1":
      table[i] = (1 << j) - 1 + (1 << j)
      break
#print(table)
xm = 0
for x in a: xm ^= x
table.sort(reverse = True)
res = 0
for x in table:
  if xm ^ x < xm:
    res += 1
    xm ^= x
if xm: print(-1)
else: print(res)

Measured memory_bytes: 43996
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array([0] + lr())
P = (P+1) / 2
Pcum = P.cumsum()
X = Pcum[K:] - Pcum[:-K]
answer = X.max()
print(answer)


Measured memory_bytes: 33996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    std::vector<int> prices(N);

    for(auto& x : prices)
    {
        cin >> x;
    }

    std::sort(prices.begin(), prices.end());

    int total = 0;
    for(int i = 0; i < K; ++i)
    {
        total += prices[i];
    }

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

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define tezi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define ull unsigned long long
#define traverse(c,it) for(auto it=c.begin();it!=c.end();it++)
#define lowerb(v,a) lower_bound(v.begin(),v.end(),a)
#define lowerbarr(v,n,a) lower_bound(v,v+n,a)
#define upperb(v,a) upper_bound(v.begin(),v.end(),a)
#define upperbarr(v,n,a) upper_bound(v,v+n,a)
#define maxval(v) max_element(v.begin(),v.end())
#define maxarr(v,n) max_element(v,v+n)
#define minval(v) min_element(v.begin(),v.end())
#define minarr(v,n) min_element(v,v+n)
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define mem0(v) memset(v,0,sizeof(v))
#define memf(v) memset(v,false,sizeof(v))
#define memt(v) memset(v,true,sizeof(v))
#define mem(v,a) memset(v,a,sizeof(v))
#define MAX 100000
#define MOD 1000000007
 
                    /**************SIEVE****************/
 
/*{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
   
    memset(prime, true, sizeof(prime)); 
  
    for (long p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long i=p*p; i<=MAX; i += p) 
                prime[i] = false; 
        } 
    } 
  
  
   
    
   
} */
 
                                        /**************gcd****************/
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
 
 
                                         /**************POWER****************/
long pow(int v,int a)
{
  long prod=1;
  loop(i,0,a)
  prod*=v;
  return prod;
}
 
 
 
                                        /**************MAIn****************/
 
 
 
 
 
 
int main()
{   tezi
  
  //freopen("input.txt","r",stdin);
  //freopen("put.txt","w",stdout);
   
 
  int t=1;
  //cin>>t;
  while(t--)
  {
     ll a,b,c,k;
   cin>>a>>b>>c>>k;
   cout<<min(a,k)-max(0LL,k-a-b);
 
   
  }

 
   
 
 }
 
 
 
  
 
 

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := readString()
	for i := 0; i < len(s); i++ {
		if i%2 == 0 {
			fmt.Printf("%c", s[i])
		}
	}
	fmt.Println("")
}


Measured memory_bytes: 1024
S = list(input())
ans1 = 0
ans2 = 0

tmp = S[0]
for i in range(1, len(S)):
    if tmp == S[i]:
        ans1 += 1
        tmp = "0" if tmp == "1" else "1"
    else:
        tmp = S[i]


tmp = S[-1]
for i in reversed(range(0, len(S)-1)):
    if tmp == S[i]:
        ans2 += 1
        tmp = "0" if tmp == "1" else "1"
    else:
        tmp = S[i]

print(min(ans1, ans2))


Measured memory_bytes: 3956
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    public static void Main()
    {
        var input = Console.ReadLine();
        HitachiString(input);
    }

    static void HitachiString(string s)
    {
        if(s.Length%2!=0)
        {
            Console.Write("No");
            return;
        }

        if (s.Length == 2)
        {
            if (s[0] == 'h' && s[1] == 'i')
            {
                Console.Write("Yes");
                return;
            }
            else
            {
                Console.Write("No");
                return;
            }
        }
        for (int i = 2; i < s.Length; i++)
        {

            if (s[i] != s[i - 2])
            {
                Console.Write("No");
                return;
            }

        }

        Console.Write("Yes");

    }





}



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


using namespace std;


int main()
{
	int	N, K;
	int total = 1;

	cin >> N >> K;


	for (int i = 0; i < N; i++) {
		if (total <= K)
			total *= 2;
		else
			total += K;
	}

	cout << total << endl;


	return 0;
}




Measured memory_bytes: 256
A = tostring(io.read())
B = tostring(io.read())
if #A>#B then
    print("GREATER")
elseif #A<#B then
    print("LESS")    
elseif #A==#B then
    oh = true
    for i=1 , #A do
        if A:sub(i,i) > B:sub(i,i) then
            oh = false
            print("GREATER")
            break
        elseif A:sub(i,i) < B:sub(i,i) then
            oh = false
            print("LESS")
            break
        end
    end
    if oh then
        print("EQUAL")
    end
end

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[123];
int main(){
	int n; scanf("%d%s", &n, s);
	bool ok = n % 2 == 0;
	REP(i, n/2) if(s[i] != s[n/2 + i]) ok = false;
	if(ok) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define INF 2000000000
#define watch(x) cout << setw(10) << "[" << (#x) << ":] " << (x) 
#define FORE(i,v,n) for(int i=v;i<n;i++)
#define FORI(i,v,n) for(int i=v;i<=n;i++)


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<string, int> msi;


//typedef tree <int, null_type, less<int> rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int const MOD = 1000000007;

int test_case(){
	int n, value;
	cin >> n;
	vi doc(n,0);
	FORE(i,0,n){
		cin >> doc[i];
	}
	bool flag = false;
	FORE(i,0,n){
		if(doc[i] %2 == 0){
			
		if(!(doc[i] %3 ==0 || doc[i]%5 ==0)){
			flag = true;
			break;
		}
	}
	}
	printf("%s",flag?"DENIED":"APPROVED");
	//cout << answer;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int test=1;
	//cin >> test;
	for(int i=0;i<test;i++){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
ans=H*W

def ep(H,W,h):
    S1=h*W
    S2=(H-h)*(W//2)
    S3=(H-h)*(W-W//2)
    c1=max(S1,S2,S3)-min(S1,S2,S3)

    T1=h*W
    T2=((H-h)//2)*W
    T3=(H-h-((H-h)//2))*W
    c2=max(T1,T2,T3)-min(T1,T2,T3)

    return min(ans,c1,c2)




if H!=1:
    for h in range(1,H):
        ans=ep(H,W,h)

H,W=W,H
if H!=1:
    for h in range(1,H):
        ans=ep(H,W,h)

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int A, B;

    cin >> A >> B;
    if(2 * B > A) {
        cout << 0 << endl;
    } else {
        cout << A - 2 * B << endl;
    }
}

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

using namespace std;

struct edge{
    int to;
    int cost;
};
class Situation{
public:
	int cost;
	int idx;

	Situation(int cost_,int idx_){
		cost=cost_;
		idx=idx_;
	}
	Situation();

	bool operator<(const Situation &s)const{
		return s.cost < this->cost;
	}
};
const int MAX_V=3001;

int N,M,K;
vector<edge> G[MAX_V];

int d[MAX_V];
const int INF=1000000000;
int froms[100001];
int tos[100001];
int costs[100001];

void dijkstra(int s){
	priority_queue<Situation> que;
	d[s] = 0;
	que.push(Situation(0,s));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int v = p.idx;
		if(d[v] < p.cost)
			continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(Situation(d[e.to],e.to));
			}
		}
	}
}


int main(){

    cin>>N>>M>>K;
    for(int i=0;i<M;i++){
        edge e;
        int from,to,cost;
        cin>>from>>to>>cost;
        from--;to--;
        froms[i]=from;
        tos[i]=to;
        costs[i]=cost;
        e.to=to;
        e.cost=cost;
        G[from].push_back(e);
        e.to=from;
        G[to].push_back(e);
    }
	fill(d,d+MAX_V,INF);
    for(int i=0;i<K;i++){
        int a;
        cin>>a;
        a--;
        dijkstra(a);
    }
    double res=0;
    for(int i=0;i<N;i++)
        res=max(res,(double)d[i]);
    for(int i=0;i<M;i++){
        double dit=(1.0*d[froms[i]]+d[tos[i]]+costs[i])/2;
        res=max(dit,res);
    }
    int val=(int)(res+0.5);
    cout<<val<<endl;
    //printf("%.0f\n",res);

    return 0;
}

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

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

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

//#define int long long

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

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

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

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

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);



struct Matrix {
    vector<vector<long long> > val;
    Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
    void init(int n, int m, long long x = 0) {val.assign(n, vector<long long>(m, x));}
    size_t size() const {return val.size();}
    inline vector<long long>& operator [] (int i) {return val[i];}
};

Matrix operator * (Matrix A, Matrix B) {
    Matrix R(A.size(), B[0].size());
    for (int i = 0; i < A.size(); ++i) 
        for (int j = 0; j < B[0].size(); ++j)
            for (int k = 0; k < B.size(); ++k) 
                R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD; 
    return R;
}

Matrix pow(Matrix A, long long n) {
    Matrix R(A.size(), A.size());
    for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; LL K; cin >> N >> K;    
    Matrix mt(N,N);


    REP(i,N) REP(j,N){
        cin >> mt[i][j];
    }
    Matrix res = pow(mt, K);
    LL ans = 0;
    REP(i,N) REP(j,N){
        ans = (ans + res[i][j]) % MOD;
    }
    cout << ans << endl;

    

}


Measured memory_bytes: 384
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())

Measured memory_bytes: 11884
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int i;
	
	while(scanf("%d %d", &a, &b) != EOF){
		c = a + b;
		for (i=1; (c/=10) > 0;i++ ){}
		printf("%d\n", i);
	}
	
	return(0);
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size()-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))
dp = [[0]*(n+1) for _ in range(len(p)+1)]
dp[1][0] = (1-p[0])
dp[1][1] = p[0]
for i in range(1, n):
    for j in range(i+2):
        if j == 0: dp[i+1][0] = dp[i][0]*(1-p[i])
        else: dp[i+1][j] = dp[i][j-1]*p[i]+dp[i][j]*(1-p[i])
print(sum(dp[-1][-(-n//2):]))

Measured memory_bytes: 203652
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int h,w;
	cin >> h >> w;
	if(h==1 or w==1){
		cout << 1;
		return 0;
	}
	int ans=w/2*h;
	if(w%2)ans+=(h+1)/2;
	cout << ans;
}


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

int main() {
  int n, a, b, c;
  string reply;

  cin >> n;

  a = n / 1000;
  n %= 1000;
  b = n / 100;
  n %= 100;
  c = n / 10;
  n = n % 10;

  if ((b == c) && ((a == b) || (c == n))) {
    reply = "Yes";
  } else {
    reply = "No";
  }
  cout << reply << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := 0, 0
	for {
		x = nextInt()
		y = nextInt()
		if x == 0 && y == 0 {
			break
		}
		if y < x {
			fmt.Println(y, x)
		} else {
			fmt.Println(x, y)
		}
	}
}



Measured memory_bytes: 1144
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    VI a(n);
    int x = 0;
    REP(i,n){
        a[i] += x;
        if (s[i] == 'W') x++;
    }
    x = 0;
    FORR(i,n-1,0){
        a[i] += x;
        if (s[i] == 'E') x++;
    }
    cout << *min_element(ALL(a)) << endl;

    return 0;
}


Measured memory_bytes: 1924
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, K; std::cin >> N >> K;
  ll E = N % K;
  std::cout << std::min( E , K - E ) << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, d; cin >> n >> d;
  int m = 2 * d + 1;
  cout << (n + m - 1) / m << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,a[202020],b[202020];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	fo(i,0,n)cin>>b[i];
	if(n<=190000){
		fo(i,0,n){
			bool q=1;
			fo(j,i,i+n) if(a[j-i]==b[j%n]){
				q=0;
				break;
			}
			if(q){
				cout<<"Yes\n";
				fo(j,i,i+n-1)cout<<b[j%n]<<' ';
				cout<<b[(i+n-1)%n]<<endl;
				return 0;
			}
		}
		cout<<"No\n";
		return 0;
	} 
	fo(i,0,n) if(a[0]!=b[i]){
		fo(j,i,i+n){
			while(a[j-i]==b[j%n]){
				i++;
				j++;
			}
			if(i>=n){
				cout<<"No\n";
				return 0;
			}
		}
		fo(j,i,i+n) if(a[j-i]==b[j%n]){
			cout<<"No\n";
			return 0;
		}
		cout<<"Yes\n";
		fo(j,i,i+n-1)cout<<b[j%n]<<' ';
		cout<<b[(i+n-1)%n]<<endl;
		return 0;
	}
	cout<<"No\n";
	return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> x(100002, 0);
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        x[a-1+1] += 1;
        x[a  +1] += 1;
        x[a+1+1] += 1;
    }
    int ans = 0;
    for(auto i : x){
        ans = max(ans, i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        int x = Integer.parseInt(in[0]);
        int a = Integer.parseInt(in[1]);
        System.out.println(x < a? 0 : 10);
    }
}

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

#define      ll     long long int

const int inf = 1e9 + 9;
int F[111][12];
int P[111][12];

int main()
{
    int n, i, j, k;
    cin >> n;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= 10; j++) {
            cin >> F[i][j];
        }
    }
    for (i = 1; i <= n; i++) {
        for (j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }
    int res = -inf;
    for (k = 1; k < 1024; k++) {
        int cur = 0;
        for (i = 1; i <= n; i++) {
            int c = 0;
            for (j = 1; j <= 10; j++) {
                if ((k & (1<<(j - 1))) != 0 && F[i][j] == 1) {
                    c++;
                }
            }
            cur += P[i][c];
        }
        res = max(res, cur);
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, cnt = 0;
    cin >> a >> b >> c;

    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            cnt++;
    }

    cout << cnt << endl;
}



Measured memory_bytes: 3124
n, y = map(int, input().split())
swi = 0

for a in range(y//10000 + 1):
    b = (y - 1000 * n - 9000 * a) // 4000
    c = n - a - b
    if 10000 * a + 5000 * b + 1000 * c == y and a >= 0 and b >= 0 and c >= 0:
        print(a, b, c)
        swi = 1
        break
if swi == 0:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

//#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int H, W, h, w;
long long X[500][500];

long long ctr(int tx, int ty) {
  long long sum = 0;
  for (int y=max(0, ty-h+1); y<=ty; y++) {
    //for (int x=max(0, tx-w+1); x<=tx; x++) {
    //  sum += X[x][y];
    //}
    sum += X[tx][y];
    if (tx-w>=0) sum -= X[tx-w][y];
  }
  return sum;
}

bool f() {
  if (h == 1 && w == 1) return false;
  rep(y, H) {
    rep(x, W) {
      X[x][y] = 0;
    }
  }
  rep(y, H) {
    rep(x, W) {
      if (x>0) X[x][y] = X[x-1][y];
      if (x < w-1 || y < h-1) {
        X[x][y] += 3500;
      }
      else {
        long long c = ctr(x, y);
        X[x][y] += -c-1;
        //if (X[x][y] < -1000000000 || X[x][y] > 1000000000) return false;
      }
    }
  }
  long long sum = 0;
  rep(y, H) {
    sum += X[W-1][y];
  }
  return sum >= 1;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> h >> w;
  if (!f()) {
    cout << "No\n";
    return 0;
  }

  cout << "Yes\n";
  rep(y, H) {
    rep(x, W) {
      long long g = X[x][y];
      if (x>0) g-=X[x-1][y];
      cout << g << " ";
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
string s;
int main()
{
cin>>s;
int n=s.size();
ref(i,0,n-2)if(s[i]=='A'&&s[i+1]=='C')
{
	cout<<"Yes"<<endl;
	return 0;
}
cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,i,v[100],c[100];
	int aw=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&v[i]);}
		
			for(i=0; i<n; i++){
				scanf("%d",&c[i]);}
				
					for(i=0; i<n; i++){
				if(v[i]-c[i]>0) aw+=v[i]-c[i];}
			
	
	printf("%d",aw);
	
	
	return 0;}


Measured memory_bytes: 128
#include<map>
#include<set>
#include<stack>
#include<deque>
#include<queue>
#include<cmath>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#define inf 2139062143
#define re register
#define ll long long
#define ull unsigned long long
#define lowbit(x) x&-x
#define Flj(i,a,b) for(int i=(a);i;i=(b))
#define Fze(i,a,b) for(int i=(a);i<(b);i++)
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Fer(i,a,b) for(int i=(a);i>=(b);i--)
#define Fer1(i,a,b) for(int i=(a);i>b;i--)
#define Dfor(i,a,b,k) for(double i=(a);i<(b);i+=k)
#define Qmax priority_queue
#define Qmin priority_queue<int,vector<int>,greater<int> >
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n, D, cnt, Y[22][22];
int main(){
	n = read(); D = read();
	For(i, 1, n){
		For(j, 1, D){
			Y[i][j] = read();
		}
	}
	For(i, 1, n){
		For(j, i + 1, n){
			double ans = 0;
			For(k, 1, D) ans += (double)(Y[i][k] - Y[j][k]) * (Y[i][k] - Y[j][k]);
			ans = (double)sqrt(ans);
			if(ans == (int)ans) cnt++;
		}
	}
	printf("%d", cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
 
 
int main() {
    int n;

    cin >> n;

    vector<int> e(100000);
    vector<int> o(100000);

    for (int i = 0; i < 100000; i++) {
        e[i] = 0;
    }
    for (int i = 0; i < 100000; i++) {
        o[i] = 0;
    }

    int tmp;
    int e_max_index = 0;
    int o_max_index = 0 ;
    for (int i = 0; i < n; i++) {
        if (i%2) {
            cin >> tmp;
            e[tmp]++;
            if (e[e_max_index] < e[tmp]) e_max_index = tmp;
        }
        if (i%2) {
            cin >> tmp;
            o[tmp]++;
            if (o[o_max_index] < o[tmp]) o_max_index = tmp;
        }
    }

    sort(e.begin(), e.end(), greater<int>());
    sort(o.begin(), o.end(), greater<int>());
    
    int nokori = e[0] + o[0];
    if (e_max_index == o_max_index) {
        nokori = max((e[0] + o[1]),(e[1] + o[0]));
    }
    int ans = n - nokori;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n){
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<ll> > dp(n + 1, vector<ll>(3, 0));
  for(int i = 1; i <= n; ++i){
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i-1];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i-1];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i-1];
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


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

int main(void)
{
  int N, M, C, i, j, tmp, ans = 0; cin >> N >> M >> C;
  vector<int> B(M); for(i = 0; i < M; i++) cin >> B.at(i);
  vector<vector <int> > A(N, vector<int>(M));
  for (i = 0; i < N; i++) {
	for (j = 0; j < M; j++) {
	  cin >> A.at(i).at(j);
	}
  }

  for (i = 0; i < N; i++) {
	for (j = 0, tmp = 0; j < M; j++) {
	  tmp += A.at(i).at(j) * B.at(j);
	}
	if (tmp + C > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        # 要素が根の場合、-(そのグループの要素数)を格納
        self.parents = [-1] * n
        
    # 要素xが属するグループの根を返す    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    # 要素xが属するグループのサイズ(要素数)を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属すかどうか返す
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    
    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    # printでの表示用, ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

tree = UnionFind(n)
for a, b in ab:
    a,b = a-1, b-1
    if not tree.same(a, b):
        tree.union(a, b)
ans = float("-inf")
for i in range(n):
    ans = max(ans, tree.size(i))
print(ans)

Measured memory_bytes: 109196
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int x = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(0, a)
					.map(i -> (int) IntStream.rangeClosed(0, b)
							.filter(j -> (x >= (i * 500 + j * 100)) && (x <= (i * 500 + j * 100 + c * 50))).count())
					.sum());
		}
	}
}


Measured memory_bytes: 28240
#include <vector>
#include <iostream>
#include <algorithm>
#include <strstream>
using namespace std;
void disp(int x)
{
	cout << x<< " ";

}
void dispLast(int x)
{
	cout << x <<endl;

}

int main()
{
	int a[3];
	vector<int>vect;
	cin >> a[0]>>a[1]>>a[2];
	for (int i = 0; i < 3; i++) {
		if(a[i]<1 || a[i]>10000)return 0;
	}
	for (int i = 0; i < 3; i++ )vect.push_back(a[i]);
	sort(vect.begin(), vect.end());
	for (int i = 0; i < 2; i++) disp(vect[i]);
	dispLast(vect[2]);
	return 0;

}

Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN_V(ll, als, n);
	
	double res = 0;
	for (auto& a : als)res += (1.0 / a);
	res = 1.0 / res;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
gates = [list(map(int, input().split())) for _ in range(M)]

leftest = 1
rightest = N
for gate in gates:
    L = gate[0]
    R = gate[1]
    if L > leftest:
        if L > rightest:
            print(0)
            break
        leftest = L
    if R < rightest:
        if R < leftest:
            print(0)
            break
        rightest = R
else:
    print(rightest - leftest + 1)

Measured memory_bytes: 56028
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
 int M, D; cin >> M >> D;
int ans = 0;
for (int m = 1; m <= M; ++m) {
for (int d = 10; d <= D; ++d) {
int d_1 = d % 10, d_10 = d / 10;
if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == m) {
++ans; }
} }
cout << ans << endl; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,t;
  while(1){
  int ans = 0;
  int r[200]={};
  cin >> a >> b;
  if(a==0 && b==0) break;
  for(int i=0; i<a; i++){
    cin >> c;
    for(int i=0; i<c; i++){
      cin >> d;
      r[d]++;
    }
  }
  t = 0;
  //for(int i=0; i<c; i++) cout << r[i] << " ";
  for(int i=0; i<200; i++){
    if(r[i]>=b && ans < i && t < r[i]){
      ans = i;
      t = r[i];
    }
  }
  cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,a[500005],b[500005],i,k;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	b[0]=a[0];
	for(i=1;i<n;i++)b[i]=b[i-1]+a[i];

	ll mn=10000000000;
 	for(i=1;i<n;i++)
 	{
 		
 		ll p=abs(b[n-1]-b[i-1]-b[i-1]);
 		//cout<<p<<" "<<b[i-1]<<endl;
 		mn=min(p,mn);
 	    //cout<<mn<<endl;
 	}
 	cout<<mn<<endl;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
vector<int> a, b;

int ca[200009], cb[200009];

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

    cin >> n;
    rep(i, n) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    rep(i, n) {
        int x;
        cin >> x;
        b.push_back(x);
    }

    reverse(ALL(b));

    int idx = 0;
    rep(i, n) if(a[i] == b[i]) {
        int x = a[i];
        while(idx < n && !(a[idx] != x && b[idx] != x))
            idx++;
        if(idx >= n) {
            cout << "No\n";
            return 0;
        }
        swap(b[idx], b[i]);
    }

    cout << "Yes\n";
    rep(i, n) cout << b[i] << " \n"[i == n - 1];

    return 0;
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    cin >> s;
    ll ans = 9*(s.size()-1);
    ll f = 0;
    for(ll i = 1; i < s.size(); i++) if(s[i]-'0' < 9) f = 1;
    ans += s[0]-'0'-f;
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256