akhauriyash/Code-Regression huggingface dataset:
///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   █▀█─█──█──█▀█─█─█
///   █▄█─█──█──█▄█─█▄█
///   █─█─█▄─█▄─█─█─█─█

///   كُلُّ نَفْسٍ ذَآئِقَةُ الْمَوْت
///   Every soul shall taste death.

/// TODO::

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

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;


#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(0);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)
//***********************************************  The END **********************************************************************************************************************************
using ll = long long;
const ll N = 1e5 + 1;
const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main()
{

  MOHAMMAD

  ll n;
  cin >> n;
  string s;
  map < string , ll > mp;
  while(n--){
       cin >> s;
       mp[s]++;
  }

  cout << "AC x " << mp["AC"]<<"\n";
  cout << "WA x " << mp["WA"]<<"\n";
  cout << "TLE x " << mp["TLE"]<<"\n";
  cout << "RE x "<<mp["RE"]<<"\n";

}


/*





  Alhamdulillah
*/



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

using namespace std;

typedef long long LL;

int main()
{
    string s;
    cin >> s;
    bool flag = true;
    for(int i = 0; i < s.size(); i++)
        if(i & 1)
        {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') flag = false;
        }
        else
        {
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') flag = false;
        }

    if(flag) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 256
N =int(input())
A =[int(i)for i in input().split()]
wa = sum(A)//2
foo = 0
for i in range(N//2):
    foo += A[i*2]
foo = wa- foo
ans = []
foo = A[-1] -foo
for i in A:
    ans.append(str(foo*2))
    foo = i -foo
print(" ".join(ans))

Measured memory_bytes: 17228
#include <bits/stdc++.h>
#include <iostream>
#define ll long long

using namespace std;

bool doneNode[100001];

int ans[100001];
pair<int, int> hen[100001];
unordered_set<int> used_color[100001];
vector<int> node_line[100001];

int colorNumber;

void search(int nodeIndex) {
  if (doneNode[nodeIndex]) {
    return;
  }
  doneNode[nodeIndex] = true;

  // vector<int> queue;
  int next_color = 1;
  for (int lineIndex : node_line[nodeIndex]) {
    if (ans[lineIndex]) {
      continue;
    }

    int f = hen[lineIndex].first;
    int s = hen[lineIndex].second;

    while (true) {
      if ((used_color[f].find(next_color) != used_color[f].end())) {
        next_color++;
      } else if ((used_color[s].find(next_color) != used_color[s].end())) {
        next_color++;
      } else {
        break;
      }
    }
    ans[lineIndex] = next_color;
    colorNumber = max(colorNumber, next_color);

    used_color[f].insert(next_color);
    used_color[s].insert(next_color);

    if (!doneNode[f]) {
      search(f);
      // queue.emplace_back(f);
    }
    if (!doneNode[s]) {
      search(s);
      // queue.emplace_back(s);
    }
  }

  // for (int i = 0; i < queue.size(); i++) {
  //   search(queue[i]);
  // }
}

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

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);

    hen[i] = make_pair(a - 1, b - 1);

    node_line[a - 1].emplace_back(i);
    node_line[b - 1].emplace_back(i);
  }

  search(0);

  cout << colorNumber << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 23552
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[100000]={NULL};
    int n;

    scanf("%s", s);
    n = strlen(s)-1;

    while(1){
        if(s[n-5]=='e'&&s[n-4]=='r'&&s[n-3]=='a'&&s[n-2]=='s'&&s[n-1]=='e'&&s[n]=='r'){
            n-=6;
        }else if(s[n-4]=='e'&&s[n-3]=='r'&&s[n-2]=='a'&&s[n-1]=='s'&&s[n]=='e'){
            n-=5;
        }else if(s[n-6]=='d'&&s[n-5]=='r'&&s[n-4]=='e'&&s[n-3]=='a'&&s[n-2]=='m'&&s[n-1]=='e'&&s[n]=='r'){
            n-=7;
        }else if(s[n-4]=='d'&&s[n-3]=='r'&&s[n-2]=='e'&&s[n-1]=='a'&&s[n]=='m'){
            n-=5;
        }else{
            printf("NO");
            return 0;
        }
        if(n==-1)break;
    }
    printf("YES");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c,&d)
	
	train := Min(a,b)
	bus := Min(c,d)
	
	fmt.Println(train + bus)
}

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

int main()
  
