akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;     
   cin >> i;
   h = i / 3600;
   m = i / 60 % 60;
   s = i % 60;
   cout << h << ":"<< m << ":" << s << endl;
   
   return 0;
}


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

using namespace std;

using pii = pair<int, int>;
using pll = pair<long long, long long>;

constexpr int INF = (int)1e9+7;
constexpr long long LLINF = (long long)1e18+7;

int main()
{
    int n;
    cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int t;
        cin >> t;
        cnt[t]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 3988
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  rep(i, n){
    if(h[i] > 0){
      swap(h[0], h[i]);
      swap(x[0], x[i]);
      swap(y[0], y[i]);
      break;
    }
  }
  rep(width, 100 + 1){
    rep(height, 100 + 1){
      int high = h[0] + abs(x[0] - width) + abs(y[0] - height);
      bool ok = true;
      for(int i = 1; i < n; i++){
        if(h[i] != max(high - abs(x[i] - width) - abs(y[i] - height), 0)){
          ok = false;
          break;
        }
      }
      if(ok){
        cout << width << " " << height << " " << high << endl;
        return 0;
      }
    }
  }
}

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

ll n;
vector<ll> a;
ll solve(int x);
int main(){
  cin >> n;
  for(ll i=0;i<n;i++){
    int x;
    cin >> x;
    a.push_back(x);
  }

  cout << min(solve(0),solve(1)) << endl;

  return 0;
}

ll solve(int x){
  ll ans = 0; ll now = 0;

  for(ll i=0;i<n;i++){
    now += a[i];
    if((i%2^x)&&(now>=0)){
      ans += now + 1;
      now = -1;
    } 

    if(!(i%2^x)&&(now<=0)){
      ans -= now - 1;
      now = 1;
    }
  }
  return ans;
}


Measured memory_bytes: 1400
/*input
1
AC
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
 
#define mod 998244353
 
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 





 
int main() 
{
    ll n; cin>>n;
    ll a = 0;
    ll w = 0;
    ll t = 0;
    ll r = 0;

    string dummy;
    getline(cin,dummy);

    rep(i,n){
    	string str;
    	getline(cin,str);
    	if(str == "AC")++a;
    	if(str == "WA")++w;
    	if(str == "TLE")++t;
    	if(str == "RE")++r;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
    return 0;  
}
 

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

int main() {
    long int A,B,C;
    cin >> A >> B >> C;
    int ans=0;
    if(A%2==1 || B%2==1 || C%2==1){
        ans=0;
    }
    else if(A==B &&B==C){
        ans=-1;
    }
    else{
    while(A%2==0 && B%2==0 && C%2 == 0){
    
        int a=A/2;
        int b=B/2;
        int c=C/2;
        A=b+c;
        B=a+c;
        C=a+b;
        ans++;
    }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n+2);
  for (int i = 1; i < n+1; i++){
    cin >> A.at(i);
  }

  int total = 0;
  vector<int> B(n+1);
  for (int i = 0; i < n+1; i++){
    B.at(i) = abs(A[i]-A[i+1]);
    total += B.at(i);
  }

  for (int i = 0; i < n; i++){
    cout << total - B[i] - B[i+1] + (abs(A[i] - A[i+2])) << endl;
  }
}

Measured memory_bytes: 2048
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

_ = ri()
def f(x):
  return 1/int(x)
print(1/sum(map(f, sys.stdin.readline().split())))
















Measured memory_bytes: 27224
A, B = map(int, input().split())
S = input()
ans = "Yes"
if S[A] != '-' and S[A].count('-') != 1:
    ans = "No"
else:
    S = S.split('-')
    if len(S) != 2:
        ans = "No"
    if not(S[0].isdecimal() and S[1].isdecimal()):
        ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n,k;

int main(){
    cin>>n>>k;
    double ans=0;
    rep(i,1,n+1){
        //int cnt=0;
        int num=i;
        double p=1.0;
        while(num<k){
            num*=2;
            p/=2;
            //cnt++;
        }
        //rep(j,0,cnt) p*=1/2;
        ans+=p;
    }
    ans/=n;
    cout<<fixed<<setprecision(12)<<ans<<"\n";
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> arr(8);
	int r8 = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int r = a/400;
		if(r>=8) r8++;
		else arr[r]++;
	}
	int mn = 0;
	for(int i = 0; i < 8; i++) {
		if(arr[i]>0) mn++;
	}
	//int mx = min(mn+r8,8);
	int mx = mn+r8;
	cout << max(mn,1) << " " << mx << endl;
}


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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(x-r >=0 && x+r<=W && y-r>=0 && y+r<=H){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    long long int name[5] = {};
    for(int i = 0;i < n;i++)
    {
        string s;
        cin >> s;
        if(s[0] == 'M')
        {
            name[0]++;
        }
        else if(s[0] == 'A')
        {
            name[1]++;
        }
        else if(s[0] == 'R')
        {
            name[2]++;
        }
        else if(s[0] == 'C')
        {
            name[3]++;
        }
        else if(s[0] == 'H')
        {
            name[4]++;
        }
    }
    long long int ans = 0;
    for(long long int i = 0;i < 5;i++)
    {
        for(long long int j = i + 1;j < 5;j++)
        {
            for(long long int k = j + 1;k < 5;k++)
            {
                ans = ans + name[i] * name[j] * name[k];
            }
        }
    }
    cout << ans << "\n";

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{   /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); /**/
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF INT_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef unsigned long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    int n;cin>>n;
    int r=n%10;
    if(r==2 || r==4 || r==5 || r==7 || r==9) cout<<"hon";
    else if(r==0 || r==1 || r==6 || r==8) cout<<"pon";
    else cout<<"bon";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 3672
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
ans0=[]
for i in range(N):
        ans0+=[i+1]*A[i]
