akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int main()
{
  // int a,b,c;
  // cin >> a >> b >> c;
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  sort(a,a+3);
  cout << (a[0] + a[1]) << endl;

  return 0;
}


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

using namespace std;

int main(void){
    int N, M;
    const long long MOD = (1E9+7);
    cin >> N >> M;
    vector<long long> p(N + 10, 0);
    p[0] = 1;
    for(int i = 0; i < M; i++){
        int a;
        cin >> a;
        p[a] = -1;
    }
    for(int i = 0; i < N; i++){
        if(p[i] == -1) continue;
        if(p[i + 1] != -1){
            p[i + 1] += p[i];
            p[i + 1] %= MOD;
        }
        if(p[i + 2] != -1){
            p[i + 2] += p[i];
            p[i + 2] %= MOD;
        }
    }
    cout << p[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, l;
  cin >> n >> l;
  i64 s = 0, x = 1 << 30;
  for (i64 i = 0; i < n; ++i) {
    s += l + i;
    if (abs(x) > abs(l + i)) x = l + i;
  }
  s -= x;
  cout << s << '\n';
  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  
  bool k = true;
  rep(i,n) if (s[i] != t[i]) k = false;
  
  if (k) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	map<string, int> p = {};
	string s;
	int n, m, ans = 0 , count = 0;
	string t[100];
	cin >> n;
	FOR(i, 0, n) {
		cin >> s;
		if (p[s] == 0) {
			t[count] = s;
			++count;
		}
		++p[s];
	}
	cin >> m;
	FOR(i, 0, m) {
		cin >> s;
		--p[s];
	}
	FOR(i, 0, count) {
		ans = max(ans, p[t[i]]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int length = Integer.parseInt(scan.nextLine());
		String str = scan.nextLine();
		int countMax = 0;

		for(int i = 0; i < length - 1; i++){
			String a = str.substring(0, i + 1);
			String b = str.substring(i + 1, length);

			int count = count(a, b);
			if(countMax < count){
				countMax = count;
			}
		}

		System.out.println(countMax);
	}

	public static int count(String a, String b){
		HashSet<Character> set1 = new HashSet<>();
		HashSet<Character> set2 = new HashSet<>();
		for(char c : a.toCharArray()){
			set1.add(c);
		}
		for(char c : b.toCharArray()){
			set2.add(c);
		}
		set1.retainAll(set2);
		return set1.size();
	}
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<pair<int, int>> F;
   vector<int> A;
   int x = n;
   for(int i=2;i*i<=x;i++){
      if(x%i == 0){
         F.pb({i,0});
         while(x%i == 0){
            F.back().S++;
            x /= i;
         }
         A.pb(F.back().S);
      }
   }
   if(x>1){
      A.pb(1);
   }
   int op = 0;
   for(auto &e : A){
      int mx = 0;
      while(mx*(mx+1)/2 <= e){
         mx++;
      }
      mx--;
      op += mx;
   }
   cout << op;
   return 0;
}

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

typedef int i ;
typedef double d ;
typedef string s ;

int main ()
{
   i numA , numP , res ;
   cin >> numA >> numP ;
   res = ((numA * 3) + numP ) / 2 ;
   cout << res << endl ;
    //its_Rashid
    return 0 ;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var number = int.Parse(Console.ReadLine());

            if (number % 2 == 0)
            {
                Console.WriteLine(number);
            }
            else
            {
                Console.WriteLine(number * 2);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+10,INT_MAX);
    vector<int> B(N+10,INT_MAX);
    vector<int> C(N+10,INT_MAX);

    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    for(int i=1;i<=N;i++){
        cin >> B[i];
    }
    for(int i=1;i<=N-1;i++){
        cin >> C[i];
    }

    int score = 0;
    for(int i=1;i<=N;i++){
        score += B[A[i]];
        if(A[i]-1 == A[i-1]) {
            score += C[A[i-1]];
            }
    }

    cout << score << endl;

    return 0;

}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 200010;

int N, M;
string s;
vi g[MN];
int num[MN][2];
bool er[MN];

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

	rep(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;

		if (s[b] == 'A') {
			++num[a][0];
		} else {
			++num[a][1];
		}

		if (s[a] == 'A') {
			++num[b][0];
		} else {
			++num[b][1];
		}	

		g[a].pb(b); g[b].pb(a);
	}

	queue<int> que;

	int dec = N;

	rep(i, N) {
		if (num[i][0] == 0 || num[i][1] == 0) {
			que.push(i);
			er[i] = 1;
		}
	}

	while (!que.empty()) {
		--dec;
		int v = que.front(); que.pop();
		int c = (s[v] != 'A');

		for (int to : g[v]) {
			if (--num[to][c] == 0 && !er[to]) {
				que.push(to);
				er[to] = 1;
			}
		}
	}

	puts(dec > 0 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 12548
module ABC083B
	sub Main(ByVal args() as String)
		dim n,a,b,r,i,j,s as integer
		dim arr(3) as string
		arr=Split(Console.ReadLine())
		n=arr(0):a=arr(1):b=arr(2)
		r=0
		for i=1 to n
			s=0
			j=i
			while j>0
				s+=j mod 10
				j\=10
			end while
			if a<=s andalso s<=b
				r+=i
			end if
		next
		Console.WriteLine(r)
	end sub
end module


Measured memory_bytes: 13536
import itertools
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R.sort()

out = P[-X:] + Q[-Y:]

out.sort()
for i in range(min(C, X+Y)):
  if R[-i-1] > out[i]:
    out[i] = R[-i-1]
  else:
    break
print(sum(out))


Measured memory_bytes: 22720
($A, $B, $C, $X, $Y)=split / /, <>;
$a=$X;
$b=$Y;
$price=$A*$a+$B*$b;
for($c=2;;$c+=2){
	$prev=$price;
	$a--;$b--;
	$a=0 if $a < 0;
	$b=0 if $b < 0;
	$price=$A*$a+$B*$b+$C*$c;
	last if $price > $prev;
}
print $prev, "\n";


Measured memory_bytes: 512
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, k:i64, x:[i64;n]};
    println!("{}", x.iter().map(|&t| min(t*2, 2*(k-t).abs())).sum::<i64>());
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a < b)
		swap(a, b);
	if(a < c)
		swap(a, c);
	if(b < c)
		swap(b, c);
	int sum = a - b;
	c += sum;
	if((a - c) % 2 == 0)
		sum += ((a - c) / 2);
	else
		sum += ((a - c) / 2 + 2);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations_with_replacement


def main():
    input = sys.stdin.buffer.readline
    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    li = [0] * m
    for i in range(1, m + 1):
        li[i - 1] = i
    max_point = 0
    for a in combinations_with_replacement(li, n):
        point = 0
        for qer in query:
            if a[qer[1] - 1] - a[qer[0] - 1] == qer[2]:
                point += qer[3]
        if point > max_point:
            max_point = point
    print(max_point)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67596
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

vl vb;
int N;

class triplet{ll f, s, t;};

vl in(ll n){
    vl ar;
    ll x;
    f(i,n)
    cin>>ar[i];
    return ar;
}
vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void printArray(vector<int> arr, int n) 
{ 
    ll num=0;
    for (int i = 0; i < n; i++) 
    num*=10, num+=i;

    if(n==N)
    vb.pb(num);
        
} 

int printfactorialof(int n){
    if(n<=1)
        return 1;
    
    return n*printfactorialof(n-1);
}

void solve(){
ll N,x,ans=0;
vl v;
cin>>N;
f(i, N)
{cin>>x, v.pb(x);
while(x%2==0){
    ans+=1;
    x/=2;
}
}

cout<<ans,nl
}

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

Measured memory_bytes: 3788
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int f(const int d, const int n) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    return ans;
}

