akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int n,a,b,c,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if( (a>b && a>c && a*a==b*b+c*c) || (b>a && b>c && b*b==a*a+c*c) || (c>a && c>b && c*c==a*a+b*b) )
			printf("YES\n");
		else
			printf("NO\n");
	}
	//for(i=0;i<=10000000000;i++);
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll dp[200010], nxt[200010], lst[200010], a[200010],n,MOD=1e9+7;

ll solve(int pos){
  if(pos==n) return 1;
  ll &r=dp[pos];
  if(r>=0) return r;
  r=solve(pos+1);
  if(nxt[pos]>=0&&nxt[pos]!=pos+1) r=(r+solve(nxt[pos]))%MOD;
  return r;
}

int main(){FIN;
  cin >> n;
  memset(lst,-1,sizeof(lst));
  memset(nxt,-1,sizeof(nxt));
  memset(dp,-1,sizeof(dp));
  fore(i,0,n) cin >> a[i];
  for(int i =n-1;i>=0;i--){
    if(lst[a[i]]>=0) nxt[i]=lst[a[i]];
    lst[a[i]] = i;
  }
  cout << solve(0) << endl;
}

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


int main()
{
    int n,k; cin>>n>>k;
    int arr[n];
    int cost[n];

    for(int i=0;i<n;i++) { cin>>arr[i]; cost[i]=INT_MAX; }

    cost[0]=0;

    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++) {
            if(i+j<n) cost[i+j]= min( cost[i]+abs(arr[i+j]-arr[i]), cost[i+j]);
        }
    }
    cout<<cost[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll x;
    cin >> x;
    vector<ll>v;
    for(ll i = 0;i <= 4000;++i)
        v.push_back(i * i * i * i * i);
    for(int i = 0;i < v.size();++i)
    {
        for(int j = 0;j < v.size();++j)
        {
            if(v[i] - v[j] == x)
                return cout << i << ' ' << j, 0;
            if(v[i] + v[j] == x)
                return cout << i << ' ' << -j, 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

ll a[3000];
ll memo[3000][3000][2];

inline ll search(int l, int r, int turn) {
  if (memo[l][r][(turn + 1) / 2] == -1LL << 60) {
    if (l == r) {
      if (turn > 0) {
        memo[l][r][1] = a[l];
      } else {
        memo[l][r][0] = -a[l];
      }
    } else {
      if (turn > 0) {
        memo[l][r][1] = max(search(l + 1, r, turn * -1) + a[l] * turn,
                            search(l, r - 1, turn * -1) + a[r] * turn);
      } else {
        memo[l][r][0] = min(search(l + 1, r, turn * -1) + a[l] * turn,
                            search(l, r - 1, turn * -1) + a[r] * turn);
      }
    }
  }
  return memo[l][r][(turn + 1) / 2];
}

int main() {
  int N;
  cin >> N;
  FOR(i, N) cin >> a[i];
  FOR(i, N) FOR(j, N) FOR(c, 2) memo[i][j][c] = -1LL << 60;
  print(search(0, N - 1, 1));
  return 0;
}

Measured memory_bytes: 141056
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public class Program
{
    public static void Main()
    {
        string[] inputSplit = ReadLine().Split(' ');
        int numH = int.Parse(inputSplit[0]);
        int numW = int.Parse(inputSplit[1]);
      
        List<string> SList = new List<string>(numH + 2);
        SList.Add(new String('0', numW + 2));
        for (int i = 0; i < numH; i++) SList.Add("0" + ReadLine()+"0");
        SList.Add(new String('0', numW + 2));

        List<string> resultList = new List<string>();
        for (int i = 1; i < numH+1; i++)
        {
            string resultWString = string.Empty;
            for (int j = 1; j < numW+1; j++)
            {
                if (SList[i][j] == '.')
                {
                    int numBomb = BombCount(SList, i, j);
                    resultWString += numBomb.ToString("D");
                }
                else
                {
                    resultWString += SList[i][j];
                }
            }
            resultList.Add(resultWString);
        }

        foreach(string res in resultList)
        {
            WriteLine(res);
        }
    }
    public static int BombCount(List<string> SList, int h, int w)
    {
        int countBomb = 0;
        for (int i = h - 1; i <= h + 1; i++)
        {
            for (int j = w - 1; j <= w + 1; j++)
            {
                if (SList[i][j] == '#')
                {
                    countBomb++;
                }
            }
        }
        return countBomb;
    }
}

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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	
	int odd_ct = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			odd_ct++;
		}
	}
	
	float ans = (float)odd_ct / (float)n;
	cout << ans << endl;
}

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

