akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define N 500

int main() {
	static int kk[N][N], dp[N][N];
	int n, m, t, i, j, k;

	scanf("%d%d%d", &n, &m, &t);
	while (m--) {
		int l, r;

		scanf("%d%d", &l, &r), l--, r--;
		kk[l][r]++;
	}
	for (i = 0; i < n; i++) {
		dp[i][i] = kk[i][i];
		for (j = i + 1; j < n; j++) {
			dp[i][j] = dp[i][j - 1];
			for (k = i; k <= j; k++)
				dp[i][j] += kk[k][j];
		}
	}
	while (t--) {
		int p, q;

		scanf("%d%d", &p, &q), p--, q--;
		printf("%d\n", dp[p][q]);
	}
	return 0;
}


Measured memory_bytes: 2816
if __name__=='__main__':
    N = int(input())
    x,y,z = 0,0,0
    for i in range(N):
        a,b,c = map(int,input().split())
        x,y,z = max(y,z)+a, max(x,z)+b,max(x,y)+c 
    
    print(max(x,y,z))

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double[] array = new double[n + 1];
		array[0] = 0.;
		for (int i = 1; i <= n; ++i) {
			array[i] = sc.nextDouble() / 2. + 0.5 + array[i - 1];
		}
		
		double max = 0;
		for (int i = 0; i < n - k + 1; ++i) {
			double sum = array[i + k] - array[i];
			if (sum > max) {
				max = sum;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 158220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll c[n+1];
	c[0]=0;
	for(ll i=0;i<n;i++)c[i+1]=c[i]+a[i];
	ll dp[n][n];
	for(ll i=0;i<n;i++)dp[i][i]=0;
	for(ll l=2;l<=n;l++)
	{
		for(ll i=0;i<n-l+1;i++)
		{
			ll j=i+l-1;
			dp[i][j]=1e15;
			for(ll k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+c[j+1]-c[i]);
			}
		}
	}
	cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 1536
import sys
def input():
  return sys.stdin.readline()[:-1]
h, n = map(int, input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i], b[i] = map(int, input().split())

dp = [float('inf')]*(h+max(a))
dp[0] = 0 
for i in range(1, h+max(a)):
  for j in range(n):
    dp[i] = min(dp[i], dp[i-a[j]]+b[j])
print(min(dp[h:]))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;  cin >> s >> t;
    int lens = s.size();
    int lent = t.size();
    bool isIn = false;
    for (int i = lens - lent; i >= 0; --i) {
      bool flag = true;
      rep(j, lent) {
        if (s[j + i] != t[j] && s[j + i] != '?') flag = false;
      }
      if (flag) {
        rep(j, lent) {
          s[j + i] = t[j];
        }
        isIn = true;
        break;
      }
    }
    if (isIn) {
      rep(i, lens) {
        if (s[i] == '?') {
          s[i] = 'a';
        }
      }
      cout << s << '\n';
    } else {
      cout << "UNRESTORABLE" << '\n';
    }

    return 0;
}


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

using namespace std;

int ctoi(char ch)
{
	if ('0' <= ch && ch <= '9')
	{
		return (int)(ch - '0');
	}
	else
	{
		return -1;
	}
}

int N_in(string s)
{
	return ctoi(s[1]);
}

bool isStable(vector<string> after, vector<string> before)
{
	vector<char> a_suitseq;
	vector<char> b_suitseq;
	vector<int> countval(10, 0);
	for (int i = 0; i < after.size(); i++)
	{
		countval[N_in(after[i])]++;
	}
	for (int i = 0; i < 10; i++)
	{
		if (countval[i] > 1)
		{
			a_suitseq.resize(4, '\0');
			b_suitseq.resize(4, '\0');
			for (int j = 0; j < after.size(); j++)
			{
				for (int k = 0; k < countval[i]; k++)
				{
					if (i == N_in(after[j]))
					{
						a_suitseq[k] = after[j][0];
					}
					if (i == N_in(before[j]))
					{
						b_suitseq[k] = before[j][0];
					}
				}
			}
			if (a_suitseq != b_suitseq)
			{
				return false;
			}
		}
	}
	return true;
}

vector<string> bubbleSort(vector<string> a)
{
	string tmp;
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = a.size() - 1; j > i; j--)
		{
			if (N_in(a[j - 1]) > N_in(a[j]))
			{
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
	}
	return a;
}