int main(void) {
    int L, R, d;
    cin >> L >> R >> d;

    cout << f(d, R) - f(d, L - 1) << endl;

    return 0;
}


Measured memory_bytes: 3560
dic={1:0,2:0,3:0,4:0,5:0,6:0}
n=int(input())
for i in range(n):
    N=float(input())
    if N<165:dic[1] +=1
    elif 165<=N<170:dic[2] +=1
    elif 170<=N<175:dic[3] += 1
    elif 175<=N<180:dic[4] += 1
    elif 180<=N<185:dic[5] += 1
    else:dic[6] +=1
for i in range(6):print("%d:"%(i+1)+"*"*dic[i+1])


Measured memory_bytes: 5612
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define int long long
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
 
 
int32_t main()
{
	IOS;
	string str;
	cin>>n;
	if(n%2){
		cout<<0<<ln;
	}
	else{
		int ans=0;
		ll orig=n;
		n/=2;
		while(n){
			ans+=n/5;
			n/=5;
		}
		cout<<ans<<ln;
		// int flag=0;
		// while(true){
		// 	if(orig%10==0){
		// 		flag=1;
		// 		break;
		// 	}
		// 	else if(orig%5==0 && orig%2){
		// 		break;
		// 	}
		// 	orig--;
		// }
	}
}

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