int main() {
  
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  char key= S.at(K-1);
  for(int i=0; i<N; i++){
    if( S.at(i)!=key ){ S.at(i)='*'; }
  }  

  cout << S << endl;

}

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

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

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






int main() {

	int n, z, w;
	cin >> n >> z >> w;
	VI a(n);
	REP(i, n)cin >> a[i];

	if (n > 1)cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
	else cout << abs(a[0] - w) << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n, m, x;
  cin >> n >> m >> x;
  int a[m];
  for(int i = 0; i < m; i++){
    cin >> a[i];
  }

  int b[n + 1];
  fill(b, b + n + 1, 0);
  for(int i = 0; i < m; i++){
    b[a[i]] = 1;
  }

  int s = x;
  int cost0 = 0;
  while(s <= n){
    cost0 += b[s];
    s++;
  }
  s = x;
  int cost1 = 0;
  while(s >= 0){
    cost1 += b[s];
    --s;
  }

  int ans = min(cost0, cost1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define us unsigned short int
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);
using namespace std;


int main(){
    string s,t;
    cin>>s>>t;
    ll cnt=0;
    for (ll i = 0; i < s.size(); i++)
    {
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  200005
using namespace std;
ll v[MAXN],lazy[4*MAXN],seg[2][4*MAXN];
ll n;

void build(ll node,ll l,ll r){
    if(l==r){
        if(l%2){
            seg[1][node]=l;
            seg[0][node]=MAXN-1;
        }
        else{
            seg[0][node]=l;
            seg[1][node]=MAXN-1;
        }
        return;
    }
    build(2*node,l,(l+r)/2);
    build(2*node+1,(l+r)/2+1,r);
    if(v[seg[0][2*node]]<v[seg[0][2*node+1]]){
        seg[0][node]=seg[0][2*node];
    }
    else{
        seg[0][node]=seg[0][2*node+1];
    }
    if(v[seg[1][2*node]]<v[seg[1][2*node+1]]){
        seg[1][node]=seg[1][2*node];
    }
    else{
        seg[1][node]=seg[1][2*node+1];
    }
}

ll query(ll node,ll l,ll r,ll p,ll q){
    if(l>q||r<p)
        return MAXN-1;
    ll ans,ans1,ans2;
    if(l>=p&&r<=q){
        ans=seg[p%2][node];
        if(lazy[node])
            ans=1-ans;
        return ans;
    }
    if(lazy[node]){
        lazy[node]=0;
        lazy[2*node]=1-lazy[2*node];
        lazy[2*node+1]=1-lazy[2*node+1];
    }
    ans1=query(2*node,l,(l+r)/2,p,q);
    ans2=query(2*node+1,(l+r)/2+1,r,p,q);
    if(v[ans1]<v[ans2])
        return ans1;
    else return ans2;
}
class cmp{
    public:
        bool operator()(pair<ll,ll>a,pair<ll,ll>b){
            if(v[query(1,0,n-1,a.ff,a.ss)]<v[query(1,0,n-1,b.ff,b.ss)])
                return 0;
            else return 1;
        }
};

priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,cmp>pq;
vector<ll>ans;

void solve(ll a,ll b){
    pq.push(mp(a,b));
    ll w,e,r,z;
    while(!pq.empty()){
        w=pq.top().ff;
        e=pq.top().ss;
        pq.pop();
        r=query(1,0,n-1,w,e);
        z=query(1,0,n-1,r+1,e);
        ans.pb(v[r]);
        ans.pb(v[z]);
        if(r-1-w>=1)
        pq.push(mp(w,r-1));
        if(z-1-r-1>=1)
        pq.push(mp(r+1,z-1));
        if(e-z-1>=1)
        pq.push(mp(z+1,e));
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    v[MAXN-1]=LLONG_MAX;
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    build(1,0,n-1);
    solve(0,n-1);
    for(auto it=ans.begin();it!=ans.end();it++){
        cout<<*it<<" ";
    }


    return 0;
}



Measured memory_bytes: 17728
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


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

  vl v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0){
      v.pb(i-1);
      if(i*i == n) continue;
      v.pb(n/i-1);
    }
  }
  for(ll i : v) {
    if(i == 0) continue;
    if(n%i == n/i) ans += i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(v):
    global MOD
    childs = 0
    var = 1
    for e in edge[v]:
        if path[e] == 0:
            path[e] = 1
            nc, nvar = dfs(e)
            childs += nc
            V[v][e] = (nc, nvar)
            var *= nvar
            var %= MOD
            var *= invs[nc]
            var %= MOD
    var *= modFacts[childs]
    var %= MOD
    dp[v] = (childs, var)
    return childs + 1, var


def dfs2(v, pn, pVar):
    global MOD
    oNodes, oVar = dp[v]
    tNodes = pn + oNodes
    tVar = (oVar * pVar) % MOD
    tVar *= invs[oNodes]
    tVar %= MOD
    tVar *= modFacts[tNodes]
    tVar %= MOD
    tVar *= invs[pn]
    tVar %= MOD

    dp[v] = (tNodes, tVar)

    for e in V[v].keys():
        eNodes, eVar = V[v][e]
        nVar = (tVar * invs[tNodes]) % MOD
        nVar *= modFacts[eNodes]
        nVar %= MOD
        nVar *= modFacts[tNodes - eNodes]
        nVar %= MOD
        nVar *= pow(eVar, MOD - 2, MOD)
        nVar %= MOD
        dfs2(e, tNodes - eNodes + 1, nVar)


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
path = [0] * N
dp = [None] * N
path[0] = 1
dfs(0)
dfs2(0, 0, 1)


for i in range(N):
    print(dp[i][1])


Measured memory_bytes: 176476
#include<bits/stdc++.h>
using namespace std;
vector<int> primeFactors(long long n)  
{  vector<int> counter;
    // Print the number of 2s that divide n
    bool done = false;  
    int iter = 0;
    while (n % 2 == 0)  
    {   if(!done){
    	counter.push_back(0);
    	done = true;
    	}	

        counter[iter] = counter[iter] + 1;  
        n = n/2;  
    }  
  	// iter+=1;
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {   done = false;
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {   
        	if(!done){
        		iter+=1;
        		done = true;
        		counter.push_back(1);
        	}
            n = n/i; 
            if(n%i == 0)
            	counter[iter] = counter[iter] + 1; 
 
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    // for(int i = 0; i< counter.size(); ++i){
    // 	cout << counter[i] << '\n';
    // }
    if (n > 2)  
        counter.push_back(1);
    return counter; 
}  
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	long long  n;
	cin >> n;
	vector<int> counter = primeFactors(n);
	int l = counter.size();
	int finalCount = 0;
	for(int i = 0; i< l; ++i){
		for(int j = 1; j <= counter[i]; ++j ){
			// cout << counter[i] << " " << j << '\n';
			counter[i] = counter[i] - j;
			finalCount+=1;
		}
	}
	cout << finalCount;
	
}

Measured memory_bytes: 3676
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct BIT { //1-indexed
private:
    int n,n2;
    vector<ll> bit;

public:
    BIT(ll N){
        n = N;
        bit.assign(n+1, 0);
        n2 = 1;
        while(n2 * 2 <= n) n2 *= 2;
    }

    ll sum(ll x){ //[1, x]
        ll res = 0;
        for(ll i = x; i > 0; i -= i & -i) res += bit[i];
        return res;
    }

    ll sum(ll lv, ll rv){ // [lv, rv)
        return sum(rv-1) - sum(lv-1);
    }

    void add(ll x, ll v){
        if(x == 0) return;
        for(ll i = x; i <= n; i += i & -i) bit[i] += v;
    }

    ll lower_bound(ll w) {
        if (w <= 0) return 0;
        ll x = 0;
        for (ll k = n2; k > 0; k /= 2) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};
vector<BIT> bit;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    rep(i,0,26){
        BIT b(N+1);
        bit.push_back(b);
    }
    rep(i,0,N){
        ll v = S[i] - 'a';
        bit[v].add(i+1, 1);
    }

    while(Q--){
        ll q;
        cin >> q;
        if(q == 1){
            ll i;
            char c;
            cin >> i >> c;
            i--;
            ll v = S[i] - 'a';
            bit[v].add(i+1, -1);
            bit[c - 'a'].add(i+1, 1);
            S[i] = c;
        }else{
            ll l,r;
            cin >> l >> r;
            l--; r--;
            ll res = 0;
            rep(j,0,26){
                ll sum = bit[j].sum(l+1, r+2);
                if(sum > 0) res++;
            }
            print(res);

        }
    }

    

}

Measured memory_bytes: 106328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program
{
	class Program
	{
		static void Main(string[] args)
		{
			var nd = Console.ReadLine().Split(' ').ToList().ConvertAll(x => int.Parse(x)).ToArray();
			var n = nd[0];
			var d = nd[1];
			List<int[]> points = new List<int[]>();

			for(int i = 0;i < n; i++)
			{
				var point = Console.ReadLine().Split(' ').ToList().ConvertAll(x => int.Parse(x)).ToArray();

				points.Add(point);
			}

			int num = 0;

			for(int i = 0; i < n - 1; i++)
			{
				for(int j = i + 1; j < n; j++)
				{
					double distance_2 = 0;

					for(int k = 0;k < d; k++)
					{
						distance_2 += Math.Pow(points[i][k] - points[j][k], 2);
					}

					var distance = Math.Sqrt(distance_2);

					var intDistance = (int)distance;

					if(Math.Abs(distance - intDistance) < 1e-10)
					{
						num++;
					}
				}
			}

			Console.WriteLine(num);
		}
	}
}


Measured memory_bytes: 13396
h,w = (int(i) for i in input().split())
s = ["."+input()+"." for i in range(h)]
s,flag = ["."*(w+2)]+s+["."*(w+2)],True
for i in range(1,h+1):
	for j in range(1,w+1):
		if s[i][j]=="#":
			if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
				flag = False
if flag: print("Yes")
else: print("No")

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

using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool flag1 = 0;
    bool flag2 = 0;
    while(1){
    	c = c - b;
    	if(c<=0){
    	
    		flag2 =1;
    			break;
		}
		a =a-d;
    	if(a<=0){
    		flag1 = 1;
    			break;
		} 
	}
	if(flag1) cout<<"No"<<endl;
	if(flag2) cout<<"Yes"<<endl;
	return 0;
} 

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

a, b, c, x, y = map(int, input().split())
c *= 2
if a+b < c:
    ans = a*x + b*y
else:
    m = min(x, y)
    ans = c*m
    if x != m:
        if a > c:
            ans += c*(x-m)
        else:
            ans += a*(x-m)
    else:
        if b > c:
            ans += c*(y-m)
        else:
            ans += b*(y-m)
print(ans)

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

int main(){
    long long n;
    cin >> n;
    long long a[n], b[n], c[n-1];

    for(long long i = 0; i < n; i++) cin >> a[i], a[i]--;
    for(long long i = 0; i < n; i++) cin >> b[i];
    for(long long i = 0; i < n-1; i++) cin >> c[i];

    long long ans = 0;

    for(long long i = 0; i < n; i++){
        ans += b[a[i]];
        if(a[i] + 1 == a[i+1]) ans += c[a[i]];
    }

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

Measured memory_bytes: 3520
#include<bits/stdc++.h>
#include <sstream>
using namespace std;
string s;
long long sum=0;

void count(int lastplus,int now,long long a[],int qnt){
	if(now==s.length()){
		long long ans=0;
		for(int i=1;i<=qnt;i++){
			
			ans+=a[i];
		}
		sum+=ans;
		
		return;
	}
	
		if(now<s.length()-1) count(lastplus,now+1,a,qnt);
		stringstream ss;
		ss<<s.substr(lastplus+1,now-lastplus);
		ss>>a[++qnt];
		count(now,now+1,a,qnt);
	
}
int main(){
	long long a[20],b[20]={0ll};
	cin>>s;
    count(-1,0,b,0);
	cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char a, b, c, d;
    int ai, bi, ci, di;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    ai = a - 48;
    bi = b - 48;
    ci = c - 48;
    di = d - 48;

    if(ai + bi + ci + di== 7)
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(ai + bi + ci - di== 7)
    {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if(ai + bi - ci + di== 7)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if(ai + bi - ci - di== 7)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }
    else if(ai - bi + ci + di== 7)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(ai - bi + ci - di== 7)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if(ai - bi - ci + di== 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if(ai - bi - ci - di== 7)
    {
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }

        
         public static long gcd(long x, long y)
        {
            if (x < y) gcd(y, x);
            while (y != 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long C(long n, long k)
        {
            long x = 1;
            for (long i = 1; i <= k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var d = new Dictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                if (d.ContainsKey(a[i])) d[a[i]]++;
                else d.Add(a[i], 1);
            }
            long ans = 0;
            foreach (var item in d)
            {
                if (item.Key < item.Value) ans += item.Value - item.Key;
                else if(item.Key > item.Value) ans += item.Value;
            }
            WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


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

#define ll long long
#define int ll
#define endl "\n"

signed main () {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	return 0;

}


Measured memory_bytes: 4780
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

ans = 0
for pat in combinations_with_replacement(range(1, m + 1), n):
    sm = 0
    for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if pat[b] - pat[a] == c:
            sm += d

    ans = max(ans, sm)

print(ans)


Measured memory_bytes: 9144
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll a,b,c,k; cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }
    if(k-a<=b){
        cout<<a<<endl;
        return 0;
    }
    cout<<a-(k-a-b)<<endl;

}








Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

typedef struct S
{
	int s,e,f;//(s e]
	bool operator <(const S &a)const{ return s<a.s;};
}S;
int N;
vector<S>F;
int main()
{
	for(;scanf("%d\n",&N),N;puts(""))
	{
		F.clear();
		S t={0,1000000001,-1};
		F.push_back(t);
		for(;N--;)
		{
			int a,b;
			char c;
			scanf("%c",&c);
			if(c=='W')
			{
				scanf("%d%d\n",&a,&b);
				for(int i=0;b>0;i++)
				{
					if(F[i].f==-1)
					{
						if(b>F[i].e-F[i].s)
						{
							F[i].f=a;
							b-=F[i].e-F[i].s;
						}
						else
						{
							S ins={F[i].s,F[i].s+b,a};
							F[i].s=F[i].s+b;
							F.push_back(ins);
							b=0;
							sort(F.begin(),F.end());
						}
					}
				}
			}
			else if(c=='R')
			{
				scanf("%d\n",&a);
				for(int i=0;i<F.size();i++)
					if(F[i].s<=a&&a<F[i].e)
					{
						printf("%d\n",F[i].f);
						break;
					}
			}
			else
			{
				scanf("%d\n",&a);
				for(int i=0;i<F.size();i++)
					if(F[i].f==a)
						F[i].f=-1;
			}
		}
	}
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	while(1) {
		int n,x;
		cin >> n >> x;
		if(n == 0 && x == 0) return 0;
		ll count=0;
		for(int i=1; i<=n; i++) {
			for(int j=i+1; j<=n; j++) {
				for (int k=j+1; k<=n; k++) {
					if(i == j || j == k || i == j) continue;
					else if(i+j+k == x) count++;
				}
			}
		}
		cout << count << endl;
	}

  return 0;
}


Measured memory_bytes: 3100
n,m = map(int,input().split())
list1=[]
list2=[]
for i in range(m):
  a,b = map(int,input().split())
  list1.append(a)
  list2.append(b)
x = min(list2)-max(list1)+1 if min(list2)-max(list1)>=0 else 0
print(x)

Measured memory_bytes: 10996
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll N;
ll dp[100][3];
vi b;
ll solve(){
  fill(dp,0);
  ll k=0,l=0,m=1;
  while(k!=N){
    if((N>>l)&1){
      b.pb(1);
      k+=m;
    }
    else{
      b.pb(0);
    }
    l++;
    m*=2;
  }
  reverse(b.begin(),b.end());
  int bs=b.size();
  dp[0][0]=1;
  rep(i,bs){
    if(b[i]){
      dp[i+1][0]=(dp[i+1][0]+dp[i][0])%MOD;
      dp[i+1][1]=(dp[i+1][1]+dp[i][0])%MOD;
      dp[i+1][1]=(dp[i+1][1]+dp[i][1])%MOD;
      dp[i+1][2]=(dp[i+1][2]+(dp[i][2]*3)%MOD)%MOD;
      dp[i+1][2]=(dp[i+1][2]+(dp[i][1]*2)%MOD)%MOD;
    }
    else{
      dp[i+1][0]=(dp[i+1][0]+dp[i][0])%MOD;
      dp[i+1][0]=(dp[i+1][0]+dp[i][1])%MOD;
      dp[i+1][1]=(dp[i+1][1]+dp[i][1])%MOD;
      dp[i+1][2]=(dp[i+1][2]+(dp[i][2]*3)%MOD)%MOD;
      dp[i+1][2]=(dp[i+1][2]+dp[i][1])%MOD;      
    }
  }
  ll res=0;
  rep(i,3){
    res=(res+dp[bs][i])%MOD;
  }
  return res;
}
int main(){
  cin>>N;
  prin(solve());
  return 0;
}


Measured memory_bytes: 256
N,H = list(map(int, input().split()))
A=0
B=[]
for _ in range(N):
    a,b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B = sorted([b for b in B if b>A], reverse=True)
from itertools import accumulate
B = list(accumulate(B))
total_throw_damage = (B[-1] if len(B)>0 else 0)

HP_after_throw = H - total_throw_damage
if HP_after_throw <= 0:
    for i,b in enumerate(B,1):
        if H<=b:
            print(i)
            exit()
    raise AssertionError('error')
else:
    q,r = divmod(HP_after_throw, A)
    print(len(B)+q+min(1, r))


Measured memory_bytes: 16592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  int n, m, c; cin >> n >> m >> c;
  Vi b(m); rep(i,m) cin >> b[i];
  int ans = 0;
  rep(i,n) {
    int sum = c;
    rep(j,m) {
      int a; cin >> a;
      sum += a * b[j];
    }
    if (sum > 0) ++ans;
  }
  pl(ans)
  return 0;
}


Measured memory_bytes: 3596
n, k = map(int, input().split())

res = 0
for value in range(1, n + 1):
    if value >= k:
        res += (1 / n)
    else:
        # 何回コインの表を出す必要があるか
        tmp = 0
        while value * 2 ** (tmp) < k:
            tmp += 1
        res += (1 / n * (1 / 2) ** tmp)
print(res)


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

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);

	if (a == 5 && b == 5 && c == 7) cout << "YES";
	else cout << "NO"; 
}

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

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL K; cin >> K;
		vector<UL> P(N);
		vector<UL> m(N), M(N);
		rep(i, N) cin >> P[i];
		deque<UL> q;
		rep(i, N) {
			while (q.size()) {
				if (P[q.back()] < P[i]) q.pop_back();
				else if(q.front() + K <= i) q.pop_front();
				else break;
			}
			q.push_back(i);
			if (i >= K - 1) M[i] = P[q.front()];
		}
		rep(ip, N) {
			UL i = N - ip - 1;
			while (q.size()) {
				if (P[q.back()] > P[i]) q.pop_back();
				else if (q.front() >= i + K) q.pop_front();
				else break;
			}
			q.push_back(i);
			if (ip >= K - 1) m[i] = P[q.front()];
		}
		UL ans = 0;
		vector<UL> S(N);
		S[0] = 1;
		for (UL i = 1; i < N; i++) {
			if (P[i] > P[i - 1]) S[i] = S[i - 1] + 1;
			else S[i] = 1;
			if (S[i] >= K) ans = 1;
		}
		for (UL i = K - 1; i < N; i++) {
			if (S[i] >= K) continue;
			if (i != K - 1) {
				if (M[i] == P[i] && m[i - K] == P[i - K]);
				else ans++;
			}
			else ans++;
		}
		//rep(i, N) cout << m[i] << " "; cout << endl;
		//rep(i, N) cout << M[i] << " "; cout << endl;
		//rep(i, N) cout << S[i] << " "; cout << endl;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3328
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int main() {
	int n;
	cin >> n;
	int mx = -1e9, mn = 1e9, cnt = 0;
	for (int j = 0; j < n; ++j) {
		cin >> a[j];
		mx = max(mx, a[j]);
		mn = min(mn, a[j]);
	}
	if (mx - mn > 1) {
		cout << "No\n";
		return 0;
	}
	for (int j = 0; j < n; ++j)
		cnt += (a[j] == mx);
	if (mx == mn) {
		if (mx == n - 1) {
			cout << "Yes\n";
			return 0;
		}
		if (mx <= n / 2) {
			cout << "Yes\n";
			return 0;
		}
		cout << "No\n";
		return 0;
	}
	int less = (n - cnt) + (cnt >= 1), most = (n - cnt) + (cnt / 2);
	for (int j = 0; j < n; ++j) {
		if (a[j] + 1 < less) {
			cout << "No\n";
			return 0;
		}
		if (a[j] > most) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}




Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, cnt, min, max;
  char hoge[10000];
  cin >> n;
  cin.ignore();
  while(n--){
    cnt = 1000, min = 1000, max = 1000;
    string num;
    cin >> num;
    for(int i=0;i<num.size();i++){
      if(num[i] == '>') cnt++;
      else if(num[i] == '<') cnt--;
      else if(num[i] != '-') hoge[cnt] = num[i];
      if(min > cnt) min = cnt;
      else if(max < cnt) max = cnt;
    }
    for(int i = min ; i <= max; i++){
      cout << hoge[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1204
#include<cstdio>
#define M 1000
int P[205],ans;
bool flag[205];
int n,x,y;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<2*n;i++){scanf("%d%d",&x,&y);P[x]=y+M*(i/n);}
    for(int i=0;i<2*n;i++)
		if(P[i]/M){
			int Pnum=-1,nq=-1;
			for(int j=i-1;j>=0;j--)
			if(!flag[j]&&P[j]/M!=P[i]/M&&P[j]%M<P[i]%M&&Pnum<P[j]%M)Pnum=P[j]%M,nq=j;
			if(Pnum==-1)continue;
			flag[nq]=1,flag[i]=1,ans++;
		}
    printf("%d",ans);
}


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

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int num[5] ;

int main()
{
	int n, m ;
	scanf ("%d%d", &n, &m) ;
	
	ms (num, -1) ;
	bool flag = true ;
	for (int i=0; i<m; i++)
	{
		int s, c ;
		scanf ("%d%d", &s, &c) ;
		
		if (num[s] == -1)
			num[s] = c ;
		else if (num[s] != c)
			flag = false ;
			
		if (s == 1 && c == 0 && n > 1)
			flag = false ;
		if (s > n)
			flag = false ;
	}
	
	if (!flag)
	{
		cout << -1 << endl ;
		return 0 ;
	}
	
	int ans = 0 ;
	if (n == 1 && m == 0)
		ans = 0 ;
	else
	{
		for (int i=1; i<=n; i++)
		{
			if (num[i] == -1)
				num[i] = (i == 1) ;
			
			ans += pow (10, n-i) * num[i] ;
		}
	}
	
	
	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n,x;
    int alice=0,bob=0;
    cin>>n;
    vector <int> v(n);
    for (int i = 0; i < n; ++i) {
        cin>>x;
        v[i]=x;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for (int j = 0; j < n; ++j) {
        if (j%2==0) {
            alice=alice+v[j];
        } else {
            bob+=v[j];
        }
    }
    cout<<alice-bob;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
const int  MOD = 1e9+7;
int main()
{	int n , k;
	cin>>n>>k;
	vector <int> a(n),dp(k+1);
	for(auto &i:a)
		cin>>i;
	// base case intialization 
	dp[0] = 1;
	FOR(i,1,k)
	{
		dp[i] = 0;
	}
	// outer loop
	FOR(i, 0,n-1)
	{vector <ll> sum(k+1);
		sum[0] = dp[0];
		FOR(j ,1,k)
		sum[j] = (sum[j-1] + dp[j])%MOD;
		FOR(j,0,k)
		if(j<=a[i])
			dp[j] = sum[j];
		else
			{
				int s = j-a[i]-1;
				dp[j] = (sum[j]-sum[s]+MOD)%MOD;
			}
			sum.clear();
	}
	cout<<dp[k];
    return 0;
}

Measured memory_bytes: 4556
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			double s = (double)(a * b) / 3.305785;
			System.out.printf("%.5f\n",s);
		}
	}
}

Measured memory_bytes: 17336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
vector<int> pathes[200500];
int parent[205000];
vector<int> children[200500];
int maxancestor[200500];
int ans[200050];
int lazy[200500];
int dp1[200050];
int dp2[200050];
bool visited[200050];
void initialize(int now, int maxi) {
    maxancestor[now] = maxi;
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == parent[now]) continue;
        parent[to] = now;
        children[now].push_back(to);
        initialize(to, max(maxi, now));
    }
}

void dfs1(int now, int bound);
void dfs2(int now);

void f(int now) {
    if(visited[now]) return;
    int sum1 = 0;
    int sum2 = 0;
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        dfs1(to, maxancestor[now]);
        dfs2(to);
        sum1 += dp1[to];
        sum2 += dp2[to];
    }
    lazy[now] += sum1 + 1;
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        lazy[to] -= dp1[to];
        lazy[to] += dp2[to];
    }
    visited[now] = true;
}

void propagate(int now, int val) {
    val += lazy[now];
    ans[now] += val;
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        propagate(to, val);
    }
}

