akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define MOD 1000000007
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';



using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    cin>>N;
    ll x=0, xbar=0;
    ll A;
    rep(i, N){
        cin>>A;
        xbar+=A;
        x+=A*A;
        xbar%=MOD;
        x%=MOD;
    }
    //cout<<x<<sp<<xbar<<endl;
    ll val=(xbar*xbar%MOD-x)%MOD+MOD;
    val%=MOD;
    if(val%2==0) cout<<val/2<<endl;
    else cout<<(val+MOD)/2<<endl;
    
    return 0;


}


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

long long N,M,B,C,i,j,n,ans;

main(){
    cin>>N>>M;
    vector<long long>A(N);
    vector<pair<long long,int>>c(M);

    for(auto&a:A) cin>>a;
    sort(A.begin(),A.end());

    for(;i<M;++i){
        cin >> B >> C;
        c[i]=make_pair(C,B);
    }
    sort(c.begin(),c.end());
    for(i=0,j=M-1,n=c[M-1].second; i<N&&A[i]<c[j].first; ++i){
        A[i]=c[j].first;
        
        if(--n==0&&--j>=0) n=c[j].second;
    }

    ans = accumulate(A.begin(),A.end(),0LL);
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
const string T="JOI";
int main(){
	int H,W,Q;
	cin>>H>>W>>Q;
	vector<string>v(H);
	for(int i=0;i<H;i++)cin>>v[i];
	map<char,vector<vector<int> > >M;
	for(int c=0;c<T.size();c++){
		vector<vector<int> > &m=M[T[c]];
		m.resize(H+1);
		m[0].resize(W+1);
		for(int i=1;i<=H;i++){
			m[i].resize(W+1);
			for(int j=1;j<=W;j++)m[i][j]=m[i][j-1]+(v[i-1][j-1]==T[c]);
		}
		for(int j=1;j<=W;j++){
			for(int i=1;i<=H;i++)m[i][j]+=m[i-1][j];
		}
	}
	for(;Q--;){
		int a,b,x,y;
		cin>>a>>b>>x>>y;
		for(int c=0;c<T.size();c++){
			vector<vector<int> > &m=M[T[c]];
			printf(c<T.size()-1?"%d ":"%d\n",m[x][y]-m[a-1][y]-m[x][b-1]+m[a-1][b-1]);
		}
	}
}

Measured memory_bytes: 13944
package main

import (
	"fmt"
	"log"
)

func main() {

	var N ,K int
	var S string
	var out string

	_, err := fmt.Scan(&N, &S, &K)
	if err != nil {
		log.Fatal(err)
	}

	var s = S[K -1 : K]

	//
	for i := 0; i < N; i++ {
		if S[i : i + 1] != s{
			out += "*"
		} else {
			out += s
		}
	}
	fmt.Println(out)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r, sum;
  cin >> N;
   
  for ( int i = 0; i < N ; i++ ) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
	int n;
	int l[1050], r[1050];
	int ans = 0;
	cin >> n;
	rep(i, n){
		cin >> l[i] >> r[i];
		ans += r[i]-l[i]+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[101];
string u[101];
int main()
{
	int i,j,n;
	double s;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		cin>>u[i];
		if (u[i]=="JPY") s+=a[i];
		else s+=a[i]*380000;
	}
	cout<<s;	
}

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

namespace AtCoder
{
    class Abc170A
    {
        public static void Main()
        {
            var x = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            for (int i = 0; i < x.Length; i++)
                if (x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
        }
    }
}


Measured memory_bytes: 28308
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int getDigitSum(int x);

int getAbs(int x);

int getMin(vector<int> v);

int main(){
    int n, grade = 0;
    cin >> n;
    vector<int> s_vec;
    for(int i = 0; i < n; i++){
        int s;
        cin >> s;
        grade += s;
        s_vec.push_back(s);
    }
    
    sort(s_vec.begin(), s_vec.end());

    bool notProduct10Included = false;
    if(grade % 10 == 0){
        for(int i = 0; i < n; i++){
            if(s_vec[i] % 10 != 0){
                notProduct10Included = true;
                grade -= s_vec[i];
                break;
            }
        }

        if(!notProduct10Included) grade = 0;
    }
    cout << grade << endl;
    return 0;
}

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

int getAbs(int x){
    return (x > 0)? x : -x;
}

int getMin(vector<int> v){
    int res = 40000;
    for(int i = 0; i < v.size(); i++){
        res = min(res, v[i]);
    }
    return res;
}

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

using namespace std;

int f(int x)
{
    return x * x;
}

int main()
{
    int d;
    while (cin >> d) {
        int res = 0;
        for (int i = d; i <= 600 - d; i += d) {
            res += d * f(i);
        }
        cout << res << endl;
    }
    return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#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 rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

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

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,t;cin>>n>>t && n|t;){
		vi a(n);
		rep(i,n) cin>>a[i];

		vi mins(n,INF); mins[0]=a[0];
		repi(i,1,n) mins[i]=min(mins[i-1],a[i]);

		vi maxs(n); maxs[n-1]=a[n-1];
		per(i,n-1) maxs[i]=max(maxs[i+1],a[i]);

		int diffmax=0;
		rep(i,n) diffmax=max({diffmax,a[i]-mins[i],maxs[i]-a[i]});

		map<tuple<int,int>,int> c1,c2;
		rep(i,n){
			if(a[i]-mins[i]==diffmax)
				c1[mt(mins[i],a[i])]++;
			if(maxs[i]-a[i]==diffmax)
				c2[mt(a[i],maxs[i])]++;
		}

		int res=0;
		for(auto p:c1)
			res+=min(p.second,c2[p.first]);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 7680
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

//先行順巡回
void preParse(int u){
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

//中間順巡回
void inParse(int u){
	if (u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

//後行順巡回
void postParse(int u){
	if (u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

int main(){
	int i, v, l, r, root;

	scanf("%d", &n);

	for (i=0; i<n; i++){
		T[i].p = NIL;
	}

	for (i=0; i<n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}

	for (i=0; i<n; i++){
		if (T[i].p == NIL){
			root = i;
		}
	}

	printf("Preorder\n");
	preParse(root);
	printf("\n");

	printf("Inorder\n");
	inParse(root);
	printf("\n");

	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}


Measured memory_bytes: 2140
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

bool p[10100];

void prime() {
  fill(p, p+10100, true);
  p[0] = false;
  p[1] = false;

  FOR(i, 2, 10100) {
    if(p[i]) {
      for(int j = 2; i*j < 10100; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;

  prime();
  while(cin >> n) {
    int cnt = 0;
    REP(i, n) {
      if(p[i+1] && p[n-i]) cnt++;
    }
    cout << cnt << endl;
  }  
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;


int main(){
    LL N;
    cin >> N;
    LL a[N];
    LL sum=0;
    LL div=N*(N+1)/2;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum%div!=0){
        puts("NO");
        return 0;
    }
    LL t=sum/div;
    LL s[N];
    for(int i=0;i<N-1;i++){
        s[i]=a[i+1]-a[i]-t;
    }
    s[N-1]=a[0]-a[N-1]-t;
    LL count=0;
    for(int i=0;i<N;i++){
        if(((s[i]%N)!=0)||s[i]>0){
            puts("NO");
            return 0;
        }
        count+=(-s[i])/N;
    }
    if(count==t) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ans := int64(0)
	for i := 1; i <= n; i++ {
		if i%3 == 0 {
			continue
		}
		if i%5 == 0 {
			continue
		}
		ans += int64(i)
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 1804
d = input().split(" ")
n = int(d[0])
m = int(d[1])
a = input().split(" ")
t = 0
for i in range(n):
	b = int(a[i])
	a[i] = b
	t += b
c = t /(m * 4)
e = 0
for i in range(n):
	if a[i] >= c:
		e += 1
if e >= m:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	char kata;
	int val[26]={0};
	while(scanf("%c", &kata)!=EOF){
		if('A'<=kata&& kata<='Z'){
			val[kata-'A']++;
		}
		else if('a'<=kata && kata<='z'){
			val[kata-'a']++;
		}
	}
	for(int i=0; i<26; i++){
		printf("%c : %d\n", 'a'+i, val[i]);
	}
}


Measured memory_bytes: 2736
#include <stdio.h>

int main(void)
{
	int    no;
	double w, h, bmi;
	int cnt=0;
	while(scanf("%d,%lf,%lf", &no, &w, &h)!=EOF)
	{
		bmi = w/h/h;
		if(bmi>=25.0)
		{
			printf("%d\n", no);
			cnt++;
		}
	}
	if(cnt == 0)
		printf("該当なし\n");
	return 0;
}

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

int main()
{
    int n, s[1001], p[1001], q[1001], r[1001];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < n + 1; i++ )
            cin >> s[i] >> p[i] >> q[i] >> r[i];

        bool j = false;
        for( int i = 0; i < n; i++ )
        {
            if( p[i] <= s[n] && q[i] <= p[n] && r[i] <= q[n] && p[i] * 4 + q[i] * 9 + r[i] * 4 <= r[n] )
            {
                cout << s[i] << endl;
                j = true;
            }
        }
        if( j == false )
            cout << "NA" << endl;
    }

    return 0;
}



Measured memory_bytes: 3108
function Main(input){
    input = input.split('');
    var counts = {};
    input.forEach(function(elm) {
        var key = elm;
        if(counts[key]) {
            counts[key] += 1;
        } else {
            counts[key] = 1;
        }
    });

    var result = 0;
    for(var count in counts) {
        if(counts[count] > 1) {
            result += 1;
        }
        
    }
    if(result === 0) {
        console.log('yes');
    } else {
        console.log('no');
    }

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

Measured memory_bytes: 7372
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 100000

struct V {
	int a, b;
} vv[N];

int compare(const void *a, const void *b) {
	struct V *u = (struct V *) a;
	struct V *v = (struct V *) b;

	return u->a - v->a;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
	int n, m, i;
	long long ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		struct V *u = &vv[i];

		scanf("%d%d", &u->a, &u->b);
	}
	qsort(vv, n, sizeof *vv, compare);
	ans = 0;
	for (i = 0; i < n && m; i++) {
		int x = min(vv[i].b, m);

		m -= x;
		ans += (long long) vv[i].a * x;
	}
	printf("%lld\n", ans);
	return 0;
}


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

#ifdef ARTEM
	#define deb(x) x
#else
	#define deb(x)
	const int LIMIT = 2 * int(1e5) + 123;
#endif

void solve();

int main() {
	solve();
}

/* ================ actual code starts here ================ */

void solve() {
	int t;
	scanf("%d", &t);
	if(t >= 30)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;



int main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++){
		string s = to_string(i), t = to_string(i);
		reverse(t.begin(), t.end());
		if (s == t){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> D(N, vector<int>(2));
  vector<bool> flag(N);
  int count=0;
  for (int i=0;i<N;i++) {
    for (int j=0;j<2;j++) {
      cin >> D.at(i).at(j);
    }
  }
  for (int i=0;i<N;i++) {
    if (D.at(i).at(0)==D.at(i).at(1)) {
      flag.at(i)=true;
    }
    else {
      flag.at(i)=false;
    }
  }
  for(int i=0;i<N;i++) {
    if(flag.at(i)==true) {
      count++;
    }
    else {
      count=0;
    }
    if(count==3) {
      break;
    }
  }
  
  if(count==3) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<queue>
#include<functional>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919810931
typedef pair<int, int> P;
struct edge { int to, cost; };
vector<edge>G[114514];
int d[114514];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>Q;
	fill(d, d + 114014, inf);
	d[s] = 0;
	Q.push(P(0, s));
	while (Q.size()) {
		P p = Q.top();
		Q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				Q.push(P(d[e.to], e.to));
			}
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a - 1].push_back({ b - 1,c });
		G[b - 1].push_back({ a - 1,c });
	}
	int q, k;
	cin >> q >> k;
	dijkstra(k - 1);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << d[x - 1] + d[y - 1] << '\n';
	}
}

Measured memory_bytes: 11632
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			String[] str = new String[n];
			for(int i = 0; i < n; i++){
				str[i] = sc.next();
			}
			
			HashSet<String> hash = new HashSet<String>();
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					
					if(k == 2){
						if(i == j){
							continue;
						}else{
							hash.add(str[i] + str[j]);
						}
					}else{
						
						for(int l = 0; l < n; l++){
						
							if(k == 3){
								if(i == j || j == l || i == l){
									continue;
								}else{
									hash.add(str[i] + str[j] + str[l]);
								}
							}else{
							
								for(int m = 0; m < n; m++){
									if(i == j || j == l || l == m || m == i || i == l || j == m){
										continue;
									}else{
										hash.add(str[i] + str[j] + str[l] + str[m]);
									}
								}
							}
						}
					}
					
				}
			}
			
			System.out.println(hash.size());
			
		}
		
	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#include <numeric>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll dp[100005];
ll a[100005];
ll i,j,k;
ll pow1(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return pow1(a*a,b/2);
    else
        return a*pow1(a*a,b/2);
}
void solve(ll n)
{
    //cout<<n<<"\n";
    if(dp[n]!=-1)
        return;
    if(n==1)
    {
        dp[n]=0;
        return;
    }
    solve(n-1);
    if(n==2)
    {
        dp[n]=abs(a[n-1]-a[n]);
        return;
    }
    ll min1=INT_MAX;
    forsn(i,1,min(k+1,n))
    {
        solve(n-i);
        min1=min(min1,dp[n-i]+abs(a[n-i]-a[n]));
    }
    dp[n]=min1;
    return;
}
int main()
{
    ll n;
    cin>>n>>k;
    forsn(i,1,n+1)
    {
        cin>>a[i];
    }
    fillv(dp,-1);
    solve(n);
    cout<<dp[n];


}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=150000;
int main(){
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	ll n,cap,item,maxis=0,dp[N],i,j,weight;
	cin>>n>>cap;
	for(i=0;i<=cap;++i) dp[i]=0;
	for(i=0;i<n;++i){
		cin>>weight>>item;
		for(j=cap;j>=weight;--j) dp[j]=max(dp[j-weight]+item,dp[j]);
	}
	for(i=0;i<=cap;++i) maxis=max(maxis,dp[i]);
	cout<<maxis;
}


Measured memory_bytes: 1024
def inpl(): return [int(i) for i in input().split()]
from collections import defaultdict

N, K = inpl()
inf = 10**19+1
x = [inf for _ in range(N+1)]
y = [inf for _ in range(N+1)]
H = defaultdict(lambda: 0)

for i in range(N):
    x[i], y[i] = inpl()
    H[(x[i],y[i])] = 1
    

x.sort()
y.sort()

for i in range(N-1):
    for j in range(N):
        H[(x[i+1],y[j])] = H[(x[i],y[j])] + H[(x[i+1],y[j])]

for j in range(N-1):
    for i in range(N):
        H[(x[i],y[j+1])] = H[(x[i],y[j])] + H[(x[i],y[j+1])]

for i in range(N+1):
    H[(x[i],inf)] = H[(inf,y[i])] = 0
H[(inf,inf)] = 0

ans = inf
for i in range(N):
    for j in range(N):
        for t in range(i):
            if i-t+1 < K:
                break
            for s in range(j):
                if j-s+1 < K:
                    break
                if H[(x[i],y[j])] - H[(x[t-1],y[j])] -\
                H[(x[i],y[s-1])] + H[(x[t-1],y[s-1])] != K:
                    continue
                ans = min(ans,(x[i]-x[t])*(y[j]-y[s]))
print(ans)
         

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

using namespace std;
int main()
{
    int n;
    cin >> n;
    int cnt = 1;
    for(int i = 1; i <= n; i ++) {
        int p;
        cin >> p;
        if(p == cnt)
            cnt ++;
    }
    cnt --;
    if(!cnt)
        cout << -1;
    else
        cout << n - cnt;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 ll s;sc(s);
 ll ans=a[s-1];
 pr(ans);
return 0;}

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

int main() {
    int n;
    cin >> n;
    int numbers[4][13];

    int tempn;
    char tempc;

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            numbers[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> tempc;
        cin >> tempn;
        
        switch (tempc)
        {
            case 'S':
                numbers[0][tempn - 1] = 1;
            break;
            case 'H':
                numbers[1][tempn - 1] = 1;
            break;
            case 'C':
                numbers[2][tempn - 1] = 1;
            break;
            case 'D':
                numbers[3][tempn - 1] = 1;
            break;
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
    	    if (numbers[i][j] == 0) {
                switch (i)
                {
                    case 0:
                        cout << "S " << j + 1 << endl;
                    break;
                    case 1:
                        cout << "H " << j + 1 << endl;
                    break;
                    case 2:
                        cout << "C " << j + 1 << endl;
                    break;
                    case 3:
                        cout << "D " << j + 1 << endl;
                    break;
                }
    	    }
        }
    }
}



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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int h,w;
	cin >> h >> w;
	string s[h];
	string t[h];
	FOR(i,h) cin >> s[i];
	FOR(i,h)t[i]=s[i];


	for(int i=0;i<h;i++){
		for(int j=0; j<w;j++){
			if(s[i][j]=='.'){
				int count=0;
				for(int k=-1;k<2;k++)
					for(int l=-1;l<2;l++ )
						if(i+k<h && i+k>=0 && j+l<w && j+l >=0 && s[i+k][j+l]=='#') count++;
				cout << count;
			}
			else cout <<"#";
		}
		cout <<"\n";
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Bara-Bara Manju
public class Main{
	
	int res, num, ID;
	int[][] div;
	int[] c, u;
	
	void f(int k, int rest){
		if(rest==0){
			for(int i=1;i<10;i++)div[ID][i] = u[i];
			ID++;
			return;
		}
		if(k<=0)return;
		for(int use=0;use*k<=rest;use++){
			u[k] = use;
			f(k-1, rest-use*k);
			u[k] = 0;
		}
	}
	
	void dfs(int k, int num, int sum){
		res = Math.max(res, num);
		if(k==ID || num+sum/10 <= res)return;
		int t = 1000;
		for(int i=1;i<10;i++)if(div[k][i]>0)t = Math.min(t, c[i]/div[k][i]);
		for(int use=0;use<=t;use++){
			for(int i=1;i<10;i++)c[i]-=use*div[k][i];
			dfs(k+1, num+use, sum-use*10);
			for(int i=1;i<10;i++)c[i]+=use*div[k][i];
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		div = new int[50][11];
		u = new int[11];
		f(9, 10);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			c = new int[11];
			int sum = 0;
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				c[x]++;
				sum+=x;
			}
			int g = c[5]/2;
			sum-=g*10;
			c[5]%=2;
			for(int i=6;i<10;i++){
				int t = Math.min(c[i], c[10-i]);
				sum-=10*t;
				g+=t;
				c[i]-=t;
				c[10-i]-=t;
			}
			res = 0;
			dfs(0, g, sum);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>

#include <tuple>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main(void)
{
    int N, K;

    cin >> N >> K;

    vector<long long> x_map;
    vector<long long> y_map;
    vector<pair<int, int>> p;

    REP(i, N)
    {
        long long x, y;
        cin >> x >> y;
        x_map.push_back(x);
        y_map.push_back(y);
        p.push_back(make_pair(x, y));
    }

    sort(ALL(x_map));
    sort(ALL(y_map));

    long long area =
            (x_map[N-1] - x_map[0]) *
            (y_map[N-1] - y_map[0]);

    REP(x_start, N)
    {
        REP(y_start, N)
        {
            FOR(x_end, x_start+1, N)
            {
                FOR(y_end, y_start+1, N)
                {
                    long long current_area =
                        (x_map[x_end] - x_map[x_start]) * (y_map[y_end] - y_map[y_start]);

                    if( area <= current_area ) continue;

                    int in = 0;

                    for( auto pp : p )
                    {
                        if( x_map[x_start] <= pp.first &&
                            pp.first <= x_map[x_end] &&
                            y_map[y_start] <= pp.second &&
                            pp.second <= y_map[y_end] )
                        {
                            in++;
                        }
                    }

                    if( K <= in ) area = current_area;
                }
            }
        }
    }

    cout << area << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

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

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<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

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

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int h,w,d;cin>>h>>w>>d&&h|w|d;){
		vvi res(h,vi(w));
		rep(i,h) rep(j,w){
			int ii=((i-j)%(2*d)+2*d)%(2*d);
			int jj=(i+j)%(2*d);
			res[i][j]=ii/d*2+jj/d;
		}
		rep(i,h) rep(j,w) cout<<"RYGB"[res[i][j]]<<(j+1<w?"":"\n");
	}
}


Measured memory_bytes: 1536
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;





signed main()
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int a, b;
    cin >> a >> b;
    int res = a - b;
    res = max(res, a + b);
    res = max(a * b, res);
    cout << res << endl;




    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);
ll fac(ll a);

int main(){
  vint a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  if (x == 1) {
    cout << "Hello World" << endl;
    return 0;
  }

  int A, B;
  cin >> A >> B;
  cout << A + B << endl;
}

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

int main(){
    int N;
    int res = 0;
    bool flag = true;
    cin >> N;

    vector<int> A(N);

    for(int i=0;i<N;i++){
        cin >> A[i];
    }   

    while(flag){
        for(int i=0;i<N;i++){
            if(A[i] % 2 == 1){
                flag = false;
                break;
            }
            else{
                A[i] = A[i]/2;
            }
        }
        if(flag == true){
            res++;
        }
        
    }

    cout << res;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(n) for(int s = 0; s < 1 << n; ++s)
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define parity(a,b) (((a) & 1)^((b) & 1)^1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<class T,class U> auto LB(T v, U in){ return lower_bound(all(v), in); }

template<class T,class U> auto UB(T v, U in){ return upper_bound(all(v), in); }

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

ll Pow(ll n, ll m, int mod = MOD){
	ll res = 1,pow = n % mod;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

vector<ll> Frac(int range, int mod = MOD){
	vector<ll> frac(range + 1);
	frac[0] = 1;
	for(int i = 1; i <= range; ++i) frac[i] = frac[i - 1] * i % mod;
	return frac;
}

vector<ll> frac;

ll Comb(int n, int m, int mod = MOD){
	if(n < m || m < 0) return 0;
	ll rev = Pow(frac[m] * frac[n-m] % mod, mod - 2, mod);
	return rev * frac[n] % mod;
}

int N,M;
ll A = 0;

void solve(){
	
	ll comb[3001],power1[3001],power2[3001];
	
	frac = Frac(N,M);
	rep(i,N/2+1) comb[i] = comb[N-i] = Comb(N,i,M);
	
	power1[N] = 1;
	rep(i,N) power1[N-i-1] = power1[N-i] * 2 % M;
	
	power2[N] = 2;
	rep(i,N) power2[N-i-1] = power2[N-i] * power2[N-i] % M;
	
	vector<ll> s(1,1);
	int b = 1;
	
	rep(i,N+1){
		ll p = power1[i];
		ll t = 1;
		ll ways = 0;
		
		rep(j,i+1){
			ways += s[j] * t % M * power2[i] % M;
			ways %= M;
			t = t * p % M;
		}
		
		A += comb[i] * ways % M * b;
		A = (A + M) % M;
		
		s.pub(1);
		repD(j,i,1) s[j] = (s[j] * (j+1) + s[j-1]) % M;
		
		b *= -1;
	}
	
	cout<<A<<endl;
	
	return;
}

void input(){

	cin>>N>>M;
	
	return;
}

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





Measured memory_bytes: 384
#include <stdio.h>
int main()
{
    int n, d1, d2, i, count = 0, mn = 0;
    scanf("%d", &n);

    for(i = 1; i <= n; i++)
    {
        scanf("%d %d", &d1, &d2);
        if(d1 == d2)
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if(count > mn)
        {
            mn = count;
        }
    }
    if(mn >= 3)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1620
package main

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

var MIN int = 0

var sc = bufio.NewScanner(os.Stdin)

type Node struct {
	key, pri    int
	left, rigth *Node
}

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

func nextString() string {
	sc.Scan()
	return sc.Text()

}

func rigthRotate(t *Node) *Node {
	s := t.left
	t.left = s.rigth
	s.rigth = t
	return s
}

func leftRotate(t *Node) *Node {
	s := t.rigth
	t.rigth = s.left
	s.left = t
	return s
}

func insert(t *Node, key int, pri int) *Node {
	if t == nil {
		return &Node{key: key, pri: pri}
	}
	if key == t.key {
		return t
	}
	if key < t.key {

		t.left = insert(t.left, key, pri)
		if t.pri < t.left.pri {
			t = rigthRotate(t)
		}
	} else {
		t.rigth = insert(t.rigth, key, pri)
		if t.pri < t.rigth.pri {
			t = leftRotate(t)
		}

	}
	return t
}

func find(t *Node, key int) bool {
	if t == nil {
		return false
	}

	if t.key == key {
		return true
	}

	if t.key > key {
		return find(t.left, key)

	} else if t.key < key {
		return find(t.rigth, key)

	}
	panic("error")
}

func erase(t *Node, key int) *Node {
	if t == nil {
		return nil
	}
	if key == t.key {
		if t.left == nil && t.rigth == nil {
			return nil

		} else if t.left == nil {
			t = leftRotate(t)
		} else if t.rigth == nil {
			t = rigthRotate(t)

		} else {
			if t.left.pri > t.rigth.pri {
				t = rigthRotate(t)

			} else {

				t = leftRotate(t)

			}

		}
		return erase(t, key)

	}
	if key < t.key {
		t.left = erase(t.left, key)

	} else {
		t.rigth = erase(t.rigth, key)

	}
	return t
}

func printInOrder(t *Node) {
	if t == nil {
		return
	}

	printInOrder(t.left)
	fmt.Printf(" %d", t.key)
	printInOrder(t.rigth)

}

func printPreOrder(t *Node) {
	if t == nil {
		return
	}

	fmt.Printf(" %d", t.key)
	printPreOrder(t.left)
	printPreOrder(t.rigth)

}

func main() {
	sc.Split(bufio.ScanWords)

	var head *Node

	m := next()
	for i := 0; i < m; i++ {

		switch nextString() {

		case "insert":
			k, p := next(), next()
			head = insert(head, k, p)

		case "print":
			printInOrder(head)
			fmt.Println()
			printPreOrder(head)
			fmt.Println()
		case "find":
			k := next()
			if find(head, k) {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		case "delete":
			k := next()
			head = erase(head, k)

		}

	}
}



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

int main(void)
{
	int *data,i,e,n,datasize,count = 0,j = 0;

	datasize = 10;
	data =(int *)malloc(sizeof(int) * datasize);
	scanf("%d",&n);

	while (j < n) {
		scanf("%d",&data[j]);
		j++;

		if (j >= datasize) {
			datasize +=10;
			data = (int *)realloc(data,sizeof(int) * datasize);
		}
	}

	for (i = 0;i < j;i++) {
		for (e = 2;e * e <= data[i];e++) {
			if (data[i] % e == 0)
				break;
		}
		if (e * e <= data[i] && data[i] % e == 0)
			continue;
		count++;
	}

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


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        n -= 1;
        String ans = "";
        while (n >= 0) {
            ans = (char) ('a' + n % 26) + ans;
            if (n == 0)
                break;
            n /= 26;
            n -= 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 39276
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    bool b[1000001];
    fill(b, b + 1000001, false);
    int ans = 0;
    rep(i, n){
        if(b[a[i]]) continue;
        for (int j = 1; a[i] * j <= 1000000; j++){
            b[a[i]*j] = true;
        }
        if(i < n - 1 && a[i] == a[i+1]) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5304
n=int(input())
p=list(map(int, input().split()))
c=0
for i in range(1, n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        c+=1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        c+=1
print(c)

Measured memory_bytes: 3316
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[100001];
int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>lis[i];
    sort(lis,lis+N);
    int l,r,mid;
    l=0;
    r=1000000002;
    for(int i=0;i<32;i++){
        mid=(l+r)/2;
    //printf("[%d]\n",mid);
        int cou=0;
        for(int j=0;j<N;j++){
            int p=lis[j];
            while(mid<=p&&p!=0){
                cou++;
                p/=2;
            }
        }
        if(cou<=M) r=mid;
        else l=mid;
    }
/*
    for(int i=0;i<N;i++){
        printf("[[%d]]",lis[i]);
        puts("");
    }
*/
    for(int j=0;j<N;j++){
            //printf("[%d][%d]\n",mid+1,lis[j]);
        while((mid+1<=lis[j])&&(lis[j]!=0)){
            M--;
            //puts("hoge");
            lis[j]/=2;
        }
    }
    sort(lis,lis+N);

    for(int i=N-1;0<=i;i--){
        if(M==0)break;
        lis[i]/=2;
        M--;
    }

    long long int ans=0;
    for(int i=0;i<N;i++){

        //printf("[[%d]]",lis[i]);
        //puts("");

        ans+=lis[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A = list(map(int, readline().split()))
    A.sort()
    if A == [5,5,7]:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9072
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

steps = Hash.new(-1)
visited = []
to_visit = 1

while steps[to_visit] == -1
  steps[to_visit] = visited.size
  visited << to_visit
  to_visit = as[to_visit - 1]
end

i = steps[to_visit]
cycles = visited.size - i

if k < i
  puts visited[k]
else
  puts visited[i + ((k - i) % cycles)]
end


Measured memory_bytes: 37916
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;
const string YES = "Yes";
const string NO = "No";

string S;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> S;
    solve();
}

// S は長さ 6 の英小文字からなる文字列である。

// string S
// S がcoffeeに似ている場合 Yes を、そうでない場合 Noを出力せよ。
void solve(){
    cout<<(S[2]==S[3]&&S[4]==S[5]?YES:NO)<<endl;
}


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

import itertools

rects = sorted([(t[0]**2 + t[1] ** 2,t[0],t[1]) for t in itertools.combinations(range(1,151),2)],key = lambda x:(x[0],x[1]))

while True:
    h,w = map(int,input().split(" "))
    if h == 0 and w == 0:
        break
    rect = h**2 + w**2
    for i in range(len(rects)):
        if rects[i][0] == rect and rects[i][1] == h and rects[i][2] == w:
            H,W = rects[i+1][1:]
            print(H,W)

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

int main(){
	int n;
	ll a[100010], l;
	cin >> n >> l;
	for(int i = 0; i < n; i++) cin >> a[i];
	ll maxsum = -1;
	int k1 = -1, k2 = -1;
	for(int i = 1; i < n; i++){
		if(a[i-1] + a[i] > maxsum) {
			maxsum = a[i-1] + a[i];
			k1 = i - 1;
			k2 = i;
		}
	}
	if(maxsum < l){
		cout << "Impossible" << "\n";
		return 0;
	} else cout << "Possible" << "\n";

	// if possible

	for(int i = 1; i <= k1; i++) cout << i << "\n";

	for(int i = n - 1; i > k2; i--) cout << i << "\n";

	cout << k2 << "\n";

	return 0;
}

Measured memory_bytes: 1536