akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0 ; i < n ; i++)
        cin >> p[i];

    vector<int> s(n + 1,0);
    int dmax = 0;
    for(int i = 0 ; i < n ; i++)
        s[i + 1] = s[i] + p[i];

    // for(int i = 0 ; i < n + 1 ; i++)
    //     cout << s[i] << " ";

    for(int i = 0 ; i < n - k + 1 ; i++){
        dmax = max(s[i + k] - s[i],dmax);
    }

    cout << std::fixed << std::setprecision(15) << (double)(dmax + k) / 2 << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        vector<pii> ujimatsu(n,pii(0,0));
        vc anko(n);
        rep(i,n){
            cin>>anko[i];
            rep(j,n-1){
                int tiya; cin>>tiya;
                if(tiya==0)ujimatsu[i].first+=100000000;
                else if(tiya==1)ujimatsu[i].second+=1;
                else if(tiya==2)ujimatsu[i].first+=1;
            }
        }
        vector<bool>flag(1000,true);
        rep(i,n){
            int maxi=-INF;
            int ans=0;
            rep(j,n){
                if(!flag[j])continue;
                if(ujimatsu[j].first>maxi){
                    maxi=ujimatsu[j].first;
                    ans=j;
                }else if(ujimatsu[j].first==maxi){
                    if(ujimatsu[ans].second>ujimatsu[j].second){
                        ans=j;
                    }
                }
            }
            flag[ans]=false;
            cout<<anko[ans]<<endl;
        }
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b) cout << 0 << endl;
	else if (n == 1) {
		if (a == b) cout << 1 << endl;
		else cout << 0 << endl;
	} else {
		ll l = a * (n - 1) + b, r = a + b * (n - 1);
		cout << r - l + 1 << endl;
	}
}

Measured memory_bytes: 3640
n,m = map(int,input().split())
s = list(input())

now = n
res = []

while now != 0:
    judge = False
    for i in range(max(0,now-m),now):
        if s[i] == '0':
            res.append(now-i)
            now = i
            judge = True
            break
    if not judge:
        print(-1)
        exit()
