akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int mn = 1010;

int x[mn], y[mn];
int d[50];
char ch[50];
int main()
{
	int n;	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d %d", &x[i], &y[i]);

	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; i++)
	{
		if ((abs(x[i]) + abs(y[i])) % 2 == 1)	cnt1++;
		else	cnt2++;
	}
	if (cnt1 && cnt2)
	{
		printf("-1\n");
		return 0;
	}

    int num = 0;
    if (cnt2)	d[++num] = 1;
    for (int i = 0; i <= 30; i++)
		d[++num] = (1 << i);

	printf("%d\n", num);
	for (int i = 1; i <= num; i++)
		printf("%d ", d[i]);
	printf("\n");

    for (int i = 1; i <= n; i++)
	{
		int cnt = 0;
		for (int j = num; j >= 1; j--)
		{
            if (abs(x[i]) > abs(y[i]))
			{
				if (x[i] > 0)
				{
					ch[++cnt] = 'L';
					x[i] -= d[j];
				}
				else if (x[i] <= 0)
				{
					ch[++cnt] = 'R';
					x[i] += d[j];
				}
			}
			else if (abs(x[i]) <= abs(y[i]))
			{
				if (y[i] > 0)
				{
					ch[++cnt] = 'D';
					y[i] -= d[j];
				}
				else if (y[i] <= 0)
				{
					ch[++cnt] = 'U';
					y[i] += d[j];
				}
			}
			//cout << x[i] << ' ' << y[i] << endl;
		}

		for (int i = cnt; i >= 1; i--)
		{
			if (ch[i] == 'L')	printf("R");
			if (ch[i] == 'R')	printf("L");
			if (ch[i] == 'U')	printf("D");
			if (ch[i] == 'D')	printf("U");
		}
		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
num = sum(A)//2
A += A
for j in range(0,N-2,2):
    num -= A[j]
ans = [0]*N
for i in range(N):
    ans[i] = A[i-1]-num
    num = ans[i]
    ans[i]*= 2
print(*ans)

Measured memory_bytes: 90384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int n; cin >> n;
  VV a(n, V(n));
  rep(i, n) rep(j, n) {
    char x; cin >> x;
    if (x == '.') a[i][j] = 0; 
    if (x == '#') a[i][j] = 1; 
  }

  V sumi(n), sumj(n);
  rep(i, n) rep(j, n) {
    sumi[i] += a[i][j];
    sumj[j] += a[i][j];
  }

  bool easy = false;
  rep(i, n) if (sumi[i] == n) easy = true;
  if (easy) {
    int ans = 0;
    rep(j, n) if (sumj[j] < n) ans++;
    cout << ans << endl;
    return 0;
  }

  int x = n+1;
  rep(i, n) {
    int y = n - sumi[i];
    if (sumj[i] == 0) y++;
    chmin(x, y);
  }

  if (x == n+1) {
    cout << -1 << endl;
    return 0;
  }
    
  int ans = x+n;
  rep(j, n) if (sumj[j] == n) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  llong ans = 0;
  for(llong i = 1; i < n; ++i){
    ans += i;
  }
  cout << ans << endl;
  return 0;
}



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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  cout<<(n-1)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt(),k=sc.nextInt();
			int ans=k;
			for(int i=0;i<n-1;i++) ans*=(k-1);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long  n,m;
int main() {
	IO
	char c;
	cin>>c;
	if(c>='a'&&c<='z')
        cout<<"a"<<endl;
    else
        cout<<"A"<<endl;

    return 0;
}


