akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = Integer.parseInt(br.readLine());

		String[] str = br.readLine().split(" ");
		int[] numList = new int[count];
		for (int i = 0; i < count; i++) {
			numList[i] = Integer.parseInt(str[i]);
		}
		Tool.selectionSort(numList, count);
	}
}

class Tool {
	static void selectionSort(int[] numList, int count) {
		StringBuffer sb = new StringBuffer();
		int flag = 0;
//????????¨????¨???°
		for(int i = 0; i < count - 1; i++){
			int minj = i;
			for(int j = i + 1; j < count; j++){
				if(numList[j] < numList[minj]){//?????§??????????´¢??????
					minj = j;
				}
			}
				if(minj != i){//???????????????
					int temp = numList[i];
					numList[i] = numList[minj];
					numList[minj] = temp;
					flag++;
				}
			}
		sb.append(numList[0]);
		for (int i = 1; i < count; i++) {
			sb.append(" " + numList[i]);
		}
		System.out.println(sb.toString() + "\n" + flag);
	}
}

Measured memory_bytes: 24476
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end

function ftAdd(ft::Array{Int,1},k::Int,x::Int)
	t = k
	n = length(ft)
	while t<=n
		ft[t] = max(ft[t],x)
		t += t&(-t)
	end
	ft
end

function ftMax(ft::Array{Int,1},rr::Int)
	r = rr
	s = -10^9
	while r>0
		s = max(ft[r],s)
		r -= r&(-r)
	end
	s
end

function main()
	p = 998244353
	n = readline() |> parseInt
	a = Tuple{Int,Int}[(0,0) for i in 1:n]
	for i in 1:n
		x,d = readline() |> split |> parseMap
		a[i] = (x,d)
	end
	a = sort(a,by=x->x[1])
	b = Int[a[i][1] for i in 1:n]
	push!(b,10^18)
	dp = zeros(Int,n+1,2)
	dp[n+1,:] = [0,1]
	ft = -10^9*ones(Int,n)
	for i in n:-1:1
		ftAdd(ft,i,a[i][1]+a[i][2])
		j = bsearch(b,a[i][1]+a[i][2])
		x = ftMax(ft,j)
		k = bsearch(b,x)
		ftAdd(ft,i,x)
		dp[i,1] = mod(dp[k+1,1]+dp[k+1,2],p)
		dp[i,2] = mod(dp[i+1,1]+dp[i+1,2],p)
	end
	println(mod(dp[1,1]+dp[1,2],p))
end

main()

Measured memory_bytes: 156972
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	string n;
	cin >> n;
	for(int i=0; i<3; i++){
		if (n[i] == '1') cout << '9';
		else cout << '1';
	}
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=200000+10;
int n,w[N],v[N],W;
ll dp[N];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    int lim=n*1000;
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
    for(int i=1;i<=n;i++){
    	for(int j=lim;j>=v[i];j--){
    		dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    	}
    }
    ll ans=0;
    for(int i=0;i<=lim;i++)if(dp[i]<=W)ans=i;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>

typedef long long ll;
const ll INF = 1ll<<60;