void dfs1(int now, int bound) {
    dp1[now] = 0;
    if(visited[now]) return;
    if(bound < now) return;
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        dfs1(to, bound);
        dp1[now] += dp1[to];
    }
    dp1[now]++;
    return;
}

void dfs2(int now) {
    dp2[now] = 0;
    if(visited[now]) return;
    visited[now] = true;
    for(int i = 0; i < children[now].size(); i++) {
        int to = children[now][i];
        dfs2(to);
        dp2[now] += dp2[to];
    }
    dp2[now]++;
    return;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    parent[1] = 0;
    initialize(1, 0);
    for(int i = N; i >= 2; i--) {
        f(i);
    }
    propagate(1, 0);
    for(int i = 2; i <= N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 46080
package main

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

var cache = make(map[string]int)

func sortString(in string) string {
	out := strings.Split(in, "")
	sort.Strings(out)
	return strings.Join(out, "")
}

func solve(N int, s []string) uint64 {
	for _, v := range s {
		ss := sortString(v)
		cache[ss]++
	}
	return count(cache)
}

func count(cache map[string]int) uint64 {
	ret := uint64(0)
	for _, v := range cache {
		if v >= 2 {
			for i := 1; i <= v-1; i++ {
				ret += uint64(i)
			}
		}
	}
	return ret
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func newSplitScanner(r io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func main() {
	var sc = newSplitScanner(os.Stdin)
	n := nextInt(sc)
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = nextLine(sc)
	}

	fmt.Println(solve(n, a))
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	string S[3];

	cin >> S[0] >> S[1] >> S[2];

	int sz[3] = { (int)S[0].size(), (int)S[1].size(), (int)S[2].size() };
	int turn = 0;
	int ii[3] = { 0 };
	while( 1 ) {
		if( ii[ turn ] >= sz[ turn ] ) {
			break;
		}
		ii[ turn ]++;
		turn = S[ turn ][ ii[ turn ] - 1 ] - 'a';
	}
	char ans = 'A' + turn;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

#define PI 3.1415926535897932

int main() {
  int n;
  string s;
  cin>>n>>s;
  char c='0';
  int count=0;
  for (size_t i = 0; i < n; i++) {
    if(s[i]!=c){
      count++;
      c=s[i];
    }
  }
  cout<<count;
}

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

using namespace std;

using UInt = uint_fast64_t;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

UInt find_count(const string& src, const string& ptn)
{
    UInt ret = 0;
    string::size_type pos = 0;
    while (true) {
        pos = src.find(ptn, pos);
        if (string::npos == pos) {
            break;
        }
        else {
            ++ret;
            ++pos;
        }
    }
    return ret;
}

bool sub()
{
    const auto S(cin2var<string>());

    if (S.empty()) return false;

    cout << find_count(S, "JOI") << endl;
    cout << find_count(S, "IOI") << endl;

    return true;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    while (sub());
    return 0;
}


Measured memory_bytes: 3040
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return sorted(divisors,reverse=True)

N = int(input())
div = make_divisors(N)
ans = [(a - 1) for a in div if a > 1 and N % (a - 1) == N // (a - 1)]
print(sum(ans))

Measured memory_bytes: 3424
#include <cstdio>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    for(int i = 8; i < 1010; i++)
    if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
        return printf("%d\n", i), 0;
    printf("-1\n");
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int n;
    for (n = 1; N > 0; n++)
    {
        N -= n;
    }
    if (N == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }

    cout << n << endl;
    vector<vector<int>> ans(n);
    int current = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++, current++)
        {
            ans[i].push_back(current);
            ans[j].push_back(current);
        }
    }

    for (auto a : ans)
    {
        cout << a.size() << " ";
        for (int x : a)
        {
            cout << x << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 2304