Measured memory_bytes: 3604
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int main() {
    int a, b;
    cin >> a >> b;
    if (b < a) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[10002][102][2];
string s;
int d;
int fun(int idx,int cur,bool gr)
{
    if(idx==s.size()) return !cur;
    int &ret=dp[idx][cur][gr];
    if(~ret)
        return ret;
        ret=0;
    if(!gr)
    {
        for(int i=0;i<s[idx]-'0';i++)
        {
            ret+=fun(idx+1,(cur+i)%d,1);
            ret%=mod;
        }
        ret+=fun(idx+1,(cur+s[idx]-'0')%d,0);
        ret%=mod;
    }
    else
    {
        for(int i=0;i<=9;i++)
        {
            ret+=fun(idx+1,(cur+i)%d,1);
            ret%=mod;
        }
    }
    return ret;
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>s>>d;
    cout<<(fun(0,0,0)+mod-1)%mod<<endl;
}


Measured memory_bytes: 12416
#include<stdio.h>
#include<math.h>

#define N 246920

int main(){
  int n, a[N], i, j, cnt;

  for(i=0; i<N; i++){
    if(i%2==0){
      a[i]=0;
    }else{
      a[i]=1;
    }
  }

  a[1]=0;
  a[2]=1;
  for(i=5; i<N; i+=2){
    for(j=3; j<=sqrt(i); j+=2){
      if(i%j==0){
	a[i]=0;
	break;
      }
    }
  }

  while(scanf("%d", &n), n){
    cnt=0;
    for(i=n+1; i<=n*2; i++){
      if(a[i]==1){
	cnt++;
      }
    }
    printf("%d\n", cnt);
  }
  
  return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_ll a(n);
    cin >> a;

    ll ans = 0;
    rep(i, 60) {
        ll x = 0;
        rep(j, n) {
            if((a[j] >> i)&1) {
                x++;
            }
        }
        ll sum = x * (n-x);
        sum %= MOD;
        rep(j,i) {
            sum *= 2;
            sum %= MOD;
        }
        ans += sum;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


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

typedef unsigned long long ll;

ll md = 1000000007;

ll gcd(ll a, ll b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}
ll ggd(ll a, ll b){
    if( a == 0 && b == 0)return 0;
    return a / gcd(a, b) * b;
}

int main(int, char**)
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll x = b / c - (a-1) / c;
	ll y = b / d - (a-1) / d;
	ll k = ggd(c,d);
	ll z = b / k - (a-1) / k;

	// cerr << ( b - a + 1) << "," << x << "," << y << "," << z << endl;

	cout << (b - a + 1 - x - y + z ) << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int age;
	int gene[7] = {0};
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &age);
			if (age >= 0 && age < 10){
				gene[0]++;
			}
			else if (age < 20){
				gene[1]++;
			}
			else if (age < 30){
				gene[2]++;
			}
			else if (age < 40){
				gene[3]++;
			}
			else if (age < 50){
				gene[4]++;
			}
			else if (age < 60){
				gene[5]++;
			}
			else if (age >= 60){
				gene[6]++;
			}
		}
		
		for (i = 0; i < 7; i++){
			printf("%d\n", gene[i]);
			gene[i] = 0;
		}
		
	}
	
	return (0);
}

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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  t.pop_back();
  if (s == t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int cnt;
deque<int> G;
int m;

void makeG(int N){
    // ll tmp = 1;
    // while(tmp <= N){
    //     G.push_front(tmp);
    //     tmp = 3 * tmp + 1;
    // }
    for(int i = 1; i <= N; i = i * 3 + 1) G.push_front(i);
    m = G.size();
}

void insertionSort(vector<int> &A, int N, int g){
    for(int i = g; i < N; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

int shellSort(vector<int> &A, int N){
    cnt = 0;
    for(int i = 0; i < m; i++){
        insertionSort(A, N, G[i]);
    }
}

int main(){
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    rep(i, N) scanf("%d", &A[i]);

    makeG(N);
    
    printf("%d\n", m);
    rep(i, m){
        if(i) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n");

    shellSort(A, N);

    printf("%d\n", cnt);
    rep(i, N) printf("%d\n", A[i]);
}


Measured memory_bytes: 6712
def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps


N = int(input())
A = [int(elem) for elem in input().split()]
num_swaps = selection_sort(A)
print(*A)
print(num_swaps)



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int N;
int ans;

int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input_1.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> N;
    }else{ // ファイル入力する
        ifs >> N;
    }    
    
    int tmp = 0;
    ans = 0;

	while(true){
        ans++;
        tmp *= 10;
        tmp += 7;

        tmp %= N;

        if(tmp == 0) break;


        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.9)break;
    }

    if(tmp != 0){
        ans = -1;
    }

    cout << ans << endl;

    string fileName = "sample_out.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    ofs << ans << endl;
    ofs.close();

    return 0;
}
 
 


Measured memory_bytes: 3652
package main

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

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

	a := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	m := make(map[rune]int)
	for i, r := range a {
		m[r] = i
	}

	var wr = bufio.NewWriter(os.Stdout)
	for _, r := range s {
		wr.WriteString(string(a[(m[r]+n)%26]))
	}
	wr.WriteString("\n")
	wr.Flush()
}


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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int n;
    cin>>n;
    int ans;
    for(int i=1;i<=7;i++)
    {
        if(n<pow(2,i))
        {
         ans=i-1;
         break;
        }
    }
    cout<<pow(2,ans)<<endl;
}

