akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n;
int izq[MX], der[MX];
ll x, y;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n)
		cin >> der[i] >> izq[i];

	sort(izq, izq + n);
	sort(der, der + n, greater<int>());

	int act = 0;
	forn (i, n) {
		if (izq[i] < act) {
			x += abs(act - izq[i]);
			act = izq[i];
		} else break;

		if (der[i] > act) {
			x += abs(act - der[i]);
			act = der[i];
		} else break;
	}
	x += abs(act);
	
	act = 0;
	forn (i, n) {
		if (der[i] > act) {
			y += abs(act - der[i]);
			act = der[i];
		} else break;

		if (izq[i] < act) {
			y += abs(act - izq[i]);
			act = izq[i];
		} else break;
	}
	y += abs(act);

	cout << max(x, y) << endl;

	return 0;
}


Measured memory_bytes: 1024
def resolve():
    sx, sy, tx, ty = list(map(int, input().split()))
    dx = tx - sx
    dy = ty - sy
    res = "U"*dy+"R"*dx+"D"*dy+"L"*dx+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"
    print(res)


if '__main__' == __name__:
    resolve()



Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=2e5+10;
    int n;
    char S[MAXN];
    int ans[MAXN];
    int r[MAXN];
    int l[MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>S+1;
        n=strlen(S+1);
        r[1]=1;
        l[n]=1;
        for(int u=2;u<=n;u++){
            if(S[u]=='R'&&S[u-1]=='R')r[u]=r[u-1]+1;
            else if(S[u]=='R')r[u]=1;
        }
        for(int u=n-1;u>=1;u--){
            if(S[u]=='L'&&S[u+1]=='L')l[u]=l[u+1]+1;
            else if(S[u]=='L')l[u]=1;
        }
        for(int u=1;u<n;u++){
            if(S[u]=='R'&&S[u+1]=='L'){
                ans[u]+=r[u]/2+l[u+1]/2;
                ans[u+1]+=r[u]/2+l[u+1]/2;
                if(r[u]%2)ans[u]++;
                if(l[u+1]%2)ans[u+1]++;
            }
        }
        for(int u=1;u<=n;u++)
        cout<<ans[u]<<" ";
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 2944
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }

    let mut cnt = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500*i+100*j+50*k==x {
                    cnt += 1;
                }
            }
        }
    }
    println!("{}", cnt);
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    rep(m, N-1) {
        ll left = C * (N - 1 - m) - D*m;
        ll right = -C*m + D * (N - 1 - m);
        if (left <= B-A and B-A <= right) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
(defun fun ()
  (let ((n (read))
	(x 0)
	(ans 0))
    (dotimes (i n)
      (setf x (logior x (read))))
    (loop
      (if (eq (logand x 1) 1) (return))
      (setf ans (1+ ans))
      (setf x (ash x -1)))
    ans))

(format t "~A~%" (fun))


Measured memory_bytes: 12388
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll dp[110][100010];
int main(){
  int n,w;
  cin>>n>>w;
  vector<int>W(n),V(n);
  rep0(i,n)cin>>W[i]>>V[i];
  rep0(i,n){
    rep0(j,w+1){
      if(j + W[i] <= w){
        dp[i+1][j+W[i]] = max(dp[i+1][j+W[i]],dp[i][j] +V[i]);
      }

        dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
    
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}

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

int main() {
  string s = "abcdefghijklmnopqrstuvwxyz";
  char c;
  cin >> c;
  for(int i = 0; i < s.size(); i++){
    if(c==s.at(i)){
      cout << s.at(i+1) <<endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int Num = 0;
		if(N % 100 == 0) {
			Num = (N + 1) * (int)Math.pow(100, D);
		}else {
			Num = N * (int)Math.pow(100, D);
		}
		
		System.out.println(Num);
	}
}


Measured memory_bytes: 22740
#include<iostream>

using namespace std;

int main(){
    // a- b = 2k
    int a,b;
    cin>>a>>b;
    int sum = abs(a-b);
    if(sum%2!=0){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        sum /=2;
        int n = a < b ? b : a;
        cout<<n-sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	cin >> n >> k >> m;
	if(k*m>=n){
		cout << "Yes";
	}else{
		cout << "No";
	}
 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3632
# https://atcoder.jp/contests/arc071/submissions/6325840

from itertools import accumulate

convert = {'A': 1, 'B': 2}
S = tuple(convert[x] for x in input())
T = tuple(convert[x] for x in input())
# 最速:   convert
# 次点:   *A, = map()
# 最下位: A = tuple(map())

acc_s = (0,) + tuple(accumulate(S))
acc_t = (0,) + tuple(accumulate(T))

ans = []
Q = int(input())
for _ in range(Q):
    sl, sr, tl, tr = map(int, input().split())
    # 添え字-1は変数再代入しない方が20ms速い
    ans.append('YES' if ((acc_t[tr] - acc_t[tl - 1]) - (acc_s[sr] - acc_s[sl - 1])) % 3 == 0 else 'NO')

print(*ans, sep='\n')
# 逐次printだと1000ms
# 一括だと500ms


Measured memory_bytes: 15768
def solve():
    from sys import stdin
    f_i = stdin
    
    n = f_i.readline()
    A = f_i.readline().split()
    q = int(f_i.readline())
    for i in range(q):
        b, e = map(int, f_i.readline().split())
        r = A[b:e]
        r.reverse()
        A = A[:b] + r + A[e:]
    print(' '.join(A))

solve()


Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
struct Tree {
    vector<long long> distances;
    vector<bool> passed;
    vector<vector<int> > edges;

    explicit Tree(int n) {
        distances.resize(n + 1, 0);
        passed.resize(n+1);
        edges.resize(n + 1);
    }

    void connect(int a, int b) {
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }

    void bfs(int root) {
        passed[root] = true;
        queue<int> current;
        current.push(root);
        while (!current.empty()) {
            int a = current.front();
            for (const auto b : edges[a]) {
                if (!passed[b]) {
                    distances[b] += distances[a];
                    current.push(b);
                    passed[b] = true;
                }
            }
            current.pop();
        }
    }
};
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    Tree tree(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        tree.connect(a, b);
    }
    for (int i = 0; i < Q; ++i) {
        int p, q;
        cin >> p >> q;
        tree.distances[p] += q;
    }
    tree.bfs(1);
    for (int j = 1; j <= N; ++j) {
        printf("%lld%c", tree.distances[j], j == N ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 16372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;


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

	LL g[n][n];

	
	vector<vector<LL>> adj(n);

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			char c;
			cin >> c;
			g[i][j] = c-'0';
			if (g[i][j]) {
				adj[i].push_back(j);
			}
		}
	}


	vector<int> side(n, -1);
	bool is_bipartite = true;
	queue<LL> q;
	for (LL st = 0; st < n; ++st) {
		if (side[st] == -1) {
			q.push(st);
			side[st] = 0;
			while (!q.empty()) {
				LL v = q.front();
				q.pop();
				for (LL u : adj[v]) {
					if (side[u] == -1) {
						side[u] = side[v] ^ 1;
						q.push(u);
					} else {
						is_bipartite &= side[u] != side[v];
					}
				}
			}
		}
	}

	if (is_bipartite) {
		// Find largest "shortest path" between any two nodes
		// answer is this distance + 1
		LL d[n][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				d[i][j] = g[i][j];
				if (d[i][j] == 0) {
					d[i][j] = 10000000;
				}
			}
		}

		for (int i = 0; i < n; ++i) {
			d[i][i] = 0;
		}
		for (int k = 0; k < n; ++k) {
   			for (int i = 0; i < n; ++i) {
        		for (int j = 0; j < n; ++j) {
            		d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 
        		}
    		}
		}

		LL mx = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (d[i][j] <= 1000) {
					mx = max(mx, d[i][j]+1);
				}
			}
		}
		cout << mx << endl;
	}
	else {
		cout << "-1\n";
	}

	 
}

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

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

  vector<int> a(n);
  for (auto &i : a) cin >> i;

  int sum = 0;
  bitset<4101010> dp;
  dp[0] = 1;

  for (int i = 0; i < n; ++i) {
    sum += a[i];
    dp |= (dp << a[i]);
  }

  for (int i = (sum + 1) / 2;; ++i) {
    if (dp[i]) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc084/tasks/abc084_d

import sys
input=sys.stdin.readline
            
def main():
    sv=[1]*(10**5+1)
    sv[0]=0
    sv[1]=0
    for i in range(int(10**5)+1):
        if sv[i]==0:
            continue
        k=2
        while(k*i<=10**5):
            sv[k*i]=0
            k+=1

    Q=int(input())
    LRs=[tuple(map(int,input().split())) for i in range(Q)]
    like17=[]
    for i in range(1,10**5+1,2):
        if sv[i]!=0 and sv[int((i+1)//2)]!=0:
            like17+=[i]
            
    imo=[0]*(10**5+1)
    for i in range(len(like17)):
        imo[like17[i]+1]=1
    for i in range(10**5):
        imo[i+1]+=imo[i]
    
    for lr in LRs:
        l=lr[0]
        r=lr[1]
        print(imo[r+1]-imo[l])
        
    
if __name__=="__main__":
    main()


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

typedef long long ll;

int const N = 5e5 + 7;
ll const mod = 1e9 + 7;
ll fact[N];

inline ll add(ll x, ll y)
{
	return (x + y) % mod;
}

inline ll mul(ll x, ll y)
{
	return (x * y) % mod;
}

inline ll fpow(ll x, ll y)
{
	ll res = 1;
	while (y)
	{
		if (y & 1) res = mul(res, x);
		x = mul(x, x);
		y = (y >> 1);
	}
	return res;
}


inline ll choose(ll n, ll k)
{
	return mul(mul(fact[n], fpow(fact[k], mod-2)), fpow(fact[n-k], mod-2));
}

inline ll perm(ll n, ll k)
{
	return mul(fact[n], fpow(fact[n-k], mod-2));
}

int main()
{
	fact[0] = 1;
	for (int i = 1; i <= 5e5; ++i)
		fact[i] = mul(i, fact[i-1]);

	int n, m;
	cin >> n >> m;

	ll res = 0;
	for (int k = 0; k <= n; ++k)
	{
		ll tmp = mul(perm(m-k, n-k), perm(m-k, n-k));
		tmp = mul(tmp, perm(m, k));
		tmp = mul(tmp, choose(n, k));

		if (k % 2) res = add(res, mul(tmp, mod-1));
		else res = add(res, tmp);
	}
	cout << res << '\n';
	return 0;		
}

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


bool linear(vector<int> a,int n,int key);

int main(){
    int x,y;
    int z=0;
    cin>>x;
    vector<int> a(x);
    rep(i,x) cin>>a.at(i);
    
    cin>>y;
    vector<int> b(y);
    rep(i,y) cin>>b.at(i);
    
    rep(i,y) z+=linear(a,x,b.at(i));
    cout<<z<<endl;
    
    return 0;
}

bool linear(vector<int> a,int n,int key){
    a.push_back(key);
    int k=0;
    while(a.at(k)!=key) k++;
    a.pop_back();
    return k!= n;
}


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

using namespace std;

const int MX = 200000;

int a[MX], l;
long long s[MX + 1];

long long f(int n) {
	s[0] = 0;
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
	
	long long res = 0;
	for (int f = 0; f < n; f++) {
		int N = n - f, p = (N + 1) / 2, q = N / 2;
		long long ans = (s[f + q] - s[f]) * 2 + s[f + p] - s[f + q];
		ans -= 2 * (s[n] - s[n - p + 1]) + s[n - p + 1] - s[n - q];
		ans += l * (N - 1ll);
		
		/*
		long long ans = 0;
		for (int i = f, j = n - 1, p = 0; i <= j; i++, j--) {
			ans += a[i] - p;
			p = a[i];
			if (i != j) {
				ans += p - (a[j] - l);
				p = a[j] - l;
			}
		}
		*/
		
		res = max(res, ans);
	}
	
	return res;
}

int main() {
	int n;
	ignore = scanf("%d %d", &l, &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d", a + i);
	
	long long ans = f(n);
	
	reverse(a, a + n);
	for (int i = 0; i < n; i++) a[i] = l - a[i];
	
	ans = max(f(n), ans);

	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()

if H%3==0 or W%3==0:
    print(0)
    exit()

H, W = max(H, W), min(H, W)

a = H // 3
bc = H - a
ans1 = max(abs(bc*ceil(W, 2)-a*W), abs(bc*(W//2)-a*W))
a = ceil(H, 3)
bc = H - a
ans2 = max(abs(bc*ceil(W, 2)-a*W), abs(bc*(W//2)-a*W))

H, W = min(H, W), max(H, W)

a = H // 3
bc = H - a
ans3 = max(abs(bc*ceil(W, 2)-a*W), abs(bc*(W//2)-a*W))
a = ceil(H, 3)
bc = H - a
ans4 = max(abs(bc*ceil(W, 2)-a*W), abs(bc*(W//2)-a*W))

ans5 = abs(ceil(W, 3)*H-W//3*H)
ans6 = abs(ceil(H, 3)*W-H//3*W)

print(min(ans1, ans2, ans3, ans4, ans5, ans6))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int[] a = new int[101];
		while (sc.hasNext()) {
			int i = sc.nextInt();
			a[i]++;
			if (a[i] > a[0]) {
				a[0] = a[i];
			}
		}

		for (int i=1; i <= 100; i++) {
			if (a[i] == a[0]) {
				System.out.println(i);
			}
		}
	}

}

Measured memory_bytes: 26248
n = int(input())
zorome = 0
yes = False

for i in range(n):
  x, y = map(int, input().split())
  if x == y:
    zorome += 1
    if zorome >= 3:
      yes = True
  else:
    zorome = 0

if yes:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
w,h,n = map(int,input().split())
grid = [[1 for i in range(w)] for k in range(h)]

for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(h):
            for k in range(x):
                grid[j][k] = 0
    elif a == 2:
        for j in range(h):
            for k in range(x,w):
                grid[j][k] = 0
    elif a == 3:
        for j in range(y):
            for k in range(w):
                grid[j][k] = 0
    elif a == 4:
        for j in range(y,h):
            for k in range(w):
                grid[j][k] = 0

counter = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == 1:
            counter += 1
print(counter)

Measured memory_bytes: 3192
N = int(input())
def get(n, item):
    i = 0
    while n%item==0:
        n = n/item
        i += 1
    return i
def get2(n):
    l = []
    target = [3,5,7,11,13]
    for item in target:
        l.append(get(n,item))
        if not l: continue
    m = 1
    for item in l:
        m *= (item+1)
    if m == 8:
        return 1
    else:
        return 0

out = 0
for n in range(105, N+1, 2):
    tmp = get2(n)
    out += tmp
#     if tmp: print(n)
print(out)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int i,s;
  char x[1001];
  while(scanf("%s\n",&x),x[0]!='0'){
      s=0;
      for(i=0;x[i]!='\0';i++){
          s+=x[i]-'0';
      }
      printf("%d\n",s);
  }
  return 0;  
}


Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>
#include <bitset>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 2005;

int n, ar[N], sum;

bitset <4000001> old, dp;

main ()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d", &ar[i]), sum += ar[i];

    dp[0] = 1;

    for (int i = 1; i <= n; i++)
    {
        dp |= (dp << ar[i]);
    }
    for (int i = (sum + 1) / 2; i <= sum; i++)
    {
        if (dp[i])
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//string e = " Eve";
int n;


int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    cin >> n;
 cout<< "Christmas";
  REP(i,25 - n){
    cout << " Eve" ;
  }
  cout<<endl;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
const int MaxN = 1e5 + 5;
int n, x;
int t = 100000;
int main()
{
	int a;
	int ans = 0;
	int sum = 0;
	scanf("%d %d", &n, &x);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a);
		sum = sum + a;
		t = min(t, a);
	}
	x = x - sum;
	ans = n + x / t;
	printf("%d\n", ans);
}
		


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

namespace ConsoleApp2
{
    public class Program
    {

        static long D = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int[] NK = Read(Console.ReadLine());
            long N = NK[0];
            long K = NK[1];
            int[] Hs = Read(Console.ReadLine());

            Array.Sort(Hs);

            long atkNum = 0;
            long special = 0;

            for (int i = 0; i<Hs.Length; i++)
            {
                int index = Hs.Length - i-1;
                if (special < K)
                {
                    special++;
                }
                else
                {
                    atkNum += Hs[index];
                }
            }

            Console.WriteLine(atkNum);

            Console.ReadLine();
        }


        private static int[] Read(string input)
        {
            string[] aaa = input.Split(' ');
            int num = aaa.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(aaa[i]);
            }
            
            return ints;
        }


    }


}


Measured memory_bytes: 34908
#include<cstdio>
using namespace std;
int main()
{
	int a[3],sum=0,sum1=0;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);   
	for(int i=0;i<3;i++)
	{
		if(a[i]==5)
		sum++;
		if(a[i]==7)
		sum1++;
	}
	if(sum==2&&sum1==1)
	printf("YES\n");
	else
	printf("NO\n");	return 0;	
} 

Measured memory_bytes: 128
n = int(input())
al = list(map(int, input().split()))
al.sort()
al.append(-1)
cnt = 1
bl = []
for i in range(n):
    if al[i] == al[i+1]:
        cnt += 1
    else:
        bl.append([al[i], cnt])
        cnt = 1
tmp = 0
ans = 0
for j in range(len(bl)):
    tmp = bl[j][1]
    if bl[j-1][0] + 1 == bl[j][0]:
        tmp += bl[j-1][1]
    if j!=len(bl)-1 and bl[j][0] == bl[j+1][0] - 1:
        tmp += bl[j+1][1]

    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 20736
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
map<int,int>g,g1;
int main()
{
  //flash;
  int n;
  cin>>n;
  ll sum=0;
  for (int i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    g[yo]++;
    sum+=yo;
  }
  int q;
  cin>>q;
  while(q--){
    ll val,val1;
    cin>>val>>val1;
    sum-=g[val]*val;
    sum+=g[val]*val1;
    g[val1]+=g[val];
    g.erase(val);
    cout<<sum<<'\n';
  }
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 6572
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = inputStr[0];
  //パラメータNを配列に持ち込む
  var ARR = [];
  for(var i=0 ; i<4 ; i++){
    ARR.push(Number.parseInt(N.substr(i,1)));
  }
  //bit値を0～3迄
  for(var i=0 ; i<8 ; i++){
    var str = "";
    //1桁目
    if( i&1 ){
      str = ARR[0] + "+" + ARR[1]
    } else {
      str = ARR[0] + "-" + ARR[1]
    }
    //2桁目
    if( i&1<<1 ){
      str += "+" + ARR[2]
    } else {
      str += "-" + ARR[2]
    }
    //3桁目
    if( i&1<<2 ){
      str += "+" + ARR[3]
    } else {
      str += "-" + ARR[3]
    }
    //結果判断
    if(eval(str) ===7){
      break;
    }
  }
  console.log(str+"=7");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import sys
import numpy as np

# input処理を高速化する
input = sys.stdin.readline

# 入力
N, W = map(int, input().split())
# sum_vの取りうる上限値
MAX_V = (10**3) * N +1

def knapsack(n, w):
    # dp[i][j] : i番目の品物で価値jの重さの最小値
    dp = np.full([N+1, MAX_V], np.inf)
    dp[0][0] = 0
    for i in range(n):
        w, v = map(int, input().split())
        dp[i+1] = dp[i]
        dp[i+1][v:] = np.minimum(dp[i][v:], dp[i][:-v] + w)
    print(np.max(np.where(dp <= W)))

knapsack(N, W)


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int plan1 = N * A;
  int plan2 = B;
  
  if (plan1 <= plan2){
    cout << plan1 << endl;
  }
  else {
    cout << plan2 << endl;
  }

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N), X(Q), Y(Q);
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < Q; i++) {
		cin >> X[i] >> Y[i];
		X[i]--, Y[i]--;
	}
	cat mod = 1000000007;
	vector<cat> pw2(Q+1, 1);
	for(int i = 1; i <= Q; i++) pw2[i] = pw2[i-1] * 2 % mod;
	vector< vector<cat> > cnt(N, vector<cat>(N, 0));
	for(int i = 0; i < N; i++) for(int j = 0; j < i; j++) cnt[i][j] = 1;
	vector< vector<int> > pw(N, vector<int>(N, Q));
	for(int i = Q-1; i >= 0; i--) {
		int x = X[i], y = Y[i];
		int a = cnt[y][x] * pw2[pw[y][x]-i-1] % mod, b = cnt[x][y] * pw2[pw[x][y]-i-1] % mod;
		cnt[x][y] = cnt[y][x] = (b + a) % mod;
		pw[x][y] = pw[y][x] = i;
		for(int j = 0; j < N; j++) if(x != j && y != j) {
			a = cnt[y][j] * pw2[pw[y][j]-i-1] % mod, b = cnt[x][j] * pw2[pw[x][j]-i-1] % mod;
			cnt[x][j] = cnt[y][j] = (b + a) % mod;
			pw[x][j] = pw[y][j] = i;
		}
		for(int j = 0; j < N; j++) if(x != j && y != j) {
			a = cnt[j][y] * pw2[pw[j][y]-i-1] % mod, b = cnt[j][x] * pw2[pw[j][x]-i-1] % mod;
			cnt[j][x] = cnt[j][y] = (b + a) % mod;
			pw[j][x] = pw[j][y] = i;
		}
	}
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++)
		cnt[i][j] = cnt[i][j] * pw2[pw[i][j]] % mod;
	cat ans = 0;
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) if(A[i] > A[j])
		ans = (ans + cnt[j][i]) % mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 108148
X = input()

X1 = 10*int(X[0]) + int(X[1])
X2 = 10*int(X[2]) + int(X[3])
if (1 <= X1 <= 12) and ((X2 > 12) or (X2 == 0)):
    print("MMYY")
elif ((X1 > 12) or (X1 == 0)) and (1 <= X2 <= 12):
    print("YYMM")
elif (1 <= X1 <= 12) and (1 <= X2 <= 12):
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    vector<Int> a(x), b(y), c(z);

    for (int i = 0; i < x; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < y; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < z; i++) {
        cin >> c[i];
    }

    vector<Int> d;
    for (int i = 0; i < x; i++) {
        for (int k = 0; k < y; k++) {
            d.push_back(a[i] + b[k]);
        }
    }
    sort(d.begin(), d.end(), greater<>());
    sort(c.begin(), c.end(), greater<>());

    vector<Int> ans;
    int ro = min(3000, x * y);
    for (int i = 0; i < ro; i++) {
        for (int k = 0; k < z; k++) {
            ans.push_back(d[i] + c[k]);
        }
    }

    sort(ans.begin(), ans.end(), greater<>());
    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 43240
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }
fn main() {
    input!(x: i32);
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end(), greater<int>());
    queue<int> que;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            que.push(A.at(i));
            continue;
        }
        else {
            ans += que.front();
            que.pop();
            que.push(A.at(i));
            que.push(A.at(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4824
#include <stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    long long ans = 0;

    for (long long i = 1; i <= n; ++i)
    {
        if (i % 3 == 0 || i % 5 == 0) {
		continue;}
        else {
		ans += i;
	}
    }
    printf("%lld",ans);
    return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

const int M = 12720*2+1;

bool dp[80][80][M];
int a[80][80];

#define ok(x) (x) >= 0 && (x) < M

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        int b;
        cin >> b;
        a[i][j] -= b;
    }
    dp[0][0][12720+a[0][0]] = true;
    dp[0][0][12720-a[0][0]] = true;
    for (int i = 1; i < n; i++) for (int k = -12720; k <= 12720; k++) {
        int x = 12720+k+a[i][0], y = 12720+k-a[i][0];
        if ((ok(x) && dp[i-1][0][y]) || (ok(y) && dp[i-1][0][y])) dp[i][0][12720+k] = true;
    }
    for (int j = 1; j < m; j++) for (int k = -12720; k <= 12720; k++) {
        int x = 12720+k+a[0][j], y = 12720+k-a[0][j];
        if ((ok(x) && dp[0][j-1][x]) || (ok(y) && dp[0][j-1][y])) dp[0][j][12720+k] = true;
    }
    for (int i = 1; i < n; i++) for (int j = 1; j < m; j++) {
        for (int k = -12720; k <= 12720; k++) {
            int x = 12720+k+a[i][j], y = 12720+k-a[i][j];
            if ((ok(x) && dp[i-1][j][x]) || (ok(y) && dp[i-1][j][y])) dp[i][j][12720+k] = true;
            if ((ok(x) && dp[i][j-1][x]) || (ok(y) && dp[i][j-1][y])) dp[i][j][12720+k] = true;
        }
    }
    int ans = 1000000000;
    for (int i = 0; i < M; i++) {
        if (dp[n-1][m-1][i]) {
            ans = min(ans, abs(i-12720));
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 158080
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        ans += "0";
      } else if(s.charAt(i) == '1') {
        ans += "1";
      } else {
        if(!(ans.equals(""))) {
          int t = ans.length() - 1;
          if(t > 0) {
            ans = ans.substring(0, t);
          } else {
            ans = "";
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e9+7;

int main(){

    char A = 'A';
    char a = 'a';
    char input;
    cin >>input;

    if (isupper(input)){
        cout << A << endl;
    }else if (islower(input)){
        cout<<a<<endl;
    }


}




Measured memory_bytes: 3624
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		//call answer Method argument 4
		System.out.println(answer(A,B,C,X));

	}

	//need method
	//
	private static int answer(int A,int B,int C,int X)
	{
		int countHowToChoose = 0;
		for(int a = 0;a <= A;a++){
			for(int b = 0;b <= B;b++){
				for(int c = 0;c <= C;c++){
					int xyenQuestion = 500*a+100*b+50*c;
					//System.out.println(xyenQuestion);
					if(xyenQuestion == X){	
					countHowToChoose++;	
					}
				}
			}
		}
		return countHowToChoose;
	}
}



Measured memory_bytes: 21844
import sys
from collections import defaultdict
s = input()
t = input()
d1 = defaultdict(set)
d2 = defaultdict(set)

for i in range(len(s)):
    d1[t[i]].add(s[i])
    d2[s[i]].add(t[i])
    if len(d1[t[i]])>1 or len(d2[s[i]])>1:
        print("No")
        sys.exit()
print("Yes")


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    atcoder::dsu d(N);
    for(int i=0; i<Q; i++)
    {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) d.merge(u, v);
        else cout << d.same(u, v) << '\n';
    }

    return 0;
}


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

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> X(m); rep(i, m) cin >> X[i];
    sort(X.begin(), X.end());
    if(n >= m)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> diff(m-1);
    rep(i, m-1) diff[i] = abs(X[i+1] - X[i]);
    sort(diff.begin(), diff.end());
    //rep(i, m-1) cout << diff[i] << endl;
    int sum = 0;
    rep(i, m - n) sum += diff[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict
MOD = 10**9+7
n = int(input())
dp = [1]
d = defaultdict(list)
cur = int(input())
d[cur].append(0)
for i in range(1,n):
  pre,cur = cur,int(input())
  c = dp[-1]
  if pre != cur and d[cur]:
    c += dp[d[cur][-1]]
  dp.append(c)
  d[cur].append(i)
print(dp[-1]%MOD)

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

int solve(string s){
  int joi=0,ioi=0;
  for(int i=0;i<s.size()-2;i++){
    if(s.substr(i,3)=="JOI")joi++;
    else if(s.substr(i,3)=="IOI")ioi++;
  }
  cout<<joi<<endl;
  cout<<ioi<<endl;
  return 0;
}

int main(){
  string s;
  while(cin>>s){
    solve(s);
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

string s;

int main()
{
  cin >> s;

  rev(i, s.size()) cout << s[i];  cout << endl;

  return 0;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  if(x==2 && y==2){
    cout << "Yes" << endl;
    return 0;
  }else if((x==4 || x==6 || x==9 || x==11)&&(y==4 || y==6 || y==9 || y==11)){
    cout << "Yes" << endl;
    return 0;
  }else if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) && (y==1 || y==3||y==5||y==7 ||y==8||y==10||y==12)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    
    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    
    if (H % h != 0) {
        int a = H, b = -H * (h-1) - 1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i % h == h-1) {
                    cout << b << " ";
                } else {
                    cout << a << " ";
                }
            }
            cout << endl;
        }
    } else {
        int a = W, b = -W * (w-1) - 1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (j % w == w-1) {
                    cout << b << " ";
                } else {
                    cout << a << " ";
                }
            }
            cout << endl;
        }
    }
            
    
    
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
priority_queue<int> pq;
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	ll sum=0;
	vector<int> a(n+1);
	int mx=1e9;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}

	sort(a.begin()+1,a.end());
	for(int i=1; i<n; i++) {
		pq.push(a[i]);
		pq.push(a[i]);
	}
	pq.push(a[n]);
	for(int i=2; i<=n; i++) {
		int u=pq.top();
		pq.pop();
		sum+=u;
	}
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

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

    int n , k;
    cin >> n >> k;

    vector<double> p(18);

    p[0] = 1;
    for (int i = 1 ;i < p.size() ;i++)
        p[i] = p[i - 1] / 2;

    double ans = 0;
    for (int i = 1 ;i <= n ;i++) {
        int cur = i , t = 0;
        while (cur < k)
            t++ , cur *= 2;

        ans += (1.0 / n) * p[t];
    }

    cout << fixed << setprecision(12) << ans;
}

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

int main() {
  int n;
  int sum = 0;
  cin >> n;
  vector<int> mon(n);
  for(int i=0; i<n; i++){
    cin >> mon.at(i);
    sum += mon.at(i);
  }
  int m;
  cin >> m;
  vector<vector<int>> dri(m, vector<int>(2));
  for(int i=0; i<m; i++){
    for(int j=0; j<2; j++){
      cin >> dri.at(i).at(j);
    }
    cout << sum - mon.at(dri.at(i).at(0)-1) + dri.at(i).at(1) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
}

Measured memory_bytes: 35904
#!/usr/bin/env python3
import sys

# a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


def solve(A: int, B: int):
    print(lcm(A, B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == "__main__":
    main()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 5000 + 10;

int n, m, dist[nax][nax], visited[nax][nax];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

bool isvalid(int x, int y)
{
    if(x <= 0 || x > n || y <= 0 || y > m) return false;
    return true;
}
char arr[nax][nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> arr[i][j];
    queue<int> q;
    q.push(1);
    q.push(1);
    visited[1][1] = 1;
    while(!q.empty())
    {
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        for(int i = 0; i < 4; i++)
        {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if(isvalid(xx, yy) == false) continue;
            if(arr[xx][yy] == '#') continue;
            if(visited[xx][yy] == 1) continue;
            visited[xx][yy] = 1;
            dist[xx][yy] = 1 + dist[x][y];
            q.push(xx);
            q.push(yy);
        }
    }
    int distance = dist[n][m];
    distance--;
    int totalmaxblack = n * m - distance;
    int cnt = 0;
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) if(arr[i][j] == '#') cnt++;
    if(dist[n][m] == 0) cout << -1;
    else
    cout << totalmaxblack - cnt - 2;
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    REP(i, n) cin >> a[i]; sort(a.begin(), a.end());
    REP(i, n) cin >> b[i]; sort(b.begin(), b.end());
    REP(i, n) cin >> c[i];

    vector<ll> ab(n);
    REP(i, n) ab[i] = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    vector<ll> s(n); s[0] = ab[0];
    REP(i, n - 1) s[i + 1] = s[i] + ab[i + 1];
    
    ll ans = 0;
    REP(i, n) {
        int idx = lower_bound(b.begin(), b.end(), c[i]) - b.begin() - 1;
        if(idx >= 0) ans += s[lower_bound(b.begin(), b.end(), c[i]) - b.begin() - 1];

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

Measured memory_bytes: 3196
/*****Be Name Khoda*****/

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

#define F first
#define S second
#define Size(x) ((int)x.size())
#define All(x) x.begin() , x.end()

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline long long lcm(long long a , long long b)
{
	return (a * b) / (__gcd(a , b));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	long long ans = 1;
	cin >> n;
	while(n--){
		long long a;
		cin >> a;
		long long x = __gcd(a , ans);
		a /= x;
		ans *= a;
	}
	cout << ans;
}

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

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);}} premain;

#define MIN(a,b) ((a) < (b) ? (a) : (b))

int Q, type;


int main() {
	cin >> Q;
	
	priority_queue<int> Al;
	priority_queue< int, std::vector<int>, std::greater<int> > Ar;
	ll A = 0, B = 0;

	ll a, b;
	cin >> type >> a >> b;
	Al.push(a);
	A = 0;
	B = b;

	REP(i, Q-1) {
		cin >> type;
		if (1 == type) {
			cin >> a >> b;
			if (Al.size() != Ar.size()) { //奇数(Al.topが最小値
				if (a <= Al.top()) {
					A += (Al.top() - a);
					Al.push(a);
					Ar.push(Al.top());
					Al.pop();
				} else {
					A += (a - Al.top());
					Ar.push(a);
				}
			} else { //偶数(Al.topとAr.topの間に入るならそれが最小値
				if (a <= Al.top()) {
					A += (Al.top() - a);
					Al.push(a);
				} else if (Ar.top() <= a) {
					A += (a - Ar.top());
					Ar.push(a);
					Al.push(Ar.top());
					Ar.pop();
				} else {
					Al.push(a);
				}
			}
			B += b;
		} else {
			print(Al.top(), (A + B));
		}
	}
}


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

using namespace std;

int main (void) {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a.at(i);
    }

    for ( int ki = 0; ki < K; ki++ ) {
        vector<int> new_a(N+1);
        /* 累積和の準備 */
        for ( int i = 0; i < N; i++ ) {
            int l = max(0, i - a.at(i));
            int r = min(N, i + a.at(i) + 1);
            new_a.at(l)++;
            new_a.at(r)--;
        }
        /* 累積和にする */
        for ( int i = 0; i < N; i++ ) {
            new_a.at(i+1) += new_a.at(i);
        }
        new_a.pop_back(); // 不要な末尾を消す
        /* a と b が同一のとき、全部の電球の強さがマックス */
        if ( a == new_a )
            break;
        a = new_a;
    }

    for ( int i = 0; i < N; i++ ) {
        cout << a.at(i);
        if ( i != N-1 )
            cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4808
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
int arr[2000005];
int main()
{
	deque<int>s;
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%d",&arr[i]);
	for(int i=1;i<=n;i++)
	{
		if(i<=k)
		{
			s.push_back(i);
		}
		else if(i>k)
		{
			if(arr[i]>arr[s.front()])
			printf("Yes\n");
			else
			printf("No\n");
			s.push_back(i);
			s.pop_front();
		}
	}
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int dfs ( int a, vector<vector<int>> &g ) {
    int cnt = 0;
    for ( auto tmp_num : g[a] ) {
        for ( auto tmp_num2 : g[tmp_num] ) {
            if ( a == tmp_num2 ) {
                ++cnt;
            }
        }
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i,n) {
        int tmp_a;
        cin >> tmp_a;
        --tmp_a;
        g[i].push_back(tmp_a);
    }
    int ans = 0;
    vector<bool> flg(n, false);
    rep(i,n) {
//        cout << dfs(i, g) << endl;
        ans += dfs(i, g);
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 5760