akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int MOD=1e9+7;
const int MXN=3000;
vector<vector<int>>dp(MXN+1,vector<int>(MXN+1));
vector<vector<pair<int,int>>>par(MXN+1,vector<pair<int,int>>(MXN+1));

string s;
string r;
void findPath(string &p,int i,int j)
{
	if(i==0 || j==0 )return;
	int x=par[i][j].first;
	int y=par[i][j].second;
	
	if( x==i-1 && y==j-1)
	{
		p=s[i]+p;
	}
	findPath(p,x,y);
}
int32_t main()
{
   IOS
   cin>>s;
   cin>>r;
   int n=s.length();
   int m=r.length();
   s='$'+s;
   r='$'+r;
   for(int i=1;i<=n;i++)
   for(int j=1;j<=m;j++)
   {
	   if( s[i]==r[j] ){
		   dp[i][j]=dp[i-1][j-1]+1;
		   par[i][j]={i-1,j-1};
	   }
	   else if( dp[i-1][j] > dp[i][j-1] )
	   {
		   dp[i][j]=dp[i-1][j];
		   par[i][j]={i-1,j};
	   }
	   else
	   {
		   dp[i][j]=dp[i][j-1];
		   par[i][j]={i,j-1};
	   }
   }
   string s;
   findPath(s,n,m);
   cout<<s<<endl;
   
   
}


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

using namespace std;

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

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

    if(S.size() <= K){
        cout << S << endl;
    } else {
        rep(i, K){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3628
#!/bin/sh
read
cnt=0
for i in `echo $REPLY | awk '{print $1"\n"$2"\n"$3}' | sort -n`
do
	cnt=$(( cnt + 1 ))
	eval n$cnt=$i
done
n=$(( $(( $(( n1 % 2 )) + $(( n2 % 2 )) + $(( n3 % 2 )) )) % 2 ))
if [ $n -eq 1 ]
then
	echo $(( n1 * n2 ))
else
	echo 0
fi


Measured memory_bytes: 2124
s = int(input())
a={s}
tmp_a = s
index = 1
def func(n):
  if n%2==0:
    return n/2
  else:
    return 3*n+1

while(1):
  index += 1
  tmp_a = func(tmp_a)
  if tmp_a in a:
    break
  else:
    a |= {tmp_a}

print(index)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N, T, A;
    int H[1100];
    cin >> N >> T >> A;
    for (int i = 0; i < N; i++) cin >> H[i];

    double diff;
    double min_diff = 10000.0;
    int index = 0;
    for (int i = 0; i < N; i++){
        diff = 0.0;
        double temp = T - H[i] * 0.006;
        diff = abs(A - temp);
        if (diff < min_diff){
            min_diff = diff;
            index = i;
        }
    }
    cout << index + 1 << endl;
}


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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<int> mem(N,0);
  int cl = 0;
  int cr = 0;
  for (int i = 0; i <= N; i++) {
    if (s[i] == 'L') cl += 1;
    if (s[i] == 'R' && cl == 0) cr += 1;
    if ((s[i] == 'R' && cl > 0) || i == N) {
      mem[i-cl-1] = (cr+1)/2+cl/2;
      mem[i-cl] = cr/2+(cl+1)/2;
      cr = 1;
      cl = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << mem[i];
    if (i < N-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <tuple>
#include <vector>
#include <map>

using namespace std;
using lint = long long int;

int main()
{
	/* 入力処理ここから*/
	int N;
	int* A, * B;
	cin >> N;

	A = new int[N + 1];
	B = new int[N];

	for (int i = 0; i < N + 1; i++) {
		int n;
		cin >> n;
		A[i] = n;
	}
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		B[i] = n;
	}
	/*入力処理ここまで*/

	lint totalMonster = 0; // モンスター討伐数カウンタ
	for (int i = 0; i < N; i++) {
		int sub = min(A[i], B[i]); // iの町で勇者iが討伐できるモンスターの数
		A[i] -= sub; // iの町から、討伐したモンスターを除く（実際にはこの処理をしなくてもよい）
		B[i] -= sub; // 勇者の討伐できる数から、討伐数を除く
		totalMonster += sub; 

		// まだ勇者がモンスターを討伐できる場合
		if (B[i] > 0) {
			sub = min(A[i+1], B[i]); // i+1の町で勇者iが討伐できるモンスターの数
			A[i + 1] -= sub; // i+1の町から、討伐したモンスターを除く
			totalMonster += sub;
		}
	}

	cout << totalMonster << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int A = int.Parse(imp[0]);
            int B = int.Parse(imp[1]);
            int C = Math.Max(A, B);
            if (A != B)
            {
                Console.Write(2 * C - 1);
            }
            else
            {
                Console.Write(2 * C);
            }

            //System.Threading.Thread.Sleep(1000);
        }
    }
    
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

    std::cin >> N;

    for(int i=0;i<=N;++i){
        for(int j=0;j<=N;++j){
            if(4 * i + 7 * j == N){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;
}


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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
}


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

int main(){
    int N,K; cin >> N >> K;
    string S; cin >> S;
    
    // 「１の個数」「０の個数」を交互に数える
    vector<int> num;
    if(S[0] == '0') num.push_back(0);
    for(int i=0; i<N; i++){
        int j=i;
        while(j < N  &&  S[j] == S[j+1]) j++;
        num.push_back(j-i+1);
        i = j;
    }
    if(S.back() == '0') num.push_back(0);

    //累積和
    vector<long long> sums(num.size()+1);
    for(int i=0; i<num.size(); i++) sums[i+1] = sums[i] + num[i];

    //最大値を求める
    long long ans = 0;
    for(int left=0; left < sums.size(); left+=2){
        int right = left + 2*K+1;
        if(right >= sums.size()) right = sums.size() - 1;
        ans = max(ans , sums[right]-sums[left]);
    }

    cout << ans << endl;
}

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

const int maxn = 3030;
double dp[maxn][maxn];

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

    // dp[i][j]: i番目のコインまでふって、j枚表の確率
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; j++) {
            dp[i][j] += dp[i-1][j] * (1.0 - p[i-1]);
            if(j-1 >= 0){
                dp[i][j] += dp[i-1][j-1] * p[i-1];
            }
        }
    }
    double ans = 0.0;
    for (int i = (n + 1) / 2; i <= n; ++i) {
        ans += dp[n][i];
    }
    printf("%.9lf\n", ans);
}


