akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(bufferedReader.readLine());
        int[][] board = new int[8][8];
        for(int i = 0; i < 8 ; i++){
            Arrays.fill(board[i], 0);
        }
        for(int i = 0; i < num; i++){
            String[] tmpArray = bufferedReader.readLine().split(" ");
            int r = Integer.parseInt(tmpArray[0]);
            int c = Integer.parseInt(tmpArray[1]);
            board[r][c] = 1;
        }
        int nextC = getAvailableColumn(board, 8);
        if(nextC >= 0){
            for(int i = 0; i < 8; i++){
                boolean result = putQueen(board, 8, i, nextC);
                if(result == true){
                	break;
                }
            }
        }
        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8 ; j++){
                if(board[i][j] == 1){
                    System.out.print("Q");
                }
                else{
                    System.out.print(".");
                }
            }
            System.out.println();
        }
    }
     
    static int getAvailableColumn(int[][] board, int num){
        int j;
        for(j = 0; j < num ; j++){
            int queen = 0;
            for(int i = 0; i < num; i++){
                if(board[i][j] == 1){
                    queen++;
                    break;
                }
            }
            if(queen == 0){
                break;
            }
        }
         
        if(j >= num){
            return -1;
        }
         
        else {
            return j;
        }
    }
     
    static boolean putQueen(int[][] board, int num, int r, int c){
        for(int i = 0; i < num ; i++){
            if(board[i][c] == 1 && i != r){
                return false;
            }
            if(board[r][i] == 1 && i != c){
                return false;
            }
        }
        for(int i = 0; i < num; i++){
            if(  r+i < num && c+i < num && board[r+i][c+i] ==1){
                return false;
            }
            if( r+i < num && c-i >= 0 && board[r+i][c-i] ==1 ){
                return false;
            }
            if(  r-i >= 0 && c+i < num && board[r-i][c+i] ==1){
                return false;
            }
            if( r-i >= 0 && c-i >= 0 && board[r-i][c-i] ==1 ){
                return false;
            }
        }
        board[r][c] = 1;
         
        int nextColumn = getAvailableColumn(board, 8);
        if(nextColumn < 0){
            return true;
        }
        for(int i = 0; i < num ; i++){
            boolean result = putQueen(board, num, i, nextColumn);
            if(result == true){
                return true;
            }
        }
        board[r][c] = 0;
        return false;
    }

}

Measured memory_bytes: 24488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int fee,cash,max,ct=0;
  cin >>fee>>cash>>max;
  while(true){
    if(cash<fee || ct==max){
      cout<<ct<<endl;
      break;
    }
    cash-=fee;
    ct++;
  }


  return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 04.08.2020 17:14:06
*/

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


int main(){
    int x; cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

vector<int> l(26, 0);
int last(int d, int i) { return l.at(i); }

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D + 1, vector<int>(26));
    vector<int> t(D + 1);

    for(int i = 0; i < 26; i++) {
        cin >> c.at(i);
    }
    for(int d = 1; d <= D; d++) {
        for(int i = 0; i < 26; i++) {
            cin >> s.at(d).at(i);
        }
    }
    for(int d = 1; d <= D; d++) {
        cin >> t.at(d);
        t.at(d)--;
    }

    int v = 0;
    for(int d = 1; d <= D; d++) {
        v += s.at(d).at(t.at(d));
        l.at(t.at(d)) = d;
        // cout << "d:" << d << " v:" << v << endl;
        for(int i = 0; i < 26; i++) {
            v -= c.at(i) * (d - last(d, i));
            // cout << "d:" << d << " v:" << v << endl;
        }
        cout << v << endl;
    }

    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    map<string,int> songs;
    vector<int> t(n);
    rep(i,n){
        string s;cin >> s;
        cin >> t[i];
        songs[s] = i;
    }
    int ret = 0;
    string x;cin >> x;
    for(int i = songs[x]+1;i < n;i++)ret += t[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3628
"use strict";

const receive = () => require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/);

const main = input => {
  const str = input[0].split("");
  const ans = (str[0] !== str[1] && str[0] !== str[2] && str[1] !== str[2]) ? "Yes" : "No";
  console.log(ans);
};

main(receive());


Measured memory_bytes: 7372
n = int(raw_input())
   
dis = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
   
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if dis[e] > dis[s] + 1:
        dis[e] = dis[s]+1
        BFS(e)
   
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
   