{
  long long n;
  cin>>n;
  if(n==0)
  {
    cout<<0<<endl;
  }
  else
  {
    cout<< (1000-n%1000)%1000<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

struct dice {
  int label[7];
};

struct dice *make_dice(int *num) {
  int i;
  struct dice *dice1;
  dice1 = (struct dice *)malloc(sizeof(struct dice));
  for(i = 1;i <= 6;i++) {
    dice1->label[i] = num[i];
  }
  return dice1;
}

void turnS(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[5];
  a->label[5] = a->label[6];
  a->label[6] = a->label[2];
  a->label[2] = temp;
}

void turnW(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[3];
  a->label[3] = a->label[6];
  a->label[6] = a->label[4];
  a->label[4] = temp;
}

void turnN(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[2];
  a->label[2] = a->label[6];
  a->label[6] = a->label[5];
  a->label[5] = temp;
}

void turnE(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[4];
  a->label[4] = a->label[6];
  a->label[6] = a->label[3];
  a->label[3] = temp;
}

int main() {
  int i,c,num[7];
  struct dice *dice1;
  for(i = 1;i <= 6;i++) {
    scanf("%d", num+i);
  }
  dice1 = make_dice(num);
  while((c = getchar()) != EOF) {
    switch (c) {
    case 'S':
      turnS(dice1);
      break;
    case 'W':
      turnW(dice1);
      break;
    case 'N':
      turnN(dice1);
      break;
    case 'E':
      turnE(dice1);
      break;
    default:
      break;
    }
  }
  printf("%d\n",dice1->label[1]);

  return 0;
}

Measured memory_bytes: 600
n = int(input())

a = list(map(int, input().split()))


ans = [0] * 8
hi_rate = 0

for i in range(n):
    buf = int(a[i]/400)
    if buf <= 7:
        ans[buf] += 1
    else:
        hi_rate += 1

low_rate = 0
for i in range(8):
    if ans[i] > 0:
        low_rate += 1

if low_rate == 0:
    minm = 1
    maxm = hi_rate
else:
    minm = low_rate
    maxm = low_rate + hi_rate

#if maxm > 8:
#    maxm = 8

print(str(minm) + ' ' + str(maxm))

Measured memory_bytes: 3064
from typing import List
from collections import deque

def bfs(G: List[int], s: int) -> None:
	d[s] = 0
	color[s] = "GRAY"
	Q = deque()
	Q.append(s)
	while Q:
		u = Q.popleft()
		for v in G[u]:
			if color[v] == "WHITE":
				color[v] = "GRAY"
				d[v] = d[u] + 1
				pi[v] = u
				Q.append(v)
		color[u] = "BLACK"


if __name__ == "__main__":
	n = int(input())
	G = [[] for _ in range(n)]
	for _ in range(n):
		u, k, *adj = list(map(int, input().split()))
		u -= 1
		G[u] = [v - 1 for v in adj]
	color = ["WHITE" for _ in range(n)]
	d = [-1 for _ in range(n)]
	pi = [None for _ in range(n)]
	bfs(G, 0)
	for i in range(n):
		print(f"{i + 1} {d[i]}")


Measured memory_bytes: 7244
/**
 * Created by karayuu on 2018/07/03
 */
fun main(args: Array<String>) {
    var (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val dislikeNums = readLine()!!.split(" ")
    var n_s = n.toString().map { it.toString() }

    /* .none{}で指定された要素を含まないとき(.filter{}.isEmpty()と同じ)にtrueを返す */
    /* whileはtrueの間ループを回すので、含まなくなった->falseにするために真偽値を反転 */
    while (!n_s.none { dislikeNums.contains(it) }) {
        n++
        n_s = n.toString().map { it.toString() }
    }

    print(n)

}

Measured memory_bytes: 40560
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin >> h >> w;
    char s[h][w];
    for(int i = 0; i<h;i++){
        for(int k = 0; k <w; k++){
            cin >> s[i][k];
        }
    }
    
    int yoko[h][w];
    int tate[h][w];
    for(int i = 0; i<h;i++){
        for(int k = 0; k <w; k++){
            yoko[i][k] = 0;
            tate[i][k] = 0;
        }
    }
    
    for(int i = 0; i<h; i++){
        int counter = 0;
        int start = 0;
        for(int k = 0; k<w; k++){
            if(s[i][k] == '.'){
                counter += 1;
                if (k == w-1){
                    for(int j = start; j<=k;j++){
                        yoko[i][j] = counter;
                    }
                }
            }
            else{
                for(int j = start; j<k; j++){
                    yoko[i][j] = counter;
                }
                start = k+1;
                counter = 0;
            }
        }
    }
    
    for(int i = 0; i<w; i++){
        int counter = 0;
        int start = 0;
        for(int k = 0; k<h; k++){
            if(s[k][i] == '.'){
                counter += 1;
                if (k == h-1){
                    for(int j = start; j<=k;j++){
                        tate[j][i] = counter;
                    }
                }
            }
            else{
                for(int j = start; j<k; j++){
                    tate[j][i] = counter;
                }
                start = k+1;
                counter = 0;
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i<h; i++){
        for(int k = 0; k<w; k++){
            if(yoko[i][k] != 0 && tate[i][k] != 0){
                if(yoko[i][k] + tate[i][k] -1 > ans){
                    ans = yoko[i][k] + tate[i][k] -1;
                }
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  cin >> n;

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

  vector<ll> lf(3*n), rg(3*n);
  priority_queue<int, vector<int>, greater<int>> l;
  ll sum = 0;
  for(int i = 0; i < 2*n; ++i) {
    sum += a[i];
    l.push(a[i]);
    if(l.size() > n) {
      auto f = l.top();
      sum -= f;
      l.pop();
    }
    lf[i] = sum;
  }

  sum = 0;  
  priority_queue<int> r;
  for(int i = 3*n-1; i >= n; --i) {
    sum += a[i];
    r.push(a[i]);
    if(r.size() > n) {
      auto f = r.top();
      sum -= f;
      r.pop();
    }
    rg[i] = sum;
  }

  ll ans = -1e18;
  for(int i = n-1; i < 2*n; ++i)
    ans = max(ans, lf[i]-rg[i+1]);

  cout << ans << endl;
}

Measured memory_bytes: 7288
def resolve():
    def countis(inputlist):
        ret = 0
        lenlist = len(inputlist)
        for i in range (lenlist-1):
            if inputlist[i] != 0 and inputlist[i+1] == 0:
               ret += 1
        return ret
    n = int(input())
    h = list(map(int, input().split()))
    h.append(0)
    ans = 0
    while True:
        if sum(h) == 0:
            print(ans)
            exit()
        else:
            ans += countis(h)
            h = list(map(lambda x: x-1, h))
            for j in range(len(h)):
                if h[j] <0 :
                    h[j] =0
resolve()

Measured memory_bytes: 3064
N=int(input());K=int(input());X=int(input());Y=int(input())
s=0
if N >= K:
  for i in range(1,K+1):
    s+=X
  for i in range(K+1,N+1):
    s+=Y
else:
  for i in range(1,N+1):
    s+=X
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }

   long long dp[n+1];
   for(int i=0;i<n;i++){
    dp[i]=1000000001;
   }

dp[0]=0;
for(int i=0;i<n-1;i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
    if(i+2<n)dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
}
cout<<dp[n-1];

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll t[2],a[2],b[2];
	rep(i,2)cin>>t[i];
	rep(i,2)cin>>a[i];
	rep(i,2)cin>>b[i];


	ll x = (a[0]-b[0])*t[0];
	ll y = (a[1]-b[1])*t[1];

		// cout<<x<<" "<<y<<endl;
	if(x>0)x*=-1,y*=-1;
	if(x+y<0){
		cout<<0<<endl;
	}else if(x+y==0){
		cout<<"infinity"<<endl;
	}else{
		cout<<(-x)/(x+y)*2+(-x%(x+y)==0?0:1)<<endl;
	}

	return 0;
}

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

using namespace std;
typedef pair<int, int> P;

int n, u, v, m;
int a[505][505], b[505][505];
bool vala[1000005], valb[1000005];
P reva[1000005], revb[1000005];
bool useda[505][505], usedb[505][505];
int rowa[505], rowb[505], cola[505], colb[505];
int diaga, diagb, cdiaga, cdiagb;

int main(void)
{
	cin >> n >> u >> v >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> a[i][j];
			reva[a[i][j]] = make_pair(i, j);
			vala[a[i][j]] = true;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> b[i][j];
			revb[b[i][j]] = make_pair(i, j);
			valb[b[i][j]] = true;
		}
	}
	
	int x;
	for(int q = 0; q < m; q++){
		cin >> x;
		//cout << x << endl;
		
		bool wina = false, winb = false;
		if(vala[x]){
			int i = reva[x].first, j = reva[x].second;
			useda[i][j] = true;
			rowa[i]++, cola[j]++;
			if(i == j) diaga++;
			if(i+j == n+1) cdiaga++;
			int cnt = 0;
			for(int k = 1; k <= n; k++){
				if(rowa[k] >= n) cnt++;
				if(cola[k] >= n) cnt++;
			}
			if(diaga >= n) cnt++;
			if(cdiaga >= n) cnt++;
			if(n == 1) cnt = min(cnt, 1);
			wina = (cnt >= u);
		}
		if(valb[x]){
			int i = revb[x].first, j = revb[x].second;
			usedb[i][j] = true;
			rowb[i]++, colb[j]++;
			if(i == j) diagb++;
			if(i+j == n+1) cdiagb++;
			int cnt = 0;
			for(int k = 1; k <= n; k++){
				if(rowb[k] >= n) cnt++;
				if(colb[k] >= n) cnt++;
			}
			if(diagb >= n) cnt++;
			if(cdiagb >= n) cnt++;
			if(n == 1) cnt = min(cnt, 1);
			winb = (cnt >= v);
		}
		
		if(wina && !winb){
			cout << "USAGI" << endl;
			return 0;
		}
		if(!wina && winb){
			cout << "NEKO" << endl;
			return 0;
		}
		if(wina && winb){
			cout << "DRAW" << endl;
			return 0;
		}
	}
	cout << "DRAW" << endl;
	
	return 0;
}


Measured memory_bytes: 22564
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MOD = 1000000007;

using Graph = vector<vector<pair<ll, ll>>>;
using Pi = pair<ll, ll>;

//準備...Graph g;
//入力...g[Node].push_back(make_pair(nextNode, weight));

vector<ll> djkstra(Graph &g, ll s) {
	vector<ll> dist(g.size(), MOD);
	dist[s] = 0;
	priority_queue<Pi, vector<Pi>, greater<Pi>> que;
	que.emplace(dist[s], s);
	while ( !que.empty() ) {
		ll cost; ll u; tie(cost, u) = que.top(); que.pop();
		if (dist[u] < cost) continue;
		for (auto &x : g[u]) {
			ll v; ll nc; tie(v, nc) = x;
			if (chmin(dist[v], dist[u] + nc)) que.emplace(dist[v], v);
		}
	}

	return dist;
}

int main(void) {
	int n, x, y;
	cin >> n >> x >> y;

	x--;
	y--;

	Graph g(n);
	rep (i, n - 1) {
		g[i].eb(i + 1, 1);
		g[i + 1].eb(i, 1);
	}
	g[x].eb(y, 1);
	g[y].eb(x, 1);

	vector<vector<ll>> dist(n);
	rep (i, n) {
		dist[i] = djkstra(g, i);
	}

	vector<int> memo(50000000, 0);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			memo[dist[i][j]]++;
		}
	}

	for (int i = 1; i < n; i++) {
		cout << memo[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 227072
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
    llong abs ( llong n ) { return n < 0 ? -n : n; }
}

#define int long long

namespace Rlyeh {

    int N, W;
    int v[110], w[110];
    int dp[110][100100];

    int dfs ( int pos, int left ) {
        if ( ~dp[pos][left] ) return dp[pos][left];
        if ( pos == N ) return 0;
        if ( left-w[pos] < 0 ) {
            return dp[pos][left] = dfs ( pos+1, left );
        }
        else {
            return dp[pos][left] = std::max ( dfs ( pos+1, left ),
                    dfs ( pos+1, left-w[pos] ) + v[pos] );
        }
    }

    signed call_of_Cthulhu( signed datum ) {
        memset ( dp, -1, sizeof(dp));
        read N >> W;

        for ( int i = 0; i < N; i++ ) {
            read w[i] >> v[i];
        }

        echo dfs(0, W) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,k;cin >> n >> k;
    int ary[3];
    rep(i,3) cin >> ary[i];
    string s;
    cin >> s;
    rep(i,n)
    {
        if (s[i]=='r')
        {
            s[i]='2';
        }
        else if (s[i]=='s')
        {
            s[i] = '0';
        }
        else if (s[i]=='p')
        {
            s[i]='1';
        }
    }

    int points[n];
    fill(points, points+n, -1);
    rep(i,n)
    {
        if (i-k<0)
        {
            points[i] = ary[s[i]-'0'];
        }
        else
        {
            if (points[i-k]==-1 || s[i-k]!=s[i])
            {
                points[i] = ary[s[i]-'0'];
            }
        }
    }
    ll ans = 0;
    rep(i,n)
    {
        if (points[i]==-1) continue;
        ans += points[i];
        // cout << points[i] << " ";
    }
    cout << ans << endl;
    
    
}




Measured memory_bytes: 848
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,q,sum=0,num[100009],l,r;
    char a[100009];
    scanf("%d%d%s",&n,&q,a);
    for(int i=1;i<n;i++)
    {
        if(a[i]=='C'&&a[i-1]=='A')
            sum++;
        num[i]=sum;
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",num[r-1]-num[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int n,k,x,y,r,ans;
    scanf("%d %d %d %d",&n,&k,&x,&y);

    if(n>k)
    {ans=(x*k)+((n-k)*y);}
    else if (n<=k)
        ans=n*x;
    printf("%d\n",ans);
}


Measured memory_bytes: 1700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();
		scanner.close();

		if (R < 1200) {
			System.out.println("ABC");
		} else if (1200 <= R && R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(){
    int h = 0,
        w = 0,
        i = 0,
        j = 0;
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0)break;
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    printf("#");
                }
                printf("\n");
            }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1752
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll D;

int main() {
  INCANT;
  cin >> N >> D;
  int cnt=0;
  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    if (pow(x,2)+pow(y,2)<=pow(D,2)) cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3568
# 下，右，上，左，右下，右上，左下，左上
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

H, W = map(int, input().split())
field = []

for i in range(H):
    field.append(list(input()))

for y in range(H):
    for x in range(W):

        if field[y][x] == "#":
            continue

        cnt = 0

        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]

            if ny < 0 or H <= ny or nx < 0 or W <= nx:
                continue

            if field[ny][nx] == "#":
                cnt += 1

        field[y][x] = str(cnt)

for y in range(H):
    print("".join(field[y]))

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
using namespace std;
#define INF 1000000005
int main()
{
int a, b;
std::cin >> a >> b;
if(a % 2 == 1 && b % 2 == 1){
    std::cout << "Yes" <<std::endl;
} else {
    std::cout << "No" << std::endl;
}

return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
char ans[2] = {'+','-'};
int num[4];
int op[3] = {};
void output(void);

int main(){
  REP(i, 4){
      char t;
      cin >> t;
      num[i] = t - '0';
    }
      int sum = 0;
  for(op[0] = 0;op[0] < 2; op[0]++){
      for(op[1] = 0; op[1] < 2; op[1]++){
        for(op[2] = 0; op[2] < 2; op[2]++){
            sum = num[0];
              REP(l,3){
                  if(op[l] == 0) sum += num[l + 1];
                  else sum -= num[l + 1];
               }
               if(sum == 7) break;
            }
            if(sum == 7) break;
        }
        if(sum == 7) break;
    }
    output();
    return 0;
}
void output(void){
    REP(i,3) cout << num[i] << ans[op[i]];
    cout << num[3] << "=7" << endl;
  }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    for (int i = 0; i < N; i++) {
        vec.at(i)--;
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += vec.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,l,pre=0,mn=100000000,res=0;;
    cin>>n>>l;
    for(int i=1;i<=n;i++){
        pre+=(l+i-1);
    }

    for(int i=1;i<=n;i++){
        int eat=l+i-1;
        if(abs(eat)<mn){
            res=pre-eat;
            mn=abs(eat);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int A, B;
  scanf("%d %d", &A, &B);
  long c;
  int po;
  c = (long)A * B;

  if (A < B)
  {
    po = A;
    A = B;
    B = po;
  }
  int d = A % B;
  while (d != 0)
  {
    A = B;
    B = d;
    d = A % B;
  }
  printf("%ld", (long)(c / B));
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> trainLR(N + 1, vector<ll>(N + 1, 0));
    for (int i = 0; i < M; i++)
    {
        ll left, right;
        cin >> left >> right;
        trainLR.at(left).at(right)++;
    }
    vector<vector<ll>> ruisekiTrainLR(N + 1, vector<ll>(N + 1, 0)); //Lを固定した場合のRの累積
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            ruisekiTrainLR.at(i).at(j) = ruisekiTrainLR.at(i).at(j - 1) + trainLR.at(i).at(j);
        }
    }
    for(int i = 0; i < Q; i++)
    {
        ll qLeft, qRight;
        cin >> qLeft >> qRight;
        ll answer = 0;
        for(int i = qLeft; i <= qRight; i++)
        {
            answer += ruisekiTrainLR.at(i).at(qRight) - ruisekiTrainLR.at(i).at(i - 1);
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      StringTokenizer str = new StringTokenizer(sc.nextLine());
      int h = Integer.parseInt(str.nextToken());
      int w = Integer.parseInt(str.nextToken());
      
      int[][] cost = new int[10][10];
      for(int i = 0; i < cost.length; i++){
         str = new StringTokenizer(sc.nextLine());
         for(int j = 0; j < cost[i].length; j++){
            cost[i][j] = Integer.parseInt(str.nextToken());
         }
      }
      
      for(int i = 0; i < cost.length; i++){
         for(int j = 0; j < cost.length; j++){
            for(int k = 0; k < cost.length; k++){
               cost[j][k] = Math.min(cost[j][k], cost[j][i] + cost[i][k]);
            }
         }
      }
      
      long ans = 0;
      for(int i = 0; i < h; i++){
         str = new StringTokenizer(sc.nextLine());
         for(int j = 0; j < w; j++){
            int n = Integer.parseInt(str.nextToken());
            if(n != -1) {
               ans += cost[n][1];
            }
         }
      }
      System.out.println(ans);             
   }
}

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

using namespace std;

typedef long long ll;

ll max (ll x, ll y) {
  return x < y ? y : x;
}

ll myhash(int x, int y)
{
  return x * 1000 + y;
}

int main(void)
{
  int N;
  vector< int > x(100), y(100);
  vector< ll  > h(100);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  ll ansx = -1, ansy = -1, ansh = -1;
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      ll H = -1;
      for (int i = 0; i < N; i++) {
	if (H < 0) {
	  if (h[i] > 0) {
	    H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
	    break;
	  }
	}
      }
      bool ok = true;
      for (int i = 0; i < N; i++) {
	if (max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
	  ok = false;
	}
      }
      if (ok) {
	ansx = cx;
	ansy = cy;
	ansh = H;
      }
    }
  }
  cout << ansx << " " << ansy << " " << ansh << endl;
}


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

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

  vector<int> btn(n);
  for(int i = 0; i < n; ++i) {
    cin >> btn.at(i);
  }

  int num = 0;
  for(int i = 1; i < n; ++i) {
    if(btn.at(num) == 2) {
      cout << i << "\n"; return 0;
    }
    num = btn.at(num) - 1;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3744
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        System.out.println(s.equals(u)?(a-1)+" "+b:a+" "+(b-1));
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
const ll  INF=10000000000000;
using namespace std;
ll optimalStrategyOfGame(ll arr[],int n){
    ll table[n][n];
    for(int gap=0;gap<n;++gap){
        for(int i=0,j=gap;j<n;++i,++j){
            ll x=((i+2)<=j?table[i+2][j]:0);
            ll y=((i+1)<=j-1?table[i+1][j-1]:0);
            ll z=(i<=(j-2)?table[i][j-2]:0);
            table[i][j]=max(arr[i]+min(x,y),arr[j]+min(y,z));

        }
    }
    return table[0][n-1];

}
int main()
{
    IOS;
    int n;cin>>n;
    ll a[n];
    ll sum=0;
    for(int i=0;i<n;i++) {cin>>a[i];sum+=a[i];}
    cout<<2*optimalStrategyOfGame(a,n)-sum;
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long tint;
typedef long double ld;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);
#define dbg cout << "hu" << endl;

const int INF = 50000001;
const int MOD = 1000000007;

int main(){
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		puts("Yes");
	}else puts("No");
}



Measured memory_bytes: 256
class Mansion(val position:Long, population:Long) {
    private var mPopulation: Long = population
    val population: Long
        get() = mPopulation

    fun mergeFrom(other: Mansion): Unit {
        mPopulation += other.mPopulation
    }
}

fun main(args:Array<String>):Unit{
    val maxPopulation = 1L shl 60//最大人口を超える値
    val (n, s) = readLine()!!.split(' ').map(String::toInt)
    val mansions = mutableListOf<Mansion>().apply {
        for (i in 0 until n) {
            val (x, p) = readLine()!!.split(' ').map(String::toLong)
            add(Mansion(x, p))
        }
        add(Mansion(s.toLong(), maxPopulation))
        sortBy(Mansion::position)
    }
    var time = 0L
    while (mansions.size != 1){
        if (mansions.size != 1 && mansions.first().population >= mansions.last().population) {
            time += mansions.last().position - mansions.first().position
            while (mansions.size != 1 && mansions.first().population >= mansions.last().population) {
                mansions.first().mergeFrom(mansions.removeAt(mansions.size - 1))
            }
        }
        if (mansions.size != 1 && mansions.last().population > mansions.first().population) {
            time += mansions.last().position - mansions.first().position
            while (mansions.size != 1 && mansions.last().population > mansions.first().population) {
                mansions.last().mergeFrom(mansions.removeAt(0))
            }
        }
    }
    println(time)
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000000000
const ll mod=1e9+7;

int main()
{
	int nT; nT=1; //cin>>nT;
	while(nT--)
	{
		int n; cin>>n;
		ll a[n][3], dp[n][3]; 
		rep(i,n) rep(j,3) { cin>>a[i][j]; dp[i][j]=-1; }
		rep(i,3) dp[0][i]=a[0][i];
		for(int i=1; i<n; i++)
		rep(j,3)
		{
			if(j-1>=0) dp[i][j]=max(dp[i][j], dp[i-1][j-1]+a[i][j]);
			if(j-2>=0) dp[i][j]=max(dp[i][j], dp[i-1][j-2]+a[i][j]);
			if(j+1<3) dp[i][j]=max(dp[i][j], dp[i-1][j+1]+a[i][j]);
			if(j+2<3) dp[i][j]=max(dp[i][j], dp[i-1][j+2]+a[i][j]);
		}
		ll ans=-1;
		rep(i,3) ans=max(ans, dp[n-1][i]);
		cout<<ans; //cout<<endl;
		//rep(i,n) { rep(j,3) cout<<dp[i][j]<<' '; cout<<endl; }
	}
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>

using ll = long long;

ll count_a(std::string const& S, int i, ll ret, ll cnt_a);
ll look_bc(std::string const& S, int i, ll ret, ll cnt_a);

ll neutral(std::string const& S, int i, ll ret) {
  if (i < S.size()-1) {
    if (S[i] == 'A') {
      return count_a(S, i+1, ret, 1);
    } else {
      return neutral(S, i+1, ret);
    }
  } else {
    return ret;
  }
}

ll count_a(std::string const& S, int i, ll ret, ll cnt_a) {
  if (i < S.size()-1) {
    if (S[i] == 'A') {
      return count_a(S, i+1, ret, cnt_a+1);
    } else if (S[i] == 'B' && S[i+1] == 'C') {
      return look_bc(S, i+2, ret+cnt_a, cnt_a);
    } else {
      return neutral(S, i+1, ret);
    }
  } else {
    return ret;
  }
}

ll look_bc(std::string const& S, int i, ll ret, ll cnt_a) {
  if (i < S.size()-1) {
    if (S[i] == 'A') {
      return count_a(S, i+1, ret, cnt_a+1);
    } else if (S[i] == 'B' && S[i+1] == 'C') {
      return look_bc(S, i+2, ret+cnt_a, cnt_a);
    } else {
      return neutral(S, i+1, ret);
    }
  } else {
    return ret;
  }
}

int main() {
  std::string S;

  std::cin >> S;

  ll ans = neutral(S, 0, 0);

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint x(n);
  rep(i, n) cin >> x[i];
  int l;
  cin >> l;
  vector<vint> far(22, vint(n, -1));
  rep(i, n) {
    int lb = i, ub = n;
    while(lb+1 < ub) {
      int mb = (lb+ub)/2;
      if(x[i]+l >= x[mb]) lb = mb;
      else ub = mb;
    }
    far[0][i] = lb;
    //cout<<i<<" "<<lb<<endl;
  }
  rep(i, 21) {
    rep(j, n) {
      far[i+1][j] = far[i][far[i][j]];
    }
  }
  vint pow2(22);
  pow2[0] = 1;
  rep(i, 21) pow2[i+1] = pow2[i]*2;
  int q;
  cin >> q;
  while(q--) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if(a > b) swap(a, b);
    int ans = 0;
    for(int i = 21; i >= 0; --i) {
      if(far[i][a] < b) {
	ans += pow2[i];
	a = far[i][a];
      }
    }
    cout << ans+1 << endl;
  }

  return 0;
}


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

int main(void){
	double a,b;
	int C;

	scanf("%lf %lf %d", &a, &b, &C);

	double rad = C * M_PI / 180.0;
	double S = a * b * sin(rad) / 2;
	double L = a + b + sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad));
	double h = 2*S/a;

	printf("%lf\n", S);
	printf("%lf\n", L);
	printf("%lf\n", h);

	return 0;
}

Measured memory_bytes: 652
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		while(scan.hasNext()){
			double S_abc, S_pab, S_pac, S_pbc;
			double[] x = new double[3];
			double[] y = new double[3];
			
			for(int i = 0; i < 3; i++){
				x[i] = scan.nextDouble();
				y[i] = scan.nextDouble();
			}
			double xp = scan.nextDouble();
			double yp = scan.nextDouble();

			S_abc = 1.0 / 2.0 * Math.abs(x[0]*y[1] + x[1]*y[2] + x[2]*y[0]
				- y[0]*x[1] - y[1]*x[2] - y[2]*x[0]);
			S_pab = 1.0 / 2.0 * Math.abs(xp*y[0] + x[0]*y[1] +x[1]*yp
				- yp*x[0] - y[0]*x[1] - y[1]*xp);
			S_pac = 1.0 / 2.0 * Math.abs(xp*y[0] + x[0]*y[2] + x[2]*yp
				- yp*x[0] - y[0]*x[2] -y[2]*xp);
			S_pbc = 1.0 / 2.0 * Math.abs(xp*y[1] + x[1]*y[2] + x[2]*yp
				- yp*x[1] - y[1]*x[2] - y[2]*xp);
			if(S_abc == S_pab + S_pac + S_pbc){
				System.out.println("YES");
			} else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 30972
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<ll, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;
    P a[112345];

    a[0] = {0, 0};

    cin >> n;
    REP(i, n)
    {
        cin >> a[i + 1].first;
        a[i + 1].second = i + 1;
    }

    sort(a, a + n + 1);

    ll res[112345];
    fill(res, res + n + 1, 0);

    int i = n;

    int mi = a[i].second;

    while (i > 0)
    {
        mi = min(mi, a[i].second);

        res[mi] += (n - i + 1) * (a[i].first - a[i - 1].first);

        i--;
    }

    for (int i = 1; i <= n; i++)
        cout << res[i] << endl;

    return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    int n; cin >> n;
    int a[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cin >> a[i][j];
    }
    
    vector<mint> dp(1 << n, 0);
    dp[0] = 1;
    for (int S = 0; S < (1 << n); S++) {
        int i = __builtin_popcount(S);
        if (i == n) continue;
        for (int j = 0; j < n; j++) {
            if (a[i][j] && !((S >> j) & 1)) dp[S | (1 << j)] += dp[S];
        }
    }

    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 16640
def inpl(): return [int(i) for i in input().split()]
from collections import defaultdict

A, B, C, D, E, F = inpl()
H = defaultdict(lambda: 0)
H[(0,0)] = 1
x = [(100*A, 0), (100*B, 0), (0, C), (0, D)]
flag = True
while flag:
    flag = False
    for i, j in x:
        for ni,nj in H.copy().keys():
            if i+j+ni+nj <= F and ni+i:
                if (nj+j)/(ni+i) <= E/100:
                    if not H[(i+ni, j+nj)]:
                        H[(i+ni, j+nj)] = 1
                        flag = True
anssw, anss = (100*A, 0)
for k, l in H.keys():
    if not k:
        continue
    if anss/anssw < l/(k+l):
        anssw, anss =k+l, l
print(anssw, anss)

Measured memory_bytes: 5892
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0,0]  for j in range(K+1)]
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i][0]=max((dp[i-a[j]][1]+1)%2,dp[i][0])
            dp[i][1]=max((dp[i-a[j]][0]+1)%2,dp[i][1])
        
