akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	char b;
	scanf("%c", &b);
	switch (b) {
	case 'A':
		printf("T\n");
		break;
	case 'T':
		printf("A\n");
		break;
	case 'C':
		printf("G\n");
		break;
	case 'G':
		printf("C\n");
		break;
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for j in range(n):
  time = 0
  for i in range(j,n-1):
    if time > csf[i][1]:
      time += (csf[i][1]-time)%csf[i][2]
    else:
      time = csf[i][1]

    time += csf[i][0]  
  print(time)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B; cin>>A>>B;
  string ans="Alice";
  if(B==1||(A<B&&A!=1))
    ans="Bob";
  if(A==B)
    ans="Draw";
  cout<<ans<<endl;
  }


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

int main() {
    int N;
    cin >> N;
    vector<int> l(N);
    vector<int> r(N);
    for(int i=0;i<N;i++){
        cin >> l.at(i);
        cin >> r.at(i);
    }
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=r.at(i)-l.at(i)+1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
// 最大の利益
#include <stdio.h>

int main(void)
{
    int n, i, j;
    scanf("%d", &n);

    int array[n];
    for(i=0; i<n; i++){
        scanf("%d", &array[i]);
    }
    int maxv = array[1] - array[0];
    int minv = array[0];
    for(j=1; j<n; j++){
        if(maxv < array[j] - minv){
            maxv = array[j] - minv;
        }
        if(minv > array[j]){
            minv = array[j];
        }
    }
    printf("%d\n", maxv);

    return 0;   
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d, n;
  cin >> d >> n;
  long long ans = n;
  if(n == 100){
      ans += 1;
  }
  for(int i = 0; i < d; i++) ans *= 100;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 10;
const int oo = 1e9;

struct state{ int dist, u, ci; };
int n, m;
map<int, int> dp[N];
vector<ii> vi[N];

void solve()    {
    deque<state> pq;
    pq.push_back({0, 1, 0});

    while(!pq.empty())  {
        state cur = pq.front(); pq.pop_front();
        int u = cur.u, ci = cur.ci;

        if(!dp[u].count(0) || (dp[u][0] > cur.dist) ){
            dp[u][0] = cur.dist; pq.push_back({cur.dist, u, 0});
        }

        if(ci)  {
            int pos = lower_bound(vi[u].begin(), vi[u].end(), ii(ci, 0)) - vi[u].begin();
            while(pos < vi[u].size() && vi[u][pos].fi == ci)    {
                int v = vi[u][pos].se;
                if(!dp[v].count(ci) || dp[v][ci] > cur.dist)    {
                    dp[v][ci] = cur.dist; pq.push_front({cur.dist, v, ci});
                }
                pos ++;
            }
        } else {
            for(ii v: vi[u])    {
                if(!dp[v.se].count(v.fi) || dp[v.se][v.fi] > cur.dist + 1)  {
                    dp[v.se][v.fi] = cur.dist + 1;
                    pq.push_back({cur.dist + 1, v.se, v.fi});
                }
            }
        }
    }
    int ans = oo;
    for(auto v: dp[n])  ans = min(ans, v.se);
    if(ans == oo) printf("-1");
    else printf("%d", ans);
}

signed main()
{
	//freopen("test.inp", "r", stdin);
	scanf("%d%d", &n, &m);
	FOR(i, 1, m)    {
        int u, v, ci; scanf("%d%d%d", &u, &v, &ci);
        vi[u].pb(ii(ci, v));
        vi[v].pb(ii(ci, u));
	}
	for(int i = 1; i <= n; ++i) sort(vi[i].begin(), vi[i].end());
	solve();
}


Measured memory_bytes: 44288
N = int(input())

a = []

for i in range(N):
  a.append(input().split(' '))

money = 0
  
for i in range(N):
  if a[i][1] == 'JPY':
    money += float(a[i][0])
  
  else:
    money += float(a[i][0]) * 380000

print(money)
    

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline


def insertionSort(A):
    for i in range(len(A)):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join([str(a) for a in A]))


def main():
    _ = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    insertionSort(A)


if __name__ == "__main__":
    main()



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

using namespace std;

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

int N, K;

#define INF 11451419
#define MAX_V 1010

int cost[MAX_V][MAX_V];
int V;

int d[MAX_V];
bool used[MAX_V];
void dijkstra(int s) {
  fill(d, d+V, INF);
  fill(used, used+V, false);
  d[s] = 0;

  while (true) {
    int v = -1;
    for (int u=0; u<V; u++) {
       if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;

    for (int u=0; u<V; u++) {
       d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  V = N;
  rep(u, MAX_V) rep(v, MAX_V) cost[v][u] = INF;
  rep(i, K) {
    int op;
    cin >> op;
    if (op == 0) {
      int a, b;
      cin >> a >> b;
      dijkstra(a-1);

      int x = d[b-1];
      cout << (x==INF? -1 : x) << "\n";
    }
    else {
      int c, d, e;
      cin >> c >> d >> e;
      cost[c-1][d-1] = min(cost[c-1][d-1], e);
      cost[d-1][c-1] = min(cost[d-1][c-1], e);
    }
  }
  }
  return 0;
}

Measured memory_bytes: 7000
def getFinal(initial, m, h):
  for i in xrange(m):
    temp = initial[:h[i]]
    # print "temp = " + temp
    initial = initial[h[i]:] + temp
    # print initial
  return initial

while True:
  initial = raw_input()
  if initial == "-":
    break
  m = int(raw_input())
  h = []
  for i in xrange(m):
    h.append(int(raw_input()))

  # line = "*******************"
  # print line
  # print initial
  # print m
  # print h
  # print line

  print getFinal(initial, m, h)

Measured memory_bytes: 6464
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int count1=0,count0=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1'){
            count1++;
        }
        else
        {
            count0++;
        }
    }
    cout<<2*min(count1,count0);
}

