akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d%d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double)a/b;
	 printf("%d ",d);
	 printf("%d ",r);
	 printf("%.5f\n",f);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;
#define TEST(x) int x; cin>>x; while(x--)
#define ITR(type, var) type::iterator var;
#define ALIAS(type, alias) using alias = type;
#define ALIAS_M(container, A, B, alias) using alias = container<A,B>;

using namespace std;
using ii = pair<int,int>;
using vii = vector<ii>;
using vi = vector<int>;
using vvi = vector<vi>;
using hmapii = unordered_map<int,int>;
using hmapsi = unordered_map<string, int>;
using hmapss = unordered_map<string, string>;
using ll = long long;
using llu = unsigned long long;

int main() {
	FIO;
	int r;
	cin>>r;
	const long double pi = acos(-1);
	long double ans = 2*pi*r;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3816
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int step[] = new int[6];
		int n = sc.nextInt();
		for (int i = 0; i < n; i++)
		{
			double h = sc.nextDouble();
			if (h < 165.0)
				step[0]++;
			else if (h < 170.0)
				step[1]++;
			else if (h < 175.0)
				step[2]++;
			else if (h < 180.0)
				step[3]++;
			else if (h < 185.0)
				step[4]++;
			else
				step[5]++;
		}
		for (int i = 0; i < 6; i++)
		{
			System.out.printf("%d:", i+1);
			for (int j = 0; j < step[i]; j++)
			{
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
a = input()
b = input()
A = []
B = []
for i in range(len(a)):
  A.append(a[i])
for j in range(len(b)):
  B.append(b[j])
A.sort()
B.sort()
B.reverse()
aa = ''
bb = ''
for i in range(len(a)):
  aa += A[i]
for j in range(len(b)):
  bb += B[j]
if aa < bb:
  print('Yes')
else:
  print('No')
#print(aa,bb)

Measured memory_bytes: 3064
N,M=map(int,input().split())

graph=[[False]*N for i in range(N)]
visited=[False]*N
a=[0]*M
b=[0]*M

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


def dfs(v):
    visited[v]=True
    for v2 in range(N):
        if graph[v][v2]==False:continue
        if visited[v2]==True:continue
        dfs(v2)

ans=0
for i in range(M):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    for j in range(N):
        visited[j]=False
    dfs(0)
    bridge=False
    for j in range(N):
        if visited[j]==False:
            bridge=True
    if bridge==True:
        ans+=1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

const int MAX=1005;
const int mod=1e9+7;
int dp[MAX][MAX];
char plane[MAX][MAX];
int h,w;

int main(){
    cin >> h >> w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> plane[i][j];
        }
    }
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(plane[i][j]!='#'){
                dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
long long a[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	long long res=0LL,tmp=0LL; 
	for(int i=1;i<=n;i++){
		if(a[i]!=0LL)
			tmp+=a[i];
		else{
			res+=tmp/2;
			tmp=0LL;
		}
	}
	res+=tmp/2;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mincost(vector<ll> v,ll n)
{
  ll dp[100001];
  dp[0] = 0;
  dp[1] = abs(v[1] - v[0]);
  for(ll i=2;i<n;i++)
  {
    dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]),dp[i-2] + abs(v[i] - v[i-2]));
  }
  return dp[n-1];
}
int main()
{
  vector<ll> v;
  ll n,t;
  cin>>n;
  for(ll i=0;i<n;i++)
  {
    cin>>t;
    v.push_back(t);
  }
  cout<<mincost(v,n);

  return 0;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n,m;
    cin>>n>>m;
    vector<double >v(n);
    for(auto &c:v)
        cin>>c;
    double sum=0;
    for(auto c:v)
        sum+=c;
    //cout<<sum<<endl;
    int cnt=0;
    for(int i=1;i<=n;i++)
    if(double ((double (sum)/double (4*m)))<=v[i-1])
        cnt++;
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(int argc, char* argv[]) {
	ll n, m, sum = 0;
	cin >> n;
	ll a;
	ll Employee[200005] = {};
	for (int i = 1; i < n; i++)
	{
		cin >> a;
		Employee[a]++;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << Employee[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5160
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int n; cin >> n;
  int a[n][3];
  rep(i, n){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  int dp[101010][3];  // dp[i][j] : i + 1 日目に j をしたときの幸福の総和の最大値
  for (int i = 0; i < 101010; ++i){
    for (int j = 0; j < 3; ++j) dp[i][j] = -1;
  }

  for (int i = 0; i < 3; ++i) dp[0][i] = a[0][i];

  for (int i = 0; i < n - 1; ++i){
    dp[i + 1][0] = max(dp[i][1] + a[i + 1][0], dp[i][2] + a[i + 1][0]);
    dp[i + 1][1] = max(dp[i][2] + a[i + 1][1], dp[i][0] + a[i + 1][1]);
    dp[i + 1][2] = max(dp[i][0] + a[i + 1][2], dp[i][1] + a[i + 1][2]);
  }

  print(max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}));

  return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {

	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;

	REP(i, 3001) {
		REP(j, 3001) {
			int k = n - i*r - j*g;
			if(k%b==0)if (0 <= k && k <= n)ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
<?php


  while(true) {
    $line = explode(" ",fgets(STDIN));
    $H =$line[0];
    $W = $line[1];


    if($H ==0 && $W == 0) {
      break;
    }
    for($i=0;$i<$H;$i++) {
      for($j=0;$j<$W;$j++) {
        if(($i>0)&& ($i!== ($H-1))&&($j >0)&& ($j!==($W-1))){
          print(".");
        }else{
          print("#");
        }

      }
      echo PHP_EOL;

    }
  echo PHP_EOL;
}


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

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

	int x = 0, N;
	string s;
	cin >> N >> s;

	int ans = 0;
	for(int i = 0; i < N; i++) {
		if(s[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
char s[8][8];
int main(){
	

	while(cin>>s[0][0]){
		for(int j=1;j<8;j++){
			cin>>s[0][j];
		}
		for(int i=1;i<8;i++){
			for(int j=0;j<8;j++){
				cin>>s[i][j];
			}
		}
		for(int y=0;y<8;y++){
			for(int x=0;x<8;x++){
		if(s[y][x]=='1'&&s[y+1][x]=='1'&&s[y][x+1]=='1'&&s[y+1][x+1]=='1')
			cout<<"A"<<endl;
		else if(s[y][x]=='1'&&s[y+1][x]=='1'&&s[y+2][x]=='1'&&s[y+3][x]=='1')
			cout<<"B"<<endl;
		else if(s[y][x]=='1'&&s[y][x+1]=='1'&&s[y][x+2]=='1'&&s[y][x+3]=='1')
			cout<<"C"<<endl;
		else if(s[y][x]=='1'&&s[y+1][x]=='1'&&s[y+1][x-1]=='1'&&s[y+2][x-1]=='1')
			cout<<"D"<<endl;
		else if(s[y][x]=='1'&&s[y][x+1]=='1'&&s[y+1][x+1]=='1'&&s[y+1][x+2]=='1')
			cout<<"E"<<endl;
		else if(s[y][x]=='1'&&s[y+1][x]=='1'&&s[y+1][x+1]=='1'&&s[y+2][x+1]=='1')
			cout<<"F"<<endl;
		else if(s[y][x]=='1'&&s[y][x+1]=='1'&&s[y+1][x]=='1'&&s[y+1][x-1]=='1')
			cout<<"G"<<endl;
			}
		}
	}
}

Measured memory_bytes: 1132
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        int[] l = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            l[i] = int.Parse(input[i]);
        }

        int total = 0;

        for (int i = 0; i < n - 2; i++)
        {
            for (int j = i + 1; j < n - 1; j++)
            {
                for (int k = j + 1; k < n; k++)
                {
                    if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k])
                    {
                        continue;
                    }
                    if (l[i] + l[j] <= l[k] || l[i] + l[k] <= l[j] || l[j] + l[k] <= l[i])
                    {
                        continue;
                    }

                    total++;
                }
            }
        }

        Console.WriteLine(total);
    }
}

Measured memory_bytes: 27492
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
d=n1()

d.sort()
a=d[n//2-1]
b=d[n//2]
print(b-a)

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


int main()
{
  int n;
  cin >> n;
  vector<int> m(n,0);
  for(int a = 1; a < 142; ++a){
    for(int b = 1; b < 142; ++b){
      for(int c = 1; c < 142; ++c){
        if(a*a+b*b+c*c+a*b+b*c+c*a > n) break;
        m[a*a+b*b+c*c+a*b+b*c+c*a-1]++;
        //cout << a << b << c << endl;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    cout << m[i] << endl;
  }
}


Measured memory_bytes: 3664
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
int a[N];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n;cin>>n;
    ll res = 0;
    _for(i,0,n){cin>>a[i];res^=a[i];}
    _for(i,0,n)cout<<(res^a[i])<<' ';
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 4356
import math


raw_input = list(map(int, input().strip().split()))
h_len = raw_input[0]
m_len = raw_input[1]
h = raw_input[2] / 12
m = raw_input[3] / 60
m_degree = 360 * m
h_degree = 360 * h + 30 * m
abs_degree = abs(m_degree - h_degree)
a_len = h_len ** 2 + m_len ** 2 - 2 * h_len * m_len * math.cos(math.radians(abs_degree))
print(math.sqrt(a_len))

Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int n;
int a[200005];
long long ans=0;
int main(int argc, char** argv) {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]; 
	}
	sort(a,a+n);
	ans+=a[n-1];
	for(int i=1;i<=(n-2)/2;i++){
		ans += a[n-i-1]*2;
	}
	if((n-2)%2 != 0){
		ans+=a[n-(n-2)/2-2];
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int n,x;cin>>n>>x;
	int ans=1;
	int cur=0;
	for(int i=0;i<n;i++){
		int l;
		cin>>l;
		cur+=l;
		if(cur<=x)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

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 ans = 0;
		
		ans = c - (a - b);
		if (ans < 0)
			ans = 0;
		out.println(ans);

	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	int m[2], d[2];
	rep(i, 2)cin >> m[i] >> d[i];
	if (m[0] != m[1])co(1);
	else co(0);
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE TupleSections #-}

import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import           Control.Monad (replicateM)

modT :: Integer
modT = 1000000007

main :: IO ()
main = do
  n <- getInt
  m <- M.fromListWith (+) . fmap ((, 1) . convert) <$> replicateM n getInts
  print . solve $ m

convert :: [Int] -> (Int, Int)
convert [a, b]
  | a == 0 && b == 0 = (0, 0)
  | a == 0 = (0, 1)
  | b == 0 = (1, 0)
  | otherwise = let gcd' = gcd a b
                in if b < 0
                   then (-div a gcd', -div b gcd')
                   else (div a gcd', div b gcd')

solve :: M.Map (Int, Int) Int -> Integer
solve map = let zero = M.findWithDefault 0 (0, 0) map
                ans = solve' . M.delete (0, 0) $ map
            in (fromIntegral zero + ans - 1) `mod` modT

solve' :: M.Map (Int, Int) Int -> Integer
solve' map =
  if M.null map
  then 1
  else let ((a, b), count) = M.elemAt 0 map
           inv = if a > 0
                 then (-b, a)
                 else (b, -a)
           count' = M.findWithDefault 0 inv map
           ncount = solve' . M.delete (a, b) . M.delete inv $ map
           ccount = ((2 ^ count `mod` modT) + (2 ^ count' `mod` modT) - 1)
             `mod` modT
       in (ncount * ccount) `mod` modT

getInt = fst . fromJust . B.readInt <$> B.getLine

getInts = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine


Measured memory_bytes: 95032
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,P; cin>>N>>P;
  vector<int> A(N);
  bool all_even = true;
  for(int i=0; i<N; i++) {
    int a; cin>>a;
    A[i] = a;
    if(a % 2 == 1) {
      all_even = false;
    }
  }

  ll ans = 0;
  if(P % 2 == 0 && all_even) {
    ans = 1ll << N;
  } else if(P % 2 == 1 && all_even) {
    ans = 0;
  } else {
    ans = 1ll << (N - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int a = 0;
		int b = 0;
		int ab = 0;
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			for (int j = 1; j < s.length(); j++) {
				// 文字列の中にあるABをカウント
				if (s.charAt(j - 1) == 'A' && s.charAt(j) == 'B') {
					ans++;
				}
			}
			// 最後がA最初がBの場合 = ab
			// 最後がAの場合 = a
			// 最初がBの場合 = b
			if (s.charAt(s.length() - 1) == 'A') {
				if (s.charAt(0) == 'B') {
					ab++;
				} else {
					a++;
				}
			} else if (s.charAt(0) == 'B') {
				b++;
			}
		}
		// 最後がaのものがない場合、abが有っても組が作れない
		if (a == 0 && ab > 0) {
			ab--;
			a++;
		}

		if (b == 0 && ab > 0) {
			ab--;
			b++;
		}

		int result = ans + ab + Math.min(a, b);
		System.out.println(result);
	}
}

Measured memory_bytes: 31556
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int count = 0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3908
n,y = map(int,input().split())
for i in range(n+1):
  for j in range(n+1):
    k = n-(i+j)
    if k<0:
      continue
    else:
      if 10000*i+5000*j+1000*k == y:
         print(i,j,k,sep=" ")
         exit()
print(-1,-1,-1,sep=" ")

Measured memory_bytes: 9176
#include<stdio.h>
int main(void)
{
    int n,i,m,h;
	m=0;
	h=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    h++;
	    m=m+h;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int H,W,M;
  cin >> H >> W >> M;
  vector<pair<int,int>> cntH(H);
  vector<pair<int,int>> cntW(W);
  rep(i,H)  cntH.at(i)=m_p(0,i);
  rep(i,W)  cntW.at(i)=m_p(0,i);
  set<pair<int,int>> S;
  rep(i,M){
    int h,w;
    cin >> h >> w;
    h--;
    w--;
    cntH.at(h).fi++;
    cntW.at(w).fi++;
    S.insert(m_p(h,w));
  }
  sort(all(cntH));
  sort(all(cntW));
  reverse(all(cntH));
  reverse(all(cntW));

  int ans = cntH.at(0).fi + cntW.at(0).fi -1;
  rep(i,H){
    rep(j,W){
      int tmp=cntH.at(i).fi + cntW.at(j).fi;
      if(tmp<=ans){
        break;
      }
      if(!S.count(m_p(cntH.at(i).se,cntW.at(j).se))){
        cout << ans+1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, k; cin >> n >> k;
  vector <int> a(n);
  for (int &x : a) cin >> x;
  sort(all(a));
  long res = 0;
  for (int i = 0; i < max(0, n - k); i++) res += a[i];
  cout << res;  
  return 0;
}

Measured memory_bytes: 1024
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 answer = a * b;
       
       //表示
       if(answer % 2 != 0 ) {
           System.out.println("Odd");
       } else {
           System.out.println("Even");
       }
    }
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d = gets.chomp.split(' ').map(&:to_i)

n = b - a + 1
k = c.lcm(d) #最小公倍数

if(a % d == 0)
d_1 = (b/d - a/d + 1) #dで割れる個数
else
d_1 = (b/d - a/d) #dで割れる個数
end

if(a % c == 0)
c_1 = (b/c - a/c + 1) #cで割れる個数
else
c_1 = (b/c - a/c) #cで割れる個数
end

if(a % k == 0)
k_1 = (b/k - a/k + 1) #cとdで割れる個数
else
k_1 = (b/k - a/k) #cとdで割れる個数
end

m = c_1 + d_1 - k_1

puts n - m



Measured memory_bytes: 14252
for _ in range(int(input())):
    s=input()
    for i in range(1,27,2):
        for j in range(27):
            a=[]
            for k in range(len(s)):
                if s[k].islower():a+=chr(((ord(s[k])-97)*i+j)%26+97)
                else:a+=s[k]
            a=''.join(a)
            if 'this' in a or 'that' in a:print(a);break

Measured memory_bytes: 7564
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int A,B,C;

	scanf("%d %d %d",&A,&B,&C);

	int ans = C,left = 0,right= C,mid = (left+right)/2;

	while(left <= right){

		if(mid*A+mid/7*B >= C){

			ans = mid;
			right = mid-1;

		}else{

			left = mid+1;
		}
		mid = (left+right)/2;
	}

	printf("%d\n",ans);

	return 0;
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> tmp(1, -1);
    vector<vector<int>> num(10, tmp);
    int slen = s.size();
    rep(i, slen){
        int x = s[i] - '0';
        num[x].push_back(i);
    }
    int cnt=0, fir, sec;
    rep(i, 10){
        if(num[i].back()==-1){
            continue;
        }else{
            fir = num[i][1];
        }
        rep(j, 10){
            if(num[j].back() <= fir){
                continue;
            }else{
                int seclen = num[j].size();
                rep2(k, 1, seclen) { 
                    if(num[j][k] > fir){
                        sec = num[j][k];
                        break;
                    }
                }
            }
            rep(k, 10){
                if(num[k].back() > sec){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<ll> H(N);
  for(int i = 0;i < N;i++)cin >> H[i];

  ll ans = 0;
  ll now_mov = 0;
  int now_pos = 0;

  while(now_pos <= N - 1){
    now_mov = 0;
    for(int i = now_pos;i < N - 1;i++){
      now_pos = i;
      if(H[i] >= H[i+1])now_mov++;
      else break;
    }
    ans = max(ans,now_mov);
    now_pos++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    d = II()
    print("Christmas" + (" Eve" * (25 - d)))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
xkd = input().split()
X = int(xkd[0])
K = int(xkd[1])
D = int(xkd[2])

X = abs(X)
ans = 0
times = int(X/D)
oneMore = False
if X%D > abs(D-X%D):
    times+=1

if times > K:
    ans = X - (D*K)
else:
    if (times%2) == (K%2):
        ans = min(X%D, (D-X%D))
    else:
        ans = max(X%D, (D-X%D))

print(ans)

Measured memory_bytes: 9092
N=int(input())
S=[list(input()) for _ in range(N)]

ans=0
for k in range(N):
  ju=1
  for i in range(N):
    for j in range(N):
      if S[i][(k+j)%N]!=S[j][(k+i)%N]:
        ju=0
        
  if ju==1:
    ans+=1

print(N*ans)

Measured memory_bytes: 47024
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool compare_by_a(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    else return a.second<b.second;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,sum=0;
    cin>>n;
    vector<ll> b(n-1),a(n);
    rep(i,n-1) cin>>b[i];
    
    a[0]=b[0];
    a[n-1]=b[n-2];
    for(int i=1;i<=n-2;i++){
        a[i]=min(b[i-1],b[i]);
    }
    rep(i,n) sum += a[i];
    cout<<sum<<endl;
    return 0;
}

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

typedef long long ll;

int main() {
    int N, M;
    ll MOD = 1e9 + 7;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    vector<vector<ll>> A(N + 1, vector<ll>(M + 1, 0));
    rep(i, N) {
        rep(j, M) {
            A[i + 1][j + 1] = A[i][j + 1] + A[i + 1][j];
            if (S[i] == T[j]) {
                A[i + 1][j + 1]++;
            } else {
                A[i + 1][j + 1] -= A[i][j]; 
                A[i + 1][j + 1] += MOD; 
            }
            A[i + 1][j + 1] %= MOD;
        }
    }
    cout << A[N][M] + 1 << "\n";
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int H,W; cin>>H>>W;

int h,w; cin>>h>>w;

cout << (H-h)*(W-w) << endl;


return 0;
}

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

signed main() {
	string S;
	cin>>S;
	ll N=S.size();

	//dp[桁][ちょうど出す]
	vector<vector<ll>> dp(N+1,vector<ll>(2,0));
	for(ll i=0; i<N; i++){
		ll t=S[N-1-i]-'0';
		dp[i+1][1]=min(dp[i][1]+t, dp[i][0]+t+2);
		dp[i+1][0]=min(dp[i][1]+9-t, dp[i][0]+9-t);
	}
	dp[N][0]+=2;
	cout << min(dp[N][0],dp[N][1]) << endl;
	return 0;
}


Measured memory_bytes: 55940
import fractions

A, B, C, D = map(int, input().split())

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

L = lcm(C, D)

b = B - (B // C + B // D - B // L)
a = (A-1) - ((A-1) // C + (A-1) // D - (A-1) // L)

print(b - a)



Measured memory_bytes: 5472
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a : i128,
        b: i128,
        c: i128,
        d: i128
    };

    if a >= 0 && c >= 0 {
        let b = b as u128;
        let d = d as u128;

        println!("{}", b * d);
    } else {
        let x1 = a * c;
        let x2 = a * d;
        let x3 = b * c;
        let x4 = b * d;

        let mut result = std::cmp::max(x1, x2);
        result = std::cmp::max(result, x3);
        result = std::cmp::max(result, x4);
        println!("{}", result);
    }
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=1e5+7;

ll dp[N];

int main(){
	int n=input(),W=input();

	for(int i=1;i<=n;i++){
		ll w=input(),v=input();
		for(int j=W;j>=w;j--){
			dp[j]=max(dp[j-w]+v,dp[j]);
		}
	}
	cout<<dp[W]<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
bool com[1000005];
int main()
{
	for(int i=2;i<=1000000;i++)
	{
		if(com[i]) continue;
		for(int j=2;i*j<=1000000;j++) com[i*j] = true;
	}
	while(1)
	{
		int n,lim;
		bool dp[1000005]={};
		cin >> n >> lim; if(n==0) return 0;
		int h[35];
		for(int i=0;i<n;i++) cin >> h[i];
		dp[0] = true;
		for(int i=0;i<n;i++)
		{
			for(int j=h[i];j<=lim;j++)
			{
				if(dp[j]) continue;
				if(dp[j-h[i]]) dp[j] = true;
			}
		}
		for(int i=lim;i>=1;i--)
		{
			if(dp[i] && !com[i])
			{
				cout << i << endl; goto end;
			}
		}
		puts("NA"); end:;
	}
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int> c(n-1),s(n-1),f(n-1);
	rep(i,n-1){
		cin >> c[i] >> s[i] >> f[i];
	}
	vector<int> ans(n,0);
	rep(i,n-1){
		int now = 0;
		for(int j = i; j < n-1; j++){
			if(now <= s[j]){
				now = s[j];
				now += c[j];
			}else{
				now = s[j] + f[j]*(int)((f[j]+now-s[j]-1.0)/f[j]);
				now += c[j];
			}
		}
		ans[i] = now;
	}
	rep(i,n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int red, green, blue,k;
cin >> red >> green >> blue >> k;
int count = 0;
while(red >= green){
	green = green * 2;
	count++;
	}
while(green >= blue){
	blue = blue * 2;
	count++;
}
if(count <= k){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}

}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{

			int n = int.Parse(Console.ReadLine());

			decimal ans = 0;
			for (int i = 0; i < n; i++) {
				string[] vs = Console.ReadLine().Split();
				if (vs[1] == "JPY") {
					ans += decimal.Parse(vs[0]);
				} else {
					ans += decimal.Parse(vs[0]) * 380000;
				}
			}

			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 13140
s = gets.chomp.split("")
sum = 0
(2 ** (s.length - 1)).times do |i|
  bit = i
  array = []
  s.each_with_index do |ss, j|
    if bit[j] == 1
      ss = ss + "+"
    end
    array << ss
  end
  sum += eval(array.join)
end
puts sum

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b+c>=22 ? "bust" : "win") << endl;
    return 0;
}

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

int top;
int S[1000];

void push(int x) { S[++top]=x; }

int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a,b;
  top=0;
  char s[100];
  while (scanf("%s", s)!=EOF) {
    if (s[0]=='+') {
      a=pop();
      b=pop();
      push(a+b);
    }
    else if (s[0]=='-') {
      a=pop();
      b=pop();
      push(b-a);
    }
    else if (s[0]=='*') {
      a=pop();
      b=pop();
      push(a*b);
    }
    else push(atoi(s));
  }
  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 2752
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad (replicateM)

main :: IO ()
main = do
  n <- readLn
  ps <- replicateM n readLn
  print $ solve n ps

solve :: Int -> [Int] -> Int
solve _ ps = sum ps - maximum ps `div` 2


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
int main() {
    int n ;
    cin >> n ;
    vector<vector<int>> vec (n) ;
    rep(i, n){
        int d1, d2 ;
        cin >> d1 >> d2 ;
        vec[i].push_back(d1) ;
        vec[i].push_back(d2) ;
    }
    int cnt = 0 ;
    rep(i, n){
        if(vec[i][0] == vec[i][1]){
            cnt++ ;
        }
        else {
            cnt = 0 ;
        }
        if(cnt == 3){
            cout << "Yes" << endl ;
            return 0 ;
        }
    }
    cout << "No" << endl ;
    return 0 ;
} 

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,a[105],ans=1e9+7;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int j=-100;j<=100;j++)
	{
		int res=0;
		for(int i=0;i<n;i++)res+=(a[i]-j)*(a[i]-j);
		ans=min(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
 
 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void func() {
  LL N ;
  cin >>N;
  vector<LD> X(N);
  vector<LD> Y(N);

  for(LL i=0;i<N;++i){
    cin >> X[i];
    cin >> Y[i];
  }
  LD dist = 0;
  for(LL i=0;i<N-1;++i){
    for(LL j=i+1;j<N;++j){
      //cerr <<  sqrtl((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]))<< endl;;
      dist += sqrtl((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]));
      //cout << dist;
    }
  }
  LD M = ((LD)N*(LD)N - (LD)N)/2.0;
  LD mean_dist = dist*((LD)N-1.0)/M;
  //cout << dist;
  //cout << mean_dist;
  printf("%.10llf",mean_dist);

  
}
 

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

Measured memory_bytes: 256
n,a=map(int,input().split())
X=list(map(int,input().split()))

dp=[[[0]*(sum(X)+1) for _ in range(n+1)] for _ in range(n+1)]

dp[0][0][0]=1

for i in range(1,n+1): #x_1,x_2...x_n
  for k in range(i):   #k枚数選ぶ
    for s in range(sum(X)+1): #合計
      if dp[i-1][k][s]:
        dp[i][k+1][s+X[i-1]]+=dp[i-1][k][s] #1枚選択肢が増えた時の、そのカードを加えた結果を加算
        dp[i][k][s]+=dp[i-1][k][s]
ans=0
for i in range(1,n+1):
  for j in range(1,sum(X)+1):
    if j == i*a: #合計が平均のi倍の時に加える
      ans+=dp[n][i][j]

print(ans)

Measured memory_bytes: 54004
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

string s;
signed main(){
    int n,l;
    priority_queue< string, vector<string>,greater<string> > que;
    cin >> n >> l;
    rep(i,n){
        cin >> s;
        que.push(s);
    }   
    rep(i,n){
        cout << que.top();
        que.pop();
    }   
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char c  = getchar();
  if ( c == 'a'){
    printf("vowel");
  }
  else if ( c == 'i'){
    printf("vowel");
  }
  else if ( c == 'u'){
    printf("vowel");
  }
  else if ( c == 'e'){
    printf("vowel");
  }
  else if ( c == 'o'){
    printf("vowel");
  }
  else{
    printf("consonant");
  }
  
  return 0;
}

Measured memory_bytes: 128
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

void ins(deque <pair<int,int>> &q, int y, int t, int h, int w, int sur, int cost, char k, vector<vector<int>> &dis){
    if (y>=h || y<0 || t>=w || t<0 || k=='#')
        return;
    if (dis[y][t] > sur + cost){
        dis[y][t] = sur+cost;
        if (sur == 0)
            q.push_front(make_pair(y,t));
        else
            q.push_back(make_pair(y,t));
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,si,sj,ei,ej;
    cin >> h >> w >> si >> sj >> ei >> ej;
    si--;
    sj--;
    ei--;
    ej--;
    char arr[h][w];
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            cin >> arr[i][j];
        }
    }
    vector<vector<int>> dis(h,vector<int>(w,INT_MAX/10));
    deque<pair<int,int>> q;
    q.push_back(make_pair(si,sj));
    dis[si][sj] = 0;
    while (q.size()!=0){
        pair<int,int> temp = q.front();
        q.pop_front();
        int y = temp.first;
        int t = temp.second;
        ins(q,y+1,t,h,w,0,dis[y][t],arr[y][t],dis);
        ins(q,y,t+1,h,w,0,dis[y][t],arr[y][t],dis);
        ins(q,y-1,t,h,w,0,dis[y][t],arr[y][t],dis);
        ins(q,y,t-1,h,w,0,dis[y][t],arr[y][t],dis);
        ins(q,y-2,t-2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-2,t-1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-2,t,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-2,t+1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-2,t+2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-1,t-2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-1,t-1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-1,t+1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y-1,t+2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y,t-2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y,t+2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+1,t-2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+1,t-1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+1,t+1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+1,t+2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+2,t-2,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+2,t-1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+2,t,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+2,t+1,h,w,1,dis[y][t],arr[y][t],dis);
        ins(q,y+2,t+2,h,w,1,dis[y][t],arr[y][t],dis);
    }
    if (dis[ei][ej] == (INT_MAX/10))
        dis[ei][ej] = -1;
    cout << dis[ei][ej] << "\n";
}


Measured memory_bytes: 8660
from collections import Counter

N, C = [int(_) for _ in input().split()]

D = [[int(_) for _ in input().split()] for _ in range(C)]

cnt = [Counter() for _ in range(3)]
for i in range(N):
    tmp = [int(_) for _ in input().split()]
    for j in range(N):
        idx = (i + 1 + j + 1) % 3
        cnt[idx][tmp[j] - 1] += 1

ans = 1e12
for x in range(C):
    for y in range(C):
        if x == y: continue
        for z in range(C):
            if x == z or y == z: continue
            tmp = 0
            for i in range(C):
                tmp += cnt[0][i] * D[i][x]
                tmp += cnt[1][i] * D[i][y]
                tmp += cnt[2][i] * D[i][z]
            ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 3436
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int F;
	scanf("%d",&F);

	printf("%d\n",(F-30)/2);

	return 0;
}



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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    int n,x,t;
    cin>>n>>x>>t;

    int times = n/x;
    if( n%x != 0 )
        times++;

    ll ans = times*t;
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
  int n,i;
  int x = 0;
  int min = 100;
  int s[100] = {};
  scanf("%d", &n);

  for(i=0; i<n; i++)
  {
    scanf("%d", &s[i]);
    x = x + s[i];
    if(s[i] % 10 != 0)
    {
      if(min > s[i])
      {
        min = s[i];
      }
    }
  }
  if(x % 10 != 0)
  {
    printf("%d", x);
  }
  else if(min % 10 != 0)
  {
    printf("%d", x-min);
  }
  else
  {
    printf("0");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  string s; cin >> s;
  ll x = 0;
  ll ans = 0;
  REP(i, n){
    if(s[i] == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 764