akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var S = ReadLine().ToCharArray();
            var lNum = 0L;
            var lS = 0L;
            foreach (var s in S)
            {
                if (s == '(') ++lNum;
                else
                {
                    if (lNum == 0) ++lS; 
                    else --lNum;
                }
            }
            S = S.Reverse().ToArray();
            var rNum = 0L;
            var rS = 0L;
            foreach (var s in S)
            {
                if (s == ')') ++rNum;
                else
                {
                    if (rNum == 0) ++rS;
                    else --rNum;
                }
            }
            S = S.Reverse().ToArray();
            var ans = new string('(', (int)lS) + string.Join("", S) + new string(')', (int)rS);
            WriteLine(ans);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28304
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;

//==============================================

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

	int n, a;
	cin >> n >> a;

	vi card(51);
	vvvl dp(vvvl(51, vvl(51, vl(3050))));

	REP(i, n) cin >> card[i];
	dp[0][0][0] = 1;

	REP(i, n) {
		REP(j, n) {
			REP(k, 2500) {
				if (dp[i][j][k]) {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j + 1][k + card[i]] += dp[i][j][k];
				}
			}
		}
	}

	LL ans = 0;
	REP3(i, 1, n) {
		ans += dp[n][i][i * a];
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 63616
# coding: utf-8
from bisect import bisect_left
from collections import defaultdict


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))

    ret = 0
    X = defaultdict(list)
    for i, a in enumerate(A):
        X[a+i].append(i)

    for j, a in enumerate(A):
        if 0 <= j-a:
            ret += bisect_left(X[j-a], j)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 65956
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;
#define def 0

int dec(vl& a, int start) {
  int end = start + 1;
  ll cur = a[start];
  while (end < a.size() && cur >= a[end]) {
    cur = a[end];
    end++;
  }
  return end;
}

int inc(vl& a, int start) {
  int end = start + 1;
  ll cur = a[start];
  while (end < a.size() && cur <= a[end]) {
    cur = a[end];
    end++;
  }
  return end;
}

int main() {
  //
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  int start = 0;
  int ans = 0;
  while (start < n) {
    int nexti = inc(a, start);
    int nextd = dec(a, start);
    // cout << start << "->" << nexti << "," << nextd << endl;
    start = max(nexti, nextd);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long LL;
using Graph = vector<vector<LL>>;
static LL INF = (1LL<<62);
using LLPair = pair<LL, LL>;

// N:頂点の数、G：グラフ(隣接行列表現)
void WarshallFloyd(LL N, Graph &G, vector<vector<LL>> &D){
	D.assign(N, vector<LL>(N, INF));
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){ D[i][j] = G[i][j]; }
	}

	for(int k=0; k<N; k++){
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				if(D[i][k] != INF && D[k][j] != INF){
					D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
				}
			}
		}
	}
	return;
}

LL N, M, R;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	vector<LL> r;
	cin >> N >> M >> R;

	for(int i=0; i<R; i++){
		LL t; cin >> t;
		r.push_back(t-1);
	}

	Graph G;
	G.assign(N, vector<LL>(N, INF));

	for(int i=0; i<M; i++){
		LL a, b, c; cin >> a >> b >> c;
		a--; b--;
		G[a][b] = min(G[a][b], c);
		G[b][a] = min(G[b][a], c);
	}
	
	vector<vector<LL>> D;
	WarshallFloyd(N, G, D);

	LL ans = INF;
	sort(r.begin(), r.end());
	do{
		LL w = 0;
		for(int i=0; i<r.size()-1; i++){
			LL d = D[r[i]][r[i+1]];
			w += d;
		}
		if(ans > w){
			ans = w;
		}
	}
	while(next_permutation(r.begin(), r.end()));

	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4396
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n >> s;

    for (int i = 0; i < s.size(); i++) {
        int tmp = n;
        while (tmp) {
            if (s[i] != 'Z') {
                s[i]++;
            }
            else {
                s[i] = 'A';
            }
            tmp--;
        }
    }

    cout << s << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int x=0, ans=0, n; cin >> n;
    string s; cin >> s;
    REP(i , n){
        if(s[i] == 'D') --x;
        else ++x;
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
program hihi;
var 
	N : longint;
    M, i : integer;
    A : array[1..10000] of integer;
    
begin 
	readln(N, M);
    for i:=1 to M do begin
    	read(A[i]);
       	N := N - A[i];
        end;
    if N<0 
    	then N:=-1;
    writeln(N);
end.

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  sort(ALL(v));
  int ans = v.back() - v.front();

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,l,r;
  cin>>a>>b>>c>>d;
  l=a+b; r=c+d;
  if(l>r){
    printf("Left");
  }
  else if(l<r){
    printf("Right");
  }else{
    printf("Balanced");
  }
  return 0;
}

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

