akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


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

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector<lli>arr(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	//int dp[3003][3003][2];
	vector<vector<vector<lli>>> dp(n + 1, vector<vector<lli>>(n + 1, vector<lli>(2)));
	for (int i = 1; i <= n; i++) {
		dp[i][i][0] =  arr[i];
		dp[i][i][1] = -1*arr[i];
	}
	for (int sz = 2; sz <= n; sz++) {
		for (int i = 1; i + sz - 1 <= n; i++) {
			int j = i + sz - 1;
			dp[i][j][0] = max(arr[j] + dp[i][j - 1][1], arr[i] + dp[i + 1][j][1]);
			dp[i][j][1] = min( dp[i][j - 1][0] - arr[j],  dp[i + 1][j][0] - arr[i]);
		}
	}
	cout << dp[1][n][0];
	//system("PAUSE");
}


Measured memory_bytes: 493184
n = int(input())
ls = [input()]
ans = 0
for i in range(n-1):
    a = input()
    if (a  in ls) or (ls[i][len(ls[i])-1] != a[0]):
        ans += 1
    ls.append(a)
if ans == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
a, b = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


if a > b:
    num = gcd(a, b)
else:
    num = gcd(b, a)


def prime(n):
    i = 2
    table = set([])
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.add(i)
        i += 1
    if n > 1:
        table.add(n)
    return len(table)


