akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    long long X, K, D;
    cin >> X >> K >> D;

    long long n = abs(X) / D;
    
    long long res = 1LL << 60;

    if (n >= K) {
        long long NX = abs(X) - D * K;
        res = min(res, NX);
    } else {
        long long NX = abs(X) - D * n;
        if ((K - n) % 2 == 1) {
            NX = D - NX;
        }
        res = min(res, NX);
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

signed main(void)
{
	#define ll long long int
	
    int k,n;
    cin>>k>>n;
    int arr[n];
    for(int i =0;i<n;i++)
       {cin>>arr[i];arr[i]%=k;}
 
    sort(arr,arr+n);
    int m =INT_MAX;int start,end,temp;
    for(int i =0;i<n;i++)
    {
    	start = arr[i];
    	end = arr[(i+n-1)%n];
    	if(end <=start)
    	{
              temp = k-start;
              temp+=end;
    	}
    	else
    		temp=end-start;

    	if(m>temp)
    		m = temp;
    }
   cout<<m<<endl;

}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl;
#define _GLIBCXX_DEBUG

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

  vector<vector<bool>> c(n, vector<bool>(n, false));
  rep(i, m){
    int a, b;
    cin >> a >> b;
    c[a-1][b-1] = true;
    c[b-1][a-1] = true;
  }

  vector<int> v(n-1);
  iota(ALL(v), 1);

  int cnt = 0;
  do{
    int p = 0;
    bool f = true;
    for(auto x : v){
      if(c[p][x] == false){
        f = false;
        break;
      }
      else{
        p = x;
      }      
    }
    if(f) cnt++;
  }
  while(next_permutation(ALL(v)));
  cout << cnt << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    if (S[0] != S[1]) cout << "Yes" << endl;
    else if (S[1] != S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(void)
{
	int K;
	cin >> K;

	int e = K/2;
	int o;
	if(K%2 == 0)
		o = e;
	else
		o = e + 1;

	cout << e * o << endl;

	return 0;
}


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

int main()
{
  
  long long int a,b,k,ans;
  scanf("%lld%lld%lld",&a,&b,&k);
   if(a<=k)
     {   k=k-a;
         a=0;
         
     }
     
    else
     {
         a=a-k;
         k=0;
     }
     
     if(b<=k)
         b=0;
       
      else
         b-=k;
   
   
  printf("%lld %lld",a,b);
     
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////


//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);

  lin(N);
  vlin(a, N);

  ll m = 0;
  ll res = 0;
  rep(i, N){
    if(i == 0){
      m = a[0];
    }
    if(m > a[i]){
      res += m - a[i];
    }
    else m = a[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
  int N;
  cin >> N;
  if(N / 100 == 7){
    cout << "Yes" << endl;
  }
  else if ((N % 100) / 10 == 7){
    cout << "Yes" << endl;
  }
  else if (N % 10 == 7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}



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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, Q; cin >> N >> Q;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    REP( i, Q ){
        int q; cin >> q;

        int right = 0;
        int ans = 0;
        int sum = 0;
        REP( left, N ){
            while( right < N && sum + a[right] <= q ){
                sum += a[right];
                right++;
            }
            ans += right - left;
            sum -= a[left];
        }

        cout << ans << endl;
    }

}



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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

/*-----------------END TEMPLATE-----------------*/

int main() {
  FASTIO;
  string s;
  cin >> s;
  ll k;
  cin >> k;
  vi v;
  v.pb(1);
  for (size_t i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1])
      v.back()++;
    else
      v.pb(1);
  }

  if (v.size() == 1) {
    cout << (s.size() * k) / 2 << endl;
    return 0;
  }

  ll ans = 0;
  for (size_t i = 1; i < v.size() - 1; i++) {
    ans += (v[i] / 2) * k;
  }
  ans += v[0] / 2;
  ans += v.back() / 2;

  if (s[0] == s.back()) {
    ans += ((v[0] + v.back()) / 2) * (k - 1);
  } else {
    ans += v[0] / 2 * (k - 1);
    ans += v.back() / 2 * (k - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i, N, M, A, B, count=0;
  scanf("%d%d", &N,&M);
  long int H[N], a[N];
  for(i=0; i<N; i++){
    a[i]=1;
  }
  for(i=0; i<N; i++){
    scanf("%ld", &H[i]);
  }
  for(i=0; i<M; i++){
    scanf("%d%d", &A, &B);
    if(H[A-1]<H[B-1]){
      a[A-1]=0;
    }else if(H[B-1]<H[A-1]){
      a[B-1]=0;
    }else{
      a[A-1]=0;
      a[B-1]=0;
    }
  }
  for(i=0; i<N; i++){
    if(a[i]==1){
      count++;
    }
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=505;
int n,p[N*N],d[N][N];
bool in[N][N];

int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};

void dfs(int x,int y)
{
   int cur=d[x][y]+in[x][y];
   for(int k=0;k<4;k++)
   {
       int nx=x+dx[k];
       int ny=y+dy[k];
       if(d[nx][ny]>cur)
       {
           d[nx][ny]=cur;
           dfs(nx,ny);
       }
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>p[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            in[i][j]=true;
            d[i][j]=min({i-1,j-1,n-i,n-j});
        }
    }
    int res=0;
    for(int i=1;i<=n*n;i++)
    {
        int x=p[i]/n+1;
        if(p[i]%n==0) x--;
        int y=p[i]%n;
        if(y==0) y=n;
        res+=d[x][y];
        in[x][y]=false;
        dfs(x,y);
    }
    cout<<res;
}


Measured memory_bytes: 21216
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


const int max_comb=120000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    int n,K;
    scanf("%d%d", &n, &K);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    pre_comb();

    ll ans0=0;
    {
        for(i=0; i<n; i++) {
            if(i>=K-1) {
                ll tmp=a[i]*comb(i,K-1)%MOD;
                ans0=(ans0+tmp)%MOD;
            }
        }
    }
    ll ans1=0;
    {
        reverse(a.begin(),a.end());
        for(i=0; i<n; i++) {
            if(i>=K-1) {
                ll tmp=a[i]*comb(i,K-1)%MOD;
                ans1=(ans1+tmp)%MOD;
            }
        }
    }

    ll ans=(ans0-ans1+MOD)%MOD;
    printf("%lld\n", ans);

    return 0;
}




Measured memory_bytes: 2560
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	if (y + z * 2 <= x) {
		
		cout << (x - z) / (y + z);
	}
	
	return 0;

}

Measured memory_bytes: 3600
from itertools import permutations

N = int(input())
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append(complex(x, y))

s = 0
c = 0
for perm in permutations(range(N), N):
    c += 1
    for i in range(N-1):
        s += abs(points[perm[i]] - points[perm[i+1]])

print(s / c)

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

#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 INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define ALL(v) (v).begin(), (v).end()
typedef pair<ll, ll> P;

int main(){
    int n;
    cin >> n;
    int kaiten[n][10];
    int tensu[n][10];

    REP(i, n) REP(j, 10) cin >> kaiten[i][j];
    REP(i, n) REP(j, 11) cin >> tensu[i][j];
    int score = 0;
    int ans = -INF;

    REPN(state, 1, 1 << 10) {
        int kaburi;
        score = 0;
        REP(i, n) {
            int cnt = 0;
            REP(j, 10) {
                if((state >> j & 1) & kaiten[i][j]) cnt++;
            }
            score += tensu[i][cnt];
        }
        ans = max(ans, score);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  long long n;
  cin >> n;
  long long a,b,c,d,e;
   cin >> a >> b >> c >> d >> e;
   long long MIN;
   MIN = min(min(a, b), min(c, min(d, e)));
   long long ans = n/MIN;
   if(n%MIN != 0){
     ans++;
   }
   cout << ans+4 << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

import sys
sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, M = l_inpl()
 
    G = [[] * (N+1) for _ in range(N+1) ]# 辺の保持
 
    for _ in range(M):
        Li, Ri, Di = l_inpl()
        Li, Ri = Li - 1, Ri - 1
        G[Li].append((Ri, Di))
        G[Ri].append((Li, -Di))
 
    # ある点からの距離
    x = [INF] * (N+1)
 
    # 計算によって得たx[s]が正しいか
    def dfs(s, cost):
        # node_startまでの距離が未探索
        if x[s] == INF:
            x[s] = cost
            # s->tの距離の整合性
            for t, d in G[s]:
                if dfs(t, cost + d) == False:
                    return False
        return x[s] == cost
 
    for i in range(N):
        # if x[i] is not None: # 探索済み
        #     continue
        if x[i] == INF and dfs(i, 0) == False:
            print("No")
            return
    print("Yes")
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 150432
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = 10 ** 9 + 1
dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))

print(dp[N - 1])


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

bool ok(int n, set<int>& s)
{
    while(n > 0)
    {
        int tmp = n%10;
        n/=10;
        if(s.find(tmp) != s.end()) return false;
    }
    return true;
}

int main()
{
    int n,k;
    cin >> n >> k;
    set<int> d;
    for(int i=0; i<k; ++i) 
    {
        int x;
        cin >> x;
        d.insert(x);
    }
    for(int i=n; i<=100000; ++i)
    {
        if(ok(i,d)) 
        {
            cout << i <<"\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int x=sc.nextInt();
        int count=0;
       for(int i=0;i<=a;i++)
           for(int j=0;j<=b;j++)
               for(int k=0;k<=c;k++){
                   if(i*500+j*100+k*50==x){
                       count++;
                   }
               }
        System.out.println(count);


        }
        
    }
    



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

using namespace std;

int main(void)
{
    double N;
    cin>>N;
  
  if((int)N%2==0){
    cout << 0.5 << endl;
    return 0;
  }
    cout << ((N+1)/2)/N << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    A =list(map(int, input().split()))
    s = sum(A)
    d = defaultdict(lambda: 0)

    for v in A:
        d[v] +=1

    Q = int(input())

    for i in range(Q):
        b,c = map(int, input().split())
        d[c] += d[b]
        s += (c-b) * d[b]
        d[b] = 0
        print(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 89376
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));

    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int ls = s.length();
  int lt = t.length();
  vector<vector<int>> dp(ls + 1, vector<int>(lt + 1, 0));
  
  for (int i = 0; i <= ls; i++) {
    for (int j = 0; j <= lt; j++) {
      if (i == 0 || j == 0) {
        dp.at(i).at(j) = 0;
        continue;
      }
      if (s[i - 1] == t[j - 1]) {
        dp.at(i).at(j) = dp.at(i - 1).at(j - 1) + 1;
      } else {
        dp.at(i).at(j) = max(dp.at(i - 1).at(j), dp.at(i).at(j - 1));
      }
    }
  }
  
  int i = ls;
  int j = lt;
  string ans = "";
  
  while (i > 0 && j > 0) {
    if (s[i - 1] == t[j - 1]) {
      ans += s[i - 1];
      i--;
      j--;
    } else if (dp.at(i - 1).at(j) > dp.at(i).at(j - 1)) {
      i--;
    } else {
      j--;
    }
  }
  reverse(ans.begin(), ans.end());
  
  cout << ans << endl;
  
  return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        if (A * B % 2 == 0)
        {
            Console.WriteLine("No");
            return;
        }
        Console.WriteLine("Yes");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 13140
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input().strip())
D = [int(x) for x in input().strip().split()]
maxD = max(D)
C = [0] * (maxD + 1)
for d in D:
    C[d] += 1
ans = 1
c_ = 1
if C[0] != 1 or D[0] != 0:
    ans = 0
else:
    for i, c in enumerate(C[1:], start=1):
        ans *= c_ ** c
        ans %= 998244353
        c_ = c

print(ans)




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

int main() {
    std::string str;
    std::cin >> str;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == '?') {
            str[i] = 'D';
        }
    }
    std::cout << str << std::endl;
}


Measured memory_bytes: 3716
#include <stdio.h>

int main()
{
  int i, j, n, m, s, t, t1, t2;
  fscanf(stdin, "%d %d", &n, &m);
  int *gg[n];
  int gid[m];

  for (i=0; i<n; i++) gg[i] = NULL;
  for (i=0; i<m; i++) gid[i] = i;
  
  int maxgrp=0;
  
  for (i=0; i<m; i++) {
    fscanf(stdin, "%d %d", &s, &t);
    if (gg[s]==NULL && gg[t]==NULL) { // create new group
      gg[s] = gid+maxgrp;
      gg[t] = gid+maxgrp;
      maxgrp++;
      continue;
    }
        
    if (gg[s]==NULL) {
      gg[s]=gg[t];
    } else if (gg[t]==NULL) {
      gg[t]=gg[s];
    } else { // gt <- gs
      if (*gg[s]<*gg[t]) {
        t1 = *gg[s];
        t2 = *gg[t];
      } else {
        t1 = *gg[t];
        t2 = *gg[s];
      }
      for (j=0; j<maxgrp; j++) {
        if (gid[j]==t2) gid[j]=t1;
      }
    }
  }
  
  fscanf(stdin, "%d", &m);
  for (i=0; i<m; i++) {
    fscanf(stdin, "%d %d", &s, &t);
                            
    if (gg[s]==NULL || gg[t]==NULL || *gg[s]!=*gg[t])
      puts("no");
    else
      puts("yes");

  }
  return 0;
}


Measured memory_bytes: 2840
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	int n; cin >> n;
	map<string, int> goods;
	int cnt = 0;
	rep(i, n) {
		cin >> s;
		goods[s]++;
		if (goods[s] == 1)cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
long long k;
string s;
int main(){
	cin >> s >> k;
	for(int i=0;i<k;i++){
		if(s[i]!='1'){
			cout << s[i];
			return 0;
		}
		else if(i==k-1)cout << s[i];
	}
	return 0;
}

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

using namespace std;

int
main(void)
{
    int N;
    string S;
    int left_w = 0, right_e = 0;
    int result = numeric_limits<int>::max();

    cin >> N;
    cin >> S;

    for(char c : S) {
        if(c == 'E') right_e++; 
    }

    for(char c : S) {
        if(c == 'E') right_e--;
        result = min(result, left_w + right_e);
        if(c == 'W') left_w++;
    }
    cout << result << endl;

}


Measured memory_bytes: 900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 256).readLine());
		int val = 100;//壱百千円
		for (; 0 < period; period--) {
			val = val * 105 % 100 == 0 ? (int) (val * 1.05) : (int) (val * 1.05) + 1;
		}
		System.out.println(val * 1000);
	}
}