dis[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if dis[s] == 99999:
    dis[s] = -1
for s in range(n):
  print'{0} {1}'.format(s+1, dis[s])

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

int n, k, w[100005];

int is_ok(int x) {
  int i, group_cnt = 1;
  int sum = 0;
  for (i = 0; i < n; i++) {
    if (w[i] > x) { return 0; }
    if (sum + w[i] <= x) {
      sum += w[i];
    } else {
      sum = w[i];
      group_cnt++;
    }
  }
  return group_cnt <= k ? 1 : 0;
}

int main() {
  int i;
  scanf("%d %d", &n, &k);

  for (i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }

  int ng = -1;       // 解が存在しない値
  int ok = 1e9+9;    // 解が存在する値

  while (abs(ok-ng) > 1) {
    int mid = (ng+ok) / 2;

    // mid が条件を満たすとき
    if (is_ok(mid)) {
      ok = mid;
    } else { // mid が条件を満たさないとき
      ng = mid;
    }
  }
  
  printf("%d\n", ok);

  return 0;
}


Measured memory_bytes: 2228
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int a[n+1];
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  
  int ans=0;
  
  for(int i=1;i<=n;i++){
    if(i%2==1 && a[i]%2==1)ans+=1;
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 2152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<string> S;

  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;

    S.push_back(s);
  }

  int ans = 0;

  int a = 0;
  for (int b = 0; b < N; ++b) {
    bool sym = true;

    for (int y = 0; y < N - 1 && sym; ++y) {
      for (int x = y + 1; x < N && sym; ++x) {
        int y1 = (y + a) % N;
        int x1 = (x + b) % N;
        int y2 = (x + a) % N;
        int x2 = (y + b) % N;

        if (S[y1][x1] != S[y2][x2]) {
          sym = false;
        }
      }
    }

    if (sym) {
      ans += N;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}

typedef pair<int ,int> P;

class car
{
    int id;
    int num;
    public:
        car(int x, int y){ id=x; num=y; }
};

/*
入力はn+2行ある． 1 行目には整数 m が書かれている． 2 行目には整数 n が書かれている． 3 行目から n+2 行目までの各行には、0 もしくは 1 が， 空白で区切られて m 個書かれており，各区画に薄氷があるか否かを表している．北から i 番目，西からj番目の区画を (i,j) と記述することにすると (1 &#8804; i &#8804; n, 1 &#8804; j &#8804; m)，第 i+2 行目の j 番目の値は，区画 (i,j) に薄氷が存在する場合は 1 となり，区画 (i,j) に薄氷が存在しない場合は 0 となる．
 */

int dfs(int s_n, int s_m);


int grid[90][90];
int visit[90][90];
int n,m;
int main()
{
    for(;;)
    {
        //input
        cin >> m;
        cin >> n;
        if (m == 0 && n == 0) { break; }

        rep(i,n)
        {
            rep(j,m)
            {
                cin >> grid[i][j];
            }
        }

        //traverse
        vector<int> ans;
        rep(i,n)
        {
            rep(j,m)
            {
                //ans push
                if( grid[i][j] == 1){
                    ans.push_back(dfs(i,j));
                }
                //visit初期化
                rep(s,90) {
                    rep(t,90){
                        visit[s][t] = 0;
                    }
                }
            }
        }

        //output
        cout <<  *max_element(ans.begin(), ans.end()) << endl;
    }
}

int dn[] = {-1, 0, 1, 0};
int dm[] = {0,  1, 0, -1};

//開始番地を受け取りそこからたどれる最大値を返す関数
int dfs(int s_n, int s_m)
{
    //枠外判定
    if(s_n < 0 || n <= s_n || s_m < 0 || m <= s_m ) { return 0; }
    //障害物判定
    if( grid[s_n][s_m] == 0 ) {return 0;}
    //visit判定
    if( visit[s_n][s_m] == 1) {return 0;}

    /*
    vector<int> a(4);
    rep(i,4)
    {
        a[i] = dfs(s_n + dn[i], s_m + dm[i] );
    }
    return *max_element(a.begin(), a.end()) + 1;
    */

    int res=0;
    rep(i,4)
    {
        visit[s_n][s_m] = 1;
        res = max(dfs(s_n + dn[i], s_m + dm[i]), res);
        visit[s_n][s_m] = 0;
    }
    return res+1;
}

Measured memory_bytes: 1304
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  for (int i = 1; i <= B; i++)
  {
    if ((i * A) % B == C)
    {
      RESULT_OUTPUT("YES");
      return 0;
    }
  }

    RESULT_OUTPUT("NO");

	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<int,int> ma,mb;
  ll ans=0;
  int t;
  for(int i=1;i<=n;i++){
    cin >> t;
    if(i%2==1){
      ma[t]++;
    }else{
      mb[t]++;
    }
  }
  vector<pair<int,int>> mc,md;
  for(auto k:ma){
    mc.push_back({k.second,k.first});
  }
  for(auto k:mb){
    md.push_back({k.second,k.first});
  }
  sort(mc.rbegin(),mc.rend());
  sort(md.rbegin(),md.rend());
  if(mc[0].second==md[0].second){
    int p=mc[1].first+md[0].first;
    int q=md[1].first+mc[0].first;
    if(p>q){
      ans=n-p;
    }else{
      ans=n-q;
    }
  }else{
    ans=n-mc[0].first-md[0].first;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6140
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &y[i])
	}

	o := make([]int, n)
	for i := range o {
		o[i] = i
	}

	var sum float64
	var cnt int
	for {
		var dist float64
		for i := 1; i < n; i++ {
			dx := math.Pow(float64(x[o[i-1]]-x[o[i]]), 2)
			dy := math.Pow(float64(y[o[i-1]]-y[o[i]]), 2)
			dist += math.Sqrt(dx + dy)
		}
		sum += dist
		cnt++

		if !nextPermutation(sort.IntSlice(o)) {
			break
		}
	}
	fmt.Println(sum / float64(cnt))

}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int N, Y;
    cin >> N >> Y;

    REP(i, N + 1) {
        REP(j, N - i + 1) {
            int k = N - i - j;
            if ((i * 10000 + j * 5000 + k * 1000) == Y) {
                cout << i << " " << j << " " << k << "\n";
                return 0;
            }
        }
    }

    cout << "-1 -1 -1"
         << "\n";

    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(a, b, c);

    rep(i, 10001000) {
        if (a % 2 || b % 2 || c % 2) {
            cout << i << endl;
            return 0;
        }
        int aa = b/2 + c/2, bb = a/2 + c/2, cc = a/2 + b/2;
        a = aa; b = bb; c = cc;
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
  std::string s;
  std::cin >> s;
  if(s == "A"){
    s = "T";
  }else if(s == "T"){
    s = "A";
  }else if(s == "C"){
    s = "G";
  }else if(s == "G"){
    s = "C";
  }
  std::cout << s << std::endl;
  return 0;
}

