akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  string s;
  cin >> s;
  bool ok = 0;
  FOR(i,0,s.size()){
    FOR(j,i,s.size()){
      string sub = s.substr(0, i) + s.substr(j, s.size() - j);
      if(sub=="keyence")
        ok = 1;
    }
  }
  if(ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3648
import math
n = int(input())
count = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
kon = math.sqrt(n)
kon = math.floor(kon)+1
a = factorization(n)
sc = len(a)
if n==1:
  print(0)
else:
  for i in range(sc):
    for j in range(kon):
      if a[i-1][1]>=j+1:
        count=count+1
        a[i-1][1]=a[i-1][1]-j-1
  print(count)

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    
    int x,y;


    cin >> x >> y;
    int ans = 0;
    if(x == 3){
        ans += 100000;
    }
    if(x == 2){
        ans += 200000;
    }
    if(x == 1){
        ans += 300000;
    }
    if(y == 3){
        ans += 100000;
    }
    if(y == 2){
        ans += 200000;
    }
    if(y == 1){
        ans += 300000;
    }

    if(x == 1 && y == 1)ans += 400000;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String s = sc.next();
		for (int i = s.length() - 2; i > 1; i -= 2) {
			String ss = s.substring(0, i);
			if (ss.substring(0, i / 2).equals(ss.substring(i / 2))) {
				System.out.println(ss.length());
				return;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int a[maxn],b[maxn];
int n,ans=0;
int solve(int li){
	int num=0;
	for(int L=1,R=n;L<=n;++L){
		while(R && a[L]+b[R]>=li) --R;
		num^=(n-R)&1;
	}
	return num;
}
int main(){
	n=read();
	REP(i,1,n) a[i]=read();
	REP(i,1,n) b[i]=read();
	DREP(i,28,0){
		REP(j,1,n){
			a[j]&=((1<<i+1)-1);
			b[j]&=((1<<i+1)-1);
		}
		sort(a+1,a+n+1),sort(b+1,b+n+1);
		int x=solve(1<<i)^solve(2<<i)^solve(3<<i);
		ans|=x*(1<<i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){

  int N;
  scanf("%d\n", &N);

  char W[100][11];
  for(int i=0; i<N; i++){
    scanf("%s", &W[i]);
  }

  for(int i=0; i<=N-2; i++){
    for(int j=i+1; j<=N-1; j++){
      if(!strcmp(W[i],W[j])){
        printf("No\n");
        return 0;
      }
    }
    if(W[i][strlen(W[i])-1] != W[i+1][0]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};

int p[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int	x, y;
		cin >> x >> y;
		x--; y--;
		uf.merge(x, y);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (uf.issame(p[i], i)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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

	int f = 0, k = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) f++;
		if (a % 2 == 1) k++;
	}

	if (n % 2) {
		cout << (k - 1 <= f ? "Yes" : "No") << endl;
	}
	else cout << (k <= f ? "Yes" : "No") << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int n, m, x;
    cin >> n >> m >> x;
    
    int front = 0, back = 0;
    rep(i,m){
        int a; cin >> a;
        (a < x ? front : back)++;
    }
    
    cout << min(front, back) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,k,ans = 1;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        ans += min(ans,k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [input().split() for i in range(n)]
for i in range(n):
    a[i][1] = int(a[i][1])
    a[i].append(i + 1)
a.sort()
for i in range(100):
    for j in range(1,n):
        if a[j][0] == a[j-1][0] and a[j][1] > a[j-1][1]:
            a[j-1],a[j] = a[j],a[j-1]
for i in range(n):
    print(a[i][2])

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A, B, N, x;
  cin >> A >> B >> N;
  long s = N/B;
  if(s){
    x = s*B-1;
  }
  else{
    x = N;
  }
  s=A*x/B;
  cout << s-A*(x/B) << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,mod=1e9+7,inf=1e9+10;
int32_t main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0)cout<<a-b;
	else 
		cout<<b-a;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
    int n, v, j;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < n; i++){
        cout << A[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
    
    for(int i = 1; i < n; i++){
        v = A[i];
        for(j = i - 1; j >= 0 ; j--){
            if(v < A[j]){
                A[j+1] = A[j];
            }else{
                break;
            }
        }
        A[j+1] = v;
        for(int i = 0; i < n; i++){
            cout << A[i];
            if(i != n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
    
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> bs(N + 1);
  int a, b;
  for(int i =0; i < M; ++i) {
    cin >> a >> b;
    bs[a].push_back(b);
    bs[b].push_back(a);
  }
  queue<pair<int, int>> qs; // island no, count
  vector<int> cs(N + 1, -1);
  qs.push({1, 0});
  while(!qs.empty()) {
    auto crnt = qs.front();
    qs.pop();
    if(cs[crnt.first] >= 0) {
      cs[crnt.first] = min(cs[crnt.first], crnt.second);
      continue;
    }
    cs[crnt.first] = crnt.second;
    for(auto n : bs[crnt.first]) {
      qs.push({n, crnt.second + 1});
    }
  }
  if(0 <= cs[N] && cs[N] <= 2) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {
 
    int A, B; cin >> A >> B;
    if (A <=8 && B <=8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}


signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    int N;
    cin >> N;
    map<pii, int> myMap;
    int zero_both = MOD - 1;
    rep(i, N){
        int A, B;
        cin >> A >> B;
        bool neg = (A < 0 && B > 0) || (A > 0 && B < 0);
        if(A == 0 && B == 0){
            zero_both++;
            continue;
        }
        A = abs(A);
        B = abs(B);
        int g = gcd(A, B);
        A /= g;
        B /= g;
        pii pr = mp((neg ? -1 : 1) * A, B);
        myMap[pr]++;
    }
    int ans = 1;
    map<pii, bool> visited;
    for(auto f : myMap){
        pii val = f.first;
        int count = f.second;
        if(visited[val] != true){
            pii counter = mp(-1 * val.second, val.first);
            if((counter.first <= 0 && counter.second <= 0) || (counter.first >= 0 && counter.second <= 0)){
                counter.first *= -1;
                counter.second *= -1;
            }
            if(present(myMap, counter)){
                ans = mul(ans, (power(2LL, count, MOD) + power(2LL, myMap[counter], MOD) - 1) % MOD, MOD);
                myMap[counter] = 0;
                visited[counter] = true;
            }else{
                ans = mul(ans, power(2LL, count, MOD), MOD);
            }
            // ans %= MOD;
        }
    }
    ans = (zero_both + ans) % MOD;
    cout << ans << endl;

    return 0;
}


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

int main(){
    int A[3][3] = {0};
    int check[3][3] = {0};
    int n = 0;
    int *b;
    int c;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> c;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(A[j][k] == c){
                    check[j][k] = 1;
                    break;
                }
            }
        }
    }
    if(check[0][0] == 1){
        if(check[1][0] == 1){
            if(check[2][0] == 1){
                cout << "Yes";
                return 0;
            }
        }else if(check[0][1]+check[0][2] == 2){
            cout << "Yes";
            return 0;
        }
    }
    if(check[1][1] == 1){
        if(check[0][0] + check[2][2] == 2 || check[0][2] + check[2][0] == 2 || check[0][1] + check[2][1] == 2|| check[1][0] + check[1][2] == 2){
            cout << "Yes";
            return 0;
        }
    }
    if(check[2][2] == 1){
        if(check[0][2] + check[1][2] == 2 || check[2][0] + check[2][1] == 2){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
    /*
    b = new int [n];
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){

    }




    delete[] b;
    }
    */
}


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


void solve(long long n, std::vector<long long> p){
    int ans = 0;
    for(int i = 0;i < n - 2;i ++){
        if((p[i + 1] < p[i] or p[i + 1] < p[i + 2]) and (p[i + 1] > p[i] or p[i + 1] > p[i + 2])) ans ++;
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> p(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int,input().split()))
S = []
for _ in range(D):
  line = list(map(int,input().split()))
  S.append(line)
T = []
for _ in range(D):
  t = int(input())
  T.append(t)
dic = {n+1:0 for n in range(26)}
ans = 0
for i in range(1,D+1):
  dic[T[i-1]] = i
  ans += S[i-1][T[i-1]-1]
  for j in range(26):
    ans -= c[j]*(i - dic[j+1])
  print(ans)

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

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll t = X / D;
    ll p = K - t;
    if (K >= t)
        if (p % 2 == 0)
            cout << X - t * D;
        else
            cout << (t + 1) * D - X;
    else
        cout << X - K * D;
    return 0;
}

Measured memory_bytes: 3592
N=gets.to_i

ps=(N+1).times.map{[]}
(N-1).times do
    a,b,c = gets.split.map(&:to_i)
    ps[a] << [a,b,c]
    ps[b] << [b,a,c]
end

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

arr = Array.new(N+1,-1)
arr[K] = 0
q = ps[K].dup

until q.empty?
    parent,child,d = q.shift
    next if arr[child] != -1
    arr[child] = arr[parent] + d
    q.concat ps[child]
end

Q.times do
    x,y = gets.split.map(&:to_i)
    puts arr[x]+arr[y]
end

Measured memory_bytes: 34424
import heapq

n, m = map(int,input().split())
a = [-int(i) for i in input().split()]
heapq.heapify(a) 

for i in range(m):
        heapq.heappush(a,heapq.heappop(a)/2)
 
print(sum([int(i) for i in a])*-1)

Measured memory_bytes: 97560
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

U = 2*10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
size = [0]*n
par = [-1]*n
dp1 = [-1]*n
dp2 = [-1]*n
def dfs1(p, v):
  if dp1[v] != -1:
    return dp1[v]
  temp = 1
  s = 1
  for nv in T[v]:
    if nv == p:
      continue
    temp *= dfs1(v, nv)
    temp *= fact_inv[size[nv]]
    temp %= MOD
    par[nv] = v
    s += size[nv]
  size[v] = s
  temp *= fact[s-1]
  temp %= MOD
  dp1[v] = temp
  return temp
dfs1(-1, 0)
def dfs2(v):
  if v == 0:
    return dp1[0]
  if dp2[v] != -1:
    return dp2[v]
  temp = dfs2(par[v])
  temp *= fact[n-size[v]-1]
  temp *= fact[size[v]]
  temp %= MOD
  temp *= fact_inv[size[v]-1]
  temp *= fact_inv[n-size[v]]
  temp %= MOD
  dp2[v] = temp
  return temp
for i in range(n):
  print(dfs2(i))

Measured memory_bytes: 218480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll max1,max2;
  map<ll,int> mp;
  max1 = max2 = 0;
  rep(i,N){
    ll x;cin >> x;
    if(mp.count(x) && mp[x]&1){
      if(x>max1){
        max2 = max1;
        max1 = x;
      }else if(x>max2) max2 = x;
    }else mp[x] = 0;
    ++mp[x];
  }
  cout << max1*max2 << endl;
  return 0;
}


Measured memory_bytes: 6528
A = list(input())
B = list(input())
C = list(input())
next = A.pop(0)
while 1:
  if next == 'a':
    if len(A) == 0:
      print("A")
      break
    next = A.pop(0)
  elif next == 'b':
    if len(B) == 0:
      print("B")
      break
    next = B.pop(0)
  else:
    if len(C) == 0:
      print("C")
      break
    next = C.pop(0)


Measured memory_bytes: 38256
#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <complex>
#pragma comment(linker, "/STACK:167772160")

using namespace std;
#define mp make_pair
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " : " << (x) << endl
#define print_array(arr, len) {cerr << #arr << " : "; for(int i = 0; i < len; ++i) cerr << arr[i] << ' '; cerr << endl;}
#define print_2d_array(arr, len1, len2) {cerr << #arr << endl; for(int i = 0; i < len1; ++i, cerr << endl) for(int j = 0; j < len2; ++j) cerr << arr[i][j] << ' ';}
#define print_iterable(i) {cerr << #i << " : "; for(auto e : i) cerr << e << ' '; cerr << endl;}
#define print_new_line() cerr << endl
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) {}
#define print_2d_array(arr, len1, len2) {}
#define print_iterable(i) {}
#define print_new_line() (void)0
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int INF = 1e9 + 10;
const ll LINF = ll(2e18) + 10;
const double PI = acosl(-1);
const double eps = 1e-8;
const ld EPS = 1e-11;
#pragma endregion

void solve()
{
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	ll d = min(n, m / 2);
	n -= d;
	m -= 2 * d;
	ans += d + m / 4;
	cout << ans << endl;
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#ifdef NOERR
	freopen("err.txt", "w", stderr);
#endif
#else
	//freopen("alter.in", "r", stdin);
	//freopen("alter.out", "w", stdout);
#endif

#ifdef ST
	while(true)
		solve();
#endif
#ifdef CASES
#define MULTITEST
#endif
#ifdef MULTITEST
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; ++i)
	{
#ifdef CASES
		printf("Case #%d: ", i + 1);
#endif
		solve();
#ifdef CASES
		//eprintf("Passed case #%d:\n", i + 1);
#endif
	}
#else
		solve();
#endif

	eprintf("\n\nTime: %.3lf", double(clock()) / CLOCKS_PER_SEC);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    string n;
	cin >> n;
    ll keta[n.length()];
    ll ni[n.length()+1];
    keta[0]=1;
    ni[0]=1;
    int j=0;
    ll de =1000000007;
    ll ans=0;
   for(int i=1;i<n.length();i++){
     keta[i]=keta[i-1]*3%de;
   }
   for(int i=1;i<n.length()+1;i++){
     ni[i]=ni[i-1]*2%de;
   }
   fr(i,n.length()){
     if(n.substr(i, 1)=="1"){
       ans+=keta[n.length()-i-1]*ni[j]%de;
       j++;
     }
   }
   ans += ni[j];
   ans%=de;
    cout << ans << endl;
}


Measured memory_bytes: 2048
#include <string.h>

int count,map[52][52];
int dir[8][2]={{-1,0},{-1,1},{-1,-1},{0,1},{1,0},{1,1},{1,-1},{0,-1}};

void solve(int i,int j){
  int k;

  map[i][j] = 0;
  for(k=0;k<8;k++){
    if(map[i+dir[k][0]][j+dir[k][1]]==1){solve(i+dir[k][0],j+dir[k][1]);}
  }
}

int main(void){
  int i,j,w,h;

  while(1){
    scanf("%d%d",&w,&h);
    if(!w && !h) break;

    memset(map,0,sizeof(map));
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        scanf("%d",&map[i][j]);
      }
    }

    count = 0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        if(map[i][j]==1){solve(i,j);count++;}
      }
    }
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,d1,d2,len,a[605][605];
void solve(int d)
{
	len=0;
	while (d%4==0) len++,d/=4;
    for (int i=0;i<2*n;i++)
	  for (int j=0;j<2*n;j++)
	  {
	  	if (d%2==1) a[i][j]=(((i>>len)+(j>>len))&1)?1:a[i][j];
	  	if (d%4==2) a[i][j]=((i>>len)&1)?1:a[i][j];
	  }
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	solve(d1);
	solve(d2); 
	int calc=0;
	for (int i=0;i<2*n;i++)
	  for (int j=0;j<2*n;j++)
	   {
	   	 if (a[i][j]==0) 
			{
			  printf("%d %d\n",i,j);
	   	      calc++; if (calc==n*n) return 0;	
			}
	   }
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string w;
  cin >> w;
  int a[26] = {};
  for (int i = 0; i < (int)w.size(); i++) a[w[i]-'a']++;
  bool j = true;
  for (int i = 0; i < 26; i++) if (a[i]%2) j = false;
  dump(j ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
            Console.WriteLine(3);
        else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R')
            Console.WriteLine(2);
        else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
            Console.WriteLine(1);
        else
            Console.WriteLine(0);
    }
}

Measured memory_bytes: 25944
#include <iostream>
#include<string>
//#include<algorithm>
//#include<vector>
//#include<cmath>

using namespace std;

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


Measured memory_bytes: 256
class Union_Find:
    def __init__(self, N):
        self.N = N
        self.par = [i for i in range(N)]
        self.height = [0 for i in range(N)]
        self.size = [1 for i in range(N)]
    def Find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.Find(self.par[x])
        return self.par[x]
    def Size(self, x):
        return self.size[self.Find(x)]
    def Union(self, x, y):
        x, y = self.Find(x), self.Find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1
    def Same(self, x, y):
        return self.Find(x) == self.Find(y)


N, M = map(int, input().split())
p = list(map(int, input().split()))
uf = Union_Find(N + 1)
for _ in range(M):
    x, y = map(int, input().split())
    uf.Union(x, y)
ans = 0
for i in range(N):
    if uf.Same(p[i], i + 1):
        ans += 1
print(ans)


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

struct STORE {
  long long yen;
  long long maxDrink;
};

bool compare(const STORE& left, const STORE& right) {
    return left.yen < right.yen;
}

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

  int n, m;
  cin >> n >> m;
  vector<STORE> store(n);
  for(int i = 0; i < n; i++) {
    cin >> store[i].yen >> store[i].maxDrink;
  }
  sort(store.begin(), store.end(), compare);

  long long sumYen = 0;
  long long sumDrink = 0;
  for(int i = 0; i < n; i++) {
    if(sumDrink + store[i].maxDrink > m) {
      sumYen += store[i].yen * (m - sumDrink);
      break;
    }
    sumYen += store[i].yen * store[i].maxDrink;
    sumDrink += store[i].maxDrink;
  }

  cout << sumYen << endl;

}


Measured memory_bytes: 1792
import fileinput


def gcd(a, b):
    if b == 0:
        r = a
    else:
        r = gcd(b, a % b)
    return r


def gcdl(l):
    r = gcd(l[0], l[1])
    for i in range(2, len(l)):
        r = gcd(r, l[i])
    return r


def algorithm(n, a):
    return gcdl(a)


def pass_inputs(input_lines):
    n = input_lines[0][0]
    return algorithm(n, input_lines[1])


def convert_int(s):
    try:
        r = int(s)
    except ValueError:
        r = s
    return r


def run():
    out = pass_inputs([[convert_int(v) for v in l.strip().split(" ")] for l in fileinput.input()])
    print(out)


if __name__ == "__main__":
    run()


Measured memory_bytes: 15196
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e10;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  string S; cin>>S;
  if(S=="ARC") cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdbool.h>
#define MAX(ans1,ans2) ((ans1) > (ans2) ? (ans1) : (ans2))

long long a[100000];
int cnt[41];

int main(void) {
    int n;
    long long k;

    scanf("%d %lld", &n, &k);

    for (int i = 0;i < n;++i)
        scanf("%lld", &a[i]);

    for (int i = 0;i < n;++i)
        for (int j = 40;j >= 0;--j)
            if (((1LL << j) & a[i]) == 0)
                cnt[j]++;

    long long total1 = 0, total2 = 0;
    bool chk = false;
    for (int i = 40;i >= 0;--i) {
        if ((total1 | (1LL << i)) <= k && cnt[i] >= n - cnt[i])
            total1 |= 1LL << i;
        if (chk && (total2 | (1LL << i)) <= k && cnt[i] >= n - cnt[i])
            total2 |= 1LL << i;
        if (k >= (1LL << i))
            chk = true;
    }

    long long ans1 = 0, ans2 = 0;
    for (int i = 0;i < n;++i) {
        ans1 += total1 ^ a[i];
        ans2 += total2 ^ a[i];
    }

    printf("%lld", MAX(ans1, ans2));

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, A[200020];

void solve(){
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", A+i);
	ll ans = 0;
	for(int i=1, p=1;i<=n;i++) {
		int t = (A[i] - 1) / p;
		ans += t;
		if(A[i] == p || p == 1) ++p;
	}
	printf("%lld\n", ans);
}

int main(){
	int T = 1; // scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 640
L, R = map(int, input().split())

a = L // 2019
b = R // 2019
if L > R or L == 0:
  ans = 0
  print(ans)
  exit()

c = L // 3
d = R // 3
e = L // 673
f = R // 673
if d > c and f > e:
  ans = 0
  print(ans)
  exit()
else:
  ans = 2019
  for i in range(L,R+1):
    for j in range(i+1, R+1):
      ans = min((i*j)%2019,ans)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(int argc, char const *argv[]) {
  char str[100], res[100];
  int i=0, j=0;
  scanf("%s", str);
  while( str[i] != '\0' ){
    if( str[i] != 'B' ){
      res[j] = str[i];
      i++;
      j++;
    }else if( str[i]=='B' && j>0 ){
      res[j] = '\0';
      i++;
      j--;
    }else{
      i++;
    }
  }
  res[j] = '\n';
  printf("%s", res);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;

    string ans = "";

    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    while (1) {
        if (N % 2 == 0) { 
            ans = to_string(0) + ans;
            N /= -2;
        }
        else if (N != 1) {
            ans = to_string(1) + ans;
            if (N >= 0) { N /= -2; }
            else { N = N / (-2) + 1; }
        }
        else if (N == 1) {
            ans = to_string(1) + ans;
            break;
        }
    }

    cout << ans << endl;
    return 0;

}

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

int a;

int main()
{
    cin>>a;
    bool f=0;
    for (int i=0; i<100; ++i)
    {
        if ((a-4*i>=0) && ((a-4*i)%7==0))
        {
            cout<<"Yes"<<endl;
            f=1;
            break;
        }
    }
    if (!f)
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int a,b,c,x,y;
    
    cin >> a >> b >> c >> x >> y;

    long long int kane = a*x + b*y;

    while(x != 0 && y!= 0){
        if(kane + c*2 - a - b < kane){
            kane = kane + c*2 - a - b;
            x--;
            y--;
        }else{
            cout << kane;
            return 0;
        }
    }
    if(x == 0){
    while(y!= 0){
        if(kane + c*2 - b < kane){
            kane = kane + c*2 - b;
            y--;
        }else{
            cout << kane;
            return 0;
        }
    }
    }

    if(y == 0){
    while(x != 0){
        if(kane + c*2 - a < kane){
            kane = kane + c*2 - a;
            x--;
        }else{
            cout << kane;
            return 0;
        }
    }
    }
    
    cout << kane;
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int[] fra = {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
    	int minFra = Integer.MAX_VALUE;
    	int order = 0;
    	for (int i = 0; i < fra.length; i++) {
    		if (0 < fra[i]%10 && fra[i]%10 < minFra) {
    			minFra = fra[i]%10;
    			order = i;
    		}
    	}
    	int count = 0;
    	for (int i = 0; i < fra.length; i++) {
    		if (i != order && 0 < fra[i]%10) {
    			count += fra[i] + 10 - fra[i]%10;
    		} else {
    			count += fra[i];
    		}
    	}
    	System.out.println(count);
    }
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int m = in();
  REP(i,m) {
    int tmp = in();
    n -= tmp;
    if(n < 0) break;
  }
  if(n < 0) {
    cout << -1;
  } else {
    cout << n;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int n,m;cn(n,m)
  vector<int> ans(n,-1);
  rep(i,m){
    int s,c;cn(s,c)
      if ( ans[s-1]>=0 && ans[s-1] != c ){
        co("-1")
        return 0;
      }
      ans[s-1] = c;
  }
  if (n>1&&ans[0]==0){
    co("-1")
    return 0;
  }
  if (n>1)ans[0] = max(ans[0],1);
  rpv(ans){
    cout << max(v,0);
  }
  cout << endl;
}

Measured memory_bytes: 256
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double PI  =3.141592653589793238463;
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int a,b,h,m;
	cin>>a>>b>>h>>m;
	//if (h == 12) h = 0;  
    //if (m == 60) m = 0;  

		double hour_angle = 0.5 * (h * 60 + m);  
    	double minute_angle = 6 * m;  
     	double angle = abs(hour_angle - minute_angle);
        angle = min(360 - angle, angle);
        //cout<<angle<<endl;
        angle=angle*PI/180.0;
		double ans=(a*a+b*b)-((2*(a*b))*cos(angle));
		cout<<fixed<<setprecision(12)<<sqrt(ans);
        



	
}

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

int n,q,bs;
int a[500005];
pair<pair<int,int>,int> qs[500005];
int ans[5000005];
int mp[5000005],cnt;

int main(){

    scanf("%d%d",&n,&q);
    bs=sqrt(n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    for(int i=0;i<q;i++){
        scanf("%d%d",&qs[i].first.first,&qs[i].first.second);
        qs[i].first.first--;
        qs[i].first.second--;
        qs[i].second=i;
    }
    sort(qs,qs+q,[](const pair<pair<int,int>,int> &i,const pair<pair<int,int>,int> &j){
        if(i.first.first/bs!=j.first.first/bs)return i.first.first/bs<j.first.first/bs;
        return i.first.second<j.first.second;
    });
    int l=0,r=-1;
    for(int i=0;i<q;i++){
        const pair<pair<int,int>,int> &p=qs[i];
        while(r<p.first.second){
            r++;
            mp[a[r]]++;
            cnt+=mp[a[r]]==1;
        }
        while(l>p.first.first){
            l--;
            mp[a[l]]++;
            cnt+=mp[a[l]]==1;
        }
        while(l<p.first.first){
            mp[a[l]]--;
            cnt-=mp[a[l]]==0;
            l++;
        }
        while(r>p.first.second){
            mp[a[r]]--;
            cnt-=mp[a[r]]==0;
            r--;
        }
        ans[p.second]=cnt;
    }
    for(int i=0;i<q;i++){
        printf("%d\n",ans[i]);
    }

    return 0;
}

Measured memory_bytes: 15456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: chars,
    }
    for i in 0..3 {
        if n[i] == '1' {
            print!("{}", 9);
        } else {
            print!("{}", 1);
        }
    }
    println!("");
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int sum = 0;
  if (k-a <= 0) {
	cout << k;
    return 0;
  }
  else {
    sum = a;
    k-=a;
  }
  if (k-b <= 0) {
    cout << sum;
    return 0;
  } else k-=b;
  sum-=k;
  cout << sum;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    string s;
    cin >> s;
    string ans = "No";
    if(s[2] == s[3] && s[4] == s[5]){
        ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


int main(){
  int n,l;
  cin>>n>>l;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  string ans;
  rep(i,n)ans+=s[i];
  cout<<ans<<endl;
}

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

namespace AtTest.C_Challenge
{
    class ABC_085
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] ny = ReadInts();
            ny[1] /= 1000;
            for (int i = 0; i <= ny[0]; i++)
            {
                for(int j = 0; j <= ny[0] - i; j++)
                {
                    int val = 10 * i + 5 * j + 1 * (ny[0] - i - j);
                    if (val == ny[1])
                    {
                        Console.WriteLine(string.Format("{0} {1} {2}",
                            i, j, ny[0] - i - j));
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

const int maxn = 5000;

int val[maxn], dp[maxn], step[maxn];

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    int k = (1 << n);
    for (int i = 1; i < maxn; i++)
        dp[i]  = 1e13;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        int check = 0;
        val[i] = a;
        for (int j = 0; j < b; j++)
        {
            int x;
            cin >> x;
            x--;
            check |= (1 << x);
        }
        step[i] = check;
    }
    for (int i = 0; i < maxn; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int kek = (i | step[j]);
            if (kek >= maxn)
                continue;
            dp[kek] = min(dp[kek], dp[i] + val[j]);
        }
    }
    int ans = dp[(1 << n) - 1];
    if (ans == 1e13)
        cout << -1;
    else
        cout << ans;
    return 0;
}


Measured memory_bytes: 384