int main() {
  int N;
  cin >> N;
  set<string> prize{};
  string p;
  for (int i = 0; i < N ; i++){
    cin >> p;
    prize.insert(p);
  }
  cout << prize.size() << endl;
}


Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}

int main(){
  int n;
  cin >>n;
  vector<int>a(n);
  vector<ll>x(n+1);
  rep(i,n){cin>>a[i];}
  x[0]=abs(a[0]-0ll);
  for(int i=1;i<n;i++){
  	x[i]=abs(a[i]-a[i-1]);
  }
  x[n]=abs(a[n-1]-0ll);
  ll sum=0;
  rep(i,n+1){sum+=x[i];}
  //i=0のとき
  cout<<sum-x[0]-x[1]+abs(a[1]-0ll)<<endl;
  for(int i=1;i<=n-2;i++){
  	cout<<sum-x[i]-x[i+1]+abs(a[i+1]-a[i-1])<<endl;
  }
  cout<<sum-x[n-1]-x[n]+abs(a[n-2]-0);
}

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

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

	int w[N];
	int v[N];
	
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	
	int DP[N+1][W+1];
	for(int i=0;i<=W;i++){
		DP[0][i]=0;
	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i-1]){
				DP[i][j]=DP[i-1][j];
			}else{
				if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1]){
					DP[i][j]=DP[i-1][j];
				}else{
						DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
				}
			}
		}
	}
		cout<<DP[N][W]<<endl;


	return 0;
}

Measured memory_bytes: 7012
a,b,c,d = map(int,input().split())