vector<string> selectionSort(vector<string> a)
{
	int min;
	string tmp;
	for (int i = 0; i < a.size(); i++)
	{
		min = i;
		for (int j = i; j < a.size(); j++)
		{
			if (N_in(a[j]) < N_in(a[min]))
			{
				min = j;
			}
		}
		if (min != i)
		{
			tmp = a[i];
			a[i] = a[min];
			a[min] = tmp;
		}
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	vector<string> a(n);
	vector<string> bubble(n);
	vector<string> selection(n);
	double tmp;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	bubble = bubbleSort(a);
	selection = selectionSort(a);
	for (int i = 0; i < n; i++)
	{
		cout << bubble[i];
		if (i == n - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	if (isStable(bubble, a))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
	for (int i = 0; i < n; i++)
	{
		cout << selection[i];
		if (i == n - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	if (isStable(selection, a))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
}


Measured memory_bytes: 3236
import math
n = int(raw_input())

p1_x = float(0)
p1_y = float(0)
p2_x = float(100)
p2_y = float(0)

def KC(i, n, x1, y1, x2, y2):
	v = [0]*5
	w = [0]*5
	if i < n:
		v[0] = x1
		w[0] = y1
		v[1] = (2*x1+x2)/3.0
		w[1] = (2*y1+y2)/3.0
		v[2] = (x1+2*x2)/3.0
		w[2] = (y1+2*y2)/3.0
		v[3] = (v[2] - v[1])*math.cos(math.pi/3) - (w[2] - w[1])*math.sin(math.pi/3) + v[1]
		w[3] = (w[2] - w[1])*math.cos(math.pi/3) + (v[2] - v[1])*math.sin(math.pi/3) + w[1]
		v[4] = x2
		w[4] = y2
		KC(i+1, n, v[0], w[0], v[1], w[1])
		print v[1], w[1]
		KC(i+1, n, v[1], w[1], v[3], w[3])
		print v[3], w[3]
		KC(i+1, n, v[3], w[3], v[2], w[2])
		print v[2], w[2]
		KC(i+1, n, v[2], w[2], v[4], w[4])

print p1_x, p1_y
KC(0, n, p1_x, p1_y, p2_x, p2_y)
print p2_x, p2_y

Measured memory_bytes: 6660
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

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

    int MAX_N = 100000;

    int ans = MAX_N * 50000;

    int a, b, v;
    REP(c2, MAX_N + 1){
        a = max((int)0, X - c2);
        b = max((int)0, Y - c2);
        v = a * A + b * B + 2 * c2 * C;
        if(v < ans) ans = v; 
    }

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    cout << (n / 500) * 1000 + (n % 500) / 5 * 5 << endl;
}

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N,c=0;
    cin>>N;
    rep(1,i,N+1)if(i%2==1)++c;
    cout<<fixed<<setprecision(10)<<1.0*c/N<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int S;
	scanf("%d",&S);
	int a;
	int b;
	a=S%100;
	b=S/100;
	int Y;
	int M;
	Y=0;
	M=0;
	if(a<=12&&a>=1){
		M=1;
	}
	if(b<=12&&b>=1){
		Y=1;
	}
	if(M==0){
		if(Y==0){
			printf("NA");
		}else{
			printf("MMYY");
		}
	}else{
		if(Y==0){
			printf("YYMM");
		}else{
			printf("AMBIGUOUS");
		}
	}
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Linq;
  
namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            string[] strForBubbleSort = new string[n];
            input.CopyTo(strForBubbleSort, 0);
            string[] strForSelectionSort = new string[n];
            input.CopyTo(strForSelectionSort,0);

            string bubbleSortResult = BubbleSort(strForBubbleSort, n);
            string selectionSortResult = SelectionSort(strForSelectionSort, n);

            Console.WriteLine(bubbleSortResult);
            Console.WriteLine("Stable");
            Console.WriteLine(selectionSortResult);
            if(bubbleSortResult == selectionSortResult)
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.Write("Not stable\n");
            }
        }
        public static void swap<T>(ref T x ,ref T y)
        {
            T temp = x;
            x = y;
            y = temp;
        }
        public static string BubbleSort(string[] strArray,int n)
        {
            string result = string.Empty;

            for (int i = 0; i < n - 1; ++i)
            {
                for (int j = n - 1; j > i; --j)
                {
                    if (strArray[j][1] < strArray[j - 1][1])
                    {
                        swap(ref strArray[j], ref strArray[j - 1]);
                    }
                }
            }
            for (int i = 0; i < n; ++i)
            {
                result += strArray[i];
                if (i != n - 1)
                {
                    result += " ";
                }
            }

            return result;
        }

        public static string SelectionSort(string[] strArray, int n)
        {
            string result = string.Empty;

            for (int i = 0; i < n - 1; ++i)
            {
                int minj = i;
                for (int j = i + 1; j < n; ++j)
                {
                    if (strArray[j][1] < strArray[minj][1])
                    {
                        minj = j;

                    }

                }
                if (strArray[minj][1] < strArray[i][1])
                {
                    swap(ref strArray[i], ref strArray[minj]);
                }

            }
            for (int i = 0; i < n; ++i)
            {
                result += strArray[i];
                if (i != n - 1)
                {
                    result += " ";
                }
            }

            return result;
        }
    }
}

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

