akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int a,b,c,k; cin>>a>>b>>c>>k;
int sum=0;
sum=min(a,k);
k-=sum;
k-=b;
if(k>0)
sum-=min(k,c);
cout<<sum;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 3616
n = gets.to_i

h = Hash.new(0)
c = 0

gets.split.each do |e| 
    e = e.to_i
    h[e] += 1
    if h[e] == 3
        c += 2
        h[e] = 1
    end
end

x = h.values.count(2)
puts n - c - x - x % 2

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

string gr(string a, string b) {
    if (a.size() > b.size()) return a;
    else if (a.size() < b.size()) return b;
    else {
        return max(a, b);
    }
}

string dp[10000 + 10];
vi A;
int match[10];

signed main(void) {
    int N, M; cin >> N >> M;
    REP(i, 0, N) dp[i] = "none";
    match[1] = 2;
    match[2] = 5;
    match[3] = 5;
    match[4] = 4;
    match[5] = 5;
    match[6] = 6;
    match[7] = 3;
    match[8] = 7;
    match[9] = 6;
    rep(i, M) {
        int a; cin >> a;
        A.pb(a);
    }

    REP(i, 0, N) { //i:マッチの本数
        string num = "none";
        rep(j, M) { //A[j]:調べる１桁目の数字
            if (match[A[j]] <= i) { //採用可能
                if (i-match[A[j]] == 0) { //１桁の数字が完成
                    if (num == "none") num = to_string(A[j]);
                    else num = gr(to_string(A[j]), num);
                } else if (dp[i-match[A[j]]] != "none"){ //複数桁の数字が完成
                    string cand = to_string(A[j])+dp[i-match[A[j]]];
                    if (num == "none") num = cand;
                    else num = gr(cand, num);
                }
            }
        }
        dp[i] = num;
    }
    
    // REP(i, 0, N) {
    //     cout << i << ":" << dp[i] << endl;
    // }

    string ans = dp[N];
    // cout << ans << endl;

    priority_queue<int> Q;

    rep(i, ans.size()) {
        Q.push(ans[i] - '0');
    }
    rep(i, ans.size()) {
        cout << Q.top();
        Q.pop();
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 32512
import java.util.*;

public class Main {

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

        int ans = 0;
        
        if(N == 100000) {
            ans = 9 + 900  + 90000;
        }else if(N >= 10000) {
            ans = 9 + 900 + N - 10000 + 1;
        }else if(N >= 1000) {
            ans = 9 + 900;
        }else if(N >= 100) {
            ans = 9 + N - 100 + 1;
        }else if(N >= 10) {
            ans = 9;
        }else {
            ans = N;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n")[0].split(" "); // 1行目がinput[0], 2行目がinput[1], …に入る
    
    if( Math.abs(input[0] - input[1]) < Math.abs(input[0] - input[2]))
        console.log("A");
    else
        console.log("B");
}
 
// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));




Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  string s, t; cin >> s >> t;
  vector<vi> dp(sz(s)+1, vi(sz(t)+1,0));
  rep(i,1,sz(s)+1){
    rep(j,1,sz(t)+1){
      if(s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  string res = "";
  int i = sz(s), j = sz(t);
  while(i && j){
    if(s[i-1] == t[j-1]){
      res += s[i-1];
      i--; j--;
    }
    else{
      if(dp[i][j-1] > dp[i-1][j]) j--;
      else i--;
    }
  }
  reverse(all(res));
  cout << res << "\n";
}


Measured memory_bytes: 38472
from heapq import heappush, heappop

n = int(input())
INF = 10 ** 10

left = [INF]
right = [INF]
left_sm = 0
right_sm = 0
cnt = 0
b_sm = 0

for _ in range(n):
    q = input()
    #print(left)
    #print(right)
    #print()

    if q[0] == "1":
        _, a, b = map(int, q.split())

        if cnt % 2:
            if a < -left[0]:
                l2r = -heappop(left)
                left_sm -= l2r
                heappush(left, -a)
                left_sm += a
                heappush(right, l2r)
                right_sm += l2r

            else:
                heappush(right, a)
                right_sm += a

        else:
            if a > right[0]:
                r2l = heappop(right)
                right_sm -= r2l
                heappush(left, -r2l)
                left_sm += r2l
                heappush(right, a)
                right_sm += a

            else:
                heappush(left, -a)
                left_sm += a

        b_sm += b
        cnt += 1

    else:
        x = -left[0]
        fx = -left_sm + right_sm + b_sm
        if cnt % 2:
            fx += x
        print(x, fx)


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    long long N,ans;
    //set<pair<long long,long long>> S;

    cin>>N;
    ans=0;
    for(long long  i=1;i<=N ;i++){
        for(long long j=1;j<=N;j++){
            if(i*j>=N){
                break;
            }
            if(i*j < N){
                ans++;
            }
        }
    }

    cout<<ans<<endl;


    return 0;
}



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

int main(){
    ll N, K;  cin >> N >> K;
    vector<ll> A(N), F(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<int>());

    ll left = -1, right = 1e18;
    while(right - left > 1){
        ll mid = (right + left)/2;
        ll cnt = 0;
        for(int i=0; i<N; i++){
            cnt += max(0LL, A[i] - mid/F[i]);
        }
        if(cnt > K){
            left = mid;
        }else{
            right = mid;
        }
    }
    cout << right << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

vector<int> djset;

int root(int x)
{
    int v = djset[x];
    while (v != djset[v]) v = djset[v];
    return v;
}

int main(void)
{
    int N, Q;
    char c;
    int v;
    while (true)
    {
        cin >> N >> Q;
        if (!N) break;
        djset.resize(N + 1);
        djset[1] = 1;
        for (int i = 2; i <= N; i++)
        {
            cin >> djset[i];
            djset[i];
        }
        long long ans = 0;
        while(Q)
        {
            cin >> c >> v;
            if (c == 'Q') ans += root(v);
            else djset[v] = v;
            Q--;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

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

    if (d == 0) {
        cout << setprecision(10) << (double)(m - 1) * (double)(n - d) / (double)n / (double)n << endl;
    } else {
        cout << setprecision(10) << (double)(m - 1) * (double)(n - d) * 2.0 / (double)n / (double)n << endl;
    }
}


Measured memory_bytes: 256
s = "#." * 150
while True:
    H,W = map(int,input().split())
    if H == 0 == W:
        break
    else :
        for i in range(H):
            if  i % 2 == 0: 
                print(s[:W])
            else :
                print(s[1:W+1])
        print()


Measured memory_bytes: 5612
S = input()
T = input()


def check1(s):
    ret = True
    for i in range(len(T)):
        if s[i] != '?' and s[i] != T[i]:
            ret = False
            break
    return ret


candidate = []
for i in range(len(S)-len(T)+1):
    if check1(S[i:i+len(T)]):
        candidate.append(i)

if not candidate:
    print('UNRESTORABLE')
else:
    S = S[:candidate[-1]] + T + S[candidate[-1]+len(T):]
    for i in range(len(S)):
        if S[i] == '?':
            S = S[:i] + 'a' + S[i+1:]
    print(S)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    int n;cin>>n;
    map<pair<ll,ll>,int> mp;
    int zero=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0){
            zero++;
            continue;
        }
        ll g=gcd(a,b);//片方が0だともう片方の絶対値が出てくる
        a/=g;b/=g;
        /*if(b<0||(b==0&&a<0)){
            b*=-1;a*=-1;//第3象限と第4象限の座標をそれぞれ第1象限と第2象限にまとめる
        }*/
        mp[{a,b}]++;
    }
    vector<ll> s(10*n+1,1);
    rep(i,n*10){
        s[i+1]=s[i]*2;
        s[i+1]%=mod;
    }
    ll res=1;
    for(auto& p:mp){
        ll a=p.first.first,b=p.first.second;
        int x=p.second,y=mp[{-a,-b}],z=mp[{-b,a}],t=mp[{b,-a}];
        if(x==-1||y==-1||z==-1||t==-1)continue;//すでに見られている
        ll tmp=1;
        tmp+=s[x+y]-1;tmp%=mod;
        tmp+=s[z+t]-1;tmp%=mod;
        res*=tmp;res%=mod;
        mp[{-b,a}]=-1;mp[{-a,-b}]=-1;mp[{a,b}]=-1;mp[{b,-a}]=-1;
        //cout<<a<<" "<<b<<" "<<x<<" "<<t<<" "<<res<<endl;
    }
    res+=zero;
    res=(res+mod-1)%mod;
    cout<<res<<endl;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,t;
	cin>>n;
	deque<int> q;
	for(int i=0;i<n;++i) {
		cin>>t;
		if(i%2==0) {
			q.push_back(t);
		}
		else q.push_front(t);
	}
	if(n==2) {
		for(int i=0;i<n;++i) {
			cout<<q.back()<<" ";
			q.pop_back();
		}
	}
	else if(n%2==0) {
		for(int i=0;i<n;++i) {
			cout<<q.front()<<" ";
			q.pop_front();
		}
	}
	else {
		for(int i=0;i<n;++i) {
			cout<<q.back()<<" ";
			q.pop_back();
		}
	}

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define st first
#define sc second
#define arr array
#define yes cout << "Yes" <<"\n"
#define no cout << "No" <<"\n"
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false)
#define out cin.tie(nullptr)
#define task "A"
#define open(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout);}
#define open_to_check(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin);}

using namespace std;

const int maxn = 2e6 + 1;
const ll mod = 1e9 + 7;
const ll lim = 1e18;


int main()
{
    //open_to_check(task);
    ll n;
    cin >> n;
    if(n >= 30) yes;
    else no;
}
/*
6 8
1 2
1 3
2 3
2 4
2 6
3 5
3 6
4 5

*/


Measured memory_bytes: 3632
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    X, K, D = iim()

    r = 1
    if X < 0:
        r = -1
        X = -X
    a, b = divmod(X, D)

    diff = K - a
    if diff <= 0:
        print(abs(r*(X - K*D)))
        return

    if diff & 1:
        b -= D

    print(abs(r*b))



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61884
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static int[] dp;
	public static path[] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int max = 0;
		dp = new int[n];
		a = new path[n];
		for (int i = 0; i < n; i++) dp[i] = -1;
		for (int i = 0; i < n; i++) a[i] = new path();
		int x, y;
		for (int i = 0; i < m; i++) {
			x = sc.nextInt()-1;
			y = sc.nextInt()-1;
			a[x].list.add(y);
		}
		for (int i = 0; i < n; i++) dfs(i);
		for (int i = 0; i < n; i++) {
			max = Math.max(dp[i], max);
		}
		System.out.println(max);
		sc.close();
	}

	public static class path{
		public ArrayList<Integer> list;
		public path() {
			this.list = new ArrayList<Integer>();
		}
	}

	public static int dfs(int x) {
		if(dp[x] != -1) return dp[x];
		int max = 0;
		if(a[x].list.size()>0) {
			for (int i = 0; i < a[x].list.size(); i++) {
				max = Math.max(max, dfs(a[x].list.get(i)));
			}
			dp[x] = max+1;
		}else {
			dp[x] = 0;
		}
		return dp[x];
	}
}

Measured memory_bytes: 101076
N,M = map(int, input().split())

Ks = []
for _ in range(M):
  Ks.append(set(list(map(int, input().split()))[1:]))
  
Ps = list(map(int, input().split()))

rlt = 0
pw = 2**N

for b in range(pw):
  lst = [0]*(M)
  tmp = 0
  for i in range(N):
    if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
  for j in range(M):
    if lst[j] % 2 == Ps[j]:
      tmp += 1
  if tmp == M:
    rlt += 1
  
print(rlt)

Measured memory_bytes: 74052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		s = s.substring(0,s.length()-1);
		if(s.length() % 2 == 1) {
			s = s.substring(0,s.length()-1);
		}
		while(true) {
			String front = s.substring(0,s.length() / 2);
			String back = s.substring(s.length() / 2);
			if(front.equals(back)) {
				break;
			} else {
				s = s.substring(0,s.length()-2);
			}
		}
		System.out.println(s.length());
	}
}



Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
int main()
{
    int i,n,a,j,counter=0;
    int ar[100][100];
    scanf("%d%d", &n, &a);
    for(i=0; i<n; i++)
    {
        for(j=0;j<a; j++)
        {
            scanf("%d", &ar[i][j]);
        }
    }
   int x,ar1[100],q;
   for(i=0; i<n; i++)
   {
       int d =i;
         for(q=0; q<n-1-i; q++)
       {
           d++;
           for(j=0; j<a ; j++)
           {
          ar1[j] = ar[i][j]-ar[d][j];

           }
           int y = 0;
       for(j=0; j<a;j++)
       {
           int borgo = (ar1[j]*ar1[j]);
           y=y+borgo;
       }
       float root = sqrt(y);
       int root1 = sqrt(y);
       if(root == root1)
       {
           counter++;
       }
       }
   }
    printf("%d\n", counter);
   return 0;
}