Measured memory_bytes: 256
s = [input() for _ in range(3)]

d = {'a': 0, 'b': 1, 'c': 2}
nxt, cnt = 0, [0, 0, 0]
for _ in range(sum(len(si) for si in s)):
    now = nxt
    nxt = d[s[now][cnt[now]]]
    cnt[now] += 1
    if len(s[nxt]) <= cnt[nxt]:
        print(['A', 'B', 'C'][nxt])
        break


Measured memory_bytes: 61608
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

string s;

int main(){
//	EnumeratePrime();
	while(1){
		getline(cin,s);
		if(s==".") break;
		int n=s.size();
		stack<char> st;
		bool B=1;
		for(int i=0;i<n;i++){
			if(s[i]=='('||s[i]=='[') st.push(s[i]);
			if(s[i]==')'){
				if(!st.empty()&&st.top()=='('){
					st.pop();
				}
				else{
					B=0;
					break;
				}
			}if(s[i]==']'){
				if(!st.empty()&&st.top()=='['){
					st.pop();
				}
				else{
					B=0;
					break;
				}
			}
		}
		if(!st.empty()) B=0;
		if(B) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}


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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    string s,p;
    cin>>s>>p;
    int maxo = 100001;
    int len = s.size()-p.size()+1,cnt;
    for(int i=0;i<len;i++){
        cnt=0;
        for(int j=0;j<p.size();j++){
            if(s[i+j] == p[j]){
                continue;
            }
            cnt++;
        }
        maxo = min(maxo,cnt);
        if(maxo == 0){
            break;
        }
    }
    cout<<maxo;
    return 0;
}


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

int main() {
  int X;
  cin >> X ;
  int happy = 0;
  int count =0;
  while (X > count*500 ) { 
    count++;
    if (X<count*500){
      count--;
      break;
    }
  }
  int count2 = 0;
  while (X > count*500 + count2*5){
    count2++;
    if (count*500+count2*5 > X){
      count2--;
      break;
    }
  }
  cout << count*1000+count2*5 << endl;
}

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