for i in range(len(res)-1,-1,-1):
    print(res[i],end = ' ')

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, x;
	cin>>n>>x;
	vector<ll> a(n);
	for(auto &y : a){
		cin>>y;
	}
	ll ans = 0;
	for(int i = 0; i + 1 < n; i++){
		if(a[i] + a[i + 1] <= x)continue;
		ll rem = a[i] + a[i + 1] - x;
		ans += rem;
		if(rem <= a[i + 1])a[i + 1] -= rem;
		else a[i + 1] = 0;
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

long long a,b;

int main () {
	cin >> a >> b;
	if(a == 1 && b == 2) {
		cout << 3;
	}
	if(a == 1 && b == 3) {
		cout << 2;
	}
	if(a == 2 && b == 1) {
		cout << 3;
	}
	if(a == 2 && b == 3) {
		cout << 1;
	}
	if(a == 3 && b == 1) {
		cout << 2;
	}
	if(a == 3 && b == 2) {
		cout << 1;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var hwab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = hwab[0];
        var w = hwab[1];
        var a = hwab[2];
        var b = hwab[3];

        var line = "";
        var output = new StringBuilder();
        for (int i = 0; i < h; ++i)
        {
            if (i == 0)
            {
                line = new string('1', a) + new string('0', w - a);
            }
            else if (i == b)
            {
                line = new string('0', a) + new string('1', w - a);
            }
            output.AppendLine(line);
        }

        Console.WriteLine(output);
    }
}


Measured memory_bytes: 19936
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
using namespace std;
typedef long long ll ;
const long long N = 1e5,OO=0x3f3f3f3f;
ll n,weight,w[105],v[105];
ll dp[105][N+5];

int main()
{
    cin>>n>>weight;
    for(int i=0; i<n; i++)
        cin>>w[i]>>v[i];

    for(int i=0; i<105; i++)
        for(int j=0; j<=N; j++)
            dp[i][j]=1e18;

    for(int i=0; i<n; i++)
        dp[i][v[i]]=w[i];

    for(int i=1; i<n; i++)
    {
        for(int j=0; j<=N; j++)
        {
            ll &ret=dp[i][j];
            ret=min(ret,dp[i-1][j]);
            if(v[i]<=j)
                ret=min(ret,w[i]+dp[i-1][j-v[i]]);
            }
    }
    for(int i=N; i>=0; i--)
        if(dp[n-1][i]<=weight)
        {
            cout<<i<<endl;
            break;
        }
}


Measured memory_bytes: 85668
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Maybe
import Control.Applicative

main = do
 [n,_] <- map read . words <$> getLine
 cxys <- map ((\[c,x,y]->(c,(x,y))) . map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
 let seg = fromList n (replicate n (2^31-1))
 mapM_ print (rmq n seg cxys)

rmq n seg = reverse . fst . foldl' process ([],seg)
 where
  process (lg,seg) (c,(x,y))
   | c==0 = (lg, update n seg x y)
   | c==1 = (query n seg x y : lg, seg)


data SegTree a = Leaf a | Node a (SegTree a) (SegTree a) deriving (Eq, Show)

val :: SegTree a -> a
val (Leaf v) = v
val (Node v _ _) = v

fromList :: (Ord a) => Int -> [a] -> SegTree a
fromList 1 [x] = Leaf x
fromList n xs  = Node (min (val left) (val right)) left right
 where
  n' = div n 2
  (xs1,xs2) = splitAt n' xs
  left = fromList n' xs1
  right = fromList (n-n') xs2

update :: (Ord a) => Int -> SegTree a -> Int -> a -> SegTree a
update 1 (Leaf v) 0 x = Leaf x
update n (Node v l r) i x
 | i < n' = Node (min (val left) (val r)) left r
 | otherwise = Node (min (val l) (val right)) l right
 where
  n' = div n 2
  left = update n' l i x
  right = update (n-n') r (i-n') x

query :: (Ord a) => Int -> SegTree a -> Int -> Int -> a
query 1 (Leaf v) 0 0 = v
query n (Node v l r) i j
 | (i,j) == (0,n-1) = v
 | j <  n' = query n' l i j
 | i >= n' = query (n-n') r (i-n') (j-n')
 | otherwise = min (query n' l i (n'-1)) (query (n-n') r 0 (j-n'))
 where n' = div n 2

Measured memory_bytes: 70180
//
//  main.cpp
//  CPP
//
//  Created by chemistrae on 02/12/2018.
//  Copyright © 2018 chemistrae. All rights reserved.
//

#include <iostream>

using namespace std;

typedef unsigned long long ll;

ll n,p;

ll pow(ll n, ll r) {
    if (r == 0) return 1;
    ll ret;
    if (r % 2) {
        ret = n*pow(n, r-1);
    }
    else {
        ll tmp = pow(n, r/2);
        ret = tmp*tmp;
    }
    if (ret > p)
        return 0;
    else
        return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    cin >> n >> p;
    
    //cout << pow(2, 3) << '\n';
    
    if (n == 1) {
        cout << p << '\n';
        return 0;
    }
    
    ll r = 1, ret = 1;
    while (true) {
        ll e = pow(r, n);
        if (e == 0)
            break;
        if ((p % e) == 0)
            ret = max(ret, r);
        r++;
    }
    
    cout << ret << '\n';
    
    return 0;
}


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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool complete(int satisfied[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (satisfied[i] != 1)
			return false;
	}
	return true;
}
void swap(int *x, int *y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

bool f(int x, int y)
{
	return x > y;
}
int Lucky(int n)
{
	int c = 0;
	while (n != 0)
	{
		int r = n % 10;
		if (r == 4 || r == 7)
			c++;
		n /= 10;
	}
	return c;
}
bool isPrime(int x)
{
	int i;
	for (i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}
int32_t main()
{
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	if (isPrime(n)) {
		cout << n;
		return 0;
	}


	n += 1;
	while (true)
	{
		if (isPrime(n))
		{
			cout << n;
			break;

		}
		n++;
	}



}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,P,G=0,X=0;cin>>N;
  vector<bool>C(8,false);
  for(int i=0;i<N;i++){
    cin>>P;
    if(P<400)C.at(0)=true;
    else if(P<800)C.at(1)=true;
    else if(P<1200)C.at(2)=true;
    else if(P<1600)C.at(3)=true;
    else if(P<2000)C.at(4)=true;
    else if(P<2400)C.at(5)=true;
    else if(P<2800)C.at(6)=true;
    else if(P<3200)C.at(7)=true;
    else G++;
  }
  for(int i=0;i<8;i++)if(C.at(i))X++;
  cout<<max(1,X)<<" "<<X+G<<endl;
}

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

int main() {
    long long N, S;
    cin >> N >> S;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<long long> dp(S+1);
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        vector<long long> p(S+1);
        swap(dp, p);
        for (int j = 0; j < S+1; ++j) {
            dp[j] += p[j] * 2;
            dp[j] %= 998244353;
            if (j + A[i] <= S) {
                dp[j + A[i]] += p[j];
                dp[j + A[i]] %= 998244353;
            }
        }
    }

    cout << dp[S] << endl;
    return 0;
}

Measured memory_bytes: 3236
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
import math
N = int(input())
arr = list(map(int,input().split()))
add = sum(arr)
avg = int(round(add/N)) 
ans = 0
for i in range(N):
	ans += (avg-arr[i])*(avg-arr[i])
print(int(ans))

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    map<string, int> S;
    ll ans = 0;
    rep(i, 0, n)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (S.count(s) == 0)
        {
            S[s] = 0;
        }
        else
        {
            S[s]++;
            ans += S[s];
        }
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;


void pre(){

}

void solve(){
  char ch; cin>>ch;

  if(ch-'a'>=0 && ch-'a'<=25){
    cout<<"a"<<"\n";
  }
  else cout<<"A"<<"\n";
}

int main(){
  // #ifndef ONLINE_JUDGE
  //   freopen("in.txt","r",stdin);
  // #endif
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


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

#define MAX  110000
#define int long long

int N;
int A[MAX], used[MAX];

signed main(){
  int ans = 0, sum = 0;
  
  cin>>N;

  for(int i = 0; i <  N; i++){
    cin>>A[i];
  }

  for(int i = 0; i <= N; i++){
    if(A[i] == 0){
      ans += sum/2;
      sum = 0;
    }
    sum += A[i];
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

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

struct Data {
	int pos, cool, cost;
	Data(int p, int c, int d) : pos(p), cool(c), cost(d) {}
	bool operator< (const Data& d)const {
		return cost > d.cost;
	}
};

struct Edge {
	int dst, cost;
	Edge(int d, int c) : dst(d), cost(c) {}
};

int main()
{
	int n, M, l, k, A, H;
	while(scanf("%d%d%d%d%d%d", &n, &M, &l, &k, &A, &H), n){
		vector<vector<Edge> > G(n);
		bool hascool[100] = {false};
		rep(i, l){
			int x;
			scanf("%d", &x);
			hascool[x] = true;
		}
		hascool[A] = hascool[H] = true;
		
		rep(i, k){
			int x, y, t;
			scanf("%d%d%d", &x, &y, &t);
			G[x].push_back(Edge(y, t));
			G[y].push_back(Edge(x, t));
		}
		
		int ans = -1;
		bool visited[100][101] = {{false}};
		priority_queue<Data> Q;
		
		Q.push(Data(A, M, 0));
		while(!Q.empty()){
			Data d = Q.top();
			Q.pop();
			if(visited[d.pos][d.cool])
				continue;
			
			visited[d.pos][d.cool] = true;
			if(d.pos == H){
				ans = d.cost;
				break;
			}
			
			rep(i, G[d.pos].size()){
				Edge e = G[d.pos][i];
				if(d.cool - e.cost >= 0){
					Q.push(Data(e.dst, d.cool-e.cost, d.cost+e.cost));
				}
			}
			
			if(hascool[d.pos] && d.cool < M)
				Q.push(Data(d.pos, d.cool+1, d.cost+1));
		}
		
		if(ans == -1)
			puts("Help!");
		else
			printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

map<string, int> total;

int main() {

	int a, b;
	scanf("%d", &a);



	while(a) {
		string s;
		cin >> s;
		total[s]++;
		a--;
	}

	scanf("%d", &b);

	while(b) {
		string s;
		cin >> s;
		total[s]--;
		b--;
	}

	int max = 0;

	for(auto& v : total) {
		if(v.second > max) {
			max = v.second;
		}
	}

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

	return 0;
}

Measured memory_bytes: 384
using System;

namespace teisyutusensei
{
    class Program
    {
        static void Main(string[] args)
        {
            
            ////?????????????????????
            string dmmy = Console.ReadLine();

            string[] input = dmmy.Split(' ');

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int count = 0;
            int amari;

            for (int i = a; i <= b; i++)
            {
                amari = c % i;

                if (amari == 0)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.ReadLine();

        }
    }

}

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int 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;
}

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

  int ans = 0;
  repp(diff, 1, N - 1) {
    int temp = 0;
    int temp_max = 0;
    rep(i, N - diff) {
      if (S[i] == S[i + diff]) {
        temp++;
      } else {
        chmax(temp_max, temp);
        temp = 0;
      }
      chmax(temp_max, temp);
    }
    chmax(ans, min(temp_max, diff));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
dice = list(map(int, input().split()))

#dice.sort(reverse=True)
MAXX = 1001
ave = [0.0]*MAXX

ans = 0.0
sumz = [0.0]*(N+1)
right = 0
#累積和
for i in range(N):
    x = dice[i]
    if ave[x] <= 0.000001:
        ave[x] = (x + 1) / 2.0
    sumz[i+1] = sumz[i]+ ave[x]

#find max
for i in range(K, N+1):
    if ans < sumz[i] - sumz[i-K]:
        ans = sumz[i] - sumz[i-K]

print(ans)
#
# for left in range(0, N):
#     if right <= left: right = left
#     while right < N and right - left <= K:
#         x = dice[right-1]
#         if ave[x] <= 0.000001:
#             ave[x] = (x+1)/2.0
#         sumz[right] = sumz[right-1] + ave[x]
#         right += 1
#
#     if ans < sumz[right-1]:
#         ans = sumz[right-1]
#
# print(ans)
#
#
#
#
#
# print(ans)


Measured memory_bytes: 98932
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int X; cin>>X;
	int mx = 1,p,b;
	for(b = 2; b<=X;b++){
		p = b*b;
		while(p<=X){
			mx = max(mx,p);
			p*=b;
		}
	}
	
	//if(p<=X) mx = max(mx,p);
	printf("%d\n",mx);
	return 0;
}

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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    if(a/k == b/k){
        if(a%k ==0 || b%k ==0)
            cout<<"OK\n";
        else
            cout<<"NG\n";
    }
    else cout<<"OK\n";


    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
double dist(double a,double b,double c){
	return sqrt(a*a+b*b+c*c);
}
int main(){
	int n,m;
	cin>>n>>m;
	vvd boll(n,vd(4));
	vi sc(n);
	rep(i,n){
		rep(j,4)cin>>boll[i][j];
		cin>>sc[i];
	}
	while(m--){
		ll out=0;
		double a,b,c,d,e,f;
		cin>>a>>b>>c>>d>>e>>f;
		rep(i,n){
			vd q{boll[i][0],boll[i][1],boll[i][2]};
			double A=d-a,B=e-b,C=f-c;
			double ssita=sqrt(pow(B*(q[2]-c)-C*(q[1]-b),2)+pow(C*(q[0]-a)-A*(q[2]-c),2)+pow(A*(q[1]-b)-B*(q[0]-a),2))/
				dist(A,B,C)/dist(q[0]-a,q[1]-b,q[2]-c);
			double dis=dist(q[0]-a,q[1]-b,q[2]-c)*ssita;
			if(dis<boll[i][3]+EPS){
				double dot1=A*(q[0]-a)+B*(q[1]-b)+C*(q[2]-c);
				double dot2=A*(q[0]-d)+B*(q[1]-e)+C*(q[2]-f);
//				cout<<i<<" "<<dot1<<" "<<dot2<<endl;
				if(dot1>=0&&dot2<=0)out+=sc[i];
			}
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
    using namespace std;
     
    int n;
    int cnt[110];
    int tot[2100];
     
    int f(int l, int r)
    {
    	int res = 0;
    	for (int i = l; i <= r; ++i) res += tot[i];
    	return res;
    }
     
    int main()
    {
    	while (scanf("%d", &n) != EOF)
    	{
    		memset(cnt, 0, sizeof cnt); 
    		memset(tot, 0, sizeof tot);
    		for (int i = 2; i <= n; ++i)
    		{
    			int tmp = i;
    			for(int j = 2; ; ++j) 
    			{
    				while (tmp % j == 0) 
    				{
    					++cnt[j];
    					tmp /= j; 
    				}
    				if (tmp == 1) break; 
    			}
    		}
    		for (int i = 2; i <= 100; ++i) ++tot[cnt[i] + 1];  
    		int res = f(75, 2000);    
    		res += f(25, 2000) * f(3, 24);
    		res += f(25, 2000) * (f(25, 2000) - 1);
    	    res += f(15, 2000) * f(5, 14);
    		res += f(15, 2000) * (f(15, 2000) - 1);
    		res += (f(5, 2000) * (f(5, 2000) - 1) / 2) * f(3, 4);	
    		res += ((f(5, 2000) * (f(5, 2000) - 1) / 2) * (f(5, 2000) - 2));
    		printf("%d\n", res);
    	}	
    	return 0;
    }


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define count ct
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
   int n;
   cin>>n;
   vin a(n);
   rep(i,n) cin>>a[i];
   sot(a);
   vin dp(n+1,0);
   queue<int> s;
   rep(i,n){
       dp[i+1]=gcd(dp[i],a[i]);
       
       
       rep(j,s.size()+1){
           int x=s.fn();
           //cout<<x<<" "<<i<<endl;
           s.pop();
           x=gcd(x,a[i]);
           if(x!=1) s.push(x);
       }
       if(dp[i]!=dp[i+1]&&dp[i]!=1) s.push(dp[i]);
       //cout<<dp[i]<<endl;
       //cout<<dp[i+1]<<endl;
   }
   int ans=1;
   //cout<<endl;
   rep(i,s.size()){
       int y=s.fn();
       //cout<<y<<endl;
       s.pop();
       ans=max(ans,y);
   }
   cout<<ans<<endl;
  
}

Measured memory_bytes: 3904
a,b,c = map(int,input().split())
lst = []
ans = 0
cnt = 0
while True:
	s = (60*cnt+c) % (a+b) 
	if s in lst:
		ans = -1
		break
	lst.append(s)
	if 0 <= s <= a:
		ans = 60 * cnt + c
		break
	cnt += 1
	
print(ans)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define int long long
using pint=pair<int,int>;

int N;
int A[18];
map<pair<pint,pint>,int> dp;
int dfs(int l,int r,int kl,int kr){
  if(l>r)return 0;
  pair<pint,pint> p={{l,r},{kl,kr}};
  if(dp.find(p)!=dp.end())return dp[p];
  int ret=LLONG_MAX;
  for(int i=l;i<=r;i++){
    int ki=kl+kr;
    ret=min(ret,ki*A[i]+dfs(l,i-1,kl,ki)+dfs(i+1,r,ki,kr));
  }
  return dp[p]=ret;
}
signed main(){
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  cout<<dfs(1,N-2,1,1)+A[0]+A[N-1]<<endl;
}

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

using namespace std;

int main(int argc, char const *argv[]) {

        char s[201], p[101], tmp[101];
        scanf("%s %s", s, p );
        strcpy(tmp, s);
        strcat(s, tmp);
        if(strstr(s, p) == NULL) cout << "No\n";
        else cout << "Yes\n";
        return 0;
}



Measured memory_bytes: 3152
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	k := sc.ReadInt()
	c := sc.ReadInt()
	s := sc.ReadString()

	leftGreedy := make([]int, k)
	{
		pos := 0
		for i := 0; i < n; i++ {
			if s[i] == 'x' {
				continue
			}

			if pos >= k {
				return
			}
			leftGreedy[pos] = i
			pos++
			i += c
		}
	}

	rightGreedy := make([]int, k)
	{
		pos := k - 1
		for i := n - 1; i >= 0; i-- {
			if s[i] == 'x' {
				continue
			}

			rightGreedy[pos] = i
			pos--
			i -= c
		}
	}

	for i := 0; i < k; i++ {
		left := leftGreedy[i]
		right := rightGreedy[i]
		if left == right {
			fmt.Println(left + 1)
		}
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 6656
N = int(input())
L_org = [int(x) for x in input().split()]
L = sorted(L_org)

cnt = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if L[i] != L[j]:
            for k in range(j + 1, N):
                if L[j] != L[k]:
                    if (L[i] + L[j] > L[k]):
                        cnt += 1
                    else:
                        break

print(cnt)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    char c;
    //string S;
    cin >> c;
    if('a'<=c && c<='z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
}


Measured memory_bytes: 3628
from sys import stdin, stdout

if __name__ == "__main__":
	N, X = stdin.readline().split(" ")
	N = int(N)
	X = int(X)

	L = []
	for e in stdin.readline().split(" "):
		L.append(int(e))

	start = 0
	i = 1
	cnt = 1
	while i <= N and start <= X:
		start = start + L[i-1] 
		if start <= X:
			cnt += 1
		i += 1
	
	print (cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.size();
    vec<string> A;
    for(int i=0;i<N;i++){
        for(int j=0;j<K;j++) if(i+j<N){
            A.push_back(S.substr(i,j+1));
//            cerr << S.substr(i,j+1) << "\n";
        }
    }
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    cout << A[K-1] << "\n";
}

Measured memory_bytes: 1660
S = int(input())
mod = 10** 9 + 7
import math
def ncr(N,R):
    return math.factorial(N)//(math.factorial(R)*math.factorial(N-R))%mod

ans = 0

for p in range(10000):
    if S-2*p-1 >= p-1>=0:
        ans +=ncr(S-2*p-1,p-1)
        ans%=mod
print(ans%mod)


Measured memory_bytes: 9180
#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,a[200010];
int n,t;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	t=n/2+1;
	for (int i=1;i<=n;i++) ans+=abs(a[i]-a[t]);
	printf("%lld",ans);
}
 

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
typedef struct hoge{
    long hB;
    long hC;
}Hoge;

int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int asc_h(const void *a, const void *b) {
   Hoge *A = ( Hoge *)a;
   Hoge *B = ( Hoge *)b;
  return (B->hC)-(A->hC);
}
int main(){
    long n;
    long *N;
    long M;
    long B[100000];
    long C[100000];
    Hoge H[100000];
    long index = 0;
    long i,j;
    long long ret = 0;
    scanf("%ld %ld",&n,&M);
    N = (long*)malloc(n * sizeof(long));
    for (i=0;i<n;i++){
        scanf("%ld",&(N[i]));
    }
    for (i=0;i<M;i++){
        scanf("%ld %ld",&(H[i].hB),&(H[i].hC));
    }
    //昇順ソート
    qsort(N, n, sizeof(long), asc);
    qsort(H, M, sizeof(Hoge), asc_h);
    for(i=0;i<M;i++){
        for(j=0;j < H[i].hB;j++){
          if(i+j+index > N)break;
            if(N[i+j + index] < H[i].hC){
                N[i+j + index] = H[i].hC;
            }else{
                break;
            }
        }
        index += j -1;
      if(0){
        printf("-------\n");
        printf("index:%ld\n",index);
          for(j=0;j<n;j++){
              printf("%lld\n",N[j]);
          }
      }
    }
    for(i=0;i<n;i++){
        ret += N[i];
    }
    printf("%lld\n",ret);
	free(N);
    return 0;
}

Measured memory_bytes: 4084
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let p:usize = s.iter().filter(|x| x==&&'p').count();
    let n = s.len();
    println!("{}", n/2 - p);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,k;
  cin>>a>>b>>c>>k;
  int need=0;
  while(a>=b)
  {
    b*=2;
    need++;
  }
  while(b>=c)
  {
	  c*=2;
	  need++;
  }
  if(need<=k)
  {
	  cout<<"Yes\n";
  }
  else
  {
	  cout<<"No\n";
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k>=a)
	{
		sum+=a;
		k-=a;
	}
	else
	{
		sum+=k;
		k=0;
	}
	if(k>=b)
	{
		k-=b;
	}
	else
	{
		k=0;
	}
	sum-=k;
	cout<<sum;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
#include <stdio.h>

int main() {
    
    int i = 0;
    int j = 0;
   
    for(i = 1; i < 10; ++i){
        for(j = 1; j < 10; ++j) {
            int value = i * j;
            printf("%dx%d=%d\n", i, j, value);
        }
    }
    
   
    return 0;
}

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

int main() {

	int N, x, i, s;
	vector<int> X,Y;

	cin >> N;

	for (i = 0; i < N;++i) {
		cin >> x;
		X.emplace_back(x);
	}
	Y = X;
	sort(Y.begin(), Y.end());
	s = Y.size();
	auto Iter = Y.begin() + s / 2;
	
	for (auto it = X.begin(); it != X.end(); ++it) {
		if (*it < *Iter) {
			cout << *Iter << endl;
		}
		else cout << *(Iter-1) << endl;
	}

	return 0;
}

Measured memory_bytes: 3828
x,y = map(int,input().split())
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]

if x in list1 and y in list1:
    print("Yes")
elif x in list2 and y in list2:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 1
for i in range(n):
    x = h[i]
    tt = t - x * 0.006
    dtt = abs(tt - a)
    if i == 0:
        dt = dtt
    elif dtt < dt:
        dt = dtt
        ans = i + 1
print(ans)

Measured memory_bytes: 3060
a=list(map(int,input().split()))
for i in range(a[2]):
    if a[i%2]%2==1:
        a[i%2]-=1
    res=a[i%2]//2
    a[i%2]-=res
    a[(i+1)%2]+=res
print(a[0],a[1])

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
	val (n, m) = readLine()!!.split(" ").map({ it -> it.toInt() })
	val counts = IntArray(n) { 0 }
	for (i in 1..m) {
		val (a, b) = readLine()!!.split(" ").map({ it -> it.toInt() - 1 })
		counts[a] += 1
		counts[b] += 1
	}
	for (i in 0..(n - 1)) {
		println(counts[i])
	}
}


Measured memory_bytes: 38116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int r;
    cin >> r;
    cout << r * r << endl;

    return 0;
}

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

int main() {
  int N;
  set<int> se;

  int a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    se.insert(a);
  }

  cout << se.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<int> A(M),B(M);
    vec<int> C(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        for(int j=0;j<B[i];j++){
            int c;
            cin >> c;
            c--;
            C[i] |= (1<<c);
        }
    }
    int inf = 1e9;
    vvec<int> dp(M+1,vec<int>(1<<N,inf));
    dp[0][0] = 0;
    for(int i=0;i<M;i++) for(int S=0;S<(1<<N);S++){
        dp[i+1][S] = min(dp[i+1][S],dp[i][S]);
        dp[i+1][S|C[i]] = min(dp[i+1][S|C[i]],dp[i][S]+A[i]);
    }
    cout << (dp[M][(1<<N)-1]!=inf? dp[M][(1<<N)-1]:-1);
}

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

 using namespace std;

 int main() {
   string N;

   cin >> N;

   int SN = 0;

   for (int i = 0; i < N.length(); i++) {
     SN += (int)(N.at(i) - '0');
   }

   if (stoi(N) % SN == 0) cout << "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> v(n);
	rep(i,n)cin>>v[i].fs,v[i].sc=i;
	sort(rall(v));
	vvl dp(n+1,vl(n+1,-LINF));
	dp[0][0]=0;
	rep(i,n)rep(j,n){
		if(i+j+1>n)continue;
		chmax(dp[i+1][j],dp[i][j]+abs(v[i+j].sc-i)*v[i+j].fs);
		chmax(dp[i][j+1],dp[i][j]+abs(n-1-v[i+j].sc-j)*v[i+j].fs);
	}
	ll ans=-1;
	rep(i,n+1)chmax(ans,dp[i][n-i]);
	puta(ans);
}


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N;

    cin >> N;

    int count = 0;
    rep(i,N){
        int rank = 0;
        int temp = i + 1;
        while(temp > 0) {
            temp /= 10;
            rank++;
        }
        if(rank % 2) count++;
    }
    cout << count << endl;
}

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

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int64_t c1 = K;
    rep(i, N)
    {
        int start, goal;
        int64_t ctmp;
        if (i == 0)
        {
            start = i;
            goal = N - 1;
            ctmp = A[goal] - A[start];
        }
        else
        {
            start = i - 1;
            goal = i;
            ctmp = K - (A[goal] - A[start]);
        }
        //      cout << ctmp << endl;
        c1 = min(ctmp, c1);
    }
    cout << c1 << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = 0;
		int t = 0;
		for (int i = 1; y < x; i++) {
			y += i;
			t++;
		}
		System.out.println(t);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,w,wi,vi;
  cin >> n >> w;
  vector<ll> mval(w+1);
  for(ll i = 0; i < n; ++i){
    cin >> wi >> vi;
    for(ll j = w-wi; j >= 0; --j){
      mval[j+wi] = max(mval[j+wi],mval[j]+vi);
    }
  }
  cout << *max_element(begin(mval),end(mval));
  return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize "03"
#pragma GCC target("sse4")

#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,n) for(ll i=a;a<n?i<n:i>=n;a<n?i+=1:i-=1)
#define loop(i,a, n) for(ll i = a; i <= n; i++)
#define loopb(i,a, n) for(ll i = a; i >= n; i--)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define setmem(x, k) memset(x, k, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
// const ll N = 1e6+5;	
// ll a[N], b[N], dp[N], in[N], out[N], level[N], vis[N];
// vl g[N];
ll n, m, k;

ll dp[100005];

ll fun(vector<ll>& a, ll pos){
	if(pos == n - 1){
		return 0;
	}
	if(pos >= n){
		return INT_MAX;
	}
	if (dp[pos] != -1) return dp[pos];
	ll mn = INT_MAX;
	loop(i, 1, k){
		mn = min(mn, abs(a[pos] - a[pos+i]) + fun(a, pos + i));
	}
	return dp[pos] = mn;
}

void solve() {
	// ll k, x, y, p, q, r;
	cin>>n>>k;
	vector<ll> a(n);
	f(i,n) cin >> a[i];
	setmem(dp, -1);
	cout << fun(a, 0);
}

int32_t main() {
	IOS
	ll T;
	// cin >> T;
	// while(T--)
		solve();
	cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define For(i,u) for(int i=hed[u],v=e[i].to;i;i=e[i].nex,v=e[i].to)
using namespace std;
const int N=3010;
int n,u,v,ed,f[N],hed[N],a[N];
struct edge{
    int to,nex;
    edge(int _=0,int __=0):to(_),nex(__){}
}e[N<<1];
inline void add(int u,int v){e[++ed]=edge(v,hed[u]);hed[u]=ed;}
void dfs(int u,int fa){f[u]=0;For(i,u) if((v^fa)&&(a[u]>a[v])) dfs(v,u),(!f[v])&&(f[u]=1);}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i);
    rep(i,1,n-1) scanf("%d%d",&u,&v),add(u,v),add(v,u);
    rep(i,1,n) dfs(i,0),(f[i])&&(printf("%d ",i));
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, H, M;
    cin >> A >> B >> H >> M;

    double th0 = 6.0 * M;
    double th1 = 30.0 * H + 0.5 * M;
   // cout << th0 << " " << th1 << endl;

    double theta = abs(th0 - th1);
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(theta / 180.0 * M_PI));

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

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_E
//区間加算　区間和クエリ
//演算の定義
auto query = [](ll x, ll y) { return x+y; };
//単位元
const ll unit = 0;
struct LazySegTree
{
private:
  ll n;
  vector<ll> node,lazy;

public:
  LazySegTree(vector<ll> v)
  {
    node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    lazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    n = 1LL << 64 - __builtin_clzll(v.size());
    for (ll i = 0; i < v.size(); i++)
      node[i + n - 1] = v[i]; //最下段から構築
    for (ll i = n - 2; i >= 0; i--)
      node[i] = query(node[2 * i + 1], node[2 * i + 2]);
  }
  
  // k 番目のノードについて遅延評価を行う
  void eval(int k, int l, int r){ 
    // 遅延配列が空でない場合、自ノード及び子ノードへの
    // 値の伝播が起こる
    if (lazy[k] != 0){
      node[k] += lazy[k];
      // 最下段かどうかのチェックをしよう
      // 子ノードは親ノードの 1/2 の範囲であるため、
      // 伝播させるときは半分にする
      if (r - l > 1){
        lazy[2 * k + 1] += lazy[k] / 2;
        lazy[2 * k + 2] += lazy[k] / 2;
      }
      // 伝播が終わったので、自ノードの遅延配列を空にする
      lazy[k] = 0;
    }
  }

  void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
    if (r < 0)
      r = n;
    // k 番目のノードに対して遅延評価を行う
    eval(k, l, r);
    // 範囲外なら何もしない
    if (b <= l || r <= a)
      return;
    // 完全に被覆しているならば、遅延配列に値を入れた後に評価
    if (a <= l && r <= b){
      lazy[k] += (r - l) * x;
      eval(k, l, r);
    }
    // そうでないならば、子ノードの値を再帰的に計算して、
    // 計算済みの値をもらってくる
    else{
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }

  // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
  ll get(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
  {
    // 最初に呼び出されたときの対象区間は [0, n)
    if (r < 0)
      r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if (r <= a || b <= l)
      return unit;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    // 関数が呼び出されたら評価！
    eval(k, l, r);
    if (a <= l && r <= b)
      return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return query(vl, vr);
  }
};

int main()
{
ll n , q ;
cin >> n >> q ;

vector<ll> t(n,0);
LazySegTree s(t);
vector<ll> ans;
rep(i,q){
  ll a  ;
  cin >> a  ;
  if(!a){
    ll b , c , d ;
    cin >> b >> c >> d ;
    s.update(b, c+1, d);
  }
  else {
    ll b ;
    cin >> b ;
    ans.push_back(s.get(b, b+1));
  }
}

rep(i,ans.size())cout<<ans[i]<<"\n";

return 0;
}



Measured memory_bytes: 9392
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B = LI()
print(A*B)


Measured memory_bytes: 67348