Measured memory_bytes: 128
N,X =map(int,input().split())
pa =[1]
bu =[1]
for i in range(N-1):
    pa.append(pa[i]*2+1)
    bu.append(bu[i]*2+3)
ans = 0
for i in range(N):
    if X >= bu[N-1-i]*2+2:
        ans += 2*pa[N-1-i]+1
        break
    elif X >= bu[N-1-i]+2:
        ans += pa[N-1-i]+1
        X -= bu[N-1-i]+2
    elif X == bu[N-1-i]+1:
        ans += pa[N-1-i]
        break
    else:
        X -= 1
print(ans)


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll res = min(n%k, k-n%k);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int x,y;
    cin >> x >> y;
    if (y > x * 4 || y < x * 2) cout << "No";
    else {
        if (y % 2 == 0) {
           cout << "Yes"; 
        } else {
            cout << "No";
        }
    }   

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3600
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll>a(n);
    vector<ll>cnt(n);
    rep(i, n)cnt[i] = 0;
    rep(i, n) {
        cin >> a[i];
        cnt[a[i] - 1]++;
    }
    rep(i,n)ans += cnt[i] * (cnt[i] - 1) / 2;//先に一つ除かない場合の数を求める
    rep(i, n) {
        ll ans2 = 0;
        ans2 = ans - cnt[a[i] - 1] * (cnt[a[i] - 1] - 1) / 2;
        if (cnt[a[i] - 1] != 0) ans2 += (cnt[a[i] - 1] - 1) * (cnt[a[i] - 1] - 2) / 2;
        cout << ans2 << endl;
    }
    return 0;
}