ans0=ans0[::-1]

ans1=[[] for i in range(H)]
for i in range(H):
    for j in range(W):
        ans1[i].append(ans0.pop())

for i in range(H):
    if i%2==0:
        print(*ans1[i])
    else:
        print(*ans1[i][::-1])

Measured memory_bytes: 3956
$debug = true

### DFS: Depth-First Search = 深さ優先探索
# スタックによる実装
def iterative_dfs(nums, border)
  answer = nil

  # 嫌いな数字を除いた、使用できる数字。
  good_nums = (0..9).to_a - nums

  # スタックとなる配列を用意し、初期状態である空配列を格納する
  stack = [[]]
  until stack.empty?
    # スタックから1つ取り出す（末尾から取り出すのでpopを使う）
    current_num = stack.pop

    if current_num.length == border.to_s.length
      # 頂点に達した際の処理
      current_num = current_num.reverse.join("").to_i

      if current_num == border
        answer = current_num
        break
      elsif current_num > border
        answer = [answer, current_num].compact.min
      end
    else
      # 分岐処理
      good_nums.each do |chosen_num|
        stack << current_num + [chosen_num]
      end # of nums.each
    end # of if
  end # of until

  if answer.nil?
    # 桁が不足しており、まだ答えが定まらないパターンの対処
    digits = border.to_s.length
    answer = (((good_nums - [0]).min).to_s + good_nums.min.to_s * digits).to_i
  end

  # 結果を返す
  answer
end # of def

PRICE, _k = gets.split.map(&:to_i)
hate_numbers = gets.split.map(&:to_i)
answer = iterative_dfs(hate_numbers, PRICE)

puts answer


Measured memory_bytes: 1916
N = int(input())
T, A = input().split()
T = int(T)
A = int(A)
h = input().split()


w = 999999
answer = 0
for i,x in enumerate(h):
    x = int(x)
    tmp = abs(A - (T - (x * 0.006)))
    if tmp < w:
        w = tmp
        answer = i+1

print(answer)

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

float n, d;

void input() {
    cin >> n >> d;
}