class Dice{
private:
  int right,wrong;
  int N,E,W,S;
  int tmp1,tmp2;
public:
  Dice():right(0),wrong(0),N(0),E(0),W(0),S(0){};
  Dice(int ri,int wr,int n,int e,int w,int s):right(ri),wrong(wr),N(n),E(e),W(w),S(s){};
  void SetDice(int,int,int,int,int,int);
  int ShowRight(){return right;}
  int ShowWrong(){return wrong;}
  int ShowN(){return N;}
  int ShowE(){return E;}
  int ShowW(){return W;}
  int ShowS(){return S;}
  void goN();
  void goE();
  void goW();
  void goS();
};

void Dice::SetDice(int ri,int wr,int n,int e,int w,int s){
  right=ri; wrong=wr;
  N=n; S=s;
  W=w; E=e;
}
void Dice::goN(){
  tmp1=N; tmp2=S;
  N=wrong; S=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goE(){
  tmp1=E; tmp2=W;
  E=wrong; W=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goW(){
  tmp1=W; tmp2=E;
  W=wrong; E=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goS(){
  tmp1=S; tmp2=N;
  S=wrong; N=right;
  right=tmp1; wrong=tmp2;
}

int main()
{
  int label1[6];
  int label2[6];
  Dice dice[100];

  int n;
  int a,b;
  int flag=0;
  int OK_flag=0;

  cin >> n;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<6;j++)
	cin >> label1[j];
      dice[i].SetDice(label1[0],label1[5],label1[1],label1[3],label1[2],label1[4]);
    }

  for(int p=0;p<n-1;p++)
    {
      for(int q=p+1;q<n;q++)
	{

	  for(int j=0;j<6;j++)
	    {
	      for(int i=0;i<4;i++)
		{
		  flag=0;
		  if(dice[p].ShowRight()!=dice[q].ShowRight()) flag=1;
		  if(dice[p].ShowWrong()!=dice[q].ShowWrong()) flag=1;
		  if(dice[p].ShowN()!=dice[q].ShowN()) flag=1;
		  if(dice[p].ShowE()!=dice[q].ShowE()) flag=1;
		  if(dice[p].ShowW()!=dice[q].ShowW()) flag=1;
		  if(dice[p].ShowS()!=dice[q].ShowS()) flag=1;
		  if(flag==0) OK_flag=1; //\u5168\u304f\u540c\u3058\u306e\u3068\u304d=1
		  dice[q].goS();dice[q].goW();dice[q].goN();
		}
	      if(j==0||j==1)dice[q].goN();
	      else if(j==2) dice[q].goE();
	      else if(j==3||j==4) dice[q].goN();
	    }

	}
    }
  if(OK_flag==0)cout << "Yes\n"; //\u3059\u3079\u3066\u304c\u7570\u306a\u308b\u3068\u304d
  else       cout << "No\n";    

  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <assert.h>
typedef long long ll;
using namespace std;

const int N=1e6+10;
int in[N];
vector<int>G[N];
bool vis[N];

int bfs(int s,int t){
//	cerr<<s<<' '<<t<<endl;
	queue<int>que;
	que.push(s);
	int ans=0;
	while(!que.empty()){
		int u=que.front();que.pop();
		vis[u]=1;
		for(auto v:G[u]){
			if(v==t){
				ans++;
			}
			if(vis[v]) continue;
			vis[v]=1;
			if(v!=t) que.push(v);
		}
	}
	return ans;
}

void solve(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		in[u]++,in[v]++;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int four=0,six=0;
	for(int i=1;i<=n;i++){
		if(in[i]&1){
			printf("No\n");
			return ;
		}
		if(in[i]>=4) four++;
		if(in[i]>=6) six++;
	}	
	if(four==2 && six==0){
		int s=-1,t;
		for(int i=1;i<=n;i++){
			if(in[i]==4){
				if(s==-1) s=i;
				else t=i;
			}
		}
		int ret=bfs(s,t);
	//	cout<<ret<<endl;
		assert(ret==2 || ret==4);
		if(ret==4) printf("No\n");
		else printf("Yes\n");
	}
	else if(four>=2 || six>=1){
		printf("Yes\n");
	}
	else printf("No\n");
}

int main(){

	solve();
    return 0;
}

Measured memory_bytes: 29056
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

template<typename T>
void fill_all(T& a, const T& b)
{
	a = b;
}
template<typename T, size_t N, typename U>
void fill_all(T(& a)[N], const U& b)
{
	for (auto& i : a)
	{
		fill_all(i, b);
	}
}

int h[100000];
int main() {
	int N;
	cin >> N;
	cout << "Christmas";
	for (int i = N; i < 25; i++)
	{
		cout << " Eve";
	}
	cout << endl;
}

#if 0
int P, R, Q;
int r_num[300];
std::vector<int> resolved[300][101];

int main()
{
	cin >> P >> R >> Q;
	for (int i = 0; i < R; i++)
	{
		cin >> r_num[i];
	}



}
#endif

Measured memory_bytes: 256
import java.util.*;
class Main
{
    static long mod = 1000000007;
    static long[] p = new long[1000001];
    String yes = "Yes";
    String no = "No";
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        System.out.println(a * b / 2);
    }
}


Measured memory_bytes: 30932
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }
    a.sort_by(|a, b| b.cmp(a));
    let mut ans = 0;
    let mut t = n - 1;
    for i in 0..n {
        let lim = if i == 0 { 1 } else { 2 };
        for j in 0..lim {
            if t > 0 {
                ans += a[i];
                t -= 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6236
N=int(input())
A=list(map(int, input().split()))
left=0
a=0
cnt=0
for right in range(N):
  if a&A[right]:
    while a&A[right]:
      a^=A[left]
      left+=1
  cnt+=right-left
  a^=A[right]
print(cnt+N)

Measured memory_bytes: 24840
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);


  
  
  
  int a,b;cin>>a>>b;
  
  if(b>=a){
    cout<<a<<endl;
  }else{
    cout<<a-1<<endl;
  }
  
}


Measured memory_bytes: 256
n = gets.chomp.to_i

t0 = 0
x0 = 0
y0 = 0

n.times do
  t, x, y = gets.chomp.split(" ").map(&:to_i)
  d = (x0 - x).abs + (y0 - y).abs
  dt = t - t0
  if d > dt || (d % 2 != dt % 2) then
    puts "No"
    exit
  end
  t0 = t
  x0 = x
  y0 = y
end
puts "Yes"


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

using namespace std;
typedef long long llong;

#define MAX 1010
const llong mod = 1000000000 + 7;

int main()
{

  double a, b, h, m;
  scanf("%lf%lf%lf%lf", &a, &b, &h, &m);

  double th = m - h * 5.0 - m / 12.0;
  th = th / 30 * M_PI;
  if (th < 0.0)
  {
    th *= -1.0;
  }

  double c_square = a * a + b * b - 2 * a * b * cos(th);
  double c = sqrt(c_square);
  printf("%.16lf", c);
  return 0;
}

Measured memory_bytes: 2644
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int dp[2005][2005];

int main () {
	SpeedForce;

	cin >> n >> k;
	for (int i = 0; i < 2005; i ++) {
   	for (int j = 0; j <= i; j ++) {
      	if (j == 0 || i == j) {
        		dp[i][j] = 1;
      	} else {
        		dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]);
        		if(dp[i][j] >= mod) dp[i][j] -= mod;
      	}
    	}
  	}

	for (int i = 1; i <= k; i ++) {
		cout << (dp[n - k + 1][i] * (ll)dp[k - 1][i - 1]) % mod << '\n';
	}

	return Accepted;
}

