akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for ( int i = 0; i < (n); ++i)
#define mins(x,y) x = min(x, y)
#define maxs(x,y) x = max(x, y)
using namespace std;

const double inf = 1e10;

struct D 
{
    vector<double> l, r;
    D():l(3, inf),r(3, -inf){}
    void add (double x, int v)
    {
        ++v;
        mins(l[v], x);
        maxs(r[v], x);
    }
    double get(double t)
    {
        double nl = inf, nr = -inf;
        rep(i, 3)
        {
            mins(nl, l[i] + i * t);
            maxs(nr, r[i] + i * t);
        }
        return nr - nl;
    }
    vector<double> events()
    {
        vector<double> ts;
        rep(i, 3)rep(j, i) // j < i
        {
            double t = (l[j] - l[i]) / (i - j);
            if (t > 0) ts.push_back(t);
        }
        rep(i, 3)rep(j, i)
        {
            double t = (r[j] - r[i]) / (i - j);
            if (t > 0) ts.push_back(t);
        }
        return ts;
    }
};

int main()
{
    int n;
    cin >> n;
    D xd, yd;
    rep(i, n)
    {
        int x, y;
        char d;
        cin >> x >> y >> d;
        if (d == 'L') xd.add(x, -1), yd.add(y, 0);
        if (d == 'R') xd.add(x, 1), yd.add(y, 0);
        if (d == 'U') xd.add(x, 0), yd.add(y, 1);
        if (d == 'D') xd.add(x, 0), yd.add(y, -1);
    }
    vector<double> ts;
    ts.push_back(0);
    ts.push_back(inf);
    {
        auto nts = xd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    {
        auto nts = yd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    sort(ts.begin(), ts.end());
    double ans = 1e18;
    for (auto t :  ts)
    {
        double cand = xd.get(t) * yd.get(t);
        mins(ans, cand);
        // cout << t << ' ' << cand << ' ' << xd.get(t) << ' ' << yd.get(t) << endl;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, n;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    n = a+b+c;
    if (n>=22)
        printf("bust");
    else
        printf("win");
    return 0;
        
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x.at(i);
        if(IsPrime(x.at(i))) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.length()==2)
	{
		cout<<s;
	}
	else if(s.length()==3)
	{
	
		for(int i=s.length()-1;i>=0;i--)
		
		cout<<s[i];
	}
 } 

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,K;
    cin >>N>>K;

    vector<int> x(N);
    rep(i,N) cin >> x[i];
    
    int ans=0;
    rep(i,N) ans+=min(x[i]*2,abs(x[i]-K)*2);

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

Measured memory_bytes: 256
import sys
import string
input = sys.stdin.readline

N = int(input())

ans = ['a']
alph = list(string.ascii_lowercase[:10])
l = 1

while l < N:
    ans2 = []
    for value in ans:
        for letter in alph:
            ans2.append(value + letter)
            if letter not in value:
                break
    l += 1
    ans = ans2
    
for value in sorted(ans):
    print(value)

Measured memory_bytes: 14172
#include <iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  ll ans = 0;
  rep(i,n){
    int left = min(a[i],b[i]);
    a[i] -= left;
    b[i] -= left;
    ans += left;
    int right = min(a[i+1],b[i]);
    a[i+1] -= right;
    b[i] -= right;
    ans += right;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
<?PHP
  $amount = fgets(STDIN);
$aaa = fgets(STDIN);
$heights = explode(" ", $aaa);
$kick_power=2;
$dps=[];
 
foreach (range(0, $amount-1) as $index) {
	$dps[$index] = INF;
	if($index===0){ 
		$dps[0]=0; 
		continue;
	}
//	$dps[$index]=$dps[$index-1]+abs($heights[$index]-$heights[$index-1]);
	foreach (range(1, $kick_power) as $i) {
		if($index>=$i){
			$distanse=abs($dps[$index - $i] + abs($heights[$index] - $heights[$index - $i]));
			if ($dps[$index]> $distanse){$dps[$index]=$distanse;}
		}
 
	}
}
 
echo end($dps);

Measured memory_bytes: 23028
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }

    let top = s.match_indices("o").count();
    println!("{}", 700 + top*100);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    char a,b;
    cin >> a >> b;
    char ans;
    if(a == 'H'){
        if(b == 'H'){
            ans = 'H';
        }else{
            ans = 'D';
        }
    }else{
        if(b == 'H'){
            ans = 'D';
        }else{
            ans = 'H';
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int ans = 0;
    rep(i,k) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin >> n;
    int tgt = 1;
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        if (b==tgt){
            tgt++;
        } else {
            ans++;
        }
    }

    if(ans==n){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto x : mp){
        int num = x.first;
        int cnt = x.second;
        if(cnt >= num) ans += cnt-num;
        else ans += cnt;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    d <- getInt
    cs <- VU.fromList <$> getIntList
    ss <- V.fromList . map VU.fromList <$> replicateM d getIntList
    let ts = VU.create $ do
            vec <- VUM.replicate d (0 :: Int)
            forM_ [0..d-1] $ \day -> do
                let con = ss V.! day
                let t = snd . VU.maximum $ VU.imap (\i c -> (c,i)) con
                VUM.write vec day t
            return vec
              
    let result = VU.create $ do
             sat <- VUM.replicate (d+1) (0 :: Int)
             res <- VUM.replicate (d+1) (0 :: Int)
             ld <- VUM.replicate 26 (0 :: Int)
             decs <- VUM.replicate 26 (0 :: Int)
             forM_ [1..d] $ \day -> do
                 let contest = ts VU.! (day - 1)
                 let inc = ss V.! (day - 1) VU.! contest
                 VUM.write ld contest day
                 forM_ [0..25] $ \con -> do
                     let dec = cs VU.! con
                     lday <- VUM.read ld con
                     VUM.write decs con $ dec * (day - lday)
                 s <- VUM.read sat (day - 1)
                 VUM.write sat day (s + inc)
                 forM_ [0..25] $ \con -> do
                     dec <- VUM.read decs con
                     VUM.modify sat (subtract dec) day
                 VUM.write res day (contest + 1)
             return res
    VU.mapM_ print $ VU.tail result

Measured memory_bytes: 5524
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    ll n,k;
    cin>>n>>k;
    ll a[n],sum=0;
    ifr(i,0,n) cin>>a[i];
    sort(a,a+n);
    n = max(0ll,n-k);
    ifr(i,0,n) {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int n, t, l, b; cin >> n >> t >> l >> b, n | t | l | b; )
	{
		VI ls( l ), bs( b );
		FOR( tmp, ls )
		{
			cin >> tmp;
		}
		FOR( tmp, bs )
		{
			cin >> tmp;
		}

		vector< vector<double> > dp( n + 1, vector<double>( t + 1, 0. ) );
		dp[0][0] = 1.;

		REP( turn, 0, t )
		{
			REP( pos, 0, n )
			{
				REP( d, 1, 7 )
				{
					int nextpos = pos + d;
					if ( n < nextpos )
					{
						nextpos -= ( nextpos - n ) * 2;
					}
					if ( binary_search( ALL( bs ), nextpos ) )
					{
						nextpos = 0;
					}

					const int nextturn = turn + 1 + binary_search( ALL( ls ), nextpos );
					if ( t < nextturn )
					{
						continue;
					}

					dp[ nextpos ][ nextturn ] += dp[ pos ][ turn ] / 6.;
				}
			}
		}

		cout << accumulate( ALL( dp.back() ), 0. ) << endl;
	}		

	return 0;
}

Measured memory_bytes: 1372
H = int(input())
A = list(map(int, input().split()))

def maxHeapify(A, i):
    l = (i+1) * 2 - 1
    r = (i+1) * 2
    if l < H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r < H and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest)

def buildMaxHeap(A):
    for i in range(H//2, -1, -1):
        maxHeapify(A, i)


buildMaxHeap(A)

for v in A:
    print('', v, end='')
print('')



Measured memory_bytes: 63700
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define SORT(x) sort((x).begin(),(x).end(),greater<int>())
using LL=long long;
using ULL=unsigned long long;
using PII=pair<int,int>;
const int INF = numeric_limits<int>::max();
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> vc( N + 1 );
    REP2( i, 1, N + 1 )
    {
        cin >> vc[ i ];
    }
    int cnt{};
    REP2( i, 1, N + 1 )
    {
        if( i == vc[ i ] )
        {
            i != N ? swap( vc[ i ], vc[ i + 1 ] ) : swap( vc[ i ], vc[ i - 1 ] );
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

static const int N=100;

int main(){

  int M[N][N];
  int n,u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
     for(j=0;j<n;j++){
       M[i][j]=0;
     }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;

    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

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

 return 0;
}





Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's')
    s += "es";
  else
    s += 's';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3604
def ii2ss(n):
    ss = []
    for i in range(n):
        ss.append(input())
    return ss

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

def main(ss):
    nn0 = ss2nn(ss)
    nn = nn0[0:5]
    k = nn0[5]
    for i in range(5):
        for j in range(i+1, 5):
            if abs(nn[j] - nn[i]) > k:
                return ':('
    return 'Yay!'
ss = ii2ss(6)
print(main(ss))

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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if (A+B < C+D){
  cout<<"Right"<<endl;
  }
  else if(A+B==C+D){
  cout<<"Balanced"<<endl;
  }
  else{
  cout<<"Left"<<endl;
  }
}



Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    for j in range(n):
        if j + 1 <= n:
            dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1 - p[i])

print(sum(dp[n][n//2+1:]))

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

using namespace std;

#define pi 3.1415926536
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bs binary_search
#define int long long
#define float double

typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<string,int> msi;
typedef map<string,string> mss;
typedef map<char,char> mcc;
typedef map<pair<int,int>,int> mpi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef set<int> si;
typedef set<string> ss;
typedef set<char> sc;
int const max1= 1e5+5;
int const mod = 1e9+7;


int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin>>t;
while(t--){
    int x,k,d;
    cin>>x>>k>>d;
    if(x==0){
        if(k%2){
            cout<<d;
        }
        else{
            cout<<0;
        }
        return 0;
    }
    int m=(x%d+d)%d;
    int f1=m,f2=m-d;
    int dist=min(abs(f1-x),abs(f2-x));
    int temp=dist/d;
    //cout<<temp<<endl;
    if(temp>k){
        if(x>0){
            cout<<x-k*d;
        }
        else{
            cout<<-1*(x+k*d);
        }
    }
    else{
        temp=k-temp;
        if(temp%2){
            if(x>0){
                cout<<-1*f2;
            }
            else{
                cout<<f1;
            }
        }
        else{
            if(x<0){
                cout<<-1*f2;
            }
            else{
                cout<<f1;
            }
        }
    }
}
}


Measured memory_bytes: 3616
def solve():
    R, G, B, N = map(int, input().split())
    ans = 0
    for r in range(N + 1):
        for g in range(N + 1):
            v = N - r * R - g * G
            if v >= 0 and v % B == 0:
                ans += 1
    print(ans)

solve()

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int res = 0;
	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[N - i - 1]) {
			res++;
		}
	}
	cout << res << endl;
}

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

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

int i=1;
for(i=1;i<=2000;i++){
  if((i*8/100==a)&&(i*10/100==b)){
    break;
  }
}
  
  
if(i==2001){
System.out.println(-1);
}else{
  System.out.println(i);
}

}
}