Measured memory_bytes: 3768
#include<stdio.h>

int main()
{
    long x,y,i,l=0;
    scanf("%d",&x);
    for(i=1;i<=x;i++){
        scanf("%ld",&y);
        if(y%2==0)
        {
            if(y%3==0 || y%5==0)
                continue;
                else l=1;
        }


}
if(l==0)
        printf("APPROVED");
    else
        printf("DENIED");
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] numbers = new int[4];
        for(int i = 0;i<4;i++)
        {
            numbers[i] = int.Parse(str[i]);
        }
        Array.Sort(numbers);
        //Console.WriteLine("[{0}]", string.Join(", ", numbers));
        if (numbers[0] == 1 && numbers[1] == 4 && numbers[2] == 7 && numbers[3] == 9)
        {
            return "YES";
        }

        return "NO";
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, p[10], q[10],a=0,b=0;
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> p[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> q[i];
	}
	for (int i = 1; i < n;i++) {
		int c = p[i] - 1,m=1;
		for (int j = 1; j < i;j++) {
			if (p[i]>p[j]) {
				c--;
			}
		}
		for (int j = 1; j <=n-i ;j++) {
			m *= j;
		}
		a += c*m;
	}
	for (int i = 1; i < n; i++) {
		int c = q[i] - 1, m = 1;
		for (int j = 1; j < i; j++) {
			if (q[i] > q[j]) {
				c--;
			}
		}
		for (int j = 1; j <= n - i; j++) {
			m *= j;
		}
		b += c*m;
	}
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, cnt;
pair<int, int>p[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
		p[i].first -= p[i].second;
	}
	sort(p, p + N);
	cnt = N;
	int q = -intmax;
	for (int i = 0; i < N; i++) {
		if (p[i].first >= q) {
			q = p[i].first + p[i].second + p[i].second;
		}
		else {
			cnt--;
			q = min(q, p[i].first + p[i].second + p[i].second);
		}
	}
	cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a, b;
	cin>>a>>b;
	if(a<b){
		swap(a, b);
	}
	if(a==b){
		cout<<a+b<<'\n';
	}
	else{
		cout<<a*2-1<<'\n';
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/06/03  Problem: ARC 075 B / Link: http://arc075.contest.atcoder.jp/tasks/arc075_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N,A,B;
ll h[100010];
ll a[100011];

ll ans = 0LL;



// x回で倒せるか
bool f(ll x) {
	FOR(i, 0, N)a[i] = h[i];
	ll s = x;
	FOR(i, 0, N)a[i] -= B*s;


	ll cnt = 0;;
	FOR(i, 0, N) {
		if (a[i] <= 0)continue;
		cnt += (a[i]+A-B-1) / (A - B);
	}

	if (cnt > s)return 0;
	else return 1;
	

}

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

  cin >> N>>A>>B;
  FOR(i, 0, N)cin >> h[i];

  sort(h, h + N);

  ll l = 0; ll r = 1e10;
  FOR(i, 0, 150) {
	  ll mid = (r + l) / 2;
	  if (f(mid))r = mid;
	  else l = mid;



  }
//  cout << r << " " << l << endl;
  ans = r;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int min = 0;
		int min2 = 0;

		if(a < b){
			min = a;
			if(b < c){
				min2 = b;
			}
			else{
				min2 = c;
			}
		}
		else{
			min = b;
			if(a < c){
				min2 = a;
			}
			else{
				min2 = c;
			}
		}
		System.out.println(min + min2);
	}
}

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