// B...a

Measured memory_bytes: 15104
from collections import deque
def main3():
    S = input()

    i = 0
    tmp = ""
    sub = deque()
    words = set()
    while True:
        j = 1
        while i + j <= len(S):
            if S[i:i+j] != tmp:
                sub.append(S[i:i+j])
                tmp = S[i:i+j]
                i = i + j
                # print(tmp)
                break
            else:
                j += 1

        if i + j > len(S):
            # print("over : {}".format(S[i:i+j]))
            if S[i:i+j] != "":
                if sub[-1] == S[i:i+j]:
                    e = sub.pop()
                    sub.append(e + S[i:i+j])
                else:
                    sub.append(S[i:i+j])
            break
    
    # print(sub)
    print(len(sub))
    
if __name__ == "__main__":
    main3()

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

#define fast_io()                    \
    do {                             \
        ios::sync_with_stdio(false); \
        std::cin.tie(0);             \
    } while (0)
#define DBG(__need_dbg)                                              \
    do {                                                             \
        std::cout << "[" << __FUNCTION__ << ":" << __LINE__ << "] "; \
        std::cout << #__need_dbg << " = " << (__need_dbg) << endl;   \
    } while (0)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> two;

int main() {
    fast_io();

    bool flag{};
    int n;
    cin >> n;
    while (n--) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0 && tmp % 3 != 0 && tmp % 5 != 0) {
            flag = true;
        }
    }
    if (flag) {
        cout << "DENIED\n";
    } else {
        cout << "APPROVED\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    REP(i,H) cin>>S[i];
    vector<vector<ll>> dist(H*W,vector<ll>(H*W,1LL<<50));
    int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    REP(i,H*W){
        if(S[i/W][i%W]=='#') continue;
        REP(j,4){
            int nx=i/W+dx[j],ny=i%W+dy[j];
            if(0<=nx&&nx<H&&0<=ny&&ny<W&&S[nx][ny]=='.'){
                dist[nx*W+ny][i]=dist[i][nx*W+ny]=1;
            }
        }
        dist[i][i]=0;
    }
    REP(k,H*W) REP(i,H*W) REP(j,H*W){
        if(dist[i][j]>dist[i][k]+dist[k][j]){
            dist[i][j]=dist[i][k]+dist[k][j];
        }
    }
    ll ans=0;
    REP(i,H*W) REP(j,H*W){
        if(S[i/W][i%W]=='.'&&S[j/W][j%W]=='.') ans=max(ans,dist[i][j]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2044
#include <iostream>
#include <limits>
#include <algorithm>

int main()
{
    int n;
    int min = std::numeric_limits<int>::max();
    int max = std::numeric_limits<int>::min();

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        min = std::min(min, x);
        max = std::max(max, x);
    }
    std::cout << max - min << std::endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 100;
ll p[maxn], q[maxn], r[maxn];
int main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for (int i = 1; i <= a; i++)
		cin >> p[i];
	for (int i = 1; i <= b; i++)
		cin >> q[i];
	for (int i = 1; i <= c; i++)
		cin >> r[i];
	sort(p + 1, p + 1 + a);
	sort(q + 1, q + 1 + b);
	sort(r + 1, r + 1 + c);
	int f1 = a - x + 1, f2 = b - y + 1, f3 = c;//位置
	ll sum = 0;
	for (int i = f1; i <= a; i++)
		sum += p[i];
	for (int i = f2; i <= b; i++)
		sum += q[i];

	while ((r[f3] > p[f1] || r[f3] > q[f2])&&f3>0&&f1<=a&&f2<=b){
		if (r[f3] > p[f1] && r[f3] > q[f2]){
			if (p[f1]>q[f2])
				sum += r[f3] - q[f2], f3--, f2++;
			else
				sum += r[f3] - p[f1], f3--, f1++;
		}
		else if (r[f3] > p[f1])
			sum += r[f3] - p[f1], f3--, f1++;
		else if (r[f3] > q[f2])
			sum += r[f3] - q[f2], f3--, f2++;
	}
	while (r[f3]>p[f1]&&f3>0&&f1<=a)
		sum += r[f3] - p[f1], f3--, f1++;
	while (r[f3]>q[f2] && f3>0 && f2 <= b)
		sum += r[f3] - q[f2], f3--, f2++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if (a*b >= c*d) {
    cout<<a*b;
  } else {
    cout<<c*d;
  }

  return 0;
}


Measured memory_bytes: 256
import math

def gc3(a,b,c):
    x = math.gcd(a,b)
    x = math.gcd(x,c)
    return x

n = int(input())
ans = 0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans += gc3(i,j,k)
            
print(ans)

Measured memory_bytes: 70876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = 0;
		int B = 0;
		for(int i=-500; i<500; i++) {
			for(int j=-500; j<500; j++) {
				double c = Math.pow(i, 5)-Math.pow(j, 5);
				if((int)c==X) {
					A = i;
					B = j;
					break;
				}
			}
		}
		System.out.println(A + " " + B);
	}

}