Measured memory_bytes: 23764
a = list(map(int,input().split()))
b = [list(map(int,input().split())) for i in range(a[1])]
c = []

for i in range(a[0]):
  d = []
  for j in range(a[1]):
    d.append(b[j].count(i+1))
  else:
    c.append(sum(d))
else:
  for i in range(a[0]):
    print(c[i])

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int a=0, b=0 ,c=0;
    char A[11], B[11], C[11];
    for(int i=0; i<10; i++){
        A[i] = '0';
        B[i] = '0';
        C[i] = '0';
    }
    scanf("%s %s %s",A,B,C);
    for(a=0; A[a]!='\0';a++);
    for(b=0; B[b]!='\0';b++);
    for(c=0; C[c]!='\0';c++);
    if(A[a-1]==B[0]&&B[b-1]==C[0]){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	long N, T;
	cin >> N >> T;
	vector<long> c(N), t(N);
	for (long i=0;i<N;++i) {
		cin >> c[i] >> t[i];
	}
	vector<long> cost;
	for (long i=0;i<N;++i) {
		if (t[i] <= T) {
			cost.push_back(c[i]);
		}
	}
	if (cost.size() == 0) {
		cout << "TLE" << endl;
		return 0;
	}
	long minc = *min_element(cost.begin(), cost.end());
	cout << minc << endl;
	return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

sosuu=[2];n=int(input())
for L in range(3,n+100):
    chk=True
    for L2 in sosuu:
        if L%L2 == 0:chk=False
    if chk==True:sosuu.append(L)
S=set(sosuu)



A=[0]*(n+1)
g=0
for i in range(n+1):
  A[i]=int(input())
P=[]
PP=factorization(abs(A[0]))
for i in range(len(PP)):
  P.append(PP[i][0])
if P==[1]:
  P=[]
P=set(P)
P=S|P
P=list(P)
P.sort()
for i in range(len(P)):
  p=P[i]
  B=A[0:n+2]
  b=0
  for j in range(n+1):
    if p+j<n+1:
      B[j+p-1]=(B[j+p-1]+B[j])%p
    else:
      if B[j]%p!=0:
        b=1
        break
  if b==0:
    print(p)

Measured memory_bytes: 49372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

lint app() {
  int h,w;
  cin>>h>>w;

  int ch,cw,dh,dw;
  cin>>ch>>cw;
  cin>>dh>>dw;
  ch--;cw--;dh--;dw--;

  vector<vector<bool>> s(h,vector<bool>(w));
  rep(i,h){
    string str;
    cin>>str;
    rep(j,w) s[i][j]=(str[j]=='.');
  }

  vector<vector<int>> dep(h,vector<int>(w,2e9));

  using state=pair<int,pair<int,int>>;
  priority_queue<state,vector<state>,greater<state>> que;
  que.emplace(0,make_pair(ch,cw));
  while(!que.empty()){
    auto u=que.top(); que.pop();
    auto us=u.second;
    int udep=u.first;
    int ui=us.first;
    int uj=us.second;
    if(udep>=dep[ui][uj]) continue;
    dep[ui][uj]=udep;
    rep(t,4){
      int vi=ui+dx[t];
      int vj=uj+dy[t];
      if(vi<0||vi>=h||vj<0||vj>w) continue;
      if(s[vi][vj]) if(udep<dep[vi][vj]) que.emplace(udep,make_pair(vi,vj));
    }
    rep_range(vi,ui-2,ui+3) rep_range(vj,uj-2,uj+3){
      if(vi<0||vi>=h||vj<0||vj>w) continue;
      if(s[vi][vj]) if(udep+1<dep[vi][vj]) que.emplace(udep+1,make_pair(vi,vj));
    }
  }

  int ans=dep[dh][dw];
  if(ans==2e9) return -1;
  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  int N;cin >> N;
  vector<int> A(N), B(N), C(N-1);
  cin >> A >> B >> C;
  int ret = accumulate(ALL(B),0);

  REP(i,N-1){
    if(A[i] == A[i+1]-1){
        ret += C[A[i] - 1];
    }
  }
  cout<<ret<<endl;
}

int main(){   
  
 solve();

 return 0;
}


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

num = 2
while num <= N+1:
    num *= 2

seg = [0]*(2*num-1)

#update(i,x):Aiをxに更新する
def update(i,x):
    k = i + num - 1
    while k >= 0:
        seg[k] = max(x,seg[k])
        k = (k-1)//2

#query(a,b,0,0,num):[a,b)の最大値
def query(a,b,k,l,r):
    if r <= a or b <= l:
        return -1
    elif a <= l and r <= b:
        return seg[k]
    else:
        return max(query(a,b,2*k+1,l,(l+r)//2),query(a,b,2*k+2,(l+r)//2,r))


for i in range(N):
    update(h[i], query(0,h[i],0,0,num) + a[i])

print(max(seg))

Measured memory_bytes: 124880
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#define ll long long
#define ull unsigned long long
#define mn 1000020
#define FOR(a,b,c) for (int a=b;a<=c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int Max(int a,int b){return (a>b)?a:b;}
int Min(int a,int b){return (a<b)?a:b;}
 
int main(){
	int n=read(),k=read();
	printf("%d\n",!!(n%k));
	return 0;
}

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


const int MOD = 1000000007;

 
int H, W;
char a[1000][1000];
long long dp[1005][1005] = {};
 
int main(void){
    // Your code here!
    cin >> H >> W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
               cin >> a[i][j];
        }
    }
    
    dp[0][1] = 1;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(a[i-1][j-1] == '#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
            }
        }
    }
    
    
    cout << dp[H][W] << endl;
    
    
    return 0;
}