int main(){
	int h, w, k;
	std::cin >> h >> w >> k;
	int dx[4] = {-1, 0, 1, 0};
	int dy[4] = {0, -1, 0 ,1};
	std::pair<int, int> star, goal;
	std::cin >> star.first >> star.second >> goal.first >> goal.second;
	--star.first; --star.second; --goal.first; --goal.second;
	std::vector<std::string> c(h);
	for(int i=0; i<h; i++){
		std::cin >> c[i];
	}

	std::vector<std::vector<ll>> dist(h, std::vector<ll>(w, INF));
	dist[star.first][star.second] = 0;
	std::queue<std::pair<int, int>> q;
	q.push(star);
	while(!q.empty()){
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for(int i=0; i<4; i++){
			for(int j=1; j<=k; j++){
				int nx = x + j * dx[i];
				int ny = y + j * dy[i];
				if(nx<0 || nx>=h || ny<0 || ny>=w) break;
				if(c[nx][ny] == '@' || dist[nx][ny] <= dist[x][y]) break;
				if(dist[nx][ny] == INF){
					dist[nx][ny] = dist[x][y] + 1;
					q.push({nx, ny});
				}
			}
		}
	}

	if(dist[goal.first][goal.second] == INF){
		std::cout << -1 << std::endl;
	}else{
		std::cout << dist[goal.first][goal.second] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 19980
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#pragma warning(disable : 4996)

#define MAX_N 100000+1
#define INF 100000+1

int N;
int C[MAX_N];

int abs(int v) {
	if (v < 0) return -v;
	return v;
}
int min(int a, int b) {
	if (a < b) return a;
	return b;
}

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

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i <= N; ++i) {
		C[i] = i;
	}
	C[0] = 0;
	for (int i = 1; i <= N; ++i) {
		int val = 1;
		while (1) {
			val *= 6;
			if (i - val < 0) break;
			chmin(C[i], 1 + C[i - val]);
		}
		val = 1;
		while (1) {
			val *= 9;
			if (i - val < 0) break;
			chmin(C[i], 1 + C[i - val]);
		}
	}
	printf("%d", C[N]);
	return 0;
}


Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int ans=0;
    string s;
    cin>>s;
    int memo=0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            memo++;
        }
        else{
            memo=0;
        }
        chmax(ans,memo);
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[100],S2[][100] = {"Sunny", "Cloudy", "Rainy"};
ll i, j, k;
int main(){
    scanf("%s", S);
    fornum(i,0,3){
        if(S[0]==S2[i][0]){
            printf("%s", S2[(i + 1) % 3]);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
      ll a, b, c;
      cin >> a >> b >> c;

      ll left = a*b*4;
      ll v = c-a-b;
      ll right = (c-a-b)*(c-a-b);
      if(v > 0 && left < right){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
}     

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort()
ans = 0
index = 0
while index < N:
    bus = T[index] + K
    for i in range(C):
        if index+i < N and T[index+i] > bus:
            i -= 1
            break
    index += i+1
    ans += 1

print(ans)

Measured memory_bytes: 7384
n, k = map(int, input().split())
arr = [0 for _ in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for v in a:
        arr[v-1] += 1
ans = 0
for i in arr:
    if i == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9184
import numpy as np
n, m = map(int, input().split())
#文字列をlistとしてinputしそれをn行の配列にする
a = np.array([list(input()) for _ in range(n)])
b = np.array([list(input()) for _ in range(m)])

judge = False

for i in range(n - m + 1):
    for j in range(n - m +1):
        image = a[i:i+m,j:j+m]
        if (image == b).all(): #配列が完全に一位してた場合
            judge = True

print("Yes" if judge else "No")

Measured memory_bytes: 12432
n=int(input())
c=[]
for i in range(n):
    x,y=map(int,input().split())
    c.append([x,y])
s=0
flag=0
for i in range(len(c)):
    if c[i][0]==c[i][1]:
        s+=1
    else:
        if s>=3:
            flag=1
        s=0

if s>=3:
    flag=1
if flag==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9136
n,k=map(int,input().split())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
data=sorted(data.items(),key=lambda x:x[1])
count=0
if len(data)<=k:
    print(0)
    exit()
else:
    for i in range(len(data)-k):
        count+=data[i][1]
print(count)


Measured memory_bytes: 39348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

int dp[1010][1010];

int main(){
    ll N; cin >> N;
    rep(x,N){
        string s,t; cin >> s >> t;
        rep(i,s.size()){
            rep(j,t.size()){
                if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
                else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
        cout << dp[s.size()][t.size()] << endl;
    }
}


Measured memory_bytes: 7104
from collections import deque
n = int(input())
e = [[] for _ in range(n)]
AB = [list(map(int, input().split())) for _ in range(n - 1)]
AB = [(a -1, b - 1) for a, b in AB]

for itr, (a, b) in enumerate(AB):
  e[a].append(b)
  e[b].append(a)
  
colors = [-1] * n

# ２色で塗分けする。
q = deque()
# 現在見ている頂点、親の色
q.append((0, 0))
while q:
  v, pcol = q.popleft()
  # 親と異なる色で塗る。
  if colors[v] == -1:
    col = not pcol
    colors[v] = col
    for i in e[v]:
      if colors[i] == -1:
        q.append((i, col))

# print(e)
# print(colors)
        
m = [deque([i for i in range(1, n + 1) if i % 3 == j]) for j in range(3)]

# print(m)

def opop(n, ne):
  if m[n]:
    p = m[n].pop()
  else:
    if n == 1 or n == 2:
      if m[ne]:
        p = m[ne].pop()
      else:
        p = m[0].pop()
    else:
      if m[1]:
        p = m[1].pop()
      else:
        p = m[2].pop()
  return p

ans = [0] * n

if sum(colors) <= len(m[0]):
  for itr, i in enumerate(colors):
    if i:
      ans[itr] = opop(0, 0)
    else:
      ans[itr] = opop(1, 2)
elif sum(colors) >= len(m[1]) + len(m[2]):
  for itr, i in enumerate(colors):
    if not i:
      ans[itr] = opop(0, 0)
    else:
      ans[itr] = opop(1, 2)
else:
  for itr, i in enumerate(colors):
    if i:
      ans[itr] = opop(1, 0)
    else:
      ans[itr] = opop(2, 0)
print(*ans)


Measured memory_bytes: 127308
#include<stdio.h>

int main(){
    int n;
    int dp[200][200], p[200];
    int i, j, k, l;
    int tmpa, tmpb;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%d %d", &p[i], &p[i+1]);
    }
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            dp[i][j] = 0;
        }
    }

    for(l=1; l<n; l++){
        for(i=0; i<n-l+2; i++){
            j=l+i;
            dp[i][j] = 1000000000;
            for(k=i; k<j; k++){
                tmpa = dp[i][j];
                tmpb = dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j];
                if(tmpa>tmpb){
                    dp[i][j] = tmpb;
                }
            }
        }
    }
    printf("%d\n", dp[1][n]);

    return 0;
}


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

int main(void){
  double n,k;
  double result;

  scanf("%lf%lf",&n,&k);
  
  result= k*(pow(k-1,n-1));
  
  printf("%.0lf\n",result);
  
  return 0;
}

Measured memory_bytes: 2516
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

typedef pair<int,int> P;
int N, K, x[100002];

int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &N, &K);
    rep(i,N) scanf("%d", x+i);
    
    if (N == 1) {
      puts("0");
      continue;
    }

    vector<P> v;
    for (int i = 0; i < N - 1; ++i) {
      v.push_back(P(x[i+1] - x[i], i));
    }
    sort(v.begin(), v.end(), greater<P>());
    rep(i,v.size()) {
      // printf("%d : %d\n", v[i].first, v[i].second);
    }

    int sumLen = x[N-1] - x[0];
    for (int i = 0; i < v.size() && --K; ++i) {
      sumLen -= v[i].first;
    }
    printf("%d\n", sumLen);
  }
  return 0; 
}

