akhauriyash/Code-Regression huggingface dataset:
/*
********************
Author : Sahil Kundu
********************
*/
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb(i) push_back(i)
#define pp() pop_back()
#define f first
#define s second
#define mk(l,r) make_pair(l,r)
#define all(vc) vc.begin(),vc.end()
#define bg(vc) vc.begin()
#define ed(vc) vc.end()
#define ms(i,j) memset(i,j,sizeof i)
#define w(t) while(t--)
const ll MAX=1e5+5;
const ll INF=2e18;
bool isprime[MAX];
vector<ll> vc;
void init()
{
    ms(isprime,true);
    isprime[1]=false;
    for(ll i=2;i*i<=MAX;i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i;j<=MAX;j+=i)
                isprime[j]=false;
        }
    }
    for(ll i=2;i<=MAX;i++)
        if(isprime[i])
        vc.pb(i);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    //init();
    w(t)
    {
        ll n;cin>>n;
        n=n%10;
        if(n==3)
            cout<<"bon\n";
        else if(n==0 or n==1 or n==6 or n==8)
            cout<<"pon\n";
        else cout<<"hon\n";
    }
}
/*
ll msb(ll x)
{
	ll k=(ll)log2(x);
	return (ll)(pow(2,k));
}
#define gc getchar_unlocked
void scanint(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}*/

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R')
                a++;
            else
                b++;
        }

        if (a > b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if((a==1 && b==2) || (a==2 && b==1))
  {
    printf("3\n");
  }
  if((a==1 && b==3) || (a==3 && b==1))
  {
    printf("2\n");
  }
  if((a==3 && b==2) || (a==2 && b==3))
  {
    printf("1\n");
  }
  return 0;
}
  

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

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 n; cin >> n;
    int a = n%10;
    if(a==0 || a==1 || a==6 || a == 8 )
    {
        cout << "pon" << endl;
    }
    else if( a==3)
    {
        cout << "bon" << endl;
    }
    else{
        cout << "hon" << endl;
    }

    return 0;
}



Measured memory_bytes: 3640
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


const int max_comb=510000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    pre_comb();
    ll ans = 0;
    int i;
    for (i = 0; i <= n; i++) {
        ll ans0 = comb(n, i) * perm(m,i) %MOD * perm(m-i,n-i) %MOD;
        ans0 = ans0 * perm(m - i, n - i) % MOD;
        if (i % 2 == 0) ans = (ans + ans0) % MOD;
        else ans = (ans - ans0 + MOD) % MOD;
    }
    printf("%lld\n", ans);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

using namespace std;
const int N = 1000010;
int _w;

int C( int n, int m ) {
	return (n|m) == n;
}

int n, a[N], cnt[3];
char s[N];