Measured memory_bytes: 9088
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let x = line.trim().parse::<u128>().unwrap();
    let mut a = 100;
    let mut cnt = 0;
    loop {
        a += a / 100;
        cnt += 1;
        if a >= x {
            println!("{}", cnt);
            return;
        }
    }
}


Measured memory_bytes: 2148
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)

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

int main(){
    int a, b, h, m ;
    cin >> a >> b >> h >> m;
    double t=60*h+m;
    double theta=11*t*M_PI/360;
    double c=cos(theta);
    double l=sqrt(a*a+b*b-2*a*b*c);
    //cout << l << endl;
    cout << fixed << setprecision(15) << l << endl;
}

Measured memory_bytes: 4228
using System;
using System.Linq;

namespace ABC107C_cs2
{
    class Program
    {
        static void Main(string[] args)
        {
            var nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var arrayx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var t = new Candles(nx[0], nx[1], arrayx);
            Console.WriteLine(t.MinTime());
        }
    }
    public class Candles
    {
        private readonly int N;
        private readonly int K;

        public int MinTime()
        {
            int result = int.MaxValue;
            for (int i = 0; i < N - K + 1; i++)
            {
                int LeftIndex = i;
                int RightIndex = i + K - 1;
                int LeftRoundTime = Math.Abs(arrayx[LeftIndex]) + Math.Abs(arrayx[LeftIndex] - arrayx[RightIndex]);
                int RightRoudnTime = Math.Abs(arrayx[RightIndex]) + Math.Abs(arrayx[LeftIndex] - arrayx[RightIndex]);
                result = Math.Min(Math.Min(LeftRoundTime, RightRoudnTime), result);
            }
            return result;
        }

