akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

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

    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}


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

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

const int Maxn = 200005;

set <ii> S;
int n;
int A[Maxn], B[Maxn];
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < n; i++) {
        scanf("%d", &B[i]);
        S.insert(ii(B[i], i));
    }
    while (!S.empty()) {
        set <ii>::iterator it = S.end(); it--;
        int ind = it->second; S.erase(it);
        if (B[ind] > A[ind]) {
            int a = (ind - 1 + n) % n, b = (ind + 1) % n;
            if (B[ind] > B[a] + B[b]) {
                int tk1 = (B[ind] - A[ind]) / (B[a] + B[b]);
                int tk2 = min((B[ind] - B[a] - 1) / (B[a] + B[b]), (B[ind] - B[b] - 1) / (B[a] + B[b])) + 1;
                int tk = min(tk1, tk2);
                if (tk > 0) {
                    B[ind] -= tk * (B[a] + B[b]);
                    res += tk;
                    S.insert(ii(B[ind], ind));
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
        if (A[i] != B[i]) { printf("-1\n"); return 0; }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int h,w,a=0;
	while(scanf("%d%d",&h,&w)&&h!=0&&w!=0){
		for(int i=0;i<h;i++){
			if(i%2==0) a=0;
				else a=1;
			for(int j=0;j<w;j++){
				if(a%2==0)printf("#");
				else printf(".");
				a++;
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int N;

int main() {
    cin >> N;
    int mx = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= mx) {
            cnt++;
            mx = h;
        }
    }
    cout << cnt << endl;
}





Measured memory_bytes: 384
#include <iostream>

using namespace std;

//SUN, MON, TUE, WED, THU, FRI, or SAT

int main(void){
 string s;
  cin >> s; 
  int n = 7;
  if(s == "SAT")
  	cout << n - 6;
  else if (s == "SUN")
    cout << n;
  else if(s  == "MON")
    cout << n - 1;
  else if(s  == "TUE")
    cout << n - 2;
  else if(s  == "WED")
    cout << n - 3; 
  else if(s  == "THU")
    cout << n - 4;
  else if(s  == "FRI")
    cout << n - 5;  
}

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

using namespace std;

int get_group(int i) {
  switch (i) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return 0;
    case 4:
    case 6:
    case 9:
    case 11:
      return 1;
    case 2:
      return 2;
    default:
      return -1;
  }
}

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

  if (get_group(x) == get_group(y))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int main()
{
  int x;
  cin >> x;
  int ans = 0;
  int cnt =  (x / 500);
  x -= cnt * 500;
  cout << 1000 * cnt + (x / 5) * 5 << endl;
  return 0;
}

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

int main(void){
    int w,h;
    std::string buf;
    while(1){
        std::cin >> h >> w;
        if(w+h==0) break;
        buf="";
        for(int i=0;i<w;i++){
            buf+="#";
        }
        buf+="\n";
        for(int i=0;i<h;i++){
            std::cout << buf;
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b+c-a < 0){
    cout << 0 << endl;
  }
  else{
    cout << b+c-a << endl;
  }
  
}


Measured memory_bytes: 256
import itertools
K=int(input())
X,Y=map(int,input().split())
Mdist=abs(X)+abs(Y)
if Mdist%2==1 and K%2==0:
    print(-1)
    exit()
    #K:偶数ならマンハッタン距離が偶数の点にしか行けない
    #逆にKが偶数ならマンハッタン距離が偶数の任意の点に行ける
    #K:奇数なら理論上どこでも行ける
    #よってこれ以外のパターンは全部可能
    #(0,0)->(2n+1,0)->(n+1,n+1)->(1,0)
#K:奇数のとき、移動回数と距離がmod2 で合同
if abs(X)+abs(Y)==K:
    print(1)
    print(X,Y)
    exit()
def searcheven(x,y):
    if abs(x)+abs(y)>2*K:
        return None
    if (abs(x)+abs(y))%2==1:
        return None
    for ps in itertools.product([-1,1],repeat=4):
        p1,p2,p3,p4=ps
        if p1*p4==p2*p3:
            if p3*(K-p1*x-p2*y)==-p1*K:
                a,b=0,p4*K
                if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                    return (a,b)
                a,b=p3*K,0
                if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                    return (a,b)
            else:
                pass
        else:
            tmp1=K-p1*x-p2*y
            tmp2=K
            tmp3=p4*tmp1+p2*tmp2
            tmp4=-p3*tmp1-p1*tmp2
            det=-p1*p4+p2*p3
            a,b=(tmp3//det,tmp4//det)
            if abs(x-a)+abs(y-b)==K and abs(a)+abs(b)==K:
                return (a,b)
            else:
                pass
    return None

ans=[(0,0)]
while(True):
    nx,ny=ans[-1]
    if abs(nx-X)+abs(ny-Y)<=2*K:
        if (abs(nx-X)+abs(ny-Y))%2==0:
            p,q=searcheven(X-nx,Y-ny)
            ans.append((p+nx,q+ny))
            ans.append((X,Y))
            break
        else:
            tmpx=K//2
            tmpy=K-tmpx
            nextkouho=[(tmpx,tmpy),(tmpx,-tmpy),(-tmpx,tmpy),(-tmpx,-tmpy),(K,0),(-K,0),(0,K),(0,-K)]
            for point in nextkouho:
                ptmp,qtmp=point
                p=ptmp+nx;q=qtmp+ny
                if abs(X-p)+abs(Y-q)<=2*K:
                    ans.append((p,q))
                    break
    elif abs(nx)+K<=abs(X):
        if X<0:
            ans.append((nx-K,ny))
            continue
        else:
            ans.append((nx+K,ny))
            continue
    elif abs(ny)+K<=abs(Y):
        if Y<0:
            ans.append((nx,ny-K))
            continue
        else:
            ans.append((nx,ny+K))
            continue


#print(ans)
s=len(ans)-1
flag=1
for i in range(s):
    ax,ay=ans[i]
    bx,by=ans[i+1]
    if abs(ax-bx)+abs(ay-by)==K:
        pass
    else:
        flag=0
        break
if flag==0:
    print("NG")
print(s)
for i in range(1,s+1):
    print(ans[i][0],ans[i][1])


Measured memory_bytes: 59780
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];


// returns gcd(a, b)
// x, y will contain the answer for ax + by = gcd(a, b) after the execution
// if answer for ax + by = c is needed,
// check if c % gcd(a, b) == 0
// get (c / gcd(a, b)) * (x, y)

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}

// enumerate divisors
vector<int> enum_div(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n/i);
      }
    } 
  }
  sort(res.begin(), res.end());
  return res;
}