int main() {
	cin >> n;
	cin >> (s+1);
	for( int i = 1; i <= n; ++i ) {
		a[i] = s[i] - '0' - 1;
		++cnt[a[i]];
	}
	if( cnt[1] == 0 ) {
		for( int i = 1; i <= n; ++i )
			if( a[i] == 2 )
				a[i] = 1;
	} else {
		for( int i = 1; i <= n; ++i )
			if( a[i] == 2 )
				a[i] = 0;
	}
	int ans = 0;
	for( int i = 1; i <= n; ++i )
		ans = (ans + a[i] * C(n-1, i-1)) & 1;
	if( cnt[1] == 0 ) ans *= 2;
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 8536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<PII> plus, minus;
    REP(i, n) {
        string s;
        cin >> s;

        ll now = 0, mi = 0;
        REP(j, s.size()) {
            if(s[j] == '(') now++;
            else now--;
            chmin(mi, now);
        }

        if(now > 0) plus.push_back({mi, now});
        else minus.push_back({mi, now});
    }

    auto solve = [](vector<PII> vp, ll sum) {
        ll sz = vp.size();
        REP(i, sz) {
            if(sum + vp[i].first < 0) {
                return -INF;
            }
            sum += vp[i].second;
        }
        return sum;
    };

    sort(ALL(plus), greater<>());
    ll sum = solve(plus, 0);
    if(sum == -INF) {
        cout << "No" << endl;
        return 0;
    }

    sort(ALL(minus), [](PII l, PII r){
        return l.first - l.second < r.first - r.second;
    });
    sum = solve(minus, sum);
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        int[] diff = new int[3];
        diff[0] = Math.abs(a1 - a2);
        diff[1] = Math.abs(a2 - a3);
        diff[2] = Math.abs(a3 - a1);

        Arrays.sort(diff);
        System.out.println(diff[0] + diff[1]);
    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }
  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());

      String line = br.readLine();
      String next;
      Set<String> set = new HashSet<>();
      set.add(line);
      String ans = "Yes";
      for(int i=1; i<n; i++) {
        next = br.readLine();

        if(!set.add(next)){
          ans = "No";
          break;
        }

        if(next.startsWith(line.substring(line.length()-1))) {
          line = next;
          continue;
        }
        else {
          ans = "No";
          break;
        }
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 24660
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int x,y;
  cin>>x>>y;
  int ans=0;
  if(x<=3) ans+=(4-x)*100000;
  if(y<=3) ans+=(4-y)*100000;
  if(x==1&&y==1) ans+=400000;
  cout<<ans;
	return 0;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string>
#include <climits>
using namespace std;
typedef pair<int,int> p;
int inf=INT_MAX;
int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0) break;

        int d[50][50];

        for(int i=0;i<50;i++){
            for(int j=0;j<50;j++)d[i][j]=inf;
        }
        for(int i=0;i<50;i++)d[i][i]=0;
        for(int i=0;i<n;i++){
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            d[a][b]=c;
            d[b][a]=c;
        }
        for(int k=0;k<50;k++){
            for(int i=0;i<50;i++){
                for(int j=0;j<50;j++){
                    if(d[i][k]!=inf and d[k][j]!=inf) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        int ans=inf;
        int from;
        for(int i=0;i<50;i++){
            int tmp=0;
            int flag=0;
            for(int j=0;j<50;j++){
                if(d[i][j]!=inf and i!=j){tmp+=d[i][j];flag=1;}
            }
            if(flag==1){
                if (ans>tmp){
                ans=min(ans,tmp);
                from=i;
                }
            }
        }
        printf("%d %d\n",from,ans);

    }


};

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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> data(2 + 1, vector<int>(N+1,0));
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> data[i][j];
		}
	}
	vector<vector<int>> dp(2 + 1, vector<int>(N + 1, 0));
	dp[0][0] = data[0][0];
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + data[i + 1][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + data[i][j + 1]);
		}
	}
	cout << dp[1][N - 1] << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a, cnt_1 = 0, cnt_2 = 0, cnt_4 = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a % 2 == 1) cnt_1++;
        else if (a % 4 == 0) cnt_4++;
        else cnt_2++;
    }

    if (cnt_2 == 0 && cnt_1 <= cnt_4 + 1) cout << "Yes" << endl;
    else if (cnt_2 > 0 && cnt_1 <= cnt_4) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
const main = (input) => {
  const args: any = input.split(' ');
  const a: number = args[0];
  const b: number = args[1];

  if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<stdio.h>

int main(void)
{
	int n, m, in, a = 0;
	int i, j;
	int arr1[101][101] = {{0}};
	int arr2[101] = {0};
	int arr3[101] = {0};
	
	
	scanf("%d %d", &n, &m);
	
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < m; j++)
		{
			scanf("%d", &in);
			arr1[i][j] = in;
		}
	}
	
	for(i = 0; i < m; i++)
	{
		scanf("%d", &in);
		arr2[i]= in;
	}
	
	for(i = 0; i < n; i++)
	{
		a = 0;
		for(j = 0; j < m; j++)
		{
			a += arr1[i][j] * arr2[j];
		}
	arr3[i] = a;
	}
	

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