Measured memory_bytes: 16844
words = lambda t : list(map(t, input().split()))
s = input()
t = input()

dst = {}
dts = {}
a = "abcdefghijklmnopqrstuvwxyz"
for c in a:
    dst[c] = "-"
    dts[c] = "-"

ans = True
for i in range(len(s)):
    if dst[s[i]] == "-":
        dst[s[i]] = t[i]
    elif dst[s[i]] == t[i]:
        continue
    else:
        ans = False
        break
if ans == True:
    for i in range(len(s)):
        if dts[t[i]] == "-":
            dts[t[i]] = s[i]
        elif dts[t[i]] == s[i]:
            continue
        else:
            ans = False
            break

if ans:
    print("Yes")
else:
    print("No")


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

using namespace std;

const int N = 2e5 + 100;

vector <int> Ans;
int B[N];
int Arr[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;  cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> Arr[i];

    for (int i = n; i >= 1; i--)
    {
        int Sum = 0;
        for (int j = i; j <= n; j += i)
            Sum += B[j];

        if (Arr[i]%2 != Sum%2) {
            B[i] = 1;
            Ans.push_back(i);
        }
    }

    // for (int i = 1; i <= n; i++)
    //     cout << B[i] << ' ';
    // cout << '\n';

    for (int i = 1; i <= n; i++) {
        int cur = 0;
        for (int j = i; j <= n; j += i)
            cur += B[j];
        if (cur%2 != Arr[i])
            return cout << "-1\n", 0;
    }

    sort(Ans.begin(), Ans.end());

    cout << Ans.size() << '\n';
    for (auto x : Ans)
        cout << x << ' ';
    cout << '\n';

    return 0;
}

