akhauriyash/Code-Regression huggingface dataset:
/*
    飲んだ魔剤で家が建つ。
    created at: 
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];

    for (int i = 0; i < n; i++) {
        string str = s[i];
        vector<char> chs;

        for (int k = 0; k < 10; k++)
            chs.push_back(s[i][k]);

        sort(all(chs));

        for (int k = 0; k < 10; k++)
            s[i][k] = chs[k];
    }

    sort(all(s));

    int members = 1;
    vector<int> group;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i-1]) {
            group.push_back(members);
            members = 1;
        } else {
            members++;
        }
    }
    group.push_back(members);

    LL ans = 0;
    for (int i = 0; i < group.size(); i++) {
        int g = group[i];
        ans += ((LL)g*g - g)/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7424
import math

n, d = map( int, input().split() )
x = []
for i in range( n ) :
  x.append( list( map( int, input().split() ) ) )
  
ans = 0
for i in range( n ) :
  for j in range( i+1, n ) :
    len2 = 0
    for k in range( d ) :
      len2 += (( x[i][k] - x[j][k] ) ** 2)
    sqrt_len2 = math.sqrt( len2 )
    if sqrt_len2 - int( sqrt_len2 ) == 0 : ans += 1
print( ans ) 

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int x, y;
	cin >> x >> y;
	cout << x + (y / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	k := nextInt()
	A := make([]int, n+1)
	B := make([]int, m+1)
	for i := range A[1:] {
		A[i+1] = nextInt() + A[i]
	}
	for i := range B[1:] {
		B[i+1] = nextInt() + B[i]
	}
	var ans int
	for i, a := range A {
		if a > k {
			continue
		}
		tmp := i + sort.SearchInts(B, k-a+1) - 1
		if tmp > ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 8264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	vector<lint>D(N);
	rep(i, N) {
		cin >> D[i];
	}
	lint M = 0;//行ける最大値
	rep(i, N) {
		if (i <= M) {
			M = max(M, i + D[i] / 10);
		}
	}
	bool yes1 = false;
	if (M >= N - 1) {
		yes1 = true;
	}
	reverse(D);
	M = 0;
	rep(i, N) {
		if (i <= M) {
			M = max(M, i + D[i] / 10);
		}
	}
	bool yes2 = false;
	if (M >= N - 1) {
		yes2 = true;
	}
	if (yes1 && yes2) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
}


Measured memory_bytes: 5208
#include<iostream>
#include<vector>
#include<utility>
#include<set>
#include<algorithm>
using namespace std;

typedef pair<int,int> P;
int main(){
  int n,m; cin>>n>>m;
  vector<P> v;
  for(int i=0; i<m; ++i){
    int a,b; cin>>a>>b;
    v.push_back(P(b-1,a-1));
  }
  sort(v.begin(), v.end());
  set<int> remove_bridge;
  int ret=0;
  for(int i=0; i<m; i++){
    bool meet_needs =false;
    for(set<int>::iterator it=remove_bridge.begin(); it != remove_bridge.end(); ++it){
      if( *it >= v[i].second && *it+1 <= v[i].first){
        meet_needs = true; break;
      }
    }
    if( meet_needs) continue;
    else{
      remove_bridge.insert(v[i].first-1);
      ++ret;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<time.h> 
#define loop(i,c,n) for(long long i=c;i<n;i++) 
#define iter(v) for(auto x : v)  // to iterate over entire vector/sets/map
using namespace std; 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii; 
typedef set<int> si; 
int max(int a,int b){if(a>b)return a;
return b;} 
//optimised school method
bool isPrime(ll a){ 
if(a<=1)return false ;
if(a<=3)return true ;
if(a%2==0 || a%3==0)return false;
for(ll i=5;i*i<=a;i=i+6){//Instead of checking till n, we can check till √n because a larger factor of n 
//must be a multiple of smaller factor that has been already checked.
if(a%i==0 || a%(i+2)==0)return false;}return true;}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);  
    cout.tie(0);
    //  to read input from local files  
     #ifndef ONLINE_JUDGE 
    clock_t clocktime; 
    clocktime= clock(); 
     freopen("input.txt", "r",stdin);
     freopen("output.txt", "w",stdout);
    #endif
    // to read entire line with spaces 
    // string s;
    // getline(cin,s);
    
    // when amount of data is unknown
    // while(cin>>x){}    
    
 int n ;
 cin>>n;
  int c = n/1000 ;
  int ans =  (c+1)*1000 -n; 
  if(c*1000==n)ans=0; 
  cout<<ans;

    
    #ifndef ONLINE_JUDGE
    clocktime = clock()-clocktime; 
    double runtime  = (((double)clocktime)/CLOCKS_PER_SEC); 
    cout<<"\n--------\nTimeUsed -- "<<runtime<<"s"; 
    #endif
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 51

/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// たこ焼きの個数
int d[MAX_N];	// おいしさ

int main () {

	int sum = 0;

	// 個数と長さの読込み
	scanf("%d", &N);

	for(int i = 0; i < N; i++) scanf("%d", d + i);

	for(int i = 0; i < N; i++)
		for(int j = i + 1; j < N; j++)
			sum += d[i] * d[j];

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

	return 0;
}

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


def solve(N, M, edges):
    def is_connected(es):
        e = [[False]*(N+1) for _ in range(N+1)]
        for a, b in es:
            e[a][b] = True
            e[b][a] = True

        visited = [False]*(N+1)
        s = [1]
        while len(s) > 0:
            v = s.pop()
            visited[v] = True
            for i in range(1, N+1):
                if e[v][i] and not visited[i]:
                    s.append(i)

        for v in range(1, N+1):
            if not visited[v]:
                return False

        return True

    bridge = 0
    for i in range(M):
        if not is_connected(edges[:i] + edges[i+1:]):
            bridge += 1

    return bridge


def main():
    N, M = map(int, input().split())
    edges = []
    for _ in range(M):
        a, b = map(int, input().split())
        edges.append((a, b))
    print(solve(N, M, edges))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3192
n, m = map(int, input().split())

exist = [0] * n
exist[0] = 1
cnt = [1] * n
for i in range(m):
    x, y = map(int, input().split())
    if exist[x - 1] == 1:
        exist[y - 1] = 1
        if cnt[x - 1] == 1:
            exist[x - 1] = 0

    
    cnt[x - 1] -= 1
    cnt[y - 1] += 1
print(sum(exist))

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007

int fac[N], inv[N], finv[N];

void comp()
{
	fac[0] = fac[1] = 1;
	inv[0] = inv[1] = 1;
	finv[0] = finv[1] = 1;

	for (int i = 2; i < N; ++i)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

int ncr(int n, int r)
{
	if (n < r)
		return 0;

	return fac[n] * finv[r] % MOD * finv[n - r] % MOD;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n, k;
	cin >> n >> k;

	comp();

	int ans = 0;
	for (int i = 0; i <= min(n, k); ++i)
	{
		ans = (ans + ncr(n, i) * ncr(n - 1, n - i - 1) % MOD) % MOD;
	}

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

Measured memory_bytes: 4992
import bisect
A,B=map(int,input().split())
l=[int(str(i)+str(j)+str(i%10)+str(i//10)) for i in range(10,100) for j in range(10)]
l.sort()
s=bisect.bisect_left(l,A)
t=bisect.bisect_right(l,B)
print(t-s)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  int arr[110] = {};
  for (int i = 0; i < k; ++i)
  {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j)
    {
      int a;
      cin >> a;
      a--;
      arr[a]++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    if (!arr[i])
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

#define int long long int
#define pb push_back
const int MOD = 1000000007;
#define MAXX 100005


int power(int a,int n)
{

    int res = 1;
    while(n)
    {
        if(n&1)
        {
            n--;
            res = ((res%MOD)*(a%MOD))%MOD;
        }
        else
        {
            n/=2;
            a = ((a%MOD)*(a%MOD))%MOD;
        }
    }
    return (res%MOD);
}

int gcd(int a,int b)
{
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
void solve(void)
{
    int n;
    cin >> n;
    int u,v;
    int ans= 0;
    int fin=0;
    while(n--)
    {
        cin >> u >> v;
        if(u==v)
            ans++;
        else ans=0;
        fin=max(fin,ans);
    }
    fin=max(fin,ans);
    if(fin>=3)
        cout<<"Yes";
    else cout <<"No";
    return;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    while(T--)
        solve();

    return 0;
}








Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	cout << (n - 2) * 180 << endl;
	return 0;
}

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

using namespace std;

int A[200100],num[200100],n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) num[i]=1; A[1]=1;
	for(int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		if(num[x])
		{
			num[x]--; num[y]++;
			if(A[x]) A[y]=1;
		}
		if(!num[x]) A[x]=0;
	}
	int tot=0; for(int i=1;i<=n;i++)  tot+=A[i];
	printf("%d\n",tot);
	return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			long h = -1;
			long w = -1;
			List<long[]> hwlist = new List<long[]>();

			while (h != 0 && w != 0) {
				var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
				h = array[0];
				w = array[1];
				if (h == 0 && w == 0) {
					break;
				}

				hwlist.Add(new[] { h, w });
			}

			foreach (var item in hwlist) {
				for (int i = 0; i < item[0]; ++i) {
					for (int j = 0; j < item[1]; ++j) {
						if (i == 0 || j == 0 || j == item[1] - 1 || i == item[0] - 1) {
							Console.Write("#");
						} else {
							Console.Write(".");
						}
					}
					Console.WriteLine("");
				}

				Console.WriteLine("");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 16352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
	int n, k;
	double rate = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		double rate2 = 1;
		int n2 = i;
		while (n2 < k) {
			rate2 /= 2;
			n2 *= 2;
		}
		rate += rate2;
	}
	printf("%.10lf\n", rate / n);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int h, w; cin >> h >> w;
	int n; cin >> n;
	cout << (n + max(h, w) - 1 )/ max(h, w) << "\n";




	return 0;
}


Measured memory_bytes: 256
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

ll N;
vector<vector<ll>> a(16, vector<ll>(16));
vector<ll> dp(1LL << 16, -1);
vector<ll> init(1LL << 16, 0);

ll rec(ll b) {
    if (dp[b] != -1) return dp[b];
    ll res = init[b];
    for (ll i = (b - 1) & b; i > 0; i = (i - 1) & b) {
        res = max(res, rec(i) + rec(b ^ i));
    }

    return dp[b] = res;
}

int main() {
    cin >> N;
    rep(i, N) rep(j, N) cin >> a[i][j];

    rep(i, 1LL << N) {
        rep(j, N) rep(k, N) if (((i >> j) & 1) && ((i >> k) & 1)) init[i] +=
            a[j][k];
        init[i] /= 2;
    }

    cout << rec((1LL << N) - 1) << endl;
}


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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());

        double[] heads = new double[N];
        st = new StringTokenizer(br.readLine());
        for (int i=0; i<N; i++){
            heads[i] = Double.parseDouble(st.nextToken());
        }

        double[][] dp = new double[N+1][N+1];
        dp[0][0] = 1;

        for (int i=1; i<=N; i++){
            dp[i][0]=dp[i-1][0]*(1-heads[i-1]);
        }
        for (int i=1; i<=N; i++){
            for (int j=1; j<=N; j++){

                dp[i][j] = dp[i-1][j-1]*heads[i-1]+dp[i-1][j]*(1-heads[i-1]);

            }
        }
        double ans=0;
        for (int i=N/2+1; i<=N; i++){
            ans+=dp[N][i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 131028
#include<stdio.h>
int main()
{
  int x=0,y=0,d=0;
  scanf("%d%d",&x,&y);
    d=x%y;
  while(d!=0)
    {
      x=y;
      y=d;
    d=x%y;
    }
  printf("%d\n",y);
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vll cumsum;
ll query(int a, int b) {
	return cumsum[b+1] - cumsum[a];
}

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

	int N; cin >> N;
	string S; cin >> S;

	cumsum = vll (N+1);
	F0R(i, N) {
		cumsum[i+1] = cumsum[i] + (S[i] == 'W');
	}

	ll best = N;

	F0R(i, N) {
		best = min(best, query(0, i-1) + (N - i - 1 - query(i+1, N-1)));
	}
	print(best);
}

Measured memory_bytes: 2964
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn =1e5+50;

int main()
{
    ll x;
    cin>>x;
    ll ans=0;
    ans+=x/11;
    ans=ans*2;
    ll y=x%11;
    if(y>6)
    {
        ans+=2;
    }
    else if(y>0&&y<=6)
        ans++;
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int N = 500005, inf = 1000000007 ;
using namespace std ;

int h[N], n ;
struct poi {
	int x, y ; 
} a[N], b[N] ;

bool cmpx(poi a, poi b) {
	return a.x < b.x ;
}

bool cmpy(poi a, poi b) {
	return a.y < b.y ;
}

int main() {
	scanf("%d", &n) ;
	int mn = inf, mx = - inf ;
	rep(i, 1, n) {
		scanf("%d%d", &a[i].x, &a[i].y) ;
		mn = min(mn, min(a[i].x, a[i].y)) ;
		mx = max(mx, max(a[i].x, a[i].y)) ;
		b[i << 1].x = a[i].x, b[i << 1].y = i ;
		b[(i << 1) - 1].x = a[i].y, b[(i << 1) - 1].y = i ;
	}
	ll ans = (ll) inf * inf ;
	sort(b + 1, b + 2 * n + 1, cmpx) ;
	int r = 1, cnt = 0 ;
	rep(l, 1, 2 * n) {
		for ( ; r <= 2 * n && cnt < n; ++ r) {
			++ h[b[r].y] ;
			cnt += h[b[r].y] == 1 ;
		}
		if (cnt == n) ans = min(ans, (ll) (mx - mn) * (b[r - 1].x - b[l].x)) ;
		-- h[b[l].y] ;
		cnt -= h[b[l].y] == 0 ;
	}
	rep(i, 1, n) {
		if (a[i].x > a[i].y) swap(a[i].x, a[i].y) ;
	}
	sort(a + 1, a + n + 1, cmpx) ;
	mn = a[n].x - a[1].x ;
	sort(a + 1, a + n + 1, cmpy) ;
	mx = a[n].y - a[1].y ;
	ans = min(ans, (ll) mn * mx) ;
	printf("%lld\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 8832
n=int(input())
sl=list([input() for i in range(n)])
def sort_str(s):
    cl = list(s)
    cl.sort()
    return ''.join(cl)
m={}
sum=0
for i in range(n):
    s = sort_str(sl[i])
    if not s in m:
        m[s]=0
    else:
        m[s]+=1
        sum+=m[s]
print(sum)

Measured memory_bytes: 25100
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    ps(ty-sy,'U');
    ps(tx-sx,'R');
    ps(ty-sy,'D');
    ps(tx-sx+1,'L');
    ps(ty-sy+1,'U');
    ps(tx-sx+1,'R');
    ans+='D';
    ans+='R';
    ps(ty-sy+1,'D');
    ps(tx-sx+1,'L');
    ans+='U';
    cout<<ans<<endl;
    return 0;
}    

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

string sub(string a, int x, int y) {
  string ans;
  for (int i = x; i <= y; i++) ans += a[i];
  return ans;
}

bool ispal(string s) {
  string a = s;
  string b = s;
  reverse(b.begin(), b.end());
  return (a == b);
}

int main() {
  int x;
  cin >> x;
  double here = x / 3.0;
  cout << fixed << setprecision(12) << (long double) here * here * here << endl;
  return 0;
}


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

#define NIL NULL

typedef struct node{
  int key;
  struct node *right,*left,*p;
} Node;

Node *root;

void insert(int);
void prep(Node *);
void inp(Node *);
int find(int);


int main(){
  char c[20];
  int n,i,j,x;
  

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",c);
    

    if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
   
    else if(c[0] == 'p'){
      inp(root);
      printf("\n");
      prep(root);
      printf("\n");
    }

    else if(c[0] == 'f'){
      scanf("%d",&x);
      if( find(x))printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
  
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;

    else x = x->right;
  }

    z->p = y;

    if(y == NIL)root = z;

    else{
      
    if(z->key < y->key) y->left = z;

    else y->right = z;
  }

}

void prep(Node *p){
  if(p == NIL) return;
  printf(" %d",p->key);
  prep(p->left);
  prep(p->right);
}

void inp(Node *p){
  if(p == NIL) return;
  inp(p->left);
  printf(" %d",p->key);
  inp(p->right);
}

 int find(int k){
   Node *x = root;
   Node *y = NIL;

   while(x != NIL){
     y = x;
     if(y->key == k)return 1;

     if(k < x->key) x=x->left;

     else x = x->right;
   }

   return 0;
 }


Measured memory_bytes: 20476
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i);
typedef long long ll;

int main(){
    int n,x,t;
    std::cin >> n >> x >> t;
    int tmp=n/x;
    int h=n%x;
    if(h!=0){
        tmp++;
    }
    int ans=t*tmp;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
	static String str;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int data = sc.nextInt();
		
		for(int i=0; i<data; i++){
			str = sc.next();
			System.out.println(DFS(0, str.length()-1));
		}
	}

	static int DFS(int left, int right){
		left++;
		if(str.charAt(left)>='0'&&str.charAt(left)<='9'){
			return Get_num(left);
		}

		int[] phase = new int[3333];
		int count = 0;
		int balance = 0;

		for(int i=left; i<right; i++){
			if(str.charAt(i)=='['){
				balance++;
			}else if(str.charAt(i)==']'){
				balance--;
				if(balance==0){
					phase[count++] = DFS(left, i);
					left = i + 1;
				}
			}
		}

		Arrays.sort(phase, 0, count);
		int sum = 0;

		for(int i=0; i<count/2+1; i++){
			sum += phase[i];
		}

		return sum;
	}

	static int Get_num(int n){
		int temp = 0;
		while(str.charAt(n)>='0'&&str.charAt(n)<='9'){
			temp = 10*temp + (str.charAt(n++) - '0');
		}
		return temp/2+1;
	}
}

Measured memory_bytes: 65640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 1;
    if(a == 1 && b == 2) ans = 3;
    if(a == 1 && b == 3) ans = 2;
    if(a == 2 && b == 1) ans = 3;
    if(a == 2 && b == 3) ans = 1;
    if(a == 3 && b == 1) ans = 2;
    if(a == 3 && b == 2) ans = 1;

    cout << ans << endl;

    return 0;
}

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

struct BC {
	int B;
	long long int C;
};

long long int asc(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

long long int desc(const void *a, const void *b) {
	struct BC *X = (struct BC *)a;
	struct BC *Y = (struct BC *)b;
	return Y->C - X->C;
}

int main() {
	int N, M, i, j;
	long long int A[100000], sum = 0;
	struct BC bc[100000];

	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		sum = sum + A[i];
	}
	for (i = 0; i < M; i++) {
		scanf("%d %lld", &bc[i].B, &bc[i].C);
	}

	qsort(A, N, sizeof(long long int), asc);
	qsort(bc, M, sizeof(struct BC), desc);

	i = 0;
	for (j = 0; j < M && bc[j].C > A[i] && i < N; j++) {
		while (bc[j].B > 0 && bc[j].C > A[i] && i < N) {
			sum = sum + bc[j].C - A[i];
			bc[j].B--;
			i++;
		}
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 4084
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;

int main(){
	int N, Q;
	cin >> N >> Q;
	vector<ll> a(N);
	for(int i = 0; i < N; i++) cin >> a[i];
	for(int i = 0; i < Q; i++){
		ll x;
		cin >> x;
		ll res = 0;
		ll sum = 0;
		int k = 0;
		for(int j = 0; j < N; j++){
			for(; k < N; k++){
				if(sum + a[k] > x) break;
				sum += a[k];
			}
			if(sum <= x) res += k - j;
			sum -= a[j];
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(t.nextToken());
		int W = Integer.parseInt(t.nextToken());
		int[] w = new int[n+1], v = new int[n+1];
		int s = 0;
		for(int i = 1 ; i <= n ; i++)
		{
		      t = new StringTokenizer(br.readLine());
		      w[i] = Integer.parseInt(t.nextToken());
		      v[i] = Integer.parseInt(t.nextToken());
		      s += v[i];
		}
		long[][] dp = new long[n+1][s+1];
		Arrays.fill(dp[0], (long)1e12);
		dp[0][0] = 0;
		for(int i = 1 ; i < n+1 ; i++)
		{
		      int val = v[i];
		      if(dp[0][val]!=0) continue;
		      int pos = 0;
		      for(int j = 1 ; j < n+1 ; j++)
		      {
		            if(v[j] == val) pos = Math.min(pos,j); 
		      }
		      dp[pos][val] = 1;
		      dp[0][val] = w[pos];
		}
		for(int i = 1 ; i < s+1 ; i++)
		{
		      long min = (long)1e12;
		      int pos = 0;
		      
		      for(int j = 1 ; j < n+1 ; j++)
		      {
		            if(i-v[j] < 0) continue;
		            if(dp[0][i-v[j]] + w[j] < min && dp[j][i-v[j]]==0L)
		            {
		                  pos = j;
		                  min = dp[0][i-v[j]] + w[j];
		            }
		      }
		      if(min!=(long)1e12)
		      {
		            dp[0][i] = Math.min(min,dp[0][i]);
		            for(int j = 1  ; j < n+1 ; j++) dp[j][i] = dp[j][i-v[pos]];
		            dp[pos][i] = 1;
		      }
		}
		for(int i = s ; i > 0 ; i--)
		{
		      if(dp[0][i] <= W)
		      {
		            System.out.println(i);
		            break;
		      }
		}
	}
}

Measured memory_bytes: 126736
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll a, b, k, count = 0, ans = 0;
  cin >> a >> b >> k;
  ll l;
  l = min(a, b);
  for (int i = l; i > 0; i--) {
    if (a % i == 0 && b % i == 0) count++;
    if (count == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

struct Matrix{
	int h, w;
	vector<llint> mat;
	Matrix(){
		h = w = 0;
	}
	Matrix(int h, int w){
		this->h = h, this->w = w;
		mat.resize(h*w);
	}
	llint& at(int i, int j){
		return mat[w*(i-1)+(j-1)];
	}
	static Matrix ident(int size){
		Matrix ret(size, size);
		for(int i = 1; i <= size; i++) ret.at(i, i) = 1;
		return ret;
	}
	Matrix operator*(Matrix& ope){
		Matrix ret(h, ope.w);
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= ope.w; j++){
				for(int k = 1; k <= w; k++){
					ret.at(i, j) += at(i, k) * ope.at(k, j) % mod;
					ret.at(i, j) %= mod;
				}
			}
		}
		return ret;
	}
	Matrix pow(llint n){
		if(n == 0) return ident(h);
		if(n % 2){
			return pow(n-1) * (*this);
		}
		else{
			Matrix tmp = pow(n/2);
			return tmp * tmp;
		}
	}
	void print(){
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cout << at(i, j) << " ";
			}
			cout << endl;
		}
	}
};

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

llint h, w, k;
char c[1005][1005];
Matrix mat(2, 2);

int main(void)
{
	cin >> h >> w >> k;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> c[i][j];
		}
	}
	
	llint ver = 0, hol = 0, num = 0;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(c[i][j] == '#') num++;
		}
	}
	for(int i = 1; i <= w; i++){
		if(c[1][i] == '#' && c[h][i] == '#') ver++;
	}
	for(int i = 1; i <= h; i++){
		if(c[i][1] == '#' && c[i][w] == '#') hol++;
	}
	if(ver && hol){
		cout << 1 << endl;
		return 0;
	}
	if(ver == 0 && hol == 0){
		cout << modpow(num, k-1) << endl;
		return 0;
	}
	
	if(ver){
		swap(ver, hol);
		swap(h, w);
		for(int i = 1; i <= max(h, w); i++){
			for(int j = 1; j <= max(h, w); j++){
				if(i >= j) continue;
				swap(c[i][j], c[j][i]);
			}
		}
	}
	llint join = 0;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j < w; j++){
			if(c[i][j] == '#' && c[i][j+1] == '#') join++;
		}
	}
	
	mat.at(1, 1) = num, mat.at(1, 2) = mod-join;
	mat.at(2, 1) = 0, mat.at(2, 2) = hol;
	
	Matrix pmat = mat.pow(k-1);
	
	llint ans = pmat.at(1, 1) + pmat.at(1, 2);
	ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  int a,c;
  string b;
  cin >> a >> b;
  c = b.size();//ここまで問題なし
  if (a >= c){
    cout << b <<endl;//ここまで問題なし
  }
  else {
    for(int i = 0; i < a; i++){
    cout << b.at(i);
    }
  cout << "..." << endl;
  }
}

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

using namespace std;

const int INF=1e8;
const int MAX=1000000;

struct segtree {
    int N;
	vector<int> dat;
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
		dat.resize(2*MAX);
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = INF;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return INF;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

struct segtree1{
    int N;
	vector<int> dat;
    segtree1() {}
    segtree1(int n) {
        N = 1;
        while(N < n) N *= 2;
		dat.resize(2*MAX);
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = -INF;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return -INF;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};
int min_ret(int lhs,int rhs){return min(lhs,rhs);}
int max_ret(int lhs,int rhs){return max(lhs,rhs);}
int main(){
	int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	segtree seg_min(n+2);
	segtree1 seg_max(n+2);
	vector<pair<long long int,int>> aindex(n);
	for(int i=0;i<n;i++){
		aindex[i]=make_pair(a[i],i);
	}
	sort(aindex.begin(),aindex.end());
	seg_min.update(0,0);
	seg_min.update(n+1,n+1);
	seg_max.update(0,0);
	seg_max.update(n+1,n+1);
	
	long long int res=0;
	for(int i=0;i<n;i++){

		int index=aindex[i].second;
		long long int lef=seg_max.query(0,index+1);
		long long int rig=seg_min.query(index+2,n+2);
		lef++,rig--;
		res+=a[index]*(index+1-lef+1)*(rig-(index+1)+1);
		seg_min.update(index+1,index+1);
		seg_max.update(index+1,index+1);
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 20608
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int width = Integer.parseInt(line[0]);
		int height = Integer.parseInt(line[1]);
		int area = width * height;
		int length = (width * 2) + (height * 2);

		System.out.println(area + " " + length);

	}
}

Measured memory_bytes: 24072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	rep(i,n){
		rep(j,m){
			if(s.at(i) == t.at(j)) dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}
	string ans = "";
	int i = n, j = m;
	while(i > 0 && j > 0){
		if(dp[i - 1][j] == dp[i][j]) i--;
		else if(dp[i][j - 1] == dp[i][j]) j--;
		else{
			ans += s[i - 1];
			i--;j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 35584
def main():
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    max_com = 0
    for i in range(n - m + 1):
        com = 0
        for j in range(m):
            if t[j] == s[i + j]:
                com += 1
        max_com = max(max_com, com)
    print(m - max_com)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#include <math.h>

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

int main() {
  int x, n;
  cin >> x >> n;
  if (n == 0) {
    cout << x;
    return 0;
  }

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

  int ans1 = x;
  int ans2 = x;
  bool aru = true;
  for (int i = 0; i < 100; i++) {
    aru = true;
    for (int j = 0; j < n; j++) {
      if (x + i == p[j]) {
        aru = false;
        break;
      }
    }
    if (aru) {
      ans1 = x + i;  //上

      break;
    }
  }

  for (int i = 0; i < 100; i++) {
    aru = true;
    for (int j = 0; j < n; j++) {
      if (x - i == p[j]) {
        aru = false;
        break;  //つぎのＩへ
      }
    }
    if (aru) {
      ans2 = x - i;  //ＯＫ

      break;
    }
  }

  if (abs(ans1 - x) >= abs(ans2 - x))
    cout << ans2;
  else
    cout << ans1;
end:
  return 0;
}


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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,l;
vector<pii> koma[52];
int dp[52][52];

int main(){
  scanf("%d%d%d",&n,&m,&l);
  REP(i,m){
    int d,a,k,t;
    scanf("%d%d%d%d",&d,&a,&k,&t);
    int id = d*n+a-1;
    koma[id].push_back(pii(k,t));
  }
  REP(i,5*n){
    REP(x,l+1){
      REP(j,koma[i].size()){
        int k = koma[i][j].first;
        int t = koma[i][j].second;
        CHMAX(dp[i+k][x+1],dp[i][x]+t);
      }
      CHMAX(dp[i+1][x],dp[i][x]);
    }
  }
  int ans = 0;
  REP(x,l+1)CHMAX(ans,dp[5*n][x]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1204
n = input()
f = int(n[0])
s = int(n[1])
t = int(n[2])
if f < s:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
elif f > s:
    ans = f*100 + f*10 + f
elif f == s and f >= t:
    ans = f*100 + f*10 + f
else:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
print(ans)
    

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
bool used[100001];
int cmp[100001];
vector<int> g[100001], gr[100001];
vector<int> vs;
int ts[100001];
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
 
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	ts[k]=v;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
 
int scc(){
	fill(used, used+n, 0);
	vs.clear();
	for(int i=0; i<n; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int x, y; cin>>x>>y;
		x--; y--;
		g[x].push_back(y); gr[y].push_back(x);
	}
	scc();
	int dp[100001]={};
	int ans=0;
	for(int i=0; i<n; i++){
		for(auto y:gr[ts[i]]){
			dp[ts[i]]=max(dp[y]+1, dp[ts[i]]);
		}
		ans=max(ans, dp[ts[i]]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14972
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    long double A,B,H,M,ra,rb,l,si,ans;
 
    cin >> A >> B >> H >> M;
 
    ra = H*30 + M*0.5;
    rb = M*6;

    si = min(abs(ra-rb),360-abs(ra-rb));

    si = si*M_PI/180.0;

    l = A*A + B*B -2*A*B*cos(si);

    ans = sqrt(l);

    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 4152
i=0
while i<4:
    t,n=map(int,input().split())
    if t==1:
        ans=n*6000
    elif t==2:
        ans=n*4000
    elif t==3:
        ans=n*3000
    elif t==4:
        ans=n*2000
    
    print(ans)
    i+=1


Measured memory_bytes: 5592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    long double l;
    cin >> l;
    long double a = l/3;
    printf("%.8Lf\n",a * a * a );
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        return x < p.x;
    }
    ll x;
    int v;
};

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

    int n;
    cin >> n;

    ll c;
    cin >> c;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].v;
    }
    sort(p.begin(), p.end());

    ll r = 0;
    vector<ll> a(n);
    for (int l = 0; l < 2; l++) {
        ll t = 0, s = 0;
        for (int i = 0; i < n; i++) {
            s += p[i].v;
            t = max(t, s - p[i].x);
            a[i] = t;
        }

        s = 0;
        for (int i = n - 1; i > 0; i--) {
            s += p[i].v;
            t = max(t, s - (c - p[i].x) * 2 + a[i - 1]);
        }

        r = max(r, t);

        if (l == 0) {
            for (int i = 0; i < n; i++) {
                p[i].x = c - p[i].x;
            }
            reverse(p.begin(), p.end());
        }
    }

    cout << r << endl;

    return 0;
}

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

N,M,V,P = map(int, input().split())
a = list(map(int, input().split()))
A = sorted(a)[::-1]
           
right = P-1
left = N

while left - right !=1:
    
    i = (left+right)//2
    b = (V-((P-1)+(N-i)))
    target = A[i]+M

        
    if b<0:
        if A[P-1]<=target:
            right = i
        else:
            left = i
    else:
        if target<A[P-1]:
            left = i
        else:
            Q_sum=sum(A[P-1:i])
            len_Q =i-(P-1)
            if target*len_Q-Q_sum>=b*M:
                right = i
            else:
                left =i


print(right+1)

Measured memory_bytes: 65688
table = {1: 0}

def solve():
    global c, table
    queue = []
    for i in range(10):
        if i == 1:
            continue
        queue.append((c[i][1], i))
    while queue:
        queue.sort(reverse=True)
        a = queue.pop()
        if a[1] not in table:
            table[a[1]] = a[0]
            for i in range(10):
                if i == a[1]:
                    continue
                queue.append((a[0]+c[i][a[1]], i))

H, W = map(int, input().split())
c = [list(map(int, input().split()))for i in range(10)]
A = [list(map(int, input().split()))for i in range(H)]

solve()

ans = 0
for i in range(H):
    for j in range(W):
        if 0 <= A[i][j] <= 9:
            ans += table[A[i][j]]

print(ans)


Measured memory_bytes: 3444
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
string S;
cin>>S;
S[5]=' ';
S[13]=' ';
cout<<S<<endl;



return 0;
}

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

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	vector<int> A;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		A.push_back(t);
	}
	sort(A.begin(), A.end(), greater<int>());
	bool found = false;
	long long m1 = 0;
	int c;
	for(c = 0; c < N - 1; ++c) {
		if(A[c] == A[c + 1]) {
			m1 = A[c];
			found = true;
			break;
		}
	}
	if(!found) {
		cout << "0\n";
		return 0;
	}
	found = false;
	long long m2 = 0;
	for(c += 2; c < N - 1; ++c) {
		if(A[c] == A[c + 1]) {
			m2 = A[c];
			found = true;
			break;
		}
	}
	if(!found) {
		cout << "0\n";
		return 0;
	}
	cout << (m1 * m2) << '\n';
	return 0;
}



Measured memory_bytes: 892
#include<stdio.h>
int main ()
{

    int x,y,z,k;
    scanf("%d",&x);
     scanf("%d",&y);
     z=x+y;
     k=z/2;

     if(z%2!=0)
     {

         printf("IMPOSSIBLE");
     }
     else{
            printf("%d",k);
     }
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a, &b,&c);
    d=a+b+c;
    if (d>=22)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }

    return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  if (S.size() > T.size()) {
    puts("No");
  } else {
    for (int i = 0; i < S.size(); ++i) {
      if (S[i] != T[i]) {
        puts("No");
        return 0;
      }
    }
    puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	cin >> n;
	ll sum = 0;
	int freq[1000000];
	ll x;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		freq[x] += 1;
		sum += x;
	}
	//cout << sum << endl;
	ll q, b, c;
	cin >> q;
	while (q--)
	{
		cin >> b >> c;
		freq[c] += freq[b];
		sum -= freq[b] * b;
		sum += freq[b] * c;
		freq[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3972