Measured memory_bytes: 49932
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b = map(int, input().split())
c, d = map(int, input().split())
print(a*b-c*b-d*a+c*d)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  //入力に対する処理
  int a; cin >> a;
  int b; cin >> b;
  int c; cin >> c;
  int d; cin >> d;
  int e; cin >> e;
  int k; cin >> k;
  
  //処理
  if(e-a<=k){
    cout << "Yay!" ;
  }
  
  else{
	cout << ":(";
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[110000];

int main(){
  int A,B;
  cin>>A>>B;
  cout<<(B-1+A-2)/(A-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<int> man[100000];
  vector<int> tangue[100000];
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int num;
      cin>>num;
      num--;
      man[i].push_back(num);
      tangue[num].push_back(i);
    }
  }
  bool flag[100000]={false},flag2[100000]={false};
  queue<int> mm,tt;
  mm.push(0);
  while(!mm.empty() ){
    int num=mm.front();
    flag[num]=true;
    mm.pop();
    rep(i,man[num].size() ){
      if(!flag2[man[num][i]]) tt.push(man[num][i]);
    }
    while(!tt.empty() ){
      int numm=tt.front();
      flag2[numm]=true;
      tt.pop();
      rep(i,tangue[numm].size() ){
	if(!flag[tangue[numm][i]]) mm.push(tangue[numm][i]);
      }
    }
  }
  rep(i,n){
    if(!flag[i]){cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 9844
#include<map>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100111];
int head[100111];
int name[100111];
LL ans[100111];
map<int, int> S[100111];

int main() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    memset(head, 0x3f, sizeof head);
    const int INF = head[0];
    REP (i, N) {
	int k = lower_bound(head, head+N, A[i]) - head;
	if (head[k] == INF) {
	    head[k] = A[i];
	    name[k] = i;
	}
	S[k][A[i]]++;
    }
    int len = lower_bound(head, head+N, head[N]) - head;
    while (len) {
	len--;
	int left = (len == 0? 0: head[len-1]);
	EACH (e, S[len]) {
	    ans[name[len]] += (LL)(e->first - left) * e->second;
	    if (len) S[len-1][head[len-1]] += e->second;
	}
    }
    REP (i, N) printf("%lld\n", ans[i]);
    

    return 0;
}



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

using namespace std;
using ll = long long;

int main()
{
    int N,M;cin >> N >> M;
    vector<int> v(N);
    for(int i = 0;i < M;i++){
        int a;cin >> a;
        int b;cin >> b;
        v[a-1]++;
        v[b]--;
    }
    vector<int> rui = {0};
    for(int i = 0;i < N;i++){
        rui.push_back(v[i] + rui.back());
    }
    int cnt = 0;
    for(int i = 0;i < N+1;i++){
       // cout<<rui[i]<<" ";
        if(rui[i] == M){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
inline T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
inline T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n, q; string s;
	cin >> n >> q >> s;
	vector<int> index(n,0);
	
	for (int i = 1; i < n; i++)
	{
		index[i] = index[i-1] + (s[i-1] == 'A' && s[i] == 'C');
	}

	for (int i = 0; i < q; i++)
	{
		int first, last; cin >> first >> last;

		int ans = index[last-1] - index[first-1];

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1472
use std::io::prelude::*;

fn input<T>() -> T
where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a = match input::<u32>() {
        1 => 14,
        x => x,
    };
    let b = match input::<u32>() {
        1 => 14,
        x => x,
    };
    if a == b {
        println!("Draw");
    } else if a > b {
        println!("Alice");
    } else {
        println!("Bob");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,M;
  cin >> N >> M;
  int L[M];
  int R[M];
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  sort(L,L+M);
  sort(R,R+M);
  cout << max(0,R[0] - L[M - 1] + 1) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <boost/function.hpp>
#include <cmath>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
#define sort_all(v) std::sort(v.begin(),v.end())
#define sum_all(v) std::accumulate(v.begin(),v.end(),0) // For int. For float, 0 -> 0.0
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

typedef llint dtype;

int main(void)
{
    int N;
    cin >> N;
    auto a = input<int>(N);
    cout << sum_all(a) - N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    string S;

    cin >> S;

    bool a = false, b = false, c = false;

    for (int i = 0; i < 3;i++)
    {
        if(S[i] == 'a')
        {
            a = true;
        }
        else if(S[i] == 'b')
        {
            b = true;
        }
        else if(S[i] == 'c')
        {
            c = true;
        }
    }

    if(a && b && c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }  

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=10010 ;

char s[N];
int n, len , cnta, cntb, cntba;
int main(){
	scanf("%d", &n);
	int ans=0;
	for  (int i=0; i<n; ++i){
		scanf("%s", s); len=strlen(s);
		for (int i=0; i+1<len; ++i)
			if ( s[i]=='A' && s[i+1]=='B') ++ans;
		bool flagb= s[0]=='B', flaga=s[len-1]=='A';
		cntba+=flagb&flaga;
		if( !flagb || !flaga)cntb+=flagb,cnta+=flaga;
	}
	#ifdef che
	debug("cnta=%d, cntb=%d, cntba=%d, initans=%d\n", cnta, cntb, cntba, ans);
	#endif
	if ( cntba){
		ans += cntba-1;
		if (cnta) --cnta, ++ans;
		if (cntb) --cntb, ++ans;
	}
	ans += min(cnta, cntb);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
while 1:
	n = input()
	if n == 0: break
	ans = 0
	for i in range(96):
		t = i*(i+1)*(i+2)/6
		if t > n: break
		ans = max(ans,int((n-t)**(1.0/3)+1e-8)**3 + t)
		if ans == n: break
	print ans

Measured memory_bytes: 4348
#include <cstdio>
#include <regex>
#include <list>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mt make_tuple
#define pb push_back
#define sz size()
#define SET(__set, val) memset(__set, val, sizeof(__set))

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1000000007;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=1000000000;

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

	string s;
	while(cin>>s) {
		cout <<s.substr(0, s.size() - 8)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	s := stringLineScan()
	if s[0] == s[1] && s[1] == s[2] {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	long long x,k;
	cin>>x>>k;

	if( x*500 >= k )
		cout<<"Yes";
	else
		cout<<"No";

	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
int main()
{
	int n;
	int a[200100];
	cin>>n;
	int mn;
	int res=0;
	REP(i,n)
	{
		cin>>a[i];
		if(i==0||a[i]<mn)
		{
			res++;
			mn=a[i];
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int a[55];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n - 1; i++)
		for(int j = i + 1; j < n; j++)
			ans += a[i] * a[j];
	cout << ans << endl;
	return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



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

  vector<int> p(N);
  rep(i, 0, N){
    cin >> p[i];
  }

  sort(all(p));
  int sum = 0;

  rep(i, 0, K){
    sum += p[i];
  }

  cout << sum << endl;;
  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3628
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,y,j,k,n;
    string s;
    cin>>n;
    vector<pair<ll,ll>>v;
    for(i=0; i<n; i++)
    {
        cin>>x>>y;
        v.push_back(mp(x+y,x-y));
    }
    sort(v.begin(),v.end());
    ll discard=0,cur;
    cur=v[0].fi;
    for(i=1; i<v.size(); i++)
    {
       ll q=v[i].se;
       if(cur>q) discard++;
       else cur=v[i].fi;
    }

    cout<<n-discard<<endl;
    return 0;
}





Measured memory_bytes: 5312
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	char a[1000], b[1000];

	std::cin >> a >> b;

	if (strcmp(a, b) == 0) {
		std::cout << "EQUAL" << std::endl;
	} else if (strlen(a) < strlen(b) || strcmp(a, b) < 0) {
		std::cout << "LESS" << std::endl;
	} else {
		std::cout << "GREATER" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import deque

def main():
  n, d, a = map(int, input().strip().split())
  XsHs = [list(map(int, input().strip().split())) for _ in range(n)]
  XsHs.sort(key = lambda x:x[0])

  queue = deque()
  total = 0
  ans = 0
  for x, h in XsHs:
    while queue:
      if queue[0][0] < x:
        total -= queue[0][1]
        queue.popleft()
      else:
        break
    h -= total
    if h > 0:
      num = (h+a-1)//a
      ans += num
      total += (num*a)
      queue.append((x+(2*d), num*a))
  print(ans)

if __name__=='__main__':
  main()


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

int sum(int x) {
  int n = 0;
  while (x > 0) {
    n += x % 10;
    x /= 10;
  }
  return n;
}

int main() {
  int N, A, B, count = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    if (sum(i)>=A && sum(i)<=B) {
      count += i;
    }
  }
  cout << count << endl;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i)
    {
    int x;
    cin>>x;
    if(m[x]==0) v.push_back(x);
    ++m[x];
    }
    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val X, Y = ni()
    out.println(X + Y / 2)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27208
N, M = map(int, input().split())


if min(N, M) == 1:
    if max(N, M) > 1:
        print(max(N, M) - 2)
    else:
        print(1)
else:
    print(N * M - 4 - (N - 2) * 2 - (M - 2) * 2)
    

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

#define fs first
#define sc second

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; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    printf("%.6lf\n", 1 - (double)(n/2)/n);

    return 0;
}


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

using namespace std;
#define int            long long
#define f(i,n)        for(int i=0;i<(n);++i)
#define fa(i,a,n)     for(int i=a;i<=(n);++i)
#define fd(i,a,n)     for(int i=a;i>=(n);--i)
#define tc 			  int t;cin>>t;f(testcase,t)
#define pii             pair<int,int>
void c_p_c() {

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

}

int32_t main() {

	c_p_c();

	int n;
	cin >> n;
	int t[n];
	int sum = 0;
	f(i, n)
	{
		cin >> t[i];
		sum += t[i];

	}
	int m;
	cin >> m;
	int p[m], x[m];
	f(i, m) {
		cin >> p[i] >> x[i];
	}
	f(i, m) {
		int temp = sum;
		temp -= t[p[i] - 1];
		temp += x[i];
		cout << temp << "\n";
	}




	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a, b = 1, 1
if N > 1:
    a = combinations_count(N,2) 
else:
    a = 0
if M > 1:
    b = combinations_count(M, 2)
else:
    b = 0


print(a + b)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


struct Node{
    string s;
    char target;
    int cost;
    bool operator< (const Node &r) const{
        return cost > r.cost;
    }
};

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

    priority_queue<Node> que;
    for(auto c : s) que.push({s, c, 0});

    Node node;
    while(!que.empty()){
        node = que.top(); que.pop();
        bool end = true;
        for(auto c : node.s){
            if(c != node.target){
                end = false;
                break;
            }
        }

        if(end) break;

        string tt = "";
        rep(i, (ll)node.s.size()-1){
            if(node.s[i] == node.target ||
                    node.s[i+1] == node.target){
                tt += node.target;
            }
            else{
                tt += node.s[i];
            }
        }
        que.push({tt, node.target, node.cost+1});
    }

    cout << node.cost << endl;

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

A = list(map(int,input().split()))

L = [list(map(int,input().split())) for i in range(M)]

for i in range(N) :
    L.append([1,A[i]])

L = sorted(L, key=lambda x: x[1], reverse=True)

ans = 0

for i in range(len(L)) :
    number, point = L[i]
    
    if number > N :
        number = N
    
    ans += number * point
    N -= number
    
print(ans)


Measured memory_bytes: 44996
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int a, b;cin>>a;
  map<string, int> mp;
  for(int i=0;i<a;i++){
    string s;cin>>s;
    mp[s]++;
  }
  cin>>b;
  for(int i=0;i<b;i++){
    string s;cin>>s;
    mp[s]--;
  }
  int ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    // cout << itr->first << ": " << itr->second << endl;
    ans=max(ans, max(0, itr->second));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e18
typedef long long ll;
typedef pair<ll,ll> P;



unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 

int main(void){
    string s;
    cin>>s;
    int n = s.length();
    if(n==2){
        if(s[0]==s[1]){
            cout<<1<<" "<<2<<endl;
        }
        else cout<<-1<<" "<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n-2;i++){
        set<char>x;
        x.insert(s[i]);
        x.insert(s[i+1]);
        x.insert(s[i+2]);
        if(x.size()<3){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
	return 0; 
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n/2){
    if(s[i]!=s[n-1-i])++ans;
  }
  cout << ans << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;

  bool d[10] = {};
  for (int i = 0; i < k; ++i) {
    int D;
    cin >> D;
    d[D] = true;
  }

  for (int i = n;; ++i) {
    int t = i;
    bool f = true;
    while (t) {
      if (d[t % 10]) f = false;
      t /= 10;
    }

    if (f) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>

typedef long long i64;

const int N = 100 + 10, MOD = 1000000007;

i64 n;
int f[N][2][2][2];

int main() {
  scanf("%lld", &n);
  f[0][0][0][0] = 1;
  for (int i = 0; i < 64; ++i) {
    for (int x = 0; x < 2; ++x) { // <= or >
      for (int y = 0; y < 2; ++y) { // last a & b
        for (int z = 0; z < 2; ++z) { // +z
          int cur = f[i][x][y][z];
          if (!cur) continue;
          for (int a = 0; a < 2; ++a) { // current a ^ b
            for (int b = 0; b < 2; ++b) { // current a & b
              if (a && b) continue;
              int t = a + y + z;
              int p = t & 1, q = n >> i & 1, u;
              if (p == q) u = x; else u = (p < q ? 0 : 1);
              bool w = t >> 1;
              (f[i + 1][u][b][w] += cur) %= MOD;
            }
          }
        }
      }
    }
  }
  printf("%d\n", f[64][0][0][0]);
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s;cin>>s;
  for(i=0;i<s.size();i++){
    if(s[i]=='x')buf++;
  }
  ans2(buf<8);


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int i, j, k;
    long long n;
    vector <int> v;
    
    scanf("%lld", &n);
    
    for (i = 0; ; i++) {
        if ((1LL << (i + 1)) - 1 > n) {
            n -= (1LL << i) - 1;
            
            break;
        }
        
        v.push_back(i + 1);
    }
    
    while (n > 0) {
        for (j = 0; ; j++) {
            if ((1LL << j) > n) {
                n -= (1LL << (j - 1));
                
                break;
            }
        }
        
        for (k = 0; k < v.size(); k++) {
            if (v[k] == j) {
                v.insert(v.begin() + k, i + 1);
                
                i++;
                
                break;
            }
        }
    }
    
    for (j = 0; j < i; j++) v.push_back(j + 1);
    
    printf("%d\n", v.size());
    for (i = 0; i < v.size(); i++) {
        if (i > 0) putchar(' ');
        printf("%d", v[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,m,tmp = 2,ans = 0;
LL a[2000005];
char ch;
map <LL,LL> mp;

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> ch;
		a[i] = ch - '0' - 1;
		if(a[i] == 1) tmp = 1;
	}
	if(tmp == 2){
		for(LL i = 1;i <= n;i ++){
			if(a[i] == 2) a[i] = 1;
		}
	}
	else{
		for(LL i = 1;i <= n;i ++){
			if(a[i] == 2) a[i] = 0;
		}
	}
	for(LL i = 1;i <= n;i ++) if(((n - 1) & (i - 1)) == i - 1) ans ^= a[i]; 
	cout << (ans ? tmp : 0) << endl;
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

#define REP(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

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

    int N, K;
    cin >> N >> K;
    cout << (N % K == 0 ? 0 : 1) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];

  ll mx = 0;
  rep(i, n) mx = max(mx, a[i]);
  int l = 0;
  while (mx > 0) {
    mx /= 2;
    ++l;
  }

  ll ans = 0;
  rep(i, l) {
    ll x = 1;
    rep(j, i) {
      x *= 2;
      x %= mod;
    }
    ll y = 0;
    rep(j, n) if (a[j] >> i & 1) { ++y; }
    ans += (y * (n - y) % mod) * x % mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys
for line in sys.stdin.readlines():
    try:
        list=map(float,line.split())
        x=list[0:6:2]
        y=list[1:6:2]
        xp=list[6]
        yp=list[7]
        xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)]
        yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)]
        xpv=[xp-x[a] for a in xrange(3)]
        ypv=[yp-y[a] for a in xrange(3)]
        cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)]
        if (cross[2]>0 and cross[1]>0  and cross[0]>0) or (cross[2]<0 and cross[1]<0 and cross[0]<0): 
            print "YES"
        else:
            print "NO"
    except:
        pass
#temp

Measured memory_bytes: 4300
while True:
    n,x=map(int,input().split())
    if (n,x)==(0,0):
        break

    c=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    c+=1
    print(c)


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

int main(){
	int A[4], B[4];
	while( cin >> A[0] >> A[1] >> A[2] >> A[3], cin >> B[0] >> B[1] >> B[2] >> B[3] ){
		int hit = 0, blow = 0;
		bool check[10] = {false};
		//cin >> A[0] >> A[1] >> A[2] >> A[3];
		//cin >> B[0] >> B[1] >> B[2] >> B[3];
		for( int i=0; i<4; i++ ) if( A[i] == B[i] ) hit++;
		for( int i=0; i<4; i++) check[A[i]] = true;
		for( int i=0; i<4; i++ ) if( A[i] != B[i] && check[B[i]] ) blow++;
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> S(N + 1);
  S.at(0) = 0;
  for (ll i = 0; i < N; i++)
  {
    S.at(i + 1) = S.at(i) + A.at(i) - 1;
    S.at(i + 1) %= K;
  }

  queue<ll> Q;
  map<ll, ll> mp;
  ll ans = 0;
  for (ll i = 0; i < N + 1; i++)
  {
    //cerr << ans << endl;

    if (Q.size() == K)
    {
      //cerr << "* " << Q.front() << endl;
      mp[Q.front()]--;
      Q.pop();
    }

    ans += mp[S.at(i)];

    mp[S.at(i)]++;
    Q.push(S.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 17536
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int m, day, day1, day2, tmp;
	int M, D, ans = 0;

	scanf("%d", &M);
	scanf("%d", &D);

	for(m = 4; m <= M; m++){
		for(day = 2; day <= D; day++){
			day1 = day / 10;
			day2 = day % 10;
			tmp = day1 * day2;

			if(m == tmp && day1 >=2 && day2 >=2){
				ans++;
			}
		}
	}

	printf("%d", ans);

	return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAXN = 10e5+10;

int N;
int h[MAXN];
int dp[MAXN];

int main() {
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> h[i];
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0; dp[2] = abs(h[1]-h[2]);
    for(int i=3; i<=N; i++) {
        dp[i] = min({dp[i], dp[i-1]+abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])});
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; ll m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,0,n) cin >> a[i];
  map<ll,ll> p;
  ll k = 0, ans = 0;
  p[0]++;
  rep(i,0,n) {
    k += a[i];
    ans += p[k%m];
    p[k%m]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7884
#include<iostream>
int main() {
long long int N,L[100000];
L[0]=2;
L[1]=1;
std::cin >> N;
for (int i=2; i<=N; i++)
L[i]=L[i-1]+L[i-2];
std::cout << L[N] << std::endl;
			return 0;
}
		


			
	


Measured memory_bytes: 256
import itertools
import numpy as np
N, D = [int(_) for _ in input().split()]
X = np.array([[int(_) for _ in input().split()] for _ in range(N)], dtype=int)
ans = 0
for i, j in itertools.combinations(range(N), 2):
    y = sum((X[i] - X[j])**2)
    if y == (int(y**0.5))**2:
        ans += 1
print(ans)


Measured memory_bytes: 12576
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
ans = 0
cnt = a[0]
for i in range(1, n):
    ans += cnt * a[i]
    ans %= mod
    cnt += a[i]
print(ans)



Measured memory_bytes: 92052
#include <string>
#include <iostream>
using namespace std;
int dir[] = { 0, 1, 0, -1 };
string e = "RDLU";
string s[9]; bool d[6][6][4];
int main() {
	for (int i = 0; i < 9; i++) cin >> s[i];
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 4; j++) {
			if (s[i * 2][j] == '1') d[i][j + 1][1] = d[i + 1][j + 1][3] = true;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 5; j++) {
			if (s[i * 2 + 1][j] == '1') d[i + 1][j][0] = d[i + 1][j + 1][2] = true;
		}
	}
	string ret = "R";
	int x = 0, y = 1, dr = 0;
	while (true) {
		if (d[x][y][dr]) dr = (dr + 3) & 3, ret += e[dr];
		else {
			x += dir[dr], y += dir[dr ^ 1];
			if (x == 0 && y == 1) break;
			int cnt = 0;
			while (!d[x][y][(dr + 1) & 3]) {
				dr = (dr + 1) & 3;
				x += dir[dr], y += dir[dr ^ 1];
				if (x == 0 && y == 1) break;
			}
			if (x == 0 && y == 1) break;
			ret += e[dr];
		}
	}
	cout << ret << endl;
	return 0;
}

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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

using mint = modint998244353;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    V<mint> va(N), vb(M);
    rep(i, N) {
        int x;
        cin >> x;
        va[i] = x;
    }
    rep(i, M) {
        int x;
        cin >> x;
        vb[i] = x;
    }
    auto vec = convolution(va, vb);
    for (auto& x : vec) cout << x.val() << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 19020