Measured memory_bytes: 38824
import sys
sys.setrecursionlimit(10 ** 7)

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

X = ir()

def check(n):
    if X == 2:
        return True
    if n % 2 == 0:
        return False
    f = 3
    while f * f <= n:
        if n % f == 0:
            return False
        else:
            f += 2
    return True

while True:
    if check(X):
        print(X); exit()
    else:
        X += 1

# 44

Measured memory_bytes: 3060
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

calc :: Double -> String
calc d
  | shifted == fromIntegral int = toBinString 8 i "" ++ "." ++ toBinString 4 f ""
  | otherwise = "NA"
  where
    shifted = d * 16
    int = floor shifted
    (i,f) = divMod int 16
    toBinString 0 _ s = s
    toBinString k n s = let (r,b) = divMod n 2 in toBinString (k-1) r (intToDigit b : s) 


main = map (calc . readDouble) . takeWhile ((/='-') . head) . lines <$> getContents >>= mapM_ putStrLn


Measured memory_bytes: 4488
n, m = gets.split.map(&:to_i)
abs  = n.times.map{ gets.split.map(&:to_i) }

abs.sort!{ |x,y| x[0]<=>y[0] }
btl, sum = 0, 0
abs.each do | ab |
  if btl+ab[1] >= m
    sum += (m - btl) * ab[0]
    btl += (m-btl)
    break
  else
    sum += ab[1] * ab[0]
    btl += ab[1]
  end