Measured memory_bytes: 6076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

struct info {
    int C;
    vector<int> A;

    info(int C, vector<int> &A) : C(C), A(A) {}
};

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int ans = INF;
    vector<info> book;
    for (int i = 0; i < N; i++) {
        int C;
        cin >> C;
        vector<int> A(M);
        cin >> A;
        book.emplace_back(C, A);
    }
    for (int i = 0; i < (1<<N); i++) {
        vector<int> count(M, 0);
        int cost = 0;
        for (int j = 0; j < N; j++) {
            if ((i>>j)&1) {
                cost += book[j].C;
                for (int k = 0; k < M; k++) {
                    count[k] += book[j].A[k];
                }
            }
        }
        bool check = true;
        for (int j = 0; j < M; j++) {
            if (count[j] < X) check = false;
        }
        if (check) ans = min(ans, cost);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
using namespace std;
int  sum;
int a[1001000];
int main()
{
    IO;
    int n;
    cin>>n;
    for(int x=1; x<=100; x++)
        for(int y=1; y<=100; y++)
            for(int z=1; z<=100; z++)
            {
                a[x*x+y*y+z*z+x*y+x*z+z*y]++;
            }
    for(int i=1; i<=n; i++)
    {

        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int main() {
  LL A,B,C,K;
  cin>>A>>B>>C>>K;
  if(A>=K){
    cout<<K<<endl;
  }
  else if(A<K&&A+B>=K){
    cout<<A<<endl;
  }
  else{
    cout<<A-(K-A-B)<<endl;
  }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll aa = a * b;
  ll bb = c * d;
  if (aa < bb) {
    COUT(bb);
  } else {
    COUT(aa);
  }
  return 0;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();
       int b=sc.nextInt();
       int c=sc.nextInt();
       int num=0;
       if(a<=b){
           if(b<=c)System.out.println(a+" "+b+" "+c);
           else{
               if(a<=c)System.out.println(a+" "+c+" "+b);
               else System.out.println(c+" "+a+" "+b);
       }
    }
       else{
           if(b>=c)System.out.println(c+" "+b+" "+a);
           else{
               if(c<=a)System.out.println(b+" "+c+" "+a);
               else System.out.println(b+" "+a+" "+c);
           }
       }
      }
    }


Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
	int N;
	vector<int> v;
	int t;
	cin >> N;
	REP(i, N)
	{
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	int ans;
	ans = v[N / 2] - v[N / 2 - 1];
	cout << ans << endl;
}

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

int main() {
  int h, w, a, i;
  vector<string> s(h);
  cin >> h >> w;
  for(i=0;i<h;i++){
    cin >> s.at(i);
  }
  
  for(i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  
  for(i=0;i<h;i++){
    cout << "#" 
    << s.at(i) << "#" << endl;
  }
  for(i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
    
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

void solve(){
    int X,Y; cin>>X>>Y;

    FOR(i,0,X){
        int other = X-i;
        if(i*2 + other*4 == Y){
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}
    
signed main(){
    
    FastRead;     

    
    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    




Measured memory_bytes: 3636
import itertools

N = int(input())

num = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
    S = input()
    if S[0] in num:
        num[S[0]] += 1

vs = num.values()

ans = 0
for a, b, c in itertools.combinations(vs, 3):
    ans += a * b * c

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
int h,w;
vector<string> board;
vector<vector<int>> dist;
queue<pair<int,int>> q;

bool is_valid_move(vector<string> &board, vector<vector<int>> &dist, int y, int x){
  if(y<0 || y>=h || x<0 || x>=w) return false;
  if(board.at(y).at(x) == '#') return false;
  if(dist.at(y).at(x) != -1) return false;
  return true;
}

int main(){
    cin>>h>>w;
    board.resize(h);
    dist.resize(h,vector<int>(w,-1));
    rep(i,h) cin >> board.at(i);
    q.push(make_pair(0,0));
    dist.at(0).at(0) = 0;

    while(q.size()){
        pair<int,int> p = q.front();
        q.pop();
        int cy = p.first, cx = p.second;
        if(is_valid_move(board,dist,cy+1,cx)){
            dist.at(cy+1).at(cx) = dist.at(cy).at(cx) + 1;
            q.push(make_pair(cy+1,cx));                
        }
        if(is_valid_move(board,dist,cy,cx+1)){
            dist.at(cy).at(cx+1) = dist.at(cy).at(cx) + 1;        
            q.push(make_pair(cy,cx+1));                
        }      
        if(is_valid_move(board,dist,cy-1,cx)){
            dist.at(cy-1).at(cx) = dist.at(cy).at(cx) + 1;        
            q.push(make_pair(cy-1,cx));                
        }
        if(is_valid_move(board,dist,cy,cx-1)){
            dist.at(cy).at(cx-1) = dist.at(cy).at(cx) + 1;
            q.push(make_pair(cy,cx-1));                
        }
    }
    /*
    rep(k,h){
      rep(l,w){
        cout << dist.at(k).at(l);
      }
      cout << endl;
    }
    cout << endl;
    */
      
    int min_dist = dist.at(h-1).at(w-1);
    if(min_dist == -1){
        cout << -1 << endl;
        return 0;
    }

    int blackcount = 0;
    rep(i,h) rep(j,w) if(board.at(i).at(j) == '#') blackcount++;

    cout << h * w - (min_dist+1) - blackcount << endl;
    return 0;    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;
ll n,k;
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>k;
	if(n==k){
		cout<<0<<endl;
	}
	else{
		if(n<k) n=k+(k-n);
	
	cout<<min((k-n%k)%k,n-k)<<endl;
	}
	return 0;
}

Measured memory_bytes: 888
module Main where

import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.Vector.Algorithms.Tim as VAT
import           Data.IntSet                    ( IntSet )
import qualified Data.IntSet                   as IntSet
import           Data.Ord

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- VU.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  as' <- do
    x <- VU.thaw as
    VAT.sortBy (comparing Down) x
    VU.freeze x
  print $ VU.sum $ VU.map (f as') $ VU.enumFromN 0 (n-1)
 where
  f as i = as VU.! ((i + 1) `div` 2)

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

long long a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	long long cntd = b / c - (a - 1) / c;
	long long cntb = b / d - (a - 1) / d;
	long long kmm = c * d / __gcd(c, d);
	long long cnta = b / kmm - (a - 1) / kmm;
	cout << b - a + 1 - cntd - cntb + cnta;
}

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

int main(){
    int N, K, H[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> H[i];
    sort(H, H+N);
    
    int ans = 2e9;
    for(int i=0; i<=N-K; i++) ans = min(ans, H[i+K-1] - H[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
//#include<boost/circular_buffer.hpp>
using namespace std;

//fixed << setprecision(10)
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

int main() {
	int n;
	cin >> n;
	cout << (n - 1) / 2 << endl;
}

/*
int main() {
	double deg, dis;
	cin >> dis >> deg;//逆に書いてしまった

	int w;
	char dir;

	if (112.5 <= dis && dis < 337.5)
		dir = 'NNE';



	deg /= 6;

	if (deg <= 2)
		w = 0;
	else if (3 <= deg && deg <= 15)
		w = 1;
	else if (16 <= deg && deg <= 33)
		w = 2;
	else if (34 <= deg && deg <= 54)
		w = 3;
	else if (55 <= deg && deg <= 79)
		w = 4;
	else if (80 <= deg && deg <= 107)
		w = 5;
	else if (108 <= deg && deg <= 138)
		w = 6;
	else if (139 <= deg && deg <= 171)
		w = 7;
	else if (172 <= deg && deg <= 207)
		w = 8;
	else if (208 <= deg && deg <= 244)
		w = 9;
	else if (245 <= deg && deg <= 284)
		w = 10;
	else if (285 <= deg && deg <= 326)
		w = 11;
	else if (327 <= deg)
		w = 12;

	cout << w << endl;

}
*/

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
w=get_i
s=w.inject(:+)
ans=s
n.times do|i|
  if (s-w[i]*2).abs<ans
    ans=(s-w[i]*2).abs
  end
  s-=w[i]*2
end
puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main(){

    ll d,sum=0,fiv,fi;
    cin>>d;
    fiv=d/500;
    d%=500;
    sum=sum+(fiv*1000);
    fi=d/5;
    sum=sum+(fi*5);
  cout<<sum<<endl;

return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();

		String a = S.substring(0, N/2);
		String b = S.substring(N/2);


		if(a.equals(b)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 23764
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        mut a: [i64; m],
    }

    // let ans: i64 = a.map(|a| a.count ).fold(0, |sum, i| sum + i);
    let a_iter = a.iter();
    let ans: i64 = a_iter.sum();
    if ans <= n as i64 {
        println!("{}", n as i64 - ans);
    } else {
        println!("-1")
    }
}

Measured memory_bytes: 2256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
LL d[50];
LL ans = 0;

int main(){
    cin >> n;
    REP(i, n)cin >> d[i];
    REP(i, n)for(int j = i + 1;j < n;j++){
        ans += d[i] * d[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) { cin >> a[i]; }
    ll ans = LINF;
    for (int l = 0; l + K - 1 < N; l++) {
        int r = l + K - 1;
        ll dist1 = abs(a[l]) + abs(a[r] - a[l]);
        ll dist2 = abs(a[r]) + abs(a[r] - a[l]);
        ans = min({ans, dist1, dist2});
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct na{
	int l,r;
	bool operator <(const na &rr)const
	{
		return r<rr.r;
	}
};
struct nb{
	int l, r;
	bool operator <(const nb &rr)const
	{
		return l>rr.l;
	}
};


string s;
int n;

vector<na>a;
vector<nb>b;

// bool cmp(node x, node y){
//     return x.r < y.r;
// }

// bool cmp1(node x, node y){
//     return x.l > y.l;
// }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> s;
        int len = s.length();
        int l =0, r = 0;
        for(int j = 0; j < len; j++){
            if(s[j] == '(') l++;
            else if(l) l--;
            else r++;
        }
        if(l >= r) a.push_back({l, r});
        else b.push_back({l, r});
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int sum = 0, ok = 0;
    for(int i = 0; i < a.size(); i++){
        sum -= a[i].r;
        if(sum < 0){
            ok = 1;
            break;
        }
        sum += a[i].l;
    }
    int sum1 = 0;
    for(int i = 0; i < b.size(); i++){
        sum -= b[i].r;
        if(sum < 0){
            ok = 1;
           break;
        }
        sum += b[i].l;
    }
    if(ok){
        cout << "No \n"; 
    }else{
        if(sum == 0){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }

}

Measured memory_bytes: 11260
package main

import "fmt"

func main() {
	var A [3][3]int
	var B [3][3]bool
	var N int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	fmt.Scan(&N)
	b := make([]int, N)
	for i := range b {
		fmt.Scan(&b[i])
	}
	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if A[j][k] == b[i] {
					B[j][k] = true
				}
			}
		}
	}
	ans := "No"
	if check(B) {
		ans = "Yes"
	}
	fmt.Println(ans)
}
func check(B [3][3]bool) bool {
	for i := 0; i < 3; i++ {
		if B[i][0] && B[i][1] && B[i][2] {
			return true
		}
	}
	for j := 0; j < 3; j++ {
		if B[0][j] && B[1][j] && B[2][j] {
			return true
		}
	}
	if (B[0][0] && B[1][1] && B[2][2]) ||
		(B[0][2] && B[1][1] && B[2][0]) {
		return true
	}
	return false
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,i,w,n,tmp;
    int array[31];
    
    for(i=0; i<=30; i++){
        array[i] = i;
    }
    
    scanf("%d", &w);
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%d,%d", &a, &b);
        tmp = array[a];
        array[a] = array[b];
        array[b] = tmp;
    }
    
    for(i=1; i<=w; i++){
        printf("%d\n", array[i]);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b%a, a);
}

int gcdans(int arr[])
{
	int result = arr[0];
	for (int i = 1; i < 3; i++)
	{
		result = gcd(arr[i], result);
	}
	return result;
}

int main()
{
	int n, sum = 0;
	int trip[3];
	cin >> n;

	for(int i = 1; i < n+1; i++)
	{
        for(int j = 1; j < n+1; j++)
        {
        	for(int k = 1;  k < n+1; k++)
        	{
        		trip[0] = i;
        		trip[1] = j;
        		trip[2] = k;
        		sum = sum + gcdans(trip);
        	}
        }
	}
    
    cout << sum << endl;

	return 0;
}

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

class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni();
		
		HashMap<String, Integer> m = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String s = f.readLine();
			m.put(s, m.getOrDefault(s, 0) + 1);
		}
		
		out.println("AC x " + m.getOrDefault("AC", 0));
		out.println("WA x " + m.getOrDefault("WA", 0));
		out.println("TLE x " + m.getOrDefault("TLE", 0));
		out.println("RE x " + m.getOrDefault("RE", 0));
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


Measured memory_bytes: 44380
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;

	int sum = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		int n = min(x, abs(K - x));
		sum += n;
	}

	cout << sum * 2 << endl;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
int n, sum = 0;
vector<int> point;

cin >> n;

while(n != 0){
    REP(i, n){
        int tmp;
        cin >> tmp;
        point.pb(tmp);
      }
      sort(point.begin(), point.end());

      FOR(i,1, (n-1)) sum += point[i];
      cout << (sum / (n - 2)) << endl;
      point.clear();
      sum = 0;
      cin >> n;
  }
  return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int s,m;

int calc(int num,int sum,int n)
{
	if(num==m&&sum==s)
		return 1;
	if(n>9)
		return 0;
	return(calc(num+1,sum+n,n+1)+calc(num,sum,n+1));
}

int main()
{
	while(1)
	{
		scanf("%d%d",&m,&s);
		if(m==0&&s==0)
			break;
		printf("%d\n",calc(0,0,0));
	}
	return 0;
}

Measured memory_bytes: 600
# coding: utf-8
# coding: Shift_JIS
# coding: EUC-JP
# coding: cp932
import math

a,b,radi = map(int,input().split())
rad = math.radians(radi)

s = a*b*math.sin(rad)/2.0
c = a+b+math.sqrt(a*a+b*b-2*a*b*math.cos(rad))
h = 2*s/a

print("%.10f %.10f %.10f"%(s,c,h))


Measured memory_bytes: 5724
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n, k;
    n = read(), k = read();
    vector<int> a(n);
    rep(i, 0, n - 1) a[i] = read();
    bool dp[100100];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i - a[j] >= 0) {
                if (!dp[i - a[j]]) dp[i] = true;
            }
        }
    }
    if (dp[k]) puts("First");
    else puts("Second");

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a, b, ans=0, ball, nokori;
    cin >> n >> a >> b;
    ball=a+b;
    ans=a*(n/ball);
    nokori=n%ball;
    ans+=min(nokori, a);
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3656
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> h >> w;
  rep(i, n) {
    cin >> a >> b;
    if (a >= h && b >= w) ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256