akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

const int N=(int)1e5+5;

int A[N][3],dp[N][3];


int main(int argc, char const *argv[])
{
	crap;
	int n;
	cin>>n;
	f(i,1,n)
	{
		rep(j,3)
			cin>>A[i][j];
	}

	rep(j,3)
	{
		dp[1][j]=A[1][j];
	}

	f(i,2,n)
	{
		rep(j,3)
		{
			int ans;
			if (j==0)
				ans=max(dp[i-1][1],dp[i-1][2]);
			else if (j==1)
				ans=max(dp[i-1][0],dp[i-1][2]);
			else
				ans=max(dp[i-1][0],dp[i-1][1]);
			dp[i][j]=A[i][j]+ans;
		}
	}

	int ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <list>
#include <cmath>
using namespace std;

int main() {
	long a, b;
	cin >> a >> b;
	if (a * b <= 0) {
		cout << "Zero" << endl;
	} else if (a > 0) {
		cout << "Positive" << endl;
	} else {
		if ((b - a + 1) % 2 == 0) {
			cout << "Positive" << endl;
		} else {
			cout << "Negative" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 10000

struct Node{
  int key;
  struct Node *p;
  struct Node *r;
  struct Node *l;
};

struct Node *root,*NIL;

void Insert(int );
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int n,i,num;
  char order[8];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",order);
    if(strcmp(order,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(order,"insert")==0){
      scanf("%d",&num);
      Insert(num);
      }
   }


 return 0;
}

void Insert(int k){
 struct Node *y = NIL;
 struct Node *x = root;
 struct Node *z;

 z=(struct Node *)malloc(sizeof(struct Node));
 z->key=k;
 z->l=NIL;
 z->r=NIL;

 while(x!=NIL){
   y=x;
   if(z->key < x->key){
     x=x->l;
   }else{
     x=x->r;
   }
 }

z->p=y;
if(y==NIL){
  root=z;
}else{
  if(z->key < y->key){
    y->l=z;
  }else{
    y->r=z;
  }
}
}

void inorder(struct Node *x){
  if(x!=NIL){
    inorder(x->l);
    printf(" %d",x->key);
    inorder(x->r);
  } 
}

void preorder(struct Node *x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->l);
    preorder(x->r);
  }
}


Measured memory_bytes: 25128
#include<bits/stdc++.h>
using namespace std;
int main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      int n;
      cin>>n;

    long long int s=1;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            s=0;
    }
    sort(a,a+n);
    for(int i=0;s!=0 && i<n;i++)
    {   if(a[i]>((long long int)1e18/s))
        {s=-1;break;}
        s=s*a[i];
        
    }
    if(s>1e18 || s<0)
    {
        cout<<"-1";
    }
    else
    {
        cout<<s;
    }
    return 0;
}

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

int main() {
    int N,M; cin >> N >> M;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H.at(i);
    }
    vector<int> maxh(N);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        maxh.at(a-1)=max(maxh.at(a-1),H.at(b-1));
        maxh.at(b-1)=max(maxh.at(b-1),H.at(a-1));
    }
    int ans=0;
    for(int i=0; i<N; i++){
        
        if(maxh.at(i)<H.at(i)) ans++;
    }
    cout << ans << endl;


}


Measured memory_bytes: 4012
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D.exe D.cpp 
Execute: ./D
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 
	// Input 
	int n, k;
	cin >> n >> k;
	int left[k], right[k]; 
	for(int i = 0; i < k; i++) {
		cin >> left[i] >> right[i]; 
	} 
	int mod = 998244353; 
	
	// Solve -- naive? O(N^2) worst case. 
	int r[n+1] = {0};
	r[0] = 0; 
	r[1] = 1; 
	for(int i = 1; i < n; i++) { 
		if(i > 1) {
			r[i] += r[i-1]; 
			r[i] %= mod; 
		}
		for(int w = 0; w < k; w++) {
			if(i + left[w] <= n) {
				r[i + left[w]] += r[i]; 
				r[i + left[w]] %= mod; 
			}
			if(i + right[w] + 1 <= n) { 
				r[i + right[w] + 1] -= r[i];
				r[i + right[w] + 1] += mod;
				r[i + right[w] + 1] %= mod; 
			}
		}
	}
	
	cout << r[n] << endl; 
	
	return 0; 
} 


Measured memory_bytes: 4396
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
  while(1) {
    C-=B;
    if(C <=0) {
      std::cout << YES << std::endl;
      break;
    }
    A-=D;
    if(A<=0){
      std::cout << NO << std::endl;
      break;
    }
  }
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long D;
  scanf("%lld",&D);
  solve(A, B, C, D);
  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define N 100000