end
p sum

Measured memory_bytes: 10488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  ld T,X; cin>>T>>X;
  cout << T/X << "\n";
  
}



Measured memory_bytes: 256
import copy
import sys
write = sys.stdout.write

n = int(input())
A = list(map(int,input().split())) # +, -, +, ...
B = copy.deepcopy(A) #-, +, -, ...
sumA = []
sumB = []
cntA = 0
cntB = 0
if A[0] == 0:
    A[0] += 1
    cntA += 1
    B[0] -= 1
    cntB += 1
elif A[0] > 0:
    cntB += (B[0]+1)
    B[0] = -1
else:
    cntA += abs(A[0])+1
    A[0] = 1
sumA.append(A[0])
sumB.append(B[0])
#write("cntA : " + str(cntA) + " cntB : " + str(cntB) + "\n") 
for i in range(1, n):
    tempA = sumA[i-1] + A[i]
    tempB = sumB[i-1] + B[i]
    if i%2 == 1: #Aは-, Bは+
        if tempA == 0:
            #A[i] -= 1
            cntA += 1
            sumA.append(-1)
        elif tempA > 0:
            #A[i] -= abs(tempA) + 1
            cntA += (abs(tempA) + 1)
            sumA.append(-1)
        else:
            sumA.append(tempA)

        if tempB == 0:
            #B[i] += 1
            cntB += 1
            sumB.append(1)
        elif tempB < 0:
            #B[i] += abs(tempB) + 1
            cntB += (abs(tempB) + 1)
            sumB.append(1)
        else:
            sumB.append(tempB)
    else: #Aは+, Bは-
        if tempA == 0:
            cntA += 1
            sumA.append(1)
        elif tempA < 0:
            cntA += (abs(tempA) + 1)
            sumA.append(1)
        else:
            sumA.append(tempA)
        
        if tempB == 0:
            #B[i] -= 1
            cntB += 1
            sumB.append(-1)
        elif tempB > 0:
            #B[i] -= abs(tempB) + 1
            cntB += (abs(tempB) + 1)
            sumB.append(-1)
        else:
            sumB.append(tempB)
    #write("cntA : " + str(cntA) + " cntB : " + str(cntB) + "\n")

