akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

int main() 
{
	int n; 
	while(~scanf("%d", &n)) {
		long long res = 0, ans = 0;
		int cnt = 0; int Min = 1 << 30;
		for (int i = 1; i <= n; i++) {
			int A, B; scanf("%d%d", &A, &B);
			res += A;
			if(A > B) Min = min(Min, B);
			else if(A == B) cnt++;
		}
		if(cnt != n) printf("%lld\n", res - Min);
		else printf("0\n");
	}
	return 0;
}


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

int H, W;
const int MAX_HW = 1000;
char A[MAX_HW][MAX_HW];

int black() {
    int res = 0;
    queue<pair<int, int> > que;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') que.push(make_pair(i, j));
        }
    }

    while (que.size() > 0) {
        int size_of_que = que.size();
        for (int k = 0; k < size_of_que; k++) {
            int i = que.front().first;
            int j = que.front().second;
            que.pop();

            if (i - 1 >= 0) {
                if (A[i-1][j] == '.') {
                    A[i-1][j] = '#';
                    que.push(make_pair(i-1, j));
                }
            }
            if (j - 1 >= 0) {
                if (A[i][j-1] == '.') {
                    A[i][j-1] = '#';
                    que.push(make_pair(i, j-1));
                }
            }
            if (i + 1 < H) {
                if (A[i+1][j] == '.') {
                    A[i+1][j] = '#';
                    que.push(make_pair(i+1, j));
                }
            }
            if (j + 1 < W) {
                if (A[i][j+1] == '.') {
                    A[i][j+1] = '#';
                    que.push(make_pair(i, j+1));
                }
            }
        }
        res++;
    }

    return res - 1;
}
 
int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    int ans = black();

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

Measured memory_bytes: 9360
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int a, b;

    if(scanf("%d %d", &a, &b) == 1);

    if(a * b % 2 == 0) {
        printf("No");
    } else {
        printf("Yes");
    }
}

Measured memory_bytes: 128
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc123_a.cpp
 * time   : Fri May  1 16:21:04 2020
 * quest  : A - Five Antennas
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << ((b - a <= k && c - a <= k && d - a <= k && e - a <= k && c - b <= k && d - b <= k && e - b <= k && d - c <= k && e - c <= k && e - d <= k) ? "Yay!\n" : ":(\n");
  return 0;
}


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

int cost(int X, int P) { return pow(X - P, 2); }

int main(void) {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  int min = INT_MAX;
  for (int i = 1; i < 101; i++) {
    int total = 0;
    for (int j = 0; j < N; j++) {
      total += cost(X[j], i);
    }
    if (total < min) {
      min = total;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
def resolve():
	from collections import Counter

	def prime_factorize(n):
		a = []
		i = 2
		while i < n**(1/2) + 1:
			if n%i == 0:
				n //= i
				a.append(i)
			else:
				i += 1
		if n != 1:
			a.append(n)
		return a
	
	def cnt(x):
	    ans = 0
	    i = 1
	    while True:
	        ans += i
	        if ans > x:
	            return i-1
	        i += 1
	        
	n = int(input())
	ans = 0

	a = Counter(prime_factorize(n))
	for i in a.values():
	    ans += cnt(i)

	print(ans)

resolve()

Measured memory_bytes: 9688
# B - Popular Vote

N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
V = 0

for a in A:
    V += a

if A[M - 1] < V / (4 * M):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	var sum float64
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scanf("%d", &x)

		sum += 1 / float64(x)
	}

	sum = 1 / sum
	fmt.Println(sum)
}


Measured memory_bytes: 512
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

signed main()
{
	int n;
	while (cin >> n&&n)
	{
		int ans = 0;
		bool ok = false;
		FOR(i, n)
		{
			INT(x);
			if (x > 1)ok = true;
			if(x)ans++;
		}
		if (ok)cout << ans+1 << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 3124
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

int main(){

  struct Card C1[101], C2[101],C3;
  int n,i,j,mini,hantei = 0;
  char ch;
  
  scanf("%d%c", &n, &ch);

  for ( i = 0; i < n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value,&ch);
  }
  
  
  for(i = 0 ; i < n  ; i++ ){
    C2[i] = C1[i];
  }
  
  
  //for(i=0;i<n;i++)printf("%c%c ",C1[i].suit,C1[i].value);
  
  
  for(i = 0 ; i <= n - 1 ; i++){
    
    for(j = n - 1 ; j >= i + 1 ; j--){
      
      if(C1[j].value < C1[j - 1].value){
	
      	C3 = C1[j];
	C1[j] = C1[j - 1];
      	C1[j - 1] = C3;
	
      }
    }
  }
  
  
  for(i = 0 ; i <= n - 1 ; i++){
    mini = i;
    for(j = i ; j <= n - 1 ; j++){
      
      if(C2[j].value < C2[mini].value){

	mini = j;
	
      }
    }
    if(mini != i) {
      
      C3 = C2[i];
      C2[i] = C2[mini];
      C2[mini] = C3;
      
    }
  }

  for(i = 0 ; i < n  ;i++ ){
    if(i) printf(" ");    
    printf("%c%c",C1[i].suit,C1[i].value);
  }
  printf("\n");
  printf("Stable\n");

  for(i = 0 ; i < n  ;i++ ){
    if(i) printf(" ");    
    printf("%c%c",C2[i].suit,C2[i].value);
    if(C1[i].suit == C2[i].suit) hantei++;
  }
  if(hantei == n) printf("\nStable\n");
  else printf("\nNot stable\n");
  
  
  return 0;
}

Measured memory_bytes: 612
N, K = map(int, input().split())
B = []
for i in range(1,N+1):
    count = 0
    while i < K:
        i *= 2
        count += 1
    B.append(count)

result = 0
for a in B:
    result += 1/N*0.5**a

print(result)

Measured memory_bytes: 3864
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n;j++){
      for (int k = j + 1; k < n;k++){
        if(a[i]==a[j]or a[j]==a[k] or a[k]==a[i])continue;
        if (a[i] + a[j] + a[k] - max({a[i], a[j], a[k]}) >
            max({a[i], a[j], a[k]}))cnt++;
      }
    }
  }
  cout<<cnt<<endl;
}


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


