akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =1e5+100;
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll Max =-1,x,flag =1;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&x);
            Max =max(Max,x);
            if(x<Max&&Max-x>1)
                flag =0;
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main()
{
  int n,i,adj[N+1][N+1],j,u,k,v,l,flag = 0,m;

  scanf("%d",&n);

  for(i = 0; i <= n; i++){
    for(j = 0; j <= n; j++){
      adj[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      adj[u][v] = 1;
    }
  }

  for(i = 1; i <= n; i++){      /*表示*/
    for(j = 1; j <= n; j++){
      if(j > 1)printf(" ");
      printf("%d",adj[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  double L;
  cin>>L;
  double ll=L/3;
  cout<<fixed<<setprecision(10)<<ll*ll*ll<<endl;
}

Measured memory_bytes: 256
n = int(input())
meshi = [0] * 100
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(len(a)):
    ans += b[a[i]-1]
    if(i != 0 and a[i-1] + 1 == a[i]):
        ans += c[a[i-1]-1]


print(ans)

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int x,y;
    cin >> x >> y;
    int count = 0;
    VI a(4,0);
    a[1] = 300000;
    a[2] = 200000;
    a[3] = 100000;

    if(x<=3 && x>=1) {
        count += a[x];
    }

    if(y<=3 && y>=1) {
        count += a[y];
    }

    if(x==1 && y==1) {
        count += 400000;
    }

    cout << count << endl;
 
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
A,B = LI()
S = S()
ans = 1
for i in range(A+B+1):
    if i==A:
        if S[i]!='-':
            ans = 0
            break
    else:
        if not S[i] in '1234567890':
            ans = 0
            break
print(['No','Yes'][ans])


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


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

	for(int n, s; cin >> n >> s, n | s;) {
		vector<int> r(n);
		for(int i = 0; i < n; ++i)
			cin >> r[i];

		int ans = 0;
		for(int i = 0; i < n; ++i)
			for(int j = i + 1; j < n; ++j)
				if(i != j && r[i] + r[j] > s)
					++ans;

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
    }
    println!("{}", (a + b) % 24);
}


Measured memory_bytes: 4352
N = gets.to_i
A = Array.new(100001, 0)
sum = 0
line = gets.split(' ').map(&:to_i)

line.each do |num|
    A[num] += 1
    sum += num
end

Q = gets.to_i
q_line = []

Q.times do
    q_line = gets.chomp.split(' ').map(&:to_i)
    B = q_line[0]
    C = q_line[1]
    b = A[B].to_i
    A[B] = 0
    sum += b * (C - B)
    A[C] += b
    puts sum
end


Measured memory_bytes: 41908
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int t = a[m - 1];
	int sum = accumulate(a.begin(), a.end(), 0);
	cout << (t * 4 * m < sum ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	string s;
	cin >> s;
	for (int i = 0; i < num; i++)s.push_back(s[num - 1 - i]);
	char mini = 'z';
	for (int i = 0; i < s.size(); i++)mini = min(mini, s[i]);
	string ans;
	ans.push_back('z' + 1);
	if (kai == 1)
	{
		for (int i = 0; i <= num; i++)
		{
			string z;
			for (int j = 0; j < num; j++)z.push_back(s[i + j]);
			ans = min(ans, z);
		}
		cout << ans << endl;
		return 0;
	}
	for (int p = num; p <= num + num; p++)
	{
		int x = 0;
		for (int i = p - 1; i >= 0; i--)
		{
			if (s[i] == mini)x++;
			else break;
		}
		if (x == 0)continue;
		int xx = x;
		for (int i = 0; i < kai - 1; i++)
		{
			if (x == num)break;
			x = min(x * 2, num);
		}
		string z;
		for (int i = 0; i < x; i++)z.push_back(mini);
		for (int i = 0; i < num - x; i++)z.push_back(s[p - xx - i - 1]);
		ans = min(ans, z);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def insertion_sort(Array,num):
    for i in range(1,num):
        v=Array[i]
        j=i-1
        while(j>=0 and Array[j]>v):
            Array[j+1]=Array[j]
            j-=1
        Array[j+1]=v
        print(*A)

n=int(input())
A=[int(i) for i in input().split()]
print(*A)
insertion_sort(A,n)




Measured memory_bytes: 5980
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int r = 0;
    int b = 0;
    for(int i = 0;i < n;i++){
      if(s.charAt(i)=='R')r++;
      else b++;
    }
    if(r>b)System.out.println("Yes");
    else System.out.println("No");
  }
}

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

int main() {
  int N, K, ans = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (ans >= K) {
      ans += K;
    }
    else {
      ans *= 2;
    }
  }
  cout << ans;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    for(ll i=K; i<N; i++){
        if(A[i] > A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 2e9 + 20
int const MaxSize = 50 + 10;
int N, P, A[MaxSize];

LL ways[MaxSize][2];

int main() {
	ios_base::sync_with_stdio(false);
//	freopen("/Users/george/A_1.in", "r", stdin);

	cin >> N >> P;

	LP(i, 0, N)
		cin >> A[i];

	if (A[0] % 2) {
		ways[0][1] = 1;
		ways[0][0] = 1;
	} else {
		ways[0][0] = 2;
		ways[0][1] = 0;
	}

	LP(i, 1, N)
	{

		if (A[i] % 2) {
			ways[i][1] = ways[i - 1][1] + ways[i - 1][0];
			ways[i][0] = ways[i - 1][0] + ways[i - 1][1];
		} else {
			ways[i][1] = ways[i - 1][1] + ways[i - 1][1];
			ways[i][0] = ways[i - 1][0] + ways[i - 1][0];
		}
	}

	cout << ways[N - 1][P] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  D, N ;
  cin >> D >> N; 
     if(N == 100 && D == 2)
  cout << 1010000 << endl; 
     else if(N == 100)
  cout << pow (100, D) * 101 << endl;
     else
  cout << pow (100, D) * N << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(NULL);
ios::sync_with_stdio(false);
 string a,b,c;
 cin>>a>>b>>c;
 a[0]-=32;
 b[0]-=32;
 c[0]-=32;
 cout<<a[0]<<b[0]<<c[0]<<"\n";









 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int h1, m1, h2, m2, K; 
  cin >> h1 >> m1 >> h2 >> m2 >> K;

  int x = h1*60+m1;
  int y = h2*60+m2;

  cout << y-x-K << "\n";

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  b = b / x;
  if(a != 0) a = (a - 1) / x;
  else a--;
  cout << b - a << endl;

  return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int N, M;
   cin >> N >> M;
   vector<ll> A(N);
   for (auto &a : A)
   {
      cin >> a;
   }
   std::sort(A.begin(), A.end());
   ll Amax = A[N - 1];
   ll Amin = A[0];
   map<ll, ll> CH;
   ll b, c;
   for (int i = 0; i < M; i++)
   {
      cin >> b >> c;
      if (Amin < c)
      {
         if (CH[c] == -1)
         {
            CH[c] = b;
         }
         else
         {
            CH[c] += b;
         }
      }
   }
   ll count = 0, j;
   int64_t ans = 0;
   if (CH.size() != 0)
   {
      for (auto i = CH.rbegin(); i != CH.rend(); ++i)
      {
         for (j = count; j < count + i->second && j < N; j++)
         {
            if (A[j] >= i->first)
            {
               break;
            }
         }
         if (j - count == 0)
         {
            break;
         }
         ans += i->first * (j - count);
         count += j - count;
      }
   }
   for (int i = count; i < N; i++)
      ans += A[i];
   std::cout << ans << endl;
}

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


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define MOD (1000000007)
#define int long
struct segment_tree {
  segment_tree *left, *right;
  int from, to, value;
  segment_tree(int from, int to)
    : from(from), to(to), left(NULL), right(NULL), value(0) { }
};
segment_tree* build(const vector<int> &arr, int l, int r) {
  if (l > r) return NULL;
  segment_tree *res = new segment_tree(l, r);
  if (l == r) {
    res->value = arr[l];
  } else {
    int m = (l + r) / 2;
    res->left = build(arr, l, m);
    res->right = build(arr, m + 1, r);
    if (res->left != NULL) res->value += res->left->value;
    if (res->right != NULL) res->value += res->right->value;
  }
  return res;
}
int query(segment_tree *tree, int l, int r) {
  if (tree == NULL) return 0;
  if (l <= tree->from && tree->to <= r) return (tree->value)%MOD;
  if (tree->to < l) return 0;
  if (r < tree->from) return 0;
  return (query(tree->left, l, r)%MOD + query(tree->right, l, r)%MOD)%MOD;
}
int update(segment_tree *tree, int i, int val) {
  if (tree == NULL) return 0;
  if (tree->to < i) return tree->value;
  if (i < tree->from) return tree->value;
  if (tree->from == tree->to && tree->from == i) {
    tree->value = val;
  } else {
    tree->value = update(tree->left, i, val) + update(tree->right, i, val);
  }
  return tree->value;
}

main(){
  int n,m;
  cin>>n>>m;
  vector<int> s(n),t(m),v(2001,0);
  for(auto& i:s)cin>>i;
  for(int i=0;i<m;++i)cin>>t[i];
  segment_tree *root = build(v,0,2000);
  for(int siz=1;siz<=n;++siz){
    map<int,int> mup;
    for(int i=0;i<m;++i)if(s[siz-1]==t[i])mup[i]=((1+query(root,i,i))%MOD+(!i?0:query(root,0,i-1)%MOD))%MOD;
    for(auto p:mup)update(root,p.first,p.second%MOD);
  }
  cout<<(query(root,0,2000)+1)%MOD;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1

int gcd(int a, int b){
    if(a == b) return a;
    int temp1 = max(a, b);
    int temp2 = min(a, b);

    while(temp2 != 0){
        int temp = temp2;
        temp2 = temp1%temp2;
        temp1 = temp;
    }
    return temp1;
}

int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int k; cin >> k;
ll ans = 0;


for(int i = 1; i <= k; i++){
    for(int j = 1; j <= k; j++){
        for(int l = 1; l <= k; l++){
            int temp = gcd(i, j);
            ans += gcd(temp, l);
        }
    }
}
cout << ans;

}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n, m; cin>>n>>m;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin>>h[i];
    vector<vector<int>> G(n);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        bool valid = true;
        for(auto j:G[i]){
            if(h[j] >= h[i]) valid = false;
        }

        if(valid) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<long int> ticket;
    for (int i = 0; i < N; i++) {
        long int a;
        cin >> a;
        ticket.push(a);
    }
    for (int i = 0; i < M; i++) {
        long int x;
        x = ticket.top();
        ticket.pop();
        ticket.push(x/2);
    }
    long int ans = 0;
    while (!ticket.empty()){
        long int x;
        x = ticket.top();
        ticket.pop();
        ans += x;
    }
    cout << ans << "\n";
    
}

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


int main(){
    int x[5];
    rep(i,5) cin >>x[i];
    rep(i,5){
        if(x[i] == 0){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<double> ave(N);
  for(int i=0; i<N; i++){
    double p;
    cin >> p;
    ave.at(i)=(1+p)/2;
  }
  vector<double> dp(N+1);
  dp.at(0)=0;
  for(int i=1; i<N+1; i++){
    dp.at(i)=dp.at(i-1)+ave.at(i-1);
  }
  double ans=0;
  for(int i=0; i<N-K+1; i++){
    ans=max(dp.at(i+K)-dp.at(i),ans);
  }
  
  std::cout << std::setprecision(16) << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
double ans = 0;
double pi=3.1415926535897932;


struct point {
    double x,y,val;
    point() {}
    point(double x, double y, double val) : x(x), y(y), val(val) {};
    point(double x, double y) : x(x), y(y), val(0) {};
};
struct vec {
    double x ,y ;
    vec() {}
    vec(double x, double y) : x(x), y(y)  {};
    vec(point a, point b) : x(b.x-a.x), y(b.y-a.y)  {};
    double size(){return sqrt(x*x+y*y);};
};
bool cmp(const point &a, const point &b)
{
  return a.val < b.val;
}
//ベクトルabとベクトルbcにおけるbcに対して時計回りの角cba
double arg(vec a,vec b){
  if(a.x*b.y-a.y*b.x>0)return acos((-a.x*b.x-a.y*b.y)/(a.size()*b.size()))*(-180)/pi +360;
  else return acos((-a.x*b.x-a.y*b.y)/(a.size()*b.size()))*180/pi;
}
int main()
{
ll n ;
cin >> n ;
vector<point> v;
rep(i,n){
  double x , y ;
  cin >> x >> y ;
  if(x==0&&y==0)v.emplace_back(x,y,0);
  else v.emplace_back(x,y,arg(vec(-1,0),vec(x,y)));
}
auto mod = [&](ll modx){modx%=n;modx+=n;modx%=n;return modx;};
sort(v.begin(),v.end(),cmp);
rep(i,n)rep(j,n)
{
  double x=0,y=0;
  for (ll k = i; k < j+i+1; k++)
  {
    x+=v[mod(k)].x;
    y+=v[mod(k)].y;
  }
  ans=max(ans,sqrt(x*x+y*y));
}

cout<<fixed<<setprecision(13)<<ans<<endl;

return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int k;
  cin >> k;
  k--;
  int arr[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << arr[k] << ln;

  return 0;
}

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

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

    int odd_counter=0;

    for (int i=0; i < N ; i++){
        if (A[i]%2 == 1) odd_counter++;
    }

    if( odd_counter%2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
mod = 1000000007


def fexp(x, y):
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = ans * x % mod
        x = x * x % mod
        y //= 2
    return ans


fac = [1]
rev = [1]

for i in range(1, 2006):
    fac.append(fac[-1] * i % mod)
    rev.append(fexp(fac[-1], mod - 2))


def C(n, k):
    if n < k:
        return 0
    return fac[n] * rev[k] % mod * rev[n - k] % mod


def distribute(n, m):
    return C(n - 1, m - 1)


n = int(input())
if n < 3:
    print(0)
else:
    ans = 0
    parts = 1
    while n - parts * 2 >= 0:
        rest = n - parts * 2
        ans += distribute(rest, parts)
        ans %= mod
        parts += 1
    print(ans)


Measured memory_bytes: 9324
def FindParent(X):
    if Parent[X]==X:
        return X
    else:
        Parent[X] = FindParent(Parent[X])
        return Parent[X]

def UniteParent(X,Y):
    X = FindParent(X)
    Y = FindParent(Y)
    if X==Y:
        return 0
    if Rank[X]<Rank[Y]:
        Parent[X] = Y
    else:
        Parent[Y] = X
        if Rank[X]==Rank[Y]:
            Rank[X] += 1

import copy
N,M = (int(T) for T in input().split())
List = [[] for TM in range(0,M)]
for TM in range(0,M):
    List[TM] = [int(T) for T in input().split()]
    
Count = 0
for TM in range(0,M):
    ListCopy = copy.deepcopy(List)
    del ListCopy[TM]
    
    Parent = [I for I in range(N+1)]
    Rank = [0]*(N+1)
    for TTM in range(0,M-1):
        UniteParent(ListCopy[TTM][0],ListCopy[TTM][1])
    for TN in range(1,N+1):
        FindParent(TN)
    if len(set(Parent[1:]))>1:
        Count += 1
print(Count)

Measured memory_bytes: 9316
using System;
class Program
{
    static void Main(string[] args)
    {
        // 文字列の入力
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);

        //結果（各面での勝率を足しこむ用）
        double per = 0;

        for (int i = 1; i < (N + 1); i++)
        {
            int x = i;
            int cnt = 0;
            //iを何回2倍すればK以上になるか？
            while (x < K)
            {
                x = x * 2;
                cnt++;
            }

            //サイコロの出た目がiのとき、得点がK以上になる確率
            // (1/N) * ((1/2)^cnt)がやりたい けどできるだけ誤差を減らしたい？
            double omotePer = Math.Pow(2, cnt);
            double bunbo = (double)N * omotePer;
            per += (1 / bunbo);
        }

        //出力
        Console.WriteLine(per);
    }
}

Measured memory_bytes: 11092
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int n;
  cin >> n;
  vector<pl> a(n, {0, 0});
  rep(i, n)
  {
    ll temp;
    cin >> temp;
    a[i] = {temp, i};
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  vector<vl> dp(n + 1, vl(n + 1, 0)); //dp[i][j] 左からi番目と右からj番目まで並べたときの嬉しさの合計の最大
  ll result = 0;
  rep(i, n + 1)
  {
    rep(j, n + 1)
    {
      if(i + j == n) {
        result = max(result , dp[i][j]);
        break;
      }
      int index = i + j;
      //左側に追加
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + abs(a[index].second - i) * a[index].first);
      //右側に追加
      dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + abs(a[index].second - (n - 1 - j)) * a[index].first);
    }
  }
  cout << result << endl;
}


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

int main() {
  int n;
  int d1, d2;
  cin >> n;

  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> d1 >> d2;
    if (d1 == d2)
    {
      count++;
      if (count == 3) {
        break;
      }
    }
    else
    {
      count = 0;
    }
  }
  
  if (count == 3) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3636
object Main {
    def step(s: String, cmd: Array[String]) = cmd(0) match {
        case "print" => {println(s.slice(cmd(1).toInt, cmd(2).toInt+1)); s}
        case "reverse" => s.take(cmd(1).toInt) + s.slice(cmd(1).toInt, cmd(2).toInt+1).reverse +s.drop(cmd(2).toInt+1)
        case "replace" => s.take(cmd(1).toInt) + cmd(3) +s.drop(cmd(2).toInt+1)
    }
    def main(args: Array[String]): Unit = {
        val in = io.Source.stdin.getLines
        val s = in.next
        in.next
        in.map(_.split(" ")).foldLeft(s)(step)
    }
}

Measured memory_bytes: 45164
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,i,k=20; 
 	cin>>n;
    while(!(n&(1<<k))) k--;
    printf("%d %d\n", k+1, 2*k+__builtin_popcount(n)-1);
    for(i=0; i<k; i++){
      printf("%d %d %d\n", i+1, i+2, 0);
      printf("%d %d %d\n", i+1, i+2, 1<<i);
    }
    int a=1<<k;
    for(i=k-1; i>=0; i--){
      if((1<<i)&n){
        printf("%d %d %d\n", i+1, k+1, a);
        a+=1<<i;
      }
    }
}

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

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int A,B,C,D;
int n [3001][3001];
int mb [3001][3001];
int mr [3001][3001];

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> A >> B >> C >> D;

    // Base Case
    n[A][B] = 1; mb[A][B] = 0; mr[A][B] = 0;
    int ta = B, tb = B-1, tc = 1;
    FOR(i,A+1,C+1) {
        mb[i][B] = 0;
        n[i][B] = add(tb, mul(i-A,tc));
        mr[i][B] = add(ta+MOD, -n[i][B]);
        ta = mul(ta, B);
        tb = mul(tb, B-1);
        tc = mul(tc, B-1);
    }
    ta = A; tb = A-1; tc = 1;
    FOR(i,B+1,D+1) {
        mr[A][i] = 0;
        n[A][i] = add(tb, mul(i-B,tc));
        mb[A][i] = add(ta+MOD, -n[A][i]);
        ta = mul(ta, A);
        tb = mul(tb, A-1);
        tc = mul(tc, A-1);
    }

    // DP Step
    FOR(i,A+1,C+1) {
        FOR(j,B+1,D+1) {
            mb[i][j] = add(add(mul(mb[i][j-1], i), n[i][j-1]), mr[i][j-1]);
            mr[i][j] = add(add(mul(mr[i-1][j], j), n[i-1][j]), mb[i-1][j]);
            n[i][j] = add(mul(n[i-1][j],j-1), mul(mb[i-1][j],j-1));
        }
    }

    // F0R(i,C+1) {
    //     F0R(j,D+1) {
    //         cout << 
    //     }
    // }
    cout << add(add(n[C][D], mb[C][D]), mr[C][D]);
    // mb[i][j] = mb[i][j-1] * i + n[i][j-1] + mr[i][j-1];
    // mr[i][j] = mr[i-1][j] * j + n[i-1][j] + mb[i-1][j];
}

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

class Dice
{
  private:
    int top, front, right, left, back, bottom, temp;

  public:
    void set(int *nums)
    {
        this->top = nums[0];
        this->front = nums[1];
        this->right = nums[2];
        this->left = nums[3];
        this->back = nums[4];
        this->bottom = nums[5];
    }
    int getTop() { return this->top; }
    int getFront() { return this->front; }
    int getRight() { return this->right; }
    int getLeft() { return this->left; }
    int getBack() { return this->back; }
    int getBottom() { return this->bottom; }
    void east()
    {
        this->temp = this->top;
        this->top = this->left;
        this->left = this->bottom;
        this->bottom = this->right;
        this->right = this->temp;
    }
    void west()
    {
        this->temp = this->top;
        this->top = this->right;
        this->right = this->bottom;
        this->bottom = this->left;
        this->left = this->temp;
    }
    void north()
    {
        this->temp = this->top;
        this->top = this->front;
        this->front = this->bottom;
        this->bottom = this->back;
        this->back = this->temp;
    }
    void south()
    {
        this->temp = this->top;
        this->top = this->back;
        this->back = this->bottom;
        this->bottom = this->front;
        this->front = this->temp;
    }
};

void alignRollOfDice(Dice &dice, int top, int front)
{
    if (dice.getTop() == top && dice.getFront() == front)
    {
        return;
    }
    else
    {
        if (dice.getRight() != front && dice.getLeft() != front)
        {
            while (dice.getFront() != front)
            {
                dice.south();
            }
        }
        else
        {
            if (dice.getRight() == front)
            {
                dice.west();
                dice.south();
            }
            else
            {
                dice.east();
                dice.south();
            }
        }

        if (dice.getTop() != top)
        {
            while (dice.getTop() != top)
            {
                dice.east();
            }
        }

        return;
    }
}

int main(int argc, char *argv[])
{
    Dice firstDice, secondDice;
    int nums[6];
    for (int i = 0; i < 6; i++)
        cin >> nums[i];
    firstDice.set(nums);
    for (int i = 0; i < 6; i++)
        cin >> nums[i];
    secondDice.set(nums);

    alignRollOfDice(secondDice, firstDice.getTop(), firstDice.getFront());

    if (firstDice.getTop() != secondDice.getTop()) { cout << "No" << endl; return 0; }
    if (firstDice.getFront() != secondDice.getFront()) { cout << "No" << endl; return 0; }
    if (firstDice.getRight() != secondDice.getRight()) { cout << "No" << endl; return 0; }
    if (firstDice.getLeft() != secondDice.getLeft()) { cout << "No" << endl; return 0; }
    if (firstDice.getBack() != secondDice.getBack()) { cout << "No" << endl; return 0; }
    if (firstDice.getBottom() != secondDice.getBottom()) { cout << "No" << endl; return 0; }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3132
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc.Split(bufio.ScanWords)
	var buf = make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	s := next()
	q := nextInt()

	l := list.New()
	l.PushFront(s)

	d := 1
	for i := 0; i < q; i++ {
		t := nextInt()

		switch t {
		case 1:
			d *= -1
		case 2:
			f := nextInt()
			c := next()

			if d == -1 {
				if f == 1 {
					f = 2
				} else {
					f = 1
				}
			}

			if f == 1 {
				l.PushFront(c)
			} else {
				l.PushBack(c)
			}
		}
	}

	ss := make([]string, l.Len())
	i := 0
	for e := l.Front(); e != nil; e = e.Next() {
		ss[i] = e.Value.(string)
		i++
	}

	ans := strings.Join(ss, "")
	if d == -1 {
		ans = reverse(ans)
	}

	fmt.Println(ans)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var sc = bufio.NewScanner(os.Stdin)

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

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


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
long long a[110000];
map<long long,bool>sheep;
int cat;
long long go(string s,int kai,int xin){
    int i,j,k;
    long long res=0;
    for(i=kai;i<=xin;i++)
        res=res*100+(s[i]-'a'+1);
    for(i=xin-kai+2;i<=5;i++)     
        res*=100;
    return res;
}
int main()
{   int n,m,i,j,k;
    string s;
    cin>>s;
    n=s.length();
    cin>>k;
    for(i=0;i<n;i++)
        for(j=i;j<=min(i+k,n-1);j++){
            long long res=go(s,i,j);
            if(!sheep[res]){
                a[++cat]=res;
                sheep[res]=1;
            }
        }
    sort(a+1,a+cat+1);
    char c[110];
    cat=0;
    while(a[k]>0){
        if(a[k]%100)c[++cat]=(a[k]%100-1)+'a';
        a[k]/=100;
    }
    for(i=cat;i>0;i--)
        cout<<c[i];
    return 0;
}

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

typedef long long ll;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll flp = 0, rf = 0, i, upsolving;
	string s;
	cin >> s;
	for (i = s.size() - 1; i >= 0; i--)  {
		if (s[i] == 'W')
			rf++;
		else
			flp += rf;
	}
	cout << flp << endl;
	return 0;
}

Measured memory_bytes: 720
import numpy as np
n = int(input())
a=list(map(int,input().split()))
ma=len(bin(max(a)))-2
b=np.array(a)
mod=10**9+7
ans=0
for i in range(ma):
  one=np.count_nonzero((b&1)==1)
  zero=n-one
  ans+=(one*zero*(2**i))%mod
  b=b//2
print(ans%mod)

Measured memory_bytes: 48844
#define INF 48828125+100
#include<cstdio>
#include<cstring>

int pow[]={1,5,25,125,625,3125,15615,78125,390625,1953125,9765625};
bool hash[INF];

int HASH(char s[])
{
	int h(0);
	for(int i=strlen(s)-1;i>=0;--i)
	{
		if(s[i]=='A')
			h+=1*pow[i];
		if(s[i]=='C')
			h+=2*pow[i];
		if(s[i]=='G')
			h+=3*pow[i];
		if(s[i]=='T')
			h+=4*pow[i];
	}
	return h;
}
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;++i)
	{
		char oper[7],data[13];
		scanf("%s%s",oper,data);
		if(oper[0]=='i')
			hash[HASH(data)]=true;
		else
			hash[HASH(data)] ? printf("yes\n") : printf("no\n");
	}
	return 0;
}
			

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

int main(){

    int w;

    cin >> w;

    string s;

    int count=0;

    do{
      if(w/3 == 0 && w%3 == 0){
        break;
      }
      switch(w%3){
        case 0:
          s = '0' + s;
          w = w/3;
          break;
        case 1:
          s = '+' + s;
          w = w/3;
          break;
        case 2:
          s = '-' + s;
          w = 1 + w/3;
          break;
      }

    }while(1);

    cout << s << endl;

    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	
	int r=n%10;
	
	if(r==2||r==4||r==5||r==7||r==9)
	  cout<<"hon\n";
	else if(r==3)
	  cout<<"bon\n";
	else
	  cout<<"pon\n";
	  return 0;
}

Measured memory_bytes: 3672
n, a, b = map(int, input().split())

if a > b:
    print(0)
elif a==b:
    print(1)
elif n == 1 and a!=b:
    print(0)
else:
    minS = b + (n-1)*a
    maxS = a + (n-1)*b

    print(maxS - minS+1)

Measured memory_bytes: 3064
'''input
8 10
'''
import math

a, b = input().split()
a = int(a)
b = int(b)

a_low = math.ceil((a + 0.000) / 0.08)
a_hig = math.floor((a + 0.999) / 0.08)

b_low = math.ceil((b + 0.000) / 0.1)
b_hig = math.floor((b + 0.999) / 0.1)

if b_low <= a_low and a_low <= b_hig:
    print(a_low)
    exit()

if a_low <= b_low and b_low <= a_hig:
    print(b_low)
    exit()

print(-1)

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

signed main(void)
{
	int n, m;
	cin >> n >> m;
	bool g[n], h[n];
	bool ok;

	rep(i, n) {g[i] = false; h[i] = false;}
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		if (a == 0)
			g[b] = true;
		else if (b == n - 1)
			h[a] = true;
	}
	ok = false;
	FOR(i, 1, n - 1)
	{
		if (g[i] && h[i])
			ok = true;
	}
	if (ok)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, a, b, c, d;

signed main(){
	cin >> a >> b >> c >> d;
	if(c - a == 0){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
    return 0;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll k, a, b;
	cin >> k;
	cin >> a >> b;



	if ( ((b / k) * k) >= a ) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}

	return 0;
}


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

int main(){
  int n;
  long long a;
  long long max = -1000000;
  long long min = 1000000;
  long long sum = 0;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> a;
    if(a<min)min=a;
    if(a>max)max=a;
    sum += a;
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}

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

double x[5], y[5];

bool check() {
  double xa[3], ya[3], s[3];
  bool in[2], b[3];
  for (int i=0; i<3; i++) {
    xa[i] = y[(i+1)%3] - y[i];
    ya[i] = -x[(i+1)%3] + x[i];
    s[i] = xa[i]*x[i] + ya[i]*y[i];
  }
  for (int i=0; i<2; i++) {
    for (int j=0; j<3; j++) {
      b[j] = (xa[j]*x[i+3] + ya[j]*y[i+3] < s[j]);
    }
    in[i] = (b[0] == b[1] && b[1] == b[2]);
  }
  return (in[0] != in[1]);
}

int main() {
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    for (int j=0; j<5; j++) {
      cin >> x[j] >> y[j];
    }
    if (check()) {
      cout << "OK" << endl;
    } else {
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define INF 10000000000
using namespace std;

int main()
{
  long long N, a;
  cin >> N;
  long long ans = 1;
  vector<long long> cnt(3, 0);
  for (long long i = 0; i < N; ++i)
  {
    cin >> a;
    long long temp = 0;
    bool first_time = true;
    for (long long j = 0; j < 3; ++j)
    {
      if (cnt.at(j) == a)
      {
        temp += 1;
        if (first_time)
        {
          first_time = false;
          cnt.at(j) = a + 1;
        }
      }
    }
    ans = (ans * temp) % 1000000007;
  }
  cout << ans % 1000000007 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string W[N];
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
    }
    map<string, int> mp;
    mp[W[0]]++;
    for (int i = 0; i < N - 1; i++)
    {
        if (mp[W[i + 1]] == 0 && W[i][W[i].size() - 1] == W[i + 1][0])
        {
            mp[W[i]]++;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

class Point
{
public:
	int X,Y;
	Point(int x, int y) :X(x), Y(y) {};
};

using vec = vector<Point>;

int main()
{
	while (true)
	{
		int N; cin >> N;
		if (N == 0)return 0;
		vec PosList;
		PosList.reserve(201);
		PosList.emplace_back(0, 0);
		Point maxP(0, 0);
		Point minP(0, 0);

		for (int i = 1; i < N; ++i)
		{
			int n, d;
			cin >> n >> d;

			if (d == 0)
			{
				minP.X = (minP.X < PosList[n].X - 1) ? minP.X : (PosList[n].X - 1);
				PosList.emplace_back(PosList[n].X - 1, PosList[n].Y);
			}
			else if (d == 1)
			{				
				minP.Y = (minP.Y < PosList[n].Y - 1) ? minP.Y : (PosList[n].Y - 1);
				PosList.emplace_back(PosList[n].X, PosList[n].Y - 1);
			}
			else if (d == 2)
			{
				maxP.X = (maxP.X > PosList[n].X + 1) ? maxP.X : (PosList[n].X + 1);
				PosList.emplace_back(PosList[n].X + 1, PosList[n].Y);
			}
			else if (d == 3)
			{
				maxP.Y = (maxP.Y > PosList[n].Y + 1) ? maxP.Y : (PosList[n].Y + 1);
				PosList.emplace_back(PosList[n].X, PosList[n].Y + 1);
			}
		}

		cout << maxP.X - minP.X + 1 << " " << maxP.Y - minP.Y + 1 << endl;
	}
}


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

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

  int ans = 0;
  int a = stoi(s);

  for (int i=0; i<s.size(); i++) {
    ans += a % 10;
    a /= 10;
  }

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

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

vector<int> l;

int main() {
    int n;
    cin >> n;
    l.resize(n);
    rep(i, n) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    long sum = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            int k = j + 1;
            int left = l[j] - l[i];
            int right = l[i] + l[j];
            // sum += lower_bound(l.begin()+j+1, l.end(), l[i]+l[j]) - upper_bound(l.begin()+j+1, l.end(), l[j]-l[i]);
            // left < a[i] < right を満たすa[i]の個数は、
            // right未満のa[i]の個数 - left以下のa[i]の個数に等しい
            sum += lower_bound(l.begin() + k, l.end(), right) - upper_bound(l.begin() + k, l.end(), left);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		sc.close();
		double c = 3.305785;
		double ans = a * b / c;
		System.out.println(ans);
	}
}


Measured memory_bytes: 27984
#include <stdio.h>

int main(){
  int n;
  int a=0,b=0,ab=0,o=0;
  char bloodtype[3];
  while(scanf("%d,%s",&n,bloodtype) !=EOF){
    if(bloodtype[0]=='A' && bloodtype[1]=='B')
      ab++;
    else if(bloodtype[0]=='A')
      a++;
    else if(bloodtype[0]=='B')
      b++;
    else if(bloodtype[0]=='O')
      o++;
  }
 
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);

  return 0; 
}

Measured memory_bytes: 1780
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}



int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	rep(N) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	vector<int>A(N, -1);
	int c = 0;
	rep(N) {
		if (i != 0) {
			if (S[i - 1] == S[i]) {
				if (A[i - 1] == -1) {
					A[i - 1] = 2;
					A[i] = 0;
					c = i - 1;
				}
				else {
					A[c]++;
					A[i] = 0;
					
				}
			}
		}
	}
	int a = -1;
	rep(N) {
		a = max(a, A[i]);
	}
	rep(N) {
		if (a == A[i])
			cout << S[i] << endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  vector<int> r(R);
  REP(i,R)cin>>r[i];

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

  vector<vector<ll>> d(N+1, vector<ll>(N+1,INF));

  REP(i,M){
    int a,b,c;
    cin >> a >> b >> c;
    d[a][b]=c;
    d[b][a]=c;
  }
  FOR(k,1,N+1)FOR(i,1,N+1)FOR(j,1,N+1){
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }


  ll ans=INF;
  do{
    ll t=0;
    REP(i,r.size()-1){
      t+=d[r[i]][r[i+1]];
    }
    ans = min(t,ans);

  }while(next_permutation(ALL(r)));

  cout << ans << endl;

}



Measured memory_bytes: 512
#include <cassert>
#include<iostream>
#include <cctype>

using namespace std;

#if 0

08-182020の方のものを参照。termの書き換えがわからなかった。

#endif

string S;
size_t cur = 0; // 解析開始位置cursor の略記

// 1 文字読んでcur を進める
// 意味:次のreadchar では、次の文字を読む
char readchar() {
	assert(cur < S.size());
	char ret = S[cur];
	cur += 1;
	return ret;
	// return S[cur++]; と一行で書くこともできる
}
char peek() { // 1 文字読むがcur を進めない
	assert(cur < S.size());
	return S[cur];
}


int factorial(int n) {
	assert(n > 0); // (*)
	if (n == 1) return 1;
	return n * factorial(n-1);
}

int digit() {
	//assert(isdigit(peek())); // S[cur] が数字であることを確認
	int n = readchar() - '0'; // ’0’ を0 に変換
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(peek())) // 次も数字か1 文字先読
		n = n*10 + digit();
	return n;
}
int expression(); // 前方宣言
int factor() {
	if (peek() != '(') return number();
	cur += 1;
	int n = expression();
	assert(peek() == ')');
	cur += 1;
	return n;
}

int term() {
	int a = factor();
	while (cur < S.size()&& (peek() == '*' || peek() == '/')) {
		char op = readchar();
		int b = factor();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}

int expression() {
	int a = term();
	while ((cur < S.size())&& (peek() == '+' || peek() == '-')) {
		char op = readchar();
		int b = term();
		if (op == '+') a += b; else a -= b;
	}
	return a;
}



int parse(){
	return expression();
}

int main() {
	//int a = parse();
	//cout << a << endl;
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1); // 最後の=を無視
		cout << expression() << endl;
	}
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll r, d, y;
    cin >> r >> d >> y;
    for (int i = 0; i < 10; ++i) {
        y = r*y-d;
        cout << y << "\n";
    }
    return 0;
}

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

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

    int a, b, t;
    cin >> a >> b >> t;
    
    int ans = (t/a) * b;
    
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256