print(str(min(cntA, cntB)))

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

int main() {
  long N;
  cin >> N;
  long sum=0;
  for(long i=2;i*i<N;i++){
    if(N%i==0){
      if(N%(i-1)==N/(i-1))sum+=i-1;
      if((N%(N/i-1))==N/(N/i-1))sum+=N/i-1;
    }
  }
  sum+=N-1;
  if(N==2)sum=0;
  cout << sum;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))

    position = 0
    count = 0
    counts = []
    while True:
        try:
            if H[position] >= H[position+1]:
                position += 1
                count += 1
                continue
            else:
                position += 1
                counts.append(count)
                count = 0
        except:
            counts.append(count)
            break

    print(max(counts))


Measured memory_bytes: 23388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using T  = tuple<int,int,int>;

int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    
    int k;cin>>k;
    
    while(a>=b && k>0){
        b *= 2;
        k--;
    }
    
    while(b>=c && k>0){
        c*= 2;
        k--;
    }
    
    if(a<b && b<c)
        cout<<"Yes" <<endl;
    else
        cout<<"No" <<endl;
    
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, d;
    cin >> n >> d;
    ll range = 2 * d + 1;
    cout << (n + range - 1) / range << endl;
    return 0;
}

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

int a[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double a, b, p, q, r;
    cin >> a >> b >> p >> q >> r;

    double dist = p * b - (b - a) * q;
    cout << fixed << setprecision(9);
    cout << b + (dist / (q + r)) << endl;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i64 = int64_t;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int N;
  cin >> N;
  v(i64) A(N+1);
  cin >> A;

  v(i64) joukai(N+1);
  joukai[0] = 1;
  rep(i, N) {
    if(joukai[i] < A[i]) {
      cout << -1 << "\n";
      return;
    }
    joukai[i+1] = min(INF, (joukai[i]- A[i]) * 2);
  }
  if(joukai[N] < A[N]) {
    cout << -1 << "\n";
    return;
  }

  v(i64) ans(N+1);
  ans[N] = A[N];
  rrep(i, N-1, -1) {
    ans[i] = min((ans[i + 1] + A[i]), joukai[i]);
  }

  cout << accumulate(rng(ans),0LL) << "\n";
}

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

Measured memory_bytes: 5572
#include <iostream>