int main()
{
    int N, x;
    char cmd[15];
    list<int> L;
    cin >> N;
    while(N--)
    {
        cin >> cmd;
        if(cmd[0]=='i')
        {
            cin >> x;
            L.push_front(x);
        }
        else if(cmd[6]=='F')
        {
            L.pop_front();
        }
        else if(cmd[6]=='L')
        {
            L.pop_back();
        }
        else
        {
            cin >> x;
            for(list<int>::iterator it = L.begin(); it!=L.end(); it++)
            {
                if(*it==x)
                {
                    L.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for(list<int>::iterator it = L.begin(); it!=L.end(); it++)
    {
        if(i++) cout << " ";
        cout << *it;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 34332
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	sort(a.rbegin(), a.rend());
	Int ans = 0;
	for (int i = K; i < N; ++i) { ans += a[i]; }
	cout << ans << endl;

	return 0;
}


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

struct StRequir
{
  StRequir() :
    m_nBgn(0), m_nEnd(0), m_nDiff(0), m_nPoint(0) { }

  int m_nBgn;
  int m_nEnd;
  int m_nDiff;
  int m_nPoint;
};

void fnInput(int& rnSeqSiz, int& rnMaxNum, vector<StRequir>& rvoRequir)
{
  int nReqSiz;
  cin >> rnSeqSiz >> rnMaxNum >> nReqSiz;
  rvoRequir.resize(nReqSiz);

  for (StRequir& roRequir : rvoRequir)
    cin >> roRequir.m_nBgn >> roRequir.m_nEnd >> roRequir.m_nDiff >> roRequir.m_nPoint;
}
  
void fnRecSeqMake(int nPos, int nMaxNum, vector<int>& rvnSeq,
                  const vector<StRequir> cnrvoRequir, int& rnMaxPoint)
{
  if (nPos == rvnSeq.size())
  {
    int nPoint = 0;

    for (StRequir oRequir : cnrvoRequir)
      if (rvnSeq[ oRequir.m_nEnd - 1 ] - rvnSeq[ oRequir.m_nBgn - 1 ] == oRequir.m_nDiff)
        nPoint += oRequir.m_nPoint;

    rnMaxPoint = max(rnMaxPoint, nPoint);
    return;
  }

  if (nPos > 0)
    rvnSeq[nPos] = rvnSeq[ nPos - 1 ];

  while (rvnSeq[nPos] <= nMaxNum)
  {
    fnRecSeqMake(nPos + 1, nMaxNum, rvnSeq, cnrvoRequir, rnMaxPoint);
    rvnSeq[nPos]++;
  }
}

int fnMaxPointGet(int nSeqSiz, int nMaxNum, const vector<StRequir>& cnrvoRequir)
{
  int nMaxPoint = 0;
  vector<int> vnSeq(nSeqSiz, 1);

  fnRecSeqMake(0, nMaxNum, vnSeq, cnrvoRequir, nMaxPoint);
  return nMaxPoint;
}
  
int main()
{
  int nSeqSiz, nMaxNum;
  vector<StRequir> voRequir;

  fnInput(nSeqSiz, nMaxNum, voRequir);
  cout << fnMaxPointGet(nSeqSiz, nMaxNum, voRequir) << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;
int main()
{
    int num ;
    cin >> num ;
    int arr[num+1];
    for (int i = 1 ; i <= num ; i++)
        cin >> arr[i];
    int c = 0 ;
    for (int i = 1 ; i <= num ; i++)
    {
        if (i%2==1 && arr[i]%2==1)
            c++ ;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3592
n, q = map(int, input().split())
s = input()
ans = [0]
for i in range(1, n):
  if s[i - 1:i + 1] == "AC":
    ans.append(ans[-1] + 1)
  else:
    ans.append(ans[-1])
for _ in range(q):
  l, r = map(int, input().split())
  print(ans[r - 1] - ans[l - 1])

Measured memory_bytes: 79748
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=a;i<n;i++)
#define INF (int)1000000007

//etprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i;
    int N,H;
    cin>>N>>H;
    vin a(N);
    vin b(N);
    rep(i,0,N){
        cin>>a.at(i);
        cin>>b.at(i);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int count=0;
    rep(i,0,N){
        if(b.at(N-1-i)>=a.at(N-1)){
            H-=b.at(N-1-i);
            count++;
            if(H<=0){
                break;
            }
        }
    }


    /*while(H>0){
        H-=a.at(N-1);
        count++;
    }*/
    if(H>0){
        count+=H/a.at(N-1);
        if(H%a.at(N-1)!=0){
            count++;
        }
    }


    cout<<count<<endl;
return 0;
}

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



int main (){
	int n;
	lint k;
	cin >> n >> k;
	vector<int> a(n);
	rep (i,n) cin >> a[i];

	vector<int> s;//訪れた頂点のメモ
	vector<int> ord(n+1,-1); //値が-1,個数がnこ 訪れた順番をメモ vが１始まりだから、n＋1この大きさ
	int c = 1;//周期
	int l = 0;//例外の長さ
	{
		int v = 1;//{}のスコープ範囲外は使えない.頂点
		while (ord[v] == -1){//訪れていないなら-1
			ord[v] = s.size();
			s.push_back(v);//訪れた頂点を入れる
			v = a[v - 1];//テレポートしていく
		}//ex)16253まで入る16253253...のとき
		c = s.size() - ord[v];
		l = ord[v];
	}
	if (k < l) cout << s[k] << endl;
	else{
		k -= l;
		cout << s[k % c + l] << endl;
	}
	return 0;
}

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

int main(void)
{
	char S[10 + 1];
	char T[11 + 1];

	cin >> S;
	cin >> T;

	int len = strlen(T) - 1;
	for (int i = 0; i < len; i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int a[100005];
ll pre[100005];
map<ll,ll>mpp;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0){
            pre[i]=a[i]%m;
            mpp[pre[i]]++;
        }
        else
        {
            pre[i]=(pre[i-1]+a[i])%m;
            mpp[pre[i]]++;
        }
    }
    map<ll,ll>::iterator it;
    it=mpp.begin();
    ll ans=0;
    for(;it!=mpp.end();it++)
    {
        int fi = it->first;
        int se = it->second;
        if(fi==0)
        {
            se++;
            ans = ans+1LL*(se)*(se-1)/2;
        }
        else
        {
            ans = ans+1LL*(se)*(se-1)/2;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5376
K = int(input())
# 1桁
K1 = [x for x in range(1, 10)]
#2桁

def add_2(Kn):
    K_ = []
    for i in Kn:
        
        K_.append(10*i + (i % 10 - 1))
        K_.append(10*i + i % 10)
        if i % 10 < 9:
            K_.append(10*i + (i % 10+ 1))

    return K_

def add_(Kn):
    K_ = []
    for i in Kn:
        if i%10 > 0:
            K_.append(10*i + (i % 10 - 1))
        K_.append(10*i + i % 10)
        if i % 10 < 9:
            K_.append(10*i + (i % 10+ 1))

    return K_

out = [K1, add_2(K1)]
for k in range(1, 9):
    out.append(add_(out[k]))

out = sum(out, [])
print(out[K-1])

Measured memory_bytes: 53616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n,m; cin>>n>>m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin>>a.at(i)>>b.at(i);
        a.at(i)--; b.at(i)--;
    }
    vector<int> cnt(n,1); vector<bool> red(n,false);
    red.front()=true;
    rep(i,m){
        cnt.at(a.at(i))--; cnt.at(b.at(i))++;
        if(red.at(a.at(i))) red.at(b.at(i))=true;
        if(cnt.at(a.at(i))==0) red.at(a.at(i))=false;
    }
    int ans=0;
    rep(i,n){
        if(red.at(i)) ans++;
    }
    cout<<ans<<endl;
}

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

using int64 = long long;

int main() {
  int64 n;
  cin >> n;
  int64 sum = 0;
  for (int64 i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    sum += i;
  }
  cout << sum << "\n";
}


Measured memory_bytes: 3196
import numpy as np
A = np.array([list(map(int, input().split())) for i in range(3)])
N = int(input())
for i in range(N):
    bingo_num = int(input())
    A = np.where(A == bingo_num, 0, A)
if (0 in np.sum(A, axis=1)
    or 0 in np.sum(A, axis=0)
    or np.sum(np.diag(A)) == 0
        or A[0, 2]+A[1, 1]+A[2, 0] == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12460
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n,temp;
  cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>temp;
        arr[i][j]=temp;
          
      }
  }
  int dp[n][3];
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(int i=1;i<n;i++){
      for(int j=0;j<3;j++){
          dp[i][j]=max(dp[i-1][(j+4)%3]+arr[i][j],dp[i-1][(j+5)%3]+arr[i][j]);
      }
  }
  //dp[1]=max(arr[1]-arr[0]);
  //for(int i)
  cout<<max(max(dp[n-1][0],dp[n-1][1]), dp[n-1][2])<<endl;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){

	int a, b, ans;
	char op;

	while(1){

		cin >> a >> op >> b;

		if(op=='?') break;

		switch(op){

			case '+':
			ans = a + b;
			break;

			case '-':
			ans = a - b;
			break;

			case '*':
			ans = a * b;
			break;

			default:
			ans = a / b;
			break;
		}

		cout << ans << endl;

	}

	return 0;
	
}



Measured memory_bytes: 3088
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		String[] suit = {"S ","H ","C ","D "};
		TreeSet<String> in = new TreeSet<>();
		s.nextLine();
		while(s.hasNextLine()) {
			in.add(s.nextLine());
		}
		String str;
		for(String s:suit) {
			for(int i=1;i<=13;++i) {
				str = s+i;
				if(!in.contains(str)) {
					System.out.println(str);
				}
			}
		}
	}
}

Measured memory_bytes: 26216
//
//  A.cpp
//  
//
//  Created by Eiji Kaneko on 2017/06/15.
//
//

#include <iostream>

using namespace std;

int main(void){
    int N, x, y;
    cin >> N;
    
    x = N*800;
    y = (N/15)*200;
    cout << x-y << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

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

		vector<pair<int, int>> v;

		for (int i = 1; i < N-1; i++) {
				if (A[i] >= 0) {
						v.push_back(make_pair(A[0], A[i]));
						A[0] -= A[i];
				} else {
						v.push_back(make_pair(A[N-1], A[i]));
						A[N-1] -= A[i];
				}
		}

		v.push_back(make_pair(A[N-1], A[0]));
		A[N-1] -= A[0];

		cout << A[N-1] << endl;
		for (int i = 0; i < N-1; i++) cout << v[i].first << " " << v[i].second << endl;
		return 0;
}


Measured memory_bytes: 3188
n,k = map(int, input().split())
import sys
sys.setrecursionlimit(10000)
memo = [1,1]
def fact(a):
    if len(memo) > a:
        return memo[a]
    b = a*fact(a-1)
    memo.append(b)
    return b
ans = fact(n+k-1)//(fact(n)*fact(k-1))%1000000007
print(ans)



Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int a[MAXN];
int main() {
	int n, m;
	cin >> n >> m;
	long long sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum > n) {
		cout << -1 << endl;
	}
	else {
		cout << n - sum << endl;
	}
	return 0;
} 

Measured memory_bytes: 3680
using System;

public class Program
{
  static private readonly int MAX = 100;
  static private readonly int INFINITY = (1<<21);
  static private readonly int WHITE = 0;
  static private readonly int GRAY = 1;
  static private readonly int BLACK = 2;

  static private int n = -1;
  static private int[,] M = new int[MAX, MAX];

  private static void dijkstra()
  {
    int minv;
    int[] d = new int[n];
    int[] color = new int[n];

//    Console.Write("n={0}, d.length={1}, color.length={2}\n", n, d.Length, color.Length);

    for(int i=0; i<n; i++)
    {
      d[i] = INFINITY;
      color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while(true)
    {
      minv = INFINITY;
      int u = -1;
      for(int i=0; i<n; i++)
      {
        if(minv > d[i] && color[i] != BLACK)
	{
	  u = i;
	  minv = d[i];
	}
      }

      if(u == -1) { break; }
      color[u] = BLACK;
      for(int v=0; v<n; v++)
      {
	if(color[v] != BLACK && M[u,v] != INFINITY)
	{
	  if(d[v] > d[u] + M[u,v])
	  {
	    d[v] = d[u] + M[u,v];
	    color[v] = GRAY;
	  }
	}
      }
    }

    for(int i=0; i<n; i++)
    {
      Console.Write("{0} {1}\n", i, (d[i] == INFINITY ? -1 : d[i]));
    }
  }

  public static void Main()
  {
    n = int.Parse(Console.ReadLine());
    M = new int[n, n];

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

    int k, c, u, v;
    for(int i=0; i<n; i++)
    {
      int s=0;
      string [] str = Console.ReadLine().Split(' ');
      u = int.Parse(str[s++]);
      k = int.Parse(str[s++]);
//      Console.Write("{0}, {1}\n", u, k);
      for(int j=0; j<k; j++)
      {
	v = int.Parse(str[s++]);
	c = int.Parse(str[s++]);
	M[u,v] = c;
//	Console.Write("{0}, {1}\n", v, c);
      }
    }

    dijkstra();
  }
}

Measured memory_bytes: 432236
#include<iostream>
#include<vector>
using namespace std;
int solve2()
{
    int n;
    cin >> n;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (n == i*j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
}

int main(int argc, const char * argv[]) {
    return solve2();
}


Measured memory_bytes: 636
#include <iostream>

using namespace std;

const int MAX = 1000001;
long long fact[MAX], fact_inv[MAX];

const long long MOD = 1000000007l;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

long long comb(long long n, long long r) {
    return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0 || x > y * 2 || y > x * 2) {
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    int d = min(x, y) - n;
    d = min(d, n - d);
    if (d == 0) {
        cout << 1 << endl;
        return 0;
    }

    fact[0] = 1;
    for (int i = 0; i < n; ++i) {
        fact[i + 1] = fact[i] * (i + 1) % MOD;
    }
    fact_inv[n] = power(fact[n], MOD - 2);
    for (int i = n - 1; i >= 0; --i) {
        fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
    }
    cout << comb(n, d) << endl;
}


Measured memory_bytes: 14592
#include <iostream>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    if(N % 2 == 0 && S.substr(0, N/2) == S.substr(N/2, N/2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
k=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
count=0

while sum(a)!=0:
    b=[]

    m=-10000
    for i in a:
        if i!=m:
            b.append(i)
            m=i




    for i in range(1,len(b)-1):    
        if b[i]>b[i-1] and b[i]>b[i+1] and b[i]!=0:
            count+=b[i]-max(b[i-1],b[i+1])
            b[i]=max(b[i-1],b[i+1])
            
    a=b.copy()
        
print(count)    


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int cnt[15];

int main(){
     cin>>a>>b>>c;
     cnt[a]++;
     cnt[b]++;
     cnt[c]++;
     if(cnt[5]==2&&cnt[7]==1)cout<<"YES";
     else cout<<"NO";
     return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    int a[n][m], b[m][l];

    rep(i, n)
    {
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    rep(i, m)
    {
        rep(j, l)
        {
            cin >> b[i][j];
        }
    }

    rep(i, n)
    {
        rep(j, l)
        {
            ll sum = 0;
            rep(k, m)
            {
                sum += a[i][k] * b[k][j];
            }
            cout << sum;
            if (j != l - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N, S = 0;
    cin >> N;
    vector <int> A(N, 0), X(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];

    for (int i = 0; i < N; i++) {
        if (i%2) X[0] -= A[i];
        else X[0] += A[i];
    }

    for (int i = 1; i < N; i++) {
        X[i] = 2*A[i-1] - X[i-1];
    }

    for (int i = 0; i < N; i++) {
        cout << X[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    int c;
    cin >> a >> b>> c;
    int i;
    int count;
    count = 0;
    for(i=a ; i <= b;i++){
        if( c % i == 0){
            count +=1;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3116
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: MarathonForces #1

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int a,b,c;
	cin >> a >> b >> c;
	cout << min({a+b, b+c, a+c});	
	return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys

#count '<'
def count_S(S, N):
    ret=S.find('>')
    #print("<",S,N,ret)
    if ret==-1:
        ret=N
    return ret

#count '>'
def count_L(S, N):
    ret=S.find('<')
    if ret==-1:
        ret=N
    #print(">",S,N,ret)
    return ret

def count_S_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='<':
            ret+=1
        else:
            break
    return ret

def count_L_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    answer=0
    
    numS=len(S)
    cnt_l=count_L(S,len(S))
    answer+=(cnt_l+1)*cnt_l//2
    i=cnt_l
    while i<len(S):
        cnt_s=count_S_slow(S,i,numS)
        cnt_l=count_L_slow(S,i+cnt_s,numS)
        answer+=(cnt_s+1)*cnt_s//2
        answer+=(cnt_l+1)*cnt_l//2
        if cnt_l>cnt_s:
           answer-=cnt_s
        else:
           answer-=cnt_l
        #answer+=(cnt_l+1)*cnt_l//2
        #print("cnt_s,cnt_l",cnt_s, cnt_l,answer)
        i+=cnt_s+cnt_l

    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <list>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

struct Point {
	int x;
	int y;

};

int main() {

	string str;
	int n;

	cin >> str >> n;

	const int size = (int)str.size();

	priority_queue<string> que;
	set<char> top;

	for (const auto& c : str)
	{
		top.insert(c);
	}

	set<string> dictionary;

	for (const auto& t : top)
	{
		dictionary.insert({ t });
		for (int i = 0; i < size; i++)
		{
			if (str[i] == t)
			{
				for (int j = 1; j <= n; j++)
				{
					if (i + j - 1 < size)
					{
						dictionary.insert(str.substr(i, j));
					}
				}
			}

		}
		if (dictionary.size() > n)
			break;

	}

	string ans;

	{
		int count = 0;
		for (const auto& s : dictionary)
		{
			if (count == n - 1)
			{
				ans = s;
				break;
			}

			//cerr << s << endl;

			count++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;



public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			
			dp[i]=(long)(Math.min(dp[i-1]+Math.abs(ar[i-1]-ar[i-2]),
					dp[i-2]+Math.abs(ar[i-1]-ar[i-3])));
		}
		return dp[n];
		
	}


}

Measured memory_bytes: 63532
#include <stdio.h>

int main()
{
    long long int h, n, sum = 0;
    scanf("%lld %lld", &h, &n);
    for (int i = 0; i < n; i++)
    {
        long long int a;
        scanf("%lld", &a);
        sum += a;
    }
    if (sum >= h)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1644
H,W,K=map(int,input().split())
c = []
ans = 0

for i in range(H):
    s =list(input())
    c.append(s)

for i in range(2**H):
    for j in range(2**W):
        tmp = 0
        for h in range(H):
            for w in range(W):
                if 2**h & i >0 and 2**w & j >0:
                    if c[h][w] == "#":
                        tmp += 1

        if tmp == K:
            ans += 1

print(ans)

Measured memory_bytes: 9168
#define MOD 1000000007

#include <iostream>

typedef long long int ll;

using namespace std;

ll n,m;
int main(void)
{
	cin >> m >> n;
	ll res = 1;
	ll cur = m;
	ll pw = 1;
	while(n != 0)
	{
		if(n % (pw * 2) != 0)
		{
			res = (res * cur) % MOD;
			n = n - pw;
		}
		pw = pw * 2;
		cur = (cur * cur) % MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 3080
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    double L;
    cin >> L;
    double a = L/3.0;
    cout << fixed << setprecision(10);
    cout << a*a*a;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;


void solve()
{

    lli n, k;
    cin>>n>>k;
    lli X = n - 2;
    if(k > (X * (X + 1)) / 2) {
        cout<<-1;
        return ;
    }
    vector<pair<lli, lli>>  ans;
    for(int i = 1; i < n; i ++) {
        ans.push_back({n, i});
    }
    lli cnt = (X * (X + 1)) / 2;
    for(int i = 1; i < n; i ++) {
        for(int j = i + 1; j < n; j ++) {
            if(cnt > k) {
                cnt --;
                ans.push_back({i, j});
            }
            else {
                break ;
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto it : ans)
        cout<<it.ff<<' '<<it.ss<<'\n';
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def main(io):
	n,a,b= map(int, io.next().split())
	max_num= min(a,b)
	min_num= max(a+b-n, 0)
	ret= str(max_num)+' '+str(min_num)
	return ret


#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)


Measured memory_bytes: 2568
#include <stdio.h>

int main(int argc, const char * argv[])
{
    
    int i,j;
    
    for(i=1; i<=9; i++){
        for(j=1; j<=9; j++){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }

    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 2000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int pri[N],p[N],tot;
inline void sieve(int n)
{	for(rint i=2;i<=n;i++)
	{	if(!pri[i]) p[++tot]=i;
		for(rint j=1;j<=tot&&i*p[j]<=n;j++)
		{	pri[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}
ll a[666][666]; int mov[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
inline ll lcm(ll x,ll y)
{ll g=__gcd(x,y),g1=__gcd(g,x);x/=g1;g/=g1;return x*(y/g);}
int main()
{	int n,cur=1; cin>>n; sieve(1e6);
	if(n==2) return !printf("4 7\n23 10");
	for(rint i=0;i<=n+1;i++)
	for(rint j=0;j<=n+1;j++) a[i][j]=1;
	for(rint i=3;i<=n+n;i+=2,cur++)
	for(rint j=1;j<=n;j++) if(1<=i-j&&i-j<=n) a[j][i-j]*=p[cur];
	for(rint i=1;i<=n-1;i+=2,cur++)
	for(rint j=1;j<=n;j++) if(1<=i+j&&i+j<=n) a[j][i+j]*=p[cur];
	for(rint i=-1;i>=1-n;i-=2,cur++)
	for(rint j=1;j<=n;j++) if(1<=i+j&&i+j<=n) a[j][i+j]*=p[cur];
	for(rint i=1;i<=n;i++)
	for(rint j=1;j<=n;j++)
	if((i+j)%2==0)
	{	for(rint k=0;k<4;k++) a[i][j]=lcm(a[i][j],a[i+mov[k][0]][j+mov[k][1]]);
		a[i][j]++;
	}
	for(rint i=1;i<=n;i++,cout<<"\n")
	for(rint j=1;j<=n;j++) cout<<a[i][j]<<" ";
	return 0;
}


Measured memory_bytes: 13312
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <list>
#include <deque>
#include <numeric>
#include <set>
#include <climits>
#include <utility>
#include <map>
#include <float.h>
typedef long long ll;
typedef unsigned long long ull;
inline int max( int x, int y ){ return x > y ? x : y ; }
inline int min( int x, int y ){ return x < y ? x : y ; }
inline ll max( ll x, ll y ){ return x > y ? x : y ; }
inline ll min( ll x, ll y ){ return x < y ? x : y ; }
inline ull max( ull x, ull y ){ return x > y ? x : y ; }
inline ull min( ull x, ull y ){ return x < y ? x : y ; }
int GCD( int a, int b ) { return b ? GCD( b , a%b ) : a; }
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PIV 3.14159265358979323846
#define MAXN 100
typedef pair<int, int> P;
const int MAX_V = 400+1;

int main(){
	
	string s;
	
	cin >> s;
	for( int i=0; i<s.length(); ++i ){
		if( i%2 == 0 ){
			if( s[i] == 'L' ){
				printf("No");
				return 0;
			}
		}else{
			if( s[i] == 'R' ){
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}









Measured memory_bytes: 256