akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;

  int ch, cw;
  cin >> ch >> cw;

  int dh, dw;
  cin >> dh >> dw;

  ch--;
  cw--;
  dh--;
  dw--;

  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> s[i][j];

  const int INF = 1e9;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  deque<P> q;

  dist[ch][cw] = 0;
  q.emplace_back(ch, cw);
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop_front();
    int d = dist[i][j];
    rep(v, 4) {
      int ni = i + di[v], nj = j + dj[v];
      if (ni < 0 || h <= ni || nj < 0 || w <= nj)
        continue;
      if (s[ni][nj] == '#')
        continue;
      if (dist[ni][nj] <= d)
        continue;
      dist[ni][nj] = d;
      q.emplace_front(ni, nj);
    }
    for (int ei = -2; ei <= 2; ei++) {
      for (int ej = -2; ej <= 2; ej++) {
        int ni = i + ei, nj = j + ej;
        if (ni < 0 || h <= ni || nj < 0 || w <= nj)
          continue;
        if (s[ni][nj] == '#')
          continue;
        if (dist[ni][nj] <= d + 1)
          continue;
        dist[ni][nj] = d + 1;
        q.emplace_back(ni, nj);
      }
    }
  }

  int ans = dist[dh][dw];
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 8648
import std.stdio,
       std.string,
       std.conv;

R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
  return (Args args) => f(Z(f), args);
}

void main() {
  (N => 
    (Fibonacci =>
      Fibonacci(1, 1, N)
    )(Z((ulong delegate(ulong, ulong, ulong)solver, ulong n1, ulong n2, ulong N) =>
        0 < N ? solver(n1 + n2, n1, N - 1) : n2)
  ))(readln.chomp.to!ulong).writeln;
}

Measured memory_bytes: 2464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(x,b) ((x)>=0&&(x)<(b))
#define Y first
#define X second
#define INF 1 << 30

typedef pair<int, int> pii;
typedef queue<int> qi;
typedef pair<int, int> pi;

//int board[51][51], Y, X;
int board[500][500], Y, X;
int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};

pii nextp1(pii now, int i){
  pii next = now;
  next.Y += dy[i];
  next.X += dx[i];
  //  printf("%d %d\n", next.Y, next.X);
  //  if(BW(next.Y, Y)) puts("YES");
  //  if(BW(next.X, X)) puts("YES");
  //  printf("%d\n", board[next.Y][next.X]);
  if(BW((next.Y), Y) && BW((next.X), X) && board[next.Y][next.X] == 0) return next;
  return now;
}

pii nextp2(pii now, int i){
  pii next = now;
  next.Y += -1 * dy[i];
  next.X += -1 * dx[i];
  if(BW(next.Y, Y) && BW(next.X, X) && board[next.Y][next.X] == 0) return next;
  return now;
}
     
int main(){
  while(scanf("%d%d", &X,  &Y) && X+Y){
    int tx, ty, kx, ky;
    scanf("%d%d%d%d", &tx, &ty, &kx, &ky); tx--; ty--; kx--; ky--;
    rep(i, Y) rep(j, X) scanf("%d", &board[i][j]); 

    //    rep(i, X){
    //      rep(j, Y) printf("%d ", board[i][j]); puts("");
    //    }

    map<pair<pi,pi>, bool>m; // t k
    queue<pii>tq, kq;
    tq.push(make_pair(ty, tx));
    kq.push(make_pair(ky, kx));
    m[make_pair(make_pair(ty, tx), make_pair(ky, kx))] = 1;
    int res = 1;
    while(!tq.empty()){
      if(res >= 100) break;
      //      printf("%d\n", res);
      int qsize = (int)tq.size();
      //      printf(" %d\n", qsize);
      rep(i, qsize){
	pii t = tq.front(); tq.pop();
	pii k = kq.front(); kq.pop();
	//	printf("%d %d %d %d\n", t.Y, t.X, k.Y, k.X);
	rep(j, 4){
	  pii nt = nextp1(t, j), nk = nextp2(k, j);
	  //	  printf("%d %d %d %d\n", t.Y, t.X, k.Y, k.X);
	  //	  printf("%d %d %d %d\n", nt.Y, nt.X, nk.Y, nk.X);

	  //	  if(f[nt.Y][nt.X][nk.Y][nk.X]) continue;
	  pair<pi, pi> next = make_pair(make_pair(nt.Y, nt.X), make_pair(nk.Y, nk.X));
	  if(m.count(next) == 1) continue;
	  if(nt == nk){
	    printf("%d\n", res);
	    //	    printf("%d %d %d %d\n", nt.Y, nt.X, nk.Y, nk.X);
	    goto end;
	  }
	  //	  fprintf(stderr, "%d %d %d %d\n", nt.Y, nt.X, nk.Y, nk.X);
	  //	  f[nt.Y][nt.X][nk.Y][nk.X] = 1;
	  m[next] = 1;
	  tq.push(nt); kq.push(nk);
	}
      }
      //      if(res > 100) break;
      res++;

    }
    //    printf("%d\n", (int)tq.size());
    puts("NA");
  end:;
  }
  return 0;
}