using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ret;
  if (a == b && b == c) {
    ret = 1;
  } else if (a == b || b == c || c == a) {
    ret = 2;
  } else {
    ret = 3;
  }
  cout << ret << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i <= 0; --i)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, x;
	cin >> x >> a >> b;
	cout << (abs(x - a) > abs(x - b) ? "B" : "A") << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    cout << a[n - 1];
    for(int i = n - 2; i >= 0; i--)
    cout << " " << a[i];

    cout << endl;

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[1000004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
  //  cin>>t;
    while(t--){
        string s;
        cin>>s;
        int ans=0;
        for(int i=0;i<sz(s);i++){
            int j=i,cnt=0;
            while(j<sz(s)&&s[j]=='R') cnt++,j++;
            ans=max(ans,cnt);
            i=j;
        }
        cout<<ans<<endl;
    }
 return 0;
}

Measured memory_bytes: 3620
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    long double r;
    cin >> r;

    cout << 2 * 3.14 * r << endl;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int n,k,d,ans;
set<int>a;
int main(){
	cin>>n>>k;
	int x;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>x;
			a.insert(x);
		}
	}
	
	cout<<n-a.size();
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  map<string, int> map;
  
  map["AC"] = 0;
  map["WA"] = 0;
  map["TLE"] = 0;
  map["RE"] = 0;
  
  rep(i, n) {
    string res; cin>>res;
    ++ map[res];
  }
  
  cout<<"AC"<<" x "<<map["AC"]<<endl;
  cout<<"WA"<<" x "<<map["WA"]<<endl;
  cout<<"TLE"<<" x "<<map["TLE"]<<endl;
  cout<<"RE"<<" x "<<map["RE"]<<endl;

  return 0;
}

Measured memory_bytes: 3588
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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


MY_NAMESPACE(testbed)
int main()
{
	int n;
	cin >> n;
	vector<ll> avec(n);
	for (int i = 0; i < n; i++)
	{
		cin >> avec[i];
		if (avec[i] == 0)
		{
			cout << 0 << "\n";
			return 0;
		}
	}

	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (avec[i] > 1000000000000000000 / ans)
		{
			cout << -1 << "\n";
			return 0;
		}
		ans *= avec[i];
	}
	cout << ans << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 4036
# -*- coding: utf-8 -*-
A, B = map(int, input().split())
S = input()

data = S.split('-')

if len(data) != 2:
    print('No')
else:
    if len(data[0]) == A and len(data[1]) == B:
        if data[0].isdigit() and  data[1].isdigit():
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: f32 = read();
    let a: Vec<f32> = (0..n).map(|_| read()).collect();

    let sum: f32 = a.iter().fold(0.0, |sum, x| sum + x);
    let shikii:f32 = sum/(4.0*m);
    let mut count = 0.0;
    for x in a.iter() {
        if *x >= shikii {
            count += 1.0;
        }
    }
    if count >= m {
        println!("Yes");
    }else{
        println!("No");
    }


}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using Graph = vector<vector<P>>;


int main()
{
  int N;cin>>N;
  Graph G(N);
  for (int i=1;i<=N-1;i++)
  {
    int u,v,w;cin>>u>>v>>w;
    u--;v--;
    G[u].push_back(P(v,w));
    G[v].push_back(P(u,w));
  }
  
  queue<int> que;
  vector<int> dist(N,-1);//−１は未検出
  vector<int> color(N,0); 
  
  que.push(0);
  dist[0]=0;
  
  while (!que.empty())
  {
    int v = que.front();
    que.pop();
    
    for (auto nv : G[v])
    {
      if (dist[nv.first]!=-1)
      {
        continue;
      }
      
      que.push(nv.first);
      dist[nv.first]=dist[v]+nv.second;
      
      if (dist[nv.first]%2==0)
      {
        color[nv.first]=0;
      }else color[nv.first]=1;
    }
  }
  
  for (int i=0;i<N;i++)
    cout<<color[i]<<endl;
}

Measured memory_bytes: 7168
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]pair, N)
	for i := 0; i < N; i++ {
		x := getInt()
		a[i] = pair{x, i + 1}
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i].x < a[j].x
	})
	for i := 0; i < N; i++ {
		fmt.Print(a[i].y, " ")
	}
	out()
}