signed main() {
  int a, b, c; cin >> a >> b >> c;
  int x, y;
  int gcd = extGCD(a, b, x, y);
  vector<int> T = enum_div(gcd);
  // for (auto x: T) {
  //   cout << x << endl;
  // }
  cout << T[T.size() - c] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "1" << endl;
    }else if (n%2==0){
        cout << "0.5" << endl;
    }else{
        cout << (n+1.0)/(2.0*n) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n,m=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
s=sum(a)
ans=0
for i in a:
    if(i<(s/(4*m))):
        continue
    ans+=1
if(ans>=m):
    print("Yes")
else:
    print("No")


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

int main() {

    double W, H, x, y;
    cin >> W >> H >> x >> y;

    if (x == W / 2 && y == H / 2) {
        cout << W * H / 2 << " ";
        cout << 1 << endl;
    }
    else {
        cout << W * H / 2 << " ";
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int count_number(void);

int main(void)
{
    
    int a[15];//15は適当　要素数はわからないが配列を作りたかった
    int b[15];
    int dataset_number = 0;
    while (1) {
        scanf("%d %d", &a[dataset_number], &b[dataset_number]);
        if (a[dataset_number] == 0 && b[dataset_number] == 0) {
            break;
        }
        dataset_number++;
    }
    int j = 0;
    while(j < dataset_number-1){
        int leapyear_number = 0;
        int i = a[j];
        while (i <= b[j]) {
            if ((((i % 4) == 0) && ((i % 100) != 0)) || ((i % 400) == 0)) {
                printf("%d\n", i);
                leapyear_number++;
            }
            i++;
        }
        if (leapyear_number == 0){
            printf("NA\n\n");
        } else {
            printf("\n");
        }
        j++;    
    }
    //j=dataset_number-1の時のみ最後\がひとつ
    if(dataset_number > 0){
        int leapyear_number = 0;
        int i = a[dataset_number-1];
        while (i <= b[dataset_number-1]) {
            if ((((i % 4) == 0) && ((i % 100) != 0)) || ((i % 400) == 0)) {
                printf("%d\n", i);
                leapyear_number++;
            }
            i++;
        }
        if (leapyear_number == 0){
            printf("NA\n");
        } else {
            
        }
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif

struct Edge
{
	ll vertex;
	Edge(ll v)
	{
		vertex = v;
	}
};

using Graph = vector<vector<Edge>>;

Graph g;
vector<ll> memo;
vector<ll> ans;
vector<ll> p, x;

void DFS(ll v, ll r, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	for (const auto& e : g[v])
	{
		if (e.vertex == r)
			continue;

		DFS(e.vertex, v, ans);
	}
}

int main(void)
{
	ll n, q; cin >> n >> q;

	ll u, v;
	g.resize(n);
	rep(ei, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(Edge(v));
		g[v].push_back(Edge(u));
	}

	p.resize(q);
	x.resize(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	memo.resize(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	ans.resize(n);
	ans[0] = memo[0];
	DFS(0, -1, ans);

	for(auto& e: ans)
		cout << e << " ";

	return 0;
}


Measured memory_bytes: 28928
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int main() {
  int n; cin >> n;
  vector<int> b(n-1);
  rep(i, n-1) cin >> b[i];

  int ans = 0;
  rep(i, n){
    if(i==0) ans += b[0];
    else if(i == n-1) ans += b[i-1];
    else {
      ans += min(b[i-1], b[i]);
    }
  }

  cout << ans << endl;
}


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

using namespace std;



int main()
{
    int n;
    cin >> n;
    //city,score,num
    vector<tuple<string, int, int>> a;
    for (int i = 0; i < n;i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s, p, i));
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n;i++){
        cout << get<2>(a[i])+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a, b;
    cin >> a >> b;
    
    out(a * b - a - b + 1);
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
#include<ctype.h>


int main (){

int N, K;

char S[100];

scanf("%d", &N);
scanf("%d", &K);

scanf("%s", S);


S[K-1]=tolower(S[K-1]);

printf("%s\n", S);

return 0;

}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n; cin >> n;
    vector<vector<pair<int, int>>> a(n);
    for (int i = 0; i < n; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int x, y; cin >> x >> y;
            a[i].emplace_back(x - 1, y);
        }
    }

    int ans = 0;
    for (int bit = 0; bit < 1 << n; ++bit) {
        bool valid = true;
        for (int i = 0; i < n; ++i) {
            if (bit >> i & 1) {
                // honest
                for (const auto& b : a[i]) {
                    if (b.second != (bit >> b.first & 1)) {
                        valid = false;
                    }
                }
            }
        }

        if (valid) ans = max(ans, __builtin_popcount(bit));
    }

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

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

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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter out;

	static HashMap<Integer, Integer> happyC;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b%a == 0)
			out.println(b+a);
		else
			out.println(b-a);
		
		out.flush();	
	}
	
}
	
class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}

}


Measured memory_bytes: 21332
A, B, C = [int(x) for x in input().split()]
req_fives = 2
req_seven = 1
for x in (A, B, C):
    if x == 5:
        req_fives -= 1
    elif x == 7:
        req_seven -= 1
if req_fives == 0 & req_seven == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61856
//ProblemE

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

pii get_max2(const vector<int>& a, const vector<int>& b) {
	pii res = a[b[0]] > a[b[1]] ? pii{ b[0], b[1] } : pii{ b[1], b[0] };
	for (int i = 2; i < (int)b.size(); i++) {
		int x = b[i];
		if (a[x] >= a[res.first]) {
			res = { x, res.first };
		}
		else if (a[x] >= a[res.second]) {
			res.second = x;
		}
	}
	return res;
}

//ProblemE
void Solve() {
	int n;
	cin >> n;
	int N = 1 << n;
	vector<int> a(N, 0);
	for (int i = 0; i < N; i++) cin >> a[i];

	vector<pii> max2(N, { 0, 0 });
	max2[0] = { 0, 0 };
	for (int i = 1; i < N; i++) {
		set<int> poss{ i };
		int j = i;
		while (j) {
			int mask = j & -j;
			poss.insert(max2[i & ~mask].first);
			poss.insert(max2[i & ~mask].second);
			j &= ~mask;
		}
		max2[i] = get_max2(a, vector<int>(poss.begin(), poss.end()));
	}

	int ans = 0;
	for (int i = 1; i < N; i++) {
		int t = a[max2[i].first] + a[max2[i].second];
		ans = max(ans, t);
		cout << ans << endl;
	}
}


Measured memory_bytes: 6272
using System;
class Program
{
  static void Main(string[] args)
  {
    // 整数の入力
    int n = int.Parse(Console.ReadLine());
    
    // スペース区切りの整数の入力
    string input = Console.ReadLine();
    char[] chararray = input.ToCharArray(); 

    int result = 0;

    for(int i=0; i < n-2; i++){
      if(chararray[i] == 'A'){
        if(chararray[i+1] == 'B'){
          if(chararray[i+2] == 'C'){
            result++;
          }
        }
      }
    }
  
    //出力
    Console.WriteLine(result);
  }
}


Measured memory_bytes: 11092
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-27 14:04:56
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    int n;
    cin >> n ;
    cout << (n+1)*n/2 << endl;
    
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

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

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


Measured memory_bytes: 256
#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 pu push
#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(long long i=0;i<x;i++)
#define repn(i,x) for(long long 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())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long A, long long B){
	cout << N/(A+B)*A+min(N%(A+B),A) << endl;
}