void solve() {
    int result = ceil(n / (2 * d + 1));
    cout << result << endl;
}
int main() {
    input();
    solve();
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: u64 = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    a[0] %= m;
    for i in 1..n {
        a[i] = (a[i] + a[i - 1]) % m;
    }

    let mut ans = 0u64;
    let mut mp = std::collections::HashMap::new();
    mp.insert(0, 1);
    for i in 0..n {
        let cnt = mp.entry(a[i]).or_insert(0);
        ans += *cnt;
        *cnt += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);

        var s = input.ReadLine();

        var li = new List<int>();
        
        if(s[0] == '0')
            li.Add(0);

        var t = 0;
        for(int i=0; i<n; i++) {
            var c = s[i];

            if (i>0 && c != s[i - 1]) {
                li.Add(t);
                t = 0;
            }
            t++;
        }
        li.Add(t);

        if(s[s.Length-1] == '0')
            li.Add(0);

        int st = 0;
        int ed = 0;
        int sum = 0;
        int max = 0;

        for(int i=0; i<li.Count; i++) {
            if(k > 0) {
                if (i % 2 == 1) k--;
                sum += li[i];
                max = sum;
                ed++;
            } else {
                sum += li[ed];
                sum -= li[st];
                if (i % 2 == 0) {
                    max = Math.Max(max, sum);
                } else {
                    if (i < li.Count - 1)
                        max = Math.Max(max, sum + li[i + 1]);
                }
                ed++;
                st++;
            }
        }
        return max;
    }
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll gcd(ll x, ll y) {
  if (y < x)
    swap(x, y);
  if (x == 0)
    return y;
  return gcd(y % x, x);
}

ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// xに2が何個ふくまれるか
ll f(ll x) {
  ll res = 0;
  while (x > 0 && x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

signed main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  vector<ll> a(n);

  // a'とする
  rep(i, n) {
    cin >> a[i];
    if (a[i] % 2 != 0) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  ll t = f(a[0]);
  rep(i, n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
  }

  // a''とする
  // m'とする
  rep(i, n) { a[i] = (a[i] >> t); }
  m = (m >> t);

  ll L = 1;
  rep(i, n) {
    L = lcm(L, a[i]);
    if (L > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  // ans=ceil(m' /L /2)
  m /= L;
  ans = (m + 1) / 2;

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


Measured memory_bytes: 1024
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 9/3/2019

*/

#include <bits/stdc++.h>
using namespace std;
#define time cout << "\ntime: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#define W 100001
inline void Boost() {
	cin.tie(0);cin.sync_with_stdio(0);
	cout.tie(0);cout.sync_with_stdio(0);
}
static	int n,w;
long long DP[101][W],knap[101][2];

long long dp(int i,int weight){
	if(weight<0)
		return -6969696969;
	if (weight==0 || i==n)
		return 0;
	if(DP[i][weight]!=-1)
		return DP[i][weight];

	return DP[i][weight]=max(knap[i][1]+dp(i+1,weight-knap[i][0]),dp(i+1,weight));


}



int main(void){
	Boost();
	cin >>n >> w;
	
	for(int i=0 ;i<n ;i++)
		for(int j=0 ; j<2 ;j++)
			cin >>knap[i][j];

	memset(DP,-1,sizeof(DP));

	

	cout <<dp(0,w)<<endl;

   return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int D;
    cin >>D;
    cout << "Christmas";
    rep(i,25-D){
        cout << " Eve";
    }
    cout << endl;



}


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

#define LENGTH 100005



typedef struct {
  char name[100];
  int time;
}Process;

void enqueue(Process);
Process dequeue(void);

Process queue[LENGTH];
int head=0,tail=0;


int main(){
  Process data;
  int num,qms,count=0,lap,i;

  scanf("%d%d",&num,&qms);

  for(i=0;i<num;i++){
    scanf("%s",queue[i].name);
    scanf("%d",&queue[i].time);
  }
  tail=num;

  while(head!=tail){
    data=dequeue();
    lap=data.time<qms ? data.time : qms;
    count+=lap;
    data.time-=lap;
    if(data.time>0) enqueue(data);
    else printf("%s %d\n",data.name,count);
  }
  return 0;
}

void enqueue (Process data){
  int next;
  next=(tail+1)%LENGTH;
  
  if(next==head) exit(2);
  queue[tail].time=data.time;
  strcpy(queue[tail].name,data.name);
  tail=next;
}

Process dequeue(){
  Process data;
  if(head==tail) exit(3);
  data.time=queue[head].time;
  strcpy(data.name,queue[head].name);
  head=(head+1)%LENGTH;
  return data;
}
      
    
  



Measured memory_bytes: 12008
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//引用元
//http://drken1215.hatenablog.com/entry/2019/03/03/224600
//union くっつける
//find  どのグループか調べる
struct UnionFind {
    vector<LL> parent;
    
    UnionFind(LL n) : parent(n, -1) { }
    void init(LL n) { parent.assign(n, -1); }
    
    //xの属している木の根っこを返す
    LL root(LL x) {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);//経路圧縮
    }
    
    LL size(LL x) {return -parent[root(x)];}//xの属する木の要素数を求める
    bool is_same_tree(LL x,LL y) {return root(x)==root(y);}
    
    bool merge(LL x,LL y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);//xの親の方がyの親より小さくなるようにする
        parent[x] += parent[y];//経路の長さを加算
        parent[y] = x;//yの親をxとする
        return true;
    }
};

LL N,M;
LL A[200000],B[200000];
 
LL ans = 0;

void solve(){
	UnionFind uf(N+1);
	for(int i=0;i<M;i++){
		uf.merge(A[i],B[i]);
	}
	for(int i=1;i<=N;i++){
		ans = max(ans,uf.size(i));
	}
}
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++) cin >> A[i] >> B[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7636
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c;
cin >> a >> b >> c;
if(a+b+c>=22) {
  cout << "bust" << endl;
} else {
  cout << "win" << endl;
}
return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 + 7;

const int MAX = 2e6;
int64 fac[MAX] = {}, inv[MAX] = {}, finv[MAX] = {};

void make_table() {
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int64 com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int64 x, y; cin >> x >> y;
  auto ok = [](int64 xx, int64 yy) -> bool {
    if (xx * 2LL < yy || xx > yy * 2LL) return false;
    return (xx + yy) % 3 == 0;
  };

  if (!ok(x, y)) {
    cout << 0 << endl;
    return 0;
  }

  make_table();

  int64 nn = (x + y) / 3;
  //debug(nn);
  int64 r = x - nn;

  cout << com(nn, r) << endl;

  return 0;
}

Measured memory_bytes: 47104
n, y = map(int,input().split())
 
for i in range(0,n+1):
  for j in range(0, n-i+1):
    if y == 10000*i + 5000*j + 1000*(n-i-j):
      print("{0} {1} {2}".format(i, j, n-i-j))
      exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
import math

a, b, h, m = map(int, input().split())

ang_a = (h+m/60)/12
ang_b = m/60
ang = ang_a - ang_b if ang_a - ang_b <= 0.5 else ang_b - ang_a
theta = ang * 2 * math.pi
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta)))

