akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll x;
cin >> x;
if(x==0)cout<<"1"<<endl;
else
    cout << "0" << endl;
}

Measured memory_bytes: 3580
// Author : Mohamed Sameh
#include <bits/stdc++.h>
using namespace std ;
const int M = 1e5;
int n, m;
bool vis[M];
vector<int> adj[M];
int ans[M];
void dfs(int u)
{
  vis[u] = 1;
  for (int i : adj[u])
    if (!vis[i])
      dfs(i);
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
      int u, v;
      cin >> u >> v;
      u--;v--;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    int cnt =0;
    for (int i = 0; i < n; i++)
    {
      if (!vis[i])
      {
        dfs(i);
        cnt++;
      }
    }
    if (cnt != 1)
    {
      cout <<"No\n";
      return 0;
    }
    memset(ans, -1, sizeof ans);
    cout <<"Yes\n";
    for (int i : adj[0])ans[i] = 0;
    queue<int> q;
    for (int i : adj[0])
      q.push(i);
    while(!q.empty())
    {
      int cur = q.front();
      q.pop();
      for (int i : adj[cur])
      {
        if (ans[i] == -1)
        {
          ans[i] = cur;
          q.push(i);
        }
      }
    }
    for (int i = 1; i < n; i++)
    {
      cout << ans[i] + 1<<"\n";
    }
}


Measured memory_bytes: 12704
import collections

def bingo(card):
  v = list(card.values())
  bingo = [v[:3], v[3:6], v[6:], 
           v[::3], v[1::3], v[2::3], 
           [v[0], v[4], v[-1]], 
           [v[2], v[4], v[6]]]
  z = [0]*3
  b = [1 if n == z else 0 for n in bingo]
  if 1 in b:
    return "Yes"
  else:
    return "No"

  
card = collections.OrderedDict()
for i in range(3):
  for n in input().split():
    card[n] = 1

while 1:
  try:
    n = input()
    if card.get(n):
  	  card[n] = 0
    
  except:
    break
  
