akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define rep(i,n)for(int i=0;i<n;++i)
#define p pair<int,int>
int main() {
	int N; int K; int D[10];
	cin >> N >> K;
	for (int i = 0; i < K; ++i) {
		cin >> D[i];
	}
	for (int i = N;; ++i) {
		bool can = true;
		int ans = i;
		while (ans > 0) {
			int a = ans % 10;
			for (int j = 0; j < K; ++j) {
				if (a == D[j]) {
					can = false;
				}
			}
			if (!can) {
				break;
			}
			ans /= 10;
		}
		if (can) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	ps := getIntSlice(n)

	cnt := 0
	for i := 0; i < n; i++ {
		if ps[i] == i+1 {
			cnt++
			i++
		}
	}

	fmt.Println(cnt)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1920
#include<stdio.h>
int main(){
	int a;
    scanf("%d",&a);
    while(a--){
     int b,flag=1;
     int right=0,left=0;
     for(int i=0;i<10;i++){
     	scanf("%d",&b);
     	if(b>right){
		 right=b;continue;}
		if(b>left){
			left=b;continue;
		}
		if(flag)
     	printf("NO\n");
     	flag=0;
	 }
	 if(flag)
	 printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 1008
const Main = input => {
  input = input.split('\n')
    .slice(1)
    .map(v => v.split('').sort((a, b) => a > b).join(''))

  var count = 0
  const obj = {}
  input.forEach(ip => {
    if (!obj.hasOwnProperty(ip)) {
      obj[ip] = 1
      return
    }
    count += obj[ip]
    obj[ip] = obj[ip] + 1
  })

  console.log(count)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 60756
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
//#include<iostream>
using namespace std;

int n;
#define maxn 111
char s[maxn];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	int ans=233333;
	for (char c='a';c<='z';c++)
	{
		int Max=0,cnt=0;
		for (int i=0;i<n;i++)
		{
			if (s[i]==c)
			{
				Max=max(Max,cnt);
				cnt=0;
			}
			else cnt++;
		}
		Max=max(Max,cnt);
		ans=min(ans,Max);
	}
	printf("%d\n",ans);
	return 0;
}

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

a -= 1
b -= 1
c -= 1
d -= 1

flg1 = S[a:c+1].count("##")
flg2 = S[b:d+1].count("##")
flg3 = S[b-1:d+2].count("...")

if c < d :
    if flg1 + flg2 == 0 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (flg1 + flg2 == 0) and flg3 :
        ans = "Yes"
    else :
        ans = "No"

print(ans)

Measured memory_bytes: 3572
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    cin>>n;
    for(int i=0;i<=50;i++){
    	for(int j=0;j<=50;j++){
    		if(i*4+j*7==n){
    			cout<<"Yes";
    			return 0;
			}
		}
	}
	cout<<"No";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000002



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> m(2,Inf),M(2,-Inf); 
	
	vector<long long> x(N),y(N);
	for(int i=0;i<N;i++){
		cin>>x[i]>>y[i];
		if(x[i]>y[i])swap(x[i],y[i]);
		m[0] = min(m[0],y[i]);
		M[0] = max(M[0],x[i]);
	}
	m[1]=m[0];
	M[1]=M[0];
	
	vector<pair<long long,long long>> LR;
	long long xmin=Inf,ymax=-Inf;

	for(int i=0;i<N;i++){
		bool f0 = (x[i]>=m[0]);
		bool f1 = (y[i]<=M[0]);
		if(f0&&f1)continue;
		if(!f0&&!f1){
			LR.emplace_back(x[i],y[i]);
		}
		else if(!f0){
			xmin = min(xmin,x[i]);
		}
		else{
			ymax = max(ymax,y[i]);
		}
	}
	
	for(int i=0;i<LR.size();i++){
		m[0] = min(m[0],LR[i].first);
		M[1] = max(M[1],LR[i].second);
	}
	//cout<<xmin<<','<<ymax<<endl;
	long long ans = Inf;
	
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			auto cm = m;
			auto cM = M;
			cm[i] = min(cm[i],xmin);
			cM[j] = max(cM[j],ymax);
			ans = min(ans,(cM[0]-cm[0])*(cM[1]-cm[1]));
		}
	}
	
	cout<<ans<<endl;
		

	return 0;
}

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

int main() {
  ll a,b;
  cin >> a >> b;
  if(a%2 != b%2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = []
for i in a:
    if i%2 == 0:
        l.append(i)
for j in l:
    if (j%3 != 0) and (j%5 != 0):
        print("DENIED")
        exit()
print("APPROVED")


Measured memory_bytes: 38384
function main(input) {
  var x = input[0]-0;
  var ans = "NO";
  switch(x){
    case 7:
    case 5:
    case 3:
      ans = "YES";
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[x] = y
        else:
            if self.same_check(x, y) != True:
               self.size[x] += self.size[y]
               self.size[y] = 0
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
               self.rank[x] += 1

    def siz(self, x):
        x = self.find(x)
        return self.size[x]

def getlist():
    return list(map(int, input().split()))

N, M = getlist()
U = UnionFind(N)
for i in range(M):
    X, Y, Z = getlist()
    U.union(X, Y)

D = defaultdict(int)


for i in range(1, N + 1):
    n = U.find(i)
    D[n] += 1

print(len(D))

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

using namespace std;

typedef long long ll;

bool check_bit(int num, int mask) {
    return (mask & (1 << num)) != 0;
}

void solve() {
    ll D, G;
    cin >> D >> G;

    vector<ll> amount(D), bonuses(D);
    for (int i = 0; i < D; i++) {
        cin >> amount[i] >> bonuses[i];
    }

    ll ans = (1ll << 60ll);
    for (int mask = 0; mask < (1 << D); mask++) {
        ll total_moves = 0, total_score = 0;

        for (int i = 0; i < D; i++) {
            if (check_bit(i, mask)) {
                total_moves += amount[i];
                total_score += amount[i] * 100 * (ll) (i + 1) + bonuses[i];
            }
        }

        ll need = G - total_score;

        bool ok = true;
        int i = (int) D;
        while (need > 0) {
            --i;
            if (i < 0) { ok = false; break; }

            if (!check_bit(i, mask)) {
                ll price = 100ll * (i + 1), can_get = (amount[i] - 1) * price;
                if (can_get >= need) {
                    total_moves += (need + price - 1) / price;
                } else {
                    total_moves += amount[i] - 1;
                }
                need -= can_get;
            }
        }

        if (ok) ans = min(ans, total_moves);
    }

    cout << ans;
}

int main() {
    solve();
    return 0;
}

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

namespace abc155
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc155A();
        }

        public static void solve_abc155B()
        {

        }

        public static void solve_abc155A()
        {
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            if ((abc[0] == abc[1] && abc[2] != abc[0]) || (abc[0] == abc[2] && abc[1] != abc[0]) || (abc[1] == abc[2] && abc[0] != abc[1]))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int ans=0;
  int c=min(a,b);
  vector<int> d;
  for(int i=1;i<c+1;i++){
    if(a%i==0 && b%i==0) d.push_back(i);
  }
  ans=d[d.size()-k];
  cout << ans << endl;
}

Measured memory_bytes: 3544
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            WriteLine(A * B - A - B + 1);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27348
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

fn main() {
    let s = input::<String>().chars().collect::<Vec<_>>();
    let mut w = 0;
    let mut ans = 0;
    for (i, c) in s.iter().enumerate() {
        if *c == 'W' {
            ans += i - w;
            w += 1;
        }
    }

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

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


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

class UnionFind {
public:
    // parent node index if not root index
    // minus size of the tree if root index
    std::vector<int> data;

    UnionFind( int n ) {
        data.resize( n, -1 );
    }

    int find( int x ) {
        if ( data[x] < 0 ) {
            return x;
        } else {
            int r = find( data[x] );
            data[x] = r;
            return r;
        }
    }

    void unite( int x, int y ) {
        int r = find( x );
        int s = find( y );
        if ( r != s ) {
            data[r] += data[s];
            data[s] = r;
        }
    }
};

ll solve() {
    ll N;
    cin >> N;
    ll x, y;
    vector<pair<ll,int>> X, Y;
    for ( int i = 0; i < N; i++ ) {
        cin >> x >> y;
        X.emplace_back(x, i);
        Y.emplace_back(y, i);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    priority_queue<pair<ll, pair<int, int>>> qx, qy;
    for ( int i = 0; i < N-1; i++ ) {
        ll dx = X[i+1].first - X[i].first;
        qx.push(make_pair(-dx, make_pair(X[i].second, X[i+1].second)));
        ll dy = Y[i+1].first - Y[i].first;
        qy.push(make_pair(-dy, make_pair(Y[i].second, Y[i+1].second)));
    }

    ll ans = 0;
    UnionFind u(N);
    while ( !qx.empty() || !qy.empty() ) {
        pair<ll, pair<int, int>> v;
        if ( qy.empty() ) {
            v = qx.top();
            qx.pop();
        } else if ( qx.empty() ) {
            v = qy.top();
            qy.pop();
        } else if ( -qx.top().first <= -qy.top().first ) {
            v = qx.top();
            qx.pop();
        } else {
            v = qy.top();
            qy.pop();
        }
        int i = v.second.first, j = v.second.second;
        if ( u.find(i) != u.find(j) ) {
            u.unite(i,j);
            ans += -v.first;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9572
//https://onlinejudge.u-aizu.ac.jp/beta/room.html#KUPC2020Spring/problems/K
#include<bits/stdc++.h>
#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()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; string S; int P[1 << 19];
int dp[19][1 << 19];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> S;
	rep(i, 0, 1 << N) cin >> P[i];
	rep(i, 0, 1 << N) P[(1 << N) + i] = P[i];

	rep(i, 0, 1 << (N + 1)) dp[0][i] = P[i];
	rep(p, 1, N + 1) rep(L, 0, 1 << (N + 1)) {
		int R = L + (1 << (p - 1));
		if (1 << (N + 1) <= R) continue;
		int x = dp[p - 1][L];
		int y = dp[p - 1][R];
		tie(x, y) = make_pair( min(x, y), max(x, y) );

		if (S[y - x - 1] == '0') dp[p][L] = x;
		else dp[p][L] = y;
	}

	rep(i, 0, 1 << N) printf("%d\n", dp[N][i]);
}





/* ///////////////////////// writeup1 start
///////////////////////// writeup2 start
///////////////////////// writeup2 end */
//　


Measured memory_bytes: 43456
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  #ifndef ONLINE_JUDGE
  ioso //ffe
  #endif
  ll n; cin >> n;
  ll ans = (((n)*(n-1))/2)
  ;cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v(n+1);
  rep(i,n){
    cin >> v[i];
  }
  ll cnt = 0;
  int f = 0;
  rep(i,n-1){
    if(v[i] != v[i+1]){
      if(f == 0){
        if(v[i] < v[i+1]){
          ++f;
        }
        else if(v[i] > v[i+1]){
          --f;
        }
      }
      else{
        if(f < 0 && v[i] > v[i+1]){

        }
        else if(f > 0 && v[i] < v[i+1]){

        }
        else{
          /* std::cout << v[i] << ' ' << v[i+1] << std::endl; */
          ++cnt;
          f = 0;
        }
      }
    }
  }
  cout << cnt+1 << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
//#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

const int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n,k; cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i,k) cin >> l[i] >> r[i];
    vector<mint> dp(n+1);
    vector<mint> dpsum(n+1);
    dp[1] = 1;
    dpsum[1] = 1;
    for (int i=2; i<=n; i++) {
        rep(j,k) {
            int li = i-r[j];
            int ri = i-l[j];
            if (ri < 0) continue;
            li = max(li,1);
            dp[i] += dpsum[ri]-dpsum[li-1];
        }
        dpsum[i] = dpsum[i-1]+dp[i];
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 6388
#include <stdio.h>

void insertionSort(int A[],int n,int g);
void shellSort(int A[],int n);

int m;
int cnt;
int G[1000000];

int main(void)
{
	int i,n;
	scanf("%d", &n);
	
	int a[n];
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	shellSort(a,n);
	
	printf("%d\n", m);
	for(i=m-1; i>=0; i--){
		printf("%d ",G[i]);
	}
	printf("\n");
	printf("%d\n",cnt);
	for(i=0; i<n; i++){
		printf("%d\n",a[i]);
	}
	
	return 0;
}

void insertionSort(int A[],int n,int g)
{
	int i,j,v;
	for(i=g; i<n; i++){
		v=A[i];
		j=i-g;
		while(j >= 0 && A[j] > v){
			A[j+g] = A[j];
			j=j-g;
			cnt++;
		}
		A[j+g]=v;
	}
}

void shellSort(int A[], int n)
{
	int i,t;
	m=0;
	cnt=0;
	for(int h=0;; h++){
		t=1;
		for(i=0; i<=h; i++){
			t=3*t;
		}
		G[h]=(t-1)/2;
		if(G[h] > n){
			break;
		}
		m++;
	}
	
	for(i=m-1; i>=0; i--){
		insertionSort(A,n,G[i]);
	}
}


Measured memory_bytes: 5660
s = input()

if s == "SUN":
    ans = 7
elif s == "MON":
    ans = 6    
elif s == "TUE":
    ans = 5
elif s == "WED":
    ans = 4
elif s == "THU":
    ans = 3
elif s == "FRI":
    ans = 2
elif s == "SAT":
    ans = 1

print(ans)

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

signed main(){
	int N,K; cin>>N>>K;
	vector<int> h(N);
	for(int i=0;i<N;i++)cin>>h[i];
	vector<int> cost(N,1000000000+7);
	cost[0]=0;
	cost[1]=llabs(h[1]-h[0]);
	for(int i=1;i<N;i++){
		for(int j=max(0LL,i-K);j<min(N,i);j++){
			cost[i]=min(cost[i],llabs(h[i]-h[j])+cost[j]);
		}
	}
	cout<<cost[N-1]<<endl;

}


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

int main() {
	string S;
	cin >> S;
	bool str[26];
	for (int i = 0; i < 26; i++)
		str[i] = true;

	char ch[26];
	for (int i = 0, j = 97; i < 26; i++, j++)
		ch[i] = j;

	int len = strlen(&S[0]);
	bool flag = true;
	for (int i = 0; i < len; i++) {
		for (int j = 0; j < 26; j++)
			if (S[i] == ch[j]) {
				str[j] = false;
			}
	}
	for (int i = 0; i < 26; i++)
		if (str[i]) {
			flag = false;
			printf("%c\n", ch[i]);
			break;
		}
	if (flag)
		printf("None\n");

}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int fr[100];
int main (){
    int m,n,i;
    char mi[100][10],ni[100][10];
    scanf("%d",&n);
    for (i = 0 ; i < n ;i++){
        scanf ("%s",ni[i]);
    }
    scanf("%d",&m);
    for (i = 0 ; i < m ;i++){
        scanf ("%s",mi[i]);
    }
    int k=0,j;
    for (i = 0 ; i<n-1;i++)
    {
         if ( ni[i][0]!='\0' )
            { fr[k]++;
        for(j = i+1;j<n ;j++)
        //ni[i][0]!='\0' &&
            if( strcmp(ni[i],ni[j])==0){
               fr[k]++;
               ni[j][0] = '\0';
            }

        for (j = 0; j<m;j++)
             if ( mi[j][0]!='\0' && strcmp(ni[i],mi[j])==0){
               fr[k]--;
               mi[j][0] = '\0';
            }
            k++;

        }}
        int max = 0;
        for ( i = 0 ; i <100 ; i++)
            if (max <fr[i])
                max = fr[i];
        printf ("%d\n",max);
        return 0;
    }


Measured memory_bytes: 128
use std::io;
fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<u8> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut cnt = 0;
    for (i, val) in v.iter().enumerate() {
        if 1+i%2 == 1 && val%2 == 1 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll k = N % 10;
  if (k == 0 || k == 1 || k == 6 || k == 8) {
    cout << "pon\n";
  }else if (k == 3) {
    cout << "bon\n";
  }else {
    cout << "hon\n";
  }

  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
static const int64_t MAX_N = 1E5, MAX_ABC = 1E4;
int64_t n, abc[MAX_N][3];
int64_t dp[MAX_N][3];

void solve() {
	for(int64_t i = 0; i < MAX_N; i++) {
		dp[i][0] = dp[i][1] = dp[i][2] = -1;
	}
	for(int64_t i = 0; i < 3; i++) {
		dp[0][i] = abc[0][i];
	}
	for(int64_t i = 0; i < n-1; i++) for(int64_t j = 0; j < 3; j++) for(int64_t k = 0; k < 3; k++) {
		int64_t x = dp[i][k] + abc[i+1][j];
		if (j != k && dp[i+1][j] < x) dp[i+1][j] = x;
	}
	int64_t result = 0;
	for(int i = 0; i < 3; i++) if(result < dp[n-1][i]) result = dp[n-1][i];
	cout << result << endl;
}

int main() {
	cin >> n;
	for(int64_t i = 0; i < n; i++) {
		cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	}
	solve();
	return 0;
}

Measured memory_bytes: 4992
#define F for(i=h;i--;)for(j=w+1;j--;)if
char a[200][200];r[200],c[200];main(i,j,h,w){scanf("%d%d\n",&h,&w);F((a[i][j]=getchar())==35)r[i]=c[j]=1;c[0]=1;F(r[i]&c[j])putchar(a[i][j]);}

Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    x = list(map(int, input().split()))
    p = round(sum(x)/n)
    stamina = 0
    for i in range(n):
        stamina += (x[i] - p) ** 2
    print(stamina)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n, m = map(int,input().split())
height = list(map(int,input().split()))
arr = []

for i in range(m):
   x, y = map(int,input().split())
   height_x = height[x-1]
   height_y = height[y-1]
   if height_x > height_y:
      arr.append(y)
   elif height_x < height_y:
      arr.append(x)
   else:
      arr.append(x)
      arr.append(y)
arr = list(set(arr))
print(n-len(arr))



Measured memory_bytes: 20108
import sys
def az14():
    while True:
        xs = raw_input().split()
        H,W = int(xs[0]),int(xs[1]) 
        if H==0 and W==0 : break
        for i in range(0,H):
            for j in range (0,W):
                if (i+j)%2 == 0:
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")
            print
        print

az14()

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

using namespace std;

using ll = long long;

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

    int n, k;

    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) cin >> x[i];

    int min_t = 2 * (abs(x[0]) + abs(x[n - 1]));
    for (int i = 0; i + k - 1 < n; ++i) {
        if (x[i] < 0 && x[i + k - 1] < 0)
            min_t = min(min_t, abs(x[i]));
        else if (0 <= x[i] && 0 <= x[i + k - 1])
            min_t = min(min_t, abs(x[i + k - 1]));
        else if (abs(x[i]) < abs(x[i + k - 1]))
            min_t = min(min_t, 2 * abs(x[i]) + abs(x[i + k - 1]));
        else
            min_t = min(min_t, abs(x[i]) + 2 * abs(x[i + k - 1]));
    }

    cout << min_t << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 30;
int N;
int A[Max], B[Max], C[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(A, N);
    inputArray(B, N);
    inputArray(C, N-1);
    int ans = 0;
    rep(i, N) {
        ans += B[A[i]-1];
        if (i >= 1) {
            if (A[i] == A[i-1]+1) {
                ans += C[A[i-1]-1];
            }
        }
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt()
    val L = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse)

    def binarySearch(a: Int, b: Int): Int = {
      def recursive(l: Int, r: Int): Int =
        if (r - l > 1) {
          val m = l + (r - l) / 2
          if (L(m) <= L(a) - L(b)) recursive(l, m)
          else recursive(m, r)
        } else l
      recursive(b, N)
    }

    var triangles = 0
    var a = 0
    while (a < N -2) {
      var b = a + 1
      while (b < N - 1) {
        val cMin = binarySearch(a, b)
        triangles += cMin - b
        b += 1
      }
      a += 1
    }

    println(triangles)
  }

}

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

int main(){
	int R,G,B,n;
	scanf("%d %d %d %d",&R,&G,&B,&n);
	int ans = 0;
	for (int r = 0; r <= n;r++){
		for (int g = 0;g <= n;g++){
			double b = (n - r*R - g*G)/(double)B;
			double dumy = floor(b);
			if ((b >= 0) && (b == dumy)){
				ans += 1;
			}
		}
	}
	printf("%d\n",ans);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100010
using namespace std;
typedef unsigned long long ull;
ull const Base = 1777771;
int n,par[N],in[N];

ull bfs(){
  queue<int> Q;
  ull ans=0;
  map<ull,int> M[N];
  vector<ull> H(n,1),dep(n,0);
  for(int i=0;i<n;i++)if(!in[i])Q.push(i),ans+=M[0][1]++;
  
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    int nx = par[pos];
    ull &A = H[pos],&B = H[nx];
    dep[nx] = max(dep[nx],dep[pos]+1);
    B+=A*Base;
    if(--in[nx]==0)ans+=M[dep[nx]][B]++,Q.push(nx);
  }
  return ans;
}

int main(){
  cin>>n;
  for(int i=0,a,b;i<n-1;i++){
    cin>>a>>b;
    in[a-1]++,par[b-1] = a-1;
  }
  cout<<bfs()<<endl;
  return 0;
}

Measured memory_bytes: 16080
import sys
dataset = sys.stdin.readlines()

for item in dataset:
    a, b, c, d, e, f = list(map(int, item.split()))

    y = (c * d - f * a)/(b * d - e * a)
    x = (c * e - b * f) / (a * e - b * d)
    if x == 0:
        x = 0
    print("{:.3f} {:.3f}".format(x, y))

Measured memory_bytes: 7588
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    val count = 0.until(s.length - 2).count { i ->
        s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'
    }
    println(count)
}

Measured memory_bytes: 33644
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 10000000009

int main() {
    FAST_IO
    ll m;
    cin>>m;
    cout<<48-m<<endl;
return 0;
}


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

void calc(vvl v){
    ll a2,a3,b1,b2,b3;  
    rep(a1,v[0][0]+1){
        b1=v[0][0]-a1;
        b2=v[0][1]-a1;
        b3=v[0][2]-a1;
        a2=v[1][0]-b1;
        a3=v[2][0]-b1;
        if(b1<0 or b2<0 or b3<0 or a2<0 or a3<0){
            continue;
        }
        if(a2==v[1][1]-b2 && a2==v[1][2]-b3){
            if(a3==v[2][1]-b2 && a3==v[2][2]-b3){
                cout<<"Yes"<<endl;
                return;
            }
        }
    }
    cout<<"No"<<endl;
}

int main(){
    vvl v(3,vl(3));
    rep(i,3){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    calc(v);         

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] ps = new int[7];
			for(int j = 0; j < n; j++){	
				int s = sc.nextInt();
				
				if(s >= 60){
					ps[6]++;
				}else{
					ps[s/10]++;
				}
			}
			
			for(int i : ps){
				System.out.println(i);
			}
			
			
		}
		
		
		
	}
	
	
}

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

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

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

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

  vector<int> a(n), b(n - 1);
  rep(i, n - 1) cin >> b[i];

  a[n - 1] = b[n - 2];
  a[0] = b[0];
  for (int i = n - 2; i > 0; --i) 
    a[i] = min(b[i-1],b[i]);
  
  ll ans = 0;
  for (auto aa : a) ans += aa;
  cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,m;
	cin>>n>>m;
	
	int round=m;
	int cnt=0;
	m=2*m+1;

	vector<P> ans;
	int l=1,r=m/2;
	if(round%2==0)r++;
	while(cnt<round){
		if(l==r) break;
		ans.push_back(make_pair(l,r));
		l++;r--;
		cnt++;
	}
	l=m/2+1,r=m;
	if(round%2==0)l++;
	while(cnt<round){
		if(l==r)break;
		ans.push_back(make_pair(l,r));
		l++;r--;
		cnt++;
	}
	for(auto x:ans)cout<<x.first<<" "<<x.second<<endl;
	return 0;
}

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
#define MAX 100050
string s;
int n,ans,memo[MAX];
int calc(int x){
  if(~memo[x]) return memo[x];
  int res=0;
  int l=x,r=x;
  while(1){
    if(s[x]=='>') x=++r;
    else x=--l;
    res++;
    if(l<0||n<=r) break;
  }
  ans=max(ans,res);
  return memo[x]=res;
}
int main(){
  cin>>n>>s;
  memset(memo,-1,sizeof(memo));
  int l=0,r=s.size()-1,m1,m2;
  while(l+1<r){
    m1=l+(r-l)/3;
    m2=l+(r-l)*2/3;
    calc(l);calc(r);
    if(calc(m1)<calc(m2)) l=m1+1;
    else r=m2-1;
  }
  calc(l);calc(r);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3688
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> d(n);
  rep(i, n) {
    cin>>d[i];
  }
  dump(d);
  int ans=0;
  rep(i,n){
    rep(j,i+1,n){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	ll a;
	cin >> a;

	cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    int x= stoi(a+b);

    for(int i=0;i<=1000;i++){
        if(i*i==x){
            puts("Yes");
            return 0;
        }
    }

    puts("No");
    


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {

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

	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (i % 2 == 1)continue;
		if (a[i] % 2 == 1)ans++;
	}

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

//int main() {
//	int l, r, d;
//	cin >> l >> r >> d;
//	if (l % d == 0) {
//		cout << r / d - l / d + 1 << endl;
//	}
//	else cout << r / d - l / d << endl;
//	return 0;
//}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll test[1234][1234];
signed main() {
	vector<vector<ll>> abc(27, vector<ll>(2));
	ll D, c, s; cin >> D;
	for (int h = 1; h <= 26; h++) {
		cin >> abc[h][0]; abc[h][1] = h;
	}
	sort(abc.begin() + 1, abc.end());
	for (int i = 0; i < D; i++) {
		for (int h = 0; h < 26; h++) {
			cin >> test[i][h];
		}
	}
	vector<ll> ng;
	for (int h = 0; h < D - 26; h++) {
		if (h % 26 == 0) { ng.clear(); }
		ll a = 0, ans1 = 0, ans2 = 0;
		for (int i = 0; i < 26; i++) {
			if (a != ng.size() && i == ng[a]) { a++; continue; }
			if (ans1 < test[h][i]) {
				ans1 = test[h][i]; ans2 = i;
			}
		}
		cout << ans2 + 1 << endl;
		sort(ng.begin(), ng.end());
	}
	for (int h = 1; h <= 26; h++) {
		cout << abc[h][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5164
#n = int(input())
s = input()
t = input()
#a_L = list(map(int,input().split()))

s_L = list(s)
t_L = list(t)

s_L = sorted(s_L)
t_L = sorted(t_L,reverse=True)

s_L = "".join(s_L)
t_L = "".join(t_L)


if s_L < t_L:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int n,k,tree[300010<<2],a[300010],f[300010];

inline void push_up(int x){tree[x]=max(tree[x<<1],tree[x<<1|1]);}
inline void update(int u,int l,int r,int x,int k)
{
	if(l==r){
		tree[x]=max(tree[x],k);
		return;
	}int mid=l+r>>1;
	if(u<=mid)update(u,l,mid,x<<1,k);
	else update(u,mid+1,r,x<<1|1,k);
	push_up(x);return;
}
inline int query(int ql,int qr,int l,int r,int x){
	if(ql<=l&&qr>=r)return tree[x];
	int mid=l+r>>1,res=0;
	if(ql<=mid) res=max(res,query(ql,qr,l,mid,x<<1));
	if(qr>mid) res=max(res,query(ql,qr,mid+1,r,x<<1|1));
	return res;
}

int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		f[i]=query(max(a[i]-k,0),min(300000,a[i]+k),1,300000,1)+1;
		update(a[i],1,300000,1,f[i]);
	}int ans=0;
	for(int i=1;i<=n;i++) ans=max(f[i],ans);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 10084
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll D, T, S; cin >> D >> T >> S;
    pt(T * S >= D ? "Yes" : "No");
    return 0;
}

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

using namespace std;

void solve() {
    map<char, string> S;
    cin >> S['a'] >> S['b'] >> S['c'];
    char player, next_player;
    player = 'a';
    while(1)
    {
        if (S[player].length() == 0)
        {
            cout << (char)toupper(player) << endl;
            return;
        }
        
        next_player = S[player][0];
        S[player].erase(0,1);
        player = next_player;
        
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Character;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    
    int sum = 0;
    for(int x = 0;x<3;x++){
      int value = Character.getNumericValue(input.charAt(x));
      sum+=value;
      
      
    }
    System.out.print(sum);
  }
}

Measured memory_bytes: 21716