int main(){
  int d1,d2,m1,m2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if(d2 == 1){
	cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
}
  

Measured memory_bytes: 256
import itertools

numbers = []
while True:
    n = list(map(int, input().split()))
    if n[0] == 0 and n[1] == 0:
        break
    else:
        numbers.append(n)

for n in numbers:
    num = list(range(1, n[0]+1))
    count = 0
    for i in itertools.combinations(num, 3):
        if sum(i) == n[1]:
            count += 1
    print(count)

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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;

int main() {
    string N;
    cin>>N;
    //int ans=9*(N.length()-1);
    int dp[17][2]; 
    memset(dp,0,34);

    dp[0][0]=(int)(N[0]-'0')-1; //確定
    dp[0][1]=(int)(N[0]-'0');

    for(int i=1;i<N.length();i++){
        dp[i][1]=dp[i-1][1]+(int)(N[i]-'0');
        dp[i][0]=dp[i-1][0]+9;

        if(N[i]!=0){
            dp[i][0]=max(dp[i][0],dp[i-1][1]+(int)(N[i]-'0')-1);
        }

    }
    cout<<max(dp[N.length()-1][0],dp[N.length()-1][1])<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp!.to_i
str_list = Array.new
n.times do
  #str入力
  str = gets.chomp!
  #strバラし、繋げる
  str_list.push(str.chars.sort.join)
end

count = Hash.new(0)
str_list.each do |elem|
  count[elem] += 1
end

a = 0
count.each_value do |e|
  a += e*(e-1) / 2
end

p a

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n,l[200];

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

	cin>>n;
	REP(i,2*n) cin>>l[i];
	sort(l,l+2*n);
	int sum=0;
	for(int i=0;i<2*n;i+=2) sum+=l[i];
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
cost=0
amount=m
for i in range(n):
    if amount>0:
        #print('am:',amount)
        if amount > ab[i][1]:
            cost+=ab[i][0]*ab[i][1]
            amount-=ab[i][1]
        else:
            cost+=ab[i][0]*amount
            break
print(cost)


Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum = sum + a[i];
  }
  if (n - sum >= 0) {
    cout << n - sum;
  }
  if (n - sum < 0) {
    cout << "-1";
  }
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;
    bool f = true;

	if (s[0] != 'A') f = false;
	int pos = -1;
	for(int i = 2; i < s.size() - 1; i++){
		if(isupper(s[i])){
			if (pos != -1) f = false;
	    	pos = i;
		}
	}
	if(pos == -1) f = false;
	for(int i = 0; i < s.size(); i++){
		if (i == 0 || i == pos) continue;
		if (isupper(s[i])) f = false;
	}
	cout << (f ? "AC" : "WA") << endl;
	return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
#define llevel 20
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
const int N=100005;
vector<ll> v[N];
bool vis[N];
ll dp2[N],dp[N],mod;
void dfs(ll s)
{
	vis[s]=true;
	dp2[s]=1;
	dp[s]=1;
	for(auto j:v[s])
	{
		if(!vis[j])
		{
			dfs(j);
			dp[s]=dp[s]*(dp[j]+1)%mod;
		}
	}
}
void dfs2(ll s,ll val=0)
{
	vis[s]=true;
	vector<ll> v2;
	dp2[s]=((val+1)*dp[s])%mod;
	for(auto j:v[s])
	{
		if(!vis[j])
			v2.pb(dp[j]+1);
	}
	size_t nn=v2.size();
	vector<ll> pfx(nn+1),sfx(nn+1);
	pfx[0]=sfx[nn]=1;
	for(int i=1;i<=nn;++i)
		pfx[i]=v2[i-1]*pfx[i-1]%mod;
	for(int i=nn-1;i>=0;--i)
		sfx[i]=sfx[i+1]*v2[i]%mod;
	ll curr=0;
	for(auto j:v[s])
	{
		if(!vis[j])
		{
			dfs2(j,(val+1)*(pfx[curr]*sfx[curr+1]%mod)%mod);
			++curr;
		}
	}
}
int _runtimeTerror_()
{
	ll n;
	cin>>n>>mod;
	for(int i=0;i<n-1;++i)
	{
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);v[y].pb(x);
	}
	dfs(1);
	memf(vis);
	dfs2(1);
	for(int i=1;i<=n;++i)
		cout<<dp2[i]<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


Measured memory_bytes: 25472
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}