Measured memory_bytes: 12472
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=500010,maxn=500000;
const int mod=998244353;
int inv[N],cj[N];int ans;

int power(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod){
		if(y&1)	ret=1ll*ret*x%mod;
	}
	return ret;
}

void init(){
	int i;
	cj[0]=1;rep(i,1,maxn)	cj[i]=1ll*cj[i-1]*i%mod;
	inv[maxn]=power(cj[maxn],mod-2);inv[0]=1;
	for(i=maxn-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int n,int m){
	//printf("%d %d\n",n,m);
	if(m<0||n<m)	return 0;
	return 1ll*cj[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,n,m;
	init();
	scanf("%d%d",&n,&m);
	rep(i,0,min(m/2,m-n)){
		if(2*i==m)	ans=(1ll*ans+C(m-1,i-1)-C(m-1,i-1-(m-i-n+1)))%mod;
		else ans=(1ll*ans+C(m,i)-C(m,i-(m-i-n+1)))%mod;
		//if(2*i==m)	ans=(1ll*ans-(C(m-1,i-(m-i-n))-C(m-1,i-(m-i-n+1))))%mod;
		//printf("%d\n",ans);
	}
	ans=(ans%mod+mod)%mod;
	printf("%d",ans);
}
	

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

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

  int ans;
  if (s == "SUN") {
    ans = 7;
  } else if (s == "MON") {
    ans = 6;
  } else if (s == "TUE") {
    ans = 5;
  } else if (s == "WED") {
    ans = 4;
  } else if (s == "THU") {
    ans = 3;
  } else if (s == "FRI") {
    ans = 2;
  } else if (s == "SAT") {
    ans = 1;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long MOD = 1000000007;
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N;cin >> N;
    long long A[N];REP(i,N) cin >> A[i];
    long long L = 0,R = 0,cnt = 0,ans = 0;
    while(R < N){
        while((cnt ^ A[R]) != cnt + A[R]){
            cnt ^= A[L];L++;
        }
        cnt ^= A[R];
        ans += (R - L + 1);R++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
int n;
double x[55], y[55], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	
    for (int i = 0; i < 1000000 ; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}

	printf("%0.15lf\n", sqrt(d));
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges [][]Edge // Edge[i][j]: 頂点iのj番目の辺
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges: make([][]Edge, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func dfs(g *Graph, visited []bool, dp []int, cur int) int {
	if visited[cur] {
		return dp[cur]
	}
	visited[cur] = true
	cost := 1
	for _, e := range g.Edges[cur] {
		res := dfs(g, visited, dp, e.to)
		if res == -1 {
			return -1
		}
		cost = max(cost, res+1)
	}
	dp[cur] = cost
	return dp[cur]
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, n-1)
		for j := range a[i] {
			a[i][j] = nextInt() - 1
		}
	}

	// id[i][j]: 選手iと選手jの試合のid
	id := make([][]int, n)
	num := 0
	for i := 0; i < n; i++ {
		id[i] = make([]int, n)
		for j := range id[i] {
			if i < j {
				id[i][j] = num
				num++
			} else if i > j {
				id[i][j] = id[j][i]
			}
		}
	}
	// 試合を頂点とみなしたグラフ
	g := NewGraph(num)
	for i := 0; i < n; i++ {
		// 選手iの各選手との試合を，試合idで置き換える
		for j := 0; j < n-1; j++ {
			a[i][j] = id[i][a[i][j]]
		}
		// 試合を有向グラフに変換
		// 次の試合から今の試合への有向辺を張る
		for j := 0; j < n-2; j++ {
			g.AddEdge(a[i][j+1], a[i][j], 1)
		}
	}

	visited := make([]bool, num)
	// dp[i]: 頂点iからの最長経路長
	dp := make([]int, num)
	for i := range dp {
		dp[i] = -1
	}
	ans := 0
	for i := 0; i < num; i++ {
		res := dfs(g, visited, dp, i)
		if res == -1 {
			puts(-1)
			return
		}
		ans = max(ans, res)
	}

	puts(ans)
}


Measured memory_bytes: 59136
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics; 

class _Class
{
  void _Do()
  {
    var N = Split.ints()[0];
    var a = Split.ints();
    int m = 0;
    for (int i=0; ; )
    {
      if (i + 1 == N)
      {
        break;
      }
      else if (a[i] == a[i+1])
      {
        if (i + 2 < N)
        {
          m++;
          i += 2;
        }
        else
        {
          m++;
          i++;
        }
      }
      else
        i++;
      
    }
    Console.WriteLine(m);
  }


  //
  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}



Measured memory_bytes: 11092
def get_prime_num_list(n):
  if n < 3:
    return []
  result_list = []
  current_num = 3
  while current_num <= n:
    prime_flg = True
    for i in result_list:
      if current_num % i == 0:
        prime_flg = False
        break
    if prime_flg:
      result_list.append(current_num)
    current_num += 2
  return result_list

input_num = int(input())
prime_num_list = get_prime_num_list(input_num)

def divisor_count(n):
  tmp_num = n
  result_val = 1
  for prime_num in prime_num_list:
    prime_count = 0
    while tmp_num % prime_num == 0:
      prime_count += 1
      tmp_num //= prime_num
    result_val *= prime_count + 1
  return result_val
  
if input_num < 105:
  print(0)
else:
  num = 105
  result_count = 0
  while num <= input_num:
    if divisor_count(num) == 8:
      result_count += 1
    num += 2
  print(result_count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long unsigned n, k, ans;
	scanf("%llu%llu", &n, &k);
	ans = k;
	for(int i = 2; i <=n; i++)ans*=(k-1);
	printf("%llu", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(long long i=(from); i<(long long)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll X; cin >> X;
  RNG(i, -1000, 1001) {
    RNG(j, -1000, 1001) {
      if (i*i*i*i*i - j*j*j*j*j == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
int n;
int a[22][22];
ll dp[(1LL<<21)+5];
ll solve(ll row , ll mask)
{
    // cout<<row<<" "<<mask<<"\n";
    if(row == n)
    {
        if(mask == ((1LL<<n)-1))
            return 1;
        return 0;
    }
    ll ans = 0;
    if(dp[mask]!=-1)return dp[mask];
    for(int i=0;i<n;i++)
    {
        if(!(mask&(1LL<<i)) && a[row][i])
        {
            ans = (ans+solve(row+1,mask|(1LL<<i)))%mod;
        }
    }
    return dp[mask]=ans;
}
int main()
{
    fast;
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    cout<<solve(0,0);
return 0;
}

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

int main(){
	ll n;
	double d;
	cin >> n >> d;
	vector<pair<double,double>> p(n);
	rep(i,n){
		cin >> p[i].first >> p[i].second;
	}
	ll ans = 0;
	rep(i,n){
		double x = p[i].first;
		double y = p[i].second;
		if(x * x + y * y <= d*d) ans++;
	}
	cout << ans << endl;
    return 0;
}



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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  char str[21];
  int l,i;
  scanf("%s",str);
  l=strlen(str);
  for(i=l-1;i>=0;i--)
    printf("%c",str[i]);
  putchar('\n');
  return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
#include<iomanip>
int main(){
  int k,i,j,u;
  double sum=0.0,z,n;
  cin>>n>>k;
  for(i=1;i<=n;i++){
    u=0;
    for(j=i;j<=k-1;j*=2){
      u++;
    }
    z=1<<u;
    if(z)
    sum=sum+(1/z);
    //cout<<sum<<"\n";
  }
  sum=sum*((1/n));
  cout<<fixed<<setprecision(12)<<sum;
  //cout<<"\n";
  //cout<<z;
  //cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 int i,n,b,c=0,a=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&b);
  if(b%2==0){
    c++;
    if(b%3==0||b%5==0){a++;}
  }
  }
  puts(c==a?"APPROVED":"DENIED");              
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n; cin >> n;

    ll sum = 0;

    vector<ll> t(n);
    for (ll i = 0; i < n; ++i) {
        cin >> t[i];
        sum += t[i];
    }

    ll m; cin >> m;
    for (ll i = 0; i < m; ++i) {
        ll p, x; cin >> p >> x;

        cout << sum - (t[p-1] - x) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,M;
	cin >> N;
	multiset<int> S;
	for(int i =0; i < N; i++) {
		int a;
		cin >> a;
		S.insert(a);
	}
	cin >> M;
	for(int i =0; i < M; i++) {
		int a;
		cin >> a;
		auto it =S.find(a);
		if(it == end(S)) {
			cout << "NO\n";
			return 0;
		}
		S.erase(it);
	}
	cout << "YES\n";
	return 0;}

// look at my code
// my code is amazing


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

void maketree(int p, vector<unordered_set<int>> &tree){ //子から親の番号を消して木を完成
  if (tree.at(p).empty()) return;
  for (auto i: tree.at(p)){
    tree.at(i).erase(p);
    maketree(i,tree);
  }
}

void treeplus(int p, int x, vector<unordered_set<int>> &tree, vector<int> &op, vector<int> &counter){
  x+=op.at(p);
  counter.at(p)+=x;
  if (tree.at(p).empty()) return;
  else for (auto i: tree.at(p)) treeplus(i,x,tree,op,counter);
}

int main(){
  int n,q;
  cin>> n >> q;
  int a,b;
  vector<unordered_set<int>> tree(n);
  for (int i=0; i<n-1; i++){ //向きがわからないのでとりあえず双方に入力
    cin>> a >> b;
    tree.at(a-1).insert(b-1);
    tree.at(b-1).insert(a-1);
  }
  vector<int> op(n);
  for (int i=0; i<q; i++){
    cin>> a >> b;
    op.at(a-1)+=b;
  }
  
  maketree(0,tree);
    
  vector<int> counter(n);
  treeplus(0,0,tree,op,counter);
  
  for (int i=0; i<n; i++){
    cout<< counter.at(i);
    if (i==n-1) cout<<endl;
    else cout<<" ";
  }
}

Measured memory_bytes: 52352
#include<bits/stdc++.h>
#define mod 1000000007
#define rep(i,n,f) for (int i = n; i < f; i++)
#define rap(i,n,f) for (int i = n; i > f; i--)
#define inf 1e9+9

using namespace std;

const int maxn = 1e5 + 10;

vector <int> adj[maxn];
vector <int> topo;
int a,b,n,l,ans,d[maxn],dp[maxn];
bool marked[maxn];

void dfs(int f){
	marked[f] = true;
	for(int u : adj[f]){
		if(!marked[u]){
			dfs(u);
		}
	}
	topo.push_back(f);
}

int main(){
	cin >> n >> l;
	rep(i,0,l){
		cin >> a >> b;
		a --;
		b --;
		adj[a].push_back(b);
	}
	rep(i,0,n){
		if(!marked[i]){
			dfs(i);
		}
	}
	rep(i,0,n){
		for(int u : adj[topo[i]]){
			ans = max(ans , dp[u] + 1);
		}
		dp[topo[i]] = ans;
		ans = 0;
	}
	rep(i,0,n){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}
	



Measured memory_bytes: 8824
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<fstream>
#include<sstream>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define si size()
#define fr front()
#define ba back()
#define tp top()

typedef long long int ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef pair<double,double> pdd;
typedef pair<double,pdd> pddd;

#define CASE() for(int Case=1;Case<=Tc;Case++)
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const int adj[8][2]={{-1,0},{0,-1},{1,0},{0,1},{-1,-1},{-1,1},{1,1},{1,-1}};
const int INF=1e9;
const ll MOD=1e9+7;
const double EPS=1e-9;
const int SIZE=64;

int main (){
	
	int N;
	int a, b, c;
	scanf("%d", &N);
	while(N--){
		scanf("%d %d %d", &a, &b, &c);
		if(((a*a)+(b*b)==(c*c)) || ((c*c)+(b*b)==(a*a)) || ((a*a)+(c*c)==(b*b))) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}	


Measured memory_bytes: 3136
#include <iostream>


using namespace std;


int main()
{
     int N;
     cin >> N;
     int can = 101;
     int acc = 0;

     for (int i = 0; i < N; i++) {
         int t;
         cin >> t;
         acc += t;

         if (t % 10 != 0)
             can = min(can, t);
     }

     if (acc % 10 != 0)
         cout << acc << endl;
     else if (can != 101)
         cout << acc - can << endl;
     else
         cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  
  int a = 0, b = 1;
  string str;
  
  for (int i = 0; i < n; i++, b = 1) {
    
    //青いカードを確かめる
    for (int j = 0; j < n; j++) {
      if (i != j && s.at(i) == s.at(j)) {
        b++;
      }
    }
    
    //赤いカードを確かめる
    for (int k = 0; k < m; k++) {
      if (s.at(i) == t.at(k)) {
        b--;
      }
    }
    
    if (b > a) {
      a = b;
    }
  }
  
  cout << a << endl;
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n / 2){
        if (s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    string suba, subb;
    suba = s.substr(0, (n - 1) / 2);
    subb = s.substr((n + 1) / 2, (n - 1) / 2);
    rep(i, suba.size() / 2){
        if(suba[i] != suba[suba.size() - 1 - i]){
            cout << "No" << endl;
            return 0;

        }
    }
    rep(i, subb.size() / 2){
        if(subb[i] != subb[subb.size() - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep(j,n) for(ll j=0;j<(ll)n;j++)
#define rep(k,n) for(ll k=0;k<(ll)n;k++)
using namespace std;

int main() {
	ll N = 0, M = 0;
	cin >> N >> M;
	vector<ll> ac(N), pena(N);

	rep(i, M) {
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (ac[p] == 1) continue;
		if (s == "AC") {
			ac[p] = 1;
		}
		else  pena[p]++;
	
	}
	int AC = 0, PENA = 0;
	rep(i, N) {
		AC += ac[i];
		if (ac[i] == 1) PENA += pena[i];

	}
	cout << AC << " " << PENA << endl;


	return 0;
}

Measured memory_bytes: 1792
<?php

const N_MAX = 100005;

fscanf(STDIN, "%d %d", $n, $m);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$cards = array_fill(0, N_MAX, 0);
for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $b, $c);
    $cards[$c] += $b;
}

for ($i = 0; $i < $n; ++$i) {
    ++$cards[$A[$i]];
}

krsort($cards);

$sum = 0;
foreach ($cards as $card => $cnt) {
    if ($n <= 0) break;
    if ($cnt === 0) continue;

    $tmp = min($n, $cnt);

    $sum += $tmp * $card;
    $n -= $tmp;
}

echo $sum;


Measured memory_bytes: 30196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPredictionAndRestriction solver = new DPredictionAndRestriction();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPredictionAndRestriction {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            int[] points = in.readIntArray(3); // r s p
            char[] tInput = in.next().toCharArray();
            int[] t = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = "rsp".indexOf(tInput[i]);
                t[i] = (t[i] + 2) % 3;
            }

            long answer = 0;
            for (int i = 0; i < n; i++) {
                if (i - k >= 0 && t[i - k] == t[i])
                    t[i] = -1;

                if (t[i] >= 0)
                    answer += points[t[i]];
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



Measured memory_bytes: 28628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;


bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}
struct type{
    int k, i, j;
};
signed main() 
{
    fastio;
    set<int> s;
    int n;
    cin>>n;
    f(i,n)
    {
        int x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    
    
}


Measured memory_bytes: 9600
def main():
    h,w,k=map(int,input().split())
    grid=[input() for _ in [0]*h]
    ans=[[0]*w for _ in [0]*h]
    berry=0
    for i in range(h):
        if "#" in grid[i]:
            cnt=0
            berry+=1
            for j in range(w):
                if grid[i][j]=="#":
                    cnt+=1
                    if cnt>1:
                        berry+=1
                ans[i][j]=berry
    for i in range(1,h):
        if ans[i][0]==0:
            for j in range(w):
                ans[i][j]=ans[i-1][j]
    for i in range(h-2,-1,-1):
        if ans[i][0]==0:
            for j in range(w):
                ans[i][j]=ans[i+1][j]         
    for i in ans:
        print(*i)
main()

Measured memory_bytes: 47196
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  cin>>A;
  ll mx=0;
  for(auto &I:A){mx=max(mx,I);}
  ll cnt=0;
  for(auto &I:A){
    if(mx-I>1){cout<<"No"<<endl; return 0;}
    if(mx==I){cnt++;}
  }
  if(mx==N-1 && cnt==N){cout<<"Yes"<<endl; return 0;}
  if(mx==1 && cnt==N){cout<<"Yes"<<endl; return 0;}
  ll one=N-cnt;
  if(cnt/2+one<mx || one+1>mx){cout<<"No"<<endl; return 0;}
  cout<<"Yes"<<endl;


  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main() {
	long long n;

	std::cin >> n;

	std::vector<long long> v(n);

	long long sum = 0;
	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
		sum += v[i];
	}

	long long left = 0;
	long long min = sum;

	for (long long i = 0; i < n; i++)
	{
		left += v[i];
		min = std::min(std::abs(left - (sum - left)), min);
	}

	std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
long long int a,b,c,x,y;
scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
long long int minn=min(x,y);
long long int sum=0;
if(a+b>c*2)
{
    sum=sum+(c*2*minn);
    if(x>y)
    {
        if(2*c<a)
             sum=sum+2*c*abs(x-y);
        else
             sum=sum+a*abs(x-y);
    }
    else
    {

                if(2*c<b)
             sum=sum+2*c*abs(x-y);
        else
             sum=sum+b*abs(x-y);
    }

}
else
{
    sum=sum+a*x+b*y;
}
printf("%lld",sum);

return 0;
}


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

int main(){
    int k;
    cin >> k;
    int r=0;
    int cnt=0;
    if (k%2==0 || k%5==0){
        cnt = -1;
    }
    else{
        while (cnt<k) {
            cnt+=1;
            r = (10*r + 7) % k;
            if (r==0) break;
        }
        if (r != 0) cnt = -1;
    }
    cout << cnt;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long int N,M,ans=0;
    cin >> N >> M;
    ans = min(N,M/2);
    if(ans == N) {
        M -= N*2;
        ans += M/4;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string w, t;
    cin >> w;
    int ans = 0;

    while(1){
        cin >> t;
        if(t == "END_OF_TEXT") break;
        for(int i = 0; i < t.size(); i++){
            if('A' <= t[i] && t[i] <= 'Z') t[i] += 32;
        }
        if(w == t) ans++;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = new int[2]{int.Parse(str[0]),int.Parse(str[1])};
		}
		Array.Sort(A,(x,y)=>(x[0]+x[1])-(y[0]+y[1]));
		int a = -1000000007;
		int ans = N;
		for(var i=0;i<N;i++){
			if(A[i][0]-A[i][1] < a){
				ans--;
			} else {
				a = Math.Max(a,A[i][0]+A[i][1]);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 23876
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

int n ,dist[128];
bool rel[128][128];

int main() {
	scanf("%d", &n);
	
	for(int i = 1; i <= n; i++){
		int u, k;
		scanf("%d %d", &u, &k);
		
		dist[u] = INT_MAX;
		for(int j = 1; j <= n; j++){
			rel[u][j] = false;
		}
		while(k--){
			int v;
			scanf("%d", &v);
			rel[u][v] = true;
		}
	}
	
	queue<int> visit;
	visit.push(1);
	dist[1] = 0;
	
	while(visit.size()){
		for(int i = 1; i <= n; i++){
			if(rel[visit.front()][i] && 1 + dist[visit.front()] < dist[i]){
				visit.push(i);
				dist[i] = 1 + dist[visit.front()];
			}
		}
		visit.pop();
	}
	
	for(int i = 1; i <= n; i++){
		printf("%d %d\n", i, dist[i]==INT_MAX ? -1 : dist[i]);
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int M=2e3+10;
int a[M][M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			scanf("%d",&a[i][j]);
		}
		a[i][0]=1;
	}
	int num=n*(n-1)/2;
	int flag1=0;
	int ans=0;
	int i=0;
	while(1){
		ans++;
		int flag2=0;
		int used[M]={0};
		for(int j=1;j<=n;j++){
			long long k=a[j][0];
			if(!used[j]&&k!=n){
				long long t1=a[j][k];
				long long k2=a[t1][0];
				long long t2=a[t1][k2];
				if(t2==j&&!used[t1]){
					a[t1][0]++;
					a[j][0]++;
					used[t1]=1;
					used[j]=1;
					flag2=1;
					i++;
				}
			}
		}
		if(!flag2){
			flag1=1;
			break;
		}
		if(i==num){
			break;
		}
	}
	if(!flag1){
		printf("%d\n",ans);
	}else{
		printf("-1\n");
	}
}


Measured memory_bytes: 8448
N,M = map(int, input().split())
cnt = 0
# corner
if N == M == 1:
    cnt += 1
if N == 1 and M >= 3:
    cnt += M-2
if N >= 3 and M == 1:
    cnt += N-2
if N >= 3 and M>= 3:
    cnt +=(N-2)*(M-2)
print(cnt)

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

using namespace std;

#define INF 210000000
#define int long long

signed main() {
		int h,w;
		cin >> h >> w;
		int n;
		cin >> n;
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		vector<vector<int>> ans;
		int cnt = 0;
		int color_cnt = a[0];
		int color = 1;
		for(int i=0;i<h;i++){
				vector<int> tmp;
				for(int j=0;j<w;j++){
						auto begin = tmp.begin();
						if(i % 2 == 0){
								tmp.push_back(color);
						}else{
								tmp.insert(begin,color);
						}
						cnt++;
						if(cnt >= color_cnt){
								color_cnt += a[color];
								color++;
						}
				}
				ans.push_back(tmp);
		}
		for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
						cout << ans[i][j];
						cout << ' ';
				}
				cout << "\n";
		}
}


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

long inf = 1000000007;


int main() {
	long n, a, b; cin >> n >> b >> a;
	long count = 0;
	long t = n / (a + b);
	long l = n % (a + b);
	count += t * b;
	if (l >= b) {
		cout << count + b << endl;
	 }
	else {
		cout << count + l << endl;
	}

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, s, t, c, p[100000], lw[100000];
vector<int>v[100000], res;
bool vis[100000];

void dfs(int x,int from) {
	vis[x] = true;
	lw[x] = p[x] = c;
	int a = 0, b = c;
	++c;
	bool f = false;
	for (int i : v[x]) {
		if (!vis[i]) {
			dfs(i, x);
			lw[x] = min(lw[x], lw[i]);
			if (lw[i] >= b)f = true;
			++a;
		}
		else if (i != from) {
			lw[x] = min(lw[x], p[i]);
		}
	}
	if (x == 0) {
		if (a >= 2) {
			res.push_back(x);
		}
	}
	else if (f&&a >= 1) {
		res.push_back(x);
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> s >> t;
		v[s].push_back(t);
		v[t].push_back(s);
	}
	c = 1;
	dfs(0, -1);
	sort(res.begin(), res.end());
	for (int i : res) {
		cout << i << endl;
	}
}


Measured memory_bytes: 7024
a,b,c=map(int,input().split())
list=[]
ans=0
list.append(a)
list.append(b)
list.append(c)
for i in range(3):
    if list[i]==5:
        ans+=1
    elif list[i]==7:
        ans+=10
print("YES" if ans==12 else "NO")

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

#define lop(n) for(int i=0; i<n; i++)
#define loop(j,n) for(int i=j; i<n; i++)

typedef long long ll;

using namespace std;

int main()
{
    int a,b;
    cin>> a >> b;
    cout<< a*b << " " << 2*(a+b) << endl;

    return 0;
}



Measured memory_bytes: 3096
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-29 21:06:24
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans;
    for (int i = x; i < 2*x; i++) {
        int notok = 0;
        for (int j = 2; j < sqrt(x); j++) {
            if (i % j == 0) notok = 1;
        }

        if (notok) {
            ;
        } else {
            ans = i;
            break;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = 3.1415926535897932;
using namespace std;
int main(){
    int a,b,x;
    scanf("%d%d%d",&a,&b,&x);
    double ans;
    if (2*x <= a*a*b){
        ans = 180/PI*atan(((double)a*b*b)/(2*(double)x));
    }
    else{
        //printf("??");
        x = a*a*b - x;
        ans = 180/PI*atan((2*(double)x)/((double)a*a*a));
    }
    printf("%.8f",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> d(K);
    vector<vector<int>> A;
    
    int a;
    rep(i,K){
        cin>>d.at(i);
vector<int> tmp;
        rep(j,d.at(i)){
            cin>>a;
            tmp.push_back(a);
        }
        A.push_back(tmp);
    }
    set<int> s;//お菓子持ってる奴だけ格納
    rep(i,K){
        rep(j,d[i]){
            s.insert(A.at(i).at(j));
        }
    }
    cout << N-s.size() << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int pre[3], dp[3], N;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		swap(dp, pre);
		for (int j = 0; j < 3; j++) {
			int v;
			cin >> v;
			dp[j] = 0;
			for (int k = 0; k < 3; k++) {
				if (j != k) {
					dp[j] = max(dp[j], pre[k] + v);
				}
			}
		}
	}
	
	cout << *max_element(dp, dp + 3) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,ans=1;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2==0) ans *= 2;
    }
    cout << pow(3,n)-ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>
#include <queue>

using namespace std;

const int N = 2e5 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

#define int ll

void solve() {
	string s;
	cin >> s;
	if (s[2] == s[3] and s[4] == s[5])
		cout << "Yes";
	else
		cout << "No";
}


signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
	char s[81];
	int i,j,n=0;
	while(scanf("%s",s)!=EOF){
		for(i=0;s[i]!='\0';i++){
			if('0'<=s[i]&&s[i]<='9'){
				n+=atoi(s+i);
				for(j=i+1;;j++){
					if('0'<=s[j]&&s[j]<='9')i++;
					else break;
				}
			}
		}
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, l[1000], i;
    cin >> n;
    l[0]=2;l[1]=1;
    for(i=2;i<=n;i++){
        l[i]=l[i-1]+l[i-2];
    }
    cout << l[n] <<endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;
const double pi = 3.14159265358979;
int main() {
    double r; cin >> r;
    cout << fixed << setprecision(15);
    cout << 2 * pi * r << endl;
    return 0;
}

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

int H, W;
vector<string> s(55);

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

void solve() {
	bool ok = true;
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
		if (s[i][j] == '.') continue;
		bool sub_ok = false;
		for (int k = 0; k < 4; k++) {
			int y = i + dy[k];
			int x = j + dx[k];
			if (y < 0 || y >= H || x < 0 || x >= W) continue;
			if (s[y][x] == '#') sub_ok = true;
		}
		if (!sub_ok) ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) cin >> s[i];
	solve();

	return 0;
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;

int main()
{
int n,f=1;
cin>>n;
if(n%4==0||n%7==0)
{
cout<<"Yes";
return 0;	
}

while(n>=0)
{
	n=n-7;
	if(n>=4&&n%4==0)
	{
		cout<<"Yes";
		return 0;
	}
}
if(f) cout<<"No";
return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

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

func main() {
	var N, K, D int64
	fmt.Scan(&N)
	fmt.Scan(&K)
	fmt.Scan(&D)
	N = abs(N)
	if abs(K*D) <= N {
		fmt.Println(N - abs(K*D))
	} else if D > N {
		if K%2 == 0 {
			fmt.Println(N)
		} else {
			fmt.Println(D - N)
		}
	} else {
		num := N / D
		if (K-num)%2 == 0 {
			fmt.Println(N % D)
		} else {
			fmt.Println(D - (N % D))
		}
	}
}

func abs(n int64) int64 {
	if n < 0 {
		n = -n
	}
	return n
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> H(N);
  REP(i, N) H[i] = nextInt();
  int ans = 0;
  REP(i, N) {
    bool ok = true;
    REP(j, i) if (H[j] > H[i]) ok = false;
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    long long n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    n/=2;
    while(n>0){
        ans+=(n/5);
        n/=5;
    }
    cout << ans << endl;
}

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

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

    ll ans = 0, k = 1;
    while(k < B) {
        k += A - 1;
        ans++;
    }

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

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

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

    string S = "";
    while (N != 0){
        if (N % 2 == 0){
            S = "0" + S;
        } else{
            --N;
            S = "1" + S;
        }
        N /= -2;
    }

    if (S.size() == 0) cout << "0" << endl;
    else cout << S << endl;
}

Measured memory_bytes: 256
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof(x))
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int M4 = 1e4+10, M5 = 1e5+10, M6 = 1e6+10;

int ans, f[M5*2];

int main()
{_
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
    {
        int l, r;   cin >> l >> r;
        f[l]++, f[r+1] --;
    }
    int t = 0;
    for(int i = 1; i <= n; i++)
        t += f[i], ans += (t == m);
    cout << ans;
	return 0;
}


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

const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x] += 1;
  }
  int ex = 0;
  for (auto &i : mp) {
    if (i.second > 1)
      ex += i.second - 1;
  }
  if (ex % 2 == 0) {
    cout << (int)mp.size() << endl;
  } else {
    cout << (int)mp.size() - 1 << endl;
  }
  return 0;
}


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

int main(void)
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (U == S) {
        A --;
    }
    else {
        B --;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256