Measured memory_bytes: 4220
# a= int(input())
# list1 =[]

n = int(input())
a = list(map(int,input().split()))
# print(a)
# a.sort(reverse=True)
# print(a)
if 0 in a :
    ans  = 0
    print(ans)
else :
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18 :
            print(-1)
            break
if ans <= 10**18 and ans != 0 :
    print(ans)


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

#define pi 3.14159265358979323846

int main()
{
    long long int d, H, x; 
    cin >> d;
    cin >> H; 
    cin >> x;  

    long double h;
    h = double(x)/(d*d); 

    long double ans; 

    if (h <= (H/2))
    {
        ans = atan((2*d*h)/(H*H)) * 180/pi; 
    }
    else
    {
        ans = atan(d/(2*(H - h))) * 180/pi;
    }

    cout << setprecision(20) << 90 - ans << endl; 
    return 0; 
}

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

bool Compare(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  vector<int> count(n+1, 0);
  for(int i=0;i<n;i++) count[a[i]]++;
  sort(count.rbegin(), count.rend());
  int same = 0;
  for(int i=0;i<k;i++) {
    same += count[i];
  }

  cout << n - same << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int abs(int x){return x > 0 ? x : -x;}
int min(int x, int y){return x < y ? x : y;}
int main(){
	int N, K; cin >> N >> K;
	int h[N];
	for(int i = 0; i < N; i++) cin >> h[i];
	sort(h, h+N);
	int MIN = abs(h[0] - h[K-1]);
	for(int i = 1; i <= N - K; i++) MIN = min(abs(h[i] - h[i+K-1]), MIN);
	cout << MIN << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;
int n;
int ans = 0;
void dfs(ll cur,int a,int b,int c) {
	if(cur>n) {
		return;
	}
	if(a && b && c ) ans++;
	dfs(cur*10+7,1,b,c);
	dfs(cur*10+5,a,1,c);
	dfs(cur*10+3,a,b,1);
	return ;
}
int main() {
	cin >> n;
	dfs(0,0,0,0);
	cout << ans << endl;
}

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


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		Dice d01 = new Dice(scan.nextLine());
		Dice d02 = new Dice(scan.nextLine());
		if(d01.equals(d02))
			System.out.println("Yes");
		else
			System.out.println("No");
		
		
	/*	Scanner scan = new Scanner(System.in);
		int dnum = scan.nextInt();
		scan.nextLine();
		HashSet<Dice> dlist = new HashSet<Dice>();
		for(int i=0; i<dnum; i++)
			if(!dlist.add(new Dice(scan.nextLine()))){
				System.out.println("No");
				return;
			}
		System.out.println("Yes");*/
			
	}

}
class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	void rotate(){
		int tmp = front;
		front = right;
		right=back;
		back = left;
		left = tmp;
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}
	boolean equalFace(Dice d){
		if(this.top == d.top && 
		   this.bottom == d.bottom &&
		   this.right == d.right &&
		   this.left == d.left &&
		   this.front == d.front &&
		   this.back == d.back)
			return true;
		else
			return false;
	}
	@Override
	public int hashCode() {
	    final int prime = 31;
	    int result = 1;
	    result = prime * result + top;
	    result = prime * result +bottom;
	    result = prime * result + right;
	    result = prime * result + left;
	    result = prime * result + front;
	    result = prime * result + back;
	    return result;
    }
	@Override
	public boolean equals(Object obj) {
		Dice d = (Dice) obj;
		return rollAllPattern(d);
	}
	public boolean rotateCheck(Dice d){
		for(int j=0;j<4;j++){
			rotate();
			if(this.equalFace(d))
				return true;
		}
		return false;
	}
	public boolean rollAllPattern(Dice d){
		for(int i=0; i<4;i++){
			roll('N');
			if(rotateCheck(d))
				return true;
		}
		roll('W');
		if(rotateCheck(d))
			return true;		
		roll('E');
		roll('E');		
		if(rotateCheck(d))
			return true;	
		return false;			
	}
	
}	
	
	

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll powmod(ll x, ll k, ll m) {
	ll res = 1;
	for (; k; x = x * x % m, k >>= 1) {
		if (k & 1) {
			res = res * x % m;
		}
	}
	return res;
}