Measured memory_bytes: 9508
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
int XOR(int a,int b){
	int ni=1;
	rep(0,i,41){
		n2[i]=ni;
		ni*=2;
	}
	rep(0,i,41)nis[i]=0;
	for(int i=40;i>=0;i-=1){
		if(a>=n2[i]){
			nis[i]++;
			a-=n2[i];
		}
		if(b>=n2[i]){
			nis[i]++;
			b-=n2[i];
		}	
	}
	int sum=0;
	rep(0,i,41)sum+=(nis[i]%2*n2[i]);
	return sum;
}
int a[114514];
int b[114514];
signed main(){
	ic(n) ic(k)
	rep(0,i,n)cin>>a[i];
	b[0]=0;
	rep(0,i,n)b[i+1]=a[i];
	int sum=0;
	rep(0,i,n){
		if(b[i]+b[i+1]>k){
			if(b[i]>k){
				sum+=b[i+1]+b[i]-k;
				b[i+1]=0;
				b[i]=k;
			}
			else{
				sum+=b[i]+b[i+1]-k;
				b[i+1]=k-b[i];
			}
		}
	}
	c(sum)
}	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;


int main(){
   int n; cin>>n;
   
   vector<int> a(n);

   ll res=0;
   //comb関数を作って全探索ではない
   //計算量を考える
   //comb(n,k)<comb(n,k+1)⇔k<(n-1)/2
   //nを固定したときのcombを最大にするkは決まってる
   //さらにnが大きくなるほどnの最大値も大きくなる。

   REP(i,n)cin>>a[i];
   sort(ALL(a));
   reverse(ALL(a));
   //降順

   REP(i,n)if(abs(a[0]-2*a[i])<abs(a[0]-res*2)) res =a[i];
   cout<<a[0]<<" "<<res<<endl;
} 


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

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;
}