Measured memory_bytes: 2112
line1 = input().split()
n = int(line1[0])
m = int(line1[1])
line2 = input().split()
line2 = [int(i) for i in line2]
total = sum(line2)
line2 = sorted(line2, reverse=True)
if line2[m-1] >= total / (4 * m):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
	int A;
	int B, C, D;
	int P;
	int MIN;
	
	
	scanf("%d %d %d %d %d", &A, &B, &C, &D, &P);
	
	A = P * A;
	
	if (C < P){
		B += (P - C) * D;
	}
	
	MIN = min(A, B);
	printf("%d\n", MIN);
	
	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  const int n = 3;
  vector<int> cnt(4);

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    cnt[a]++;
    cnt[b]++;
  }

  bool ans = true;
  // 入力される頂点の数がそれぞれ3以上だったらNG
  // 1 -- 2 -- 3 -- 4 みたいな形になれば一本道で行けるので、この場合カウントは 1, 2, 2, 1になる
  rep(i, 4) { 
    if(cnt[i] >= 3) ans = false;
  }
  
  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;

  

}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (auto& e : x) cin >> e;

  int r = 1e9;
  for (int i = 1; i <= 100; i++) {
    int s = 0;
    for (auto e : x) s += pow(e - i, 2);
    r = min(r, s);
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAXN 200009
using namespace std;

int main () {
    double len;
    int r;
    cin>>r;
    len = 2.0 * r * 3.14;
    cout<<len;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
    long long int h,n,i,j,sum=0;
    scanf("%lld%lld",&h,&n);
    int a[n+10];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    (sum-h)>=0?printf("Yes"):printf("No");
}


Measured memory_bytes: 2044
L, R = [int(x) for x in input().split()]

if R - L >= 2018:
    ans = 0
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j % 2019)

print(ans)

Measured memory_bytes: 2940
#include <stdio.h>

int main(){
	int year,month,day;
	
	scanf("%d/%d/%d",&year,&month,&day);
	
	if(year<2019)	printf("Heisei");
	else if(year==2019 && month<=4 && day<=30)	printf("Heisei");
	else	printf("TBD");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int[] city = new int[4];
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        for (int i=0; i<3; i++) {
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	city[a-1]++;
        	city[b-1]++;
        }
    }
    
    //解答処理
    private boolean solve() {
        boolean judge = true;
        
        for (int i=0; i<4; i++) {
        	if (city[i] >= 3) {
        		judge = false;
        		break;
        	}
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean answer) {
        if (answer) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }

}


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

int n, a[2*(int)1e5];
deque<int> b;