        private readonly int[] arrayx;

        public Candles(int v1, int v2, int[] v3)
        {
            this.N = v1;
            this.K = v2;
            this.arrayx = v3;
        }
    }
}


Measured memory_bytes: 23520
#include <iostream>
using namespace std;
int n,k,m,x;
bool has[100005];
int main()
{
  cin>>n>>k;
  for(int i=1;i<=k;++i){
    cin>>m;
    for(int j=1;j<=m;++j){
      cin>>x;
      has[x]=1;
    }
  }
  int ans=0;
  for(int i=1;i<=n;++i) if(!has[i]) ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			while(A % 2 == 0) {
				cnt++;
				A /= 2;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 35652
A, B, K = map(int, input().split(' '))
if A+K <= B:
    for i in range(A, A+K):
        print(i)
else:
    for i in range(A, B+1):
        print(i)
if B-K+1 <= A+K-1:
    for i in range(A+K, B+1):
        print(i)
else:
    for i in range(B-K+1, B+1):
        print(i)

Measured memory_bytes: 3064
console.log((args=>{
  const S = args.trim();
  const L = S.length;
  let total = 0;
  for ( let bit = 0; bit < 1<<(L-1); bit++ ) {
    let st = S[0]|0, t = 0;
    for ( let i = 0; i < L-1; i++ ) {
      if ( (1<<i) & bit ) {
        t += st; st = (S[i+1]|0);
      } else {
        st = st * 10 + (S[i+1]|0);
      }
    }
    total += t + st;
  }
  return total.toString();
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29320
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n,k;
int d,maxa;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1,a;i<=n;++i)
	{
		scanf("%d",&a);
		d=gcd(d,a);
		maxa=max(maxa,a);
	}
	if(k<=maxa&&k%d==0)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=a*b;
    sc.close();

    if(c%2==0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    int N;
    cin>>N;
    int count1=0,count2=0;
    for(int i=1;i<=N;i+=2){
        FOR(j,1,N+1){
            if(i%j==0){
                count1++;
            }
        }
        if(count1==8){
            count2++;
        }
        count1=0;
    }
    cout<<count2<<endl;


    return 0;
}

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

int main(){
    int N;
    cin >> N;
    if(N > 81){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 1; i <= 9; i++){
        if(N % i > 0){
            continue;
        }
        else if(N / i > 9){
            continue;
        }
        else{
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
char s[1<<17];
int main()
{
	cin>>s+1;
	int n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1') return 0*puts("-1");
	for(int i=1;i<n;++i)
		if(s[i]!=s[n-i])
			return 0*puts("-1");
	int a=1;
	for(int i=2;i<=n;++i)
	{
		cout<<a<<' '<<i<<Endl;
		if(s[i-1]=='1') a=i;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int calc(Int K){
  Int res = 0;
  for(Int i=1;i*i<=K;i++){
    if(K%i == 0) continue;
    if(i * i != K) res++;
    res++;
  }
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  Int ans = 0;
  for(Int i=1;i<=N;i++)
    for(Int j=1;i*j<=N;j++){
      ans += i * j;
    }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 3632
def main():
    N = int(input())
    amounts = [1]
    lim = 10**6
    mul6 = 6
    while mul6 < lim:
        amounts.append(mul6)
        mul6 *= 6
    mul9 = 9
    while mul9 < lim:
        amounts.append(mul9)
        mul9 *= 9
    
    dp = [lim] * (N+1)
    dp[0] = 0
    for i in range(N):
        for a in amounts:
            if i+a <= N:
                dp[i+a] = min(dp[i+a],dp[i]+1)
    print(dp[N])

    



main()

Measured memory_bytes: 74060
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b) cout<<c<<endl;
	if (a==c) cout<<b<<endl;
	if (c==b) cout<<a<<endl;
	return 0;
}

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

int main(){
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = ((S % 3600) % 60);
	cout << h << ":" << m << ":" << s << endl; 
	
	return 0;
}


Measured memory_bytes: 3080
N, K = map(int, input().split())
A = list(map(int,input().split()))
B = []
B.append(1)
C = [0]*N
C[0] = 1

c = 0
count= 0
now=1
flag = 0

while(c < K):
  now = A[now-1]
  c += 1
  if(C[now-1] == 1):
    for i in range(len(B)):
      if(now == B[i]):
        flag = 1
        count = i
        break
  if(flag == 1):
    break
  B.append(now)
  C[now-1] = 1
if(c == K):
  print(now)
else:
  print(B[(K-count)%(len(B)-count)+count])

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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    int r;
    r = a % b;
    return (r > 0 ? gcd(b, r) : b);
}

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

    int n, x;
    cin >> n >> x;
    vector<int> A(n + 1);
    REP(i, n) cin >> A[i];
    A[n] = x;
    sort(A.begin(), A.end());

    int g = A[1] - A[0];
    for(int i = 1; i < n; i++){
        g = gcd(g, A[i + 1] - A[i]);
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int k;
  cin >> k;
  int even = 0, odd = 0;
  for (int i = 1; i <= k; i++) (i & 1) ? ++odd : ++even;
  cout << (odd * even) << endl;
}

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

int main() {
  int n;
  cin >> n;
  
  int a;
  vector<int> b(100000);
  for(int i=0; i<n; i++) {
    cin >> a;
    b[a]++;
  }
  
  int sum = b[0]+b[1]+b[2];
  int ans = sum;
  for(int i=3; i<100000; i++) {
    sum += b[i];
    sum -= b[i-3];
    ans = max(ans, sum);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {

	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}

	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			if (i == j) continue;
			ans += d[i] * d[j];
		}
	}


	cout << ans << endl;
	



}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    string s[] = {"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
    int n;cin >> n;
    cout << s[n-22] << endl;

}


Measured memory_bytes: 256
/**
 *
 * AtCoder Beginner Contest 104 - Problema C: All Green (https://abc104.contest.atcoder.jp/tasks/abc104_c)
 *
 * Check if a given string satisfies all conditions.
 *
 * Ad-hoc solution: check all conditions, one by one.
 */
#include <iostream>

using namespace std;
using ii = pair<int, int>;

const int MAX { 12 };
const int oo { 2000000000 };

int ps[MAX], cs[MAX];

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

void solve(int D, int G)
{
    int min_problems = oo;

    for (int bonus = 0; bonus < (1 << 10); ++bonus)
    {
        int problems = 0, left = G;
        
        for (int i = D; i >= 1 and left > 0; --i)
        {
            if (bonus & (1 << (i - 1)))
            {
                problems += ps[i];
                left -= (ps[i] * i * 100 + cs[i]);
            }
        }

        if (left <= 0)
        {
            min_problems = min(min_problems, problems);
            continue;
        }

        for (int i = D; i >= 1 and left > 0; --i)
        {
            if (bonus & (1 << (i - 1)))
                continue;

            int p = min(ps[i] - 1, (left + (100 * i - 1))/(100 * i));
            int value = p * 100 * i;

            problems += p;
            left -= value;
        }

        if (left <= 0)
            min_problems = min(min_problems, problems);
    }

    cout << min_problems << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int D, G;
    cin >> D >> G;

    for (int i = 1; i <= D; ++i)
        cin >> ps[i] >> cs[i];

    solve(D, G);

    return 0;
}


Measured memory_bytes: 256
///
// File:  2252.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 08:11:03 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

enum hand_t {
  None,
  Right,
  Left,
};

bool is_right(char c)
{
  return (c == 'y' || c == 'u' || c == 'i' || c == 'o' || c == 'p' || c == 'h' || c == 'j' || c == 'k' || c == 'l' || c == 'n' || c == 'm');
}

int32_t main()
{
  while (true) {
    string str;
    cin >> str;
    if (str[0] == '#') break;

    hand_t hand = None;
    uint32_t count = 0;
    for (uint32_t i = 0; i < str.size(); i++) {
      if (is_right(str[i])) {
        if (hand == None) {
          hand = Right;
        } else {
          if (hand == Left) {
            count++;
            hand = Right;
          }
        }
      } else {
        if (hand == None) {
          hand = Left;
        } else {
          if (hand == Right) {
            count++;
            hand = Left;
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3152
#include <ctype.h>
#include <iostream>
#include <string>
using namespace std;

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

    S[K - 1] = tolower(S[K - 1]);
    
    cout << S << endl;

	return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int get(int x){
	int res=0;
	while(x){
		res+=x%10;
		x/=10;
	}
	return res;
}

signed main(){
	int n=read();
	int ans=inf;
	FOR(i,1,n)
		chmin(ans,get(i)+get(n-i));
	print(ans);
}


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

static char N[200];
static char tmp[10];
static int b[4];

int main() {
    fgets(N, sizeof(N), stdin);
    fgets(tmp, sizeof(tmp), stdin);
    int K = atoi(tmp);

    int a = 1;

    b[0] = 1;
    b[1] = N[0] - '1';

    for (int i = 1; i < strlen(N) - 1; i++) {
        int t = N[i] - '0';
        for (int j = K - 1; j > -1; j--) {
            b[j + 1] += b[j] * 9;
        }
        if (t != 0) {
            if (a + 1 <= K) b[a + 1] += t - 1;
            if (a <= K) b[a] += 1;
            a++;
        }
    }

    printf("%d\n", b[K] + (a == K ? 1 : 0));
}


Measured memory_bytes: 128