akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    static int stack[]=new int[101];
	public static void main(String[] args) {
		int i=0;
		String s;
		// TODO Auto-generated method stub
    Scanner sc= new Scanner(System.in);
	s=sc.next();
    while(true){
    	if(Number(s)){
    	 i++;
    	 stack[i]=Integer.parseInt(s);
    	 }else{
    		 if(s.equals("+")){
    			 stack[i-1]=stack[i-1]+stack[i];
    			 i--;
    		 }
    		if(s.equals("-")){
    			stack[i-1]=stack[i-1]-stack[i];
    			i--;
    		}
    		if(s.equals("*")){
    			stack[i-1]=stack[i-1]*stack[i];
    			i--;
    		}
    		if(s.equals("/")){
    			stack[i-1]=stack[i-1]/stack[i];
    			i--;
    		}
    	 
     }
    	if(!sc.hasNext()) break;
    	s=sc.next();
    }
    System.out.println(stack[1]);
	}
	public static boolean Number(String a){
		try{
			Integer.parseInt(a);
		return true ;
		}catch(Exception e){
		return false;
	}
}
}



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

#define INF 1000000000000
#define MOD 1000000007

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    string s;
    cin>>s;
    if(s[s.length()-1]=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll n,d,a;
ll now;
ll ans;
ll c[200100];
pii m[200100];
ll k;
int main()
{
    cin>>n>>d>>a;
    d*=2;
    REP(i,n)
    {
    	cin>>m[i].X>>m[i].Y;
        m[i].Y=(m[i].Y+a-1)/a;
    }
    sort(m,m+n);
    now=0;
    REP(i,n)
    {
        while(now<i&&m[i].X-m[now].X>d)
          k-=c[now++];
        c[i]=m[i].Y-k;
        if(c[i]<0)
          c[i]=0;
        ans+=c[i];
        k+=c[i];
    }
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	double a,b;
	cin>>a>>b;
	printf("%.12f\n",a/b);
}

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

const int MAX_N = 1e5+2;
int N, K, H[MAX_N];
ll dp[MAX_N];

void solve()
{
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	for(int i=1;i<=N;++i){
		for(int j=1;j<=K;++j){
			if(i+j<=N) dp[i+j]=min(dp[i+j],dp[i]+abs(H[i+j]-H[i]));
		}
	}
	cout << dp[N] << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=1;i<=N;++i) cin >> H[i];
	solve();
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){
    int N, R;
    cin >> N >> R;

    if (N < 10)
        cout << R + 100 * (10 - N) << '\n';
    else
        cout << R << '\n';

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin >> a >> b;
	vector<int> st(a), sd(a);
	vector<pair<int, int>> ab(a);
	
	for (int i = 0; i < a; i++)
	{
		cin >> st[i] >> sd[i];
	}

	for (int i = 0; i < a; i++)
	{
		ab[i] = make_pair(st[i], sd[i]);
	}
	sort(ab.begin(), ab.end());
	long long ans = 0;
	
	for (int i = 0; i < a ;i++)
	{
		int buy = min(b, ab[i].second);
		ans += (long long)buy*ab[i].first;
		b -= buy;
	}
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 1920
#include <stdio.h>

int main(void){
  int n,scr[100][5],i,j;

  for(;;){
    scanf("%d", &n);
    if(n==0) break;

    int max=0;
    int min=500;
    int sum[100]={0};
    for(i=0;i<n;i++){
      for(j=0;j<5;j++){
      scanf("%d", &scr[i][j]);
      sum[i]+=scr[i][j];
      }
      if(sum[i]>max) max=sum[i];
      if(sum[i]<min) min=sum[i];
    }
    printf("%d %d\n", max, min);
  }

  return 0;
}
      


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double W,H;
  W=w;
  H=h;
  double ans=W/2*H;
  cout << fixed << setprecision(9) << ans << " ";
  if(w%2==1 || h%2==1) cout << 0 << endl;
  else if(x==w/2 && y==h/2) cout << 1 << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3100

/* Dijkstra O(NlogM)*/

struct Dijkstra{

  typedef int Type;

  int V;
  vector<vector<pair<int,Type> > > G;
  vector<int> cost;
  
  Dijkstra(int n):
    V(n),G(n,vector<pair<int,Type> >()){}
  
  void add_edge(int u, int v, Type c){
    G[u].push_back({v,c});
  }
  
  Type solve(int s, int g = -1){
    cost.assign(V,-1);
    priority_queue<pair<Type,int> > pq;
    Type max_cost = 0;
    
    pq.push({0,s});

    while(pq.size()){
      Type now_cost = pq.top().first;
      int now = pq.top().second;
      pq.pop();

      if(cost[now] >= 0) continue;
      
      cost[now] = -now_cost;
      max_cost = max(max_cost, -now_cost);
      
      if(now == g) return -now_cost;
      
      for(int i=0;i<(int)G[now].size();i++){
        pq.push({now_cost-G[now][i].second, G[now][i].first});
      }
    }
        
    return max_cost;
  }
  
};


int main(){
  int n,r;
  int s[SIZE],t[SIZE],d[SIZE];
  bool ans[SIZE] = {};
  
  scanf("%d%d",&n,&r);

  Dijkstra dij(n);
  
  for(int i=0;i<r;i++){
    scanf("%d%d%d",s+i,t+i,d+i);
    s[i]--; t[i]--;
    
    dij.add_edge(t[i],s[i],d[i]);
    dij.add_edge(s[i],t[i],d[i]);
  }

  int ans_dis = 0;
  
  for(int i=0;i<n;i++){
    int max_dis = dij.solve(i);

    if(max_dis > ans_dis){
      for(int j=0;j<n;j++) ans[j] = false;
      ans_dis = max_dis;
    }

    if(max_dis < ans_dis) continue;
    
    queue<int> que;
    bool visited[SIZE] = {};
    
    for(int j=0;j<n;j++){
      if(max_dis == dij.cost[j]){
        que.push(j);
      }
    }

    while(que.size()){
      int p = que.front();
      que.pop();
      
      if(visited[p]) continue;
      visited[p] = true;
      ans[p] = true;
      
      for(int j=0;j<dij.G[p].size();j++){
        if(dij.cost[p] - dij.G[p][j].second == dij.cost[dij.G[p][j].first]){
          que.push(dij.G[p][j].first);
        }
      }
    }
  }

  int ans_count = 0;
  for(int i=0;i<n;i++) ans_count += ans[i] == false;

  printf("%d\n",ans_count);
  
  for(int i=0;i<n;i++){
    if(ans[i] == false){
      printf("%d\n",i+1);
    }
  }
  
    
  return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector< map<string, u64> > dp;

string pool("AGCT");

bool check(string& x)
{
    bool ret;
    if (x[1] == 'A' && x[2] == 'G' && x[3] == 'C') ret = false;
    else if (x[1] == 'A' && x[2] == 'C' && x[3] == 'G') ret = false;
    else if (x[1] == 'G' && x[2] == 'A' && x[3] == 'C') ret = false;
    else if (x[0] == 'A' && x[2] == 'G' && x[3] == 'C') ret = false;
    else if (x[0] == 'A' && x[1] == 'G' && x[3] == 'C') ret = false;
    else ret = true;

    return ret;
}

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

    int N;
    cin >> N;

    dp.resize(N + 1);
    vector<string> keys;
    u64 ans = 0;
    rep (i, 4) rep (j, 4) rep (k, 4)
    {
        string key = string("") + pool.at(i) + pool.at(j) + pool.at(k);
        string temp  = 'T' + key;
        if (check(temp))
        {
            dp[3][key] = 1;
            keys.push_back(key);
        }
    }

    for (int i = 4; i <= N; ++i)
    {
        string key;
        rep (j, keys.size())
        {
            if (dp[i - 1][keys[j]] == 0) continue;
            rep (k, 4)
            {
                string temp = keys[j] + pool[k];
                if (check(temp))
                {
                    key = temp.substr(1, 3);
                    dp[i][key] += dp[i - 1][keys[j]] % MOD;
                }
            }
        }
    }

    for (auto it = dp[N].begin(); it != dp[N].end(); ++it)
    {
        ans = (ans + it->second) % MOD;
    }
    cout << ans << "\n";
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];

    int taila = 0;
    int frontb = 0;
    int banda = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') banda++;
        else if(s[i][0] == 'B') frontb++;
        else if(s[i][s[i].length()-1] == 'A') taila++;
        
        for(int j = 1; j < s[i].length(); j++){
            if(s[i][j-1] == 'A' && s[i][j] == 'B') ans++;
        }
    }
    
    if(banda > 0){
        ans += banda-1;
        if(taila > 0){
            taila--;
            ans++;
        }
        if(frontb > 0){
            frontb--;
            ans++;
        }
    }

    if(taila > frontb) ans += frontb;
    else ans += taila;
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int int64_t