ll invmod(ll x, ll m) {
	return powmod(x, m - 2, m);
}

int main() {
	int N; string S;
	cin >> N >> S;

	const int pnum = 3;
	const vector<ll> vmod = {1000000007, 1000000009, 998244353}, vB = {100007, 100007, 100007};
	vector<ll> vinv(pnum);
	rep(j, pnum) vinv[j] = invmod(vB[j], vmod[j]);

	using pll = pair<ll,ll>;

	vector<ll> vall(pnum);

	for (int i = N-1; i >= 0; --i) {
		rep(j, pnum) {
			if (S[i] == '+') {
				(vall[j] += 1) %= vmod[j];
			} else if (S[i] == '-') {
				(vall[j] += vmod[j] - 1) %= vmod[j];
			} else if (S[i] == '>') {
				(vall[j] *= vinv[j]) %= vmod[j];
			} else {
				(vall[j] *= vB[j]) %= vmod[j];
			}
		}
	}

	map<vector<ll>, int> MP;
	vector<vector<pll>> ivec(N + 1, vector<pll>(pnum));

	rep(j, pnum) ivec[N][j] = mp(1ll, 0ll);
	vector<ll> initvec(pnum);
	++MP[initvec];
	ll ans = 0;

	for (int i = N-1; i >= 0; --i) {
		vector<ll> vec(pnum);
		rep(j, pnum) {
			ivec[i][j] = ivec[i+1][j];
			if (S[i] == '+') {
				(ivec[i][j].se += vmod[j] - ivec[i][j].fi) %= vmod[j];
			} else if (S[i] == '-') {
				(ivec[i][j].se += ivec[i][j].fi) %= vmod[j];
			} else if (S[i] == '>') {
				(ivec[i][j].fi *= vB[j]) %= vmod[j];
			} else {
				(ivec[i][j].fi *= vinv[j]) %= vmod[j];
			}
			vec[j] = (vall[j] * ivec[i][j].fi + ivec[i][j].se) % vmod[j];
		}
		if (MP.count(vec)) {
			ans += MP[vec];
		}
		rep(j, pnum) {
			vec[j] = ivec[i][j].se;
		}
		++MP[vec];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 49284
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	string s, t;
	cin >> s >> t;

	int cnt = 0;

	for(int i = 0; i < 3; ++i)
		cnt += (s[i] == t[i]);

	cout << cnt << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = []
for i in range(h):
   tmp = input()
   a.append(tmp)

for i in range(0, max(h, w)):
   row = [x.count('.') for x in a]
   a = [x for x, k in zip(a, row) if k < len(x)]

   b = [list(x) for x in zip(*a)]
   line = [x.count('.') for x in b]
   b = [x for x, k in zip(b, line) if k < len(x)]
   a = [list(x) for x in zip(*b)]

for i in range(len(a)):
   for j in range(len(a[i])):
      print(a[i][j], end='')
   print()


Measured memory_bytes: 4724
#include <stdio.h>

int main(void){
   int n,point,i,result=0;
   char str[101];

   scanf("%d%s",&n,str);
   point = n/2;
   if((n==1)||(n%2==1)){printf("No\n"); return 0;}

   for(i=0;i<point;i++)
      if(str[i]!=str[i+point]){result=1;break;}

   if(result==0) printf("Yes\n");
   else printf("No\n");
   return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>

struct point
{
	int x,y;
};

point p[120],q[120];
int d[120][120],e[120];
bool b[120];
int i,j,n,s;

inline bool increasing(int x)
{
	if (b[x])
		return false;
	b[x]=true;
	for (int i=1;i<=n;i++)
		if ((d[x][i]) && ((! e[i]) || (increasing(e[i]))))
			return e[i]=x,true;
	return false;
}

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&p[i].x,&p[i].y);
	for (i=1;i<=n;i++)
		scanf("%d%d",&q[i].x,&q[i].y);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if ((p[i].x<q[j].x) && (p[i].y<q[j].y))
				d[i][j]=1;
	for (i=1;i<=n;i++)
	{
		memset(b,false,sizeof(b));
		if (increasing(i))
			s++;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int A, B;
int h, w;
vector<string> field;

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

  cin >> A >> B;
  h = 100;
  w = 100;

  for (int i = 0; i < h; ++i) {
      string tmp;
      for (int j = 0; j < w; ++j) {
          if (i < 50) {
              tmp += '#';
          } else {
              tmp += '.';
          }
      }
      field.push_back(tmp);
  }

  --A; --B;
  for (int i = 1; i < h/2-1; i += 3) {
      for (int j = 1;  j < w-1; j += 3) {
          if (A == 0) break;
          field[i][j] = '.';
          --A;
      }
      if (A == 0) break;
  }
  for (int i = (h/2)+1; i < h; i += 3) {
      for (int j = 1;  j < w-1; j += 3) {
          if (B == 0) break;
          field[i][j] = '#';
          --B;
      }
      if (B == 0) break;
  }


  cout << h << ' ' << w << endl;
  for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
          cout << field[i][j];
      }
      cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
while True:
    n,r=map(int,raw_input().split())
    if n==r==0:break
    L=range(1,n+1)[::-1]
    for i in range(r):
        p,c=map(int,raw_input().split())
	p-=1
        L=L[p:p+c]+L[:p]+L[p+c:]
    print L[0]

Measured memory_bytes: 4224
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a,b;
int main()
{
	cin>>a>>b;
	if (a=='A' && b=='A') printf("=");
	if (a=='A' && b=='B') printf("<");
	if (a=='A' && b=='C') printf("<");
	if (a=='A' && b=='D') printf("<");
	if (a=='A' && b=='E') printf("<");
	if (a=='A' && b=='F') printf("<");
	if (a=='B' && b=='A') printf(">");
	if (a=='B' && b=='B') printf("=");
	if (a=='B' && b=='C') printf("<");
	if (a=='B' && b=='D') printf("<");
	if (a=='B' && b=='E') printf("<");
	if (a=='B' && b=='F') printf("<");
	if (a=='C' && b=='A') printf(">");
	if (a=='C' && b=='B') printf(">");
	if (a=='C' && b=='C') printf("=");
	if (a=='C' && b=='D') printf("<");
	if (a=='C' && b=='E') printf("<");
	if (a=='C' && b=='F') printf("<");
	if (a=='D' && b=='A') printf(">");
	if (a=='D' && b=='B') printf(">");
	if (a=='D' && b=='C') printf(">");
	if (a=='D' && b=='D') printf("=");
	if (a=='D' && b=='E') printf("<");
	if (a=='D' && b=='F') printf("<");
	if (a=='E' && b=='A') printf(">");
	if (a=='E' && b=='B') printf(">");
	if (a=='E' && b=='C') printf(">");
	if (a=='E' && b=='D') printf(">");
	if (a=='E' && b=='E') printf("=");
	if (a=='E' && b=='F') printf("<");
	if (a=='F' && b=='A') printf(">");
	if (a=='F' && b=='B') printf(">");
	if (a=='F' && b=='C') printf(">");
	if (a=='F' && b=='D') printf(">");
	if (a=='F' && b=='E') printf(">");
	if (a=='F' && b=='F') printf("=");
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut ds = read_vec::<u32>();

    ds.sort();
    let idx_oh = n / 2;

    let ans = ds[idx_oh] - ds[idx_oh - 1];
    println!("{}", ans);
}


Measured memory_bytes: 4476
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

INF = 1e100
    
dp = [[INF] * (1+10**4) for i in range(1+10**3)]


dp[0][0] = 0

for i in range(n):
    for j in range(h+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(h, j+a[i])] = min(dp[i+1][min(h, j+a[i])], dp[i+1][j] + b[i])

print(dp[n][h])


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Triangular Relationship
            var lines = ReadLines<int>(1).ToList();
            int n = lines[0][0];
            int k = lines[0][1];

            long count = CountFulfillAllConditionsPairs(n, k);

            Console.WriteLine(count);
        }

        static long CountFulfillAllConditionsPairs(int n, int k)
        {
            int divisor = n / k;
            long count = (long)Math.Pow(divisor, 3);

            if (k % 2 == 0)
            {
                int upper = n + k / 2;
                divisor = upper / k;

                count += (long)Math.Pow(divisor, 3);
            }

            return count;
        }

        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 11220
import fractions
from collections import defaultdict

def prime_factorize(n):
    a = defaultdict(bool)
    while n % 2 == 0:
        a[2] = True
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] = True
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] = True
    return a