using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;

    vector<bool> ok(N + 1, true);
    for(int i = 0, a; i < M; i++)
    {
        cin >> a;
        ok[a] = false;
    }

    vector<ll> dp(N + 1, 0);
    dp[0] = 1;

    const ll mod = 1e9 + 7;
    for(int i = 0; i < N + 2; i++)
    {
        if(i < N && ok[i + 1])
        {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }

        if(i + 1 < N && ok[i + 2])
        {
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }
    }

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

Measured memory_bytes: 1024
//22:32
#include <stdio.h>

typedef long long ll;
int N;
ll C;
ll x[100000];
int v[100000];

ll left_cache[100000];
ll right_cache[100000];
ll max(ll a, ll b){return(a>b)?a:b;}

int main(){
	scanf("%d %lld",&N, &C);
	for(int i = 0; i < N; i++) scanf("%lld %d",x+i,v+i);

	left_cache[0] = v[0] - 2*x[0];
	for(int l = 1; l < N; l++){
		left_cache[l] = v[l] - 2*(x[l]-x[l-1]) + left_cache[l-1];
	}
	left_cache[0] = max(0,left_cache[0]);
	for(int l = 1; l < N; l++){
		left_cache[l] = max(left_cache[l],left_cache[l-1]);
	}

	ll maxcalorie = 0;
	right_cache[N-1] = v[N-1] - (C-x[N-1]);
	for(int r = N-2; r >= 0; r--){
		right_cache[r] = v[r] - (x[r+1]-x[r]) + right_cache[r+1];
	}
	for(int r = N-1; r >= 1; r--){
		ll cal = left_cache[r-1] + right_cache[r];
		//printf("l=%d,r=%d,cal=%lld\n",r-1,r,cal);
		maxcalorie = max(maxcalorie, cal);
	}
/*
	printf("l=none,r=0,cal=%lld\n",right_cache[0]);
	puts("left_cache:");
	for(int l = 0; l < N; l++){
		printf("%lld,",left_cache[l]);
	}puts("");
	puts("right_cache:");
	for(int r = 0; r < N; r++){
		printf("%lld,",right_cache[r]);
	}puts("");
*/
	maxcalorie=max(maxcalorie,right_cache[0]);


	right_cache[N-1] = v[N-1] - 2*(C-x[N-1]);
	for(int r = N-2; r >= 0; r--){
		right_cache[r] = v[r] - 2*(x[r+1]-x[r]) + right_cache[r+1];
	}
	right_cache[N-1] = max(0, right_cache[N-1]);
	for(int r = N-2; r >= 0; r--){
		right_cache[r] = max(right_cache[r], right_cache[r+1]);
	}

	left_cache[0] = v[0] - x[0];
	for(int l = 1; l < N; l++){
		left_cache[l] = v[l] - (x[l]-x[l-1]) + left_cache[l-1];
	}
	for(int l = 0; l < N-1; l++){
		ll cal = left_cache[l] + right_cache[l+1];
		//printf("l=%d,r=%d,cal=%lld\n",l,l+1,cal);
		maxcalorie = max(maxcalorie, cal);
	}
/*
	printf("l=N-1,r=none,cal=%lld\n",left_cache[N-1]);
	puts("right_cache:");
	for(int r = 0; r < N; r++){
		printf("%lld,",right_cache[r]);
	}puts("");
	puts("left_cache:");
	for(int l = 0; l < N; l++){
		printf("%lld,",left_cache[l]);
	}puts("");
*/
	maxcalorie=max(maxcalorie,left_cache[N-1]);
	

	printf("%lld\n",maxcalorie);
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

LL get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		LL s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	LL s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n,m;
LL d[N],a1;
int id[N],num[N];
LL k;
bool vis[N];
int p,t[N];

int main(){
	n=get();
	a1=get();
	fo(i,1,n-1)d[i]=get();
	fd(i,n-1,2)d[i]-=d[i-1];
	d[1]-=a1;
	fo(i,1,n-1)id[i]=i;
	m=get();k=get();
	fo(i,1,m){
		int x=get();
		swap(id[x-1],id[x]);
	}
	fo(i,1,n-1)
	if (!vis[i]){
		vis[i]=1;
		t[p=1]=i;
		for(int x=id[i];x!=i;x=id[x])vis[t[++p]=x]=1;
		fo(j,1,p)num[t[j]]=t[(k+j-1)%p+1];
	}
	printf("%lld\n",a1);
	fo(i,1,n-1){
		a1+=d[num[i]];
		printf("%lld\n",a1);
	}
	return 0;
}

Measured memory_bytes: 3328
class Node

  attr_accessor :to, :cost
  def initialize(to, cost)
    @to = to
    @cost = cost
  end
end

INF = 10 ** 7
# INF = Float::INFINITY

def dijkstra(g, s)

  # inf = 10 ** 12
  inf = INF
  dist = Array.new(g.size, inf)
  dist[s] = 0

  que = []
  que.push( [0, s] )

  while que.any?

    d, v = que.shift
    # next if dist[v] < d
    g[v].each do |e|
      next if dist[e.to] != inf || dist[v] == inf
      dist[e.to] = dist[v] + 1
      que.push( [dist[e.to], e.to ] )
    end
  end
  
  # dist.map!{|d| d == inf ? "INF" : d }
  dist
end

n, m = gets.to_s.split.map{|t|t.to_i}

g = Array.new(n*3){ [] }

m.times do
  u, v = gets.to_s.split.map{|t|t.to_i-1}
  g[3*u+0] << Node.new(3*v+1, 1)
  g[3*u+1] << Node.new(3*v+2, 1)
  g[3*u+2] << Node.new(3*v+0, 1)
end

s, t = gets.to_s.split.map{|i|i.to_i-1}

dist = dijkstra(g, s*3+0)

puts dist[t*3+0] == INF ? -1 : dist[t*3+0]/3

Measured memory_bytes: 47740
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

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

  int ans = 0;

  if (S == "RRR") {
    ans = 3;
  } else if (S == "RRS" || S == "SRR") {
    ans = 2;
  } else if (S == "RSR" || S == "SRS" || S == "SSR" || S == "RSS") {
    ans = 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3588
import math
num, m = map(int,input().split())
list = [int(x) for x in input().split()]


count = 0

for i in range(num):
    if list[i] < sum(list)/(4*m):
        None
    else:
        count += 1

if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import string, sys

alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])

