akhauriyash/Code-Regression huggingface dataset:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package here;

/**
 *
 * @author sokumar
 */
import java.util.*;
import java.io.*;
public class Main {
   
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        
         int n = sc.nextInt();
         double []p = new double[n];
         for(int i=0;i<n;i++)
         {
             p[i] = sc.nextDouble();
         }
         double [][]dp = new double[n+1][n+1];
         dp[1][1] = p[0];
         dp[1][0] = 1.0-p[0];
         for(int i=2;i<=n;i++)
         {
             for(int j=0;j<=i;j++)
             {
                 if(j!=0)
                 dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];
                 else
                     dp[i][j] = dp[i-1][j]*(1-p[i-1]);
                 //w.println(i + " "+ j + " " + dp[i][j]);
             }
         }
         double res = 0;
       
             for(int j=n/2 + 1;j<=n;j++)
             {
                 res += dp[n][j];
                 
             }
         
         w.println(res);
         
            
        w.close();
    }
    
    
}


Measured memory_bytes: 124880
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int arith(int a, int b, char op){
    switch(op){
        case '+':
            return a + b;
        case '-':
            return a - b;
        case '*':
            return a * b;
        case '/':
            return a / b;
        default:
            break;
    }
    return 0;
}

int main(void){
    int result = 0;
    stack<int> st;
    string str;
    string num = "";
    getline(cin, str);
    for(string::iterator itr = str.begin(); itr != str.end(); itr++){
        char c = *itr;
        if(c == ' '){
            st.push(stoi(num));
            num = "";
        }else if(0 <= c - '0' && c - '0' < 10){
            num += c;
        }else{
            int b = st.top();
            st.pop();
            int a = st.top();
            st.pop();
            int res = arith(a, b, c);
            st.push(res);
            if(itr < str.end() - 1) itr++;
        }
    }
    cout << st.top() << endl;
    return 0;
}


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

#define ul unsigned long 
#define ull unsigned long long
#define li long long int