def main():
    a, b = map(int, input().split())
    saidaikoyaku = fractions.gcd(a, b)
    ps = prime_factorize(saidaikoyaku)
    count = 1
    for k in ps:
      count += 1
    print(count)
main()

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    //使う刀と投げる刀
    //使う刀は一本あれば十分. 何種類も使う必要はない -> ほんまか？
    //(a1, b1) (a2, b2) でa1 > a2で、(k-2)a1 + b1 + b2はk回の試行の中で最大
    int N, H; cin >> N >> H;
    vector<pair<int, int>> katana;
    rep(i, N){
        int a, b; cin >> b >> a;
        katana.push_back(make_pair(a, b));
    }
    sort(katana.begin(), katana.end(), greater<pair<int, int>>());

    int max_normal = 0;
    rep(i, katana.size()) if(katana[i].second > max_normal) max_normal = katana[i].second;

    int cnt = 0;
    int idx = 0;
    while(idx < N && katana[idx].first > max_normal){
        H -= katana[idx++].first;
        cnt++;
        if(H <= 0){
            cout << cnt << endl;
            return 0;
        }
    }
    if(H % max_normal == 0) cout << cnt + (H / max_normal) << endl;
    else cout << cnt + (H / max_normal) + 1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1400
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
            m = Y - (10000*i+j*5000)
            if m >= 0 and (i+j+m//1000) == N:
                print(i,j,m//1000)
                exit()
print(-1,-1,-1)

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

#define ll long long
#define ld long double

#define pii pair<int, int>
#define pci pair<char, int>
#define pcc pair<char, char>

#define vi vector <int>
#define vll vector<long long>
#define vld vector<long double>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

#define vvi vector<vi>
#define vvll vector<vll>
#define vvld vector<vld>
#define vvb vector<vb>
#define vvc vector<vc>
#define vvs vector<vs>

#define vpii vector<pii>
#define vpci vector<pci>
#define vpcc vector<pcc>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

const int MOD = 1e9 + 7;
const ld pi = 3.1415926535897932384626433832;

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);


void solve(int test_case){

    int n, m;
    cin >> n >> m;
    if(m >= n) cout << "unsafe";
    else cout << "safe";
    line;

}

int main(){
    fast
    int test = 1;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve(i);
    }
    return 0;
}


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