if(b<c or d<a):print(0)
##elif(b==c or d==a):
##    if(b == 0 or d==0):print(0)
##    else:print(1)
else:
    start = a if a>c else c
    end = b if b<d else d
    print(end - start)



Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int i=0,n;
    char str[101]={};
    scanf("%s",str);
    while (str[i]!='\0') i++;
    n=i;
    for (i=0; i<(n-1)/2; i++) {
        if (str[i]!=str[n-1-i]) {
            printf("No");
            return 0;
        }
    }
    for (i=0; i<(n-1)/4; i++) {
        if (str[i]!=str[(n-1)/2-1-i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __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...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n; cin >> n;
	vector<vector<int>>arr(n + 5, vector<int>(5));
	vector<vector<int>>dp(n + 5, vector<int>(5, INT_MAX));

	rep(i, n) cin >> arr[i][1] >> arr[i][2] >> arr[i][3];

	dp[n][1] = arr[n][1];
	dp[n][2] = arr[n][2];
	dp[n][3] = arr[n][3];

	for (int i = n - 1; i >= 1; i--)
	{
		dp[i][1] = max(dp[i + 1][2], dp[i + 1][3]) + arr[i][1];
		dp[i][2] = max(dp[i + 1][1], dp[i + 1][3]) + arr[i][2];
		dp[i][3] = max(dp[i + 1][1], dp[i + 1][2]) + arr[i][3];
	}

	cout << max(dp[1][1], max(dp[1][2], dp[1][3]));
}

Measured memory_bytes: 17200
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
using namespace std;

#define ll long long

ll help(ll A, ll B, ll K) {
    ll ans = B/K - (A-1)/K;
    return ans;
}
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}

int main(int argc, const char * argv[]) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll x = C * D / gcd(C, D);
    ll ans = B - A + 1 - help(A, B, C) - help(A, B, D) + help(A, B, x);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define SQ(a) ((a) * (a))
#define EPS 1e-2
typedef struct {
	double x;
	double y;
} POINT;

double area(double a, double b, double c)
{
	double s;
	s = (a + b + c) / 2;
	return(sqrt(s * (s - a) * (s - b) * (s - c)));
}

int main(void)
{
    int n;
	POINT a, b, c, p, k;
	double ab, bc, ca, ap, bp, cp, ak, bk, ck;
    
    scanf("%d", &n);
    
	while (n--){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &p.x, &p.y, &k.x, &k.y);
		ab = sqrt(SQ(a.x - b.x) + SQ(a.y - b.y));
		bc = sqrt(SQ(b.x - c.x) + SQ(b.y - c.y));
		ca = sqrt(SQ(c.x - a.x) + SQ(c.y - a.y));
		ap = sqrt(SQ(a.x - p.x) + SQ(a.y - p.y));
		bp = sqrt(SQ(b.x - p.x) + SQ(b.y - p.y));
		cp = sqrt(SQ(c.x - p.x) + SQ(c.y - p.y));
		ak = sqrt(SQ(a.x - k.x) + SQ(a.y - k.y));
		bk = sqrt(SQ(b.x - k.x) + SQ(b.y - k.y));
		ck = sqrt(SQ(c.x - k.x) + SQ(c.y - k.y));
        
		if ((fabs(area(ab ,bc ,ca) - area(ap, bp, ab) - area(ap, cp, ca) - area(bp, cp, bc)) < EPS && fabs(area(ab ,bc ,ca) - area(ak, bk, ab) - area(ak, ck, ca) - area(bk, ck, bc)) < EPS) || (fabs(area(ab ,bc ,ca) - area(ap, bp, ab) - area(ap, cp, ca) - area(bp, cp, bc)) > EPS && fabs(area(ab ,bc ,ca) - area(ak, bk, ab) - area(ak, ck, ca) - area(bk, ck, bc)) > EPS)){
			printf("NG\n");
		}
		else {
			printf("OK\n");
		}
	}
	
	return (0);
}

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

using namespace std;

int N, ap[209];
const int mod = 1e9 + 7;
char sir[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
scanf ("%s", sir + 1);
for (int i=1; i<=N; i++)
    ap[sir[i]] ++;
int ans = 1;
for (int i='a'; i<='z'; i++)
    ans = (1LL * ans * (ap[i] + 1)) % mod;
if (--ans < 0)
    ans += mod;
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

struct dice {
	int eye[6];
};

void rightroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[3];
	a->eye[3] = a->eye[5];
	a->eye[5] = a->eye[2];
	a->eye[2] = s;
}
void beyoroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[1];
	a->eye[1] = a->eye[5];
	a->eye[5] = a->eye[4];
	a->eye[4] = s;
}
void thisroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[4];
	a->eye[4] = a->eye[5];
	a->eye[5] = a->eye[1];
	a->eye[1] = s;
}
void leftroll(struct dice *a){
	int s = a->eye[0];
	a->eye[0] = a->eye[2];
	a->eye[2] = a->eye[5];
	a->eye[5] = a->eye[3];
	a->eye[3] = s;
}
void rsideroll(struct dice *a){
	int s = a->eye[1];
	a->eye[1] = a->eye[2];
	a->eye[2] = a->eye[4];
	a->eye[4] = a->eye[3];
	a->eye[3] = s;
}
void lsideroll(struct dice *a){
	int s = a->eye[1];
	a->eye[1] = a->eye[3];
	a->eye[3] = a->eye[4];
	a->eye[4] = a->eye[2];
	a->eye[2] = s;
}