int main() {
  int N; cin >> N;
  vector<int> x;
  ll L = INF, R = 0; 
  rep(i,N) {
    ll a;
    cin >> a;
    x.push_back(a);
    L = min(L,a);
    R = max(R,a);
  }
  ll ans = INF;
  for(int i = L; i <= R; i++){
    ll sum = 0;
    rep(j,N){
      sum += (x[j] - i)*(x[j] - i);
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3624
import copy
N=int(input())
p=[int(_) for _ in input().split()]
sorted_p=sorted(p)
if p==sorted_p:
    print('YES')
else:
    flag=0
    for i in range(N):
        for j in range(N):
            new_p=copy.copy(p)
            new_p[i]=p[j]
            new_p[j]=p[i]
            if new_p==sorted_p:
                flag=1
    if flag==0:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = sc.nextIntArray(n);
		Arrays.sort(h);

		int sum = Integer.MAX_VALUE;
		for(int i = 0; i < n-k+1; i++) {
			int abs = h[i+k-1] - h[i];
			if(sum > abs)
				sum = abs;
		}
		System.out.println(sum);
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 38664
class MaxHeapInt(object):
    def __init__(self, val):  self.val = val
    def __lt__(self, other): return self.val > other.val
    def __eq__(self, other): return self.val == other.val
    def __str__(self): return str(self.val)


def resolve():
    import heapq
    n, Q = [int(i) for i in input().split()]
    ans = [[] for _ in range(n)]
    for _ in range(Q):
        q = [int(i) for i in input().split()]
        if q[0] == 0:
            heapq.heappush(ans[q[1]], MaxHeapInt(q[2]))
        elif q[0] == 1:
            if len(ans[q[1]]) > 0:
                print(ans[q[1]][0].val)
        else:
            if len(ans[q[1]]) > 0:
                heapq.heappop(ans[q[1]])


resolve()



Measured memory_bytes: 44904
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e9;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(b - a) <= d && abs(c - b) <= d) or abs(c - a) <= d)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		ulong[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,ulong>(s => ulong.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
*/

		ulong[] pans = new ulong[a[0]+1];
		ulong[] pats = new ulong[a[0]+1];
		pans[0] = 0;
		pats[0] = 1;
		for(ulong i=1; i<=a[0];i++) {
			pans[i] = pans[i-1]*2+2;
			pats[i] = pats[i-1]*2+1;
		}

		ulong cnt = 0;
		ulong k = a[1];
		for(ulong i=a[0]; 0<i;i--) {
			if(k==0) {
				break;
			} else if(k==1){
				break;
			} else if(k<=(pans[i-1]+pats[i-1]+1)){
				k--;
			} else if(k==(pans[i-1]+pats[i-1]+2)){
				cnt += pats[i-1]+1;
				break;
			} else if(k<=((pans[i-1]+pats[i-1])*2+2)){
				cnt += pats[i-1]+1;
				k = k-pans[i-1]-pats[i-1]-2;
			} else if(k==((pans[i-1]+pats[i-1])*2+3)){
				cnt += pats[i-1]*2+1;
				break;
			} else {
				break;
			}
			if((i==1)&&(k==1)) cnt++;
		}

		string ans = cnt.ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAXN 100005
#define PLI pair<long long,int>
#define fi first
#define se second
#define mp make_pair
//#define ivorysi
using namespace std;
typedef long long int64;
int N;
int64 C,x[MAXN],v[MAXN],ans;
int64 pre[MAXN],suf[MAXN],premax[MAXN],sufmax[MAXN];
void Solve() {
	scanf("%d%lld",&N,&C);
	for(int i = 1 ; i <= N ; ++i) scanf("%lld%lld",&x[i],&v[i]);
	x[N + 1] = C;
	for(int i = 1 ; i <= N ; ++i) {
		pre[i] = pre[i - 1] + v[i] - (x[i] - x[i - 1]);
		premax[i] = max(pre[i],premax[i - 1]);
	}
	for(int i = N ; i >= 1 ; --i) {
		suf[i] = suf[i + 1] + v[i] - (x[i + 1] - x[i]);
		sufmax[i] = max(suf[i],sufmax[i + 1]);
	}
	ans = max(ans,max(sufmax[1],premax[N]));
	for(int i = 1 ; i <= N ; ++i) {
		ans = max(ans,pre[i] - x[i] + sufmax[i + 1]);
	}
	for(int i = N ; i >= 1 ; --i) {
		ans = max(ans,suf[i] - (C - x[i]) + premax[i - 1]);
	}
	printf("%lld\n",ans);
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
	return 0;
}

Measured memory_bytes: 4992
//
//  main.cpp
//  test
//
//  Created by kanebako on 2017/09/10.
//  Copyright © 2017 kanebako. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    
    int accept = 0;
    
    for (int i = 0; i < 6; ++i){
        if (s[i] == '1'){
            accept += 1;
        }
        
    }
    
    cout << accept << endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
 {
	int n;
	cin>>n;
	vector<int> a(n),dp(n);
	input_array(a,n);
	dp[0]=0;dp[1]=abs(a[1]-a[0]);
	
	for(int i=2;i<=n;i++)
	{
	        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
use std::cmp::{min,Reverse};
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        s: usize,
        uvab: [(Usize1,Usize1,usize,i64);m],
        cd: [(usize,i64);n],
    }
    let mut g = vec![vec![];n];
    let mut t = 0;
    for (u,v,a,b) in uvab {
        g[u].push((v,a,b));
        g[v].push((u,a,b));
        t += a;
    }
    let inf = std::i64::MAX;
    let mut m = vec![vec![inf;t+1];n];
    let mut q = std::collections::BinaryHeap::new();
    q.push((Reverse(0),min(s,t),0));
    while !q.is_empty() {
        let (Reverse(p),s,v) = q.pop().unwrap();
        if m[v][s]<=p {continue;}
        for i in (0..=s).rev() {
            if m[v][i]<=p {break;}
            m[v][i]=p;
        }
        if s<t {
            let s = min(t,s+cd[v].0);
            let p = p+cd[v].1;
            if m[v][s]>p {
                q.push((Reverse(p),s,v));
            }
        }
        for &(u,a,b) in &g[v] {
            if a>s {continue;}
            let s = s-a;
            let p = p+b;
            if m[u][s]>p {
                q.push((Reverse(p),s,u));
            }
        }
    }
    for p in &m[1..n] {
        println!("{}",p[0]);
    }
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int h, w;
    cin>>h>>w;
    int n;
    cin>>n;
    int den = MAX2(h, w);
    int ans = n/den;
    if(n%den) ans++;
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 892
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: usize = scan(tokens);
    let b: usize = scan(tokens);
    println!("{}", (b + a - 3) / (a - 1));
}


Measured memory_bytes: 4352
use std::str::FromStr;

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

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

fn main() {
    let a: Vec<i32> = read_vec();
    let mut b: Vec<i32> = [].to_vec();
    for i in 0..3 {
        b.push(a[i] + a[(i+1) % 3]);
    }
    println!("{}", std::cmp::min(std::cmp::min(b[0], b[1]), b[2]));
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(){
    int N,data[2],ans=0,i;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&data[0]);
        scanf("%d",&data[1]);
        ans+=data[1]-data[0]+1;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 110
#define MAX_T 40010
#define MAX_V 110

ll N;
ll T[MAX_N] = {};
ll V[MAX_N] = {};
ll Limit[MAX_T] = {};   // i 秒での限界速度
ll EndTime = 0;
double dp[MAX_T][MAX_V];

// i 秒時点で、現在の速度が j m/s のときの最大値
double dfs(int i = 0, int j = 0) {
    if(EndTime <= i) {
        if(j != 0) {
            dp[i][j] = -(std::numeric_limits<double>::infinity());
        } else {
            dp[i][j] = 0;
        }
        DBG("i: %lld j: %lld dp[i][j]: %.6f\n", i, j, dp[i][j]);
        return dp[i][j];
    }

    double& res = dp[i][j];
    if(res != std::numeric_limits<double>::infinity()) {
        return res;
    }
    res = -(std::numeric_limits<double>::infinity());

    double cand1 = -(std::numeric_limits<double>::infinity());;
    double cand1_2 = cand1;
    double cand2 = cand1;
    double cand3 = cand1;
    if(j > Limit[i]) {
        // 条件違反
        res = -(std::numeric_limits<double>::infinity());
        return res;
    }
    if(j < Limit[i]) {
        double dist = static_cast<double>(j) + 0.5;
        cand1 = dfs(i+1, j+1) + dist;
        dist = static_cast<double>(j) + 0.25;
        cand1_2 = dfs(i+1, j) + dist;
    }
    if(j > 0) {
        double dist = static_cast<double>(j-1) + 0.5;
        cand2 = dfs(i+1, j-1) + dist;
    }
    cand3 = dfs(i+1, j) + static_cast<double>(j);

    res = max({res, cand1, cand1_2, cand2, cand3});
    DBG("i: %lld j: %lld cand1: %.6f cand1_2: %.6f cand2: %.6f cand3: %.6f res: %.6f\n",
            i, j, cand1, cand1_2, cand2, cand3, res);

    return res;
}

signed main()
{
    cin >> N;
    REP(i, N) { cin >> T[i]; }
    REP(i, N) { cin >> V[i]; }
    REP(i, N) {
        for(int j = EndTime; j < EndTime + T[i]; ++j) {
            Limit[j] = V[i];
            //DBG("Limit[%lld]: %lld\n", j, Limit[j]);
        }
        EndTime += T[i];
    }

    REP(i, MAX_T) {
        REP(j, MAX_V) {
            dp[i][j] = std::numeric_limits<double>::infinity();
        }
    }

    double ans = dfs();

    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 37248
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		boolean possible = true;
		Scanner input = new Scanner(System.in);
		int h = input.nextInt();
		int w = input.nextInt();
		input.nextLine();
		char[][] mat = new char[h][w];
		String[][] sol = new String[h][w];
		for (int r = 0; r < h; r++) {
			String s = input.nextLine();
			for (int c = 0; c < w; c++) {
				mat[r][c] = s.charAt(c);
			}
		}

		

		for (int r = 0; r < h; r++) {
			for (int c = 0; c < w; c++) {
				if (mat[r][c] == '#')
					sol[r][c] = "#";
				else {
					int cnt = 0;
					if (r - 1 >= 0) {
						if (c - 1 >= 0 && mat[r - 1][c - 1] == '#')
							cnt++;
						if (c + 1 < w && mat[r - 1][c + 1] == '#')
							cnt++;
						if(mat[r-1][c] == '#')
							cnt++;
					}
					if (r + 1 < h) {
						if (c - 1 >= 0 && mat[r + 1][c - 1] == '#')
							cnt++;
						if (c + 1 < w && mat[r + 1][c + 1] == '#')
							cnt++;
						if (mat[r + 1][c] == '#')
							cnt++;
					}

					if (c - 1 >= 0 && mat[r][c - 1] == '#')
						cnt++;
					if (c + 1 < w && mat[r][c + 1] == '#')
						cnt++;

					sol[r][c] = "" + cnt;
				}
			}

		}

		for (int r = 0; r < h; r++) {
			for (int c = 0; c < w; c++) {
				System.out.print(sol[r][c]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 23124
import sys
from collections import Counter

MAX_A = 10**6 + 5

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
# A.sort(reverse=True)

dp = [True] * MAX_A
Ac = Counter(A)

for k, v in Ac.items():
    if v > 1:
        dp[k] = False
    for n in range(2*k, MAX_A, k):
        dp[n] = False

ans = 0
for a in A:
    if dp[a]:
        ans += 1

print(ans)

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

int main(){
  int n,count,ans;
cin >> n;
count = 0; ans = 1;

if(n < 105){
  cout << 0 << endl;
}else{
  for(int i = 107;i <= n;i += 2){
    for(int j = 1;j <= i;j += 2){
      if(i % j == 0){
        count++;
        if(count > 8){
          break;
        }
      }
    }
    if(count == 8){
      ans++;
    }
    count = 0;
  }
  cout << ans << endl;
}
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;
int main(){
	long double a,b,c;
	long double x;  //??????????????????
	long double s,l,h;
	
	cin>>a>>b>>c;
	
	s=a*b*sin(c*M_PI/180.0)/2;
	x=sqrt(a*a+b*b-2*a*b*cos(c*M_PI/180.0));
	l=a+b+x;
	h=2*s/a;
	
	cout<<fixed<<setprecision(9)<<s<<endl;
	cout<<fixed<<setprecision(9)<<l<<endl;
	cout<<fixed<<setprecision(9)<<h<<endl;
}

Measured memory_bytes: 1288
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
int N, M, Q;

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

int main()
{
	int r, D;
	int X;
	cin >> r >> D >> X;
	for (i = 0; i < 10; i++) {
		X = r * X - D;
		cout << X << endl;
	}
}

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

using namespace std;

int main(){
	double m,a;
	ll n,i,s[1003];
	
	while(1){
		cin>>n;
		if(n==0) break;
		m=0;
		for(i=1;i<=n;i++){
			cin>>s[i];
			m+=s[i];
		}
		m=m/n;
		a=0;
		for(i=1;i<=n;i++){
			a+=(s[i]-m)*(s[i]-m);
		}
		a=a/n;
		a=sqrt(a);
		printf("%8lf\n",a);
	}
}



Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

bool isPrime(int N){
  if(N<=1) return false;
  if(N==2) return true;
  if(N%2==0) return false;

  for(int i=3 ; i*i<=N ; i+=2){
    if(N % i == 0) return false;
  }

  return true;
}

//============================================
int main(){
  int Q;
  cin >> Q;
  int l[Q],r[Q];
  for(int i=0;i<Q;i++) cin >> l[i] >> r[i];

  bool prime[100001];
  fill(prime,prime+100001,false);
  for(int i=3;i<100000;i++){
    if(i%2 == 1){
      if(isPrime(i) && isPrime((i+1)/2)) prime[i] = true;
    }
  }

  //累積和
  int sum[100002];
  sum[0] = 0;
  for(int i=1;i<=100001;i++){
    if(prime[i-1]){
      sum[i] = sum[i-1] + 1;
    } else {
      sum[i] = sum[i-1];
    }
  }

  for(int i=0;i<Q;i++){
    cout << sum[r[i]+1] - sum[l[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 1920
n = int(input())
S = set()
for i in range(n):
    query, x = map(int, input().split())
    if query == 0:
        S.add(x)
        print(len(S))
    elif query == 1:
        print(1 if x in S else 0)
    else:
        S.discard(x)


Measured memory_bytes: 23356
program main
  implicit none

  integer :: n, p(50), i, c=0

  read(*,*)n
  read(*,*)(p(i),i = 1, n)
  
  do i = 1, n
    if ((p(i) - i) /= 0) then
      c = c + 1
    end if
  end do
  if ((c == 2) .or. (c == 0)) then
    write(*,*)"YES"
  else
    write(*,*)"NO"
  end if

end program main

Measured memory_bytes: 256