int main(){
  int n,m,x,b;
  cin >> n >> m;
  vector<pair<ll,ll>> a;
  for(int i=0;i<n;i++){
  	cin >> x >> b;
    a.push_back(make_pair(x,b));
  }
  ll ans=0;
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    ll f,s;
    f=0;s=0;
    f=a[i].first;
	s=a[i].second;
    if(m-s<=0){
      ans+=m*f;
      break;
    }else{
      ans+=f*s;
      m=m-s;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<pii>a(100005,{0,0}),b(100005,{0,0});
    rep(i,n){
        int k;
        cin >> k;
        if(i%2){
            a[k].first++;
            a[k].second = k;
        }else{
            b[k].first++;
            b[k].second = k;
        }
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    if(a[0].second != b[0].second){
        cout << n-a[0].first-b[0].first << endl;
    }else{
        cout << min(n-a[0].first-b[1].first,n-a[1].first-b[0].first) << endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
typedef long long ll;
const int MOD = 1000000007;
#define PI 3.141592653589
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char ch[n+1];
	int a[n+1], b[n+1], c[n+1], s1=0, s2=0, s3=0;
	long long t=0;
	for (register int i=1; i<=n; i++)
	{
		cin >> ch[i];
		if (ch[i]=='R')
		{
			s1++;
			a[s1]=i;
		}
		if (ch[i]=='G')
		{
			s2++;
			b[s2]=i;
		}
		if (ch[i]=='B')
		{
			s3++;
			c[s3]=i;
		}
	}
	for (register int i=1; i<=s1; i++)
		for (register int j=1; j<=s2; j++)
		{
			int maxx=max(a[i], b[j]), minn=min(a[i], b[j]);
			int dif=maxx-minn;
			t+=s3;
			if (minn-dif>=1)
				if (ch[minn-dif]=='B') t--;
			if (maxx+dif<=n)
				if (ch[maxx+dif]=='B') t--;
			if (dif%2==0)
				if (ch[minn+dif/2]=='B') t--;
		} 
	cout << t << endl;
	return 0;
}

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

int main() {
  int n;
  cin >>n;
  
  double x,sumx;
  string y;
  
  for(int i=0; i<n; i++){
    cin >>x >>y;
    if(y=="BTC"){
      sumx += x*380000;
    }
    else{
      sumx += x;
    }
  }
  
  cout <<sumx <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    ll hoge=0;
    ll n;cin>>n;
    rep(i,n){ll temp;cin>>temp;hoge+=temp;};
    cout<<hoge/n<<endl;
}

Measured memory_bytes: 2960
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
           var N = int.Parse(Console.ReadLine());
            var hash = new HashSet<string>();
            foreach (var i in Enumerable.Range(0, N))
            {
               hash.Add(Console.ReadLine());
            }

            Console.WriteLine(hash.Count());
        }
    }
}