int search(struct dice *a, struct dice *b){
	int i, j,k;
	int c = 0; //カウント用,=6で一致
	for (i = 0; i < 6; i++){
		if (a->eye[i] == b->eye[0]){
			c++;
			break;
		}
	} //串刺し固定
	if (c == 0)
		return 0;
	switch (i){
	case 0:
		break;
	case 1:
		beyoroll(a);
		break;
	case 2:
		leftroll(a);
		break;
	case 3:rightroll(a);
		break;
	case 4:
		thisroll(a);
		break;
	case 5:
		leftroll(a);
		leftroll(a);
		break;
	} //固定完了

	for (k = 0; k < 4; k++){
		for (j = 0; j < 4; j++){
			i = 0;
			c = 1;
			for (i = 1; i < 6; i++){
				if (a->eye[i] == b->eye[i]){
					c++;
				}
				if (c == 6){
					return 1;
				}
			}
			lsideroll(a);
		}
		beyoroll(a);
	}
	return 0;
}

int main(void){
	struct dice a,b;
	int n=0;
	int i = 0;
	for (; i < 6; i++){
		scanf("%d", &a.eye[i]);
	}
	for (i=0; i < 6; i++){
		scanf("%d", &b.eye[i]);
	}

	if (search(&a,&b)==1)
	    printf("Yes\n");
	else
		printf("No\n");


	return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>

int main(){
  int d;  scanf("%d", &d);
  int c[30], s[370][30], t[370] = {0}, last[30] = {0};
  for(int i=1; i<=26; i++)  scanf("%d", c+i);
  for(int i=1; i<=d; i++)  for(int j=1; j<=26; j++)  scanf("%d", &s[i][j]);

  for(int i=1; i<=d; i++)
    printf("%d\n", i%26+1);

  return 0;
}


Measured memory_bytes: 1780
import java.util.*;

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

        int A[] = new int[110];
        int N = sc.nextInt();
        int D = sc.nextInt();     //日数
        int X = sc.nextInt();     //残ったチョコ

        int count = 0;
        int i = 0;

        for(i = 0;i<N;i++){
            A[i] = sc.nextInt();
            
            for(int j = 1;j<=D;j=j+A[i]){
                count++;
            }
        }

        System.out.println((X+count));

    
    
    }



}

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

using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

#ifndef DEBUG
	#pragma GCC optimize ("Ofast")
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
auto mapf(auto a, auto f){for(auto& x:a)x=f(x); return a;}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1);
#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
  int n; cin>>n;
	string s; cin>>s;
	int ans=0;
	for(int i=0;i<sz(s)-2;i++)
		if(s.substr(i,3)=="ABC")
			ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  long ans;
  ans = k * pow(k - 1, n - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0 ;
  for(int i=1;i <=N;i++){
    int t=i;
    int c;
    int sum=0 ;
    while(t > 0){
      c = t %10 ;
      sum+= c ;
      t = t/10 ;
    }
    if(A <= sum && sum <= B)
      ans += i ;
  }
  cout << ans << endl;
}

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

using ll = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cout << fixed << setprecision(6);
	int n; cin >> n;
	vector<ld> v(n);
	rep(i, n) cin >> v[i];

	priority_queue<ld, vector<ld>, greater<ld>> pq;
	rep(i, n) pq.push(v[i]);
	while(pq.size() != 1){
		ld t1 = pq.top();
		pq.pop();
		ld t2 = pq.top();
		pq.pop();
		pq.push((t1 + t2) / 2);
	}

	cout << pq.top() << endl;
	return 0;
}


Measured memory_bytes: 256
#ABC163c
n = int(input())
a = [int(i) for i in input().split()]
a.insert(0, 0)
joushi = [0]*n

for i in range(n):
    if i == 0:
        pass
    else:
        joushi[a[i]-1] += 1
for i in range(n):
    print(joushi[i])


Measured memory_bytes: 32196
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish
{
    ll time;
    ll taste;
};

bool isP(ll n)
{
    string s = to_string(n);
    bool is_p = true;
    for (ll i = 0; i < s.size() / 2; i++)
    {
        is_p &= s[i] == s[s.size() - 1 - i];
    }
    return is_p;
}