#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(usize);
    let ds = invec!(u64);

    let mut total = 0;
    for i in 0..n {
        for j in (i+1)..n {
            total += ds[i] * ds[j];
        }
    }

    println!("{}", total);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
n = int(input())
nt,nx,ny = 0,0,0
 
for i in range(n):
    t,x,y = map(int,input().split())
    if (abs(nx-x)+abs(ny-y)) > t-nt:
        print("No")
        exit()
    else:
        t2 = t-nt-abs(nx-x)
        if abs(ny-y)%2 == 0 and t2%2 == 0:
            nt,nx,ny = t,x,y
        elif abs(ny-y)%2 == 1 and t2%2 == 1:
            nt,nx,ny = t,x,y
        else:
            print("No")
            exit()
 
print("Yes")

Measured memory_bytes: 48616
#include <stdio.h>


int main(void)
{
	double r, pi=3.141592653589;
	double men, ens;
	
	scanf("%lf", &r);
	
	men = r * r * pi;
	ens = 2.0 * r * pi;
	
	printf("%lf %lf\n", men, ens);
	
	
	
	
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 648
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        if (tup[0] in nums) assert(0);
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (all_num > all_num_true) re[N] = 1;
    //else if (all_num < all_num_true) assert(0);
    
    foreach (k; 0 .. N) {
        writeln( all_num_true - (nums[A[k]] - 1) );
    }
}



Measured memory_bytes: 26640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=a;
    (b>=a)?:ans--;
    printf("%d",ans);
    return 0;
}

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

using namespace std;

vector<int>v;

void sieve()
{
    bool prime[1000005];
    memset(prime,true,sizeof(prime));
    long long i,j;
    for(i = 2;i <= 1000;i++){
        if(!prime[i])continue;
        for(j = i*i;j <= 1000000;j+=i)prime[j] = false;
    }
    for(i = 2;i <= 1000000;i++)if(prime[i])v.push_back(i);
}

int main()
{
    sieve();
    long long a,b,g,i;
    set<long long>s;
    cin>>a>>b;
    g = __gcd(a,b);
    for(i = 0;i<v.size();i++){
        while(g % v[i] == 0){
            s.insert(v[i]);
            g /= v[i];
        }
    }
    s.insert(g);s.insert(1);
    cout<<(int)s.size()<<'\n';
    return 0;
}


Measured memory_bytes: 1916
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

int* table;

void func(int X,int Y){

	int current = X%Y,ans_left,ans_right;

	table[current] = 0;

	for(int i = 1;i < 1000000; i++){
		current = (10*current)%Y;

		if(current == 0){ //?????????????????´???
			ans_left = i;
			ans_right = 0;
			break;
		}else{
			if(table[current] != -1){
				ans_left = table[current];
				ans_right = i - table[current];
				break;
			}else{
				table[current] = i;
			}
		}
	}
	printf("%d %d\n",ans_left,ans_right);
}


int main(){

	int X,Y;

	table = new int[1000010];

	while(true){
		scanf("%d %d",&X,&Y);
		if(X == 0 && Y == 0)break;

		for(int i = 0; i < 1000010; i++)table[i] = -1;

		func(X,Y);
	}

    return 0;
}

Measured memory_bytes: 6636
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


def dfs(s, c):
    if len(s) == N:
        print(s)
    else:
        for ch in range(97, ord(c) + 1):
            dfs(s + chr(ch), chr(ord(c) + 1) if chr(ch) == c else c)