Measured memory_bytes: 47560
#include<bits/stdc++.h>
using namespace std;
main(){
  int N;
  cin>>N;
  vector<bool> exists(100001);
  for(int i=1;i<=N;++i){
    int A;
    cin>>A;
    exists[A]=true;
  }
  int k=0;
  for(bool x:exists)if(x)++k;
  cout<<(k%2?k:k-1)<<endl;
}


Measured memory_bytes: 256
#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 push_back
#define INF 999999999


template<class T>
class BIT{
private:
    vector<T> sum_of_section_;
    int element_count_;
    T init_;
    
public:
    BIT(int element_count=0 , T init=0):element_count_(element_count) , init_(init) , sum_of_section_(element_count+1,init){}

    T sum(int i){
        int sum=0;
        while(i>0){
            sum+=sum_of_section_[i];
            i -= i&-i;
        }
        return sum;
    }
    
    void add(int i,T val){
        while(i<=element_count_){
            sum_of_section_[i]+=val;
            i += i&-i;
        }
    }
};

int n;

int main(){
    int q;
    cin>>n>>q;
    BIT<int> bit(n);
    rep(i,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0)bit.add(b,c);
        else cout<<bit.sum(c)-bit.sum(b-1)<<endl;
    }
}

Measured memory_bytes: 3136
N = int(input())
A_in = [int(input()) for _ in range(N)] 
 
A = sorted(A_in)
res1 = 0
A2 = []
for i in range(len(A)):
    if len(A) == 1:
        if abs(A[0] - A2[0]) < abs(A[0] - A2[-1]):
            A2.append(A[0])
        else:
            A2.insert(0,A[0])
        break
    if i % 2 == 0:
        A2.append(A.pop(-1))
    else:
        A2.append(A.pop(0))
for i in range(len(A2)-1):
    res1 += abs(A2[i] - A2[i+1])

A = sorted(A_in,reverse=True)
res2 = 0
A2 = []
for i in range(len(A)):
    if len(A) == 1:
        if abs(A[0] - A2[0]) < abs(A[0] - A2[-1]):
            A2.append(A[0])
        else:
            A2.insert(0,A[0])
        break
    if i % 2 == 0:
        A2.append(A.pop(-1))
    else:
        A2.append(A.pop(0))
for i in range(len(A2)-1):
    res2 += abs(A2[i] - A2[i+1])

print(max(res1,res2))

Measured memory_bytes: 8928
L = input()
MOD = 10 ** 9 + 7
n = len(L)
sl = set(range(n))
dp = [[0] * (n + 1) for _ in range(2)]
dp[0][0] = 1
for i in range(n):
    if L[i] == '1':
        dp[0][i + 1] = dp[0][i] * 2
        dp[1][i + 1] = dp[1][i] * 3 + dp[0][i]
    elif L[i] == '0':
        dp[0][i + 1] = dp[0][i]
        dp[1][i + 1] = dp[1][i] * 3
    dp[0][i + 1] %= MOD
    dp[1][i + 1] %= MOD
ans = (dp[0][-1] + dp[1][-1]) % MOD
print(ans)


Measured memory_bytes: 18248
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

"""
def exhaustive_search(m, i):
    if i == n:
        return 0
    if m < 0:
        return 0
    if m == A[i]:
        return 1
    return max(exhaustive_search(m, i + 1), exhaustive_search(m - A[i], i + 1))
"""

def dp_search(m):
    dp = [[1] + [0] * m for _ in range(n + 1)] # dp[i][j] i番目まででjを作れるか
    for i in range(1, n+1):
        for j in range(1, m+1):
            if j >= A[i-1]:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - A[i-1]])
            else:
                dp[i][j] = dp[i-1][j]
    return dp[n][m]

for mi in m:
    if dp_search(mi):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(B,N*A)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	n+=s[i]-'0';
	if(n%9==0)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3728