Measured memory_bytes: 3272
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

Dd = {}
for d in D:
    if d not in Dd:
        Dd[d] = 1
    else:
        Dd[d] += 1

Td = {}
for t in T:
    if t not in Td:
        Td[t] = 1
    else:
        Td[t] += 1

for k,v in Td.items():
    if k in Dd and Dd[k] >= Td[k]:
        continue
    print("NO")
    exit()
print("YES")


Measured memory_bytes: 56544
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		int sum = h+w;
		if(sum>=10) {
			System.out.println("error");
		}else {
		System.out.println(sum);
		}
	}

}


Measured memory_bytes: 23764
def print_rect(h, w):
    edgeline = "#" * w
    midline = "#" + "."*(w-2) + "#"
    print(edgeline)
    for i in range(1, h-1):
        print(midline)
    print(edgeline)
    print("")

while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    else:
        print_rect(h, w)

Measured memory_bytes: 7604
#include <iostream>
using namespace std;
 
int main () {
    int N, K, Q, tmp;
    cin >> N >> K >> Q;
    int point[N];
 
    for (int i = 0; i < N; i++) {
        point[i] = K;
    }
 
    for (int i = 0; i < Q; i++) {
        cin >> tmp;
        point[tmp - 1] += 1;
    }
 
    for (int i = 0; i < N; i++) {
        if (point[i] - Q > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
 
    return 0;
}

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

int main() {
  string str;
  cin >> str;
  
  if (str.at(0) == 'A') {
    int count_C = 0;
    for (int i=2; i<str.size()-1; i++) {
      if (str.at(i) == 'C') {
        count_C++;
      }
    }
    if (count_C ==1) {
      string result = "AC";
      for (int i=1; i<str.size(); i++) {
        if (str.at(i) < 'a' || str.at(i) > 'z') {
          if (str.at(i) != 'C') {
            result = "WA";
          }
        }
      }
      cout << result << endl;
    } else {
      cout << "WA";
    }
  } else {
    cout << "WA" << endl;
  } 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, a[200005],res=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "A") {
			res++;
		}
		else {
			res--;
		}
		if (res < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (res != 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}



Measured memory_bytes: 3156
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    ans += (b-a+1);
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<long>vec(n);
for(int i=0;i<n;i++){
cin >> vec.at(i);}
long sum=0;
sum=vec.at(0)+vec.at(n-2);
for(int i=1;i<n-1;i++){
  sum+=min(vec.at(i),vec.at(i-1));
}
  cout<<sum<<endl;
  }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int n, a[123456], cnt;
vector<int>v;
signed main() {
	cin >> n;
	for0(i, n)cin >> a[i];
	cnt = 1;
	for1(i, n - 1) {
		if (a[i - 1] == a[i]) {
			v.push_back(cnt);
			cnt = 1;
		}
		else cnt++;
	}
	v.push_back(cnt);
	if (v.size() <= 2)cout << n << endl;
	else {
		int ans = 0;
		for (int i = 2; i < v.size(); i++) ans = max(ans, v[i - 2] + v[i - 1] + v[i]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a,b,max,min;
    cin>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<'\n';
    }
    else{
        max=a-1;
        min=n-b;
        if(max<min){
            cout<<b-((b-a)/2)-1<<'\n';;
        }
        else{
            cout<<(n-a)-((b-a)/2)<<'\n';
        }
    }
    return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int I;
#define REP(i,n) for(I i=0;i<(I)(n);i++)
I n,dp[1024][100001],v[323456],w[323456];

void dfs(I i){
    I j=i/2;
    if(i>1){
        for(I k=100000;k+1;k--){
            if(dp[j-1][k]or!k){
                I ne=k+w[i-1];
                if(ne<=100000)dp[i-1][ne]=max(dp[j-1][k]+v[i-1],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(1024,n))dfs(i*2);
    if(i*2+1<=min(1024,n))dfs(i*2+1);
}

signed main(){
    cin>>n;REP(i,n)cin>>v[i]>>w[i];
    dp[0][*w]=*v;
    dfs(1);
    REP(i,1024)REP(j,100000)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    I q;cin>>q;
    REP(i,q){
        I u,l;cin>>u>>l;
        vector<I> cand;
        while(u>1024){
            cand.push_back(u);
            u=u/2;
        }
        I r=cand.size();
        I ans=0;
        REP(j,1<<r){
            I v_sub=0;I w_sub=0;
            REP(k,r){
                if(j>>k&1){
                    v_sub+=v[cand[k]-1];
                    w_sub+=w[cand[k]-1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[u-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;

int main(){
    int N; cin >> N;
    deque<int> q;
    for (int i = 0; i < N; i++){
        int a_i; cin >> a_i;
        if (i == 0){
            q.push_back(a_i);
            continue;
        }
        auto itr = lower_bound(q.begin(), q.end(), a_i);
        if (itr == q.begin()) q.push_front(a_i);
        else{
            --itr;
            *itr = a_i;
        }
    }
    cout << q.size() << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,tmp,cnt=0;
	cin >>n;
	vector<pair<int,int>>a(n);
	for(int i=0;i<n;i++){
		cin >> tmp;
		a.at(i) = make_pair(tmp-1,0);
	}
	int num=0;
	while(1){
		if(num==1)
			break;
		if(a.at(num).second==1){
			cnt= -1;
			break;
		}
		a.at(num).second=1;
		num = a.at(num).first;
		cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 203000;

    void solve() {
      ll n, k, p = 0, l = 0, r = 0;
      cin >> n >> k;
      ll a[n]; --k;
      rep(i, n) cin >> a[i];
      rep(i, n){
        if(a[i] == 1) { p = 1; continue; }
        p ? r++:l++;
      }
      ll ans = ceil(r*1.0/k + l*1.0/k);
      cout << ans << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n;
  cin >> n;
  
  ll ans=0;
  vector<ll> p(3*n);  
  rep(i,3*n){
  cin>>p[i];
  }
  
  sort(all(p));
  reverse(all(p));
  
  rep(i,2*n){
    if(i%2==1) ans+=p[i];
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2560
inf = float('inf')

n = int(input())
x = []
l = []
for _ in range(n):
    xx, ll = map(int, input().split())
    x.append(xx)
    l.append(ll)

st = []
for i in range(n):
    s = x[i] - l[i]
    t = x[i] + l[i]
    st.append([s, t])

st.sort(key=lambda x:x[1])

ans =0
cur = -inf
for i in range(n):
    if cur <= st[i][0]:
        ans += 1
        cur = st[i][1]


print(ans)

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

int main() {
    double a, b, x; cin >> a >> b >> x;
    
    double V = a * b * a / 2;
    double rad;
    if(V > x) rad = atan(2 * x / (a * b * b));
    else rad = atan(a*a*a / (2*a*a*b - 2*x));
    
    double ans = 180 * rad / 3.14159265358979;
    printf("%.10f\n", 90 - ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <ctime>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int unt;
typedef double db;
typedef pair <int, int> pii;
typedef vector <int> vi;

#define Fi first
#define Se second
#define pb push_back
#define mp make_pair
#define rep(x, a, b) for(int x = (a); x <= (b); ++ x)
#define per(x, a, b) for(int x = (a); x >= (b); -- x)
#define rop(x, a, b) for(int x = (a); x < (b); ++ x)
#define por(x, a, b) for(int x = (a); x > (b); -- x)
#define forE(x, a) for(int x = head[a]; x; x = nxt[x])

#ifdef DEBUG
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define debug(x)
#endif

const db eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const LL MINF = 0x7f7f7f7f7f7f7f7fll;

const db PI = 3.1415926535;

int main() {
	int a, b, x; cin >> a >> b >> x;
	db h = 1.0 * x / a / a;
	db S = a * h;
	db kk;
	if(a * b / 2 >= S) {
		kk = 2 * S / b;
		printf("%.10f\n", atan(b / kk) / PI * 180);
	} else {
		kk = (2 * a * b - 2 * S) / a;
		printf("%.10f\n", atan(kk / a) / PI * 180);
	}
}

Measured memory_bytes: 256
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        m=10000*i+5000*j+1000*k
        if m==y:
            print(i,j,k)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll n;
  cin >> n;
  ll p[n],r[n];
  for(int i=0;i<n;i++){
    cout << 30000*(i+1)<<" ";
  }
  cout << endl;
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
    r[p[i]]=i+1;
  }
  for(int i=0;i<n;i++){
    cout << 30000*(n-(i+1))+r[i]<<" ";
  }
  cout << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

#define M 110

int main(){
  int N, m[M], i, X, sum=0;
  cin >> N >> X;
  for (i = 0; i < N; i++)
    cin >> m[i];
  sum = accumulate(m, m+N, sum);
  sort(m, m+N);
  X = X - sum;
  int num = 0;
  while (X >= 0){
    num++;
    X -= m[0];
  }
  cout << num + N - 1<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, d; cin >> n >> d;
	vector<VE>a(n, VE(d));
	rep(i, n)rep(j, d)cin >> a[i][j];
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int now = 0;
			rep(k, d) {
				now += abs(a[i][k] - a[j][k])*abs(a[i][k]-a[j][k]);
			}
			bool ok = false;
			for (int k = 1; ; k++) {
				if (k * k >= now) {
					if (k*k == now) {
						ok = true;
					}
					break;
				}
			}
			if (ok)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
#define M 100010
LL INF = 1e18;

struct edge{
    LL to;
    LL cost;
};

LL V;
vector<edge> graph[M];
LL d[M];

void dijkstra(LL s){
    priority_queue<P, vector<P>, greater<P>>    que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        LL v = p.second;
        if(d[v] < p.first)  continue;
        for(int i = 0;i < graph[v].size();i++){
            edge e = graph[v][i];
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main(){
    cin >> V;
    for(int i = 0;i < V-1;i++){
        int ai, bi, ci;
        cin >> ai >> bi >> ci;
        edge e1 = {bi-1, ci};
        edge e2 = {ai-1, ci};
        graph[ai-1].push_back(e1);
        graph[bi-1].push_back(e2);
    }
    LL Q, K;
    cin >> Q >> K;
    dijkstra(K-1);
    for(int i = 0;i < Q;i++){
        int xi, yi;
        cin >> xi >> yi;
        cout << d[xi-1]+d[yi-1] << endl;
    }
}

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

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 2e5 + 2;
const int OO = 1e9 + 7;
using namespace std;
int main() {
    IO;
    ll h,w; cin>>h>>w;
    if(h==1 || w==1)
        re cout<<1,0;
    if(h&1){
        re cout<<((h+1)/2)*w-(w/2),0;
    }
    cout<<((h+1)/2)*w;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[205000],b[205000];
int ans[205000],len;
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  for(int i=n;i>=1;i--){
    int sum=0;
    for(int j=i*2;j<=n;j+=i)sum+=b[j];
    if(sum%2!=a[i]){
    	b[i]=1;
			ans[++len]=i;
    }
  }
  cout<<len<<endl;
  for(int i=1;i<=len;++i)cout<<ans[i]<<" ";
  return 0;
}

Measured memory_bytes: 2816
#include <cstdio>???
using namespace std;

int main(){
	int a, b, c, ans1=0, ans2=0;

	while( scanf("%d,%d,%d", &a,&b,&c) != EOF ){
		if( a*a + b*b == c*c ) ans1++; //????????§?????????????????????
		else if( a == b ) ans2++; //????????§????????????????????????
	}
	printf("%d\n%d\n", ans1, ans2);
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

void solve() {
    int N;
    cin >> N;
    vector<int> dp(2001);
    // 2以下は0、3〜5は1
    FOR(i, 3, 6) dp[i] = 1;
    FOR(i, 6, N + 1) { dp[i] = (dp[i - 1] + dp[i - 3]) % MOD; }
    cout << dp[N] << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
ll arr[305][305];
bool avoid[305][305];
int main()
{
    int n,i,j,k,f=1;
    sd(n);
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)slld(arr[i][j]);
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)for(k=1;k<=n;k++){
        if((arr[i][k]+arr[k][j])<arr[i][j]){
            f=0;
            break;
        }
        if(k!=i && k!=j)if(arr[i][k]+arr[k][j]==arr[i][j])avoid[i][j]=true;
    }
    if(f==0){
        pdn(-1);
        return 0;
    }
    ll answer=0;
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)if(!avoid[i][j])answer+=arr[i][j];
    answer/=2;
    plldn(answer);
    return 0;
}


Measured memory_bytes: 1024
#=== Buble Sort
datas = $stdin.read.split("\n")
n = datas[0].to_i
datas = datas[1].split(' ')
datas.map! do |x|
  x.to_i
end
flag = true
cnt = 0
while flag
  flag = false
  for j in 2..n
    if datas[- j] > datas[- j + 1]
      datas[- j],datas[- j + 1] = datas[- j + 1],datas[- j]
      flag = true
      cnt += 1
    end
  end
end
puts datas.join(' ')
puts cnt




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

 using namespace std;

 int main() {
   int N;

   cin >> N;

   if (N >= 64) cout << 64 << endl;
   else if (N >= 32) cout << 32 << endl;
   else if (N >= 16) cout << 16 << endl;
   else if (N >= 8) cout << 8 << endl;
   else if (N >= 4) cout << 4 << endl;
   else if (N >= 2) cout << 2 << endl;
   else cout << 1 << endl;
 }
		

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

using namespace std;

#define INF 12345678910
const int MAX_V=100005;

struct edge{int to, cost;};
typedef pair<int,int> P;//first:???????????¢???second:???????????????
vector<edge> G[MAX_V];
long long int d[MAX_V];
int V,E,s;

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;//
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v]< p.first) continue;
    for(int i=0; i<G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  scanf("%d%d%d",&V,&E,&s);
  for (int i=0; i<E; i++) {
      int from, to, cost;
      scanf("%d", &from);
      scanf("%d", &to);
      scanf("%d", &cost);
      edge e;
      e.to = to;
      e.cost = cost;
      G[from].push_back(e);
    }

  dijkstra(s);

  for(int i=0; i<V;i++){
    if(d[i]==INF)printf("INF\n");
    else printf("%lld\n",d[i]);
  }
  return 0;
}

Measured memory_bytes: 12972
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
 cin>>n;
 vector<int> arr(n,0);
 vector<int> mapper(n+1,0);

 for(int i=0;i<n;i++){
     cin>>arr[i];
     mapper[arr[i]]++;
 }
 for(int k=1;k<=n;k++){
     cout<<mapper[k]<<endl;
 }

}

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

int main(){
 while(1){
 int H,W;
 cin >>H>>W;
 if(H ==0 && W==0)break;
 for(int i=0;i<H;i++){
 for(int j=0;j<W;j++){
 if(i==0||i==H-1||j==0||j==W-1)cout<<"#";
 else cout<<".";
 }
cout<<endl;
}
cout<<endl;
}

}


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

int main(){
    int a, b, x;
    double ans;
    cin >> a >> b >> x;

    if(x > a * a * b / 2){
        ans = atan(a * a * a / (2.0 * (a * a * b - x)));
    }
    else{
         ans = atan(2.0 * x / b / b / a);
    }

    cout << setprecision(10) << 90 - ans * 180 / M_PI << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
input=sys.stdin.readline
from heapq import heappush,heappop

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))

def main():
    Q = int(input())
    sb = 0
    lupper = []
    rlower = []
    s = 0
    for _ in range(Q):
        cmds = tuple(map(int,input().split()))
        if cmds[0]==1:
            _,a,b = cmds
            sb+= b
            if len(lupper)== 0 or a<=-lupper[0]:
                heappush(lupper,-a)
                s+=-lupper[0]-a
                if len(lupper)-len(rlower)>=2:
                    heappush(rlower,-heappop(lupper))
            else:
                heappush(rlower,a)
                s+=a+lupper[0]
                if len(rlower)>len(lupper):
                    s+=-lupper[0]-rlower[0]
                    heappush(lupper,-heappop(rlower))  
        else:
            print (-lupper[0], s+sb)
    
main()


Measured memory_bytes: 75224
N,M,X = map(int,input().split())

L = [list(map(int,input().split()))  for i in range(N)]

cost = 10**12

import itertools

S = list(itertools.product([0,1],repeat=N))


for i in S:
    cnt = 0
    ablity = [0] * M
    for j in range(N):
        if i[j] == 1:
            for k in range(M+1):
                if k == 0:
                    cnt += L[j][k]
                    
                else:
                    ablity[k-1] += L[j][k]
    
    ans = True
    for i in ablity:
        if i < X:
            ans = False
    
    if ans:
        cost = min(cost,cnt)
        
if cost == 10**12:
    print(-1)
else:
    print(cost)

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}


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

int main() {
  long long r, d, x;
  cin >> r >> d >> x;

  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int score = 0;
        int hit = 0;
        int out = 0;
        while (n > 0) {
            switch (br.readLine()) {
            case "HIT":
                if (hit < 3) {
                    hit++;
                } else {
                    score++;
                }
                break;
            case "OUT":
                out++;
                if (out >= 3) {
                    n--;
                    System.out.println(score);
                    score = 0;
                    hit = 0;
                    out = 0;
                }
                break;
            case "HOMERUN":
                score += hit + 1;
                hit = 0;
                break;
            }
        }
    }
}



Measured memory_bytes: 24200
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	for(int i = 0; i < S.length() - 1; i++) {
		if(S.substr(i,2) == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int w, h;
int maps[50][50];

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

void dfs(int x, int y)
{
  maps[y][x] = 0;
  for(int i = 0; i < 8; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h && maps[ny][nx] == 1)
      dfs(nx, ny);
  }
  return;
}

int main()
{
  while(cin >> w >> h, w || h){
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	cin >> maps[i][j];

    int cnt = 0;
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	if(maps[i][j] == 1)
	  cnt++, dfs(j, i);
    
    cout << cnt << endl;
  }
  return 0;
}

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

typedef long long ll;

const int p=1000003;

inline int power(int x, int y){
	int s=1;
	while (y){
		if (y&1) s=(ll)s*x%p;
		x=(ll)x*x%p; y>>=1;
	}
	return s;
}

int fac[p+10];

int main(){
	fac[0]=1;
	for (int i=1;i<p;i++)
		fac[i]=(ll)fac[i-1]*i%p;
	int q; scanf("%d",&q);
	while (q--){
		int x,d,n;
		scanf("%d%d%d",&x,&d,&n);
		if (x==0){
			puts("0");
			continue;
		}else if (d==0){
			printf("%d\n",power(x,n%(p-1)));
			continue;
		}else{
			x=(ll)x*power(d,p-2)%p;
			if (x+n-1>=p) puts("0");
			else printf("%d\n",(ll)fac[x+n-1]*power(fac[x-1],p-2)%p*power(d,n%(p-1))%p);
		}
	}
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
  ll N,M,R;cin>>N>>M>>R;
  vector <ll> r;r.resize(R);
  for(int i=0;i<R;i++) cin>>r[i];
  sort(r.begin(),r.end());
  ll cost[210][210];//{INF};
  for(int i=0;i<210;i++){
    for(int j=0;j<210;j++){
      cost[i][j] = INF;
    }
  }
  for(int i=0;i<M;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    cost[a][b] = min(cost[a][b],c);
    cost[b][a] = cost[a][b];
  }
  for(int i=0;i<210;i++) cost[i][i] = 0;

  for(int k=1;k<=N;k++){
    for(int i=1;i<=N;i++){
      for(int j=1;j<=N;j++){
        cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
      }
    }
  }

  ll ans = INF;
  ll cnt =1;

  do {
    cnt++;

    ll preans = 0;
    //cout<<r[0];
    for(int i=1;i<R;i++){
      //cout<<r[i];
      preans += cost[r[i-1]][r[i]];
    }
    //cout<<endl;
    ans = min(preans,ans);

  } while (next_permutation(r.begin(),r.end()) or cnt < 8*7*6*5*4*3*2 + 10);

/*
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cout<<cost[i][j];
    }
    cout<<endl;
  }
*/
cout<<ans<<endl;


  return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main () {
    int n, q ;
    string s ;
    cin >> n >> q ;
    cin >> s ; 
    vector<int> l (q), r(q) ;
    rep(i, q){
        cin >> l[i] >> r[i] ;
        l[i]-- ;
        r[i]-- ;
    }
    vector<int> num (n) ;
    rep(i, n - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            num[i + 1]++ ; 
        }
    }
    for(int i = 1 ; i < n ; i++){
        num[i] += num[i - 1] ;
    }
    vector<int> ans ;
    rep(i, q){
        ans.push_back(num[r[i]] - num[l[i]]) ;
    }
    rep(i, q){
        cout << ans[i] << endl ; 
    }
}



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

int main(){
  int n; cin >> n;
  string a; cin >> a;
  for(int i=0; i<a.length(); i++){
    char c = 'A'+(char(a[i]) -'A' + n)%26;
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int res;
	if (a <= 5) {
		res = 0;
	}
	else if (a <= 12) {
		res = b / 2;
	}
	else {
		res = b;
	}
	printf("%d", res);
}

Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    string N;
    cin >> N;
    if(N[N.size()-1] == 's'){cout << N << "es" << endl;}
    else{cout << N << 's' << endl;}


    return 0;
}



Measured memory_bytes: 3124