akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string sOrig;
	int iDigit[4];
	register int i;
	cin >> sOrig;
	for (i = 0; i <= 3; ++i){
		iDigit[i] = sOrig[i] - '0';
	}
	if (iDigit[0] + iDigit[1] + iDigit[2] + iDigit[3] == 7)
		cout << iDigit[0] << '+' << iDigit[1] << '+' << iDigit[2] << '+' << iDigit[3] << "=7\n";
	else if (iDigit[0] + iDigit[1] + iDigit[2] - iDigit[3] == 7)
		cout << iDigit[0] << '+' << iDigit[1] << '+' << iDigit[2] << '-' << iDigit[3] << "=7\n";
	else if (iDigit[0] + iDigit[1] - iDigit[2] + iDigit[3] == 7)
		cout << iDigit[0] << '+' << iDigit[1] << '-' << iDigit[2] << '+' << iDigit[3] << "=7\n";
	else if (iDigit[0] - iDigit[1] + iDigit[2] + iDigit[3] == 7)
		cout << iDigit[0] << '-' << iDigit[1] << '+' << iDigit[2] << '+' << iDigit[3] << "=7\n";
	else if (iDigit[0] - iDigit[1] - iDigit[2] + iDigit[3] == 7)
		cout << iDigit[0] << '-' << iDigit[1] << '-' << iDigit[2] << '+' << iDigit[3] << "=7\n";
	else if (iDigit[0] - iDigit[1] + iDigit[2] - iDigit[3] == 7)
		cout << iDigit[0] << '-' << iDigit[1] << '+' << iDigit[2] << '-' << iDigit[3] << "=7\n";
	else if (iDigit[0] + iDigit[1] - iDigit[2] - iDigit[3] == 7)
		cout << iDigit[0] << '+' << iDigit[1] << '-' << iDigit[2] << '-' << iDigit[3] << "=7\n";
	else if (iDigit[0] - iDigit[1] - iDigit[2] - iDigit[3] == 7)
		cout << iDigit[0] << '-' << iDigit[1] << '-' << iDigit[2] << '-' << iDigit[3] << "=7\n";
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int W, H, x, y, r;
scanf("%d", &W);
scanf("%d", &H);
scanf("%d", &x);
scanf("%d", &y);
scanf("%d", &r);
if(-100 <= x && x <= 100 && -100 <= y && y <= 100){
if(0 < W && W <= 100 && 0 < H && H <= 100 && 0 < r && r <= 100){
if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
printf("Yes\n");
}
else{
printf("No\n");
}
}
}
}