print(bingo(card))

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
	char ch,card[4][14]={false};
	int n,a,i,j,w;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>ch>>a;
		if(ch=='S'){
			card[0][a]=true;
		}
		if(ch=='H'){
			card[1][a]=true;
		}
		if(ch=='C'){
			card[2][a]=true;
		}
		if(ch=='D'){
			card[3][a]=true;
		}
	}
	for(j=0;j<4;j++){
		for(w=1;w<14;w++){
			if(!card[j][w]){
				if(j==0){
					ch='S';
					cout<<"S"<<" "<<w<<endl;
				}if(j==1){
					ch='H';
					cout<<"H"<<" "<<w<<endl;
				}
				if(j==2){
					ch='C';
					cout<<"C"<<" "<<w<<endl;
				}
				if(j==3){
					ch='D';
					cout<<"D"<<" "<<w<<endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const double eps = 1e-6;

int main(){
  ll a;
  double b;
  cin >> a >> b;
  ll c = b * 100 + eps;
  cout << ll(a*c/100) << endl;
}

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

int main()
{
    int n, k;
    long long ans(0);

    cin >> n >> k;

    for (int a(k + 1); a <= n; a++) {
        int pmax = (n + 1) / a - 1;
        ans += (pmax + 1) * (a - k);
        int x = n - (pmax + 1) * a + 1;
        ans += (x >= k ? x - k : 0);
    }

    if (k == 0)
        ans -= n;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	ll n;
	cin >> n;
	int min = 15;
	FOR(i, 1, 100001){
		if(n % i == 0 && i * i <= n) min = 1 + (int)log10((double)(n/i));
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

int main()
{

    long long unsigned int zero = 0, one = 0, n;
    std::string s;

    std::cin >> s;

    n = s.size();
    for(int i = 0;i < n;i++){
        if(s[i] == '0'){
            zero++;
        }
        else{
            one++;
        }
    }

    if(one == 0 || zero == 0){
        std::cout << 0;

        return 0;
    }

    if(zero <= one){
        std::cout << zero * 2;
    }
    else if(one < zero){
        std::cout << one * 2;
    }

    return 0;

}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int a,b;
  
  scanf("%d %d",&a,&b);
  if(a>=13){
    printf("%d\n",b);
  }else if(6<=a){
    printf("%d\n",b/2);
  }else{
    printf("0\n");
  }
  return 0;
}

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

int main(){
    long long lucas[87];
    lucas[0] = 2;
    lucas[1] = 1;

    for(int i=2; i<87; i++){
        lucas[i] = lucas[i-1] + lucas[i-2];
    }

    int n;
    while(scanf("%d",&n)==1){
        printf("%lld\n",lucas[n]);
    }

    return 0;
}


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

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

  vector<P> m(N);
  rep(i, N) {
    int X, H;
    cin >> X >> H;
    m.at(i) = P(X, (H + A - 1) / A);
  }
  sort(m.begin(), m.end());

  queue<P> q;
  ll ans = 0;
  ll acc = 0; // そこまでの爆発により、次のモンスターに対して減らせる体力量
  rep(i, N) {
    int x = m.at(i).first;
    int num = m.at(i).second;
    // qの分の精算
    while (!q.empty() && q.front().first < x) {
      acc -= q.front().second;
      q.pop();
    }

    num -= acc;

    if (num > 0) {
      ans += num;
      acc += num;
      q.push(P(x + 2 * D, num));
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int H, W;

    cin >> H >> W;
    
    vector<vector<char>> data(H+2, vector<char>(W+2));

    for(int i=0; i < H; i++){
        for(int j=0; j < W; j++){
            cin >> data.at(i+1).at(j+1);
        }
    }

    data.at(0).at(0) = '#';

    for(int j=0; j < W+1; j++){
            data.at(0).at(j+1) = '#';
    }

    for(int j=0; j < W+1; j++){
            data.at(H+1).at(j+1) = '#';
    }

    for(int i=0; i < H+1; i++){
            data.at(i+1).at(0) = '#';
    }

    for(int i=0; i < H+1; i++){
            data.at(i+1).at(W+1) = '#';
    }

    for(int i=0; i < H+2; i++){
        for(int j=0; j < W+2; j++){
            cout << data.at(i).at(j);
        }
        cout << endl;
    }    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,i,j;
	cin>>n>>k;
	int h[100005],dp[100005];
	for( i = 1 ; i <= n ; i++ )cin>>h[i];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for( i = 3 ; i <= n ; i++ )
	{
		dp[i]=abs(h[i]-h[i-1]) + dp[i-1];
		for(j=i-2;j>=1 && j>=i-k ; j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
a, b, c = list(map(int, input().split(' ')))
cnt = 0
if a == b == c:
    cnt = a%2-1
else:
    while not (a%2 or b%2 or c%2):
        cnt += 1
        a,b,c=(b+c)/2,(a+c)/2,(a+b)/2

print(cnt)


Measured memory_bytes: 2940
def insertion(A,N):
    for i in range(1,N):
        print(" ".join([str(k) for k in A]))
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v

n=int(input())
A=list(map(int,input().split()))
insertion(A,n)
print(" ".join([str(k) for k in A]))


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n,greater<int>());
    int mid = n/2;
    mid--;
    cout<<arr[mid]-arr[mid+1]<<"\n";
    
}

Measured memory_bytes: 3992
import math
def main():

    x = []
    N, D = map(int, input().split())
    for _ in range(N):
        y = list(map(int, input().split()))
        x.append(y)
    ans = 0
    for i in range(N):
        for j in range(i):
            d1 = 0
            for k in range(D):
                d1 += pow(x[i][k]-x[j][k], 2)
            d1 = math.sqrt(d1)
            if d1 == int(d1): ans += 1
    return ans

if __name__ == '__main__':
    print(main())

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

int main(){
  long w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << (w*h)/2 << (w*h%2==1 ? ".5" : ".0") << ' ' << (x*2==w && y*2==h ? 1 : 0);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int n, a, b ;
  cin >> n >> a >> b ;
  int d = min(a,b) ;
  int e = max(0,a+b-n );
  
  cout <<d<<" "<< e <<endl ;
  


  return 0 ;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations
from math import factorial


def main():
    n,m = map(int,input().split())
    print(n*(n - 1)//2 + m*(m - 1)//2)


if __name__=='__main__':
    main() 

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

using namespace std;

int main(){
	string s;
	int a[26] = {0};
	cin>>s;
	for(auto d : s){
		a[d-'a']++;
		
		}
	string ans = "None"	;
	for(int i = 0; i<26; i++){
		if(a[i]== 0){
			ans = i+'a';
			break;
			}
		}
	cout<<ans;
	return 0;
	}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
long mod=1e9+7,ans=1,fac[1<<17],n,m;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	cin>>n>>m;
	fac[0]=1;
	for(long i=1;i<1<<17;i++)fac[i]=fac[i-1]*i%mod;
	for(int i=2;i*i<=m;i++)
	{
		if(m%i==0)
		{
			long p=0;
			while(m%i==0)m/=i,p++;
			ans=ans*fac[n+p-1]%mod*power(fac[n-1],mod-2)%mod*power(fac[p],mod-2)%mod;
		}
	}
	if(m>1)
	{
		ans=ans*n%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1280
import sys

def main():
    expr = sys.stdin.readline().strip().split(' ')
    stack = []
    
    for i in expr:
        if i == '*' or i == '+' or i == '-':
            n1 = stack.pop()
            n2 = stack.pop()
            ans = eval(n2 + i + n1)
            stack.append(str(ans))
        else:
            stack.append(i)

    print(stack.pop())
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7580
#include <iostream>
#include <vector>
#include <iomanip>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
typedef long long ll;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

    double v;
    v = (l / 3.0) * (l / 3.0) * (l / 3.0);

    cout << setprecision(10) << v << endl;


    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=list(list(map(int,input().split())) for i in range(m))
l=sorted(l, key=lambda x:x[1])

ans=0
count=0

for i in range(m):
  if count<l[i][0]:
    ans+=1
    count=l[i][1]-1
print(ans)


Measured memory_bytes: 65244
n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(map(str, x))
print(o)


Measured memory_bytes: 19144
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  auto m = 10^^5+1, p = primes(m);
  auto pb = new bool[](m);
  foreach (pi; p) pb[pi] = true;

  auto b = new int[](m);
  foreach (i; 1..m) b[i] = pb[i] && pb[(i+1)/2];
  auto bc = cumulativeSum(b);

  int q; readV(q);
  foreach (_; 0..q) {
    int l, r; readV(l, r);
    writeln(bc[l..r+1]);
  }
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}

auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }

pure T[] primes(T)(T n)
{
  import std.algorithm, std.bitmanip, std.conv, std.range;

  auto sieve = BitArray();
  sieve.length((n+1)/2);
  sieve = ~sieve;

  foreach (p; 1..((nsqrt(n)-1)/2+1))
    if (sieve[p])
      for (auto q = p*3+1; q < (n+1)/2; q += p*2+1)
        sieve[q] = false;

  auto r = sieve.bitsSet.map!(to!T).map!("a*2+1").array;
  r[0] = 2;

  return r;
}

pure T factor(T)(T n, const T[] p)
{
  auto ma = nsqrt(n)+1;
  foreach (pi; p)
    if (pi > ma) return n;
    else if (n%pi == 0) return pi;
  return n;
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = 1 << (n.bsr/2+1);
  return iota(1, m).map!"a*a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 4348
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let _: String = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = (n - 1) / (k - 1) + if ((n - k) % (k - 1)) == 0 { 0 } else { 1 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#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;

int main()
{
	string s;
	ll k;

	cin >> s >> k;


	char f = s.at(0);
	bool all = true;

	for (int i = 1; i < s.length(); i++)
	{
		if (f != s.at(i))
		{
			all = false;
			break;
		}
	}

	if (all)
	{
		cout << s.length() * k / 2;
		return 0;
	}

	ll l = 0, r = 0;

	while (f == s.at(l))
	{
		l++;
	}
	while (f == s.at(s.length() - 1 - r))
	{
		r++;
	}

	
	ull cnt = 0;
	for (int i = 1; i < s.length(); i++)
	{
		if (s.at(i - 1) == s.at(i))
		{
			cnt++;
			i++;
		}
	}

	ull res = k * cnt;

	if (r > 0)
	{
		res += ((l + r) / 2 - r / 2 - l / 2) * (k - 1);
	}


	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
   string s;
   cin >> s;
   sort(all(s));
   bool ok = true;
   rep(i, s.size()-1){
       if(s[i] == s[i+1])ok = false;
   } 
   cout << (ok ? "yes" : "no") << endl;
}


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

int N, M;

inline string showbit(int n)
{
    string bits;
    for (int i = 0; i < N; i++) {
        bits.push_back('0' + (n % 2));
        n /= 2;
    }
    reverse(bits.begin(), bits.end());
    return bits;
}

int main()
{
    while (true) {
        cin >> N >> M;
        if (N == 0 and M == 0) {
            break;
        }
        vector<int> bed(N);
        for (int i = 0; i < N; i++) {
            cin >> bed[i];
        }
        vector<int> d(M);
        for (int i = 0; i < M; i++) {
            cin >> d[i];
        }
        sort(d.begin(), d.end());
        const int maximum = (1 << N);
        constexpr int INF = (1 << 28);
        vector<int> sum(maximum, 0);
        for (int i = 1; i < maximum; i++) {
            int num = i;
            int pop = 0;
            while (num % 2 == 0) {
                num /= 2;
                pop++;
            }
            sum[i] = sum[i - (1 << pop)] + bed[pop];
        }


        vector<vector<int>> dp(M, vector<int>(maximum, INF));
        vector<vector<int>> dpmin(M, vector<int>(maximum, INF));
        for (int j = 0; j < maximum; j++) {
            dp[0][j] = abs(d[0] - sum[j]);
        }
        for (int i = 1; i < M; i++) {
            for (int j = 0; j < maximum; j++) {
                dpmin[i][j] = dp[i - 1][j];
            }
            for (int j = 0; j < maximum; j++) {
                for (int k = 0; k < N; k++) {
                    if ((j >> k) & 1) {
                        dpmin[i][j] = min(dpmin[i][j], dpmin[i][j - (1 << k)]);
                    }
                }
            }
            for (int j = 0; j < maximum; j++) {
                const int score = abs(d[i] - sum[j]);
                dp[i][j] = min(dp[i][j], dpmin[i][j] + score);
            }
        }

        int mini = INF;
        for (int i = 0; i < maximum; i++) {
            mini = min(mini, dp[M - 1][i]);
        }
        cout << mini << endl;
    }
    return 0;
}

Measured memory_bytes: 28932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var A = input[0];
            var B = input[1];
            var H = input[2];
            var M = input[3];

            var H2 = H * 30 + M * 0.5;
            var M2 = M * 6;

            var kakudo = Math.Abs(H2 - M2);

            if (kakudo > 180)
            {
                kakudo = 360 - kakudo;
            }

            var ans = Math.Sqrt(Math.Pow(A, 2) + Math.Pow(B, 2) - 2 * A * B * Math.Cos(kakudo * (Math.PI / 180)));

            Console.WriteLine(ans);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28632
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m;
int pir[200000];
int md[200000];
int main(){
  vector<int> vec;
  int ans=0;
  cin>>n>>m;
  rep(i,n) {
    int x;
    cin>>x;
    vec.PB(x);
  }
  SORT(vec);
  rep(i,n){
    md[vec[i]%m]++;
    if(i+1<n&&vec[i]==vec[i+1]){
      md[vec[i]%m]++;
      pir[vec[i]%m]++;
      i+=1;
    }
  }

  rep(i,m){
    cerr<<" "<<md[i];
  }
  cerr<<endl;
  rep(i,m){
    cerr<<" "<<pir[i];
  }
  cerr<<endl;

  ans += md[0]/2;
  reps(i,1,(m+1)/2){
    int l = (md[i] < md[m-i]) ? i : m-i;
    int r = (md[i] < md[m-i]) ? m-i : i;
    cerr<<"!"<<i<<" "<< md[l] + min((md[r]-md[l])/2, pir[r])<<endl;;
    ans += md[l] + min((md[r]-md[l])/2, pir[r]);
  }
  if(m%2==0) {
    ans += md[m/2]/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1528
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??£?¨?
		char temp; //char????????????????????´???
		int [] table = new int[26]; //??¢?????????????????????26???????????¨?????????
		//??°?????????
		while(sc.hasNext()){
			//?????????(??±???)?????????
			String line = sc.nextLine();
			//??¨???????????????????°???????????????´
			String lower = line.toLowerCase();
			//?????????????????????
			for(int i =0; i < lower.length(); i++){
				//?°??????????char????????????
				temp = lower.charAt(i);
				//System.out.print(temp+ " ");
				//??¢??????????????????????°???????????????°????????????
				if('a' <= temp  && temp  <= 'z'){
					table[temp - 'a']++;
				}
			}
		}
		//???????????????????????°?????????
		for(int i = 0; i < table.length; i++){
			//?????£??????????????´ a : ??????????????° ??¨???
			System.out.println( (char )('a' + i)+ " : "+ table[i]);
		}
	}
}

Measured memory_bytes: 26232
main :: IO ()
main = do
  [n, o] <- map read . words <$> getLine
  let
    l = [[x, y, n - x - y] | x <- [0..n], y <- [0..n-x]]
    ans = filter (\(x:y:z:_) -> 10000 * x + 5000 * y + 1000 * z == o) l
  if null ans
    then putStrLn "-1 -1 -1"
    else putStrLn $ unwords $ map show $ head ans

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int N, W; cin >> N >> W;
    ll w[N+100], v[N+100]; for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(N+100, vector<ll>(W+100, 0));
    for(int i = 0; i < N; i++){
        for(int sum_w = 0; sum_w <= W; sum_w++){
            
            if(sum_w - w[i] >= 0){
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 157824
#include <iostream>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>

typedef long long ll;

using namespace std;

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

	(n >= 30) ? cout <<"Yes\n" : cout <<"No\n";

	return 0;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int maxn = 1e5 + 5;
const int siz = 131072;
const ll INF = 1e18;

int n, m;
ll dis[(siz << 2) + maxn];
vector<pii> g[(siz << 2) + maxn];

class SegmentTree{
public:
	int mode;
	int base;
	inline void build(int x, int l, int r){
		if(l == r){
			if(mode){
				//if(l == n - 1) printf("NOTE: %d %d\n", siz + l, x + base);
				g[siz + l].PB(MP(x + base, 0));
			}
			return;
		}
		int md = l + r >> 1;
		build(x << 1, l, md);
		build(x << 1 | 1, md + 1, r);
		if(mode){
			g[(x << 1) + base].PB(MP(x + base, 0));
			g[(x << 1 | 1) + base].PB(MP(x + base, 0));
		}
		else{
			g[x + base].PB(MP((x << 1) + base, 0));
			g[x + base].PB(MP((x << 1 | 1) + base, 0));
		}
		return;
	}
	inline void init(int _mode){
		mode = _mode;
		base = mode * (siz << 1) - 1;
		if(base < 0) base = 0;
		build(1, 0, siz - 1);
		return;
	}
	inline void update(int x, int l, int r, int s, int t, int y, int k){
		//printf("base = %d x = %d l = %d r = %d\n", base, x, l, r);
		if(l >= s && r <= t){
			//printf("u = %d v = %d w = %d mode = %d l = %d r = %d s = %d t = %d\n", x + base, y, k, mode, l, r, s, t);
			if(mode) g[base + x].PB(MP(y, k));
			else g[y].PB(MP(base + x, k));
			return;
		}
		int md = l + r >> 1;
		if(s <= md) update(x << 1, l, md, s, t, y, k);
		if(t > md) update(x << 1 | 1, md + 1, r, s, t, y, k);
		return;
	}
}segIn, segOut;

inline int ID(int u){
	if(u <= (siz << 1) - 1) return u;
	if(u < (siz << 2) - 1) return u - (siz << 1);
	return u - ((siz << 2) - 1);
}

inline void dijkstra(int s){
	//printf("s = %d\n", s);
	FOR(i, 0, (siz << 2) + maxn) dis[i] = INF;
	dis[s] = 0;
	priority_queue<pli, vector<pli>, greater<pli> > que;
	que.PH(MP(0, s));
	while(!que.empty()){
		pli p = que.top(); que.pop();
		int u = p.snd;
		ll d = p.fst;
		//printf("u = %d %d d = %lld\n", u, ID(u), d);
		if(d != dis[u]) continue;
		FOR(i, 0, g[u].size()){
			int v = g[u][i].fst;
			int w = g[u][i].snd;
			if(dis[v] > dis[u] + w){
				//printf("u = %d %d v = %d %d w = %d\n", u, ID(u), v, ID(v), w);
				dis[v] = dis[u] + w;
				que.PH(MP(dis[v], v));
			}
		}
	}
	return;
}

int main(){
	scanf("%d%d", &n, &m);
	segIn.init(0);
	segOut.init(1);
	int tot = (siz << 2) - 1;
	FOR(i, 0, m){
		int l, r, c; scanf("%d%d%d", &l, &r, &c); --l; --r;
		segIn.update(1, 0, siz - 1, l, r, i + tot, c);
		segOut.update(1, 0, siz - 1, l, r, i + tot, 0);
	}
	dijkstra(siz * 3 - 1);
	if(dis[siz + n - 1] != INF) printf("%lld\n", dis[siz + n - 1]);
	else puts("-1");
	return 0;
}

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

int main()
{
    int N, K;
    cin>>N>>K;
    vector<vector<int>> B(2*K, vector<int>(2*K));
    vector<vector<int>> W(2*K, vector<int>(2*K));
    for (int i=0; i<N; i++)
    {
        int x, y;
        char c;
        cin>>x>>y>>c;
        (c=='B' ? B : W)[y%(2*K)][x%(2*K)]++;
    }
    vector<vector<int>> Bs(2*K+1, vector<int>(2*K+1));
    vector<vector<int>> Ws(2*K+1, vector<int>(2*K+1));
    for (int y=0; y<2*K; y++)
    {
        vector<int> Br(2*K+1);
        vector<int> Wr(2*K+1);
        for (int x=0; x<2*K; x++)
        {
            Br[x+1] = Br[x]+B[y][x];
            Wr[x+1] = Wr[x]+W[y][x];
            Bs[y+1][x+1] = Bs[y][x+1] + Br[x+1];
            Ws[y+1][x+1] = Ws[y][x+1] + Wr[x+1];
        }
    }

    int ans = 0;
    for (int ky=0; ky<K; ky++)
    for (int kx=0; kx<K; kx++)
    {
        int a = Bs[ky][kx]
              + Bs[ky+K][kx+K] - Bs[ky+K][kx] - Bs[ky][kx+K] + Bs[ky][kx]
              + Bs[2*K][kx] - Bs[ky+K][kx]
              + Bs[ky][2*K] - Bs[ky][K+kx]
              + Bs[2*K][2*K] - Bs[ky+K][2*K] - Bs[2*K][kx+K] + Bs[ky+K][kx+K]
              -
              (Ws[ky][kx]
              + Ws[ky+K][kx+K] - Ws[ky+K][kx] - Ws[ky][kx+K] + Ws[ky][kx]
              + Ws[2*K][kx] - Ws[ky+K][kx]
              + Ws[ky][2*K] - Ws[ky][K+kx]
              - Ws[ky+K][2*K] - Ws[2*K][kx+K] + Ws[ky+K][kx+K]);
        ans = max(ans, max(a, N-a));
    }
    cout<<ans<<endl;
}


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

int main()
{

    int N;
    string S;
    cin >> N;
    cin >> S;

    for (int i = 0; i < S.size(); i++) {
        int tmp = S[i] + N;
        if (tmp > 'Z') tmp = tmp - 'Z' + 'A' - 1;
        S[i] = (char)(tmp);
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            //まずは数字を読む
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int sum = 0;
            int output = 0;

            //全部の和を求める
            for(int i = 0; i < n; i++)
            {
                sum += int.Parse(input[i]);
            }

            //頭から数を引いていく
            for (int i = 0; i < n; i++)
            {
                sum -= 2 * int.Parse(input[i]);

                if(sum == 0) //0なら決まり
                {
                    output = 0;
                    break;
                }
                else if(sum < 0) //負のとき
                {
                    int sum2 = sum + 2 * int.Parse(input[i]);

                    //その2つで比較
                    if (Math.Abs(sum) < sum2)
                        output = Math.Abs(sum);
                    else
                        output = sum2;

                    break;

                }
                        
            }  

            Console.WriteLine(output);


        }
    }

Measured memory_bytes: 11092
m, d = map(int, input().split())
result = 0
for i in range(4, m + 1):
  for j in range(22, d + 1):
    d10 = j // 10
    d1 = j % 10
    if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
      result += 1
print(result)


Measured memory_bytes: 2940
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
cnt = 0

def bisect(l,i,n):
    left = 0
    right = n
    while left < right:
        mid = int((left + right)//2)
        if l[mid] == i:
            return 1
        else:
            if i < l[mid]:
                right = mid
            else:
                left  = mid+1
    return 0

for j in range(q):
    cnt += bisect(s,t[j],n)
    
print(cnt)
    


Measured memory_bytes: 16708
s = gets
as = s.split("")
i = 1
ans = "Yes"
as.each{ |n|
    if (i % 2 == 0)
      if (n == "R") then ans = "No" end
    else
      if (n == "L") then ans = "No" end
    end
    i += 1
}
puts "#{ans}"

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; 
int main(){
	int n,i;
	cin>>n;
	int a[100005];
	a[0]=0;
	long long x=0,y=0;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+(n+1));
	for(i=n;i>=1;i--){
		if(a[i]==a[i-1]){
			x=a[i];
			break;
		}
	}
	for(int j=i-2;j>=1;j--){
		if(a[j]==a[j-1]){
			y=a[j];
			break;
		}
	}
	cout<<x*y<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//
int color[MAX];
int ch[2] = {1, 0};
//----------//

void solve(vector<pair<int, int> > v[], int p, int k, int c){
    color[k] = c;

    for(pair<int, int> f : v[k]){
        int nextNode = f.first;
        int weight = f.second;
        int nextC = weight%2==0 ? c : ch[c];
        if(nextNode == p)continue;
        solve(v, k, nextNode, nextC);
    }
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    vector<pair<int, int> > vv[MAX];
    rep(i, n-1){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        vv[u].push_back(make_pair(v, w));
        vv[v].push_back(make_pair(u, w));
    }
    solve(vv, -1, 0, 0);

    rep(i, n){
        if(i)cout << " ";
        cout << color[i];
    }
    cout << endl;

    
    return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[10],b[10],ans=-9223372036854775807;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main()
{
	a[1]=read();
	a[2]=read();
	b[1]=read();
	b[2]=read();
	for(register int i=1;i<=2;i++)
		for(register int j=1;j<=2;j++)
		{
			LL x=a[i]*b[j];
			if(x>ans)
				ans=x;
		}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()
	d := sc.NextInt()

	x := c - a
	y := d - b

	fmt.Printf("%d %d %d %d\n", c-y, d+x, a-y, b+x)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll N) {
  int result = 1;
  for (int i = 1; i <= N; i = i << 1) {
    result = i;
  }
  cout << result << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
		printf("a < b\n");
	}
	else{
		if(a>b){
			printf("a > b\n");
		}
		else{
			printf("a == b\n");
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	long long count1, count2;
	count1=count2=0;
	for(int i=k;i<=n;i+=k)
	{
		count1++;
	}
	if(k%2==0)
	{
		for(int i=k/2;i<=n;i+=k)
		{
			count2++;
		}
	}
	cout<<(long long)count1*count1*count1+count2*count2*count2<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC019
{
    public class A
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var Q = long.Parse(input[0]) * 4;
            var H = long.Parse(input[1]) * 2;
            var S = long.Parse(input[2]);
            var D = long.Parse(input[3]);
            var N = long.Parse(Console.ReadLine().Trim());

            var one = Math.Min(Q, Math.Min(H, S));
            var two = Math.Min(one * 2, D);
            long result = (N / 2) * two;
            if (N % 2 == 1) { result += one; }
            Console.WriteLine(result);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new A().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 11092
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/08
# Filename: main 
# Author: acto_mini

def main():
    N, A, B = map(int, input().split())
    ans = 0

    for i in range(1, N+1):
        s = str(i)
        array = list(map(int, s))
        x = sum(array)
        if A <= x and x <= B: ans += i

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

string op(int sign)
{
    return sign == 0 ? "+" : "-";
}

int main()
{
    int N, K;
    cin >> N >> K;
    int A;
    vector<int> cnts(N);
    REP(i, N)
    {
        cin >> A;
        ++cnts[A - 1];
    }
    vector<int> nums;
    REP(i, N)
    {
        if (cnts[i] > 0) nums.push_back(cnts[i]);
    }
    sort(nums.rbegin(), nums.rend());
    int ans = 0;
    REP(i, nums.size())
    {
        if (i >= K)
        {
            ans += nums[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
N,W = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

dp = [{0:0} for i in range(N+1)]
for i,(w,v) in enumerate(src):
    for v0,w0 in dp[i].items():
        if v0 in dp[i+1]:
            dp[i+1][v0] = min(dp[i+1][v0], w0)
        else:
            dp[i+1][v0] = w0
        if w0+w > W: continue
        if v0+v in dp[i+1]:
            dp[i+1][v0+v] = min(dp[i+1][v0+v], w0+w)
        else:
            dp[i+1][v0+v] = w0+w
print(max(dp[-1].keys()))

Measured memory_bytes: 286856
#include <cstdio>
using namespace std;
int a,b,c,x,y;
inline void swap(int &x,int &y){
	x^=y^=x^=y;
}
void readData(){
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(x<y){
		swap(a,b);
		swap(x,y);
	}
}
void solve(){
	int ans=0;
	if(a+b<=2*c)
		ans=a*x+b*y;
	else{
		ans=2*c*y;
		x-=y;
		if(x){
			if(a<=2*c)
				ans+=a*x;
			else
				ans+=2*c*x;
		}
	}
	printf("%d\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}


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

int main() {
  int M;
  
  cin >> M;
  if(0 <= M && 24 >= M){
   cout << 24 + (24 - M) << endl;
  }else{
   cout << "Please input number 0 to 24." << endl; 
  }
 }

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

using namespace std;
const int N = 100010;
int _w;

int n, a[N], tmp[3][N], t2[N], t3[N];

namespace BIT {
	int c[N];
	int lowb( int x ) {
		return x & (-x);
	}
	void add( int p ) {
		for( ; p <= n; p += lowb(p) )
			++c[p];
	}
	int sum( int p ) {
		int s = 0;
		for( ; p; p -= lowb(p) )
			s += c[p];
		return s;
	}
	void clear() {
		memset(c, 0, sizeof c);
	}
}

struct Three {
	int a, b, c;
	Three() {}
	Three( int a, int b, int c ):
		a(a), b(b), c(c) {}
	bool operator<( const Three &rhs ) const {
		if( a == rhs.a ) {
			if( b == rhs.b )
				return c < rhs.c;
			else return b < rhs.b;
		} else {
			return a < rhs.a;
		}
	}
};

map<Three,int> mp;
void prelude() {
	for( int i = 1; i <= n+n+n; i += 3 ) {
		int a = i, b = i+1, c = i+2;
		mp[Three(a,b,c)] = c/3;
		mp[Three(c,b,a)] = -c/3;
	}
}

int check( int a, int b, int c ) {
	Three tmp(a,b,c);
	if( !mp.count(tmp) )
		return puts("No"), exit(0), 0;
	return mp[tmp];
}

bool impossible() {
	for( int i = 1; i <= n; ++i ) {
		int x = abs( a[i] );
		if( i % 2 != x % 2 )
			return true;
	}
	return false;
}

int main() {
	_w = scanf( "%d", &n );
	for( int i = 0; i < 3; ++i )
		for( int j = 1; j <= n; ++j )
			_w = scanf( "%d", &tmp[i][j] );
	prelude();
	for( int i = 1; i <= n; ++i )
		a[i] = check( tmp[0][i], tmp[1][i], tmp[2][i] );
	// for( int i = 1; i <= n; ++i ) printf( "%d\n", a[i] );
	if( impossible() ) return puts("No"), 0;
	for( int i = (n&1) ? n : n-1; i >= 1; i -= 2 ) {
		int x = abs( a[i] );
		int cnt = BIT::sum(x);
		BIT::add(x);
		int p = i + cnt*2;
		++t2[x], --t2[p];
		cnt += (p-x)/2;
		if( cnt & 1 ) a[i] = -a[i];
		t3[x] = a[i];
	}
	for( int i = 2; i <= n; ++i )
		t2[i] += t2[i-1];
	for( int i = 1; i <= n; i += 2 )
		a[i] = t3[i];
	for( int i = 2; i <= n; i += 2 )
		if( t2[i] & 1 )
			a[i] = -a[i];
	BIT::clear();
	memset(t2, 0, sizeof t2);
	for( int i = (n&1) ? n-1 : n; i >= 1; i -= 2 ) {
		int x = abs( a[i] );
		int cnt = BIT::sum(x);
		BIT::add(x);
		int p = i + cnt*2;
		++t2[x], --t2[p];
		cnt += (p-x)/2;
		if( cnt & 1 ) a[i] = -a[i];
		t3[x] = a[i];
	}
	for( int i = 2; i <= n; ++i )
		t2[i] += t2[i-1];
	for( int i = 2; i <= n; i += 2 )
		a[i] = t3[i];
	for( int i = 1; i <= n; i += 2 )
		if( t2[i] & 1 )
			a[i] = -a[i];
	// for( int i = 1; i <= n; ++i ) printf( "%d\n", a[i] );
	int cnt = 0;
	for( int i = 1; i <= n; i += 2 )
		cnt += a[i] < 0;
	if( cnt & 1 ) return puts("No"), 0;
	cnt = 0;
	for( int i = 2; i <= n; i += 2 )
		cnt += a[i] < 0;
	if( cnt & 1 ) return puts("No"), 0;
	return puts("Yes"), 0;
}


Measured memory_bytes: 15488
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	int N, M;

	cin >> N >> M;

	vector<int> A(N);

	REP(i, N) {
		cin >> A[i];
	}

	sort(ALL(A),greater<int>());

	int count = 0, sum = 0;;

	REP(i, N) {
		sum += A[i];
	}

	if (sum % (4 * M) == 0) {
		sum = sum / (4 * M);
	}
	else {
		sum = sum / (4 * M)+1;
	}

	REP(i, N) {
		if (A[i] < sum)break;

		count++;
	}

	cout << ((count>=M) ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X, Y, Z; cin >> X >> Y >> Z;
    
    int ans = 0;
    REP(i,100001) {
        if (Y*i+Z*(i+1) > X) {
            ans = i - 1;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

def main():
    x,y = map(int,input().split())
    if x == y:
        print(0)
    elif x >= 0:
        if y > 0:
            if y > x:
                print(y-x)
            else:
                print(x-y+2)
        else:
            print(1+abs(abs(x)-abs(y)))
    else:
        if y > 0:
            if abs(y) > abs(x):
                print(1+y-abs(x))
            else:
                print(1+(abs(x)-y))
        else:
            if x < y:
                print(y-x)
            else:
                print(2+x-y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064