int main(void) {
    cin >> n; 
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i % 2 == (n-1) % 2) {
            b.push_front(a[i]);
        } else {
            b.push_back(a[i]);
        }
    }
    for (auto itr = b.begin(); itr != b.end(); itr++) {
        if (itr == b.begin()) {
            cout << *itr; 
            continue;
        } else cout << " " << *itr;
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3840
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class DIVERTA2019C
    {
        static public void Main(string[] args)
        {
            var N = NextInt;

            var fixABCount = 0;
            var s = new string[N];
            var lastAfirstBCount = 0;
            var lastACount = 0;
            var firstBCount = 0;
            for (int i = 0; i < N; ++i)
            {
                s[i] = NextString;
                for (int j = 0; j < s[i].Length - 1; ++j)
                {
                    if (s[i].Substring(j, 2) == "AB")
                    {
                        ++fixABCount;
                    }
                }
                var lastA = s[i].Last() == 'A';
                var firstB = s[i].First() == 'B';
                if (lastA && firstB)
                {
                    ++lastAfirstBCount;
                }
                else if (firstB)
                {
                    ++firstBCount;
                }
                else if (lastA)
                {
                    ++lastACount;
                }
            }

            if (lastAfirstBCount > 0)
            {
                if (lastACount > 0)
                {
                    fixABCount++;
                    lastACount--;
                }
                if (firstBCount > 0)
                {
                    fixABCount++;
                    firstBCount--;
                }
                Console.WriteLine(fixABCount + lastAfirstBCount - 1 + Math.Min(lastACount, firstBCount));
            }
            else
            {
                Console.WriteLine(fixABCount + Math.Min(lastACount, firstBCount));
            }
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


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

int main()
{
    long n,i;
    cin>>n;
    long A[n+1];
    A[0]=0;
    for(i=1;i<=n;i++)
        cin>>A[i];

    long long dp[n+1];
    dp[0]=0;
    dp[1]=0;
  	dp[2]=abs(A[2]-A[1]);
    for(i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
    cout<<dp[n]<<endl;
}


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


typedef long long lli;
typedef unsigned long ul;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
#define rep(i,n) for(lli i=0; i<(n); ++i)
#define reps(i,n) for(lli i=1; i<n; ++i)
#define rrep(i,x) for(lli i=((n)-1); i>=0; --i)
#define rreps(i,x) for(lli i=((n)); i>0; --i)
#define REP(i,n) for(lli i=0; i<n; ++i)
#define REPS(i,n) for(lli i=1; i<n; ++i)
#define RREP(i,x) for(lli i=((n)-1); i>=0; --i)
#define RREPS(i,x) for(lli i=((n)); i>0; --i)
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define FT first
#define SD second
#define y0 y348
#define y1 y348
#define next asdnext
#define prev asdprev
#define all(a) (a).begin(),(a).end()
#define eps pow(10,-7)
#define SZ(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))

lli gcd(lli a,lli b){return b?gcd(b,a%b):a;}
lli dx[4]={1,0,-1,0};
lli dy[4]={0,1,0,-1};

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


int main(){
  lli N,K,input,Max,Min,ans=INF;
  vl x;

  cin >>N>>K;
  rep(i,N){
    cin >> input;
    x.pb(input);
  }


  rep(i,N-K+1){
    Min=x[i];
    Max=x[i+K-1];
    if(Min*Max<0)
      chmin(ans,2*min(abs(Min),abs(Max))+max(abs(Min),abs(Max)));
    else
      chmin(ans,max(abs(Min),abs(Max)));
  }

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


Measured memory_bytes: 1400
from heapq import heappush, heappop
import sys, operator
INF = 10**18
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    N, M = map(int, readline().split())
    if N == M == 0:
        return False
    def dijkstra(N, s, G):
        dist = [INF]*N
        dist[s] = 0
        que = [(0, s)]
        while que:
            cost, v = heappop(que)
            if dist[v] < cost:
                continue
            for w, d in G[v]:
                if cost + d < dist[w]:
                    dist[w] = r = cost + d
                    heappush(que, (r, w))
        return dist
    rN = range(N)
    GL = [[] for i in rN]
    GS = [[] for i in rN]
    for i in range(M):
        x, y, t, sl = readline().split()
        x = int(x)-1; y = int(y)-1; t = int(t)
        if sl == 'L':
            GL[x].append((y, t))
            GL[y].append((x, t))
        else:
            GS[x].append((y, t))
            GS[y].append((x, t))
    EL = [dijkstra(N, i, GL) for i in rN]
    ES = [dijkstra(N, i, GS) for i in rN]

    R = int(readline())
    *Z, = map(int, readline().split())
    iv = [INF]*N
    S = [INF]*N; T = [0]*N
    D = [0]*N
    prv = Z[0]-1
    S[prv] = 0
    oadd = operator.add
    for z in Z[1:]:
        z -= 1
        A = EL[prv]; B = EL[z]
        v = A[z]
        D[:] = map(oadd, S, A)
        for j in rN:
            C = ES[j]
            b = B[j]
            T[j] = min(S[j] + v, min(map(oadd, D, C)) + b)
        S, T = T, S
        prv = z
    write("%d\n" % min(S))
    return True
while solve():
    ...


Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, x;
  in3(a, b, x);
  if(a <= x && x <= a + b)
    out("YES");
  else
    out("NO");
  memi;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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

i64 ceil(i64 a, i64 b) { return (a+b-1)/b; }
mt19937 rnd(time(NULL));

int d, c[30], s[404][30];
int ans[400];
clock_t start;

int score(int a[400], int l, int r){
	int cnt = 0;
	int last[26] = {};
	fill(last,last+26,l-1);
	
	for(int i = l; i < r; i++){
		cnt += s[i][a[i]];
		last[a[i]] = i;
		for(int j = 0; j < 26; j++){
			cnt -= c[j]*(i-last[j]);
		}
	}
	return cnt;
}

void solve(){
	start = clock();
	
	cin >> d;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < d; i++){
		for(int j = 0; j < 26; j++) cin >> s[i][j];
	}
	
	int ma = 0;
	set<int> st[30];
	for(int i = 0; i < 26; i++){
		st[i].insert(-1);
		st[i].insert(d);
	}
	for(int i = 0; i < d; i++){
		int v = rnd()%26;
		ans[i] = v;
		st[v].insert(i);
	}
	ma = score(ans,0,d);
	
	int cc[30] = {};
	for(int i = 0; i < 26; i++){
		cc[i+1] = c[i] + cc[i];
	}
	
	int lp = 0;
	while(clock()-start < 1.9*CLOCKS_PER_SEC){
		int p = rnd()%d;
		int q = rnd()%26;
		int was = ans[p];
		
		if(q == was) continue;
		
		ans[p] = q;
		
		int cnt = ma;
		cnt -= s[p][was];
		cnt += s[p][q];
		
		auto D = st[was].find(p);
		auto D1 = D; D1++;
		auto D0 = D; D0--;
		int l = *D1 - *D, r = *D - *D0;
		int lr = l+r;
		cnt += c[was] * (l*(l+1)/2 + r*(r+1)/2);
		cnt -= c[was] * lr*(lr+1)/2;
		st[was].erase(p);
		
		st[q].insert(p);
		D = st[q].find(p);
		D1 = D; D1++;
		D0 = D; D0--;
		l = *D1 - *D; r = *D - *D0;
		lr = l+r;
		cnt -= c[q] * (l*(l+1)/2 + r*(r+1)/2);
		cnt += c[q] * lr*(lr+1)/2;
		if(!chmax(ma,cnt)){
			ans[p] = was;
			st[was].insert(p);
			st[q].erase(p);
		}
		
		
		//if(lp%1000 == 0) cout << ma << endl;
		lp++;
	}
	// cout << lp << endl;
	// cout << ma << endl;
	// cout << score(ans,0,d) << endl;
	
	for(int i = 0; i < d; i++){
		cout << ans[i]+1 << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3740
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			List<Integer> L = new LinkedList<Integer>();
			ListIterator<Integer> LI = L.listIterator();
			int i;

			for(int j=0;j<q;j++) {
				switch(sc.nextInt()) {
				case 0:
					LI.add(sc.nextInt());
					LI.previous();
					break;
				case 1:
					int num = sc.nextInt();
					if(num>0)
						for(i=0;i<num;i++) {
							LI.next();
						}
					else
						for(i=num;i<0;i++) {
							LI.previous();
						}
					break;
				case 2:
					LI.next();
					LI.remove();
					break;
				}
			}
			L.forEach(s -> System.out.println(s));
		}
	}
}


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

namespace ALDS1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int minj;
            int s;
            int l = 0;
            for (int i = 0; i < n; i++)
            {
                minj = i;
                for (int j = i; j < n; j++)
                {
                    if (a[j] < a[minj]) { minj = j; }
                }
                if (i != minj)
                {
                    s = a[i];
                    a[i] = a[minj];
                    a[minj] = s;
                    l++;
                }
            }
            for (int i = 0; i < n-1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine(a[n - 1]);
            Console.WriteLine(l);
        }
    }
}



Measured memory_bytes: 18328
#include <iostream>
#include <vector>
#include <map>
#include <functional>

using namespace std;

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

    vector<int> p(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    
    auto issorted =  [&](vector<int> s){
        for (size_t i = 0; i < N-1; i++)
        {
            if(s[i]>s[i+1]) return false;
        }
        return true;
    };
    
    if(issorted(p)){
        cout << "YES" << endl;
        return 0;
    }

    for (size_t i = 0; i < N-1; i++)
    {
        for (size_t j = i+1; j < N; j++)
        {
            swap(p[i],p[j]);
            if(issorted(p)){
                cout << "YES" << endl;
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    
    cout << "NO" << endl;
    return 0;

    return 0;
}

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


# NSの最小値と最大値の間でコストが最小になる値を探す
def solve():
    min_cost = float("inf")
    for x in range(min(NS), max(NS) + 1):
        cost = 0
        for n in NS:
            cost += abs(n - x) ** 2
        if cost < min_cost:
            min_cost = cost
    return min_cost

print(solve())


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
int a[N],p[N],n;
ll ans=0;
int pl1[N],pl2[N],pr1[N],pr2[N];
bool cmp(int x,int y) { return a[x]>a[y]; }
set<int> s;
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]),p[i]=i;
	sort(p+1,p+n+1,cmp);
	s.insert(0),s.insert(n+1);
	for(int i=1;i<=n;++i) {
		set<int>::iterator it1=s.lower_bound(p[i]),it2=it1; it2--;
		pl1[p[i]]=*it2;
		if(*it2) pl2[p[i]]=*(--it2); else pl2[p[i]]=0;
		pr1[p[i]]=*it1;
		if((*it1)!=n+1) pr2[p[i]]=*(++it1); else pr2[p[i]]=n+1;
		s.insert(p[i]);
	}
//	for(int i=1;i<=n;++i) printf("%d: %d %d %d %d\n",i,pl1[i],pl2[i],pr1[i],pr2[i]);
	for(int i=1;i<=n;++i) {
		ll tmp=0;
		tmp+=(i-pl1[i])*(ll)(pr2[i]-pr1[i]);
		tmp+=(pl1[i]-pl2[i])*(ll)(pr1[i]-i);
		ans+=tmp*a[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL mod = 1'000'000'007;
constexpr int maxn = (1 << 17) + 1;
int P[maxn];
LL mark[2][maxn];
vector<pair<int, LL>> nodes[2][maxn];
void add(LL& x, LL y){
	x += y;
	if(x >= mod) x -= mod;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int H;
    cin >> H;
	int M = 1 << (H - 1);
	for(int i = 1; i <= M; i += 1) cin >> P[i];
	for(int i = 1; i <= M; i += 1)
		for(LL u = i + M - 1, p = u; u > 1; u >>= 1){
			nodes[u & 1][u >> 1].push_back({P[i] + M - 1, p});
			p = (u >> 1) * p % mod;
		}
	LL ans = 0;
	for(int i = 1; i < M; i += 1){
		for(auto [u, p] : nodes[0][i])
			for(; u > 1; u >>= 1){
				p = p * u % mod;
				add(mark[u & 1][u >> 1], p);
			}
		for(auto [u, p] : nodes[1][i])
			for(; u > 1; u >>= 1){
				p = p * u % mod;
				add(ans, mark[(u & 1) ^ 1][u >> 1] * p % mod * i % mod * (u >> 1) % mod);
			}
		for(auto [u, _] : nodes[0][i])
			for(; u > 1; u >>= 1)
				mark[u & 1][u >> 1] = 0;
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 50920
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
//#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
void solve(ll h1,ll m1,ll h2,ll m2)
{
    ll h=h1-h2;
    ll m=m1-m2;
    if(m<0)
    {
        m+=60;
        h--;
    }
    if(h<10)
    {
        cout<<"0"<<h<<":";
    }
    else
    {
        cout<<h<<":";
    }
    if(m<10)
    {
        cout<<"0"<<m<<"\n";
    }
    else
    {
        cout<<m<<"\n";
    }
    return;
}
ll func(ll i)
{
    ll ans=1;
    for(ll k=4;k<=i;k+=2)
    {
        ans*=3;
        ans--;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(n*500<k) cout<<"No\n";
    else cout<<"Yes\n";
	return 0;
}


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

int main(int argc, char const *argv[])
{
  while(1)
  {
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;

    for(int i = 0; i < H; i++)
    {
      for(int j = 0; j < W; j++)
        cout << "#" << flush;

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

Measured memory_bytes: 3108
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#define MIN(a,b) a>b?b:a
int main() {
	int n,m,i,j,min,cnt,nn;
	int *C, *T;
	scanf("%d%d", &n, &m);
	n += 1;
	min = n;
	C = (int*)malloc(sizeof(int)*m);
	T = (int*)calloc(n*m,sizeof(int));
	for (i = 0; i < m; i++) scanf("%d", C + i);
	for (j = 0; j < n; j++) T[j] = j;
	
	for (i = 1; i < m; i++) {
		for (j = 0; j < n; j++) {
			if(j<C[i]) *(T+n*i + j) = *(T+n*(i - 1) + j);
			else T[n*i + j] = MIN(T[n*(i-1)+j],T[(n*i)+j-C[i]]+1);
		}
	}
	for (i = 1,j=0; i <=m; i++,j++) if (min > *(T+(n-1)*i+j))min = *(T+(n-1)*i+j);
	printf("%d\n", min);
	free(C); free(T);
	return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5;
ll N,M;
ll par[MAX_N];
void init(){
	REP(i,N)par[i]=i;
}
ll fndpar(ll v){
	if(v==par[v]){
		return v;
	}
	return par[v]=fndpar(par[v]);
}
void unite(ll u,ll v){
	u=fndpar(u);
	v=fndpar(v);
	par[v]=u;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	init();
	REP(i,M){
		ll x,y,z;
		cin>>x>>y>>z;
		x--;
		y--;
		unite(x,y);
	}
	ll ans=0;
	REP(i,N){
		if(par[i]==i)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
nums = input().split()
num1 = int(nums[0])
num2 = int(nums[1])
num3 = int(nums[2])
for x in nums:
    if nums.index(x)+1 < len(nums):
        if x != nums[nums.index(x)+1] and x != nums[nums.index(x)-1]:
            print(x)
    else:
        if x != nums[0] and x != nums[1]:
            print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double
#define v vector

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) begin(x), end(x)
#define rall(x) end(x), begin(x)

#define endl '\n'


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

string solve(ll N) {
  N %= 10;
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    return "hon";
  } else if (N == 0 || N == 1 || N == 6 || N == 8) {
    return "pon";
  } else {
    return "bon";
  }
}

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

  ll N;
  cin >> N;

  auto ans = solve(N);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int cnt[5000][5000];
int main(){
	//freopen("DataSet.txt","r",stdin);
	char str[1001];
	scanf("%s",str);
	bool e=0,w=0,s=0,n=0;
	int len=strlen(str);
	for(int i=0;i<len;i++)
		if(str[i]=='N')n=1;
		else if(str[i]=='E')e=1;
		else if(str[i]=='W')w=1;
		else s=1;
	if((s==n)&&(w==e))puts("Yes");
	else puts("No");
}

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

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

		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.parallelSort(a);
		System.out.println(a[n/2]-a[n/2-1]);
	}
}



Measured memory_bytes: 50532
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<((H-h)*(W-w))<<endl;
    return 0;
}


Measured memory_bytes: 256
"""from collections import *
from itertools import
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline


"""
import copy
from collections import *
from heapq import *
N=int(input())

lst=[]

if N%2==0:
    for i in range(N-1):
        for m in range(i+1,N):
            if m !=(N-i-1):
                lst.append([i,m])
else:
    for i in range(N):
        for m in range(i+1,N):
            if m !=(N-i-2):
                lst.append([i,m])
print(len(lst))
for a,b in lst:
    print(a+1,b+1)


Measured memory_bytes: 43504
N = int(input())
A = list(map(int, input().split()))

ans = (2020202020)**100
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  hoge = hoge + A[i]
  ans = min(ans,(abs(sum_A - (hoge*2))))

print(ans)


Measured memory_bytes: 26024
import java.util.Scanner;


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

		double x=0,y=0;

		while(scan.hasNextInt()){
			a = scan.nextInt();
			b = scan.nextInt();
			c = scan.nextInt();
			d = scan.nextInt();
			e = scan.nextInt();
			f = scan.nextInt();

			double det = (double)(d*b - a*e);

			y = (double)(d*c-a*f)/det;
			x = (double)(c-b*y)/a;

			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
}

Measured memory_bytes: 18164
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,m;
  cin>>n>>m;
  vi cnt(m+1,0);
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int a;
      cin>>a;
      cnt[a]++;
    }
  }

  int ans=0;
  rep(i,m+1){
    ans+=(cnt[i]==n);
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int X,Y;cin>>X>>Y;Y/=X;
    int ans=1;
    while(Y>=2){
        ans++;
        Y/=2;
    }
    cout<<ans<<endl;
}

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

class Stack{
private:
	int sp;
	int data[100];
public:
	Stack(){
		sp=0;
	}
	bool isFull(){
		return (sp==100);
	}
	bool isEmpty(){
		return (sp==0);
	}
	void push(int d){
		if(isFull()){
			return;
		}
		data[sp++] = d;
	}
	int top(){
		if(isEmpty()){
			return -1;
		}
		return data[sp - 1];
	}
	void pop(){
		if(isEmpty()){
			return;
		}
		sp--;
	}
};
		
 
int main() {
	Stack s;
	string in;
	while(cin >> in){
		if(cin.eof()){
			break;
		}
		if(in == "+"){
			int tmp1 = s.top();
			s.pop();
			int tmp2 = s.top();
			s.pop();
			s.push(tmp2 + tmp1);
		}else if(in == "-"){
			int tmp1 = s.top();
			s.pop();
			int tmp2 = s.top();
			s.pop();
			s.push(tmp2 - tmp1);
		}else if(in == "*"){
			int tmp1 = s.top();
			s.pop();
			int tmp2 = s.top();
			s.pop();
			s.push(tmp2 * tmp1);
		}else{
			s.push(atoi(in.c_str()));
		}
	}
	cout<<s.top()<<endl;
    	return 0;
}


Measured memory_bytes: 1192
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-03-22 20:59:14 +0900
# LastModified: 2020-03-22 21:04:09 +0900
#


import os
import sys


def main():
    N,M = map(int,input().split())
    even_even = N*(N-1)//2
    odd_odd = M*(M-1)//2
    print(even_even+odd_odd)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int m = 10000;
        for(int i = 0;i < N;i++){
            int ci = sc.nextInt();
            int ti = sc.nextInt();
            if(ti <= T) m = Math.min(m, ci);
        }
        if(m == 10000)  System.out.println("TLE");
        else System.out.println(m);
    }
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (n == 1) {
        cout << (a == b);
        return 0;
    }

    if (b < a) {
        cout << 0;
        return 0;
    }
    long long nmax = a + 1ll * (n - 1) * b, nmin = 1ll * (n - 1) * a + b;
    cout << nmax - nmin + 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, C;
	char B;
	int answer;
	cin >> A >> B >> C;
	if (B == '+'){
		answer = A + C;
	}
	if (B == '-'){
		answer = A - C;
	}
	cout << answer << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mod 1000000007

using namespace std;
const int N=200010;
int n,m,ans,f[N],g[N];
char s[N];

void inc(int&x,int y){x+=y;if(x>=mod)x-=mod;}
void dec(int&x,int y){x-=y;if(x<0)x+=mod;}

int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	scanf("%d%d%s",&n,&m,s+1);
	int p=0;while(p<m&&s[p+1]==s[1])++p;
	if(p==m){
		ans=f[0]=g[0]=1;
		for(int i=0;i<=n;++i){
			if(i>1)f[i]=g[i-2];
			if(i)g[i]=(g[i-1]+f[i])%mod;
			if(n-i!=1)inc(ans,(ll)(n-i)*f[i]%mod);
		}
		cout<<ans<<endl;
	}else{
		if(n&1)puts("0"),exit(0);
		int L=p|1;
		while(1){
			int tmp=0;
			while(p<m&&s[p+1]!=s[1])++p;tmp-=p;
			while(p<m&&s[p+1]==s[1])++p;tmp+=p;
			if(p==m)break;
			if(tmp&1)L=min(L,tmp);
		}
		f[0]=g[0]=1;
		L=(L+1)>>1;n>>=1;
		for(int i=0;i<=n;++i){
			if(i)f[i]=g[i-1];
			if(i>L)dec(f[i],g[i-L-1]);
			if(i)g[i]=(g[i-1]+f[i])%mod;
			if(n-i<=L)inc(ans,(ll)(n-i)*f[i]%mod);
		}
		cout<<ans*2%mod<<endl;
	}
	return 0;
} 


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
char s[200010];
int n,a[200010];
long long c[3];
long long ans;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='B') a[i]=1;
		else a[i]=2;
	}
	for(int i=1;i<=n;i++){
		if(a[i]==2) ans+=c[1];
		c[a[i]]++;
	}
	printf("%lld\n",ans);
	
	return 0;
}

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

using namespace std;

long long a,b,c,d;

long long gcd(long long n,long long m){
    long long a = min(n,m);
    long long b = max(n,m);
    while(b % a != 0){
        long long c = b % a;
        b = a;
        a = c;
    }
    return n * m / a;
}

int main(){
    cin >> a >> b >> c >> d;
    long long ac = (a-1)/c;
    long long ad = (a-1)/d;
    long long acd = (a-1)/gcd(c,d);
    //cout << ac << " " << ad << " " << acd << endl;
    acd = ac + ad - acd;
    long long bc = b/c;
    long long bd = b/d;
    long long bcd = b/gcd(c,d);
    //cout << bc << " " << bd << " " << bcd << endl;
    bcd = bc + bd - bcd;
    cout << b - (a-1) - (bcd - acd) << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce


N = int(input())
if N == 1:
    ans = int(input())
    print(ans)
    exit()
lst_A = list(map(int, input().split()))


upper = reduce(mul, lst_A)
lower = 0
for i in range(N):
    lst_tmp = lst_A[:i] + lst_A[i+1::]
    lower += reduce(mul, lst_tmp)
ans = upper / lower
print(ans)

Measured memory_bytes: 3700