int main()
{
  int n;
  string s,s2,t="ABC";
  cin >> n;
  cin >> s;

  int count=0;
  while (s.find(t)!=string::npos) {
    count++;
    s = s.substr(s.find(t)+t.length());
  }

  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
ans = 0
if H%2 == 0 and W%2 == 0:
  ans = (W//2)*H
elif H == 1 or W == 1:
  print(1)
  exit()
elif H%2 != 0 and W%2 != 0:
  ans = (W//2)*(H//2) + (H-(H//2))*(W-(W//2))
elif H%2 == 0 and W%2 != 0:
  ans = (W//2)*(H//2) + (H//2)*(W-(W//2))
elif H%2 != 0 and W%2 == 0:
  ans = (W//2)*(H//2) + (H-(H//2))*(W//2)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, q, ans;

struct node {
	ll s, e, m, v;
	node *l, *r;
	node(ll S, ll E) {
		s = S, e = E, m = (s+e)/2, v = n;
		if (s == n) v = 1;
		if (s != e) {
			l = new node(s, m);
			r = new node(m+1, e);
		}
	}
	void up(ll x, ll y, ll nv) {
		if (s == x and e == y) v = min(v, nv);
		else if (y <= m) l->up(x, y, nv);
		else if (x > m) r->up(x, y, nv);
		else l->up(x, m, nv), r->up(m+1, y, nv);
	}
	ll query(ll x) {
		if (s == e) return v;
		else return min(v, (x <= m ? l : r)->query(x));
	}
} *row, *col;

int main() {
	fastio; cin >> n >> q;
	row = new node(1, n), col = new node(1, n);
	ans = (n-2) * (n-2);
	while (q--) {
		ll t, x; cin >> t >> x;
		if (t == 1) {
			ans -= max(0ll, col->query(x) - 2);
			row->up(1, col->query(x)-1, x);
		} else {
			ans -= max(0ll, row->query(x) - 2);
			col->up(1, row->query(x)-1, x);
		}
	}
	cout << ans;
}


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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int mod = 1e9 + 7;

void solve(void) {

	int n, m;
	cin >> n >> m;

	vector<string> A;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		A.push_back(s);
	}

	vector<vi> dp(n+1, vi(m+1));

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(i == 1 && j == 1) {
				dp[i][j] = 1;
			} else if(A[i-1][j-1] == '.') {
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
			}
			dp[i][j] %= mod;
		}
	}

	cout << dp[n][m] << '\n';

}

int main(void) {

	solve();
	return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<algorithm>
using namespace std;
int m[2600000];
int n[2600000];
long long sum[2600000];
int main(){
	int a,b;
	int m0,md,n0,nd;
	scanf("%d%d%d%d%d%d",&a,&b,&m0,&md,&n0,&nd);
	for(int i=0;i<a;i++){
		m[i]=m0;
		m0=(m0*58+md)%(b+1);
	}
	for(int i=0;i<b;i++){
		n[i]=n0;
		n0=(n0*58+nd)%(a+1);
	}
	std::sort(m,m+a);
	std::sort(n,n+b);
	sum[0]=n[0];
//	for(int i=0;i<a;i++)printf("%d ",m[i]);printf("\n");
//	for(int i=0;i<b;i++)printf("%d ",n[i]);printf("\n");
	
	for(int i=1;i<b;i++)sum[i]=sum[i-1]+n[i];
	long long ret=9999999999999999LL;
	long long now=0;
	for(int i=0;i<=a;i++){
		int at=upper_bound(n,n+b,a-i)-1-n;
		ret=min(ret,now+sum[at]+(long long)(a-i)*(b-at-1));
		now+=m[i];
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 41268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int A, B;

  cin >> A >> B;

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    puts("Possible");
  } else {
    puts("Impossible");
  }

  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

//-----------------------------------
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int N;
Graph G;
vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e:G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main(){
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i=0; i<N-1; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    res.assign(N,0);

    dfs(0,-1,1);

    rep(i,res.size()) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back
 
typedef long long ll;

const int INF = 1e9;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int N, a, b; cin >> N >> a >> b;
	cout << min(N*a, b) << endl;
		
}


Measured memory_bytes: 256
N, W = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]

dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(N):
    for j in range(W + 1):
        if j < A[i][0]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - A[i][0]] + A[i][1])
            
print(dp[N][W])

Measured memory_bytes: 120044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

ll gcd(ll a, ll b) {
	ll temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	int n, m;
	cin >> n >> m;
	vi a(n+3,0);
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l--; r;
		a[l]++;
		a[r]--;
	}

	int t = 0;
	int ans = 0;
	rep(i, n) {
		t += a[i];
		//cout << a[i] << endl;
		if (t == m) {
			ans++;
		}
	}
	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void)
{
	int dice[6];
	int i, j;
	int n;
	char str[5];
	char str_t[6][6] = {"North", "East", "West", "South", "Right", "Left"};
	int sum;
	int m;
	int tmp;

	while(1){

		sum = 1;

		for (i = 0; i < 6; i++){
			dice[i] = i + 1;
		}

		scanf("%d", &n);

		if (n == 0){
			break;
		}

		for (i = 0; i < n; i++){
			scanf("%s", str);
			for (j = 0; j < 6; j++){
				if (!strcmp(str_t[j], str)){
					m = j;
					break;
				}
			}

			switch (m){
			  case 0:
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;

				sum += dice[0];
				break;

			  case 1:
			    tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;

				sum += dice[0];
				break;

			  case 2:
			    tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;

				sum += dice[0];
				break;

			  case 3:
			    tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;

				sum += dice[0];
				break;

			  case 4:
			    tmp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = tmp;

				sum += dice[0];
				break;

			  case 5:
			    tmp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = tmp;
				
				sum += dice[0];
				break;
			}
		}

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

	return (0);
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int n;
long long a[10000],b[10000];
long long z,f;
int main()
{
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        cin>>a[i];
    }
    for(int i = 0;i < n;i ++)
    {
        cin>>b[i];
        if(b[i] - a[i] < 0)f += a[i] - b[i];
        else if(b[i] - a[i] > 0)z += (b[i] - a[i]) / 2;
    }
    if(z >= f)cout<<"Yes";
    else cout<<"No";
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
 
vector <ll> v;
ll m1[200005];
 
ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	ll n,i,m,j,k,x,y,a,b,c,t;
	string s;
	
	cin >> n >> k >> c >> s;
	for(i=n-1;i>=0;i--)
		if(s[i]=='o')
			break;
	a=k;
	while(k && i>=0)
	{
		if(s[i]=='o')
		{
			m1[i]=k;
			k--;
			i-=c+1;
		}
		else
			i--;
	}
	for(i=0;i<n;i++)
		if(s[i]=='o')
			break;
	k=a;
	while(k && i<n)
	{
		if(s[i]=='o')
		{
			if(m1[i]==a-k+1)
				cout << 1+i << endl;
			k--;
			i+=c+1;
		}
		else
			i++;
	}
 
	return 0;
}


Measured memory_bytes: 3348
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
int buf[100];
void dfs(int c,int p)
{
	int i;
	if(c==0)
	{
		for(i=0;i<p-1;i++)
		{
			cout << buf[i] << ' ';
		}
		cout << buf[i] << endl;
		return;
	}
	for(i=min(c,((p==0) ? c : buf[p-1]));i>0;i--)
	{
		buf[p]=i;
		dfs(c-i,p+1);
	}
	return;
}
int main()
{
	while(1)
	{
		cin >> n;
		if(n==0)break;
		dfs(n,0);
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define tt long t;cin>>t;while(t--)
#define tez ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define plli pair<lli,lli>
#define vlli vector<lli>
#define vplli vector<plli>
#define pqlli priority_queue <lli>
#define pqplli priority_queue <plli>
#define mplli map<lli,lli>
#define all(v) v.begin(),v.end()
#define alll(s) s.begin(),s.end(),s.begin(), ::tolower
#define allu(s) s.begin(),s.end(),s.begin(), ::toupper

#define mod 1000000007
#define ff first
#define ss second
#define fori(i,a,b)    for(int i=a;i<b;i++)
#define ford(i,a,b)    for(int i=a;i>=b;i--)
#define br cout<<endl
#define sz(v) (long)v.size()
#define YS cout<<"YES"<<endl
#define ys cout<<"yes"<<endl
#define Ys cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define no cout<<"no"<<endl
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define bs binary_search
#define mp make_pair
#define llmn LLONG_MIN
#define llmx  LLONG_MAX
#define stp setprecision
#define fxd fixed
#define tu (char)toupper
#define tl (char)tolower
#define coutv(v) for(lli index=0;index<v.size();index++) {cout<<v[index]<<" ";} br;

using namespace std;

/*
lli count01(string s,char ch){
  lli mx=0,c=0;
  if(ch=='0'){

   fori(i,0,sz(s)){
     if(s[i]=='0'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

   }

  }
  else{

    fori(i,0,sz(s)){
     if(s[i]=='1'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

    }

  }
return mx;

}*/
/*
vector<lli> prime(lli n){
  bool a[n+1];
  memset(a,true,sizeof(a));
  for(lli i=2;i*i<=n;i++){
    if(a[i]){
      for(lli j=i*i;j<=n;j+=i)
      {  a[j]=false;}
    }
  }
  vector<lli>v;
  for(lli i=2;i<=n;i++){
    if(a[i]){
      v.pb(i);
    }
  }
  return v;
}

*/

int main(){
tez
string s,ss;
cin>>s>>ss;
lli n=sz(s),ans=0;
for(lli i=0;i<n;i++){
    if(s[i]!=ss[i]){
        ans++;
    }
}
cout<<ans;




return 0;
}


Measured memory_bytes: 3800
#include <stdbool.h>
#include <stdio.h>          // printf(), getc()
#include <ctype.h>          // isdigit()

bool
ope_line()
{
	int n;
	int c;

	c = getc(stdin);
	if (c == '\n')
		return true;

	if (c == EOF)
		return false;

	n = 0;
	while (isdigit(c))
	{
		n = n * 10 + c - '0';
		c = getc(stdin);
	}

	printf("%d\n", n * n * n);
	if (c == EOF)
		return false;

	return true;
}

int
main(int argc, char** argv)
{
	while (ope_line())
		;

	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
using namespace std;

long long ans;
int n;
int a[3][100005];

int main(){
	cin>>n;
	for(int i=0;i<3;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int i=0;i<3;i++) sort(a[i],a[i]+n);
	for(int i=0;i<n;i++){
		long long x=lower_bound(a[0],a[0]+n,a[1][i])-a[0];
		long long y=upper_bound(a[2],a[2]+n,a[1][i])-a[2];
		y=n-y;
		ans+=x*y;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

bool isPrime(int x) {
  for(int i=2;i*i<=x;i++) {
    if(x%i==0)return false;
  }
  return true;
}

int main(void){
  int n,i,j,k,tmp;
  cin>>n;

  vector<int> primes;
  primes.clear();
  
  for(i=2;i<100;i++){
    if(isPrime(i))primes.push_back(i);
  }
  vector<int> cnt(primes.size());
  for(i=0;i<cnt.size();i++){
    cnt[i]=0;
  }

  for(i=1;i<=n;i++){
    tmp=i;
    for(j=0;j<cnt.size();j++){
      while(tmp%primes[j]==0){
        tmp/=primes[j];
        cnt[j]++;
      }
      if(tmp==1)break;
    }
  }

  int ans=0;
  for(i=0;i<cnt.size();i++){
    for(j=i+1;j<cnt.size();j++){
      for(k=j+1;k<cnt.size();k++){
        if(cnt[i]>=4&&cnt[j]>=4&&cnt[k]>=2)ans++;
        if(cnt[i]>=4&&cnt[j]>=2&&cnt[k]>=4)ans++;
        if(cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4)ans++;
      }
      if(cnt[i]>=14&&cnt[j]>=4)ans++;
      if(cnt[i]>=4&&cnt[j]>=14)ans++;
      if(cnt[i]>=24&&cnt[j]>=2)ans++;
      if(cnt[i]>=2&&cnt[j]>=24)ans++;
    }
    if(cnt[i]>=74)ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int,input().split()))

count = collections.Counter(a)

tmp = [0 for _ in range(n)]
tmp2 = [0 for _ in range(n)]

for key,value in count.items():
	if value == 1:
		continue
	tmp[key-1] = value*(value-1) // 2
	tmp2[key-1] = (value-1)*(value-2) // 2
tmp3 = sum(tmp)

for i in range(n):
	print(tmp3 - tmp[a[i]-1] + tmp2[a[i]-1])


Measured memory_bytes: 26780
# -*- coding: utf-8 -*-
import sys

def main():
	A, B = map(int, input().split(" "))
	
	B0 = 0
	if B % 2 == 1:
		tmp = (B + 1) // 2
		if tmp % 2 == 1: B0 = 1
		else: B0 = 0
	else:
		tmp = B // 2
		if tmp % 2 == 1: B0 = 1
		else: B0 = 0
		B0 = B0 ^ B
		
	A0 = 0
	if (A-1) % 2 == 1:
		tmp = A // 2
		if tmp % 2 == 1: A0 = 1
		else: A0 = 0
	else:
		tmp = (A-1) // 2
		if tmp % 2 == 1: A0 = 1
		else: A0 = 0
		A0 = A0 ^ (A-1)
		
	print(B0 ^ A0)
		
if __name__ == "__main__":
	main()
	

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

int     main() {
        int DD=1000000007;
        int N, M;
        cin >> N >> M;
        vector <int> a(N+1, 0);
        vector <int> b(N+1);
        int aa;
        b.at(0)=1;
        b.at(1)=1;
        for (int i=0; i<M; i++) {
                cin >> aa;
                a.at(aa)=1;
                b.at(aa)=0;
        }
        for (int i=2; i<=N; i++){
                if (a.at(i) == 1) b.at(i)=0;
                else b.at(i)=(b.at(i-1)+b.at(i-2)) % DD;
        }
        cout <<b.at(N) << endl;
        return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
using namespace std;
int N, K, a, res = 1e9;
vector<int> arr;
deque<int> dq;

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

	cin >> N;
	cin >> K;

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

	sort(arr.begin(), arr.end());

	for (int i = 0; i < K; ++i) {
		dq.push_back(arr[i]);
	}
	res = min(dq.back() - dq.front() + abs(dq.back()), dq.back() - dq.front() + abs(dq.front()));

	for (int i = K; i < N; ++i) {
		dq.pop_front();
		dq.push_back(arr[i]);
		res = min(res, min(dq.back() - dq.front() + abs(dq.back()), dq.back() - dq.front() + abs(dq.front())));
	}

	cout << res;

}

Measured memory_bytes: 1016
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABCD = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] ST = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int K = int.Parse(Console.ReadLine());
            int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int A = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            bool res = true;
            int sample = AB[1]/K;
            if(sample*K>=AB[0] && sample*K<=AB[1]){
                res = true;
            }else{
                res = false;
            }
            Console.WriteLine(res?"OK":"NG");
        }
    }
}


Measured memory_bytes: 17908
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <array>
#include <cassert>

using namespace std;

typedef long long ll;
const ll MOD = ll(1e9+7);
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    ll ans,n,x;
    string s[2];
    cin >> n >> s[0] >> s[1];
    bool flag;
    if(s[0][0]==s[1][0]){
        ans = 3;
        x = 1;
        flag = true;
    }
    else {
        ans = 6;
        x = 2;
        flag = false;
    }
    while(x<n){
        if(flag){
            if(s[0][x]==s[1][x]){
                ans *= 2;
                x+=1;
            }
            else{
                ans *= 2;
                x+=2;
                flag = false;
            }
        }
        else{
            if(s[0][x]==s[1][x]){
                flag = true;
                x+=1;
            }
            else{
                ans *= 3;
                x+=2;
            }
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, a, b;
  cin >> N;
  a = N;
  b = 0;
  
  while (a > 0) {    
    b += a % 10;
    a /= 10;
  }

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

Measured memory_bytes: 256
D,N = list(map(int,input().split(' ')))
#ar = [ar.append(100**D*i) for i in range(1,N+1)
ar = []
if N <100:
  for i in range(1,N+1):
    ar.append(100**D*i)
else:
  for i in range(1,N+2):
    ar.append(100**D*i)
    
  
print(ar[-1])

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

int N,C,D[30][30],cnt[3][30];

int main(){
    cin>>N>>C;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            cin>>D[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int color; cin>>color;
            cnt[(i+j)%3][color-1]++;
        }
    }
    int ans=1<<30;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            if(i!=j){
                for(int k=0;k<C;k++){
                    // 三色異なる
                    if(k!=i&&k!=j){
                        int s=0;
                        for(int l=0;l<C;l++){
                            s+=D[l][i]*cnt[0][l];
                        }
                        for(int l=0;l<C;l++){
                            s+=D[l][j]*cnt[1][l];
                        }
                        for(int l=0;l<C;l++){
                            s+=D[l][k]*cnt[2][l];
                        }
                        ans=min(ans,s);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
#define TRUE 1
#define FALSE 0

/*
	p: parent
	l: left-child
	r: right sibling
*/

int n;
struct Node {
	int p, l, r;
};
int found;
int root;

struct Node T[MAX];	// Tree

int dfs (int curr, int depth )
{
	if (found == TRUE ) return depth;
	if (curr == root ){
		found = TRUE;
		return depth;
	} // end if

	return dfs (T[curr].p, depth + 1 );
}

int calc_depth (int node )
{
	int i;
	found = FALSE;
	if (root == NIL ){
		for (i = 0; i < n; i++ ){
			if (T[i].p == NIL ){
				root = i;
				break;
			} // end if
		} // end for
	} // end if

	int res = dfs (node, 0 );

	return res;	
}

int main()
{
	int i, j, d, v, c, l;
	root = NIL;
	scanf("%d", &n );

	for (i = 0; i < n; i++ ){
		T[i].p = T[i].l = T[i].r = NIL;
	} // end for

	for (i = 0; i < n; i++ ){
		scanf ("%d %d", &v, &d );	// v: 節点の番号 d: 次数 
		for (j = 0; j < d; j++ ){
			scanf ("%d", &c );	// c: 子の節点番号 
			if (j == 0 ){
				T[v].r = c;
			}else{
				T[l].l = c;
			} // end if
			l = c;
			T[l].p = v;
		} // end for
	} // end for

	for (i = 0; i < n; i++ ){
		printf ("node %d: parent = %d, depth = %d, ", i, T[i].p, calc_depth(i ) );
		if (T[i].p == NIL ){		// case root 
			printf ("root, [" );
			int next = T[i].r;
			while (next != NIL ){
				printf ("%d", next );
				next = T[next].l;
				if (next != NIL ) printf (", " );
			} // end while
			printf ("]\n" );
		}else
		if (T[i].r == NIL ){		// case leaf
			printf ("leaf, []\n" );
		}else{				// case internal node
			printf ("internal node, [" );
			int next = T[i].r;
			while (next != NIL ){
				printf ("%d", next );
				next = T[next].l;
				if (next != NIL ) printf (", " );
			} // end while
			printf ("]\n" );
		} // end if
	} // end for		

	return 0;
}

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

typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int MID = 1e5 + 3;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main(){
    speed;
    ll n, x;
    cin >> n >> x;
    vector<ll> v(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
    }
    ll cnt = 0;
    for(int i = 1; i <= n; ++i){
        if(v[i] + v[i - 1] > x){
            cnt += v[i] + v[i - 1] - x;
            v[i] += x - (v[i] + v[i - 1]);
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<vector<int>> d(10, vector<int>(10, 1000000));

void warshall_floyd(int n) {
    rep(k,n) rep(i,n) {
        rep(j,n) {
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}
int main()
{
    ll n; cin >> n;
    vector<ll> a;
    int ans = 20;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            a.push_back(i);
            a.push_back(n/i);
        }
    }
    for (int i = 0; i < a.size(); i += 2) {
        int tmp1 = to_string(a[i]).length();
        int tmp2 = to_string(a[i+1]).length();
        ans = min(ans, max(tmp1, tmp2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)cout<<c<<endl;
  if(a==c)cout<<b<<endl;
  if(b==c)cout<<a<<endl;
}

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

int main() {
  char s[4];
  scanf("%s", s);

  if (s[0] == s[1] && s[1] == s[2]) {
    printf("Yes");
  } else if (s[1] == s[2] && s[2] == s[3]) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true
s = gets.chomp.chars
q = gets.chomp.to_i
is_reverse = false

q.times do
  val = gets.chomp.split
  t, f, c = val
  t = t.to_i
  if t == 1
    # 先頭に付けるかお尻につけるか
    is_reverse = !is_reverse
  elsif t == 2
    f = f.to_i
    if f == 1 && is_reverse == false || f == 2 && is_reverse == true
      s.unshift c
    elsif f == 2 && is_reverse == false || f == 1 && is_reverse == true
      s.push c
    end
  end
end

s.reverse! if is_reverse

puts s.join

Measured memory_bytes: 28028
#python3

def main():
    n = int(input())
    for _ in range(n):
        t, x, y = map(int, input().split())
        if t < x + y:
            print('No')
            return
        if (x+y-t)%2 != 0:
            print('No')
            return
    print('Yes')
main()


Measured memory_bytes: 3060
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split('\n');
  for (var i = 0; i < inputs.length; i++) {
  	if (inputs[i]==='0 0'){
  		break;
  	}
  	var input = inputs[i].split(' ')
  	.map(Number).sort(function(a,b){
  		return a-b;
  	})
  	.join(' ');
  	console.log(input);
  }
  // ????????????????????????
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 19304
#include <bits/stdc++.h>
#define f(i,q,a) for(long long i=q; i<a; i++)
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll sum=0;
    f(i,0,s.size())
    {
        sum+=(s[i]-3);
        sum%=9;
    }
    if(sum%9)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      String str = sc.nextLine();
      String[] arr = str.split(" ");
      
      int max = Integer.parseInt(arr[0]);
      int min = Integer.parseInt(arr[0]);
      long sum = 0;
      
      int a;
      int i;
      
      for(i = 0; i < n; i ++){
         a = Integer.parseInt(arr[i]);
         if(a > max){
            max = a;
         }else if(a < min){
            min  = a;
         }
         sum += a;
      }
      
      
      
      
            
      System.out.println(min + " " + max + " " + sum);
     
      
   
   }//main method 
}//class

Measured memory_bytes: 31896
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

string s;
ll dp[200010]={},ans=0;

int main(void){
	cin>>s;
	irep(i,s.size())if(s[i]=='W')dp[i]=1;
	irep(i,s.size())dp[i]+=dp[i+1];
	rep(i,s.size()){
		if(s[i]=='B')ans+=dp[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2180
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int d[N];

int main() {
  int k, q; scanf("%d %d", &k, &q);
  for (int i = 0; i < k; i++)
    scanf("%d", &d[i]);
  for (int i = 1; i <= q; i++) {
    int n, x, m; scanf("%d %d %d", &n, &x, &m);
    ll sm = 0;
    for (int j = 0; j < k; j++)
      sm += d[j] % m;
    x %= m;
    ll ans = 0;
    if (n <= k) {
      int a = x;
      for (int j = 1; j < n; j++) {
        int b = (a + d[(j - 1) % k]) % m;
        if (a < b)
          ans++;
        a = b;
      }
    } else {
      int r = n % k;
      if (n % k == 0)
        r += k, n -= k;
      ll z = x + (n/k) * 1ll * sm;
      for (int j = 1; j < r; j++)
        z += d[(j - 1) % k] % m;
      ans = z / m;
      for (int j = 0; j < k; j++) if (d[j] % m == 0)
        ans += (j+1 < r) + (n / k);
      if (r == k)
        n += k;
      ans = n - ans - 1;
    }
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;
#define inf 100000000/*10^8*/

/////////////////////////////////

#define MAX_N 100005//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void init(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

//////////////////////////////////////

int main(){
    int n,m;cin>>n>>m;
    int a[n];for(int i=0;i<=n-1;i++)cin>>a[i];
    init(n);
    for(int i=0;i<=m-1;i++){
        int x,y;cin>>x>>y;
        unite(x,y);
    }
    if(n==m+1){
        cout<<0<<endl;
        return 0;
    }
    if(2*m-n+2<0){
        cout<<"Impossible"<<endl;
        return 0;
    }
    
    bool already[n];for(int i=0;i<=n-1;i++)already[i]=false;
    vector<int>amari;
    ll ans=0;
    
    
    vector<int>samepar;
    for(int i=0;i<=n-1;i++){
        if(i==par[i])samepar.push_back(i);
    }
    
    vector<int>cost[n];
    for(int i=0;i<=n-1;i++){
        cost[find(i)].push_back(a[i]);
    }
    for(auto i:samepar){
        sort(cost[i].begin(),cost[i].end());
    }
    for(auto i:samepar){
        ans+=cost[i][0];
        for(int j=1;j<cost[i].size();j++){
            amari.push_back(cost[i][j]);
        }
    }
    
    
        sort(amari.begin(),amari.end());
    /*for(int i=0;i<=amari.size()-1;i++)cout<<amari[i]<<" ";cout<<endl;*/
        int mm=n-m-2;
        for(int i=0;i<mm;i++){
            ans+=amari[i];
        }
        cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 6268
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		
		int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
		
		if (y1 < y2)
			x3 = x2 - Math.abs(y2 - y1);
		else
			x3 = x2 + Math.abs(y2 - y1);
		
		x4 = x1 + x3 - x2;
		
		if (x1 < x2)
			y3 = y2 + Math.abs(x2- x1);
		else
			y3 = y2 - Math.abs(x2 - x1);
		
		y4 = y1 + y3 - y2;
		
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

	}

}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<" ";
#define Y {cout<<"YES"<<endl;return 0;}
#define pb(x) push_back(x)
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f,maxn=2e5+100;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
double w,h,x,y;
int main()
{
	fast;cin>>w>>h>>x>>y;
	double ans=w*h/2.0;
	cpp(6,ans);
	if(x*2.0==w&&y*2.0==h) cout<<"1"<<endl;
	else cout<<"0"<<endl;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();

        String[] strArray = input.split(" ");

        int W = Integer.parseInt(strArray[0]);
        int H = Integer.parseInt(strArray[1]);
        int x = Integer.parseInt(strArray[2]);
        int y = Integer.parseInt(strArray[3]);
        int r = Integer.parseInt(strArray[4]);

        if(r <= x && r <= y && (x + r) <= W && (y + r) <= H){
                System.out.println("Yes");
        }else{
                System.out.println("No");
        }
    }
}

Measured memory_bytes: 24392
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 256
using namespace std;
typedef pair<int,int> P;

int M, n;
string str;
map<string,P> m;
stack<vector<int> > st;
vector<int> tmp, n1, n2;
int dp[100][256];
bool ok = true;

vector<int> calc(int x, vector<int> v1, vector<int> v2){
	/*
	cout << x << endl;
	rep(i,v1.size()) cout << v1[i] << " ";
	cout << endl;
	rep(i,v2.size()) cout << v2[i] << " ";
	cout << endl;
	*/
	vector<int> ret;
	rep(i,v1.size()) rep(j,v2.size()){
		if(x == 0) ret.push_back((v1[i]*v2[j])%MOD);
		if(x == 1) ret.push_back((v1[i]+v2[j])%MOD);
		if(x == 2) ret.push_back((v1[i]-v2[j]+MOD)%MOD);
		if(x == 3){
			if(v2[j] == 0){
				ret.clear();
				return ret;
			} else{
				ret.push_back(v1[i]/v2[j]);
			}
		}
	}
	sort(ret.begin(),ret.end());
	ret.erase(unique(ret.begin(),ret.end()),ret.end());
	return ret;
}

int main(){
	cin >> M;
	rep(i,M){
		string str;
		int s, e;
		cin >> str >> s >> e;
		m[str] = P(s,e);
	}
	cin >> n;
	rep(i,n){
		cin >> str;
		if(str=="*"){
			n1 = st.top();
			st.pop();
			n2 = st.top();
			st.pop();
			st.push(calc(0,n2,n1));
		} else if(str=="+"){
			n1 = st.top();
			st.pop();
			n2 = st.top();
			st.pop();
			st.push(calc(1,n2,n1));
		} else if(str=="-"){
			n1 = st.top();
			st.pop();
			n2 = st.top();
			st.pop();
			st.push(calc(2,n2,n1));
		} else if(str=="/"){
			n1 = st.top();
			st.pop();
			n2 = st.top();
			st.pop();
			st.push(calc(3,n2,n1));
			n2 = st.top();
			if(n2.size() == 0){
				ok = false;
				break;
			}
		} else if(m.count(str)==0){
			int num = atoi(str.c_str());
			tmp.clear();
			tmp.push_back(num);
			st.push(tmp);
		} else{
			P p = m[str];
			tmp.clear();
			for(int j = p.first; j <= p.second; j++){
				tmp.push_back(j);
			}
			st.push(tmp);
		}
	}
	if(!ok) puts("error");
	else puts("correct");
}

Measured memory_bytes: 1632
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
using namespace std;


long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}


int main()
{
	int n;
	cin >> n;
	vector<vector<double>> a(2, vector<double>(n));
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[0][i];
		cin >> a[1][i];
		b[i] = i;
	}

	double sum = 0;
	for (long i = 0; i < factorial(n); i++) {
		for (int j = 1; j < n; j++) {
			sum = sum + pow((pow((a[0][b[j]] - a[0][b[j - 1]]), 2) + pow((a[1][b[j]] - a[1][b[j - 1]]), 2)),0.5)/ double(factorial(n));
		}
		next_permutation(b.begin(), b.end());
	}

	cout << setprecision(20)<< sum;

}

Measured memory_bytes: 256
//????????????' '???????????°???????????????????????§???????????§????????¨??? ?????????????????¨???????????°?????¨????????? 
//C?¨??????§?????????????????????char??????????????¨????????±???????????? ???????????????""????????????????????????????????§???????????§????????¨??? ????????????????????¨?????????????????¨?????????
//???????????????op == "+" ??¨?????????if ??????????????§?????????????????????char ?????¨???pointer ???????????????????????¨????????¨????????????????????????

#include <stdio.h>

int main(void){

  int a,b,ans;
  char op;

  while(1)
      {
        scanf("%d %c %d",&a,&op,&b);//?????????????????\???????????¨???????????¨??????????????§????????????
        if(op == '?')break;
        else if(op == '+'){printf("%d\n",a + b);}
        else if(op == '-'){printf("%d\n",a - b);}
        else if(op == '*'){printf("%d\n",a * b);}
        else if(op == '/'){printf("%d\n",a / b);}
        else {break;}//???????????????????????????????????????????????????break;?????\??????
      }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int H, N;
  cin >> H >> N;
  
  for (int n=0; H>0 && n<N; ++n) {
    int a;
    cin >> a;
    H -= a;
  }
  
  cout << (H>0?"No":"Yes") << endl;

  return 0;
}


Measured memory_bytes: 256