akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // 6, 5, 6, 5, 6, 5, ....
  ans = n / 11 * 2;
  n %= 11;
  if(n > 6)
    ans += 2;
  else if(n > 0)
    ans++;
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define REP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define REPI(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define REPITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, a[100008], dp[100008];
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    //memset(dp,INT_MAX,sizeof(dp));
    for (int i = 0; i < 100008; ++i)
        dp[i] = INT_MAX;
    dp[1] = 0;
    for (int i = 2; i <= n; ++i)
    {
        //cout<<dp[i]<<endl;
        int u = 1;
        while (u <= k)
        {
            if (i - u >= 1)
                dp[i] = min(dp[i], dp[i - u] + abs(a[i] - a[i - u]));
            u++;
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    ll H, W, K; 
    cin >> H >> W >> K;
    
    vector<pii> in;

    vector<vector<ll > > grid(H, vector<ll >(W, -1));

    ll cn = 1;
    for(ll row = 0; row < H; row++){
        for(ll col = 0; col < W; col++){
            char t = 0; cin >> t;
            if(t == '#'){
                grid[row][col] = cn;
                in.push_back(make_pair(make_pair(row, col), cn));
                cn++;
            }
        }
    }

    bool f = 0;
    //cout << "ok" << endl;
    
    for(ll i = 0; i < in.size(); i++){
        //cout << in[i].first.first << " " << in[i].first.second << endl;
        //左
        ll row = in[i].first.first;
        ll col = in[i].first.second;
        for(ll left = col-1; left >= 0; left--){
            if(grid[row][left] != -1) break;

            grid[row][left] = in[i].second;
        }
        //右
        for(ll right = col+1; right < W; right++){
            if(grid[row][right] != -1) break;

            grid[row][right] = in[i].second;
        }
    }
    
    //確認

    for(ll col = 0; col < W; col++){
        for(ll row = 0; row < H; row++){
            if(grid[row][col] == -1) continue;
            //うえ
            for(ll up = row-1; up >= 0; up--){
                if(grid[up][col] != -1) break;
                grid[up][col] = grid[up+1][col];               
            }
            //した
            for(ll down = row+1; down < H; down++){
                if(grid[down][col] != -1) break;
                grid[down][col] = grid[down-1][col];    
            }
        }

    }

    for(ll row = 0; row < H; row++){
        for(ll col = 0; col < W; col++){
            cout << ( col ? " " : "" ) << grid[row][col];
        }
        cout << endl;
    }


}

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

#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)

int ext_gcd(int a, int b, int &x, int &y){
  if(b == 0){
    x = 1; y = 0; return a;
  }
  int q = a / b;
  int g = ext_gcd(b, a-q*b, x, y);
  int z = x - q * y;
  x = y; y = z;
  return g;
}

map<int,int> pf(int n){
  map<int,int> res;
  FOR(i,2,sqrt(n)+1){
    if(n == 1) break;
    while(n%i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n]++;
  return res;
}

int main(){
  int p, q; cin >> p >> q;
  int x, y;
  q /= ext_gcd(p,q,x,y);
  auto pr = pf(q);
  int ans = 1;
  for(auto pa : pr) ans *= pa.first;
  cout << ans << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char A,B,C,D;
    cin>>A>>B>>C>>D;
    int a=A-48,b=B-48,c=C-48,d=D-48;
    if (a+b+c+d==7) {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    } else if (a+b+c-d==7) {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    } else if (a+b-c+d==7) {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    } else if (a+b-c-d==7) {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    } else if (a-b+c+d==7) {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    } else if (a-b+c-d==7) {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    } else if (a-b-c+d==7) {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    } else if (a-b-c-d==7) {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
}

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

int main()
{
    char ch[100],str1,str2;
    gets(ch);
    int n=strlen(ch),i,c=0;
    str1=ch[0];
    str2=ch[n-1];
    for(i=0; i<n; i++)
    {
        c++;
    }
    printf("%c%d%c\n",str1,(c-2),str2);

}



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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c;
	}
	else if (a == c) {
		cout << b;
	}
	else {
		cout << a;
	}
}

Measured memory_bytes: 256
N, D = map(int,input().split())
listA = []
for i in range(N):
    listA.append(list(map(int,input().split())))
import numpy
a = 0
for i in range(N - 1):
    for j in range(i+1):
        b = numpy.linalg.norm((numpy.array(listA[i+1])-numpy.array(listA[j])))
        if b-int(b) == 0:
            a += 1
print(a)

Measured memory_bytes: 12504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 100005
using namespace std;
typedef long long ll;
ll a[N],b[N],sumb[N]= {0};
int main()
{
 
    ll n,y;
    while(scanf("%lld%lld",&n,&y)==2)
    {
        ll imax=-111111,sum=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%lld%lld",&a[i],&b[i]);
            if(a[i]>imax)
                imax=a[i];
        }
        int num=0;
        sort(b+1,b+1+n);
        for(int i=n; i>=1; i--)
        {
            if(imax<=b[i]&&y>0)
            {
                y=y-b[i];
                num++;
            }
        }
        y=y-sum;
        int r=y/imax;
        if(r>0)
        {
            if(r*imax<y)
                r++;
            num+=r;
        }
        printf("%d\n",num);
    }
 
}

Measured memory_bytes: 1792
n = int(input())
a = [int(i) for i in input().split()]

minCost = 10000*1000
for i in range(101):
    cost = 0
    for j in range(len(a)):
        cost += (i - a[j])**2
    if cost < minCost:
        minCost = cost
    cost = 0
    for j in range(len(a)):
        cost += (i + a[j]) ** 2
    if cost < minCost:
        minCost = cost
print(minCost)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n; ll a[100000], x;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		if(a[i]+a[i+1] > x){
			ll need = (a[i]+a[i+1])-x;
			ans += need;
			a[i+1] -= min(a[i+1], need);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    char curr;
    int rev = 0,a,f,q;
    cin >> s;
    deque<char> dq;
    for(int i = 0; i < s.length(); i++){
        dq.push_back(s[i]);
    }
    cin >> q;
    while(q--){
        cin >> a;
        if(a == 1){
            rev = rev ^ 1;
        }
        else{
            cin >> f >> curr;
            if(f == 1){
                if(rev == 1){
                    dq.push_back(curr);
                }
                else{
                    dq.push_front(curr);
                }
            }
            else{
                if(rev == 1){
                    dq.push_front(curr);
                }
                else{
                    dq.push_back(curr);
                }
            }
        }
    }
    if(rev == 1){
        deque <string> :: reverse_iterator it; 
        for(int i = dq.size() - 1; i >= 0; i--){
            cout << dq[i];
        }
    }
    else{
        deque <string> :: iterator it; 
        for(int i = 0; i < dq.size(); i++){
            cout << dq[i];
        }
    }
    return 0;
}



Measured memory_bytes: 976
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 100000;
ll A[NM];

ll MOD = 1000000007;


void solve() {
    ll N,A,B;
    cin >> N >> A >> B;

    ll oneset = A + B;
    ll loops = N / oneset;
    ll amari = N % oneset;

    ll sum = loops * A;
    if (amari > A) {
        sum = sum + A;
    }
    else {
        sum = sum + amari;
    }
    cout << sum;
}



int main() {
    solve();
    return 0;
}







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

int main(){
  ll a;
  string s;
  cin>>a>>s;
  int c=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  cout<<a*c/100<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    int N,Y;
    cin>>N>>Y;
    int y=Y/1000;
    if(Y%1000!=0){
        cout<<"-1 -1 -1"<<endl;
        return 0;
    }

    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(4*j==y-N-9*i){
                int z=N-i-j;
                cout<<i<<" "<<j<<" "<<z<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// row, column, left or right
bool movearray[40][15][2];
int n, m, goal, d;

bool solve(int r, int c, int prev) {
    if(r == d) {
        if(c == goal) return true;
        else return false;
    }
    else {
        if(movearray[r][c][0] && prev != 1) return solve(r, c-1, 0);
        else if(movearray[r][c][1] && prev != 0) return solve(r, c+1, 1);
        else return solve(r+1, c, -1);
    }
    return false;
}

int main() {
    while(cin >> n, n) {
        cin >> m >> goal >> d; m--; goal--;
        memset(movearray, false, sizeof(movearray));
        int inp;
        int board[40][15] = {};
        rep(i,0,d) rep(j,0,n-1) {
            scanf("%1d", &inp);
            if(inp == 1) {
                movearray[i][j  ][1] = true;
                movearray[i][j+1][0] = true;
                board[i][j] = inp;
            }
        }

        if(solve(0, m, -1)) cout << 0 << endl;
        else {
            bool ans = false;
            rep(i,0,d) rep(j,0,n-1) {
                if(ans) continue;
                bool ok = true;
                if(board[i][j]) ok = false;
                if(j != 0   && board[i][j-1]) ok = false;
                if(j != n-2 && board[i][j+1]) ok = false;
                if(!ok) continue;

                movearray[i][j  ][1] = true;
                movearray[i][j+1][0] = true;
                if(solve(0, m, -1)) {
                    printf("%d %d\n", i+1, j+1);
                    ans = true;
                }
                movearray[i][j  ][1] = false;
                movearray[i][j+1][0] = false;
            }
            if(!ans) cout << 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3144
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

dp = [-1]*(N+1)
for i in a:
    dp[i] = 0

dp[0] = 1
mod = 1000000007

for i in range(1, N+1):
    if dp[i] == 0:
        continue
    else:
        if i > 1:
            dp[i] = (dp[i-1] + dp[i-2]) % mod
        else:
            dp[i] = dp[i-1] % mod

print(dp[-1])


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

namespace ConsoleApp1
{
    static class BRollerCoaster
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int n = nk[0];
            int k = nk[1];

            var hList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            Console.WriteLine(hList.Count(h => k <= h));
            Console.ReadLine();
        }
    }
}

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

int main(){
	int n,p,tmp,odd=0,even=0;
  	long count=0,t;
  	cin >> n >> p;
  	for(int i = 0; i < n;i++) {
    	cin >> tmp;
      	(tmp%2==0)? even++ : odd++ ;
    }
  	for(int i =p;i<=odd ; i+=2){
    	t = 1;
      	for(int j = 1; j <= i; j++) {
        	t *= odd-j+1;
          	t /= j;
        }
      	count += t;
    }
  	for(int i = 1; i <=even; i++)
      	count *= 2;
  	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int n, m;
typedef struct {
    char name[256];
    int weight;
    int limit;
} FOODS;

char answer[10][256];
FOODS lunch[10];
double G;

void editPermutation(int *p)
{
	int i, j, k;
    int sum[10], deno;
    
    memset(sum, 0, sizeof(sum));
    for (i = n - 2; i >= 0; i--){
        sum[i] = sum[i + 1] + lunch[p[i + 1]].weight;
        if (lunch[p[i]].limit < sum[i]){
            return;
        }
    }
    
    sum[0] += lunch[p[0]].weight;
    
    deno = 0;
    for (i = 0; i < n; i++){
        deno += (i + 1) * lunch[p[i]].weight;
    }
    
    if (G > deno * 1.0 / sum[0]){
        G = deno * 1.0 / sum[0];
        for (i = 0; i < n; i++){
            strcpy(answer[i], lunch[p[i]].name);
        }
    }
}

int ok[10];

void put(int *p, int pos, int k)
{
	int j;

	p[pos] = k;
	if (pos == n - 1){
        editPermutation(p);
	}
	else {
		ok[k] = 0;
		for (j = 0; j < n; j++){
            if (ok[j] == 1){
                put(p, pos + 1, j);
            }
		}
		ok[k] = 1;
	}
}
/*
void makePermutation(int *p){
	int k;

	for (k = 0; k < n; k++){
        ok[k] = 1;
    }
    
	for(k = 0; k < n; k++){
        put(p, 0, k);
	}
}
*/

void makePermutation(int *p)
{
    int c[10], *pc, *q;
	int k, t;
    
    q = p;
    pc = c;
    
	for (k = 0; k < n; k++){
        *q++ = *pc++ = k;
	}
	k = 0;
	pc = c;
	do
	{
		t = *(p + k);
		*(p + k) = *(q = p + ((k & 1) ? *pc: 0));
		*q = t;
		editPermutation(p);
		k = 0;
		pc = c;
		while (*pc == 0){
            *pc++ = k++;
		}
		(*pc)--;
	} while (k < n);
}

int main(void)
{
    int p[10];
    int i, j;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%s%d%d", lunch[i].name, &lunch[i].weight, &lunch[i].limit);
        }
        G = 1000000000;
        makePermutation(p);
        for (i = 0; i < n; i++){
            printf("%s\n", answer[i]);
        }
    }
    
    return (0);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 + 5;
ll k , n ,A[N];


int main(){
    fastIO;
    cin>>n>>k;
    for(int i = 0 ; i<n ; i++){
        cin>>A[i];
    }
    sort(A,A+n);
    ll ans = 0;
    for(int i = n-1 ; i>=0 ; i--){
        if(k>0){
            k--;
            continue;
        }
        ans+=A[i];
    }
    cout<<ans;

}


Measured memory_bytes: 5164
N, W = map(int, input().split())
W_calc = W
ans = 0

items = []

for _ in range(N):
    v, w = map(int, input().split())
    density = v / w
    items.append([density, v, w])


items.sort(reverse=True)

for density, v, w in items:
    if w < W_calc:
        W_calc -= w
        ans += v
    else:
        ans += W_calc * density
        break

print(ans)


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

int main() {
  int n, q;
  cin >> n >> q;
  priority_queue<int> PQ[n];
  for (int i = 0; i < q; i++) {
    int query, t, x;
    cin >> query;
    if (query == 0) {
      cin >> t >> x;
      PQ[t].push(x);
    }
    else if (query == 1) {
      cin >> t;
      if (!PQ[t].empty()) {
        cout << PQ[t].top() << endl;
      }
    }
    else if (query == 2) {
      cin >> t;
      if (!PQ[t].empty()) {
        PQ[t].pop();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3988
#include <iostream>
using namespace std;
typedef long long ll;
const ll MAX_N = 2005;
const ll MAX_A = 2005;
const ll MOD = 1e9 + 7;
ll A[MAX_N];
ll dp[MAX_N][MAX_A];

void init()
{
	for (int i = 0; i < MAX_N; ++i)
	{
		for (int j = 0; j < MAX_A; ++j)
		{
			dp[i][j] = 0;
		}
	}
}


int main()
{
	init();
	ll N, K;
	cin >> N >> K;
	cin >> A[0];

	for (int i = 0; i < A[0]; ++i)
	{
		dp[0][i]++; 
	}

	for (int i = 1; i < N; ++i)
	{
		cin >> A[i];
		for (int j = 0; j < MAX_A; ++j)
		{
			if (j < A[i]) dp[i][j] = dp[i-1][j] + 1;
			else dp[i][j] = dp[i-1][j];
		}
	}

	/*
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 11; ++j)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	

	ll m1 = 0;
	ll m2 = 0;


	for (int i = 0; i < N-1; ++i)
	{
		m1 = (m1 + dp[i][A[i+1]]) % MOD;
	}

	for (int i = 0; i < N; ++i)
	{
		m2 = (m2 + dp[N-1][A[i]]) % MOD;
	}

	//cout << endl << m1 << " " << m2 << " " << MOD << endl;

	ll ans = 0;

	ans = (m1 * K) % MOD;

	ans = (ans + ((((K * (K-1)) / 2) % MOD) * m2) % MOD) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 31616
N=int(input())
dp=[[0]*3 for _ in range(N+1)]
abc=[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    for j in range(3): #移動元
        for k in range(3): #移動先
            if j==k: continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])
print(max(dp[N]))

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

void Replace();
void Reverse();
void Print();

string str;

int main() {
	string ver;
	int q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> ver;
		if (ver == "replace") Replace();
		else if (ver == "reverse") Reverse();
		else if (ver == "print") Print();
	}

	
	return 0;
}

void Print() {
	int a, b;
	cin >> a >> b;
//	str = str.substr(a, b - a + 1);
	cout << str.substr(a, b - a + 1) << endl;

}

void Reverse() {
	int a, b;
	cin >> a >> b;
	string temp = str.substr(a, b - a + 1);
	int n = temp.size();
	for (int i = 0; i <n ; i++) str[a+i] = temp[n-i-1];
	
}

void Replace() {
	int a, b;
	string p;
	cin >> a >> b >> p;
	str = str.replace(a, b - a + 1, p);
}


Measured memory_bytes: 3204
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    x,y = map(int, input().split())
    print(x+y//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
    int m, f, r;

    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1)
            break;

        if(m == -1 || f == -1)
            puts("F");
        else if(m + f >= 80)
            puts("A");
        else if(m + f >= 65 && m + f < 80)
            puts("B");
        else if(m + f >= 50 && m + f < 65)
            puts("C");
        else if(m + f >= 30 && m + f < 50 && r >= 50)
            puts("C");
        else if(m + f >= 30 && m + f < 50)
            puts("D");
        else
            puts("F");
    }
    return 0;
}

Measured memory_bytes: 1768
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<string> S;

LL ans = 0;
 
void solve(){
	LL B_start = 0;
	LL A_end = 0;
	LL B_start_A_end = 0;

	for(int i=0;i<N;i++){
		for(int j=0;j<S[i].size()-1;j++){
			if(S[i][j]=='A' && S[i][j+1]=='B') ans++;
		}
		if(S[i][0]=='B' && S[i][S[i].size()-1]=='A') B_start_A_end++;
		else if(S[i][0]=='B') B_start++;
		else if(S[i][S[i].size()-1]=='A') A_end++;
	}

	if(A_end==0 && B_start==0){
		ans += (max(0LL,B_start_A_end-1));
	}
	else if((A_end>0 && B_start==0) || (A_end==0 && B_start>0)){
		ans += B_start_A_end;
	}
	else if(A_end>0 && B_start>0){
		ans += min(A_end,B_start);
		ans += B_start_A_end;
	}
}
 
int main(){
    cin >> N;
    S = vector<string>(N);
    for(int i=0;i<N;i++) cin >> S[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
typedef long long ll;
typedef pair<int,int> pii;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 1e5+5;
int dp[MAXN],prop[MAXN],m;
vector<int> adj[MAXN], child[MAXN];
vector<int> pmul[MAXN], smul[MAXN];
int madd (int a, int b) {
  int sum = a + b;
  return sum >= m ? sum-m : sum;
}
void self_madd (int &a, int b) {
  a = madd(a,b);
}
int mmult (int a, int b) {
  ll prod = (ll)a*b;
  return prod >= m ? prod%m : prod;
}
void self_mmult (int &a, int b) {
  a = mmult(a,b);
}
void dfs (int cur, int p) {
  dp[cur] = 1; prop[cur] = 1;
  for (int i : adj[cur]) if (i != p){
    dfs(i,cur);
    child[cur].push_back(i);
    self_mmult(dp[cur],dp[i]+1);
    pmul[cur].push_back(dp[cur]);
  }
  int temp = 1; smul[cur].resize(child[cur].size());
  for (int i = child[cur].size()-1; i >= 0; i--) {
    self_mmult(temp,dp[child[cur][i]]+1);
    smul[cur][i] = temp;
  }
}
int dv (int cur, int i) {
  return madd(mmult(mmult(prop[cur],(i ? pmul[cur][i-1] : 1)),(i == child[cur].size()-1 ? 1 : smul[cur][i+1])),1); //sketchy
}
void dfs2(int cur, int p) {
  for (int i = 0; i < child[cur].size(); i++) {
    int mul = dv(cur,i);
    self_mmult(dp[child[cur][i]],mul);
    self_mmult(prop[child[cur][i]],mul);
    dfs2(child[cur][i],cur);
  }
}
int main() { //easy except avoiding modular division
    int n,a,b;
    scan(n,m);
    for (int i = 1; i < n; i++) {
      scan(a,b);
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    dfs(1,-1);
    dfs2(1,-1);
    for (int i = 1; i <= n; i++) printf ("%d\n",dp[i]);
    return 0;
}


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

// Computes the radius of the longest palindrome centered at each element in O(n) total.
// Actual palindrome length is 2 * radius[i] - 1.
template<typename T>
vector<int> manacher(const T &pattern) {
    int n = pattern.size();
    vector<int> radius(n, 1);
    int loc = 0;

    for (int i = 1; i < n; i++) {
        if (i < loc + radius[loc])
            radius[i] = min(radius[loc - (i - loc)], loc + radius[loc] - i);

        while (i - radius[i] >= 0 && i + radius[i] < n && pattern[i - radius[i]] == pattern[i + radius[i]])
            radius[i]++;

        if (i + radius[i] > loc + radius[loc])
            loc = i;
    }

    return radius;
}

int N;
string S;

void run_case() {
    cin >> S;
    N = S.size();
    string M = "*";

    for (int i = 0; i < N; i++) {
        M += S[i];
        M += '*';
    }

    vector<int> radius = manacher(M);
    int n = radius.size();
    if(radius[n / 2] >= n / 2 + 1){
      int k = n / 2;
      if(radius[k / 2] == k / 2 + 1 && radius[n * 3 / 4] == k / 2 + 1){
         cout << "Yes\n";
         return;
      }
    }
    cout << "No\n";
}

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

//    int tests;
////    cin >> tests;
//
//    while (tests-- > 0)
        run_case();
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    H_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    A_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+2].split(' ')))  # type:list(int)
        A_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    connect = [None] * N
    for a,b in A_B_arr:
        a -= 1
        b -= 1
        if connect[a] == None:
            connect[a] = [b]
        else:
            connect[a].append(b)
        if connect[b] == None:
            connect[b] = [a]
        else:
            connect[b].append(a)
    cnt = 0
    for i,_con in enumerate(connect):
        if _con == None:
            cnt += 1
        else:
            height = max([H_arr[i] for i in _con])
            if H_arr[i]>height:
                cnt += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 117640
#include <iostream>
using namespace std;
int main(){
    string S;
    int a = 0;
    int max = 0;
    
    cin >> S;
    
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G'){
           a++;
           if(a >= max){
               max = a;
           }
        }else{
            a = 0;
        }
    }
    
    cout << max << '\n';
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl codeforces
#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 pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
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; }

int main() {
    ll x, y, z;
    std::cin >> x >> y >> z;
    std::cout << z << ' ' << x << ' ' << y << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll h,w; cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll s = (h+2-1)/2 + h/2;
    cout << w/2 * s + (w%2) * (h+2-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    if (A == B && B == C)
    {
        writeln((A & 1) ? 0 : -1);
        return;
    }
    long cnt;
    while (!((A & 1) | (B & 1) | (C & 1)))
    {
        cnt++;
        long a = (B + C) / 2;
        long b = (A + C) / 2;
        long c = (A + B) / 2;
        A = a;
        B = b;
        C = c;
    }
    writeln(cnt);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

ll n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  ll a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(a, n % (a + b));
  return 0;
}


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

using namespace std;

int main()
{
    int n; cin>>n;
    vector<int> h;

    for (int i=0;i<n;i++)
    {
        int no;cin>>no;
        h.push_back(no);
    }
    int dp[n] = {0};

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);


    for (int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]),dp[i-2]+abs(h[i] - h[i-2]));
    }

    cout<< dp[n-1];

}


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

int main() {
    while (true) {
        int N; cin >> N;
        
        if (N==0) {
            break;
        }
        
        int c = 0;
        bool flag = true;
        
        for (int i=0; i<N; i++) {
            int ki; cin >> ki;
            
            if (ki==0) {
                continue;
            }
            
            if (ki>=2) {
                flag = false;
            }
            
            c += 1;
        }
        
        if (flag) {
            cout << "NA" << endl;
        }
        else {
            cout << c+1 << endl;
        }
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		// cin.ignore(); must be there when using getline(cin, s)
		int n,m=0,d,ans=0;
		cin>>n;
		for (int i = 0; i < n; ++i)
		{
			cin>>d;
			m=max(d,m);
			if(m==d)
				ans++;
		}
		cout<<ans;
	}

Measured memory_bytes: 256
from collections import deque
import sys
input=sys.stdin.readline
def main():
  a,b=map(int,input().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,input().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=deque([(0,-1)])
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.pop()
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append((j,i)) 
  print(*ans)

if __name__ == '__main__':  
  main()    
  

  
  


Measured memory_bytes: 75056
// AOJ 0185: Goldbach's Conjecture II
// 2017.8.3 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>
#include <stdlib.h>

#define MAX  1000000
#define SQRT 1000     // sqrt(MAX)

char prime[MAX+5] = {1,1,0,0,1}, *pmax = prime+MAX;
char buf[100];

int main()
{
	int n, i, ans;
	char *p1, *p2;

//	memset(prime, 1, MAX), prime[1] = 0;
	for (p1 = prime + 3, i = 3; i <= SQRT; p1 += 2, i += 2) if (!*p1) {
		for (p2 = p1 + i; p2 <= pmax; p2 += i) *p2 = 1;
	}

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		i = n >> 1;
		p1 = p2 = prime + i;
		if (!(i & 1)) i--, p1--, p2++;
		for (ans = 0; i > 0; i -= 2, p1 -= 2, p2 += 2) {
			if (!*p1 && !*p2) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long nx=1,ny=1,x,y;
	while(n--)
	{
		scanf("%lld%lld",&x,&y);
		nx=((nx-1)/x+1)*x;
		ny=((ny-1)/y+1)*y;
		nx=max(nx,ny/y*x);
		ny=max(ny,nx/x*y);
	}
	printf("%lld\n",nx+ny);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

float seq(float a){
	float b;
	b = (1+a)/2;
	return b;
}

int main(void){
	unsigned int n,k,a;
	double sum,sumtemp;
	scanf("%u %u",&n,&k);
	double p[n];


	for(int i=0;i<n;i++){
		scanf("%u",&a);
		p[i]=(double)a;
		if(i<k){
			sum+=seq(p[i]);
		}
	}

	sumtemp=sum;

	for(int i=k;i<n;i++){
		sumtemp=sumtemp+seq(p[i])-seq(p[i-k]);
		if(sum<sumtemp){
			sum=sumtemp;
		}
	}
	printf("%lf",sum);

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	long long n, x, ans = 0;
	cin >> n >> x;
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long s = 0;
	for(int i = 0; i < n; i++){
		s += a[i];
		if(s > x){
			ans = i;
			break;
		}else if(s == x){
			ans = i + 1;
			break;
		}else if(i == n - 1){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    if(s[1] == 'R') cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3620
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    for x in range(1, 50001):
        if int(x*1.08)==N:
            print(x)
            return
    print(":(")


if __name__ == '__main__':
    main()

Measured memory_bytes: 64364
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        long n = long.Parse(str[0]);
        long d = long.Parse(str[1]);
        long comp = d*d;
        long count = 0;
        for(long i=0; i<n; i++){
            long[] num = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            if(comp >= ((num[0]*num[0])+(num[1]*num[1]))){
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 23188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7;

int main(){
  ll N;
  cin>>N;
  string S;
  cin>>S;
  vector<ll>right(S.size());
  vector<ll>left(S.size());//この二つはWのみをカウント
  ll R=0;
  ll L=0;
  for(ll i=0;i<S.size();i++){
    if(S[i]=='W'){
      R++;
      right[i]=R;
    }
    else{
      right[i]=R;
    }

  }
  
  for(ll i=0;i<S.size();i++){
    if(S[S.size()-1-i]=='W'){
      L++;
      left[i]=L;
    }
    else{
      left[i]=L;
    }

  }
  ll min=INF;
  for(ll i=0;i<N;i++){
    ll sum=0;
    if(S[i]=='W'){//Wだった場合
      sum+=(N-i-left[N-i-1]);//右方向のRのカウント
      sum+=(right[i]-1);//左方向のWのカウント
    }
    
    else{//Eだった場合
      sum+=(N-i-left[N-i-1]-1);//右方向のRのカウント
      sum+=(right[i]);//右方向のWのカウント
    }
  
  if(min>sum){
    min=sum;
  }
}

cout<<min<<endl;
  

}  

      
        
      

Measured memory_bytes: 5380
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

bool search(int t[], int n, int key){
    int i = 0;
    t[n] = key;
    while(t[i] != key) i++;
    return i != n;
}

int main() {
    int n, q;
    int t[10001];
    int count = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        int key; cin >> key;
        if(search(t, n, key)) count++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int n;

bool ok(vector<string> vs,int a, int b){
    rep(i,n){
        rep(j,n){
            if(vs[(i+a)%n][(j+b)%n]!=vs[(j+a)%n][(i+b)%n])return false;
        }
    }
    return true;
}

int main(){
    cin>>n;
    vector<string> vs(n);
    rep(i,n)cin>>vs[i];
    
    int ans = 0;
    int a=0;
    rep(b,n){
        if(ok(vs,a,b)){
            ans++;
        }
    }
    cout<<ans*n<<endl;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int cost1 = 0; int cost2 = 0;
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		for(int i = 0; i < m; i++) {
			if(sc.nextInt() < x) cost1++;
			else cost2++;
		}
		System.out.println(Math.min(cost1, cost2));
		sc.close();
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int r;
  std::cin >> r;
  std::cout << 3 * r * r << std::endl;


  // Output

  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int n,m,r;
  while(cin>>n>>m>>r,n||m||r){
    r*=4;
    int x[100000],y[100000];
    for(i=0;i<n;++i)
      cin>>x[i]>>y[i];
    vector<int> a[10000];
    for(i=0;i<m;++i){
      int p,q;
      cin>>p>>q;
      a[q].push_back(p);
    }
    for(i=0;i<10000;++i)
      sort(a[i].begin(),a[i].end());
    int b[90],c[90];
    for(i=-r;i<=r;++i){  
      for(j=-40;i*i+j*j>r*r;++j);
      b[i+40]=j;
      for(;i*i+j*j<=r*r;++j);
      c[i+40]=j;
    }
    int sm=0;
    for(i=0;i<n;++i){  
      for(j=y[i]-r;j<=y[i]+r;++j){
	if(0<=j&&j<10000)
	  sm+=lower_bound(a[j].begin(),a[j].end(),x[i]+c[j-y[i]+40])-lower_bound(a[j].begin(),a[j].end(),x[i]+b[j-y[i]+40]);
      }
    }
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 2212
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int in[2][100000] = {};
	vector<pair<long long, int>> s(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> in[j][i];
			s[i].first += in[j][i];
			s[i].second = i;
		}
	}
	sort(s.rbegin(), s.rend());
	long long res[2] = {};
	for (int i = 0; i < n; i++) {
		int x = s[i].second;
		res[i & 1] += in[i & 1][x];
	}
	cout << res[0] - res[1] << endl;
	return 0;
}

Measured memory_bytes: 2560