akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int ap = 0, ov = 0;
  for(int i=0; i<n; i++) {
    char c = s[i];
    if(c == 'b') ov++;
    if(ap == (a + b) || c == 'c') {
      cout << "No\n";
      continue;
    }
    if(c == 'b' && ov > b) {
      cout << "No\n";
      continue;
    }
    cout << "Yes\n";
    ap++;
  }
  return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a[n],sum=0;

    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
    	a[i]*=4*m;
    }
    int ans=0;
    for(int i=0;i<n;i++){
    	if(a[i]>=sum){
    		ans++;
    	}
    }
    if(ans>=m){
    	cout << "Yes" <<endl;
    }
    else{
    	cout<<"No" <<endl;
    }
    return 0;
}


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

int dp[100001];
vector<vector<int>> g;
int dfs(int u) {

	if(dp[u] != 0)
		return dp[u];
	else {
		for( int v : g[u]) {
			dp[u] = max(dp[u], dfs(v) + 1);
		}
		return dp[u];
	}
}


int main() {
	int n,m;
	cin>>n>>m;
	g.resize(n+1);
	
	for(int i=0; i<m; i++) {
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
	}

	
	queue<int> q;
			
	memset(dp,0,sizeof(dp));
	int ans = 0;
	for(int i=1; i<=n ;i++) {
		ans = max(ans,dfs(i));
	}
	
	cout<<ans;
		return 0;
}

Measured memory_bytes: 7424
package main

import "fmt"

func main() {
	var b string
	fmt.Scan(&b)
	switch b {
	case "A":
		b = "T"
	case "T":
		b = "A"
	case "C":
		b = "G"
	case "G":
		b = "C"
	}
	fmt.Println(b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];
double ca(double h, double 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);

    return angle;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	cout<<fixed<<setprecision(10);
	double pi = 3.14159265358979323846264338327;
	double a, b, h, m;
	cin>>a>>b>>h>>m;
	double ang = ca(h, m);
	double ans = sqrt(a*a + b*b - 2*a*b*cos((ang*pi)/180));
	cout<<ans;
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = min(a*n, b);
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    n := int(nextInt())
    w := make([]int, n)
    for i := 0; i<n; i++ {
      w[i] = nextInt()
    }
    count := 0
    c := 0
    head := 0
    for i := 0; i < n; i++ {
      for ; head < n && (c & w[head]) == 0 ; {
        c = c ^ w[head]
        head++
      }
      count += (head - i)
      c = c ^ w[i]
    } 
    fmt.Println(count)
}


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

const int INF = 100100;

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

  int n, T;
  cin >> n >> T;
  vector<pair<int, int>> ct(n);
  for (int i = 0; i < n; i++) {
    int c, t;
    cin >> c >> t;
    ct[i] = make_pair(c, t);
  }
  int res = INF;
  for (int i = 0; i < n; i++) {
    if (ct[i].second <= T) {
      res = min(res, ct[i].first);
    }
  }
  if (res == INF) cout << "TLE";
  else cout << res;
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        double[] A = new double[a];
        double sum = 0.0;
        double seki = 1.0;
        for(int i = 0;i < a;i++){
            A[i] = 1.0/sc.nextDouble();
            sum += A[i];
            
        } 

        double ans = 1.0/sum;
        System.out.println(ans);

    }
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int a[101];
int n,m,k,i,j,ans;
int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	    if(a[i]>k-a[i]) ans+=(k-a[i])*2;
			else ans+=a[i]*2;
			}
cout<<ans;
return 0;
		}

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

struct Problem {