for s in sys.stdin:
  while not('the' in s or 'that' in s or 'this' in s):
    s = s.translate(tbl)
  print s[:-1]

Measured memory_bytes: 4372
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/2 20:44:09
 ************************************************************************/
#include<map>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define For(i,a,b) for(register LL i=(a);i<=(b);++i)
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
LL calc(LL x){
	return x*x*x*x*x;
}
map<LL,LL>mp;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	LL x=read();
	For(i,-1000,1000){
		LL a=i;
		a=calc(a);
		mp[a]=i;
	}
	For(i,-1000,1000){
		LL a=i,A;
		A=calc(a);
		if(mp[A-x]!=0){
			printf("%lld %lld\n",a,mp[A-x]);
			break;
		}
		if(A==x){
			printf("%lld 0\n",a);
			break;
		}
	}
	return 0;
}


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

const int N = 2e5 + 9;

int a[50][50][10];

pair<int, int> yo(long long n) {
	int p2 = 0;
	while (n % 2 == 0) p2++, n /= 2;	
	int p5 = 0;
	while (n % 5 == 0) p5++, n /= 5;
	return {p2, p5};
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		long long cur = 0;
		int d = 0, f = 0;
		for (auto i: s) {
			if (i == '.') {
				f = 1;
				continue;
			}
			cur = cur * 10 + i - '0';
			d += f;
		}
		auto p = yo(cur);
		a[p.first][p.second][d]++;
	}
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			for (int x = 0; x < 10; x++) {
				if (a[i][j][x] == 0) continue;
				for (int k = 0; k < 50; k++) {
					for (int l = 0; l < 50; l++) {
						for (int y = 0; y < 10; y++) {
							int d = min(i + k, j + l);
							if (x + y <= d) {
								if (i == k && j == l && x == y) {
									ans += 1LL * a[i][j][x] * (a[i][j][x] - 1);
								}
								else ans += 1LL * a[i][j][x] * a[k][l][y];
							}
						}
					}
				}
			}
		}
	}
	cout << ans / 2 << '\n';
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=0;
  	cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    for(int i = 1;i < n;i ++){
        int cnt = 1;
        while(a[i]==a[i-1]){
            i ++;
            cnt ++;
        }
        ans += cnt/2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string N;
	cin >> N;
	int sum=0;
	rep(i,N.size()) sum+=N[i]-'0';
	if(sum%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;


int main() {
  int R[MAX], n;
  cin >>n;
  for(int i=0;i<n;i++)cin >>R[i];
  int maxv=-2000000000;
  int minv=R[0];

  for(int i=1;i<n;i++){
	  maxv=max(maxv,R[i]-minv);
	  minv=min(minv,R[i]);
  }
  cout << maxv <<endl;

	return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

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

    int n;
    cin >> n;

    int count = 0;
    while(a >= b){
        b*=2;
        count++;
    }

    while(b >= c){
        c*=2;
        count++;
    }

    if(count <= n) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
n,k = map(int, raw_input().split(' '))
r,s,p = map(int, raw_input().split(' '))
seq = raw_input()
import collections
q = collections.deque()
i = 0
while(i < len(seq)):
	prev = q.popleft() if len(q) == k else [0,0,0]
	c = [0,0,0]
	c[0] = max(prev[1], prev[2]) + (r if seq[i]  == 's' else 0)
	c[1] = max(prev[0], prev[2]) + (s if seq[i]  == 'p' else 0)
	c[2] = max(prev[0], prev[1]) + (p if seq[i]  == 'r' else 0)
	q.append(c)
	i +=1
print sum([max(C) for C in q] or [0])


Measured memory_bytes: 43548
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=305;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N,A;
	cin>>N>>A;
	cout<<N*N-A<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools as it

N = int(input())
xy = []
for i in range(N):
    A_i = int(input())
    xy_i = []
    for j in range(A_i):
        tmp = [int(i) for i in input().split()]
        xy_i.append(tmp)
    xy.append(xy_i)
ans = 0
for conf in it.product(range(2), repeat=N):
    is_consist = True
    # honest 1, evil 0
    for i in range(N):
        if conf[i] == 0:
            continue
        # i is honest
        for jth_state in range(len(xy[i])):
            if xy[i][jth_state][1] != conf[xy[i][jth_state][0] - 1]:
                is_consist = False
                break
    if is_consist:
        ans = max(ans, sum(conf))
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#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 <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int N;
        cin >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        int ans = 0;
//        set<int> st;
        map<int, int> st;
        for (int i = 0; i < N; ++i) {
            auto pt = st.upper_bound(-A[i]);
            if (pt == st.end()) {
//                ans++;
//                st.insert(-A[i]);
                st[-A[i]]++;
            } else {
//                st.erase(*pt);
//                st.insert(-A[i]);
                st[pt->first]--;
                if (st[pt->first] == 0) {
                    st.erase(pt->first);
                }
                st[-A[i]]++;
            }
        }

        for (auto e : st) {
            ans += e.second;
        }

        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
 
int card[4][14];
 
int main(void){
    int n,i,j;
    char a;
 
    scanf("%d",&n);
 
 
    for(i = 0;i < n;i++){
       scanf(" %c %d",&a,&j);
       if(a == 'S')
           card[0][j] = 1;
       else if(a == 'H')
           card[1][j] = 1;
       else if(a == 'C')
           card[2][j] = 1;
       else
           card[3][j] = 1;
    }
    for(i = 0;i < 4;i++){
        if(i == 0)
            a = 'S';
        else if(i == 1)
            a = 'H';
        else if(i == 2)
            a = 'C';
        else
            a = 'D';
 
        for(j = 1;j <= 13;j++)
            if(card[i][j] == 0)
                printf("%c %d\n",a,j);
    }
 
    return 0;
}


Measured memory_bytes: 2140
n=int(input())
w=[]
for i in range(n):
    x,l=map(int,input().split())
    w.append([x-l,x+l])
w.sort(key=lambda x: x[1])
val=-(10**10)
ans=0
for i in range(n):
    if val<=w[i][0]:
        ans+=1
        val=w[i][1]
print(ans)


Measured memory_bytes: 21336
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();

    List<Long> enemy = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      enemy.add(Long.valueOf(sc.next()));
    }

    Long ans = enemy.stream()
                    .sorted((x, y) -> y.compareTo(x))
                    .skip(k)
                    .reduce(0L, Long::sum);

    System.out.println(ans);

  }

}


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

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