signed main() {
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int bc = 0;
	int ans = 0;
	char last = 'b';
	for(int i = n - 1; i >= 0; i--) {
		s[i] = tolower(s[i]);
		if(s[i] == 'c') {
			if(last != 'b') {
				bc = 0;
			}
			last = 'c';
		} else if(s[i] == 'b') {
			if(last == 'c') {
				bc++;
			} else {
				bc = 0;
			}
			last = 'b';
		} else {
			if(last != 'b') {
				bc = 0;
			}
			ans += bc;
			last = 'b';
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
import java.util.*

fun main(args: Array<String>) {
    val k = Integer.parseInt(readNext())
    val s = readNext()
    val list = s.split(" ").map { Integer.parseInt(it) }
    val sortList = list.sorted()
    var result = sum(sortList, 0.0)


    println(result)
}
fun sum  (list: List<Int>, res: Double) : Double {
    if(list.isEmpty()) {
        return res
    }
    var resp: Double
    val ls:List<Int>
    if (res != 0.0){
        resp = (list.get(0).toDouble() + res) / 2
        ls = list.drop(1)
    } else {
        resp = (list.get(0).toDouble() + list.get(1)) / 2
        ls = list.drop(2)
    }
    return sum(ls, resp)
}

    fun readNext(): String {
        return readLine()!!
    }


Measured memory_bytes: 37860
import java.util.*;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long x = sc.nextLong();
long[] arr = new long[N];
  for(int i=0;i<N;i++){
    arr[i] = sc.nextInt();
  }
Arrays.sort(arr);
int count=0;
for(int i=0;i<N;i++){
  if(i!=N-1){
    if(arr[i]<=x){
      x -= arr[i];
      count++;
    }else{
      break;
    }
  }else{
    if(arr[i]==x){
      count++;
    }else{
      break;
    }
  }

}
System.out.println(count);
}
}


Measured memory_bytes: 23252
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[1000],b[1000];
int main(){
    cin>>a>>b;
    if((a[strlen(a)-1]-'0')*(b[strlen(b)-1]-'0')%2==1){
        cout<<"Odd";
    }
    else{
        cout<<"Even";
    }
    //cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int ans=0;
        for (int i=0; i<N; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            ans += r-l+1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25960
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                if (i*j == N)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long;
using namespace std;
using pii = pair<int, int>;
const int N = 2e5 + 10;
ll dp[N][2];
int a[N];
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 1; i <=n; i++){
		scanf("%d", &a[i]);
	}
	dp[1][0] = 0LL;
	dp[1][1] = 1LL * a[1];
	dp[2][0] = 1LL * max(a[1], a[2]);
	for(int i = 3; i <= n; i++){
		if(i % 2 == 0){
			dp[i][0] = max(dp[i - 1][1], dp[i - 2][0] + 1LL * a[i]);
		}
		else{
			dp[i][0] = max(dp[i - 1][0], dp[i - 2][0] + 1LL * a[i]);
			dp[i][1] = dp[i - 2][1] + 1LL * a[i];
		}
	}
	printf("%lld", dp[n][0]);
}

Measured memory_bytes: 7732
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n%2==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[0]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Measured memory_bytes: 92928
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    vector <int> a(n + 2), b(n + 1);
    for(i = 1; i <= n + 1; i++) {
        cin >> a[i];
    }
    for(i = 1; i <= n; i++) {
        cin >> b[i];
    }

    ll ans = 0;
    for(i = 1; i <= n; i++) {
        int mn = min(a[i], b[i]);
        a[i] -= mn, b[i] -= mn;
        ans += mn;

        mn = min(a[i + 1], b[i]);
        a[i + 1] -= mn, b[i] -= mn;
        ans += mn;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
void sai(int n){
  int i=1,ma=0,mi=0,a,b;
  scanf("%d",&a);
  for(;i<n;i++){
    scanf("%d",&b);
    if(ma<b-a)ma=b-a;
    if(mi>b-a)mi=b-a;
    a=b;
  }
  printf("%d %d\n",ma,-mi);
}

int main(){
  int i=0,n,x;
  scanf("%d",&n);
  for(;i<n;i++){
    scanf("%d",&x);
    sai(x);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b=0,cnt=0,d=0,e=0;
string s,ss[110];
signed main()
{
	cin>>s>>a;
	if(s.size()==1){
		cout<<a/2;
		return 0;
	}
	while(1){
		if(s[e]!=s[e+1]){
			break;
		}else{
			e++;
			if(e==s.size()-2){
				cout<<s.size()*a/2;
				return 0;
			}
		}
	}
	ss[0]=s[0];
	rep(i,s.size()-1){
		ss[i+1]=s[i+1];
		if(ss[i]==ss[i+1]){
			cnt++;
			ss[i+1]='&';
		}
	}
	while(1){
		if(s[b]!=s[b+1]){
			break;
		}else{
			b++;
		}
	}
	d=s.size()-1;
	while(1){
		if(s[d]!=s[d-1]){
			break;
		}else{
			d--;
		}
	}
	if((s[s.size()-1]==s[0])&&((s.size()-d)%2==1)&&((b+1)%2==1)){
		cout<<cnt*a+(a-1);
	}else{
		cout<<cnt*a;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll dp[100001]={1000000000};
ll ans=1e9;

ll fn(vi v,ll k){
	mset(dp,1000000);
dp[0]=0;	dp[1]=abs(v[1]-v[0]);
	rep(j,1,v.size())
	{
	rep(i,1,k+1){
	if(j>=i)
	{//cout<<dp[j]<<" "<<dp[j-i]<<" "<<dp[j-i]+abs(v[j]-v[j-i])<<" ";
	dp[j]=min(dp[j],dp[j-i]+abs(v[j]-v[j-i]));
	
	}else break;}}return dp[v.size()-1];
} 
int main(){
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b;
        cin>>a>>b;
        vi v;
        int k;
        rep(i,0,a)
        {
        	cin>>k;
        	v.pb(k);
		}
		
		
		cout<<fn(v,b)<<endl;
return 0;}


Measured memory_bytes: 2676
#include<iostream>
using namespace std;
const long long mod=1e9+7;
long long dp[444][444],n,c,ans,sum[444][444];
long long a[444],b[444];
long long binpow(long long k,long long n)
{
	long long res=1,p=k;
	for (long long i=n;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
int main()
{
	cin>>n>>c;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	dp[0][0]=1;
	for (int j=a[1];j<=b[1];j++)
	{
		sum[j][0]=dp[0][0];
		for (int k=1;k<=c;k++)
		{
			sum[j][k]=(sum[j][k-1]*j+dp[0][k])%mod;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=c;j++)
		{
			for (int k=a[i];k<=b[i];k++)
			{
				dp[i][j]=(dp[i][j]+sum[k][j])%mod;
			}
		}
		if (i==n) break;
		for (int j=a[i+1];j<=b[i+1];j++)
		{
			sum[j][0]=dp[i][0];
			for (int k=1;k<=c;k++)
			{
				sum[j][k]=(sum[j][k-1]*j+dp[i][k])%mod;
			}
		}
	}
	cout<<dp[n][c]<<endl;
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    ll a = (1 + N) * N;
    ll b = a / 2;
    cout << b - N << endl;
}

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

typedef long long ll;

const int INT = 1e9;
const int mod = 1e9+7;

int main()
{
    ll s,c;
    cin >> s >> c;

    if(2 * s > c){
        cout << c / 2 << endl;
        return 0;
    }else{
        cout << s + (c - 2 * s) / 4  << endl;
        return 0;
    }
}

Measured memory_bytes: 256
use std::collections::{HashSet, HashMap};

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace()
        .map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut s = Vec::<String>::with_capacity(n);
    let mut map = HashMap::new();

    for i in 0..n {
        s.push(read::<String>());
        let mut sl = s[i].chars().collect::<Vec<_>>();
        sl.sort();
        s[i] = sl.into_iter().collect();
        let count = map.entry(s[i].clone()).or_insert(0);
        *count += 1;
    }
    let mut res : i64 = 0;
    for i in map {
        res += (i.1) * (i.1-1) / 2;
    }
    println!("{}", res);
}


Measured memory_bytes: 20412
#include<bits/stdc++.h>
#define MAX 5000
#define MOD 1000000007
using namespace std;
vector<int> p,c;
long long go(int start, int k)
{
	long long sum = 0;
	int ii = start;
	int steps = 0;
	vector<int> v;
	do
	{
		ii = p[ii];
		v.push_back(c[ii]);
		sum += 1LL*c[ii];
		++steps;
	}
	while(ii^start);
	long long tmp = 0, res = LLONG_MIN;
	for(int i=0;i+1<=k&&i<v.size();++i)
	{
		tmp += 1LL*v[i];
		if(sum>0)
			res = max(res,tmp+(k-i-1)/steps*1LL*sum);
		else res = max(res,tmp);
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	p = vector<int>(n+1), c = vector<int>(n+1);
	for(int i=1;i<=n;++i)
		cin>>p[i];
	for(int i=1;i<=n;++i)
		cin>>c[i];
	long long ans = LLONG_MIN;
	for(int i=1;i<=n;++i)
		ans = max(ans,go(i,k));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3696
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto M = RD;
	auto edges = new long[][](N);
	foreach (i; 0..M)
	{
		auto a = RD-1;
		auto b = RD-1;
		edges[a] ~= b;
		edges[b] ~= a;
	}

	long[] open = [0];
	auto ans = new long[](N);
	auto dist = new long[](N);
	dist[] = long.max;
	while (!open.empty)
	{
		auto from = open.front; open.popFront;
		foreach (to; edges[from])
		{
			if (dist[from]+1 < dist[to])
			{
				dist[to] = dist[from] + 1;
				ans[to] = from + 1;
				open ~= to;
 			}
		}
	}

	writeln("Yes");
	foreach (e; ans[1..$])
		writeln(e);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 26656
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

long int comb(long int n)
{
    if (n < 2 ) return 0;
    return n*(n-1)/2;
}

void foo(vector<long int>& m)
{
    long int sum = 0;
    unordered_map<long int,int> frq;

    for (long int x:m)
    {
        if (frq.find(x)==frq.end()) frq[x] = 1;
        else frq[x] += 1;
    }

    for (auto it:frq)
    {
        sum += comb(it.second);
    }

    //cout<<sum<<endl;

    for (int i=0;i<m.size();++i)
    {
        long int ans = sum - (frq[m[i]] - 1);
        cout<<ans<<endl;
    }
}
int main()
{
    long int n;
    cin>>n;
    vector<long int> v(n);
    for (int i=0;i<n;++i) cin>>v[i];

    foo(v);

    return 0;
}


Measured memory_bytes: 9160
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int n, m, a[100009], b[100009], c[100009], d[100009]; double f[100009];
double solve(double x) {
	for (int i = 0; i < n; i++) {
		if (x * a[i] >= d[i]) f[i] = 0;
		else f[i] = (d[i] - x * a[i]) / c[i];
	}
	double ret = x * m;
	for (int i = 0; i < n; i++) {
		ret += f[i] * b[i];
	}
	return ret;
}
int main() {
	while (scanf("%d", &n), n) {
		scanf("%d", &m);
		for (int i = 0; i < n; i++) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
		double l = 0, r = 1000000000.0;
		for (int i = 0; i < 130; i++) {
			double m1 = (l * 2 + r) / 3;
			double m2 = (l + r * 2) / 3;
			double r1 = solve(m1);
			double r2 = solve(m2);
			if (r1 < r2) r = m2;
			else l = m1;
		}
		printf("%.9f\n", solve(l));
	}
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  int count=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        cout<<"DENIED"<<endl;
        count++;
        break;
      }
    }
  }
  if(count==0){cout <<"APPROVED"<<endl;}
  
}






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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    sort(A.rbegin(),A.rend());
    ll ans = 0;
    if (N%2==1){
        ll sum = 0;
        for (int i=0;i<(N-3)/2;i++){
            sum += 2*A[i];
        }
        for (int i=(N-3)/2;i<(N+1)/2;i++){
            sum += A[i];
        }
        for (int i=(N+1)/2;i<N;i++){
            sum -= 2*A[i];
        }
        ans = max(ans, sum);
        sum = 0;
        for (int i=0;i<(N-1)/2;i++){
            sum += 2*A[i];
        }
        for (int i=(N-1)/2;i<(N+3)/2;i++){
            sum -= A[i];
        }
        for (int i=(N+3)/2;i<N;i++){
            sum -= 2*A[i];
        }
        ans = max(ans, sum);
    } else {
        ll sum = 0;
        for (int i=0;i<(N-2)/2;i++){
            sum += 2*A[i];
        }
        for (int i=(N-2)/2;i<N/2;i++){
            sum += A[i];
        }
        for (int i=N/2;i<(N+2)/2;i++){
            sum -= A[i];
        }
        for (int i=(N+2)/2;i<N;i++){
            sum -= 2*A[i];
        }
        ans = max(ans , sum);
        sum = 0;
        for (int i=0;i<(N-2)/2;i++){
            sum += 2*A[i];
        }
        for (int i=(N-2)/2;i<N/2;i++){
            sum += A[i];
        }
        for (int i=N/2;i<(N+2)/2;i++){
            sum -= A[i];
        }
        for (int i=(N+2)/2;i<N;i++){
            sum -= 2*A[i];
        }
        ans = max(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
S = list(input())
A = int(S[0] + S[1])
B = int(S[2] + S[3])

if 1 <= A <= 12:
    if 1 <= B <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= B <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	int h; cin >> h;
	int w; cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
                    printf("%c", a[i][j]);
				}
			}
			printf("\n");
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	string S;
	cin >> S;

	ll o0 = 0;
	ll o1 = 0;
	ll e0 = 0;
	ll e1 = 0;
	rep(i, S.size()) {
		if (i % 2 == 0) {
			if (S[i] == '0') {
				o0++;
			}
			else {
				o1++;
			}
		}
		else {
			if (S[i] == '0') {
				e0++;
			}
			else {
				e1++;
			}
		}
	}

	ll ans = S.size() - (abs(e1-o0) + abs(o1-e0));
	
	cout << ans << "\n";

	return 0;
}

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

int main(){

  int N=0;
  cin>>N;
  
  map<int,int> mp;
  
  int k;
  rep(i,N-1){

    cin>>k;
    
    mp[k]++;
    
  }
  
  rep(i,N){

    cout<<mp[i+1]<<endl;
    
  }
  
}

Measured memory_bytes: 12980
S = list(input())

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, sep = '', end = '')
            print (a[i])
            exit()

for i in range(25, -1, -1):
    if i == -1:
        break
    if ord(S[i]) < ord(S[i - 1]):
        continue
    else:
        break
# print (i)
if i == 0:
    print (-1)
    exit()

tmp_n = ord('z')
for j in S[i:]:
    if ord(j) > ord(S[i - 1]):
        tmp_n = min(tmp_n, ord(j))

print (*S[:i - 1], sep = '', end = '')
print (chr(tmp_n))

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   int n;
   cin >> n;
   VL a(3*n), b(n);
   int n3=3*n;
   REP(i, n3){
       cin >> a[i];
   }
   sort(ALL(a), greater<LL>());
    LL ans = 0;
   for(int i=0; i<2*n;){
       ans+=a[i+1];
       i+=2;
   }
   cout << ans << endl;


   


}

    



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n;
int main(){
    cin>>n;
    int ok=0;
    while(n){
        if(n%10==7)ok=1;
        n/=10;
    }
    if(ok)puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define maxn 1000100
using namespace std;
int n,sum[maxn*2],tp,m,a[maxn],f[maxn];
char s[maxn];
int g(int x){
	return x<0?x+26:x;
}
int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main(){
	scanf("%s%d",s+1,&n);
	int m=strlen(s+1);
	for(int i=1;i<=m;++i)s[i]-='a',f[i]=i;
	f[m+1]=m+1;
	for(int i=m+1;i>=1;--i)s[i]=g(s[i]-s[i-1]);
	for(int i=1,l,r;i<=n;++i)
		scanf("%d%d",&l,&r),f[find(l)]=find(r+1);
	for(int i=1;i<=m-i+2;++i)f[find(i)]=find(m+2-i);
	for(int i=1;i<=m+1;++i)sum[find(i)]+=s[i];
	for(int i=1;i<=m+1;++i)if(i==find(i)&&sum[i]%26)return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 2816
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int d = scanner.nextInt(), g = scanner.nextInt();
			Score[] s = new Score[d];
			IntStream.range(0, d).forEach(i -> s[i] = new Score((i + 1) * 100, scanner.nextInt(), scanner.nextInt()));
			Arrays.sort(s);
			System.out.println(IntStream.range(1, 1 << d).filter(i -> ok(i, s, g)).map(i -> getProblemNo(i, s, g)).min()
					.getAsInt());
		}
	}

	/**
	 * 目標スコアが達成できるかどうかを計算する
	 * 
	 * @param mask 使用する問題の2進数表現
	 * @param s    問題数とスコア数の配列
	 * @param g    目標スコア
	 * @return 目標スコアが達成できるかどうか
	 */
	private static boolean ok(int mask, Score[] s, int g) {
		int sum = 0;
		for (int i = 0; i < s.length; i++) {
			if ((mask & (1 << i)) > 0) {
				sum += s[i].max;
				if (sum >= g) {
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * 目標スコアが達成させるための解く問題数を計算する
	 * 
	 * @param mask 使用する問題の2進数表現
	 * @param s    問題数とスコア数の配列
	 * @param g    目標スコア
	 * @return 目標スコアが達成させるための解く問題数
	 */
	private static int getProblemNo(int mask, Score[] s, int g) {
		int result = 0;
		for (int i = 0; i < s.length; i++) {
			if ((mask & (1 << i)) > 0) {
				if (g > s[i].max) {
					result += s[i].count;
					g -= s[i].max;
				} else {
					int index = Arrays.binarySearch(s[i].scores, g);
					if (index < 0) {
						index = ~index;
					}
					result += index + 1;
					break;
				}
			}
		}
		return result;
	}

	/**
	 * 問題数とスコアを表すクラス
	 */
	private static class Score implements Comparable<Score> {
		/** 問題数 */
		int count;
		/** スコアの配列 */
		int[] scores;
		/** 完成したときのスコア数 */
		int max;

		/**
		 * コンストラクタ
		 * 
		 * @param n 1問あたりのスコア
		 * @param p 問題数
		 * @param c ボーナススコア
		 */
		Score(int n, int p, int c) {
			scores = new int[count = p];
			IntStream.range(0, p - 1).forEach(i -> scores[i] = (i + 1) * n);
			scores[p - 1] = max = p * n + c;
		}

		@Override
		public int compareTo(Score score) {
			// 問題を完了させたときのスコア数で降順でソート
			return Double.compare(((double) score.max) / score.count, ((double) this.max) / this.count);
		}
	}
}


Measured memory_bytes: 36620
from math import*
def solve(B):
    α=b*sin((90-B)*pi/180)/sin(B*pi/180)
    s=α*b/2
    if α>a:s-=(α-a)*(b-b*a/α)/2
    return s>=x/a
a,b,x=map(int,input().split())
ok=0
ng=90
while ng-ok>1e-7:
    mid=(ok+ng)/2
    if solve(mid):ok=mid
    else:ng=mid
print(ok)

Measured memory_bytes: 38640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BTrained {
public:
    vector<int> a[100010];
    vector<int> visit;
    int res = 1e6;

    BTrained():visit(100010, 0){}

    void dfs(int u, int cnt){
        //cout << u sp cnt sp res << endl;
        if(u == 1){
            chmin(res, cnt);
            return;
        }
        visit[u] = 1;
        for(auto const& e : a[u]){
            if(visit[e]) continue;
            dfs(e, cnt+1);
        }
    }

	void solve(std::istream& in, std::ostream& out)
	{
	    int n, ina;
	    in >> n;
	    for(int i=0; i<n; i++){
	        in >> ina;
	        ina--;
	        a[i].push_back(ina);
	    }

	    dfs(0, 0LL);

	    if(res == 1e6) out << -1 << endl;
	    else out << res << endl;
	}
};


int main() {
	BTrained solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int H = input.nextInt();
        int W = input.nextInt();
        
        while (H != 0 && W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    }
                    else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
            
            H = input.nextInt();
            W = input.nextInt();
        }
    }
}


Measured memory_bytes: 36344
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 20

int N;
int min_input,max_input;
int table[1005];
int POW[NUM];


void func(){

	min_input = BIG_NUM;
	max_input = -BIG_NUM;

	int tmp;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		table[i] = tmp;
		min_input = min(min_input,tmp);
		max_input = max(max_input,tmp);
	}

	vector<int> V;
	int sum;
	int ans = 1;

	for(int num = min_input; num <= max_input; num++){

		sum = 0;
		V.clear();

		for(int i = 0; i < N; i++){
			if(table[i]%num != 0)continue;

			for(int k = 0; k <= 10; k++){
				if(table[i] == num*POW[k]){
					V.push_back(POW[k]);

					sum += POW[k];
					break;
				}
			}
		}
		if(sum == 0)continue;

		int dp[sum+1];
		for(int i = 0; i <= sum; i++){
			dp[i] = -11;
		}

		dp[0] = 0;

		for(int i = 0; i < V.size(); i++){
			for(int k = (sum/V[i])*V[i]; k-V[i] >= 0; k -= V[i]){
				if(dp[k-V[i]] == -1)continue;
				dp[k] = max(dp[k],dp[k-V[i]]+1);
			}
		}

		for(int i = 0; POW[i] <= sum; i++){
			ans = max(ans,dp[POW[i]]);
		}
	}

	printf("%d\n",ans);
}

int main(){

	POW[0] = 1;
	for(int i = 1; i <= NUM-1; i++){
		POW[i] = POW[i-1]*2;
	}

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



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

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

    int X[15][15];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            int norm = 0;
            for(int k = 0; k < D; k++) {
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff*diff;
            }
            bool flag = false;
            for(int k = 0; k <= norm; k++) {
                if(k*k == norm) {
                    flag = true;
                }
            }
            if(flag) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
s = input()
n = len(s)

alp = [chr(i) for i in range(97, 97+26)]

if n < 26:
    for a in alp:
        if a not in s:
            print(s + a)
            exit()
else:
    i = 25
    while True:
        if i == 0:
            print('-1')
            exit()
        if s[i - 1] < s[i]:
            break
        i -= 1
    t = sorted(s[i-1:])
    idx = t.index(s[i-1]) + 1
    print(s[:i-1] + t[idx])


Measured memory_bytes: 61868
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

bool f(long long N){
  string s = to_string(N);
  long long slen = s.length();
  slen--;
  for (int i = 0; i < s.length(); i++)
  {
    if(s[i]!=s[slen-i])
      return false;
  }
  return true;
}

int main()
{
  long long N;
  cin >> N;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++)
  {
    string s1 = s.substr(0, i);
    string s2 = s.substr(i, s.length()-i);
    set<char> set_s1;
    set<char> set_s2;
    vector<char> result;
    for (int j = 0; j < s1.length();j++)
      set_s1.insert(s1[j]);
    for (int j = 0; j < s2.length(); j++)
      set_s2.insert(s2[j]);
    set_intersection(set_s1.begin(), set_s1.end(), set_s2.begin(), set_s2.end(), inserter(result,result.begin()));

    ans = max(ans, (int)result.size());
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//#define MD 1
#define MD 1000000007
 
int main(){
    int a,b;
    cin>>a>>b;
    if(a>8 || b>8){
        cout<<":("<<endl;
        }
        else{
            cout<<"Yay!"<<endl;
        }
    return 0;
}

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

typedef long long ll;

int main() {
    ll a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero" << endl;
    } else {
        ll neg_num1 = 0 - min(0LL, a),
           neg_num2 = 0 - min(0LL, b),
           neg_num;
        if (neg_num2 == 0) {
            neg_num = neg_num1;
        } else {
            neg_num = neg_num1 - neg_num2 + 1;
        }
        if (neg_num % 2 == 0) {
            cout << "Positive" << endl;
        } else {
            cout << "Negative" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256