    void Solve() {
        //float a; cin >> a;
        //cout << 2 * a * 3.14159 << endl;
        /*
        UL N, M; cin >> N >> M;
        rep(i, M) {
            UL a; cin >> a;
            if (N < a) { cout << -1 << endl; return; }
            N -= a;
        }
        cout << N << endl;*/
        UL N; cin >> N;
        vector<UL> ans(N);
        rep(i, N - 1) {
            UL a; cin >> a; a--; ans[a]++;
        }
        rep(i, N) cout << ans[i] << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>

int main(void)
{
    int a, an[6];
    int m, min[3];
    int n;
    int i, j, k;
    
    scanf("%d", &n);

    for (i = 0; i <= 5; i++){
        an[i] = 100000000;
    }
    
    for (i = 0; i < n; i++){
        scanf("%d", &a);
        
        for (j = 0; j <= 5; j++){
            if (a < an[j]){
                for (k = 5; k > j; k--){
                    an[k] = an[k - 1];
                }
                an[j] = a;
                break;
            }
        }
        
        
#if 0
        
        if (a < an[0]){
            an[2] = an[1];
            an[1] = an[0];
            an[0] = a;
        }
        else if (a < an[1]){
            an[2] = an[1];
            an[1] = a;
        }
        else if (a < an[2]){
            an[2] = a;
        }
#endif
    }

// printf("[%d %d %d %d %d %d %d]", an[0], an[1], an[2], an[3], an[4], an[5]);

    min[0] = min[1] = min[2] = 200000000;
    for (i = 0; i <= 5; i++){
        for (j = 0; j <= 5; j++){
            if (i != j){
                if (an[i] < 10){
                    m = an[j] * 10 + an[i];
                }
                else if (an[i] < 100){
                    m = an[j] * 100 + an[i];
                }
                else if (an[i] < 1000){
                    m = an[j] * 1000 + an[i];
                }
                else if (an[i] < 10000){
                    m = an[j] * 10000 + an[i];
                }
                else {
                    m = an[j] * 100000 + an[i];
                }
                
// printf("<%d>", m);
                
                if (m < min[0]){
                    min[2] = min[1];
                    min[1] = min[0];
                    min[0] = m;
                }
                else if (m < min[1]){
                    min[2] = min[1];
                    min[1] = m;
                }
                else if (m < min[2]){
                    min[2] = m;
                }
// printf("[%d %d %d]", min[0], min[1], min[2]);

            }
        }
    }
    
    printf("%d\n", min[2]);
    
    return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int lli;
    #define MAX 1001000
    #define MOD 1000000007
    #define endl "\n"
    lli arr[MAX];
    lli ans[MAX];
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        lli t;
        t = 1;
        while(t--){
            lli K,A,B;
            cin>>K>>A>>B;
            for(lli i = A; i<=B; i++){
                if(i%K == 0){
                    cout<<"OK";
                    return 0;
                }
            }
            cout<<"NG";

               
        }
    }

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check

const string YES = "Yes";
const string NO = "No";

void solve(std::string s){
    bool haveC = false;
    REP(i, s.length()){
        if(s.at(i) == 'C')
            haveC = true;
        if(haveC && s.at(i)=='F'){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

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


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

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

int add(int a, int b){
    return (a+b)%MOD;
}

int mul(int a, int b){
    return((ll)a*b)%MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    string s;
    cin >> s;
    ll res = 1;
    for(int i=2; i<=n; i++){
        res = mul(res, i);
    }
    int tren = 0;
    for(int i=0; i<2*n; i++){
        if(s[i] == 'B'){
            if(tren%2 == 0){
                tren++;
            }
            else{
                res = mul(res, tren);
                tren--;
            }
        }
        if(s[i] == 'W'){
            if(tren%2 == 0){
                res = mul(res, tren);
                tren--;
            }
            else tren++;
        }
    }
    if(tren){
        cout << 0;
        return 0;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 720
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
adj = [[] for _ in range(N)]
visited = [0] * N

for i in range(M):
  a, b = map(int, input().split())
  adj[a-1].append(b)
  adj[b-1].append(a)

ans = []

def dfs(x):
  visited[x-1] = 1
  if visited == [1] * N:
    ans.append(1)
  for i in range(len(adj[x-1])):
    if visited[adj[x-1][i] - 1] == 0:
      dfs(adj[x-1][i])
  visited[x-1] = 0
      
dfs(1)
if ans == []:
  print(0)
else:
  print(sum(ans))

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

static class Program
{
    static IEnumerable<int> Solve(int N, int X, int Y)
    {
        const int INF = int.MaxValue / 2;
        var values = new int[N - 1];
        for (int i = 0; i < N; ++i)
        {
            var d = Enumerable.Repeat(INF, N).ToArray();
            var q = new Queue<int>();
            d[i] = 0;
            q.Enqueue(i);
            while (q.Count > 0)
            {
                int j = q.Dequeue();
                if (j - 1 >= 0 && d[j - 1] > d[j] + 1)
                {
                    d[j - 1] = d[j] + 1;
                    q.Enqueue(j - 1);
                }
                if (j + 1 < N && d[j + 1] > d[j] + 1)
                {
                    d[j + 1] = d[j] + 1;
                    q.Enqueue(j + 1);
                }
                if (j == X - 1 && d[Y - 1] > d[j] + 1)
                {
                    d[Y - 1] = d[j] + 1;
                    q.Enqueue(Y - 1);
                }
                if (j == Y - 1 && d[X - 1] > d[j] + 1)
                {
                    d[X - 1] = d[j] + 1;
                    q.Enqueue(X - 1);
                }
            }
            for (int j = i + 1; j < N; ++j)
            {
                ++values[d[j] - 1];
            }
        }
        return values;
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var values = Solve(V[0], V[1], V[2]);
        foreach (int value in values) { Console.WriteLine(value); }
    }
}


Measured memory_bytes: 40772
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(ll i = 0;i<n;++i)
#define repc(bit,k,n) for (ll bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
const ll MOD = 1000000007;
ll dp[668][2001];
bool checked[668][2001];
ll solve(int cur, int sum){
  if(checked[cur][sum])return dp[cur][sum];
  if(cur<0)return 0;
  if(sum==0)return 1;
  ll ret = 0;
  for(int i = 3;i<=2000;i++){
    if(i>sum)break;
    ret = (ret+solve(cur-1, sum-i))%MOD;
  }
  checked[cur][sum] = true;
  return dp[cur][sum] = ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int s;cin>>s;
  ll S = 0;
  S = (S+solve(667,s))%MOD;
  cout<<S<<endl;

  return 0;
}

Measured memory_bytes: 12368
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	n,m=MI()
	G=[[] for _ in range(n+1)]

	for _ in range(m):
		a,b=MI()
		G[a].append(b)

	A=[10**5]*(n+1)

	for i in range(1,n+1):
		Q=deque([[i,0]])
		D=[-1]*(n+1)
		while Q:
			#print(Q)
			now,d=Q.popleft()
			if now==i and d>0:
				A[i]=d
				break
			for nx in G[now]:
				if D[nx]==-1:
					D[nx]=d+1
					Q.append([nx,d+1])
	#print(A)

	k=min(A)
	#print(k)

	if k==10**5:
		print(-1)
		exit()

	s=A.index(k)
	#print(s)

	A=[]
	Q=deque([[s,0]])
	D=[10**5]*(n+1)

	while Q:
		now,d=Q.pop()
		if now==s and d>0:
			break
		if d==k:
			continue
		A.append(now)
		for nx in G[now]:
			if D[nx]>d+1:
				D[nx]=d+1
				Q.append([nx,d+1])
	D[s]=0

	#print(A)
	#print(D)

	ans=[]
	d=k-1
	for i in reversed(A):
		if D[i]==d:
			ans.append(i)
			d-=1

	print(k)
	print(*ans[::-1],sep="\n")










if __name__ == "__main__":
	main()


Measured memory_bytes: 75004
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;

int main()
{
    ll n,a3,a5,a15,ans;
    scanf("%lld",&n);

    a3=n/3;
    a5=n/5;
    a15=n/15;

    ans=((n+1)*n/2)-3*((a3+1)*(a3)/2)-5*((a5+1)*(a5)/2)+15*((a15+1)*(a15)/2);

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

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int tup = 1;
    while (1) {
        if (tup < b) {
            tup--;
            ans++;
        }
        tup += a;
        if (tup >= b) {
            break;
        }
    }

    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n, d, x[15][15];
int main()
{
	std::cin >> n >> d;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < d; ++j)
			std::cin >> x[i][j];

	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			double res = 0;
			for (int k = 0; k < d; ++k)
				res += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			res = std::sqrt(res);

			int res2 = static_cast<int>(res);
			if (res == res2)
				++ans;
		}

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


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

long long a[200005],b[200005];

int main() {
    long long n,i,j;
    long long sum=0,ans=0;
    scanf("%lld",&n);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(i=0; i<n; i++) {
        scanf("%lld",&a[i]);
        b[a[i]]++;
    }
    for(j=1; j<=n; j++) {
        if(b[j]>1)
            sum+=(b[j]*(b[j]-1))/2;
    }
    for(i=0; i<n; i++) {
        if(b[a[i]]>1)
            ans=sum-(b[a[i]]*(b[a[i]]-1)-(b[a[i]]-1)*(b[a[i]]-2))/2;
        else
            ans=sum;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 5760
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 std::cin.tie(NULL);
 std::cout.tie(NULL);
 long long int N,K;
  cin>>N>>K;
  long long req;
  req=floor((log10(N))/(log10(K)))+1;
  cout<<req<<endl;
  
 return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))

    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val prefectures = Array.fill(n) {
      ArrayBuffer.empty[(Int, Int)]
    }
    for (i <- 0 until m) {
      in.readLine().split("\\s+").map(_.toInt) match {
        case Array(p, y) => prefectures(p - 1).append((y, i))
      }
    }

    val ids = Array.ofDim[(Int, Int)](m)
    for (p <- 0 until n) {
      val rankingInPrefecture = prefectures(p).sortBy(_._1)
      for (r <- rankingInPrefecture.indices) {
        ids(rankingInPrefecture(r)._2) = (p + 1, r + 1)
      }
    }

    @inline
    def print(v: Int): Unit = {
      var column = 100000
      while (true) {
        if (column > v) {
          out.print(0)
          column /= 10
        } else {
          out.print(v)
          return
        }
      }
    }

    @inline
    def println(id: (Int, Int)): Unit = {
      print(id._1)
      print(id._2)
      out.println()
    }

    for (id <- ids) {
      println(id)
    }

    out.flush()
  }
}


Measured memory_bytes: 125912
#include <stdio.h>

int main(void) {
	int N, Y;
	int i, j;
	if (scanf("%d%d", &N, &Y) != 2) return 1;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= N - i; j++) {
			int k = N - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				printf("%d %d %d\n", i, j, k);
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    char s[4];
    int p = 700;

    scanf("%s", s);

    if (s[0] == 'o') p += 100;
    if (s[1] == 'o') p += 100;
    if (s[2] == 'o') p += 100;

    printf("%d\n", p);
}


Measured memory_bytes: 128
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun main (str)
  (loop for i from 0 to (- (length str) 3)
        minimize (abs (- 753 (read-from-string (subseq str i (+ i 3)))))))

(princ (main (read-line)))


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

int main (void){
	int n[5],i;
	cin >> n[0] >> n[1] >> n[2] >> n[3];
	sort(n,n+4);
	if(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using PLL = pair<int, int>;
template <typename T> using V = vector<T>;

V<V<int>> edges;
V<V<int>> ans;
V<PLL> pos;
set<int> outside;
V<int> next_nodes;
    
int N;

int dh[] = { 1, 0, -1, 0 };
int dw[] = { 0, 1, 0, -1 };

bool check_pos(int h, int w) {
    return 0 <= h && h < N &&
           0 <= w && w < N;
}

bool check_outside(int h, int w) {
    return check_pos(h, w) &&
           ((h == 0 || h == N - 1) ||
            (w == 0 || w == N - 1)); 
}

bool check_used(int h, int w) { return ans[h][w] != 0; }
bool check_used(int num) { return pos[num] != PLL(-1, -1); }

void calc_outside(int num, int h, int w) {
    ans[h][w] = num;
    pos[num] = PLL(h, w);
    next_nodes.push_back(num);
    int nxt_num = -1;
    for(int nxt : edges[num]) {
        if(check_used(nxt)) continue;
        if(outside.find(nxt) == outside.end()) continue;
        nxt_num = nxt;
        break;
    }
    if(nxt_num == -1) return;
    for(int i = 0; i < 4; i++) {
        int nh = h + dh[i];
        int nw = w + dw[i];
        if(!check_outside(nh, nw) || check_used(nh, nw)) continue;
        calc_outside(nxt_num, nh, nw);
        break;
    }
}

void calc_inside() {
    V<int> next_next_nodes;
    for(int num : next_nodes) {
        int nxt_cand = -1;
        for(int nxt : edges[num]) {
            if(check_used(nxt)) continue;
            nxt_cand = nxt;
            break;
        }
        if(nxt_cand == -1) continue;
        int h, w;
        tie(h, w) = pos[num];
        for(int i = 0; i < 4; i++) {
            int nh = h + dh[i];
            int nw = w + dw[i];
            if(!check_pos(nh, nw) || check_used(nh, nw)) continue;
            next_next_nodes.push_back(nxt_cand);
            pos[nxt_cand] = PLL(nh, nw);
            ans[nh][nw] = nxt_cand;
            break;
        }
    }
    next_nodes = move(next_next_nodes);
}

int main() {
    cin >> N;
    int pow2 = N * N + 1;
    edges.resize(pow2);
    pos.resize(pow2, PLL(-1, -1));
    ans.resize(N, V<int>(N, 0));
    ans = V<V<int>>(N, V<int>(N, 0));
    for(int i = 0; i < 2 * N * N - 2 * N; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    int init;
    for(int i = 1; i <= N * N; i++) if(edges[i].size() <= 3) {
        outside.insert(i);
        if(edges[i].size() == 2) init = i;
    }

    calc_outside(init, 0, 0);
    while(next_nodes.size()) calc_inside();

    for(auto &&ele : ans) for(int i = 0; i < N; i++) cout << ele[i] << " \n"[i + 1 == N];
    return 0;
}



Measured memory_bytes: 3680
#include<stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if (a<b) {
    if (c<a) {
      printf("%d %d %d\n", c, a, b);
    } else if (b<c) {
      printf("%d %d %d\n", a, b, c);
    } else {
      printf("%d %d %d\n", a, c, b);
    }

  } else if (b<a) {
    if (c<b) {
      printf("%d %d %d\n", c, b, a);
    } else if (a<c) {
      printf("%d %d %d\n", b, a, c);
    } else {
      printf("%d %d %d\n", b, c, a);
    }

  } else if (a=b) {
    if (c<a) {
      printf("%d %d %d\n", c, a, b);
    } else {
      printf("%d %d %d\n", a, b, c);
    }

  } else if (b=c){
    if (a<b) {
      printf("%d %d %d\n", a, b, c);
    } else {
      printf("%d %d %d\n", b, c, a);
    }

  } else if (c=a) {
    if (b<c) {
      printf("%d %d %d\n", b, a, c);
    } else {
      printf("%d %d %d\n", c, a, b);
    }
  }
  return 0;
}

Measured memory_bytes: 1760
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int c = sc.nextInt();
    long[][] d = new long[c][c];
    for(int i = 0; i < c; i++) {
      for(int j = 0; j < c; j++) {
        d[i][j] = sc.nextLong();
      }
    }
    long[][] e = new long[3][c];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        int C = sc.nextInt() - 1;
        e[(i + j) % 3][C]++;
      }
    }
    long ans = Long.MAX_VALUE;
    for(int i = 0; i < c; i++) {
      for(int j = 0; j < c; j++) {
        for(int k = 0; k < c; k++) {
          if((i != j) && (i != k) && (j != k)) {
            long t = 0;
            for(int s = 0; s < c; s++) {
              t += (e[0][s] * d[s][i]);
              t += (e[1][s] * d[s][j]);
              t += (e[2][s] * d[s][k]);
            }
            ans = Math.min(ans, t);
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 80296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  s[k-1]-= ('A'-'a');
  cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define N 2*10e5
using namespace std;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,a;
	cin>>n;
	map <int,int>  m;
	for(int i=0;i<n-1;i++)
	cin>>a , m[a]++;
	for(int i=1;i<=n;i++)
	cout<<m[i]<<endl;
}



Measured memory_bytes: 13032
from itertools import combinations
from sys import maxsize

def check(ls, x):
    for i in ls:
        if i < x:
            return False
    return True


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
total_cost = maxsize
for i in range(1, n + 1):
    comb = list(combinations(a, i))
    for j in comb:
        mo = [0 for p in range(m)]
        cost = 0
        for k in j:
            cost += ls[k][0]
            for h in range(m):
                mo[h] += ls[k][h + 1]
        if check(mo, x):
            total_cost = min(total_cost, cost)

if total_cost ==maxsize:
    print(-1)
else:
    print(total_cost)

Measured memory_bytes: 9344
package main

import (
	"fmt"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)

	layout := "2006/01/02"
	t, _ := time.Parse(layout, s)
	t = t.AddDate(1, 0, 0)
	fmt.Println(t.Format(layout))
}


Measured memory_bytes: 512
n = int(input())
li = list(map(int,input().split()))

sun = [0] * (n +1)

for i in range(0, n):
    sun[i + 1] = sun[i] + li[i]

delta = [0] * n
for i in range(0, n):
    delta[i] = sun[i] - (sun[n] -sun[i])

ans = abs(delta[0])
for i in range(0, n):
    if ans > abs(delta[i]):
        ans = abs(delta[i])
    
print(ans)


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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    cin >> a[0];
    rep(i, N - 1) {
        cin >> a[i + 1];
        if (a[i] + a[i + 1] >= L) {
            cout << "Possible" << endl;
            rep(j, i) {
                cout << j + 1 << endl;
            }
            rep(j, N - i - 1) {
                cout << N - j - 1 << endl;
            }
            return 0;
        }
    }
    cout << "Impossible" << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;
    if (A == B) {
        cout << "Draw" << endl;
        return 0;
    }
    if (A == 1 and B != 1) {
        cout << "Alice" << endl;
        return 0;
    }
    if (A != 1 and B == 1) {
        cout << "Bob" << endl;
        return 0;
    }
    if (A > B) {
        cout << "Alice" << endl;
        return 0;
    }
    if (A < B) {
        cout << "Bob" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll arr[30];
string S;

int main() {
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		arr[S[i] - 'A']++;
	}
	ll cnt = 0;
	for(int i = 0; i < 26; i++) {
		if(arr[i] == 2) {
			cnt++;
		}
	}
	if(cnt == 2) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int N;
int V[30], C[30];
int list[30];
int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int i = 0; i < N; i++) {
		list[i] = V[i] - C[i];
		if (list[i] > 0) {
			ans += list[i];
		}
	}
	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>

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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int cnt[40];

int main(){
  ll ans=0;
  ll res=0;
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n)cin >> a[i];
  for(int i=40;i>=0;i--){
    rep(j,n){
      if(a[j]&((ll)1<<i))cnt[i]++;
    }
    if(2*cnt[i]<n && ans+((ll)1<<i)<=k)ans+=((ll)1<<i);
  }
  rep(i,n)res+=(ans^a[i]);
  cout << res << endl;
return 0;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111;
int a[N][N], dp[N][N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 1, n) {
        string s;
        cin >> s;
        rep(j, 1, m) {
            a[i][j] = s[j - 1] == '#';
        }
    }
    rep(i, 1, n) {
        rep(j, 1, m) {
            if(i == 1 && j == 1) {
                dp[i][j] = a[i][j];
            } else {
                dp[i][j] = 1e9;
                if(i > 1) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i][j] && !a[i - 1][j]));
                }
                if(j > 1) {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + (a[i][j] && !a[i][j - 1]));
                }
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

const std::size_t SIZE = 210;
std::string expr;
ll dp[SIZE][SIZE][2];
bool br[SIZE][2];
bool calced[SIZE][SIZE][2];
const ll inf = 5e15;

ll calc(ll l, ll r, bool is_max) {
    if (calced[l][r][is_max]) return dp[l][r][is_max];
    calced[l][r][is_max] = true;
    if (r - l == 1) return dp[l][r][is_max] = expr[l] - '0';
    ll ret = (is_max ? -inf : inf);
    for (ll i = l + 1; i < r; i += 2) {
        if (br[i - 1][0] && 1 < (i - l)) continue;
        if (br[i + 1][1] && 1 < (r - (i + 1))) continue;
        bool add = (expr[i] == '+');
        ll lv = calc(l, i, is_max);
        ll rv = calc(i + 1, r, (is_max ? add : !add));
        ll val = lv + (add ? rv : -rv);
        if (is_max) chmax(ret, val);
        else chmin(ret, val);
    }
    return dp[l][r][is_max] = ret;
}

int main() {
    std::string s;
    std::cin >> s;
    for (ll i = 0; i < s.size(); i++) {
        bool lb = false, rb = false;
        for (; s[i] == '('; i++) lb = true;
        expr += s[i++];
        for (; s[i] == ')'; i++) rb = true;
        br[expr.size() - 1][0] = lb;
        br[expr.size() - 1][1] = rb;
        if (i < s.size()) expr += s[i];
    }

    std::cout << calc(0, expr.size(), true) << std::endl;
    return 0;
}



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

int main(){
  vector<int> data(5);
  int min = 11;
  int minIdx = -1;
  
  for(int i=0; i<5; ++i) {
    int j;
    cin >> j;
    data[i] = j;
    
    int tmp = j%10;
    if(tmp != 0 && tmp < min) {
      minIdx = i;
      min = tmp;
    }
  }
  
  int sum = 0;
  
  for(int i=0; i<5; ++i) {
    if(i == minIdx){
      sum += data[i];
    }
    else{
      int div = data[i]/10;
      int mod = data[i]%10;
      sum += (mod==0 ? data[i] : div*10+10);
    }
  }
  
  cout << sum << endl;
  
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int A,B;
  cin >> A >> B;
  FOR(i,1,1300){
    if(A == floor(0.08 * i) &&  B == floor(0.1 * i)){
      cout << i << endl;
      exit(0);
    }
  }

  cout << -1 << endl;

}



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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair
# define int long long

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, A, B, a[N], b[N], l, r;

bool check(int x)
{
      for(int i = 1; i <= n; i ++)
            b[i] = a[i];
      for(int i = 1; i <= n; i ++)
            b[i] -= B * x;
      int d = A - B;
      for(int i = 1; i <= n; i ++)
      {
            if(b[i] > 0)
                  x -= (b[i] + d - 1) / d;
      }
      return x >= 0;
}

main()
{
      cin >> n >> A >> B;

      for(int i = 1; i <= n; i ++)
            cin >> a[i];

      r = 2e9;

      while(r - l > 1)
      {
            int md = (l + r) >> 1;
            if(check(md))
                  r = md;
            else
                  l = md;
      }

      if(check(l)) r = l;
      cout << r << endl;
}


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

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    bool flag = true;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        if(!(x&1) && flag){
            if(x%3!=0 && x%5!=0) flag=false;
        }
    }

    if(flag) cout << "APPROVED";
    else cout << "DENIED";

    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>


class vector_t {
public:
  double x;
  double y;
  double z;

public:
  vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};

public:
  vector_t operator^(const vector_t& v) const {
    return vector_t(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
  };
};


class point_t {
public:
  double x;
  double y;
  double z;
  double w;

public:
  point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
  
public:
  vector_t operator-(const point_t& p) const {
    return vector_t(x - p.x, y - p.y, z - p.z);
  };
};


class point_triangle_intersect : public std::unary_function<point_t, bool> {
public:
  point_triangle_intersect(const point_t& p1,
                           const point_t& p2,
                           const point_t& p3) : p1_(p1), p2_(p2), p3_(p3)
  {
  };

public:
  bool operator()(const point_t& p) const {
    if (((p2_ - p1_) ^ (p - p1_)).z >= 0 &&
        ((p3_ - p2_) ^ (p - p2_)).z >= 0 &&
        ((p1_ - p3_) ^ (p - p3_)).z >= 0)
      
      return true;

    if (((p2_ - p1_) ^ (p - p1_)).z <= 0 &&
        ((p3_ - p2_) ^ (p - p2_)).z <= 0 &&
        ((p1_ - p3_) ^ (p - p3_)).z <= 0)
      
      return true;

    return false;
  };

private:
  point_t p1_;
  point_t p2_;
  point_t p3_;
};


int main(int argc, char** argv)
{
  double x1, y1, x2, y2, x3, y3, xp, yp;

  while (std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    point_t p1(x1, y1);
    point_t p2(x2, y2);
    point_t p3(x3, y3);
    point_t p (xp, yp);

    if (point_triangle_intersect(p1, p2, p3)(p)) {
      std::cout << "YES" << std::endl;
    }
    else {
      std::cout << "NO" << std::endl;
    }
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int arr[4000090];
int dp[4000090];
#define ll long long
ll cost(ll x,ll n)
{
    if(x==n) return 0;
    if(x>n) return INT_MAX;

    if(dp[x]!= -1) return dp[x];
    ll ans1=cost((x+1),n)+abs(arr[x+1]-arr[x]);
    ll ans2=cost((x+2),n)+abs(arr[x+2]-arr[x]);
    return dp[x]=min(ans1,ans2);
}
main()
{
    ll t;
    cin>>t;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=t;i++)
    {
        cin>>arr[i];
    }
    cout<<cost(1,t)<<endl;
}



Measured memory_bytes: 21248
/*input
1 100000
1000000000
*/
#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;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll sub(ll x,ll y){
    return (x % MOD - y % MOD + MOD) % MOD;
}
ll mult(ll a,ll b) 
{ 
    return ((a%MOD)*(b%MOD))%MOD;
} 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    priority_queue<int> pq;
    REP(i,n){
        int x;
        cin>>x;
        pq.push(x);
    }
    while(m>0){
        int x=pq.top();
        pq.pop();
      if(x==0) break;
        while((  pq.empty() or x>=pq.top()) and x>0 and m>0){
          
            x=x/2;
            m--;
        }
        pq.push(x);
    }
    ll sum=0;
    REP(i,n){
        sum+=pq.top();
        pq.pop();
    }
    cout<<sum;
}

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

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

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