int32_t main(){
    IOS;
int n;
cin>>n;
vector<double> dp(n+1 , 0);
dp[0] = 1;
double p;

for(int i=0;i<n;i++)
{
    cin>>p;
    
    for(int j=i+1;j>=0;j--)
    {
        dp[j] = dp[j-1]*p + dp[j]*(1-p);
    }

}

p = 0;
for(int i=n;i>n/2;i--)
p += dp[i];

cout<<fixed<<setprecision(12)<<p<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    ll x;
    cin >> x;
    if (x == 0)
        cout << 1 << "\n";
    else if (x == 1)
        cout << 0 << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3596
y=["01","02","03","04","05","06","07","08","09","10","11","12"]
s=input()
if s[:2] in y:
  if s[2:] in y:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if s[2:] in y:
    print("YYMM")
  else:
    print("NA")


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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const ll mod=1000000007;

int n;
ll sz[210];
ll dp[210][210];
ll dp2[210][210][210];

vi tree[210];

void init(){
	dp2[0][0][0]=1LL;
	rep(i,n+1)rep(j,n+1)rep(k,n+1){
		(dp2[i+1][j+1][k+1]+=dp2[i][j][k])%=mod;
		(dp2[i+1][j][k+1]+=dp2[i][j][k])%=mod;
		(dp2[i][j+1][k+1]+=dp2[i][j][k])%=mod;
	}
}

ll crt[210],nxt[210];

void dfs(int v){
	for(auto v2:tree[v]) dfs(v2);
	sz[v]=1;
	for(auto v2:tree[v]) sz[v]+=sz[v2];

	rep(i,sz[v]) crt[i]=0;
	crt[0]=1LL;
	for(auto v2:tree[v]){
		rep(c,sz[v]) nxt[c]=0;
		rep(a,sz[v])rep(b,sz[v])rep(c,sz[v])
			(nxt[c]+=(crt[a]*dp[v2][b]%mod*dp2[a][b][c]%mod))%=mod;
		rep(c,sz[v]) crt[c]=nxt[c];
	}
	rep(c,sz[v]) dp[v][1+c]=crt[c];
	return;
}

int par[210];

int main(void){
	cin >> n;
	init();
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		tree[a].pb(b);
		par[b]++;
	}
	int root=min_element(par,par+n)-par;
	dfs(root);
	ll ans=0LL;
	rep(i,n+1) (ans+=dp[root][i])%=mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 71124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
ll inf=1e15;
ll solve(ll* dp,int n,int i,ll* h,int k){
	if(i>=n){
		return inf;
	}
	if(dp[i]!=-1){
		return dp[i];
	}
	if(i==n-1){
		return 0;
	}else{
		ll ans=inf;
		for(int j=1;j<=min(n-i-1,k);j++){
			ll tmp=solve(dp,n,i+j,h,k);
			tmp+=abs(h[i]-h[i+j]);
			ans=min(ans,tmp);
		}
		dp[i]=ans;
		return ans;
	}

}
int main()
{	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	ll h[n];
	int k;cin>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}		
	ll dp[n];
	for(int i=0;i<n;i++){
		dp[i]=-1;
	}
	cout<<solve(dp,n,0,h,k)<<ln;
}

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