Measured memory_bytes: 4856
n = int(input())
d = []
for i in range(n):#h:高さ
    d.append([int(m) for m in input().split()])
#dp = [None] * n
dp = []
for i in range(n + 1):
    dp.append([None, None, None])
dp[0][0] = d[0][0]#"A"
dp[0][1] = d[0][1]#"B"
dp[0][2] = d[0][2]#"C"
#dp[1][0] = d[0][0]#"A"
#dp[1][1] = d[0][1]#"B"
#dp[1][2] = d[0][2]#"C"
#dp[i] = max(dp[i - 2]["A"] + d[i - 1][1], dp[i - 2]["A"] + d[i - 1][2], dp[i - 2]["B"] + d[i - 1][0], dp[i - 2]["B"] + d[i - 1][2], dp[i - 2]["C"] + d[i - 1][0], dp[i - 2]["C"] + d[i - 1][1])
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1] + d[i][0], dp[i - 1][2] + d[i][0])
    dp[i][1] = max(dp[i - 1][0] + d[i][1], dp[i - 1][2] + d[i][1])
    dp[i][2] = max(dp[i - 1][0] + d[i][2], dp[i - 1][1] + d[i][2])
print(max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))

Measured memory_bytes: 44236
#!/usr/bin/env python3
# input
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, input().split())
path = [[] for _ in range(n)]
ans = [-1] * (n - 1)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    # 0idx に直す
    path[a].append(b)
    path[b].append(a)
# room 0 から見ていく
# i-1== -1 でなければvisited
stack = deque()
stack.append(0)
while len(stack) > 0:
    pos = stack.popleft()
    for next_pos in path[pos]:
        if next_pos == 0:
            continue
        if ans[next_pos - 1] == -1:  # unvisited
            ans[next_pos - 1] = pos + 1
            stack.append(next_pos)  # 0 idx
print("Yes")
for i in ans:
    print(i)


Measured memory_bytes: 37048
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    s = input()
    k = ii()
    n = len(s)

    s = list(s)
    ss = deepcopy(s)

    if len(set(ss)) == 1:
        print(n*k//2)
        exit()



    sc = deepcopy(s)

    cnt = 0
    for i in range(1,n):
        if sc[i] == sc[i-1]:
            sc[i] = '0'
            cnt+=1
    
    if sc[n-1] == sc[n-2] or sc[0] == sc[n-1]:
        flag = True
    else:
        flag = False

    ans = cnt*k+(flag*(k-1))

    cnt = 1
    s[0] = '0'
    for i in range(1,n):
        if s[i] == s[i-1]:
            s[i] = '0'
            cnt+=1
    
    if s[n-1] == s[n-2] or s[0] == s[n-1]:
        flag = True
    else:
        flag = False

    ans2 = cnt*k+(flag*k)



    print(min(ans,ans2))





main()


Measured memory_bytes: 23200
N,Y = map(int,input().split())
ans = [-1,-1,-1]
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if z >=0:
            if 10000 * x + 5000 * y + 1000 * z == Y:
                ans = [x,y,z]
                break

print(*ans)

Measured memory_bytes: 3060
f,p[5];main(i){for(;({for(f=i=0;i<5;f|=1<<p[i++])scanf("%d\n",p+i);*p;});)for(i=-1;i++<4;puts((f-4)%5-p[i]?f%5-p[i]%3?"3":"1":"2"));}

Measured memory_bytes: 0
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    map<ll , ll> cnt;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        cnt[a[i]]++;
    }
    // cout << "sum : " << sum << endl;
    int q;
    cin >> q;
    
    while (q--){
        ll b , c;
        cin >> b >> c;
        cnt[c] += cnt[b];
        sum -= (b * cnt[b]);
        // cout << "r sum : " << sum << endl;
        sum += (c * cnt[b]);
        // cout << "added : "<< sum << endl;

        cnt.erase (cnt.find (b));
        cout << sum << endl;
    }
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 7952