	vector<int> p(n);
	rep(i, n)
	{
		cin >> p[i];
	}

	int ans = 0;
	rep(i, n - 2)
	{
		if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2])
			|| (p[i + 2] < p[i + 1] && p[i + 1] < p[i]))
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int N,count=0;
  ll K,A[110000],x=1,ans=0,sum=0,B[110000];
  cin>>N>>K;
  
  for(int i=0;i<N;i++) {
    cin>>A[i];
    B[i]=A[i];
  }

  for(int i=0;i<39;i++) x*=2;

  for(int i=0;i<40;i++,count=0,x/=2){
    for(int j=0;j<N;j++){
      if(A[j]>=x){
        //cout<<A[j]<<" "<<x<<endl;
        A[j]-=x;
        count++;
      }
    }
    if(count*2<N && K>=ans+x){
      ans+=x;
    }
  }
  //cout<<ans<<endl;
  for(int i=0;i<N;i++){
    sum+=ans^B[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    double ans=0;
    cin >> n >> k;

    for(int i=1; i<=n; i++) {
        int v = i;
        double w = 1.0/n;
        while(v<k) {
            v *= 2;
            w /= 2;
        }
        ans += w;
    }
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n,A[50],q;

int solve(int c,int m){
	if(m==0)return 1;
	if(c>=n)return 0;
	int tans=solve(c+1,m) || solve(c+1,m-A[c]);
	return tans;
}

int main(){
	int B;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for (int j=0;j<q;j++){
		scanf("%d",&B);
		int ans=solve(0,B);
	if(ans){
		printf("%s\n","yes");
	}else{
		printf("%s\n","no");
	}

	}
	return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> result(4,0);
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s == "AC"){
            result.at(0)++;
        }
        if(s == "WA"){
            result.at(1)++;
        }
        if(s == "TLE"){
            result.at(2)++;
        }
        if(s == "RE"){
            result.at(3)++;
        }
    }
    cout << "AC x " << result.at(0) << endl;
    cout << "WA x " << result.at(1) << endl;
    cout << "TLE x " << result.at(2) << endl;
    cout << "RE x " << result.at(3) << endl;
}

Measured memory_bytes: 3632