/*
6
1 1 1 1 0 1 
*/

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

int main() {
	double N, K, ans = 0.0;
	cin >> N >> K;
	for (double i = 1.0; i <= N; ++i) {
		double a = 1.0 / N, j = i;
		while (K > j) {
			a /= 2.0;
			j *= 2.0;
		}
		ans += a;
	}
	printf("%.12f", ans);
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	set<int> st;
	for(int i = 0;i <= 999;i++){
		int a1 = -1,a2 = -1,a3 = -1;
		for(int j = 0;j < s.size();j++){
			if(a1 == -1 && a2 == -1 && a3 == -1 && s[j]-'0'== i/100){
				a1 = s[j]-'0';
			}
			else if(a1 != -1 && a2 == -1 && a3 == -1 && s[j]-'0'== i/10 % 10){
				a2 = s[j]-'0';
			}
			else if(a1 != -1 && a2 != -1 && a3 == -1 && s[j]-'0'==i%10){
				a3 = s[j]-'0';
			}
			if(a1!=-1&&a2!=-1&&a3!=-1) break;
		}
		if(a1!=-1&&a2!=-1&&a3!=-1){
			int y = a1 * 100 + a2 * 10 + a3;
			st.insert(y);
		}
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
long long int ans = 0;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    for(int b = 0; b < (1<<(N-1)); b++) {
        long long int sum = 0;
        long long int cur = 0;
        for(int i = 0; i < N-1; i++) {
            cur *= 10ll;
            cur += (S[i]-'0');
            if(b & (1<<i)) {
                sum += cur;
                cur = 0;
            }
        }
        cur *= 10ll;
        cur += (S[N-1]-'0');
        sum += cur;
        ans += sum;
//        cerr << b << " " << sum << "\n";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int A = 1e6;
vector<int> factor[A + 1];
int freq[A + 1];
int main() {
  for (int i = 1; i <= A; i++)
    for (int j = 1; j * i <= A; j++)
      factor[i * j].push_back(i);
  int n, ans = 0;
  cin >> n;
  int v[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    freq[v[i]]++;
  }
  for (int i = 0; i < n; i++) {
    bool absent = true;
    freq[v[i]]--;
    for (int f : factor[v[i]])
      if (freq[f])
        absent = false;
    ans += absent;
    freq[v[i]]++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 122404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << LCM(a, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 2147483647
vector<pair<int,int> > a(300000,pair<int,int>(INF,0));
int n,si;
int find(int);
void update(int,int,int,int,int,int,int);

int main(){
  int q,f;
  si=1;
  cin >> n >> q;
  for(int i=0;;i++){
    si*=2;
    if(si>=n)break;
  }
  for(int i=0;i<q;i++){
    cin >> f;
    if(f==1){
      int po,dat;
      cin >> po;
      dat=find(po);
      cout << dat << endl;      
    }
    else{
      int st,go,d;
      cin >> st >> go>>d;
      update(st,go+1,0,0,si,d,i+1);
    }
  }
  return 0;
}
int find(int p){
  int ko=si-1+p;
  pair<int,int> ma=a[ko];
  while(ko>0){
    ko=(ko-1)/2;
    if(ma.second<a[ko].second){
      ma=a[ko];
    }
  }
  return ma.first;
}

void update (int s,int t,int k,int l,int r,int d,int ti){
  int m=(l+r)/2;
  if(s<=l&&r<=t){
    a[k].first=d;
    a[k].second=ti;
    return;
  }
  else if(r<=s||t<=l)return;
  
  else{ 
    update(s,t,k*2+1,l,m,d,ti);
    update(s,t,k*2+2,m,r,d,ti);
  }
}

Measured memory_bytes: 5036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld",max(0,a-b-b));
}

Measured memory_bytes: 128
#include <iostream>
 
inline int get_function(const u_int x)
{
    return x * x;
}
 
int get_integral(const u_int x, const u_int d)
{
    u_int ans = 0, num_of_iter = x / d;
    for(u_int i = 1; i < num_of_iter; ++i)
        ans += d * get_function(d * i);
    return ans;
}
 
int main()
{
    const u_int x = 600;
    u_int d;
    while(std::cin >> d)
        std::cout << get_integral(x, d) << std::endl;
     
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;
int A, B, Q;

int main() {
   ll x;
   cin >> A >> B >> Q;
   vector<ll> s;
   vector<ll> t;
   ll tmp;
   for (int a = 0; a < A; a++) {
      cin >> tmp;
      s.push_back(tmp);
   }
   for (int b = 0; b < B; b++) {
      cin >> tmp;
      t.push_back(tmp);
   }
   for (int q = 0; q < Q; q++) {
      cin >> x;
      ll ans = -1;
      decltype(s)::iterator its = lower_bound(s.begin(), s.end(), x);
      decltype(t)::iterator itt = lower_bound(t.begin(), t.end(), x);
      ll tmp;
      if (its - s.begin() != A && itt - t.begin() != B) {
         tmp = max(abs(s[its - s.begin()] - x), abs(t[itt - t.begin()] - x));
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
      }
      if (its - s.begin() - 1 >= 0 && itt - t.begin() - 1 >= 0) {
         tmp = max(abs(s[its - s.begin() - 1] - x), abs(t[itt - t.begin() - 1] - x));
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
      }
      if (itt - t.begin() - 1 >= 0 && its - s.begin() != A) {
         tmp = abs(s[its - s.begin()] - x) * 2 + abs(t[itt - t.begin() - 1] - x);
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
         tmp = abs(s[its - s.begin()] - x) + abs(t[itt - t.begin() - 1] - x) * 2;
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
      }
      if (its - s.begin() - 1 >= 0 && itt - t.begin() != B) {
         tmp = abs(t[itt - t.begin()] - x) * 2 + abs(s[its - s.begin() - 1] - x);
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
         tmp = abs(t[itt - t.begin()] - x) + abs(s[its - s.begin() - 1] - x) * 2;
         if (ans == -1) ans = tmp;
         else ans = min(ans, tmp);
      }
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,z;
string st,s;
int main()
{
	cin>>st;
    for (int i=0;i<st.size();i++)
      if (st[i]=='9') {z++;break;}
    if (z>0) cout<<"Yes"<<endl;else
      cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int count = 0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                int sum = 500 * i + 100 * j + 50 * k;
                if (sum == x)
                    ++count;
            }
        }
    }

    cout << count << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll a = INF;
    ll b = INF;
    ll c = INF;
    int a_count = 0;
    int b_count = 0;
    int c_count = 0;

    rep(i, n) {
        int tmpx;
        cin >> tmpx;
        // cout << a_count << " " << b_count << " " << c_count << endl;
        if (a==INF) {
            a = tmpx;
            a_count ++;
        }
        else if (a == tmpx) {
            a_count ++;
        }
        else if (b==INF) {
            b = tmpx;
            b_count ++;
        }
        else if (b == tmpx) {
            b_count ++;
        }
        else if (c==INF) {
            c = tmpx;
            c_count ++;
        }
        else if (c == tmpx) {
            c_count++;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    int tmptmp = a ^ b;
    // cout << tmptmp << endl;
    // cout << c << endl;

    if (a_count == b_count && b_count == c_count &&  tmptmp == c) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (b_count == 0 && c_count == 0 && a == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (((a_count * 2 == b_count && a == 0) || (a_count == b_count * 2 && b == 0)) && c_count == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)


N,K=gets.split.map(&:to_i)

i=N
prob=Rational(0,1)
num=1
while N*num<K
  num*=2
end

while i>=1
  if i*num<K
    num*=2
  end
  prob+=Rational(1,num*N)
  i-=1
end

puts sprintf("%.10f", prob)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
vector<pair<int,int> > v[10001];
int vv[10001][1000];

int main(){
  int n,m;
  while(cin>>n>>m,n){
    int r,q;cin>>r;
    vector<pair<int,int> > v[10001];
    for(int i=0;i<r;i++){
      int a,b,c,d;cin>>a>>b>>c>>d;
      c--;
      a-=540;
      if(d==0){
        v[c].push_back({b,a});
      }else{
        v[c].push_back({b,a});
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<800;j++){
        vv[i][j]=0;
      }
    }
    for(int i=0;i<m;i++){
      sort(v[i].begin(),v[i].end());
      for(int j=0;j<(int)v[i].size();j+=2){
        vv[i][v[i][j].se]++;
        vv[i][v[i][j+1].se]--;
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<800;j++){
        if(j==0)continue;
        vv[i][j]=vv[i][j-1]+vv[i][j];
      }
    }
    cin>>q;
    for(int i=0;i<q;i++){
      int ts,te,tm;cin>>ts>>te>>tm;
      tm--;
      ts-=540;
      te-=540;
      int res=0;
      for(int j=ts;j<te;j++){
        if(vv[tm][j]>0)res++;
      }
      cout<<res<<endl;
    }
  }
  return 0;
}







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

int main() {
    ll a, b;
    cin >> a >> b;
    if (a>b) cout << a+a-1;
    else if (b>a) cout << b+b-1;
    else cout << a+b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int A, B, H, M;
    double tanshin, choshin, naikaku,answer;
    cin >> A >> B >> H >> M;
    tanshin = H * 30 + M * 0.5;
    choshin = M * 6;
    if(tanshin - choshin < 0){
        if(choshin - tanshin > 180){
            naikaku = 360 - (choshin - tanshin);
        }else{
            naikaku = choshin - tanshin;
        }
    }else{
        if(tanshin - choshin > 180){
            naikaku = 360 - (tanshin - choshin);
        }else{
            naikaku = tanshin - choshin;
        }
    }
    answer = sqrt( A * A + B * B - 2 * A * B * cos(3.141592653589/(180/naikaku)));
    cout << fixed << setprecision(20) << answer << endl;
        return 0;
}

Measured memory_bytes: 4152
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		int a = sc.nextInt();
		int p = sc.nextInt();
		int kakera = a * 3 + p;
		int pie = kakera / 2;
		System.out.println(pie);

	}
}


Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
#include<algorithm>

int n;
int t[17][17];
int dp[1<<17];
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=n;j++){
				scanf("%d",&t[i][j]);
			}
		}
		memset(dp,-1,sizeof(dp));
		dp[0]=0;
		for(int i=0;i<(1<<n);i++){
			if(dp[i]==-1)continue;
			for(int j=1;j<=n;j++){
				if((i>>(j-1)) & 1)continue;
				int cost=t[j][0];
				for(int k=1;k<=n;k++){
					if((i>>(k-1)) & 1)cost=std::min(cost,t[j][k]);
				}
				int bit=i|(1<<(j-1));
				if(dp[bit]==-1 || dp[bit]>dp[i]+cost)dp[bit]=dp[i]+cost;
			}
		}
		printf("%d\n",dp[(1<<n)-1]);
	}
	return 0;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int MAXN=105;
const int MAXK=1e5+5;
int a[128];
struct Node{
	#define lowbit(_X_) (_X_&(-_X_))
	int N,tree[MAXK];
	Node(int k){
		N=k+3;
		memset(tree,0,sizeof(tree));
	}
	inline void add(int x,int v){
		++x;
		while(x<=N){
			(tree[x]+=v)%=MOD;
			x+=lowbit(x);
		}
	}
	inline int sum(int x){
		++x;
		int ret(0);
		while(x){
			(ret+=tree[x])%=MOD;
			x-=lowbit(x);
		}
		return ret;
	}
	inline int query(int l,int r){
		return (sum(r)-sum(l-1)+MOD)%MOD;
	}
};
int dp[MAXK];
int main(){
	int n,k;
	cin>>n>>k;
	Node Bit(k);
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	Bit.add(0,1);
	for(int i=0;i<n;++i){
		for(int j=k;j>=1;--j){
			Bit.add(j,Bit.query(max(0,j-a[i]),j-1));
		}
	}
	cout<<Bit.query(k,k)<<endl;
	return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, a, B) for (ll I = (a); I <= (B); ++I)
#define inn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);srand(time(NULL));cout<<fixed<<setprecision(10);clock_t clk;clk = clock();
#define outt clk=clock()-clk;cerr<<fixed<<setprecision(6)<<"Time: "<<((double)clk)/CLOCKS_PER_SEC<<"\n";return 0;
using namespace std;
#define TRACE
#ifdef TRACE
#define t(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define t(...)
#endif
const int N = 2e5 + 5;
const int MAX = 2e6 + 5;
const int MOD = 1000000007;

//

signed main()
{
    inn;

    int n;
    cin >> n;
    vector<int> a(n + 1);
    repp(i,1,n) cin >> a[i];
    sort(a.begin(), a.end());
    int sum = 0;
    repp(i,1,n-1) sum += a[i];
    if(sum > a[n])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    outt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int s1, s2, s3, s4, s5;
    
  int tot = 0;
  for (int X=A; X<=B; X++) {
    s1 = X % 10;
    s2 = X / 10 % 10;
    s3 = X / 100 % 10;
    s4 = X / 1000 % 10;
    s5 = X / 10000 % 10;
    
    if (s1 == s5 && s2 == s4) {
      tot++;
    }
  }
  cout << tot << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N; N--;
  ll dig = 1, p26 = 26, sum = 26;
  while (p26<=N) { N-=p26; p26*=26; dig++; }
  // cout << N << endl;
  string result = "";
  rep(i,dig) {
    result += 'a' + N%26;
    N /= 26;
  }
  reverse(all(result));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
	int w, n, i, a, b, comp;
	int num[30];
	for(i = 1;i <= 30;i++){
		num[i - 1] = i;
	}


	scanf("%d", &w);
	scanf("%d", &n);

	for(i = 0;i < n;i++){
		scanf("%d,%d", &a, &b);
		comp = num[b - 1];
		num[b - 1] = num[a - 1];
		num[a - 1] = comp;
	}

	for(i = 0;i < w;i++){
		printf("%d\n", num[i]);
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    vector<int>v;
    for(int i=0;i<n;i++){
        if(a[i]==i+1)v.push_back(i+1);
    }
    int k=0;
    for(int i=0;i<v.size();){
        if((k+1)!=v.size()){
            if(v[i+1]-v[i]==1){
                ans+=1;
                i+=2;
            }else{
                ans+=1;
                i+=1;
            }    
        }else{
            ans+=1;
            i+=1;
        }
    }
    cout<<ans;
}


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

int main()
{
  int a, b, k, arr[100] = { 0 }, cnt = 0;
  
  cin >> a >> b >> k;
  
  for (int i = 1; i <= ((a > b) ? b : a); i++) {
    if (a % i == 0 && b % i == 0)
      arr[cnt++] = i;
  }
  
  cout << arr[cnt - k] << endl;
  
  return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for(int i=max(-1000000, X-K+1); i<=min(1000000, X+K-1); i++) {
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, z, w; cin >> n >> z >> w;
    vi a(n); rep(i, n) cin >> a[i];
    int ans = abs(a[n-1] - w);
    if(n > 1) ans = max(ans, abs(a[n-1] - a[n-2]));
    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3628