int main()
{
    ll A, B;
    cin >> A >> B;

    ll cnt = 0;
    for (ll i = A; i <= B; i++)
    {
        if (isP(i)) {
            cnt += 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N; cin>>N;
	vector<int> A(N);
	A[0]=0;
	for(int i=1;i<N;i++){
		cin>>A[i]; A[i]--;
	}
	vector<int> ans(N,0);
	for(int i=N-1;i>0;i--){
		ans[A[i]]++;
	}
	for(int i=0;i<N;i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 6428
R = 101
while 1:
	n,S = map(int,raw_input().split())
	if n == 0: break
	r = [0]*R
	for i in range(n):
		r[int(raw_input())] += 1
	ans = 0
	for i in range(R):
		if 2*i > S:
			ans += r[i]*(r[i]-1)/2
		ans += r[i]*sum([r[j] for j in range(i+1,R) if i+j > S])
	print ans

Measured memory_bytes: 4520
main :: IO()
main = getContents >>= mapM_ (print . solve . read) . lines

solve :: Int -> Int
solve n | n < 100     = length $ takeWhile (<= n) primes
        | n < 1000    = (25 +)     . f $ [101, 103..n]
        | n < 10000   = (168 +)    . f $ [1001, 1003..n]
        | n < 100000  = (1229 +)   . f $ [10001, 10003..n]
        | n < 200000  = (9592 +)   . f $ [100001, 100003..n]
        | n < 300000  = (17984 +)  . f $ [200001, 200003..n]
        | n < 400000  = (25997 +)  . f $ [300001, 300003..n]
        | n < 500000  = (33860 +)  . f $ [400001, 400003..n]
        | n < 600000  = (41538 +)  . f $ [500001, 500003..n]
        | n < 700000  = (49098 +)  . f $ [600001, 600003..n]
        | n < 800000  = (56543 +)  . f $ [700001, 700003..n]
        | n < 900000  = (63951 +)  . f $ [800001, 800003..n]
        | n >= 999983 && n < 1000000 = 78498
        | n < 1000000 = (71724 +)  . f $ [900001, 900003..n]
    where f = length . (filter isPrime)

primes :: [Int]
primes = (2 :) . (3 :) . (5 :) . (7 :) $ filter isPrime [11, 13..] 

isPrime :: Int -> Bool
isPrime 2 = True
isPrime n
    | n < 2            = False
    | (n `mod` 2) == 0 = False
    | otherwise        = testDiv 3 n
    where testDiv :: Int -> Int -> Bool
          testDiv i n
              | i * i > n      = True
              | n `mod` i == 0 = False
              | otherwise      = testDiv (i + 2) n


Measured memory_bytes: 4012
from collections import deque

N, q = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N-1)]

graph = [[] for i in range(N+1)]
for i,j in AB:
    graph[i].append(j)
    graph[j].append(i)

c = [0] * (N+1)
for i in range(q):
    p1 , x1 = map(int, input().split())
    c[p1] += x1
    
r = [-1 for i in range(N+1)] 
Q = deque()
Q.append(1)
r[1] = 0

while Q:
    x = Q.pop()
    for to in graph[x]:
        if r[to] == -1:
            c[to] += c[x]
            r[to] = 0 
            Q.append(to)

ans = ""
for i in range(1,N+1):
    ans += str(c[i]) + " "
print(ans)

Measured memory_bytes: 83960
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    printf("%d %d %.5lf\n", d, r, f);

    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=2e9+5;
const int N=1000+10;
const ll mod=1e9+7;

vector<int> a;
int n,k;

bool check(int num){
	int sum=0;
	for(int x:a){
		if(x%num==0) sum+=x/num-1;
		else sum+=x/num;
	}
	return sum<=k;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	a.resize(n);
	int maxx=0;
	for(int& x:a) cin>>x,maxx=max(maxx,x);
	int l=1,r=maxx;
	int ans=maxx;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
	cout<<ans;	
	return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin >> x;
	if (x >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;




}

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

int main() {

  long long int n;
  cin >> n;

  long long int ans = 9999999L;

  for ( long long int i = 1; i < n; i++ ) {

    long long int j = n - i;

    long long int cnt = 0;
    long long int ci = i;
    while( ci > 0 ) {
      cnt += ci % 10;
      ci /= 10;
    }
    long long int cj = j;
    while( cj > 0 ) {
      cnt += cj % 10;
      cj /= 10;
    }

    ans = min( ans, cnt );

  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream> 
#include<algorithm>
#define INT_MIN 0x80000000
using namespace std;
int main(){
	int n, R;
	cin>>n;
	int min = 0;
	int last_r = 0;
	int delta = INT_MIN;
	for(int i=0; i<n ;i++)
	{
		cin>>R;
		if(last_r == 0)
			last_r = R;
		else
		{
			int difference = R - last_r;
			if(difference > delta )
			{
				delta = difference;
			} 
			if(R < last_r)
			{
				last_r = R;
			} 
		}
	} 
	cout<<delta<<endl;
}


Measured memory_bytes: 3136
#include <stdio.h>
 
int step[31];
 
int main(){
    int n, i;
    while(1){
        scanf("%d", &n);
        if(n == 0)
            break;
        step[0] = 1;
        step[1] = 1;
        step[2] = 2;
        for(i=3; i<=n; i++){
            step[i] = step[i-1] + step[i-2] + step[i-3];
        }
        printf("%d\n", (step[n] + 3649) / 3650);
    }
exit(0);
}
 

Measured memory_bytes: 0
import java.util.*;
class Main{
    void run(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    LinkedList<Character> stack=new LinkedList<Character>();
	    char[] ch=sc.nextLine().toCharArray();
	    if(ch.length==1&&ch[0]=='.')break;
	    boolean f=true;
	    for(int i=0;i<ch.length;i++){
		if(ch[i]=='('||ch[i]=='[')stack.push(ch[i]);
		else if(ch[i]==')'){
		    if(stack.size()==0||stack.pop()!='('){
			f=false;
			break;
		    }
		}
		else if(ch[i]==']'){
		    if(stack.size()==0||stack.pop()!='['){
			f=false;
			break;
		    }
		}
	    }
	    if(f&&stack.size()==0)System.out.println("yes");
	    else System.out.println("no");
	}
    }
    public static void main(String[] args){
	new Main().run();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

using type = pair<int, long long>; // 1: query, 0; delete, -1: insert
using event = pair<long long, type>;

int main() {
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 26980
n = int(input())
h = [int(e) for e in input().split()]

dp = [0, abs(h[1]-h[0])]

for i in range(2,n):
    dp.append(min(dp[-1]+abs(h[i]-h[i-1]),dp[-2]+abs(h[i]-h[i-2])))

print(dp[-1])

Measured memory_bytes: 13928
n = int( input() )
X = list( map( int, input().split() ) )

m = min( X )
M = max( X )

v_min = 10 ** 18
for i in range( m , M + 1 ):
  v = 0
  for x in X:
    v += ( x - i ) **2
  v_min = min( v, v_min )
print( v_min )

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

struct xy{
	int x;
	int y;
};

int main(){
	int n;
	int data=1;
	while(cin >> n , n){
	vector<xy> v(n);
	for(int i=0;i<n;++i){
		cin >> v[i].x >> v[i].y;
	}
	double ans=0.;
	int bx=v[0].x;
	int by=v[0].y;
	for(int i=1;i<n-1;i++){
		int ta,tb,tc,td;
		ta=bx-v[i].x;
		tb=by-v[i].y;
		tc=bx-v[i+1].x;
		td=by-v[i+1].y;
		ans+=ta*td-tc*tb;
	}
	cout << data++ << " " << fixed << setprecision(1) << fabs(ans)*0.5 << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    H = li_input()

    hmax = H[0]
    ans = 1

    for h in H[1:]:
        if h >= hmax:
            ans += 1
            hmax = h
    
    print(ans)


main()


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

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

int main()
{
	ios::sync_with_stdio(0);
	int i, j, k, n;

	cin >> n;
	ll a[n];
	for(i=0;i<n;++i)
		cin >> a[i];

	bool zer = false;
	for(i=0;i<n;++i)
		zer = zer or (a[i] == 0);

	ll ans = 1;
	for(i=0;i<n;++i)
	{
		if(a[i] > (ll)(1e18)/ans)
		{
			ans = -1;
			break;
		}
		else
			ans = ans * a[i];
	}

	cout << (zer ? 0 : ans) << "\n";

	return 0;
}

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

struct Node;
typedef shared_ptr<Node> NP;
struct Node {
  NP l, r;
};

void test() {
  for (int i = 0; i < 2000000; ++i) new Node();
}

int main() {
  test();
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a+b+c) == max({a,b,c})*2 ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
	string s;
	string t="IVXLCDM";
	int m[7]={1, 5, 10, 50, 100, 500, 1000};
	
	while(cin >> s){
		long ans=0;
		int size=s.size();
		
		for(int i=0; i<size; ++i){
			int p=0, q=0;
			while(s[i] != t[p]) p++;
			if(i+1<size) while(s[i+1] != t[q]) q++;
			 
			if(p<q) ans -= m[p];
			else ans += m[p];
		}
		
		printf("%ld\n", ans);
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<int,int> P;


int main(){
    int a,b;
    cin >> a >> b;
    int c = a-b;
    if(abs(c)%2==1){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        int i=0;
        while(true){
            if(abs(a-i)==abs(b-i)){
                cout << i<<endl;
                return 0;
            }
            i++;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    int N;

    cin >> N;

    map<string,int> S;

    REP(i,N){
        string s;
        cin >> s;
        if(S.find(s) == S.end()){
            S.emplace(s,0);
        }else{
            S.find(s)->second++;
        }
    }

    int max = 0;

    for(auto& s:S){
        if(s.second > max){
            max = s.second;
        }
    }

    for(auto& s:S){
        if(s.second == max){
            cout << s.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int a[100005]={0};
int gcd(int a,int b)
{
	 return (!b)?a:gcd(b,a%b);
}
int main()
{
	 int n,x;
	 cin>>n;
	 for(int i=0;i<=n;i++)
	  cin>>a[i];
	  sort(a,a+n+1);
	  int m=a[1]-a[0];
	  for(int i=2;i<=n;i++)
	  {
	  	 m=gcd(abs(a[i]-a[i-1]),m);
	  }
	  cout<<m<<endl;
}

Measured memory_bytes: 640
n = int(input())
a = [int(e) for e in input().split()]
 
a.sort()

s = set()
x = a[0]

count = 0
for i in range(n):
    flg = True
    flg2 = False
    if i < n - 1 and a[i] == a[i + 1]:
        flg = False
        flg2 = True
    if a[i] in s:
        flg = False
        flg2 = False

    if flg:
        count += 1
    if flg or flg2:
        x = a[i]
        while x <= 10 ** 6:
            s.add(x)
            x += a[i]
print(count)

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

int main() {
	long long n, a[100005], cnt=0;
	cin >> n;
	for(int i=0; i<n;i++){
		cin >> a[i];
		if(a[i] % 2 == 1){
			cnt++;
		}
	}
	if(cnt % 2 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v.at(i);
  sort(v.begin(),v.end());
  int a=v.at(n/2-1),b=v.at(n/2);
  cout<<b-a<<endl;
}


Measured memory_bytes: 640
import sys

n,m,k = map(int, input().split())

for a in range(n):
	if n-2*a == 0:
		continue
	b = ((k-a*m))/(n-2*a)
	if (b >= 0) and (b <= m) and (b%1 == 0):
		print("Yes")
		sys.exit()

print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<int>> a(n, vector<int>(m));
    vector<vector<int>> b(m, vector<int>(l));
    vector<vector<long long>> c(n, vector<long long>(l, 0));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << c[i][0];
        for (int j = 1; j < l; j++)
        {
            cout << " " << c[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3252