int main(){
  int64_t K,N;
  cin>>N>>K;
    
  vector<int64_t> A(N);
  map<int64_t,int64_t> S;
  
  for(int i=0;i<N;++i){
    cin>>A.at(i);
    S[A.at(i)]=S[A.at(i)]+1;
  }
  
  int64_t M=S.size();
  
  vector<int64_t> s(M);
  int i=0;
  for(auto p:S){
    s.at(i)=p.second;
    ++i;
  }
  
  sort(s.begin(),s.end());
  int64_t sum=0;  
  
  for(int i=0;i<M-K;++i){
    sum=sum+s.at(i);
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 15872
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0),b=s(1),c=s(2)
    Dim ab=Math.Abs(b-a),bc=Math.Abs(b-c),ca=Math.Abs(c-a)
    Dim ans=Math.Min(ab+bc,Math.Min(bc+ca,ca+ab))
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var S string

func main() {
	readVariables()
	N := len(S)
	a := isP(S)
	b := isP(S[0 : (N-1)/2])
	c := isP(S[(N+1)/2 : N])
	var ans string
	// fmt.Println(a, b, c)
	if a && b && c {
		ans = "Yes"
	} else {
		ans = "No"
	}
	fmt.Println(ans)
}

func readVariables() {
	S = nextStr()
}

func isP(s string) bool {
	l := len(s)
	// fmt.Println(l)
	for i := 0; i < l; i++ {
		if s[i] != s[l-1-i] {
			return false
		}
	}
	return true
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
N = int(input())
p = list(map(int, input().split()))

for i in range(N):
    if p[i] != i+1:
        tmp = p[i]
        p[i], p[tmp-1] = p[tmp-1], p[i]
        break

if p == sorted(p):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    long long int N;
    long long int A[100010];
    scanf("%lld",&N);
    long long int i;
    for(i=1;i<=N;i++){
        scanf("%lld",&A[i]);
    }
    long long int X[100010];
    for(i=1;i<=N;i++){
        if(i%2==0){
            X[1]=X[1]-A[i];
        }else{
            X[1]=X[1]+A[i];
        }
    }
    X[1]=X[1]/2;
    for(i=2;i<=N;i++){
        X[i]=A[i-1]-X[i-1];
    }
    for(i=1;i<=N;i++){
        printf("%lld ",2*X[i]);
    }
}

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

int main(void){
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans;
    if(a==b && b==c){
        ans = "Yes";
    }else if(b==c && c==d){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
x=int(input())

if x>=400 and x<=599:
    print(8)
elif x>=600 and x<=799:
    print(7)
elif x>=800 and x<= 999:
    print(6)
elif x>=1000 and x<= 1199:
    print(5)
elif x>=1200 and x<= 1399:
    print(4)
elif x>=1400 and x<=1599:
    print(3)
elif x >= 1600 and x<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(void){
    int h, w;
    cin>>h>>w;
    for(int z=1; z<=w+2; z++) cout<<"#";
    cout<<'\n';
    string c;
    for(int z=1; z<=h; z++) {
        cin>>c;
        cout<<"#"<<c<<"#"<<endl;
    }
    for(int z=1; z<=w+2; z++) cout<<"#";
    cout<<'\n';
    /*
    char a[100][100];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++){
            cin>>a[i][j];
        }
    }
    */
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll INF=1e18;
struct edge{int to,cost;};
struct dat{
	ll dis;
	int pos,hi;
	dat(ll dis,int pos,int hi):dis(dis),pos(pos),hi(hi){}
	bool operator>(const dat &a) const{
		return dis>a.dis;
	}
};
int n,m,x,a,b,c,last;
int h[100100],t[100100];
ll d[100100];
ll d1[100100];
vector<edge>G[100100];
vector<edge>V[100100];
void dijkstra(int s){
	last=1e9;
	fill(d,d+n,INF);
	priority_queue<dat,vector<dat> ,greater<dat> >Q;
	d[s]=0;
	Q.push((dat){0,s,x});
	while(!Q.empty()){
		dat p=Q.top();Q.pop();
		int v=p.pos,hi=p.hi;
		if(d[v]<p.dis)continue;
		REP(i,G[v].size()){
			edge e=G[v][i];
			if(hi>0){
				if(e.cost/2<hi){
					if(hi>e.cost/2+h[e.to]){
						if(d[e.to]>d[v]+e.cost/2+hi-e.cost/2-h[e.to]){
							if(e.to==n-1)last=h[e.to];
							d[e.to]=d[v]+e.cost/2+hi-e.cost/2-h[e.to];
							Q.push((dat){d[e.to],e.to,h[e.to]});
						}
					}else{
						if(d[e.to]>d[v]+e.cost/2){
							if(e.to==n-1)last=min(h[e.to],hi-e.cost/2);
							d[e.to]=d[v]+e.cost/2;
							Q.push((dat){d[e.to],e.to,min(h[e.to],hi-e.cost/2)});
						}
					}
				}else{
					if(d[e.to]>d[v]+e.cost-hi){
						if(e.to==n-1)last=0;
						d[e.to]=d[v]+e.cost-hi;
						Q.push((dat){d[e.to],e.to,0});
					}
				}
			}else{
				if(d[e.to]>d[v]+e.cost){
					if(e.to==n-1)last=0;
					d[e.to]=d[v]+e.cost;
					Q.push((dat){d[e.to],e.to,0});
				}
			}
		}
	}
}
int main(){
	cin>>n>>m>>x;
	REP(i,n)cin>>h[i];
	REP(i,m){
		cin>>a>>b>>c;a--;b--;
		if(h[a]>=c)G[a].PB((edge){b,c*2});
		if(h[b]>=c)G[b].PB((edge){a,c*2});
		V[a].PB((edge){b,c});
		V[b].PB((edge){a,c});
	}
	dijkstra(0);
	if(d[n-1]>=INF)cout<<-1<<endl;
	else{
		cout<<d[n-1]+h[n-1]-last<<endl;
	}
}

Measured memory_bytes: 24768
/*author : Yashvardhan
Sunday, May 05, 2019
10:22 AM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;
	
	vi pos;
	vi neg;
	vi arr;

	for(int i = 0; i < n ; i++){
		int x;
		cin>>x;
		if(x < 0){
			neg.pb(-1*x);
		}
		else pos.pb(x);
		arr.pb(abs(x));
	}

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

	int ans = 0;
	
	int numn = neg.size();
	if(numn%2 == 0){
		for(int i = 0; i < arr.size() ; i++){
			ans += arr[i];
		}
	}
	else{
		for(int i = 1; i < arr.size() ; i++){
			ans += arr[i];
		}
		ans -= arr[0];
	}

	cout<<ans<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 2412
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

  int sum = 0;
  vector<int> W(N);
  rep(i, N) {
    cin >> W[i];
    sum += W[i];
  }

  int ans = 100000;
  int left = 0;
  int right = 0;
  rep(i, N -1) {
    left += W[i];
    right = sum - left;
    ans = min(ans, abs(left - right));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int time = 0;
  vector<int> wait(5);
 
  for (int i = 0; i < 5; i++) {
    cin >> wait.at(i);
	}
  
  vector<int> class1(5);
  vector<int> class10(5);
 
  for (int i = 0; i < 5; i++) {
    class1.at(i) = wait.at(i)%10;
    class10.at(i) = wait.at(i)/10;
    if(class1.at(i)==0){
      time=time+wait.at(i);
      class1.at(i)=10;
    	}
    else{
       time=time+class10.at(i)*10+10;
        }
	}
  sort(class1.begin(), class1.end());
  time=time-10+class1.at(0);
  cout << time << endl;
}
  
    
    
  
  
  
  

Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        int odd0 = 0, odd1 = 0, even0 = 0, even1 = 0;

        for (int i = 0; i < s.length(); i++) {

            if(i % 2 == 0) {
                if (s.charAt(i) == '0') {
                    odd0++;
                } else {
                    odd1++;
                }
            } else {
                if (s.charAt(i) == '0') {
                    even0++;
                } else {
                    even1++;
                }
            }
        }

        System.out.println(Math.min(odd0 + even1, odd1 + even0));

    }
}

Measured memory_bytes: 26308
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = sc.nextIntList(N);
		
		long count = 0;
		for (int i = 0; i < N - 1; i ++) {
			count += A[i] / 2;
			if (A[i] % 2 == 1 && A[i + 1] > 0) {
				count ++;
				A[i + 1] --;
			}
		}
		
		count += A[N - 1] / 2;

		System.out.println(count);
	}
}



class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 9976
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class SuffixArray {
	void CEB(vector<int> &v, vector<int> &b) {
		int vs = v.size(), bs = b.size();
		fill(b.begin(), b.end(), 0);
		for (int i = 0; i < vs; i++) b[v[i]]++;
		for (int i = 1; i < bs; i++) b[i] += b[i - 1];
	}
	void ISort(vector<int> &v, vector<int> &SA, int mv, vector<int> &b, vector<int> &isL) {
		int vs = v.size(), bs = b.size();
		fill(b.begin(), b.end(), 0);
		for (int i = 0; i < vs; i++) b[v[i]]++;
		int sum = 0;
		for (int i = 0; i < bs; i++) b[i] += sum, swap(sum, b[i]);
		for (int i = 0; i < vs; i++) {
			if (SA[i] > 0 && isL[SA[i] - 1]) SA[b[v[SA[i] - 1]]++] = SA[i] - 1;
		}
	}
	void IISort(vector<int> &v, vector<int> &SA, int mv, vector<int> &b, vector<int> &isL) {
		CEB(v, b);
		for (int i = v.size() - 1; i >= 0; i--) {
			if (SA[i] > 0 && !isL[SA[i] - 1]) SA[--b[v[SA[i] - 1]]] = SA[i] - 1;
		}
	}
	vector<int>SA_IS(vector<int> v, int mv) {
		int vs = v.size();
		if (vs == 1) return vector<int>(1, 0);
		vector<int> isL(vs), b(mv + 1), SA(vs, -1), ord(vs);
		auto isLMS = [&](int x)->bool { return x > 0 && isL[x - 1] && !isL[x]; };
		for (int i = vs - 2; i >= 0; i--) isL[i] = (v[i] > v[i + 1]) || (v[i] == v[i + 1] && isL[i + 1]);
		CEB(v, b);
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) SA[--b[v[i]]] = i;
		}
		ISort(v, SA, mv, b, isL);
		IISort(v, SA, mv, b, isL);
		int cur = 0;
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) ord[i] = cur++;
		}
		vector<int> nxv(cur);
		cur = -1;
		int prev = -1;
		for (int i = 0; i < vs; i++) {
			if (!isLMS(SA[i])) continue;
			bool diff = false;
			for (int d = 0; d < vs; d++) {
				if (prev == -1 || v[SA[i] + d] != v[prev + d] || isL[SA[i] + d] != isL[prev + d]) {
					diff = true;
					break;
				}
				else if (d && isLMS(SA[i] + d))break;
			}
			if (diff) cur++, prev = SA[i];
			nxv[ord[SA[i]]] = cur;
		}
		vector<int> reord(nxv.size());
		for (int i = 0; i < vs; i++) {
			if (isLMS(i)) reord[ord[i]] = i;
		}
		vector<int> nxSA = SA_IS(nxv, cur);
		CEB(v, b);
		for (int i = 0; i < SA.size(); i++) SA[i] = -1;
		for (int i = nxSA.size() - 1; i >= 0; i--) {
			SA[--b[v[reord[nxSA[i]]]]] = reord[nxSA[i]];
		}
		ISort(v, SA, mv, b, isL);
		IISort(v, SA, mv, b, isL);
		return SA;
	}
	vector<int>SA_IS(string s) {
		vector<int> v(s.size() + 1);
		for (int i = 0; i < s.size(); i++) v[i] = s[i] + 1;
		return SA_IS(v, *max_element(v.begin(), v.end()));
	}
public:
	string s;
	vector<int> sa;
	void init(string &T) {
		s = T;
		sa = SA_IS(s);
	}
	SuffixArray(string &t) { init(t); }
	SuffixArray() {}
	bool contain(string &t) {
		int a = 0, b = s.size();
		while (b - a > 1) {
			int c = (a + b) / 2;
			if (s.compare(sa[c], t.size(), t) < 0) a = c;
			else b = c;
		}
		return s.compare(sa[b], t.size(), t) == 0;
	}
};
int q; string s, t;
int main() {
	cin >> s >> q;
	SuffixArray v(s);
	for(int i = 0; i < q; i++) {
		cin >> t;
		cout << (v.contain(t) ? 1 : 0) << endl;
	}
}

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

const long long INF = 10000000000LL;
long long G[100][100];

int main() {
  int V, E; cin >> V >> E;
  for(int i = 0; i < V; i++) {
    for(int j = 0; j < V; j++) {
      G[i][j] = INF;
    }
    G[i][i] = 0;
  }
  for(int i = 0; i < E; i++) {
    long long from, to, d;
    cin >> from >> to >> d;
    G[from][to] = min(G[from][to], d);
  }
  for(int k = 0; k < V; k++)
    for(int i = 0; i < V; i++)
      for(int j = 0; j < V; j++)
        if(G[i][k] != INF && G[k][j] != INF)
          G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

  bool negative_loop = false;
  for(int v = 0; v < V; v++)
    if(G[v][v] < 0) negative_loop = true;

  if(negative_loop) {
    cout << "NEGATIVE CYCLE" << endl;
  }
  else {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        if(j != 0) cout << ' ';

        if(G[i][j] == INF) cout << "INF";
        else cout << G[i][j];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1240
h,w,k = map(int,input().split())
c = [input() for i in range(h)]

gyo = []
retu = []

def gyoretu(l,n,gr):
    if len(l) == n:
        if gr == 0:
            global gyo
            gyo.append(l)
        else:
            global retu
            retu.append(l)
    else:
        gyoretu(l+[0],n,gr)
        gyoretu(l+[1],n,gr)

gyoretu([],h,0)
gyoretu([],w,1)

ans = 0

for Gyo in range(len(gyo)):
    for Retu in range(len(retu)):
        count = 0
        for i in range(h):
            for j in range(w):
                if gyo[Gyo][i] == 1 and retu[Retu][j] == 1:
                    if c[i][j:j+1] == "#":    
                        count += 1
        if count == k:
 #           print(gyo[Gyo],retu[Retu])
            ans += 1
print(ans)
        

Measured memory_bytes: 9192
#include <iostream>

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  int count = a-1; //a月より前まではTakahashiがある

  //a月で，bがa以上ならばTakahashiがある
  if(a<=b)
    count++;
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a == c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1:
    if b == 2:
        print("3")
    elif b == 3:
        print("2")

elif a == 2:
    if b == 1:
        print("3")
    elif b == 3:
        print("1")

elif a == 3:
    if b == 1:
        print("2")
    elif b == 2:
        print("1")

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


int main() {
    int N, D;
    std::cin >> N >> D;

    std::vector<std::vector<int>> points(N, std::vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            std::cin >> points[i][j];
        }
    }

    auto calc_dist = [&D] (const std::vector<int>& pt0, const std::vector<int>& pt1) {
        int square = 0;
        for (int i = 0; i < D; i++) {
            square += (pt0[i] - pt1[i]) * (pt0[i] - pt1[i]);
        }
        return square;
    };

    std::vector<int> squares;
    int idx = 1;
    int maximum = std::sqrt(40 * 40 * 10) + 1;
    while (idx <= maximum) {
        squares.emplace_back(idx * idx);
        idx++;
    }

    int count = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            int val = calc_dist(points[i], points[j]);
            if (std::find(squares.begin(), squares.end(), val) != squares.end()) {
                count++;
            }
        }
    }
    std::cout << count << std::endl;
}


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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		double r = Double.parseDouble(br.readLine());
		if((0 < r) && (r <= 10000)){
			double f = ((double)(r * r)*Math.PI);
			double d = ((double)(r * 2)*Math.PI);

			System.out.printf("%1.6f %1.6f",f , d);
		}
	}
}

Measured memory_bytes: 24648
#include<stdio.h>
int main()
{
	int rou,tim;
	int a,b;
	int sum=0,t=0;
	scanf("%d%d",&rou,&tim);
	for(int i=0;i<rou;i++)
	{
		scanf("%d%d",&a,&b);
		if(b<=tim)
		{
		    if(t==0)
		    {
		    		sum=a;
		         	t=1;
			}
			else
			{
				if(a<sum) sum=a; 
			}
		}
	}
	if(t==0) printf("TLE");
	else printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var N, L int
	fmt.Scan(&N, &L)

	S := make([]string, N)

	for i := range S {
		fmt.Scan(&S[i])
	}
	sort.Strings(S)
	fmt.Println(strings.Join(S, ""))
}


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

int f(int y,int m,int d){
	const int year = 365;
	int month[] = {31,28,31,30,31,30,31,31,30,31,30,31},c;
	c = 0;
	for(int i = 1;i < y;++i){
		c += year;
		if(i % 100 == 0){ 
			if(i % 400 == 0) ++c;
		}
		else if(i % 4 == 0) ++c; 
	}
	for(int i = 0;i < m - 1;++i){
		c += month[i];
		if(i == 1){
			if(y % 100 == 0){
				if(y % 400 == 0) ++c;
			}
			else if(y % 4 == 0) ++c;
		}
	}
	c += (d - 1);
	return c;
}

int main(){
	int y1,m1,d1,y2,m2,d2;
	while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2,d1 > 0){
		cout << f(y2,m2,d2) - f(y1,m1,d1) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef map<string,int> msi;

/* global variables */

msi pfxmap;

/* subroutines */

/* main */

int main() {
  pfxmap["yotta"] = 24;
  pfxmap["zetta"] = 21;
  pfxmap["exa"] = 18;
  pfxmap["peta"] = 15;
  pfxmap["tera"] = 12;
  pfxmap["giga"] = 9;
  pfxmap["mega"] = 6;
  pfxmap["kilo"] = 3;
  pfxmap["hecto"] = 2;
  pfxmap["deca"] = 1;
  pfxmap["deci"] = -1;
  pfxmap["centi"] = -2;
  pfxmap["milli"] = -3;
  pfxmap["micro"] = -6;
  pfxmap["nano"] = -9;
  pfxmap["pico"] = -12;
  pfxmap["femto"] = -15;
  pfxmap["ato"] = -18;
  pfxmap["zepto"] = -21;
  pfxmap["yocto"] = -24;

  int tn;
  cin >> tn;

  while (tn--) {
    string nstr, pstr, ustr;
    cin >> nstr >> pstr;

    msi::iterator mit = pfxmap.find(pstr);
    int pexp = 0;
    
    if (mit == pfxmap.end())
      ustr = pstr;
    else {
      cin >> ustr;
      pexp = mit->second;
    }

    int prd = nstr.find('.', 0);
    int fp, np = nstr.length() - 1;
    
    if (prd == string::npos)	// no period
      prd = np;
    else {	// found period
      nstr.erase(prd, 1);
      prd--;
      np--;
    }

    for (fp = 0; fp <= np && nstr[fp] == '0'; fp++);
    if (fp > 0) {
      nstr.erase(0, fp);
      prd -= fp;
      np -= fp;
    }

    if (np > 0) nstr.insert(1, ".");

    cout << nstr << " * 10^" << (prd + pexp) << ' ' << ustr << endl;
  }

  return 0;
}

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

int main()
{
	int height[10];
	int TopOfThree[3];

	for (int i = 0; i < 10; i++)
		cin >> height[i];

	for (int i = 0; i < 3; i++)
	{
		int index;
		TopOfThree[i] = height[0];
		for (int j = 1; j < 10 - i; j++)
		{
			if (TopOfThree[i] < height[j])
			{
				TopOfThree[i] = height[j];
				index = j;
			}
		}

		for (int k = index; k < 10 - i; k++)
		{
			if (k == 9 - i)
				height[k] = 0;
			else
				height[k] = height[k + 1];
		}
		cout << TopOfThree[i] << endl;
	}

	int i;
	cin >> i;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  int bf=-1,bl=-1;
  rep(i,h){
    int f=-1,l=-1;
    string s;
    cin>>s;
    rep(j,w){
    //  cout<<w<<":"<<s[j]<<endl;
      if (s[j]=='#'){
        if(f==-1) {
          f=j;
          l=j;
        }
        else l=j;
      }
    }
//      cout<<f<<","<<l<<endl;
      if (bl!=-1 and bl!=f){
        cout<<"Impossible"<<endl;
        return 0;
      }
      bl=l;
  }
  cout<<"Possible"<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
def f():
    cnt = Counter(A)
    m = N - 1
    for k, v in cnt.items():
        if k == 0:
            if v == 1:
                continue
            else:
                return 0
        else:
            if v != 2 or k > m:
                return 0
    return pow(2, N//2, 10**9 + 7)

print(f())

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

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


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a>b){
    for(int i=0; i<a; ++i){
      cout << b;
    }
  }
  else{
    for(int i=0; i<b; ++i){
      cout << a;
    }
  }
  cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;

  CIN(N);

  int d[N];
  for (int i = 0; i < N; i++) {
    CIN(d[i]);
  }

  int total = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      total += d[i] * d[j];
    }
  }

  COUT(total)

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    double s[n],a = 0;
    double m = 0;
    for(int i=0;i<n;i++){
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for(int i=0;i<n;i++) a = a + (s[i]-m) * (s[i]-m);
    a /= n;
    cout << fixed << setprecision(5) << sqrt(a) << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define LL long long
  
using namespace std;
  
inline char nc(){
    /* 
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
    */return getchar();
}
  
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
  
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline int read(char *s)
{
    char c=nc();int len=1;
    for(;!(c>='a' && c<='z');c=nc()) if (c==EOF) return 0;
    for(;(c>='a' && c<='z');s[len++]=c,c=nc());
    s[len++]='\0';
    return len-2;
}
 
inline void read(char &x){
  for (x=nc();!(x>='A' && x<='Z');x=nc());
}
 
int wt,ss[19];
inline void print(int x){
    if (x<0) x=-x,putchar('-'); 
    if (!x) putchar(48); else {
    for (wt=0;x;ss[++wt]=x%10,x/=10);
    for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
    if (x<0) x=-x,putchar('-');
    if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

LL N,A,B,C,D,Min,Max;

bool check(LL x)
{
	if (Min<=x&&Max>=x) return true;
	for (LL i=1;i<=(N-1);i++)
	{
		Min=Min-C-D;Max=Max-C-D;
		if (Min<=x&&Max>=x) return true;
	}
	return false;
}

int main()
{
	read(N);read(A);read(B);read(C);read(D);
	LL x=B-A;Min=C*(N-1);Max=D*(N-1);
	if (check(B-A)) puts("YES");else puts("NO");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
   int X;
   int bighappy = 1000;
   int smallhappy = 5;
   int totalhappy = 0;
   scanf("%d",&X);

   totalhappy = (X/500*1000)+(X%500/5*5);

   printf("%d",totalhappy);

   return 0;
}
   

Measured memory_bytes: 1700
#include <iostream>

int main(){
	int n;
	bool flag = false;

	std::cin >> n;

	for(int i = 0; i <= 25; ++i){
		for(int j = 0; j <= 14; ++j){
			int tot = 4 * i + 7 * j;
			if(tot == n){
				flag = true;
			}
		}
	}

	if(flag){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;

namespace Contest148
{
	class Program
	{
		static void Main(string[] args)
		{
			string strs = Console.ReadLine();
			char str1;
			char str2;
			int count = strs.Length / 2;
			int numOfHug = 0;
			for(int i = 0; i < count; i++)
			{
				str1 = strs[i];
				str2 = strs[strs.Length - (i + 1)];

				if(str1 == str2)
				{
					continue;
				}
				else
				{
					numOfHug++;
				}
			}

			Console.WriteLine(numOfHug);
		}
	}
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
	int house[4][3][10] = {0};
	int b,f,r,v,i,n,j,k,l;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);

		house[b-1][f-1][r-1] = house[b - 1][f - 1][r - 1] + v;
	}

	for (j = 0; j < 4; j++)
	{
		for (k = 0; k < 3; k++)
		{
			for (l = 0; l < 10; l++)
			{
				printf(" %d", house[j][k][l]);
			}
			printf("\n");
		}

		if(j!=3)
		{
			printf("####################\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2052
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

int dp[3005][3005][5];
int val[3005][3005];

class EPickingGoods {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        CLR(dp, 0);
        CLR(val, 0);
        int R, C, K;
        cin >> R >> C >> K;
        REP(i, K) {
            int r, c, v;
            cin >> r >> c >> v;
            r--, c--;
            val[r][c] = v;
        }

        dp[0][0][1] = val[0][0];
        REP(i, R) {
            REP(j, C) {
                REP(k, 4) {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                    dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + val[i + 1][j]);
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                    dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + val[i][j + 1]);
                }
            }
        }

        int res = 0;
        REP(k, 4) {
            res = max(res, dp[R-1][C-1][k]);
        }
        cout << res << endl;
    }
};



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EPickingGoods solver;
    solver.solve(in, out);
    return 0;
}


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

int n;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    ans += min(A, K);
    K -= A;
    if(K > 0) {
        K -= B;
    }
    if(K > 0) {
        ans -= min(K, C);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = [int(i) for i in input().split()]
cnt_a = [0] * (10**5 + 2)
for i in range(n):
    cnt_a[a[i]] += 1
max_cnt = 0
for i in range(1, 10**5 + 1):
    max_cnt = max(max_cnt, sum(cnt_a[i - 1:i + 2]))
print(max_cnt)

Measured memory_bytes: 13964
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long k = scanner.nextLong();

        final int[] ones = new int[40];
        final int[] zeros = new int[40];

        for (int i = 0; i < n; i++) {
            final long ai = scanner.nextLong();
            final char[] aiBinary = Long.toBinaryString(ai).toCharArray();

            for (int j = 0; j < aiBinary.length; j++) {
                if (aiBinary[aiBinary.length - j - 1] == '0') {
                    zeros[j]++;
                } else {
                    ones[j]++;
                }
            }

            for (int j = aiBinary.length; j < 40; j++) {
                zeros[j]++;
            }
        }

        final char[] kBinary = Long.toBinaryString(k).toCharArray();
        long answer = 0;

        boolean free = false;
        for (int i = kBinary.length - 1; i >= 0; i--) {
            if (free) {
                final int max = Math.max(zeros[i], ones[i]);
                answer += (long)max * longPow(i);
                continue;
            }

            if (kBinary[kBinary.length - i - 1] == '0') {
                answer += (long)ones[i] * longPow(i);
                continue;
            }

            if (zeros[i] > ones[i]) {
                answer += (long)zeros[i]  * longPow(i);
                continue;
            }

            answer += (long)ones[i] * longPow(i);
            free = true;
        }

        for (int i = kBinary.length;i<40;i++){
            answer += (long)ones[i] * longPow(i);
        }

        System.out.println(answer);
    }

    private static long longPow(final int a) {
        return (long) Math.pow(2, a);
    }

    private static char[] reverseCharArray(final char[] charArray) {
        final int length = charArray.length;
        final char[] reversedCharArray = new char[length];
        for (int i = 0; i < length; i++) {
            reversedCharArray[i] = charArray[length - i - 1];
        }

        return reversedCharArray;
    }
}


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

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<int> vec1(n), vec2(n);
	for(int i = 0; i < n; i++) cin >> vec1[i];
	vec2 = vec1;
	sort(vec2.begin(), vec2.end());
	for(int i = 0; i < n; i++){
		int val = vec2[n/2 - 1];
		if(val >= vec1[i]){
			cout << vec2[n/2] << "\n";
		}
		else if(val < vec1[i]){
			cout << vec2[n/2 - 1] << "\n";
		}
	}
}

Measured memory_bytes: 3712