int main(void) {
  int N,K;
  string s;
  cin>>N>>K;
  cin>>s;
  s[K-1] = s[K-1]-'A'+'a';
  cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long a, b, x, acou, bcou;
    cin >> a >> b >> x;

    acou = a / x;
    bcou = b / x;

    cout << (a % x == 0 ? bcou - acou + 1 : bcou - acou) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                   
using namespace std;                                                                                  
                                                                                                      
int main() {                                                                                          
  int x, y, z;                                                                                        
                                                                                                      
  cin >> x >> y >> z;                                                                                 
  cout << z  << " " << x << " " << y << endl;                                                         
                                                                                                      
  return 0;                                                                                           
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int n;
long long a,b;
long long t[100005];


bool can(long long mid){
  long long tmp = 0;
  for(int i=0;i<n;i++){
    long long tt = t[i]-b*mid;
    if(tt > 0) tmp += tt/(a-b);
    if((tt % (a-b)) > 0) tmp++;
  }
  if(tmp <= mid) return true;
  return false;
}

int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>t[i];
  }

  long long ma = 1000000007;
  long long mi = 0;

  for(int i=0;i<40;i++){
    long long mid = (ma+mi)/2;

    bool ca = can(mid);
//cout<<mid<<" "<<ma<<" "<<mi<<" "<<ca<<endl;
    if(ca){
      ma = mid;
    } else {
      mi = mid;
    }
  }
  cout<<ma<<endl;
  //if(can(mi)) cout<<mi<<endl;
  //else cout<<ma<<endl;

  return 0;
}


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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> dvs;
    for (int i = 1; i*i <= M; i++) {
        if (M%i == 0) {
            dvs.push_back(i);
            dvs.push_back(M/i);
        }
    }

    sort(dvs.begin(), dvs.end());
    int ans = 1;
    for (int i = 0; i < dvs.size(); i++) {
        if (dvs[i] <= M/N) ans = dvs[i];
    }

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

Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll a, b, c, five = 0, seven = 0;
    cin >> a >> b >>c;
    if(a == 5) five++;
    else if( a == 7) seven++;
    if (b == 5) five++;
    else if(b == 7) seven++;
    if(c == 5) five++;
    else if(c == 7) seven++;
    if(five == 2 && seven  == 1){
        cout << "YES";
    }
    else cout << "NO";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

    for (int i = 0; i < 3; ++i) {
        if (n[i] == '1') {
            printf("9");
        } else if (n[i] == '9') {
            printf("1");
        }
    }

    printf("\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
int N;
int X, Y, Z;
int S;


int next(int prev, int k) {
    int mask = (1 << S) - 1;
    int ret = ((prev << k) + (1 << (k - 1))) & mask;
    return ret;
}

bool check(int bit) {
//    return !(bit >> (S - 1));
    int top = (X + Y + Z) - 1;
    int mid = (Y + Z) - 1;
    int bot = Z - 1;
    return !(
            ((bit >> top) & 1) &&
            ((bit >> mid) & 1) &&
            ((bit >> bot) & 1)
    );
}


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

    cin >> N >> X >> Y >> Z;
    S = X + Y + Z;

    vector<vector<ll> > dp(N + 1, vector<ll>(1 << S));
    dp[0][0] = 1;

    for (int i = 0; i < N; ++i) {
        for (int bit = 0; bit < 1 << S; ++bit) {
            if (check(bit)) {
                for (int k = 1; k <= 10; ++k) {
                    if (check(next(bit, k))) {
                        ll &tmp = dp[i + 1][next(bit, k)];
                        tmp = (tmp + dp[i][bit]) % MOD;
//                        dp[i + 1][next(bit,k)] += dp[i][bit];
                        int a = 0;

                    } else {
                        //たぴゃ〜ｗ(計算の意味がない)
                    }
                }
            }
        }
    }

//    ll ans = 0;
//
//    for (int bit = 0; bit < 1 << S; ++bit) {
//        ans = (ans + dp[N - 1][bit]) % MOD;
//    }

    ll ans = 1ll;
    for (int i = 0; i < N; ++i) {
        ans = ans * 10ll % MOD;
    }

    for (int bit = 0; bit < 1 << S; ++bit) {
        ans = (ans - dp[N][bit]) % MOD;
        if (ans < 0) ans += MOD;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 43392
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	long long n,A,B;
	cin >> n>>A>>B;
	
	cout << A*(n/(A+B)) +min(n%(A+B),A)<< endl;
}

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

int main() {
	int N;

	while (cin >> N && N != 0) {
		int dataset[11][11] = {0};
        for (int i = 0; i != N; ++i) {
            for (int j = 0; j != N; ++j) {
                cin >> dataset[i][j];
            }
        }

        for (int i = 0; i != N; ++i) {
            for (int j = 0; j != N; ++j) {
                dataset[i][N] += dataset[i][j];
            }
        }

        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j != N; ++j) {
                dataset[N][i] += dataset[j][i];
            }
        }

        for (int i = 0; i != N+1; ++i) {
            for (int j = 0; j != N+1; ++j) {
                cout << setw(5) << dataset[i][j];
            } 
            cout << endl;
        }
	}
    return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {
    private static void reslove(Scanner sc) {
        int k = sc.nextInt();
        if (k % 2 == 0 || k % 5 == 0) {
            System.out.println(-1);
            return;
        }
        int cur = 7 % k;
        int ans = 1;
        while (cur != 0) {
            cur = cur * 10 + 7;
            cur %= k;
            ans++;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        reslove(sc);
        sc.close();
    }
}


Measured memory_bytes: 35744
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define mp make_pair
#define f first
#define s second
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

char buff[110][110];
int trap[256];
char seqC[1000];
int seqI[1000];
int potion[12];
int stage[100][100];
int R,C,T,S,P;
int hpMax, hpInit;
int memo[1024][1<<12];
bool visit[1024][1<<12];
int dm[1024];
int ptmp[1<<12];
int dtmp[1024];

int dx[256];
int dy[256];

int main(){
  dx['U'] = 0;
  dx['D'] = 0;
  dx['R'] = 1;
  dx['L'] = -1;

  dy['U'] = -1;
  dy['D'] = 1;
  dy['R'] = 0;
  dy['L'] = 0;

  while(scanf("%d%d",&hpInit,&hpMax),hpMax+hpInit){

    scanf("%d%d ",&R,&C);
    REP(i,R) scanf("%s ",buff[i]);

    scanf("%d ",&T);
    REP(i,T){
      char c; int d;
      scanf("%c %d ",&c,&d);
      trap[c] = d;
    }

    scanf("%d ",&S);
    REP(i,S) scanf("%c %d ",&seqC[i],&seqI[i]);

    scanf("%d ",&P);
    REP(i,P) scanf("%d ",&potion[i]);

    REP(i,R) REP(j,C) stage[i][j] = trap[buff[i][j]];

    int ss = 0;
    {
      int x = 0;
      int y = 0;

      REP(i,S){
        char c = seqC[i];
        int  n = seqI[i];

        REP(j,n){
          x += dx[c];
          y += dy[c];
          //printf("%d %d : %d\n",x,y,stage[y][x]);
          dm[ss++] = stage[y][x];
        }
      }
    }

    REP(i,1<<P){
      int sum = 0;
      REP(j,P) if(i & (1<<j))
        sum += potion[j];
      ptmp[i] = sum;
    }

    {
      int sum = 0;
      for(int i=ss-1; i>=0; i--){
        sum += dm[i];
        dtmp[i] = sum;
      }
    }
    //    REP(i,ss) printf("dtmp[%d]: %d\n",i,dtmp[i]);

    REP(i,ss+1) REP(j,1<<P) memo[i][j] = 0;
    memo[0][(1<<P)-1] = hpInit;

    REP(i,ss) for(int j=(1<<P)-1; j>=0; j--){
      if(memo[i][j]){
        int tt = j;
        if(memo[i][j] != hpMax){
          REP(k,P) if(j & (1<<k)){
            int hh = min(hpMax,memo[i][j] + potion[k]);
            memo[i][j^(1<<k)] = max(memo[i][j^(1<<k)], hh);
          }
        }
        memo[i+1][j] = max(memo[i+1][j], memo[i][j] - dm[i]);
      }
    }

    bool ans = false;
    REP(i,1<<P){
      if(memo[ss][i] != 0)
        ans = true;
    }

    puts(ans?"YES":"NO");

  }

  return 0;
}

Measured memory_bytes: 16000
n = input()
v = list(input().split())

cnt = 0
flg = True
while flg:
  for i in range(len(v)):
    if int(v[i]) %2 == 0:
      pass
    else:
      flg = False
    v[i] = int(v[i])/2
  cnt = cnt + 1

print(cnt - 1)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int A[205];

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i < 2*N; i++) {
		scanf("%d", &A[i]);
	}
	sort(A, A +  2 * N);
	int sol = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		sol += A[i];
	}
	printf("%d", sol);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <cstdlib>