int main(){	
	long long N;
	long long A;
	long long B;
	scanf("%lld",&N);
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(N, A, B);
	return 0;
}



Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

a, b, c, d =  map(int, sys.stdin.readline().split())

if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 66284
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){

	int w[10],k[10];
	int W,K;

	for(int i=0;i<10;i++){
        cin >>w[i];
    }
    for(int i=0;i<10;i++){
        cin >>k[i];
    }
    sort(w,w+10);
    sort(k,k+10);
    W=w[9]+w[8]+w[7];
    K=k[9]+k[8]+k[7];
    cout <<W<<" "<<K<<endl;

	return 0;
}

Measured memory_bytes: 1180
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        int n = input.nextInt();
        int[]A = new int[n];
        int max = 0;
        for(int i = 0; i < n; i++) {
            A[i] = input.nextInt();
            max = max < A[i] ? A[i] : max;
        }
        print(countingSort(A, max));
    }
    
    private int[] countingSort(int[] A, int k) {
        int[] B = new int[A.length];
        int[] C = new int[k+1];
        for (int j = 0; j < A.length; j++) C[A[j]] += 1;
        for (int i = 1; i < k + 1; i++) C[i] = C[i] + C[i-1];
        for (int j = A.length - 1; 0 <= j; j--) {
            B[C[A[j]] - 1] = A[j];
            C[A[j]] = C[A[j]] - 1;
        }
        return B;
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

Measured memory_bytes: 131472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	const int dx[] = {0,1,0,-1};
	const int dy[] = {1,0,-1,0};
	int w,h,d,dir,x,y;
	char commond[16];
	while(scanf("%d%d",&w,&h),w|h){
		dir = 0;
		x = y = 1;
		while(scanf("%s",commond)){
			if( !strcmp(commond,"STOP") )break;
			if( !strcmp(commond,"RIGHT") ){
				dir = (dir+1)%4;
			}else if( !strcmp(commond,"LEFT") ){
				dir = (dir+3)%4;
			}else{
				scanf(" %d",&d);
				if( !strcmp(commond,"FORWARD") ){
					x += d*dx[dir];
					y += d*dy[dir];
				}else{
					x -= d*dx[dir];
					y -= d*dy[dir];
				}
			}
			if( x<1 )x=1;
			if( x>w )x=w;
			if( y<1 )y=1;
			if( y>h )y=h;
			//printf("%s : dir:%d  , %d,%d\n",commond,dir,x,y);
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

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

char rest(char a, char b) {
  if ((a=='R' && b =='G') || (a=='G' && b =='R')) return 'B';
  else if ((a=='B' && b =='G') || (a=='G' && b =='B')) return 'R';
  else if ((a=='B' && b =='R') || (a=='R' && b =='B')) return 'G';
  return ' ';
}

int main() {
  INCANT;
  cin >> N;
  cin >> S;
  rep(i, N) {
    if (S[i]=='R') R.push_back(i);
    if (S[i]=='G') G.push_back(i);
    if (S[i]=='B') B.push_back(i);
  }
  ll ans = 0;
  rep(i, N-2) {
    for (int j=i+1; j<N-1; j++) {
      if (S[i]==S[j]) continue;
      char c = rest(S[i], S[j]);
      int ng = 2*j-i;
      int cnt=0;
      if (c=='R') {
        cnt =upper_bound(ALL(R), j)-R.begin();
        ans+=R.size()-cnt;
      } else if (c=='G') {
        cnt =upper_bound(ALL(G), j)-G.begin();
        ans+=G.size()-cnt;
      }else {
        cnt =upper_bound(ALL(B), j)-B.begin();
        ans+=B.size()-cnt;
      }
      if (ng<N && S[ng]==c) ans--;
      
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3660
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int H[SIZE];
int main(){
    int N;
    R(N);
    FOR(i,1,N){
        R(H[i]);
    }
    for(int i=N-1;i>0;i--){
        if(H[i]>H[i+1])H[i]--;
    }
    FOR(i,2,N){
        if(H[i]<H[i-1]){
            W("No");
            return 0;
        }
    }
    W("Yes");
    return 0;
}


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

typedef pair<string, int> PAIR;

void fnInput(int &argiMaxProc, int &argiQuantum, queue<PAIR> &argqProcess)
{
  cin >> argiMaxProc >> argiQuantum;
  
  for (int i = 0; i < argiMaxProc; i++)
  {
    string sProcName;
    int iProcTime;
    cin >> sProcName >> iProcTime;
    argqProcess.push(PAIR(sProcName, iProcTime));
  }
}

void fnSchedule(int &argiMaxProc, int &argiQuantum, queue<PAIR> &argqProcess)
{
  int iTotalTime = 0;
  while (argqProcess.size())
  {
    PAIR pProcess = argqProcess.front(); argqProcess.pop(); 
    if (pProcess.second > argiQuantum)
    {
      pProcess.second -= argiQuantum;
      argqProcess.push(pProcess);
      iTotalTime += argiQuantum;
    }
    else
    {
      iTotalTime += pProcess.second;
      cout << pProcess.first << " " << iTotalTime << endl;
    }
  }
}

int main()
{
  int iMaxProc, iQuantum;
  queue<PAIR> qProcess;
  
  fnInput(iMaxProc, iQuantum, qProcess);
  fnSchedule(iMaxProc, iQuantum, qProcess);

  return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

#define MOD 1000000007

int n , x , y , z ;
long long dp[ 47 ][ (1<<19) ] ;


void input ( ) {
    scanf ( "%d%d%d%d" , &n , &x , &y , &z ) ;
}

void solve ( ) {
    dp[ 0 ][ 0 ] = 1 ;
    int sr = (1<<(z-1)) + (1<<(y+z-1)) + (1<<(x+y+z-1)) ;
    int lim = (1<<(x+y+z)) ;
    for ( int i = 0 ; i < n ; ++ i ) {
        for ( int j = 0 ; j <= lim ; ++ j ) {
            if ( dp[ i ][ j ] == 0 ) { continue ; }
            for ( int t = 1 ; t <= 10 ; ++ t ) {
                if ( j == lim ) {
                    dp[ i + 1 ][ j ] = ( dp[ i + 1 ][ j ] + dp[ i ][ j ] ) % MOD ;
                }
                else {
                    int nw = ( ( j << t ) | (1<< ( t - 1 ) ) ) & ( lim - 1 ) ;
                    if ( ( nw & sr ) == sr ) { nw = lim ; }
                    dp[ i + 1 ][ nw ] = ( dp[ i + 1 ][ nw ] + dp[ i ][ j ] ) % MOD ;
                }
            }
        }
    }
    printf ( "%d\n" , dp[ n ][ lim ] ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 82176
from fractions import gcd
a,b,c,d = map(int,input().split())
def l(x,y):
    return (x*y)//gcd(x,y)
U = b-a+1
s1 = b//c - (a-1)//c
s2 = b//d - (a-1)//d
s3 = b//l(c,d) - (a-1)//l(c,d)
print(U-(s1+s2-s3))



Measured memory_bytes: 5048
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int L;
	while(scanf("%d", &L), L){
		int M, N;
		int money = 0;
		int ans = -1;
		rep(i, 12){
			scanf("%d%d", &M, &N);
			money += M - N;
			if(ans == -1 && money >= L){
				ans = i + 1;
			}
		}
		if(ans == -1)
			puts("NA");
		else
			printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	println((a + b + c > 21 ? "bust" : "win"));
}

Measured memory_bytes: 256
#include<stdio.h>
int main () {
    int a;
    int b;
    do{
      scanf("%d",&a);
      scanf("%d",&b);

    }while(a<1||b<1||10000<a||10000<b);
    if((a*b)%2==0){
      printf("Even");
    }else printf("Odd");
}

Measured memory_bytes: 128
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

const int INF = 1e9;
const int maxk = 100 * 1000 + 5;

int dist[maxk];

int main()
{
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	fill (dist, dist + k, INF);
	deque <int> d;
	d.push_front(1);
	dist[1] = 1;
	while (!d.empty()){
		int x = d.front();
		if (x == 0)
			return (cout << dist[x] << endl), 0;
		d.pop_front();
		int r;
		if (dist[r = (10*x)%k] > dist[x]){
			dist[r] = dist[x];
			d.push_front(r);
		}
		if (dist[r = (x+1)%k] > dist[x] + 1){
			dist[r] = dist[x] + 1;
			d.push_back(r);
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <queue>
using namespace std;
int a[250010],d[250001],mp[250001];
int dd[4];
queue<pair<int,int>> que0,que1;
void bfs(int s,int n){
    for(int i=0;i<4;i++){
        int nw = s + dd[i];
        if(nw<0 || nw>=n*n) continue;
        que0.push({d[s],nw});
    }
    while(que0.size() || que1.size()){
        while(que0.size()){
            auto p = que0.front(); que0.pop();
            int pos = p.second,dist = p.first;
            if(d[pos]<=dist) continue;
            d[pos] = dist;
            for(int i=0;i<4;i++){
                int nw = pos + dd[i];
                if(nw<0 || nw>=n*n) continue;
                if(mp[pos]==1 && d[nw]>dist + 1) que1.push({dist + 1,nw});
                if(mp[pos]==0 && d[nw]>dist) que0.push({dist,nw});
            }
        }
        if(que1.size()){
            auto p = que1.front(); que1.pop();
            int pos = p.second,dist = p.first;
            if(d[pos]<=dist) continue;
            d[pos] = dist;
            for(int i=0;i<4;i++){
                int nw = pos + dd[i];
                if(nw<0 || nw>=n*n) continue;
                if(mp[pos]==1 && d[nw]>dist + 1) que1.push({dist + 1,nw});
                if(mp[pos]==0 && d[nw]>dist) que0.push({dist,nw});
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,n;
    cin >> n;
    for(i=0;i<n*n;i++){
        cin >> a[i]; a[i]--;
    }
    dd[0] = -1; dd[1] = -n; dd[2] = 1; dd[3] = n;
    for(i=0;i<n*n;i++){
        d[i] = 0; mp[i] = 1;
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            int x = min(i,n - 1 - i);
            int y = min(j,n - 1 - j);
            d[i*n + j] = min(x,y);
        }
    }
    int ans = 0;
    for(i=0;i<n*n;i++){
        ans += d[a[i]];
        mp[a[i]] = 0;
        bfs(a[i],n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6612
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

ll xor_sum(ll num) {
    long long ret;
    if ( num%2 == 0 ) {
        ret = ( (num/2)%2 == 0 ) ? 0 : 1;
        ret ^= num;
    } else {
        ret = ( ((num+1)/2)%2 == 0 ) ? 0 : 1;
    }
    return ret;
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << (xor_sum(A - 1) ^ xor_sum(B)) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define MOD (int)(1e9+7)
using namespace std;

long long mem[1005][1005];
int n,m;
string gr[1005];

int ok(int x,int y)
{
	return (0<=x&&x<n&&0<=y&&y<m);
}

long long go(int x,int y)
{
	if(!ok(x,y)) return 0;
	if(x==n-1&&y==m-1) return 1;
	if(gr[x][y]=='#') return 0;
	if(mem[x][y]!=-1) return mem[x][y];
	return mem[x][y]=(go(x+1,y)+go(x,y+1))%MOD;
}

int main()
{
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> gr[i];
	memset(mem,-1,sizeof mem);
	cout << go(0,0) << endl;
}

Measured memory_bytes: 9216
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int A,B,H,M;

void work(){
    scanf("%d%d%d%d",&A,&B,&H,&M);
//    printf("H = %d, M=%d\n",H,M);
    double theta = 2*pi*(H*1.0/12+M*1.0/60/12-M*1.0/60);
    if(theta<0) theta=theta*(-1.0);
    if(theta>pi) theta = 2.0*pi-theta;
//    printf("theta = %lf\n",theta/2/pi*360);
    double ans=A*1.0*A+B*1.0*B-2.0*A*B*cos(theta);
    printf("%.12lf\n",sqrt(ans));
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll A, B, C;
  cin >> A >> B >> C;
  ll ans = 0;
  ans += min(A + B + 1, C);
  ans += B;
  cout << ans << endl;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
    }

    int g = my_gcd(A[0], A[1]);
    for (int i = 2; i < n; ++i) {
        g = my_gcd(g, A[i]);
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

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

ll a, b;

int main() {
	cin >> a >> b;
	if (a <= 8 && b <= 8) wrln("Yay!");
	else wrln(":(");
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
A = [0] + list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(n-1)]


sys.setrecursionlimit(10**5 + 5)  # 再帰回数の上限！！


M = [[] for i in range(n+1)]
for i in range(n-1):
    M[C[i][0]].append(C[i][1])
    M[C[i][1]].append(C[i][0])


# 0-indexedの場合
V = [0] * (n+1)
# D = [-1] * (n+1)  # 自分を含む、子孫のノード数
ANS = [0] * (n+1)

R = [10**10] * (n+5)

import bisect

R[0] = A[1]
ANS[1] = 1

def des(x):
    # end = 1
    V[x] = 1
    # print(R[:10])


    for i in M[x]:
        if V[i] == 0:
            # print(i)
            # end = 0
            V[i] = 1
            ind = bisect.bisect_left(R, A[i])
            ma = R[ind]
            R[ind] = A[i]
            ANS[i] = bisect.bisect_left(R, 10**10-1)
            des(i)
            R[ind] = ma

    # if end == 1:
    #     print(R)
    #     ANS[x] = bisect.bisect_right(R, 10**10-1)

des(1)

for i in range(1, len(ANS)):
    print(ANS[i])

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

int N, K;
const int MAX_N = 1.0e5;
int x[MAX_N];

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

    int time[N-K+1];
    for (int i = 0; i < N-K+1; i++) {
        int left = abs(x[i]) + abs(x[i+K-1] - x[i]);
        int right = abs(x[i+K-1]) + abs(x[i+K-1] - x[i]);
        time[i] = min(left, right);
    }

    int ans = 1.0e9;
    for (int i = 0; i < N-K+1; i++) {
        ans = min(ans, time[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int n;
  cin >> n;
  deque<int> que;
  rep(i,n){
    int a;
    cin >> a;
    if(n % 2){//odd
      if(i % 2) que.push_back(a);// even
      else      que.push_front(a); //odd
    } else { //even
      if(i % 2) que.push_front(a);// even
      else      que.push_back(a); //odd
    }
  }

  while(que.empty() == false){
    if(que.size() == 1){
      cout << que.front() << endl;
    }else{
      cout << que.front() << ' ';
    }
    que.pop_front();
  }

  return 0;
}


Measured memory_bytes: 2944