N = int(read())
dfs("", "a")


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n;
	int d1[110], d2[110];

	bool p[110];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> d1[i] >> d2[i];
		p[i] = d1[i] == d2[i];
	}

	for(int i = 0;i < n-2;i++){
		if(p[i] && p[i+1] && p[i+2]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using pint = pair<int, int>;

int main() {
    int N; cin >> N;
    vector<pint> B;
    vector<int> A;
    
    // A[i] = A[i+1] みたいなところは 1 つの点に圧縮する
    int prev = -1;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a != prev) {
            B.push_back(pint(a, B.size())); // B は index も付け加える
            A.push_back(a);
            prev = a;
        }
    }
    sort(B.begin(), B.end(), greater<pint>());
    
    // 折れ線の折れ曲がりがない場合は例外
    if (A.size() == 1) {
        if (A[0] > 0) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else {
        // 上から順番に走査していく
        int res = 1;
        int cur = 0;
        for (int i = 0; i < B.size(); ++i) {
            int id = B[i].second;
            
            if (id == 0) {
                if (A[id] > A[id+1]) ++cur;
            }
            else if (id == A.size() - 1) {
                if (A[id-1] < A[id]) ++cur;
            }
            else {
                if (A[id-1] < A[id] && A[id] > A[id+1]) ++cur;
                else if (A[id-1] > A[id] && A[id] < A[id+1]) --cur;
            }

            // 同一高さに複数の「山頂」や「谷底」がある場合は、その高さの処理をすべて終えてから更新する
            if (i == (int)B.size() - 1 || B[i].first != B[i+1].first) {
                res = max(res, cur);
                prev = B[i].first;
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 4556
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 1e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n;
    SCD(n);
    int a[505];
    long long dp[405][405];
    memset(dp, BIGINF, sizeof(dp));
    for (int i = 0; i < n; i++) {
    	SCD(a[i]);
    }
    long long prefix[405];
    prefix[0] = 0;
    for (int i = 1; i <= n; i++) {
    	prefix[i] += prefix[i - 1] + a[i - 1];
    }
    for (int L = n - 1; L >= 0; L--) {
    	for (int R = L; R < n; R++) {
    		if (L == R) {
    			dp[L][R] = 0;
    		}
    		else {
    			for (int k = L; k <= R - 1; k++) {
    				dp[L][R] = min(dp[L][R], dp[L][k] + 
    							   dp[k + 1][R] + (prefix[R + 1] - prefix[L]));
    			}
    		}
    	}
    }
   	// dp[i][j] min cost to convert into one
    printf("%lld" , dp[0][n - 1]);

    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

// nCa
ll combinationWithoutMod(ll n, ll k){
    ll v[51][51];
    rep(i,n+1){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    repi(i,n+1){
        repi(j,i){
            v[i][j] = v[i-1][j-1] + v[i-1][j];
        }
    }
    return v[n][k];
}

void Main()
{
    ll n, A, B;
    cin >> n >> A >> B;

    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    
    sort(all(v));
    reverse(all(v));

    ll sum = 0;
    rep(i, A) {
        sum += v[i];
    }
    ld avg = (ld)sum / A;
    printf("%.6Lf\n", avg);

    ll minVal = v[A - 1];
    ll offset = -1;
    ll len = 0;
    rep(i, n) {
        if (minVal == v[i]) {
            if (offset < 0) offset = i; 
            len++;
        }
    }

    // 上位が全部minValだった場合、A+1個とってもよい
    ll res = 0;
    if (offset == 0) {
        for (ll i = A; i <= B; i++) {
            res += combinationWithoutMod(len, i);
        }
    }
    else {
        res = combinationWithoutMod(len, A - offset);
    }

    put(res);

}
signed main(){ Main();return 0;}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    int ans = 0;
    rep(i, n)
    {
        ans += min(a[i], b[i]);
        b[i] -= a[i];
        if (b[i] > 0)
        {
            ans += min(a[i + 1], b[i]);
            a[i + 1] = max(0LL, a[i + 1] - b[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		if(N % 2 == 1){
			System.out.println("No");
		}else{
			String S1 = S.substring(0 , N / 2);
			String S2 = S.substring(N / 2);
			if(S1.equals(S2)){
				System.out.println("Yes");				
			}else{
				System.out.println("No");								
			}
		}
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = acos(-1); // cos(pi) = -1 <=> pi = arccos(-1)

/* global variables */
vector<int> dice(6);
/* function */

struct Dice{

  int s[6];

  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0]; s[0]=s[3]; s[3]=s[5]; s[5]=s[2]; s[2]=b;
    }
    if(c=='W'){
      b=s[0]; s[0]=s[2]; s[2]=s[5]; s[5]=s[3]; s[3]=b;
    }
    if(c=='N'){
      b=s[0]; s[0]=s[1]; s[1]=s[5]; s[5]=s[4]; s[4]=b;
    }
    if(c=='S'){
      b=s[0]; s[0]=s[4];s[4]=s[5]; s[5]=s[1]; s[1]=b;
    }
  }

  void shift() {
      int b;
      b=s[1]; s[1]=s[2]; s[2]=s[4]; s[4]=s[3]; s[3]=b;
  }

  int top() {
    return s[0];
  }

  void print_dice() {
        for (int i = 0; i < 6; i++) {
            cout << s[i] << ' ';
        } cout << '\n';
  }


};

Dice d[100];

bool check(int a, int b) {
    bool flag = true;
    for (int i = 0; i < 6; i++) {
        if (d[a].s[i] != d[b].s[i]) flag = false;
    }
    return flag;
}

/* main */
int main(){


    int n; cin >> n;
    for (int ind = 0; ind < n; ind++) {
        for (int i = 0; i < 6; i++) {
            cin >> d[ind].s[i];
        }
    }

    bool same = false;
    for (int k = 0; k < n-1; k++) {
        for (int l = k+1; l < n; l++) {
            for (int i = 0; i < 4; i++) {
                d[l].roll('S');
                for (int j = 0; j < 4; j++) {
                    d[l].shift();
                    same = check(k, l);
                    if (same) {
                        cout << "No" << '\n';
                        return 0;
                    }
                    // d[l].print_dice();
                }
            }
            d[l].roll('E'); 
            for (int j = 0; j < 4; j++) {
                    d[l].shift();
                    same = check(k, l);
                    if (same) {
                        cout << "No" << '\n';
                        return 0;
                    }

                    // d[l].print_dice();
            }
            d[l].roll('W'); 
            d[l].roll('W'); 
            for (int j = 0; j < 4; j++) {
                    d[l].shift();
                    same = check(k, l);
                    if (same) {
                        cout << "No" << '\n';
                        return 0;
                    }
                    // d[l].print_dice();
            }
            d[l].roll('E'); 
        }
    }

      cout << "Yes" << '\n';


}




Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




ll n, m;
vector<vector<ll>> g;
bool used[200005];

void dfs(ll p){
    for(auto x : g[p]){
        if(!used[x]){
            used[x] = true;
            dfs(x);
        }
    }
}

int main() {
    cin >> n >> m;
    g.resize(n + m);
    REP(i, n){
        ll k;
        cin >> k;
        REP(j, k){
            ll l;
            cin >> l;
            l--;
            g[i].push_back(n + l);
            g[n + l].push_back(i);
        }
    }
    
    dfs(0);
    
    REP(i, n){
        if(!used[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 8948
#13:50
n,a,b = map(int,input().split())
a -= b
h = []
for _ in range(n):
  h.append(int(input()))
now = 0
scale = 2**31
while scale != 0:
  tmp = now + scale
  cnt = 0
  for x in h:
    y = x - tmp * b
    if y > 0:
      cnt += (y-1) // a + 1
  if cnt > tmp:
    now = tmp
  #print(tmp,cnt)
  scale //= 2
print(now+1)

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

int main(){
  int i,n,m,s;
  cin >> n >> m;
  vector<int> a(m);
  s=0;
  for(i=0;i<m;i++){
    cin >> a.at(i);
    s=s+a.at(i);
  }
  
  if(s>n){
    cout << -1 << endl;
  }else{
    cout << n-s << endl;
  }
}

Measured memory_bytes: 3644
# import sys
# input = sys.stdin.readline
# import re
import itertools

def main():
    n = int(input())
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for _ in range(n):
        s = str(input())
        if s == "AC":
            ac += 1
        elif s == "WA":
            wa += 1
        elif s == "TLE":
            tle += 1
        elif s == "RE":
            re += 1
    print("AC x", ac)
    print("WA x", wa)
    print("TLE x", tle)
    print("RE x", re)

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

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

if __name__ == '__main__':
    main()



Measured memory_bytes: 69892
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int A,B;
  cin >> A >> B;
  bool flag = false;
  int res;
  for(int x = 1; x <= 50000; x++){
    if(x * 8 / 100 == A && x * 10 / 100 == B){
      res = x;
      flag = true;
      break;
    }
  }
  if(flag == false){
    cout << -1 << endl;
  }else{
    cout << res << endl;
  }
}


Measured memory_bytes: 256
X,Y,Z,K = map(int,input().split())
K = min(K,X*Y*Z)
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
sum2 = []
for a in A:
    for b in B:
        sum2.append(a+b)
sum2.sort(reverse = True)
sum2 = sum2[:K]
idx = 0
sum3 = []
for c in C:
    for s in sum2:
        sum3.append(c+s)
sum3.sort(reverse=True)
for i in range(K):
    print(sum3[i])

Measured memory_bytes: 223256
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		int X = reader.ni();
		int a = X / 500;
		X %= 500;
		int b = X / 5;

		int res = a * 1000 + b * 5;
		System.out.println(res);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 21460
#include <iostream>
#include <string>

int main (void) {
  std::string S; std::cin >> S;
  
  int year = std::atoi(S.substr(0,4).c_str());
  int mon =  std::atoi(S.substr(5,2).c_str());
  int day =  std::atoi(S.substr(8,2).c_str());
  
  if ( year <= 2018 ) {
    std::cout << "Heisei" << std::endl;
  }
  else if ( mon <= 4 ) {
    std::cout << "Heisei" << std::endl;
  }
  else {
    std::cout << "TBD" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

ll fac[100000];

ll p(int a, int b){
  if(b == 1) return a;
  else if(b % 2 == 0){
    ll x = p(a, b/2);
    return (x*x) % MOD;
  }
  else return (a * p(a, b-1)) % MOD;
}

ll comb(int n, int m){
  if(n < 0 || m < 0 || n < m) return 0;
  ll x = fac[n];
  x = (x * p(fac[m], MOD-2)) % MOD;
  x = (x * p(fac[n-m], MOD-2)) % MOD;
  return x;
}

int main(){
  fac[0] = 1;
  FOR(i, 1, 100000) fac[i] = (fac[i-1] * i) % MOD;
  int n;
  cin >> n;
  int a[n+1];
  REP(i, n+1) cin >> a[i];
  int r = -1, l, t;
  int o[n] = { };
  REP(i, n+1) o[a[i]-1]++;
  REP(i, n){
    if(o[i] == 2) t = i+1;
  }
  REP(i, n+1){
    if(a[i] == t && r == -1) r = i;
    else if(a[i] == t) l = i;
  }
  l = n - l;
  REP(i, n+1){
    cout << (comb(n-1, i-1) + 2*comb(n-1, i) + comb(n-1, i+1) - comb(l+r, i) + MOD) % MOD << endl;
  }
  return 0;
}


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

int main()
{
    int count[4] = { 0, 0, 0, 0 };
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")
            count[0]++;
        else if (s == "WA")
            count[1]++;
        else if (s == "TLE")
            count[2]++;
        else
            count[3]++;
    }
    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int N=1e6;
int n;
LL x,ans=INF,a[N+10],b[N+10];
LL Sqr(LL x) {
    return x*x;
}
int main() {
    scanf("%d%lld",&n,&x);
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++) b[i]=b[i-1]+a[i];
    LL nowsum=0;
    for (int i=1;i<=n;i++) {
        LL sum=0;
        nowsum=min(INF,nowsum+(a[n-i+1]-a[n-i])*i*5);
        for (int j=n-i;j>=1;j-=i) {
            int l=max(j-i+1,1);
            int sz=j-l+1;
            LL nowx=b[j]-b[l-1]-a[l-1]*sz;
            LL k=Sqr((n-j)/i+2)-Sqr((n-j)/i+1);
            LL Base=Sqr((n-j)/i+1)*i;
            double value=1.0*nowx*k+1.0*Base*(a[j]-a[l-1]);
            if (value>INF) {
                sum=INF;
                break;
            }
            sum=min(INF,sum+nowx*k+Base*(a[j]-a[l-1]));
        }
        sum+=x*(n+i)+nowsum+a[n-i]*i;
        ans=min(ans,sum);
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  long a, b, c;

  cin >> a >> b >> c;

  long d = a, e = b, f = c;

  if (a % 2 || b % 2 || c % 2) {
    cout << 0;
    return 0;
  }

  long ans = 0;

  while (1) {
    ans++;
    long atmp = a, btmp = b, ctmp = c;
    a = btmp / 2 + ctmp / 2;
    b = atmp / 2 + ctmp / 2;
    c = atmp / 2 + btmp / 2;
    if (a % 2 || b % 2 || c % 2) {
      cout << ans;
      return 0;
    } else if (a == d && b == e && c == f) {
      cout << -1;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
 
int N, P, a[50];
 
int main(void) {
  while(cin >> N >> P, N && P) {
    REP(i, 0, N) a[i] = 0;
 
    for(int i = 0; true; i = (i + 1) % N) {
      if(P == 0) {
        P = a[i];
        a[i] = 0;
      } else {
        P--;
        a[i]++;
        if(P == 0) {
          bool fin = true;
          REP(j, 0, N) if(j != i && a[j] != 0) fin = false;
          if(fin) {
            cout << i << endl;
            break;
          }
        }
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        char A;
        cin >> A;

        if (A == 'a' || A == 'e' || A == 'i' || A == 'o' || A == 'u')
        {
                cout << "vowel" << endl;
        }
        else
        {
                cout << "consonant" << endl;
        }


        return 0;
}


Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n,m,p = map(int,ipt().split())

    way = [[] for i in range(n+1)]
    gway = [[] for i in range(n+1)]
    rway = [[] for i in range(n+1)]
    for i in range(m):
        a,b,c = map(int,ipt().split())
        way[a].append((b,p-c))
        rway[b].append(a)
        gway[a].append(b)

    ar = [True]*(n+1)
    ar[n] = False
    q = [n]
    while q:
        qi = q.pop()
        for j in rway[qi]:
            if ar[j]:
                ar[j] = False
                q.append(j)
    q = [1]
    ar2 = [True]*(n+1)
    ar2[1] = False
    while q:
        qi = q.pop()
        for j in gway[qi]:
            if ar2[j]:
                ar2[j] = False
                q.append(j)

    for i in range(1,n+1):
        if ar[i] or ar2[i]:
            way[i] = []

    def bellmanford(s,g,way):
        n = len(way)
        d = [10**18]*(n)
        d[s] = 0
        sl = 0
        re = True
        while re:
            re = False
            for i in range(1,n):
                for j,cj in way[i]:
                    if d[j] > d[i]+cj:
                         d[j] = d[i]+cj
                         re = True
            sl += 1
            if sl == n:
                d[g] = -10**18
                break
        return d[g]

    ans = bellmanford(1,n,way)
    if ans == -10**18:
        print(-1)
    else:
        print(max(0,-ans))

    return None

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(1);
	int n,m;cin>>n>>m;
	vi cnt(n,0);
	vi ac(n,0);
	FOR(i,m){
		int p;cin>>p;--p;
		string s;cin>>s;
		if (s=="AC") ac[p]=1;
		else if (ac[p]==0) ++cnt[p];
	}
	int pen=0,total=0;
	FOR(i,n) if (ac[i]) {++total,pen+=cnt[i];}
	cout << total << " " << pen;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  if(n%1000 > 0) {
    cout << 1000 - n % 1000 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(char c)
{
	stack <char> s,S;
	while(~scanf("%c",&c)&&c!='\n'&&c!=EOF)
	{
		if(c=='B'&&!s.empty())
		s.pop();
		if(c!='B')
		s.push(c);
	}
	while(!s.empty())
	{
		S.push(s.top());
		s.pop();
	}
	while(!S.empty())
	{
		cout<<S.top();
		S.pop();
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
pre = list(int() for _ in range(300000))

N,M = map(int,input().split())
H = list(map(int,input().split()))
"road = [list(map(int,input().split())) for _ in range(M)]"

for _ in range (M):

    road =list(map(int,input().split()))

    st = road[0]
    gl = road[1]

    if H[st-1]<=H[gl-1]:
        pre[st-1] += 1

    if H[st-1]>=H[gl-1]:
        pre[gl-1] += 1

con = 0

for i in range (300000):


    if pre[i] == 0:
        con += 1

ans = 300000 - con

fin = N - ans

print(fin)


Measured memory_bytes: 98792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    
    ll r = 0;

    int cnt = 1;
    while (cnt <= n) {
        if (cnt % 3 != 0 && cnt % 5 != 0) {
            r += cnt;
        }
        ++cnt;
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
using namespace std;
typedef unsigned long long ullong;
int n, k;

ullong count_tal(ullong u){
  ullong init = 1 * (u-1) * u / 2;
  ullong end = 1 * (2 * n - u + 1) * u / 2;
  return end - init + 1;
}

int main(){
  cin >> n >> k;
  //cout << ans << endl;
  ullong total = 0;
  for (ullong i=k;i<=n+1;i++){
    ullong ans = count_tal(i);
    total  += ans;
    total = total % 1000000007;
  }
  cout << total << endl;
}


Measured memory_bytes: 3188
n=int(input())
a=[]
for i in range(n):
  b,d=map(int,input().split())
  a.append([d,b])
a.sort()
t=0
f=0
for i in range(n):
  t=t+a[i][1]
  if(t>a[i][0]):
    f=1
    break
if(f==1):
  print('No')
else:
  print('Yes')


Measured memory_bytes: 35608