print(prime(num)+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;

struct S{
    ll one,zero,inv;
};

S op(S l,S r){return S{l.one+r.one,l.zero+r.zero,l.inv+r.inv+l.one*r.zero};}
S e() {return S{0,0,0};}
S mapping(bool l,S r){
    if(l) return S{r.zero,r.one,r.zero*r.one-r.inv};
    else return r;
}
bool composition(bool l,bool r){ return (l^r);}
bool id(){ return false;}

int main(){
    int n,q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i,n){
        int t;
        cin >> t;
        (a[i]).one = (t==1?1:0);
        (a[i]).zero = (t==0?1:0);
        (a[i]).inv = 0;
    }
    lazy_segtree<S,op,e,bool,mapping,composition,id> seg(a);

    while(q--){
        int t,l,r;
        cin >> t >> l >> r;
        if(t==1){
            --l;
            seg.apply(l,r,true);
        }else{
            --l;
            cout << seg.prod(l,r).inv << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    vector<ll> num(k, 0);
    for(int a = 1; a <= n; a++) num[a%k]++;
    ll ans = 0;
    for(int a = 0; a < k; a++){
        int b = (k - a) % k;
        int c = (k - a) % k;//a=0の時のため
        if((b+c) % k != 0)continue;
        ans += num[a]*num[b]*num[c];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
LL A,B,C;
LL K;
int main(){
    cin>>A>>B>>C>>K;
    cout<< (K%2==1 ? B-A:A-B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using namespace std;

int main() {
  ll q;
  cin >> q;
  REP(i, q) {
    ll a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 2 * (a - 1) << endl;
      continue;
    }
    a > b ? swap(a, b), 0 : 0;

    ll ok = 0, ng = 1e10;
    while (ng - ok > 1) {
      ll m = a + (ng + ok) / 2;
      // cout << ng << " " << ok << endl;
      bool isSafe = true;
      for (ll i = -1; i <= 1; i++)
        if ((m / 2 + i) * ((m - m / 2) - i) >= a * b && !(isSafe = 0))
          break;

      if (isSafe)
        ok = m - a;
      else
        ng = m - a;
    }
    cout << ok - a + 2 * (a - 1) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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 rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[1100000][13];
const int mod = 1000000007;
signed main(){
    dp[0][0] = 1;
    string s;cin >> s;
    int n = s.size();
    rep(i,n)rep(j,13){
        if(s[i] == '?'){
            
            rep(a,10){
                dp[i+1][(j*10 + a)%13] = (dp[i+1][(j*10 + a)%13]+dp[i][j])%mod;
            }
        }   
        else{
            int x = s[i] - '0';
            dp[i+1][(j*10 + x)%13] = (dp[i+1][(j*10 + x)%13]+ dp[i][j])%mod;

            
        }
        
    }
    cout << dp[n][5] << endl;
    
    
    return 0;
}

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

#[fastout]
fn main() {
    input!{
        x: usize
    }

    let mut cur = 100;
    let mut count = 0;
    
    while cur < x {
        cur = (cur as f64 * 1.01) as usize;
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = (result * x)%MOD;
    x=(x*x)%MOD;
    n >>= 1;
  }
  return result%MOD;
}

int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  ll n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b);
}

Measured memory_bytes: 256
N = gets.chomp.to_i
S = gets.chomp.split('')

east_sum = [0]
(0..N-1).each do |n|
  east_sum[n+1] = east_sum[n] + (S[n] == 'E' ? 1 : 0)
end

results = (1..N).map do |leader|
  leader - 1 - east_sum[leader-1] + east_sum[N] - east_sum[leader]
end

puts results.min

Measured memory_bytes: 32316
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct hat{
    int x;
    int y;
    int z;
}hat;

int main(){
    int N;cin >> N;
    vector<int> A(N);
    vector<hat> h(N+1);
    rep(i,N)cin >> A[i];
    rep(i,N+1){
        if(i == 0){
            h[0] = (hat){0,0,0};
            continue;
        }
        int a = h[i-1].x;
        int b = h[i-1].y;
        int c = h[i-1].z;
        if(a == A[i-1])h[i] = (hat){a+1,b,c};
        else if(b == A[i-1])h[i] = (hat){a,b+1,c};
        else h[i] = (hat){a,b,c+1};
    }
    
    LL ans = 1;
    rep(i,N){
        hat t = h[i];
        int ct  = 0;
        if(t.x == A[i])ct++;
        if(t.y == A[i])ct++;
        if(t.z == A[i])ct++;
        ans *= ct;
        ans %= MOD; 
    }

    cout << ans << endl;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long sum = 0;
		for ( int i = 0 ; i < N ; i++ ) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		sc.close();

		long minD = sum;
		long curSum = 0;
		for ( int i = 0 ; i < N ; i++ ) {
			curSum += A[i];
			if ( Math.abs(sum - curSum * 2) < minD ) {
				minD = Math.abs(sum - curSum * 2);
			}
		}
		
		System.out.println(minD);
	}
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int A,B,C,ans=MOD;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> A >> B >> C;
    F0R(i,8) {
        int a = A, b = B, c = C,cur=0;
        if (i&1) a ++, b ++, cur++;
        if (i&2) a ++, c ++, cur++;
        if (i&4) b ++, c ++, cur++;
        if ((a&1) != (b&1) || (b&1) != (c&1)) continue;
        int t = max(max(a,b),c); 
        cur += (3*t-a-b-c)/2;
        ans = min(ans,cur);
    }
    cout << ans;
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, ans = -1;
  char s[100010], be = 0;
  scanf("%s", s);
  for(i = 0; i < strlen(s); ++i) if(be != s[i]) ++ans, be = s[i];
  printf("%d", ans);
  return 0;
}

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<pll>v(n);
  rep(i,n){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(),v.end());
  ll ans = (ll)0;
  rep(i,n){
    if(v[i].second < m){
      ans += v[i].first * v[i].second;
      m -= v[i].second;
    }
    else {
      ans += v[i].first * m;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

static const int n = 1000;

int lcs(string X, string Y) {
	int c[n + 1][n + 1]; //　XiとYjのLCSの長さとする２次元配列
	int m = int(X.length());
	int n = int(Y.length());
	X =' '+X;
	Y =' '+Y;
	int maxl = 0;
	//初期化
	for (int i = 0;i<=m;i++) {
		c[i][0] = 0;
	}
	for (int j = 1;j<= n; j++) {
		c[0][j] = 0;
	}

	//Xｍ－１とYｎ、XmとYn-1どちらが長いかを調べる
	for (int i = 1; i <= m;i++) {
		for (int j = 1; j <= n;j++) {
			if (X[i] == Y[j]){
			   c[i][j] = c[i - 1][j - 1] + 1; 
			} 
			else{
			    c[i][j]= max( c[i][j - 1],c[i-1][j]);
            }
			maxl = max(maxl,c[i][j]);
		}
	}

	return maxl;
}

int main() {
	int n; cin >> n;
	string S1, S2;

	for (int i = 0;i<n;i++) {
		cin >> S1 >> S2;
		cout << lcs(S1, S2) << endl;
	}
	return 0;

}



Measured memory_bytes: 7060
#include<stdio.h>

int main(){
  int N, X;
  scanf("%d",&N);
  X = N / 1.085;
  for(;(int)X*1.08 < N+1;X++){
    if(int(X*1.08) == N){
      printf("%d", X);
      return 0;
    }
  }
  printf(":(");
}

Measured memory_bytes: 128
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    LL N, A, B;
    cin >> N >> A >> B;
    LL X[N];
    REP(i, N) cin >> X[i];
    LL ans = 0;
    REP(i, N - 1)
    {
        ans += min((X[i + 1] - X[i]) * A, B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int A[2];
  int B[2];
  for(int i=0;i<2;i++){
  cin>>A[i];  
  }
   for(int i=0;i<2;i++){
  cin>>B[i];  
  }
 int f=0;
  while(A[0]>0 && B[0]>0){
    B[0]-=A[1];
    if(B[0]<=0){
      f=1;
      break;
    }
    A[0]-=B[1];
    if(A[0]<=0){
      f=2;
      break;
    }
    //cout<<A[0]<<" "<<B[0]<<endl;
  }
  if(f==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 return 0; 
}

Measured memory_bytes: 3592
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	A := make([][]int, 3)
	for i := 0; i < 3; i++ {
		A[i] = make([]int, 3)
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			A[i][j] = nextInt()
		}
	}
	var N int
	N = nextInt()
	matrix := [][]int{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
	for i := 0; i < N; i++ {
		b := nextInt()
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if A[j][k] == b {
					matrix[j][k] = 1
				}
				if matrix[j][0]+matrix[j][1]+matrix[j][2] == 3 {
					fmt.Println("Yes")
					return
				}
			}
		}
		if matrix[0][0]+matrix[1][0]+matrix[2][0] == 3 || matrix[0][1]+matrix[1][1]+matrix[1][1] == 3 || matrix[0][2]+matrix[1][2]+matrix[2][2] == 3 || matrix[0][0]+matrix[1][1]+matrix[2][2] == 3 || matrix[2][0]+matrix[1][1]+matrix[0][2] == 3 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 32128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n,m=0;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
        m+=a[i];
    }
    sort(a,a+n);
    if (m%10==0){
        bool f=true;
        ll i=0;
        while(a[i]%10==0){
            i++;
            if (i==n){
                f=false;
            }
        }
        if (!f){
            cout << 0 << endl;
            return 0;
        }
        cout << m-a[i] << endl;
    }else{
        cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s,t;
    cin>>s>>t;
    int n=SZ(s);
    string ans="";
    REP(i,n) {
        string tmp=s;
        bool mat=1;
        REP(j,SZ(t)) {
            if(i+j>=n) {
                mat=0;
                break;
            }
            if(s[i+j]==t[j] || s[i+j]=='?') {
                tmp[i+j]=t[j];
            } else {
                mat=0;
                break;
            }
        }
        if(!mat) {
            continue;
        }
        REP(j,n) {
            if(tmp[j]=='?') {
                tmp[j]='a';
            }
        }
        if(ans=="") ans=tmp;
        else chmin(ans,tmp);
    }
    if(ans=="") {
        cout<<"UNRESTORABLE"<<endl;
    } else {
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.14159265358979323846
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;

//vector<vector<ll>>v;
//vector<ll>vis,d;
  

int main() {
    IOS;
    ll a[5];h=inf;
    fo(i,5){
        cin>>a[i];
        if((a[i]-1)%10+1<h)h=(a[i]-1)%10+1,p=i;
    }//cout<<h<<el;
    fo(i,5){
        if(i!=p){
            kv+=ceil((ld)a[i]/10)*10;
        }
        else{
            kv+=(a[i]/10)*10;
            if(h!=10)kv+=h;
        }
    }
    cout<<kv;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	ans := 0
	c := 1
	for c < b {
		c += a - 1
		ans += 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner  = new Scanner(System.in);
		final var r = scanner.nextInt();
		final var D = scanner.nextInt();
		var x = scanner.nextInt();
		for(int i = 0; i < 10; i++) {
			x =  r * x - D;
			System.out.println(x);
		}
		scanner.close();
	}

}


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

int main() {
    int h, w;
    while(cin >> h >> w && h + w) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) cout << "#";
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>

int main(){
    int n;
    scanf("%d", &n);
    int d;
    scanf("%d", &d);
    long x[n];
    long y[n];
    int count = 0;
    double length = 0;
    
    for(int i=0;i<n;i++){
        scanf("%ld", &x[i]);
        scanf("%ld", &y[i]);
        if(sqrt(pow(x[i], 2) + pow(y[i], 2)) <= d){
            count++;
        }
    }

    printf("%d\n", count);
    
    return 0;

}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,d;
	cin >> n >> d;
	int tmp=1+d*2;
	if(n%tmp) cout << n/tmp+1 << endl;
	else cout << n/tmp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >>a>>b;

if(a<b){
cout <<"a < b"<<endl;
} 

else if(a>b){
cout <<"a > b"<<endl;
}

else{
cout <<"a == b"<<endl;
}

}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)(N);i++)
#define p(s) cout<<(s)<<endl;
#define F first
#define S second
using namespace std;

string s[501];
bool tacX(int x1,int x2,int y,char c){
    for(int x=x1;x<=x2;x++) if(s[y][x]!='.' && s[y][x]!=c) return false;
    return true;
}

bool tacY(int y1,int y2,int x,char c){
    for(int y=y1;y<=y2;y++) if(s[y][x]!='.' && s[y][x]!=c) return false;
    return true;
}
int main(){
	int M,N;
	cin>>M>>N;
	vector<pair<int,int>> vc[30];
	REP(i,0,M){
		cin>>s[i];
		REP(j,0,N){
			if(s[i][j]!='.') vc[s[i][j]-'A'].push_back({j,i});
		}
	}
	int ans=0;
	while(1){
		bool change=false;
		REP(i,0,'Z'-'A'+1){
			if(vc[i].size()!=2) continue;
			pair<int,int> a=vc[i][0],b=vc[i][1];
			bool ok=false;
			if(a.F!=b.F&&a.S!=b.S){
				if((tacX(min(a.F,b.F),max(a.F,b.F),a.S,'A'+i)
				&& tacY(a.S,b.S,b.F,'A'+i))
				|| (tacX(min(a.F,b.F),max(a.F,b.F),b.S,'A'+i)
				&& tacY(a.S,b.S,a.F,'A'+i))) ok=true;
			}
			else if(a.S==b.S&&b.F-a.F>1&& tacX(a.F,b.F,a.S,'A'+i)) ok=true;
			else if(a.F==b.F&&b.S-a.S>1&&tacY(a.S,b.S,a.F,'A'+i)) ok=true;
			if(ok){
				s[a.S][a.F]=s[b.S][b.F]='.';
				vc[i].clear();
				ans+=2;
				change=true;
			}
		}
		if(!change) break;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 3356
#include "iostream"
#include "fstream"

using namespace std;

int main() {

  int N=0;
  int K=0;
  char S[51]={0};
  
  cin >> N >> K;
  
  for(int i=1;i<=N;i++){
 
    cin >> S[i];
   
  }
  
  if(S[K]=='A')  S[K]='a';
  if(S[K]=='B')  S[K]='b'; 
  if(S[K]=='C')  S[K]='c';
  
  for(int i=1;i<=N;i++){
 
    cout << S[i];
   
  }

	return 0;
}

Measured memory_bytes: 256
//59
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  char g[51][51];
  for(int y=0;y<h;y++){
    cin>>g[y];
  }
  int cc[51][51];
  fill(cc[0],cc[51],1<<30);
  cc[0][0]=0;
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      cc[y+1][x]=min(cc[y+1][x],cc[y][x]+g[y+1][x]-'0');
      cc[y][x+1]=min(cc[y][x+1],cc[y][x]+g[y][x+1]-'0');
    }
  }
  cout<<cc[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 1176
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a, b, c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    print(800*n-(n//15)*200)

if __name__ == '__main__':
    main()


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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const int mod = 998244353;
const int mxN = 200*1000+5;
int fact[mxN], finv[mxN];

int add(int a, int b) {
    a += b;
    while(a >= mod) {
        a -= mod;
    }
    return a;
}

void add_self(int& a, int b) {
    a = add(a, b);
}

int mul(int a, int b) {
    return 1LL * a * b % mod;
}

int mpow(int a, int n) {
    if(n == 0) {
        return 1;
    }
    int x = mpow(a, n/2);
    x = mul(x, x);
    if(n&1) {
        x = mul(x, a);
    }
    return x;
}

int binomial(int n, int k) {
    return mul(fact[n], mul(finv[n-k], finv[k]));
}

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

    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = finv[0] = 1;
    for(int i = 1; i < n; i++) {
        fact[i] = mul(i, fact[i-1]);
        finv[i] = mpow(fact[i], mod-2);
    }
    int ans = 0;
    forn(i, k+1) {
        add_self(ans, mul(mul(m, binomial(n-1, i)), mpow(m-1, n-i-1)));
    }
    cout << ans << endl;
}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    string S;
    INX(S);
    
    ll cont = 0;
    ll max = 0;
    for (ll i = 0; i < (ll)S.size(); i++)
    {
        if(S[i] == 'R')
        {
            cont++;
        }
        else
        {
            max = max < cont ? cont : max;
            cont = 0;
        }
    }
    max = max < cont ? cont : max;
    OUTX(max);


    return 0;
}


Measured memory_bytes: 3624
from operator import itemgetter

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab = sorted(ab, key=itemgetter(1))

ans = 1
limit = ab[0][1]

for i in range(1, m):
	if ab[i][0] >= limit:
		ans += 1
		limit = ab[i][1]

print(ans)

Measured memory_bytes: 29920
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N;
int d[100100];
deque<int> dque;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        d[i] = INF;
    }
    d[1] = 1;
    dque.pf(1);
    while(dque.size()){
        int cur = dque.front();
        dque.pop_front();
        int nxt = cur * 10 % N;
        if(d[nxt] > d[cur]){
            d[nxt] = d[cur];
            dque.pf(nxt);
        }
        nxt = (cur + 1) % N;
        if(d[nxt] > d[cur] + 1){
            d[nxt] = d[cur] + 1;
            dque.pb(nxt);
        }
    }
    cout << d[0] << endl;



    return 0;
}
/*


*/




Measured memory_bytes: 1408
n, x = map(int, input().split())
a = list(map(int, input().split()))


t = 0
ans = 0
if a[0] <= x:
  for i in range(1,n):
    if a[i-1]+a[i] > x:
      ans = ans + (a[i] + a[i-1] - x)
      a[i] = x - a[i-1]
else:
  ans += (a[0] - x)
  a[0] = x
  for i in range(1,n):
    if a[i-1]+a[i] > x:
      ans = ans + (a[i] + a[i-1] - x)
      a[i] = x - a[i-1]
      
print(ans)

Measured memory_bytes: 19936
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

def in_sec(a, b, c):
    return min(a, b) <= c <= max(a, b)

q = input()

for loop in range(q):
    x0, y0, x1, y1 = map(int, raw_input().split())
    n = input()
    ls = []
    for i in range(n):
        x2, y2, x3, y3, o, l = map(int, raw_input().split())
        flag = (o + l) % 2
        #(y1 - y0)(x - x0) = (x1 - x0)(y - y0)
        a1, b1, c1 = [y1 - y0, x0 - x1, x0 * (y1 - y0) - y0 * (x1 - x0)]
        a2, b2, c2 = [y3 - y2, x2 - x3, x2 * (y3 - y2) - y2 * (x3 - x2)]
        det = a1 * b2 - b1 * a2
        if det == 0:
            dx, dy = [x2 - x0, y2 - y0]
            if dx * a1 + dy * b1 != 0:
                pass
            elif max(x0, x1) < min(x2, x3) or max(x2, x3) < min(x0, x1) \
                or max(y0, y1) < min(y2, y3) or max(y2, y3) < min(y0, y1):
                pass
            else:
                p = [(x0, y0), (x1, y1), (x2, y2), (x3, y3)]
                ls += [(p[i], flag) for i in range(4) for j in range(4) if p[i] == p[j]]
            continue
        
        xdet = c1 * b2 - c2 * b1
        ydet = c2 * a1 - c1 * a2
        if in_sec(det * x0, det * x1, xdet) and in_sec(det * y0, det * y1, ydet) \
            and in_sec(det * x2, det * x3, xdet) and in_sec(det * y2, det * y3, ydet):
            det = float(det)
            ls += [((xdet / det, ydet / det), flag)]
    ls.sort()
    ans = 0
    for i in range(len(ls) - 1):
        if ls[i][1] != ls[i + 1][1]:
            ans += 1
    print ans


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

int main(){
  	int w,h,n;
  	cin >> w >> h >> n;
  	int x[n],y[n],a[n],r = w,l = 0,u = h,d = 0;
  
  	rep(i,0,n){
      cin >> x[i] >> y[i] >> a[i];
    }
  
  	rep(i,0,n){
      switch(a[i]){
        case 1:
          l = max(l,x[i]);
          break;
        case 2:
          r = min(r,x[i]);
          break;
        case 3:
          d  = max(d,y[i]);
          break;
        case 4:
          u = min(u,y[i]);
          break;
      }
    }
  
  	cout << max(0,r-l)*max(0,u-d) << endl;
  
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;

int main(){
  string str;
  cin>>str;
  for(char ch:str){
    if(ch=='a')a++;
    if(ch=='b')b++;
    if(ch=='c')c++;
  }

  if(a>b)swap(a,b);
  if(b>c)swap(b,c);
  if(a>b)swap(a,b);

  int x=(a>0) + (b>0) + (c>0);
  
  if( x==1 ){
    if(str.size()==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
  }
  
  if( x==2 ){
    if(str.size()<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
  }
  
  if( abs(c-a) <= 1 ){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  scanf("%lld%lld",&h,&w);
  if(h==1||w==1){
    cout<<1<<endl;
  }else{
    if(h%2==0||w%2==0){
    cout<<(h*w)/2<<endl;
    }else{
      cout<<((h*w)/2)+1<<endl;
    }
  }
}

Measured memory_bytes: 256
let moves attack defence =
  (defence / attack) + (if defence mod attack == 0 then 0 else 1)

let () =
  let (h1, s1, h2, s2) = Scanf.scanf "%d %d %d %d" (fun a b c d -> a, b, c, d) in
  let s1 = moves s1 h2 in
  let s2 = moves s2 h1 in
  print_string (if s1 <= s2 then "Yes" else "No")


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int inf = 1e9;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        string num;
        num = to_string(i);
        if(num.size()%2!=0){
            ans++;
            //cout<<"i="<<i<<endl;
        }
    }
    cout << ans << endl;
}

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;
using P = pair<int, int>;

const int INF = 100100100;

int main(void){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int  ans = INF;
  rep(i,105) {
    int cnt = 0;
    rep(j,n) {
      int a = x[j] - i;
      cnt += a*a;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

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

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		while (n != 0) {
			int max = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				int sum = 0;
				for (int k = 0; k < 5; k++) {
					sum += in.nextInt();
				}
				if (max < sum) {
					max = sum;
				}
				if (min > sum) {
					min = sum;
				}
			}
			System.out.printf("%d %d", max, min);
			System.out.println();
			n = in.nextInt();
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}
bool prime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
 
bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

bool vis[100005];
vl v[100005];
bool c=0;
void dfs(ll u,ll par){
	vis[u]=1;
	for(int child: v[u]){
		if(vis[child]==0 ){
			dfs(child,u);
		}
		else{
			if(child!=par){
				c=1;
			}
		}
	}
}

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans+=i;
		}
	}
	cout<<ans;
    return 0; 
}

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

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

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

#define INF 1e16
#define mod 1000000007

//// gcd
ll gcd(ll a,ll b){
  return b?gcd(b,a%b):a;
}

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

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

  while(1){
    ll n,m;
    vector<ll> a;
    cin>>n>>m;
    if(n==0&&m==0)break;
    a.resize(m);
    rep(i,m)cin>>a[i];

    ll num=0,sum=0;
    rep(S,(1<<m)){
      ll p=1;
      rep(i,m){
        if((S>>i)&1){
          p=lcm(p,a[i]);
        }
      }
      ll cnt=n/p;
      ll cnts=cnt*(cnt+1)/2;
      if(bcnt(S)%2==0){
        num+=cnt;
        sum+=p*cnts;
      }else{
        num-=cnt;
        sum-=p*cnts;
      }
    }

    if(num>0)printf("%.10f\n", (double)sum/(double)num);
    else printf("0\n");
  }

  return 0;
}



Measured memory_bytes: 3228
#include<stdio.h>
#define M 1000000

int main(void){
  int i,j;
  int num[M];
  int n;

  num[0]=0;
  for(i=1;i<M;i++)
    num[i]=1;
  for(i=1;i<M;i++)
    if(num[i])
      for(j=i+i+1;j<M;j+=i+1)
        num[j]=0;

  for(;scanf("%d",&n)==1;){
    for(i=n-2;i>=0;i--)
      if(num[i]){
        printf("%d ",i+1);
        break;
      }

    for(i=n;i<=M;i++)
      if(num[i]){
        printf("%d\n",i+1);
        break;
      }
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.HashSet;
import java.util.Set;

public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);

    Set<Integer> set = new HashSet<>();
    for (int v : a) {
      if (set.contains(v)) {
        System.out.println("NO");
        return;
      }
      set.add(v);
    }
    System.out.println("YES");

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 55196