Measured memory_bytes: 2608
#include<stdio.h>
int h[200005], l;
int comp_h(int a, int b)
{
	if (h[a] > h[b])
		return 1;
	else
		return -1;
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void f1(int ne)
{
	h[l] = ne;
	int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2()
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[200005], b[200005];
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	l = 0;
	for (i = 0; i < n; i++)
		f1(a[i]);
	for (i = 0; i < n; i++)
		a[i] = f2();
	l = 0;
	for (i = 0; i < n; i++)
		f1(b[i]);
	for (i = 0; i < n; i++)
		b[i] = f2();
	if (n % 2 > 0)
		printf("%d\n", b[n / 2] - a[n / 2] + 1);
	else
		printf("%d\n", b[n / 2 - 1] + b[n / 2] - a[n / 2 - 1] - a[n / 2] + 1);
	return 0;
}

Measured memory_bytes: 4076
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,int> P;

P dp[51][51]={};

ll x;
ll y;
int main() {
	int x;
	cin>>x;
	for(int i=1;i<100001;i++){
		if((i+1)*i>=2*x){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(void){
  int a,b,k;
  int ansa[100];
  cin>>a>>b>>k;
  if(k%2==1&&b-a+1<k*2){
    REP(i,b-a+1){
      cout<<a+i<<endl;
    }
    return 0;
  }
  if(b-a+1<k*2){
    REP(i,b-a+1){
      cout << a+i << '\n';
    }
    return 0;
  }
  else{
    REP(i,k){
      cout<<a+i<<endl;
    }
    REP(i,k){
      cout<<b-k+1+i<<endl;
    }
  }
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template <typename T>
inline bool chmin (T& a, T b)
{
  if(a > b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int a;
  cin >> a;
  cout << a + pow(a, 2) + pow(a, 3) << endl;
}

Measured memory_bytes: 4288
import numpy as np
 
N,Max_W = map(int,input().split())

dp = [0 for _ in range(Max_W + 1)]
dp = np.array(dp)

for i in range(N):
    w,v = map(int,input().split())
    a = dp[:-w] + v
    b = dp[w:]
    m = np.maximum(a,b)
    dp[w:] = m


print(dp[Max_W])

Measured memory_bytes: 22428
#include<iostream>
#include<cmath>
#define Int int
using namespace std;

const int MAX_NUM = 500000;
bool prime_number[MAX_NUM];
 
void isPrime() {
    fill(prime_number, prime_number + MAX_NUM, true);
    prime_number[0] = prime_number[1] = false;
 
    for(int i = 2; i < MAX_NUM; i++) {
        if(prime_number[i])
        for(int j = 2; i*j < MAX_NUM; j++) {
            prime_number[i*j] = false;
        }
    }
}
int main(void){
  int n;
  isPrime();
  while(cin>>n){
    int i;

    for(i = (!prime_number[n]?n:n-1) ; !prime_number[i] ; i --);
    cout<<i<<" ";
    for(i = (!prime_number[n]?n:n+1) ; !prime_number[i] ; i ++);
    cout<<i<<endl;
  }
}

Measured memory_bytes: 1648
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

struct graph_t {
	int n;           // |V|, index begins with 0
	int m;           // |E|
	vector<P> edges; // E
	vector<ll> cost; // cost or distance
	vector<ll> cap;  // capacity
};

class Dijkstra {
private:
	struct node {
		int id; bool done; vi to_eid; vi to; vll cost; int from_eid; int from; ll d;
		bool operator<(const node & another) const {
			return !(d != another.d ? d < another.d : id < another.id);
		}
	};
	vector<node> nodes;
	int n, source;
public:
	Dijkstra(graph_t G, int start) {
		n = G.n;
		nodes.resize(n);
		Loop(i, n) nodes[i] = { i, false,{},{},{}, -1, -1, INFLL };
		Loop(i, G.edges.size()) {
			nodes[G.edges[i].first].to_eid.push_back(i);
			nodes[G.edges[i].first].to.push_back(G.edges[i].second);
			nodes[G.edges[i].first].cost.push_back(G.cost[i]);
		}
		source = start;
		nodes[source].d = 0;
		priority_queue<node> pq;
		pq.push(nodes[source]);
		while (pq.size()) {
			node a = pq.top();
			pq.pop();
			if (nodes[a.id].done) continue;
			nodes[a.id].done = true;
			Loop(j, a.to.size()) {
				node *b = &nodes[a.to[j]];
				if (b->done) continue;
				ll buf = a.d + a.cost[j];
				if (buf < b->d) {
					b->d = buf;
					b->from_eid = a.to_eid[j];
					b->from = a.id;
					pq.push(*b);
				}
			}
		}
		return;
	}
	vi get_path(int v) {
		stack<int> stk;
		stk.push(v);
		int a = v;
		while (nodes[a].from != -1) {
			stk.push(nodes[a].from);
			a = nodes[a].from;
		}
		if (a != source) return{ -1 };
		vi ret;
		while (stk.size()) {
			ret.push_back(stk.top());
			stk.pop();
		}
		return ret;
	}
	vi get_path_eid(int v) {
		stack<int> stk;
		int a = v;
		while (nodes[a].from != -1) {
			stk.push(nodes[a].from_eid);
			a = nodes[a].from;
		}
		if (a != source) return{ -1 };
		vi ret;
		while (stk.size()) {
			ret.push_back(stk.top());
			stk.pop();
		}
		return ret;
	}
	ll get_dist(int v) {
		return nodes[v].d;
	}
};

int main() {
	int n; cin >> n;
	graph_t G;
	G.n = n;
	Loop1(i, n - 1) {
		if (i % 10 != 9) {
			G.edges.push_back({ i, (i + 1) % n });
			G.cost.push_back(1);
		}
		G.edges.push_back({ i, i * 10 % n });
		G.cost.push_back(0);
	}
	Dijkstra dijkstra(G, 1);
	cout <<  dijkstra.get_dist(0) + 1 << endl;
	return 0;
}

Measured memory_bytes: 36064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    int cur = 1;
    bool ok = false;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        if (cur == tmp) {
            if (cur == 1) ok = true;
            cur++;
        } else ans++;
    }
    if (ok) cout << ans << "\n";
    else cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100010
int main(){
	int flag,flagthen,n;
	flag=1;
	int hn[N]={0};
	scanf("%d\n",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&hn[i]);
	}
	flag=1;
	flagthen=1;
	for(int k=0;k<n-1;k++){
		//printf("%d",hn[k]);
		if(hn[k]==(hn[k+1]+1)){
			if(flagthen==1){
				hn[k]--;
				flagthen=0;
			}else if(flagthen==0){
				flag=0;
				break;
			}
		}else if(hn[k]>(hn[k+1]+1)){
			flag=0;
			break;
		}else if(hn[k]==hn[k+1]){
			if(flagthen==1){
				hn[k]--;
			}
			//flagthen=0;
		}else {
			flagthen=1;
		}
		/*for(int m=0;m<n;m++){
		printf("%d ",hn[m]);
	}
	printf("\n");*/
	}
	if(flag==0){
		printf("No\n");
	}else if(flag==1){
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  ll sum = 0;
  for(auto &a:A){cin>>a;}
  sort(ALL(A),greater<ll>());
  priority_queue<ll>que;
  que.push(A[0]);
  for(int i=1;i<n;i++){
    sum += que.top();
    que.pop();
    que.push(A[i]);
    que.push(A[i]);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 6892
//题目名称:
//日期:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
char c[330][330];
int n,m,k,now=1,ans[330][330];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%s",c[i]);
		bool emp=1;
		for(int j=0;j<m;j++)
			if(c[i][j]=='#')emp=0;
		if(emp)
		{
			if(i)
				for(int j=0;j<m;j++)
					ans[i][j]=ans[i-1][j];
		}
		else
		{
			int j;
			for(j=0;j<m;j++)
			{
				ans[i][j]=now;
				if(c[i][j]=='#')break;
			}
			for(j++;j<m;j++)
			{
				if(c[i][j]=='#')now++;
				ans[i][j]=now;
			}
			now++;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(ans[i][0]==0)
			for(int j=0;j<m;j++)
				ans[i][j]=ans[i+1][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1280
#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 MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, 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; }

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vvi G(n, vi(26));
  rep(i, n){
    string s; cin >> s;
    for(char c : s){
      G[i][c-'a']++;
    }
  }
  vi C(26,100);
  rep(i, n){
    rep(c, 26){
      chmin(C[c], G[i][c]);
    }
  }
  string ans;
  rep(c, 26){
    rep(i, C[c]){
      ans += (char)('a'+c);
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <set>

using namespace std;

int col[24], on[24];
set<int> S;

int search(int cur, int n){
	if(S.count(cur)) return 0;
	S.insert(cur);
	int res = 0;
	for(int i=0;i<n;i++){
		if(!(cur&(1<<i))||(on[i]&cur)) continue;
		for(int j=i+1;j<n;j++){
			if(col[i]!=col[j]||!(cur&(1<<j))||(on[j]&cur)) continue;
			res = max(res, 2+search(cur^(1<<i)^(1<<j), n));
		}
	}
	return res;
}

int main(){
	int n;
	int x[24], y[24], r[24];
	while(cin >> n, n){
		S.clear();
		for(int i=0;i<n;i++){
			cin >> x[i] >> y[i] >> r[i] >> col[i];
			on[i] = 0;
			for(int j=0;j<i;j++){
				if(hypot(x[i]-x[j], y[i]-y[j]) < r[i]+r[j]-1e-8) on[i] |= (1<<j);
			}
		}
		cout << search((1<<n)-1, n) << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
using namespace std;
#define L0 2
#define L1 1

int main() {
  int N ;
  long long int L[87] ;
  scanf("%d", &N) ;
  L[0]=L0;
  L[1]=L1;
  for(int i=1; i<N; i++){
    L[i+1]=L[i]+L[i-1];
  }
  printf("%lld", L[N]) ;
  return 0 ;
}

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

int main() {
  int x,n;
  cin>>x>>n;
  map<int,int> mp;
  if(n==0){
    cout<<x<<endl;
    return 0;
  }
  rep(i,n){
    int p;
    cin>>p;
    mp[p]=1;
  }
  bool flag=0;
  int ans=x;
  if(mp[x]!=1){
    cout<<x<<endl;
    return 0;
  }
  for(int i=1; i<=130; i++){
    if(mp[x+i]!=1){
      ans=x+i;
      flag=1;
    }
    if(mp[x-i]!=1){
      ans=x-i;
      flag=1;
    }
    if(flag){
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k=sc.nextInt();
		int x=sc.nextInt();
		int s=x-k+1;
		int s2=x+k-1;
		for(int i=s;i<=s2;i++){
			System.out.println(i);
		}


	}
}



Measured memory_bytes: 21844
#include<stdio.h>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n;
	int tmp;
	string s;
	cin >> n >> s;
	rep(s.size()) {

		if (s.at(i) + n > 90) {

			tmp = s.at(i)-90 + n-3;
			s.at(i) = 67 + tmp;
		}
		else {
			s.at(i) += n;
		}

	}
	cout << s;

}

Measured memory_bytes: 888
x, y = list(map(int, input().split()))
group = 0

while True:
    if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
        if y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
            print("Yes")
            break

    if x == 4 or x == 6 or x == 9 or x == 11:
        if y == 4 or y == 6 or y == 9 or y == 11:
            print("Yes")
            break

    if x == 2 and y == 2:
        print("Yes")
        break

    print("No")
    break

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

void solve(){
    ll n,m;
    ll ans;

    while(cin>>n>>m,n|m){
        vector<ll> v,sum_v;

        for(ll i=0;i<n;i++){
            ll t;
            cin >> t;
            v.push_back(t);
        }

        v.push_back(0);

        for( auto t:v ){
            for( auto s:v ){
                sum_v.push_back(t+s);
            }
        }

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

        ans=-1;
        for( auto t:sum_v ){
            if( binary_search(sum_v.begin(),sum_v.end(),m-t) ){
                ans=m;
                break;
            }else{
                auto it=upper_bound(sum_v.begin(),sum_v.end(),m-t);
                if( it != sum_v.begin() ){
                    ans=max(ans,t + *(--it));
                }
            }
        }

        cout<<ans<<endl;
    }
}

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

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

int main(){
	int n, m, in, b, c, left;
	long long res;
	pair<int, int> p;
	vector<pair<int, int>> a;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> in;
		a.push_back({in, 1});
	}
	for(int i=0; i<m; i++){
		cin >> b >> c;
		a.push_back({c, b});
	}
	sort(a.begin(), a.end());
	res = 0;
	left = n;
	for(int i=a.size()-1; i>=0; i--){
		if(a[i].second < left){
			res += ((long)a[i].second)*a[i].first;
			left -= a[i].second;
		}else{
			res += ((long)left)*a[i].first;
			break;
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2420
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
struct node
{
	int x,y;
}a[200010];
int n;
long long ans=4e18,mnx=2e9,mny=2e9,mxx,mxy;
multiset<int> sx,sy;
bool cmp(node x,node y)
{
	return x.x<y.x;
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if (x>y)
		{
			swap(x,y);
		}
		a[i].x=x;
		a[i].y=y;
		sx.insert(x);
		sy.insert(y);
		mxx=max(mxx,1LL*x);
		mxy=max(mxy,1LL*y);
		mnx=min(mnx,1LL*x);
		mny=min(mny,1LL*y);
	}
	sort(a,a+n,cmp);
	ans=min(ans,(mxx-mnx)*(mxy-mny));
	for (int i=0;i<n;i++)
	{
		sx.erase(sx.find(a[i].x));
		sy.insert(a[i].x);
		sy.erase(sy.find(a[i].y));
		sx.insert(a[i].y);
		ans=min(ans,1LL*(*sx.rbegin()-*sx.begin())*(*sy.rbegin()-*sy.begin()));
	}
	printf("%lld\n",ans);
    return 0;
}
//人到情多情转薄，而今真个悔多情。
//——纳兰性德《山花子》

Measured memory_bytes: 20608
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int tmp = 0;
  srep(i,1,b+1){
    tmp=i*a%b;
    if(tmp == c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
struct S{
    mint val, unit;
};
S op(S a, S b){
    return {a.val + b.val, a.unit + b.unit};
}
S e(){
    return {0, 0};
}
S mapping(int f, S x){
    if(f != 0){
        x.val = f * x.unit;
    }
    return x;
}
int composition(int f, int g){
    if(f != 0){
        return f;
    }
    return g;
}
int id(){
    return 0;
}
int main(){
    int n, q;
    cin >> n >> q;
    vector<S>v(n);
    mint pw = 1;
    for(int i = n - 1; i >= 0; i--){
        v[i] = {pw, pw};
        pw *= 10;
    }
    lazy_segtree<S, op, e, int, mapping, composition, id>seg(v);
    for(int i = 1; i <= q; i++){
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().val.val() << '\n';
    } 
    return 0;
}

Measured memory_bytes: 9880
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a<b) {cout<<"No"<<endl;continue;}
        if(d<b) {cout<<"No"<<endl;continue;}
        if(c>=b) {cout<<"Yes"<<endl;continue;}
        ll tmp = gcd(b,d%b);
        ll k = (b-a%b-1)/tmp*tmp+a%b;
        if(c+1 <= k && k <= b-1) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
H,W=map(int,input().split())
if H*W%3==0:print(0)
else:
    a,b,c=(W//3)*H,(H//2)*(W-W//3),(H-H//2)*(W-W//3)
    H1=max(a,b,c)-min(a,b,c)
    d,e,f=((W//3)+1)*H,(H//2)*(W-(W//3)-1),(H-H//2)*(W-(W//3)-1)
    H2=max(d,e,f)-min(d,e,f)
    p,q,r=(H//3)*W,(W//2)*(H-H//3),(W-W//2)*(H-H//3)
    W1=max(p,q,r)-min(p,q,r)
    s,t,u=((H//3)+1)*W,(W//2)*(H-(H//3)-1),(W-W//2)*(H-(H//3)-1)
    W2=max(s,t,u)-min(s,t,u)
    print(min(H1,H2,W1,W2,H,W))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,r;
    cin>>n>>d;
    int a[n][d];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            cin>>a[i][j];
        }
    }

    int ans=0;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int sum=0;

            for(int k=0;k<d;k++)
            {
                sum+=pow(a[i][k]-a[j][k],2);
            }

            r=sqrt(sum);

            if(r*r==sum)
            {
                ans++;
            }
        }
    }

    cout<<ans<<endl;
    exit(0);
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
map<string, int> m;

int main(void) {
    int n; 
    cin >> n;
    rep(i, 0, n) {
        string s;
        cin >> s;
        m[s]++;
    }

    printf("AC x %d\n", m["AC"]);
    printf("WA x %d\n", m["WA"]);
    printf("TLE x %d\n", m["TLE"]);
    printf("RE x %d\n", m["RE"]);


    return 0;
}



Measured memory_bytes: 3732
program main
   implicit none
   integer::n,i,counter=0
   integer,allocatable,dimension(:)::v,c
   read(*,*)n
   allocate(v(n),c(n))
   read(*,*)v
   read(*,*)c
   v=v-c
   call heapsort(n,v)
   do i=n,1,-1
      if(v(i)<0)exit
      counter=counter+v(i)
   enddo
   write(*,*)counter
contains
subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  
  integer ::i,k,j,l
  integer :: t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort
end program main


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,m;
  cin>>n>>m;

  vll x(n),y(m);
  REP(i,n)
    cin>>x[i];
  REP(i,m)
    cin>>y[i];

  ll xsum=0;
  ll ysum=0;
  REP(i,n)
    xsum = (xsum + (i-(n-i-1))*x[i])%MOD;
  REP(i,m)
    ysum = (ysum + (i-(m-i-1))*y[i])%MOD;

  ll ans = (xsum*ysum)%MOD;
  cout<<ans<<endl;

}


Measured memory_bytes: 1792
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    use = N//11
    rest = N%11
    if rest == 0:
        print(2*use)
    elif rest <= 6:
        print(2*use+1)
    else:
        print(2*use+2)

if __name__ == "__main__":
    main()

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

const int N=1e4+10,Mod=998244353;

int n,dp[N][N],fact[N],inv[N],cnt,dif,sam;
char A[N],B[N];

void Init() {
	scanf("%s%s",A,B); 
	n=strlen(A);
	for (int i=0;i<n;++i) if (A[i]=='1') ++cnt;
	for (int i=0;i<n;++i) if (B[i]=='1' && A[i]=='1') sam++;
	dif=cnt-sam;
}

int Calc(int n,int m) { return 1ll*fact[n]*inv[n-m]%Mod*inv[m]%Mod; }

void Solve() {
	fact[0]=1; for (int i=1;i<=cnt;++i) fact[i]=1ll*fact[i-1]*i%Mod;
	inv[0]=inv[1]=1;  for (int i=2;i<=cnt;++i) inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	for (int i=1;i<=cnt;++i) inv[i]=1ll*inv[i]*inv[i-1]%Mod;
	for (int i=0;i<=dif;++i) dp[0][i]=1ll*fact[i]*fact[i]%Mod;
	for (int i=1;i<=sam;++i)
		for (int j=1;j<=dif;++j)
			dp[i][j]=(1ll*dp[i-1][j]*i+1ll*dp[i][j-1]*j)%Mod*j%Mod;
	int ans=0;
	for (int j=0;j<=sam;++j)
		ans=(ans+1ll*dp[sam-j][dif]*fact[j]%Mod*fact[j]%Mod*Calc(sam,j)%Mod*Calc(cnt,j))%Mod;
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 389632
import java.util.*;
import java.io.*;
 
public class Main {
 
	public static void main(String[] args)throws IOException {
		Scanner sc =new Scanner(System.in);
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		
		int A = sc.nextInt();
		int[]arr = new int[A];
		
		for(int i=0; i<arr.length; i++) {
			arr[i] = sc.nextInt();
		}
		
			sc.close();
		int howmany =0;
		
		for(int i=0; i<arr.length; i++){
			if(arr[i] == i+1) {
				swap(arr,i);
				howmany += 1;
			}
		}
		
		System.out.println(howmany);
 
	}
	
	public static void swap(int[] arr, int j) {
		if(j != arr.length-1) {
			int a = arr[j];
			arr[j] = arr[j+1];
			arr[j+1] = a;
		}
	}
 
}

Measured memory_bytes: 59724
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


int main()
{
    long long int a, b;
    cin >> a >> b;
    long long int maxNum;
    maxNum = max(a, b);
    for (int k = 0; k < maxNum; k++) {
        if (abs(a - k) == abs(b - k)) {
            cout << k << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
    char s1[10],s2[10];

    cin >> s1;
    cin >> s2;

    if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
        cout << "YES";
    else
        cout << "NO";


}

Measured memory_bytes: 256
#include <stdio.h>

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

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

int main() {
	int Q; cin >> Q;
	for (int _ = 0; _ < Q; ++_) {
		int res = 0;
		string S[2]; cin >> S[0] >> S[1];

		if (S[0] == S[1]) {
			cout << 0 << endl;
			continue;
		}

		int n = S[0].size();

		int ichi = 0;
		int zerogawa = 0;
		bool allzero = true;
		for (int i = 0; i < n; ++i) {
			if (S[0][i] != S[1][i]) {
				ichi = i;
				break;
			}
		}
		if (S[0][ichi] == '0') zerogawa = 0;
		else zerogawa = 1;
		for (int i = ichi; i < n; ++i) {
			if (S[zerogawa][i] == '1') allzero = false;
		}

		if (allzero) {
			int first = 0;
			for (int i = ichi; i >= 0; --i) {
				if (S[zerogawa][i] == '1') {
					first = i;
					break;
				}
			}
			ichi = first;
		}

		for (int iter = 0; iter < 2; ++iter) {
			int second = ichi;
			for (int i = ichi; i < n; ++i) {
				if (S[iter][i] == '1') {
					second = i;
				}
			}
			res += second - ichi;
		}
		cout << res << endl;
	}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly Dictionary<char, string> dic1 = new Dictionary<char, string>()
        {
            {'A',"00000" }, {'B',"00001" }, {'C',"00010" }, {'D',"00011" },
            {'E',"00100" }, {'F',"00101" }, {'G',"00110" }, {'H',"00111" },
            {'I',"01000" }, {'J',"01001" }, {'K',"01010" }, {'L',"01011" },
            {'M',"01100" }, {'N',"01101" }, {'O',"01110" }, {'P',"01111" },
            {'Q',"10000" }, {'R',"10001" }, {'S',"10010" }, {'T',"10011" },
            {'U',"10100" }, {'V',"10101" }, {'W',"10110" }, {'X',"10111" },
            {'Y',"11000" }, {'Z',"11001" }, {' ',"11010" }, {'.',"11011" },
            {',',"11100" }, {'-',"11101" }, {'\'',"11110" }, {'?',"11111" }
        };

        static readonly Dictionary<string, char> dic2 = new Dictionary<string, char>()
        {
            {"101"      ,' ' }, {"000000"   ,'\'' },
            {"000011"   ,',' }, {"10010001" ,'-' },
            {"010001"   ,'.' }, {"000001"   ,'?' },
            {"100101"   ,'A' }, {"10011010" ,'B' },
            {"0101"     ,'C' }, {"0001"     ,'D' },
            {"110"      ,'E' }, {"01001"    ,'F' },
            {"10011011" ,'G' }, {"010000"   ,'H' },
            {"0111"     ,'I' }, {"10011000" ,'J' },
            {"0110"     ,'K' }, {"00100"    ,'L' },
            {"10011001" ,'M' }, {"10011110" ,'N' },
            {"00101"    ,'O' }, {"111"      ,'P' },
            {"10011111" ,'Q' }, {"1000"     ,'R' },
            {"00110"    ,'S' }, {"00111"    ,'T' },
            {"10011100" ,'U' }, {"10011101" ,'V' },
            {"000010"   ,'W' }, {"10010010" ,'X' },
            {"10010011" ,'Y' }, {"10010000" ,'Z' }
        };

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while ((input = Console.ReadLine()) != null)
            {
                string nums = "";

                for (int i = 0; i < input.Length; i++)
                {
                    nums += dic1[input[i]];
                }

                bool flg = true;
                string res = "";

                while (flg)
                {
                    flg = false;

                    for (int i = 3; i <= 8; i++)
                    {
                        if (nums.Length < i) continue;

                        string sub = nums.Substring(0, i);

                        if (dic2.ContainsKey(sub))
                        {
                            res += dic2[sub];
                            nums = nums.Substring(i);
                            flg = true;
                            break;
                        }
                    }
                }
                sb.AppendLine(res);
            }
            Console.Write(sb);
        }
    }
}

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

#define ll long long int
using namespace std;
int main()
{
    int n,t,a,p;
    double x,b,c,m=1e9;
    cin>>n>>t>>a;
    for(int i=0;i<n;i++)
    {
        cin>>c;
        b = t-c*.006;
        x = abs(a-b);
        if(x<m)
        {
            m = x;
            p= i+1;
        }
    }
    cout<<p<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int n;
  bool flag=true;
  cin>>n;
  for(int i=1;i<50000;i++){
    if(static_cast<int>(i*1.08)==n){
      cout<<i<<endl;
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int col[207],s[207],n;
char ss[207][207];
int bfs(int x){
    int l=0,r=0;
    for(int i=1;i<=n;i++)
        col[i]=0;
    s[++r]=x;
    col[x]=1;
    while(l<r){
        x=s[++l];
        for(int i=1;i<=n;i++)
            if(ss[x][i]-'0'){
                if(col[i]==0){
                    col[i]=col[x]+1;
                    s[++r]=i;
                }
                else if(abs(col[i]-col[x])!=1)
                    return -1;
            }
    }
    return col[s[r]];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ans=-1;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>ss[i]+1;
    for(int i=1;i<=n;++i)
        ans=max(ans,bfs(i));
    printf("%d",ans);
}


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

class Fermat{
  private:
	int z;
	vector<ll> fact_mod, fact_invmod;
	ll modpow(ll a, ll n){
		if(n==1)return a;
		ll half=modpow(a,n/2);
		return (n%2?modpow(a,n-1)*a:half*half)%MOD;
	}
  public:
	Fermat(int Z):z(Z){
		fact_mod=vector<ll>(z+1,1);
		fact_invmod.resize(z+1);
		range(i,1,z+1) fact_mod[i]=fact_mod[i-1]*i%MOD;
		fact_invmod[z]=modpow(fact_mod[z],MOD-2);
		for(int i=z-1;i>=0;i--) fact_invmod[i]=fact_invmod[i+1]*(i+1)%MOD;
	}
	ll comb(int n,int r){return fact_mod[n] * fact_invmod[r]%MOD * fact_invmod[n-r]%MOD;}
};

int main(){
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    if(b<a)swap(a,b);
    Fermat f(n);
    ll ans=0;
    rep(i,n+1){
        if((k-a*i)%b==0 and (k-a*i)/b>=0 and (k-a*i)/b<=n){
            ans=(ans+f.comb(n,i)*f.comb(n,(k-a*i)/b))%MOD;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const ll mod = 1e9+7;
// find common elm in each mult and times it together but dont want to double count
void solve(){
    int n; cin >> n;
    ll a[n], b[n], summ = 0;
    FOR(n){
        cin >> a[i];
        summ += a[i];
    }
    b[0] = summ - a[0];
    FOR(i,1,n) b[i] = b[i-1] - a[i];
    ll ans = 0;
    FOR(n){
        ans += ((a[i]%mod) * (b[i]%mod))%mod;
        ans %= mod;
    }
    cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 



Measured memory_bytes: 6776
N,D = map(int,input().split())
x = [list(map(int,input().split())) for i in range(N)]
count = 0

for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            tmp += abs(x[i][k]-x[j][k])**2
        tmp = tmp**0.5
        if tmp.is_integer() == True:
            count += 1
print(count)

Measured memory_bytes: 3064
#include<cstdio>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    n %= 10;
    if (n == 1 || n == 0 || n == 6 || n == 8) printf("pon");
    else if (n == 3) printf("bon");
    else printf("hon");
    return 0;
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B, C;
	cin >> A >> B >> C;

	int OK = 0;
	rep(i, A + 1) {
		int D = C + B * i;
		if (D % A == 0) OK = 1;
	}

	if (OK) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    dishes = list()
    ans = 0

    # See:
    # https://poporix.hatenablog.com/entry/2019/01/28/222905
    # https://misteer.hatenablog.com/entry/NIKKEI2019qual?_ga=2.121425408.962332021.1548821392-1201012407.1527836447
    for i in range(n):
        ai, bi = map(int, input().split())
        dishes.append(tuple([ai + bi, ai, bi]))

    for index, dish in enumerate(sorted(dishes, reverse=True)):
        if index % 2 == 0:
            ans += dish[1]
        else:
            ans -= dish[2]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21744
N = gets.to_i
D = gets.chomp.split(" ").map(&:to_i)

countD = Array.new(D.max + 1, 0)

D.each{|d|
  countD[d] += 1
}

if D[0] != 0 then
  puts 0
elsif D[1...N].include?(0)
  puts 0
else
  ans = 1
  for i in 1...countD.length do
    ans = ans * (countD[i-1] ** countD[i]) % 998244353
  end
  puts ans
end


Measured memory_bytes: 9484
#include <iostream>
#include <cstdio>
#include <cmath> 
#include <cstdlib>
using namespace std;

int main()
{
	int i;
    double n,x[1001],y[1001],sum,d,p,max=0;
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=0;i<n;i++){
		cin>>y[i];
	}
	for(p=1;p<4;p++){
		for(i=0,sum=0;i<n;i++){
			sum+=pow(fabs(x[i]-y[i]),p);
			if(max < fabs(x[i] - y[i])) max = fabs(x[i] - y[i]);
		}
		d=pow(sum,1.0/p);
		printf("%10f\n",d);
	}
	printf("%10f\n",max);
    return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEND(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,N;
    cin>>H>>N;
    vector<pair<int,int>> tech;
    rep(n,0,N){
        int a,b;
        cin>>a>>b;
        tech.push_back(make_pair(a,b));
    }

    vector<vector<uint64_t>> dp(N+1,vector<uint64_t>(H+1,UINT64_MAX));
    rep(n,1,N+1){
        rep(h,1,H+1){
            if(h>tech.at(n-1).first){
                dp.at(n).at(h)=min(dp.at(n-1).at(h),
                    dp.at(n).at(h-tech.at(n-1).first)+tech.at(n-1).second);
            }else{
                dp.at(n).at(h)=min(dp.at(n-1).at(h),(uint64_t)tech.at(n-1).second);
            }
        }
    }
    cout<<dp.at(N).at(H)<<endl;
}

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

using namespace std;

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

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

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

pll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A + N, [](pll a, pll b) { return a.first < b.first; });
    ll ans = 0;
    REP(i, N) {
        ll t = std::min(A[i].second, M);
        ans += A[i].first * t;
        M -= t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;

ll pmod(ll n,ll p,ll m){
  ll r=1;
  while(p>0){
    if(p%2==1) r=r*n%m;
    p/=2;
    n=n*n%m;
  }
  return r;
}

int main(){
  ll a,b,c=0,d=1,e=1,f=1,g,h,m,n,ans=0;
  cin>>n>>a>>b;
  d=pmod(2,n,mod); d--;
  ll au=1,ad=1,bu=1,bd=1;
  rep(i,0,a) au=au*(n-i)%mod;
  rep(i,0,b) bu=bu*(n-i)%mod;
  rep(i,2,a+1) ad=ad*i%mod;
  rep(i,2,b+1) bd=bd*i%mod;  
  e=pmod(ad,mod-2,mod); e%=mod;
  f=pmod(bd,mod-2,mod); f%=mod;
  au=au*e; au%=mod;
  bu=bu*f; bu%=mod;  
  d-=au; if(d<0) d+=mod;
  d-=bu; if(d<0) d+=mod;
  co(d);
  
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    std::vector<std::string> table(h);
    for (auto& row : table)
    {
        cin >> row;
    }

    const auto size = h * w;

    std::vector<std::vector<std::size_t>> dist_table(
        size, std::vector<std::size_t>(size, std::numeric_limits<std::uint32_t>::max()));

    for (int i = 0; i < size; i++)
    {
        dist_table[i][i] = 0;
    }

    for (int y = 0; y < h; y++)
    {
        for (int x = 0; x < w; x++)
        {
            if (y > 0 && table[y][x] == '.' && table[y - 1][x] == '.')
            {
                const auto idx1 = y * w + x;
                const auto idx2 = (y - 1) * w + x;
                dist_table[idx1][idx2] = dist_table[idx2][idx1] = 1;
            }
            if (x > 0 && table[y][x] == '.' && table[y][x - 1] == '.')
            {
                const auto idx1 = y * w + x;
                const auto idx2 = y * w + x - 1;
                dist_table[idx1][idx2] = dist_table[idx2][idx1] = 1;
            }
        }
    }

    for (int k = 0; k < size; k++)
    {
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                dist_table[i][j] = min(dist_table[i][j], dist_table[i][k] + dist_table[k][j]);
            }
        }
    }

    int ans = 0;
    for (auto& row : dist_table)
    {
        for (auto dist : row)
        {
            if (dist < std::numeric_limits<std::uint32_t>::max())
            {
                ans = std::max<int>(ans, dist);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
n = int(input())
h = [int(i) for i in input().split()]
d = [float('inf')] * n
d[0] = 0

def check_min(a, b):
    if a > b:
        a = b
    return a

for i in range(1, n):
    d[i] = check_min(d[i], d[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        d[i] = check_min(d[i], d[i - 2] + abs(h[i] - h[i - 2]))
print(d[n - 1])

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n;
string s;
int cnt0[300010],cnt1[300010];

int main(){
  cin>>n>>s;
  rep(i,n){
    if(s[i]=='E'){
      cnt0[i+1]=cnt0[i]+1;
    }else cnt0[i+1]=cnt0[i];
  }
  for(int i=n;i>=1;i--){
    if(s[i-1]=='E'){
      cnt1[i-1]=cnt1[i]+1;
    }else cnt1[i-1]=cnt1[i];
  }
  int res=INF;
  rep(i,n){
    minch(res,i-cnt0[i]+cnt1[i+1]);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3076