int main() {
  int n = 0 ;
  cin >> n ;
  
  vector<int> a( n ), b( n ), c( n-1 ) ;
  rep( i, n ) cin >> a[i] ;
  rep( i, n ) cin >> b[i] ;
  rep( i, n-1 ) cin >> c[i] ;
  
  int iSatisfaction = 0 ;
  rep( i, n ) {
    iSatisfaction += b[a[i]-1] ;
    if ( i > 0 && a[i]-a[i-1] == 1 ) {
      iSatisfaction += c[ a[i-1]-1 ] ;
    }
  }
  
  cout << iSatisfaction << endl ;
  return 0 ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,h,w,t,ans=INF,ans2=0;
string s,S;
int main() {
ios_base::sync_with_stdio(false);
  cin >> h >> w;
  vstr(C,h);
  REP(i,h){
    cout << C[i] <<endl<<C[i]<<endl;

  }
  }

Measured memory_bytes: 3652
class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


V, E = map(int, input().split())
uft = UnionFind(V)
l = [tuple(map(int, input().split())) for _ in range(E)]
l.sort(key=lambda x:x[2])

ans = 0
for s, t, w in l:
    s += 1; t += 1
    if not uft.isunited(s, t):
        ans += w
        uft.unite(s, t)

print(ans)


Measured memory_bytes: 25460
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N), card(N);
   for (int i = 0; i < N; i++) {
     cin >> vec.at(i);
   }
   for (int i = 0; i < N; i++) {
     int a = vec.at(i);
       for (int i = 0; i < N; i++) {
         if (vec.at(i) == a)
           card.at(i) ++;
       }
   }
  int x = 0;
   for (int i = 0; i < N; i++) {
     int b = 0;
      for (int i = 0; i < N; i++) {
        if(vec.at(i) > b && card.at(i) >= 1)
          b = vec.at(i);
      }
     for (int i = 0; i < N; i++) {
       if (vec.at(i) == b)
         card.at(i) --;
     }
     if (i % 2 == 0)
       x += b;
     else
       x -= b;
   }
  cout << x << endl;
}

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