if dp[K][0]:
    print("First")
else:
    print("Second")



Measured memory_bytes: 53872
/**
 *   Author:  Wasi Ur Rahman
 *   FROM RMSTU
**/
#include <bits/stdc++.h>
#define ll         			long long
#define boost       		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define min3(a,b,c)    		min(a,min(b,c))
#define min4(a,b,c,d)  		min(d,min3(a,b,c))
#define max3(a,b,c)    		max(a,max(b,c))
#define max4(a,b,c,d)  		max(d,max3(a,b,c))
#define all(v)         		v.begin(),v.end()
#define revall(v)      		v.rbegin(),v.rend()
#define pb             		push_back
#define eb             		emplace_back
#define setbits(x)     		__builtin_popcountll(x)
#define zrobits(x)     		__builtin_ctzll(x)
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define siiii(p,x, y, z)    scanf("%d %d %d %d",&p, &x, &y, &z)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)
#define read                freopen("input.txt","r",stdin)
#define write               freopen("output.txt","w",stdout)
#define println()           cout << endl
#define printi(x)           printf("%d\n")
#define printii(x,y)        printf("%d %d\n")
#define printiii(x,y,z)     printf("%d %d %d\n")
#define printl(x)           printf("%lld\n")
#define printll(x,y)        printf("%lld %lld\n")
#define printlll(x,y,z)     printf("%lld %lld %lld\n") 
using namespace std;
/*************************************
**          A S S E M B L E         **
**************************************/
bool isPrime(ll n){if(n <= 1)return false;for (ll i = 2; i * i < n; i++)if (n % i == 0)return false;return true;}
ll fact(ll n){ll res = 1;for(ll i = n;i>=1;i--)res *= i;return res;}
ll nCr(ll n,ll r){return (fact(n)/(fact(r)*fact(n-r)));}
ll nPr(ll n,ll r){return fact(n)/fact(n-r);}
ll modpow(ll a, ll n, ll mod){ll res=1;while(n>0){if(n&1) res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
const int mod=998244353;
inline int add(int a,int b){if((a+=b)>=mod)a-=mod;return a;}
inline int dec(int a,int b){if((a-=b)<0)a+=mod;return a;}
inline int mult(int a,int b){long long t=1ll*a*b;if(t>=mod)t%=mod;return t;}
inline int power(int a,int b){int out=1;while(b){if(b&1)out=mult(out,a);a=mult(a,a);b>>=1;}return out;}
/*************************************
**  E N D    G A M E   S T A R T S  **
**************************************/
int main(){
	boost;
	int t;
	cin >> t;
	cout << t + pow(t,2) + pow(t,3) << endl;
}


Measured memory_bytes: 4308