using namespace std;
#define pii pair<int,int>
#define ft first
#define sc second
#define INF 1000000006
#define INFLL 4000000000000000006ll
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define gc getchar_unlocked
#define gi(x) while((_c=gc())<'0'); x=_c-'0'; while((_c=gc())>='0') x=x*10+_c-'0';
#define LL long long
#define DB double
#define PARAM int id, int l, int r
#define _L id*2,l,mid
#define _R id*2+1,mid+1,r
#define PREP int mid = (l+r)/2
#define MEMSET(x,y) memset(x,y,sizeof(x));
#define ALL(x) x.begin(),x.end()
#define REP(i,x,y) for(int i = x; i < y; i++ )

int n, k;
int arr[100005];

int main(){
	char _c; gi(n) gi(k)
	for(int i = 0; i < n; i++ ) {gi(arr[i])}
	int cc = 0, mx = 0;
	for(int i = 0; i < n; i++ ) cc = __gcd(cc,arr[i]), mx = max(mx,arr[i]);
	if(mx < k){
		printf("IMPOSSIBLE\n"); return 0;
	}
	if(cc==1){
		printf("POSSIBLE\n"); return 0;
	}
	if((mx-k)%cc==0) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 640
N = input()
a = list(map(int,input().split()))
el = sorted(list(set(a)))

if len(el) == 1:
  if el[0] == 0:
    print("Yes")
  else:
    print("No")
elif len(el) == 2 :
  if a.count(0)*2 == a.count(el[1]):
    print("Yes")
  else:
    print("No")
elif len(el) == 3 and el[0]^el[1]^el[2] == 0 and a.count(el[1]) == a.count(el[2]) and a.count(el[1]) == a.count(el[0]):
      print("Yes")
else:
  print("No")
  

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

int main(void)
{
	bool possible = false;
	int N, T; cin >> N >> T;
	int c_min = 1000;
	for (int i = 0; i < N; i++) {
		int t_tmp, c_tmp; cin >> c_tmp >> t_tmp;
		if (t_tmp <= T) {
			if (c_min > c_tmp)c_min = c_tmp;
			possible = true;
		}
	}

	if (possible)cout << c_min << endl;
	else cout << "TLE" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
dp = list([0] * 2 for i in range(n+1))
dp[0][0] = 0
dp[0][1] = -1000000000000
for i in range(1, n) :
    dp[i][0] = max(dp[i-1][0] + A[i], dp[i-1][1] - A[i])
    dp[i][1] = max(dp[i-1][0] - A[i], dp[i-1][1] + A[i])
ans = max(dp[n-1][0] + A[n], dp[n-1][1] - A[n])    

print(ans)


Measured memory_bytes: 25804
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
using Graph = vector<vector<int>>;

using mint=modint998244353;

struct S{
    int ze,one,inv;
};

using F=bool;

S op(S l,S r){
    return S{
        l.ze+r.ze,
        l.one+r.one,
        l.inv+r.inv+l.one*r.ze,
    };
}

S e(){
    return S{0,0,0};
}

S mapping(F l,S r){
    if(!l) return r;
    return S{r.one,r.ze,r.one*r.ze-r.inv};
}

F composition(F l,F r){
    return (l&&!r)||(!l&&r);
}
F id(){
    return false;
}



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,Q;
    cin>>N>>Q;


    vector<S> a(N);
    rep(i,N){
        int x;
        cin>>x;
        if(x){
            a[i]=S{0,1,0};
        }else{
            a[i]=S{1,0,0};
        }
    }

    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);

    rep(i,Q){
        int t,l,r;
        cin>>t>>l>>r;
        l--;
        if(t==1){
            seg.apply(l,r,true);
        }else{
            cout<<seg.prod(l,r).inv<<endl;
        }
    }
}