int main(){
    int n;
    cin >> n;
    string ans = "APPROVED";
    int x;
    for (int i=0;i<n;i++){
        cin >> x;
        if (x % 2 == 0){
            if (x % 3 != 0 && x % 5 != 0){
                ans = "DENIED";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

bool loading(int n, int k, int w[],long long maxAmount) {
	int cnt = 1;
	long long amount = 0;
	for (int i = 0; i < n; i++) {
		if (w[i] > maxAmount)return false;
		if (amount + w[i] <= maxAmount) {
			amount += w[i];
		}
		else {
			cnt++;
			amount = w[i];
		}
		if (k < cnt)return false;
	}
	return true;
}

int main() {
	int n;
	int k;
	int w[100000];
	long long min, max, mid;

	long long maxAmount = 1000000000;

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	
	min = 0;
	max = maxAmount;
	while (min < max) {
		mid = (min + max) / 2;
		if (loading(n, k, w, mid)) {
			maxAmount = mid;
			max = mid;
		}
		else {
			min = mid + 1;
		}
	}

	cout << maxAmount << endl;
	return 0;
}

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

int main() {
    int x, y; cin >> x >> y;
    auto f = [] (int v) {
        return max(0, 4 - v);
    };
    cout << (f(x) + f(y) + (x + y == 2 ? 4 : 0)) * 100000 << endl;
}


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

SortedP = P.copy()
SortedP.sort()
count=0
for i in range(N):
    if(P[i]!=SortedP[i]):
        count = count + 1
    if(count>2):
        print("NO")
        break
else:print("YES")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string str;
    cin >> str;
    vector<long long int> vec;
    for(long long int i=0; i<str.size(); i++) {
        if(str[i]=='W') {
            vec.push_back(i);
        }
    }
    
    long long int ans=0;
    for(int i=0; i<vec.size(); i++) {
        ans += vec[i]-i;
    }
    cout << ans << endl;
    

    return 0;
    
}

Measured memory_bytes: 2680
#include <stdio.h>
int divs(int a){
	int div = 2;
	for(int i = 3; i < a/2+1; i+= 2){
		if(a%i == 0) div++;
	}
	return div;
}
int main(){
	int n, qnt = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i+= 2){
		if(divs(i) == 8) qnt++;
	}
	printf("%d\n", qnt);
	return 0;
}


Measured memory_bytes: 128
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int k, n;
	cin >> k >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) cin >> arr[i];
	int ans = arr.back()-arr.front();
	for(int i = 1; i < n; i++) {
		ans=min(ans, k-arr[i]+arr[i-1]);
	}
	cout << ans;

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using int64 = long long;

int64 solve(int N, vector<int64> A) {
  int64 res = 0;
  unordered_map<int64, int64> m;
  REP(i, N) {
    auto it = m.find(i - A[i]);
    if (it != m.end()) {
      res += it->second;
    }
    m[A[i] + i] += 1;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int64> A(N);
  for (auto&& x : A) {
    cin >> x;
  }
  cout << solve(N, move(A)) << endl;
}


Measured memory_bytes: 12856
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int sum = 0;
    for (int i = 0; i < N; i++) {
      string[] input = Console.ReadLine().Split(' ');
      sum += (int.Parse(input[1]) - int.Parse(input[0]) + 1);
    }
    Console.WriteLine(sum);
  }
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N,W;
  cin >> N >> W;
  VI w(N),v(N);
  REP(i,N){
    cin >> w.at(i) >> v.at(i);
  }
  
  VVLL DP(N+1,VLL(W+1));
  
  REP(i,N){
    REP(j,W+1){
      if(j < w.at(i)){ 
        DP.at(i+1).at(j) = DP.at(i).at(j);
      }else{
        DP.at(i+1).at(j) = max(DP.at(i).at(j),DP.at(i).at(j-w.at(i))+v.at(i));
      }
    }
  }
  cout << DP.at(N).at(W) << endl;
  
  return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    int cnt = 0;
    rep(i, N){
        int a;
        cin >> a;
        if(a % 2 == 1) cnt++;
    }
    
    if(cnt % 2 == 0){
        output("YES");
    }
    else output("NO");
    return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
 
int main(){
    int len;
    char s[4096];
    while(1){
        int ans=0;
        scanf("%s",s);
        len=strlen(s);
        if(len==1 && s[0]=='0') break;
        rep(i,0,len){
            ans+=s[i]-'0';
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    cout<<arr[k-1]<<'\n';
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int c[11][11];
//c[i][j]首尾ij
int sol(int x){
	int xx=x;
	int ans=0;
	while(x){
		x/=10;
		ans++;
	}
	return xx/pow(10,ans-1);
}
int main(int argc, char const *argv[])
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int st=sol(i);
		int k=i%10;
		c[st][k]++;
	}
	int ans=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++)
			ans+=c[i][j]*c[j][i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    string S;
    cin >> S;
    for(int i=0;i<S.length();i++){
        S[i] = 'x';
    }
    cout << S << endl;
}


Measured memory_bytes: 3132
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        if A[i + 1] >= B[i]:
            ans += B[i]
            A[i + 1] -= B[i]
        else:
            ans += A[i + 1]
            A[i + 1] = 0
print(ans)

Measured memory_bytes: 18624
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
  aaa = input()
  if aaa == 'AC':
    ac += 1
  elif aaa == 'WA':
    wa += 1
  elif aaa == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int dx = x2 - x1;
  int dy = y2 - y1;
  
  int x3 = x2 - dy;
  int y3 = y2 + dx;
  
  int x4 = x3 - dx;
  int y4 = y3 - dy;
  
  cout << x3 << " "<<y3 <<" "<<x4<<" "<< y4 <<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

res = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
  for j in range(N)[i:]:
    k = 2*j-i
    if N <= k:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      res -= 1

print(res)

Measured memory_bytes: 73644
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

double ThirdRoot(double q){
	double ret = q/2;
	while( true ){
		if( fabs(pow(ret,3.0) - q) < 0.00001*q ) break;
		ret = ret - ((pow(ret,3.0) - q) / (3 * pow(ret, 2.0)));
	}
	return ret;
}

int main(void){
	while( true ){
		int q;
		
		cin >> q;
		if( q == -1 ) break;

		printf("%lf\n", ThirdRoot((double)q));
	}
	return 0;
}

Measured memory_bytes: 0
public class Main{
  public void run(java.io.InputStream in,java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, i, x, y, suma, sumb;

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;

      suma = 0;
      sumb = 0;

      for(i = 0;i < n;++i){
        x = sc.nextInt();
        y = sc.nextInt();
        if(x > y){
          suma += x + y;
        }else if(x < y){
          sumb += x + y;
        }else{
          suma += x;
          sumb += y;
        }
      }
      System.out.println(suma + " " + sumb);
    }

/*end*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 51808
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

score = 0
INF = float('inf')
graph = Dinic(n+2)

for i in range(n):
    if a[i]>0:
        graph.add_edge(i+1,n+1,a[i])
        score += a[i]
    elif a[i]<0:
        graph.add_edge(0,i+1,-a[i])

for i in range(1,n//2+1):
    for j in range(2*i,n+1,i):
        graph.add_edge(i,j,INF)

print(score-graph.flow(0,n+1))




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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N; cin >> N;
	lnt origN = N;
	lnt ans = 0;
	for(lnt i = 2; i*i <= origN; i++){
		if(N % i == 0){
			lnt cnt = 0;
			while(N % i == 0){
				cnt++;
				N /= i;
			}
			cnt *= 2;
			lnt tmp = 1;
			while(tmp*(tmp+1) <= cnt) tmp++;
			tmp--;
			// cerr << i << ' ' << tmp << ln;
			ans += tmp;
		}
	}
	if(N != 1){
		ans++;
	}
	cout << ans << ln;
}

Measured memory_bytes: 3652
import math
import collections
n = int(input())
l = []
ans = 0
for i in range(n):
  a = list(input())
  a.sort()
  a = str(a)
  l.append(a)
c = collections.Counter(l)
for j in c.values():
  if j >= 2:
    ans += j*(j-1)//2
print(ans)

Measured memory_bytes: 24560
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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 main() {
	int n;
	string s;
	cin >> n >> s;

	vector<int> w(n+1);
	vector<int> e(n+1);
	w[0] = 0, e[0] = 0;

	for(int i = 1; i <= n; ++i) {
		if (s[i - 1] == 'W') {
			w[i] = w[i - 1] + 1;
			e[i] = e[i - 1];
		}
		else {
			w[i] = w[i - 1];
			e[i] = e[i - 1] + 1;
		}
	}

	int ans = n;
	rep(i, n) {
		if (ans > w[i] + (e[n] - e[i + 1])) ans = w[i] + (e[n] - e[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
program count_median
  implicit none
  integer :: n, i
  integer, dimension(200000) :: a = 0, b = 0
  read(*,*) n
  do i = 1, n
    read(*,*) a(i), b(i)
  end do
  call quick_sort(a(1:n))
  call quick_sort(b(1:n))
  write(*,'(i0)') merge(b(n/2)+b(n/2+1)-a(n/2)-a(n/2+1)+1,b((n+1)/2)-a((n+1)/2)+1,mod(n,2) == 0)
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program count_median

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 13396
def candies(a, n):
    top = []
    accum = 0
    for i in range(n):
        accum += a[0][i]
        top.append(accum)

    bottom = []
    accum = 0
    for i in range(n - 1, -1, -1):
        accum += a[1][i]
        bottom.append(accum)
    bottom.reverse()

    return max(map(lambda x, y: x + y, top, bottom))


if __name__ == '__main__':
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(2)]
    print(candies(a, n))

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

using namespace std;

#define PII pair<int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int>adj[100005];
int parent[100005],dist[100005];
priority_queue<PII,vector<PII>,greater<PII> >pq;

void Dijkstra()
{
    int cost,x;
    while(!pq.empty())
    {
        cost=pq.top().first+1;
        x=pq.top().second;pq.pop();
        for(int y : adj[x])
        {
            if(dist[y] > cost)
            {
                dist[y]=cost;
                parent[y]=x;
                pq.emplace(cost,y);
            }
        }
    }
}

int main()
{
    FAST();
    int i,m,n,x,y;
    cin >> n >> m;
    while(m--)
    {
        cin >> x >> y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }
    for(i=2;i<=n;i++)dist[i]=INT_MAX;
    pq.emplace(0,1);
    Dijkstra();
    for(i=2;i<=n;i++)
    {
        if(dist[i] == INT_MAX)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for(i=2;i<=n;i++)cout << parent[i] << '\n';
    return 0;
}


Measured memory_bytes: 11060
#include <stdio.h>
//#include <stdlib.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int s[40], t[40], ans[40], k=0;
  for (int i=0; i<40; i++) {
    s[i] = 0;
    t[i] = 0;
    ans[i] = 0;
  }
  if (n==0) {
    printf("0\n");
    return 0;
  }
  else if (n>0) {
    while (n != 0) {
      s[k] = n%2;
      n /= 2;
      k++;
    }
    for (int i=0; i<k; i++) {
      if (i%2 == 1 && s[i] == 1) {
        s[i] = 0;
        t[i] = 1;
        t[i+1] = 1;
      }
    }
  } else {
    n *= -1;
    while (n != 0) {
      s[k] = n%2;
      n /= 2;
      k++;
    }
    for (int i=0; i<k; i++) {
      if (i%2 == 0 && s[i] == 1) {
        s[i] = 0;
        t[i] = 1;
        t[i+1] = 1;
      }
    }
  }
  for (int i=0; i<40; i++) {
    if (s[i] == 1 && t[i] == 1) {
      if (t[i+1] == 1) {
        t[i+1] = 0;
        ans[i] = 0;
      } else {
        t[i+1] = 1;
        t[i+2] = 1;
        ans[i] = 0;
      }
    } else if (s[i] == 0 && t[i] == 0) {
      ans[i] = 0;
    } else {
      ans[i] = 1;
    }
  }
  k=39;
  while (ans[k]==0) k--;
  for (; k>=0; k--) printf("%d", ans[k]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif


int n;
char s1[N],s2[N];
int dp[N][3][3][3][3];
void add(int &a, int b) {a+=b;if (a>=P) a-=P;}
int main() {
	scanf("%d%s%s",&n,s1+1,s2+1);
	if (n==1) return puts("3"),0;
	if (n==2) return puts("6"),0;
	if (s1[1]==s2[1]) {
		if (s1[2]==s2[2]) { 
			REP(z1,0,2) REP(z2,0,2) if (z1!=z2) { 
				++dp[2][z1][z2][z1][z2];
			}
		}
		else { 
			REP(z,0,2) REP(u2,0,2) REP(d2,0,2) if (z!=u2&&z!=d2&&u2!=d2) {
				++dp[2][z][u2][z][d2];
			}
		}
	}
	else {
		REP(z1,0,2) REP(z2,0,2) if (z1!=z2) ++dp[2][z1][z1][z2][z2];
	}
	int ans = 0;
	REP(i,3,n+1) {
		REP(u1,0,2) REP(u2,0,2) {
			REP(d1,0,2) REP(d2,0,2) {
				int &r = dp[i-1][u1][u2][d1][d2];
				if (!r) continue;
				if (i==n+1) add(ans,r);
				if (s1[i]==s2[i]) {
					REP(z,0,2) if (z!=u2&&z!=d2) add(dp[i][u2][z][d2][z],r);
				}
				else if (s1[i]==s1[i-1]) {
					if (s2[i]==s2[i-1]) {
						add(dp[i][u2][u2][d2][d2],r);
					}
					else {
						REP(z,0,2) if (z!=u2&&z!=d2) add(dp[i][u2][u2][d2][z],r);
					}
				}
				else {
					if (s2[i]==s2[i-1]) {
						REP(z,0,2) if (z!=u2&&z!=d2) add(dp[i][u2][z][d2][d2],r);
					}
					else {
						REP(z1,0,2) REP(z2,0,2) if (z1!=u2&&z1!=z2&&z2!=d2) {
							add(dp[i][u2][z1][d2][z2],r);
						}
					}
				}
			}
		}
	}
	printf("%d\n", ans);
}








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

#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 21;
const int M = (1LL<<N);

int a[N][N];
int pw[N+5];
int n;

vector<int> cur(M),nex(M);
vector<int> go[N+1];

int cnt[M];
const int MOD = 1e9 + 7;

void solve()
{
    pw[0] = 1;
    for(int i=1;i<=N;i++) pw[i] = pw[i-1]<<1;
    
    cin >> n;
    f(i,n) f(j,n) cin >> a[i][j];
    
    f(i,n) if(a[0][i] == 1) cur[pw[i]] = 1;
        
    for(int i=1;i<n;i++)
    {
        f(j,M) nex[j] = 0;
        
        for(auto j : go[i])
        {
            for(int k=0;k<n;k++)
            {
                if(a[i][k] == 1 && ( (j&pw[k]) == 0))
                    nex[j|pw[k]] = (nex[j|pw[k]] + cur[j])%MOD;
            }
        }
        
        swap(cur,nex);
    }
    
    cout << cur[pw[n]-1]; 
}

signed main()
{
    f(i,M) go[__builtin_popcount(i)].pb(i);
    
    fast;
    solve();
}

Measured memory_bytes: 26560
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  100005
#define endl "\n"
using namespace std;
ll n,k;
vector<ll>v;
int dp[MAXN];
bool rec(int r){
    if(r==0)
        return 1;
    if(r<0)
        return 0;
    if(dp[r]!=-1)
        return dp[r];
    ll flag=0;
    for(ll i=0;i<n;i++){
        flag|=rec(r-v[i]);
    }
    return dp[r]=1-flag;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a;
        v.pb(a);
    }
    memset(dp,-1,sizeof(dp));
    bool ans=rec(k);
    if(ans==0){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
    return 0;
}



Measured memory_bytes: 5376
N = int(input())
arr = sorted([list(map(int, input().split())) for _ in range(N)])
cnt = {}
for i in range(N):
    for j in range(i+1,N):
        pq = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(pq, 0)
        cnt[pq] += 1
print(1 if cnt == {} else N - max(cnt.values()))

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

using namespace std;

int main(){

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

	a = a ^ b;
	b = a ^ b;
	a = a ^ b;

	a = a ^ c;
	c = a ^ c;
	a = a ^ c;

	cout << a << " " << b << " " << c << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;

long long pow_mod(long long a, long long b) {
  long long pow_ans=1;
  while(b) {
    if(b%2==1) {
      pow_ans*=a%mod;
      pow_ans%=mod;
    }
  a=a*a%mod;
  b/=2;
  }
  return pow_ans;
}

int main() {
  int n;
  cin >> n;
  vector<long long> box(n,0);
  for(int i=0;i<n;i++) {
    cin >> box.at(i);
  }
  long long mx=0;
  vector<long long> num_box(n,0);
  for(int i=0;i<n;i++) {
    num_box.at(box.at(i))++;
    mx=max(mx,box.at(i));
    //cout << mx << endl;
  }
  long long ans = 1;
  if(num_box.at(0)!=1||box.at(0)!=0) {
    ans = 0;
  }
  else {
    for(int i=0;i<mx;i++) {
      ans *= (pow_mod(num_box.at(i),num_box.at(i+1)))%mod;
      ans%=mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7

dp = [[0]*(k+2) for i in range(n+1)]
# dp[i][j]: i人目まで配ったときに残っているアメの個数がj個となる場合の数
from itertools import accumulate
dp[0][k] = 1
for i in range(n):
    x = [0]*(k+2)
    for j in range(k+1):
        x[max(0, j-A[i])] += dp[i][j]%mod
        x[j+1] -= dp[i][j]%mod
    cum = list(accumulate(x))
    dp[i+1] = cum

print(dp[n][0]%mod)

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

int main(void)
{

		
	
	long long int val[100005];
    int sta[100005];
	int N;
	cin>>N;
	int cou=1; 
	cin>>val[1];
	sta[1]=3;
	for(int i=2;i<=N;i++)
	{
		cin>>val[i];
		if(sta[i-1]==1)
		{
			if(val[i]>val[i-1])
			{
				sta[i]=3;
				cou++;
				
			}
			else
			{
				sta[i]=1;
			}
		}
		else if(sta[i-1]==0)
		{
			if(val[i]<val[i-1])
			{
				sta[i]=3;
				cou++;
				
			}
			else
			{
				sta[i]=0;
			}
		}else
		{
			if(val[i]>val[i-1])
			{
				sta[i]=0;
			}
			else if(val[i]<val[i-1])
			{
				sta[i]=1;
			}
			else
			{
				sta[i]=3;
			}
		}
	}
	cout<<cou<<endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

map<string, int> p;

int main() {
	int x; cin >> x;
	for (int i = 0; i < x; ++i) {
		string k; cin >> k;
		sort(k.begin(), k.end());
		++p[k];
	}
	long long ans = 0;
	for (map<string, int>::iterator it = p.begin(); it != p.end(); ++it)
		ans += 1ll * it->second * (it->second - 1) / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 11136
coin = [int(input()) for i in range(3)]
X = int(input())
cnt = 0
for i in range(coin[0]+1):
    x = X
    x -= 500 * i
    y = x
    if x == 0:
        cnt += 1
        break
    for j in range(coin[1]+1):
        x = y
        x -= 100 * j
        z = x
        if x == 0:
            cnt += 1
            break
        for k in range(coin[2]+1):
            x = z
            x -= 50 * k
            if x == 0:
                cnt += 1
                break
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Info {
    int ia;
    int ib;
    int ic;
    int dist;
    Info(int ia, int ib, int ic, int dist) : ia(ia), ib(ib), ic(ic), dist(dist) {}

    int hash() {
        return ia * 100000000 + ib * 10000 + ic;
    }

    bool operator< (const Info& a) const {
        return dist > a.dist;
    }
};

signed main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<int> A, B, C;
    inputVector(A, X);
    inputVector(B, Y);
    inputVector(C, Z);

    sort(all(A));
    sort(all(B));
    sort(all(C));
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));

    int ia = 0;
    int ib = 0;
    int ic = 0;

    int sum = A[0] + B[0] + C[0];

    unordered_map<int, int> memo;
    priority_queue<Info> q;
    q.push(Info(0, 0, 0, 0));
    memo[0] = 0;
    int cnt = 0;
    while (!q.empty()) {
        auto info = q.top(); q.pop();
        if (info.dist > memo[info.hash()]) continue;
        cnt++;
        //cerr << "(" << info.ia << ", " << info.ib << ", " << info.ic << ") dist:" << info.dist << endl;
        cout << sum - info.dist << endl;
        if (cnt == K) break;
        if (info.ia != X - 1) {
            auto ninfo = info;
            ninfo.ia++;
            ninfo.dist += A[info.ia] - A[info.ia + 1];
            if (memo.find(ninfo.hash()) == memo.end() || memo[ninfo.hash()] > ninfo.dist) {
                memo[ninfo.hash()] = ninfo.dist;
                q.push(ninfo);
            }
        }
        if (info.ib != Y - 1) {
            auto ninfo = info;
            ninfo.ib++;
            ninfo.dist += B[info.ib] - B[info.ib + 1];
            if (memo.find(ninfo.hash()) == memo.end() || memo[ninfo.hash()] > ninfo.dist) {
                memo[ninfo.hash()] = ninfo.dist;
                q.push(ninfo);
            }
        }
        if (info.ic != Z - 1) {
            auto ninfo = info;
            ninfo.ic++;
            ninfo.dist += C[info.ic] - C[info.ic + 1];
            if (memo.find(ninfo.hash()) == memo.end() || memo[ninfo.hash()] > ninfo.dist) {
                memo[ninfo.hash()] = ninfo.dist;
                q.push(ninfo);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <vector>


int main(int argc, char const *argv[]) {
  int A, B, C, X;
  std::cin >> A >> B >> C >> X;
  int ans = 0;
  int tmpa, tmpb, tmpc;
  for(int i = 0; i<= A; i++){
    int sum = X;
    tmpa = sum - i * 500;
    if(tmpa < 0){
      break;
    }
    if(tmpa == 0){
      ans++;
      break;
    }
    for(int j = 0; j <= B; j++){
      tmpb = tmpa - j * 100;
      if(tmpb < 0){
        break;
      }
      if(tmpb == 0){
        ans++;
        break;
      }
      for(int k = 0; k <= C;k++){
        tmpc = tmpb - k * 50;
        if(tmpc < 0){
          break;
        }
        if(tmpc == 0){
          ans++;
          break;
        }
      }
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }else if(abs(a-b)<=d && abs(b-c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007
  
bool ok(int a,int b,int c){
	if(a+b>c && b+c>a && a+c>b)return true;
	return false;
}

void solve(){
	ll x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	ll div = x / d;
	if(div == 0){
		if(k % 2 == 0){
			cout<<x;
		}else{
			cout<<abs(x-d);
		}
	}else{
		if(k == div){
			cout<<x % d;
		}else if(k > div){
			x = x - (div * d);
			k -= div;
			if(k % 2 == 0){
				cout<<x;
			}else{
				cout<<abs(x-d);
			}
		}else{
			cout<<x - k*d;
		}
	}
}

int main(){
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3588
use proconio::{input, fastout};

fn ppc(mut x: u64) -> u64 {
    let mut c = 0;
    while x > 0 {
        if x & 1 != 0 {c += 1}
        x >>= 1;
    }
    c
}

fn check(mut x: u64) -> u64 {
    let mut c = 0;
    while x > 0 {
      x %= ppc(x);
      c += 1;
    }
    c
}

fn pow2m(mut x: u64, m: u64) -> u64 {
    let mut d: u64 = 2;
    let mut ans: u64 = 1;
    while x > 0 {
        if x & 1 != 0 {
            ans *= d;
            ans %= m;
        }
        d *= d;
        d %= m;
        x >>= 1;
    }
    ans
}

#[fastout]
fn main() {
    input! {
        n: usize,
        mut x: String,
    }
    let mut ppc = 0;
    for c in x.chars() {
        if c == '1' {ppc += 1}
    }
    let ppcp = ppc + 1;
    let ppcm;
    if ppc > 1 {
        ppcm = ppc - 1;
    } else {
        ppcm = ppc;
    }
    // xp,xm = x % ppcp,ppcm
    let mut xp = 0;
    let mut xm = 0;
    let mut dp = 1;
    let mut dm = 1;
    for c in x.chars().rev() {
        if c == '1' {
            xp += dp;
            if xp >= ppcp { xp -= ppcp }
            if ppc > 1 {
                xm += dm;
                if xm >= ppcm { xm -= ppcm }
            }
        }
        dp *= 2;
        dp %= ppcp;
        if ppc > 1 {
            dm *= 2;
            dm %= ppcm;
        }
    }
    let mut i = n as u64;
    for c in x.chars() {
        i -= 1;
        let mut xt;
        if c == '0' {
            xt = xp + pow2m(i, ppcp);
            if xt >= ppcp {xt -= ppcp}
            if xt == 0 {
                println!("1");
            } else {
                println!("{}", check(xt) + 1);
            }
        } else {
            if ppc == 1 {
                println!("0");
            } else {
                xt = xm + ppcm - pow2m(i, ppcm);
                xt %= ppcm;
                if xt == 0 {
                    println!("1");
                } else {
                    println!("{}", check(xt) + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 2480
import itertools
import math
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
size = math.factorial(n)
a = list(itertools.permutations(l,n))
total = 0
for i in range(size):
    for j in range(n-1):
        x1 = a[i][j][0]
        x2 = a[i][j+1][0]
        y1 = a[i][j][1]
        y2 = a[i][j+1][1]
        x_total = (x1-x2)**2
        y_total = (y1-y2)**2
        total += (x_total + y_total)**.5
print(total/size)

Measured memory_bytes: 13812
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int a, b, c; readf("%d %d %d\n", &a, &b, &c);
    writeln( (b * 10 + c) % 4 == 0 ? "YES" : "NO" );
}


Measured memory_bytes: 256
n=int(input())
primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
pcnt = [0]*len(primes)
for x in range(1,n+1):
  for pidx in range(len(primes)):
    p=primes[pidx]
    while x % p ==0:
      x//=p
      pcnt[pidx]+=1
      
ret=0
#3*5*5 case
for i in range(len(pcnt)):
  for j in range(i+1,len(pcnt)):
    for k in range(len(pcnt)):
      if pcnt[i]>=4 and pcnt[j]>=4 and pcnt[k]>=2 and i!=k and j!=k:
        ret+=1
#3*25 case
for i in range(len(pcnt)):
  for j in range(len(pcnt)):
    if pcnt[i]>=24 and pcnt[j]>=2 and i!=j:
      ret+=1
#5*15 case
for i in range(len(pcnt)):
  for j in range(len(pcnt)):
    if pcnt[i]>=14 and pcnt[j]>=4 and i!=j:
      ret+=1
#75 case
for i in range(len(pcnt)):
  if pcnt[i]>=74:
    ret+=1

print(ret)


Measured memory_bytes: 3064