Measured memory_bytes: 20384
import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
tmp = abs(x[0] - X)
for i in range(1,N):
  tmp = fractions.gcd(tmp,abs(x[i]-X)) # Xとの差分に対し、最大公約数を求める
print(tmp)

Measured memory_bytes: 16296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int n,k;
    int r,s,p;
    ll ans=0;
    string str;
    cin>>n>>k>>r>>s>>p>>str;
    rep(i,n){
        switch (str[i]){
        case 'r':
            if(i-k>=0&&str[i-k]=='r') {
                str[i]='a';
                break;
                }
            ans+=p;
            break;
        case 's':
            if(i-k>=0&&str[i-k]=='s') {
                str[i]='a';
                break;
                }
            ans+=r;
            break;
        case 'p':
            if(i-k>=0&&str[i-k]=='p') {
                str[i]='a';
                break;
                }
            ans+=s;
            break;
        }
        
    }
    cout<<ans<<endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

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

  int n;
  cin >> n;

  vector<FiniteField> fs(n + 1);
  vector<FiniteField> gs(n + 1);
  fs[1] = n;
  gs[1] = n;
  for (int k = 2; k <= n; k++) {
    FiniteField f = fs[k - 1];
    if (k - 3 >= 1) {
      f += gs[k - 3];
      f += (n - 1 - (k - 3));
      f += FiniteField(n - 1) * (n - 1);
    } else {
      f += n - 1;
      f += FiniteField(n - 1) * (n - 1);
    }
    fs[k] = f;
    gs[k] = gs[k - 1] + fs[k];
  }
  
  cout << fs[n] << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

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

    ll N;
    cin >> N;

    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    for (ll i = 0; i < N; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        for (ll j = 6; i + j <= N; j *= 6) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (ll j = 9; i + j <= N; j *= 9) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }

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



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int cases;
string s;

int dfs(int l,int r){
	bool num=true;
	repl(i,l+1,r-1){
		if(!isdigit(s[i])){
			num=false;
			break;
		}
	}
	if(num){
		return stoi(s.substr(l+1,r-l-2))/2+1;
	}else{
		int level=-1;
		int ll;
		vector<int> ns;
		repl(i,l,r){
			if(s[i]=='['){
				if(level==0){
					ll=i;
				}
				level++;
			}else if(s[i]==']'){
				level--;
				if(level==0){
					ns.pb(dfs(ll,i+1));
				}
			}
		}
		sort(all(ns));
		int res=0;
		rep(i,ns.size()/2+1){
			res+=ns[i];
		}
		return res;
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>cases;
	while(cases--){
		cin>>s;
		cout<<dfs(0,s.length())<<endl;
	}
	return 0;
}

Measured memory_bytes: 3268
import heapq

N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
for i in range(N-1):
    min_1 = heapq.heappop(V)
    min_2 = heapq.heappop(V)
    ave = (min_1 + min_2)/2
    heapq.heappush(V, ave)
print(V[0])

Measured memory_bytes: 38512