akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
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(){
  Int n;
  string s;cin >> n >> s;
  Int ans = 0;
  for(Int i=1;i<n;i++){
    string a=s.substr(0,i);
    string b=s.substr(i);
    set<char> x(a.begin(),a.end()),y(b.begin(),b.end());
    Int res = 0;
    for(char c:x) res+=y.count(c);
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
    int a;
    int cnt=0;
    char s[51];

    scanf("%d %s",&a,s);
    for(int i=0;i<a;i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'&&s[i+2]=='C'){
                cnt++;
            }
        }
    }
    
    printf("%d\n",cnt);

    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B,V,W,T;
    string S;
    cin >> A >> V >> B >> W >> T;
    ll d = abs(A-B);
    ll sa = V-W;
    if(sa*T >= d){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3624
package main

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

var (
	s = bufio.NewScanner(os.Stdin)
	w = bytes.Buffer{}
	n = 0
	a = []int{}
)

func main() {
	n = nextInt(s)
	a = atoi(s)
	_ = nextInt(s)
	m := atoi(s)

	for _, v := range m {
		i := 0
		if solve(i, v) {
			w.WriteString("yes\n")
			continue
		}
		w.WriteString("no\n")
	}
	fmt.Println(strings.TrimRight(w.String(), "\n"))
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	r, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return r
}

func atoi(s *bufio.Scanner) []int {
	s.Scan()
	a := strings.Fields(s.Text())
	i := []int{}

	for _, v := range a {
		j, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		i = append(i, j)
	}
	return i
}

func solve(i, m int) bool {
	if m == 0 {
		return true
	} else if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-a[i])
}



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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

// N^(2 ^ i)を最初に計算して、呼ばれた時にN^xを計算して返す
class PowerN {
    std::vector<ll> table;
public:
    PowerN(uint N, uint max) // max:使いたい引数nの最大
    {
        if (max == 0) return;
        table.resize(static_cast<uint>(floor(log2f(max))) + 1);
        table[0] = N;
        for (uint i = 1; i < table.size(); ++i){
            table[i] = table[i - 1] * table[i - 1]; // N ^ (2 ^ i)
        }
    }

    ll operator () (int n)
    {
        if (n < 0) return 0;
        if (n == 0) return 1;
        ll result = 1;
        for (uint i = 0; n; ++i, n >>= 1){
            if (!(n & 1)) continue;
            result *= table[i];
        }
        return result;
    }
};

int main()
{
    scanInt(M);
    scanLLInt(K);
    if (M == 0){
        if (K == 0){
            puts("0 0");
            return 0;
        }else{
            puts("-1");
            return 0;
        }
    }else if (M == 1){
        if (K == 0){
            puts("0 0 1 1");
            return 0;
        }else{
            puts("-1");
            return 0;
        }
    }
    PowerN pow2(2, M + 1);
    const ll pow2M = pow2(M);
    if (pow2M <= K){
        puts("-1");
        return 0;
    }
    cout << K << " ";
    for (ll n = 0; n < pow2M; ++n){
        if (n == K) continue;
        cout << n << " ";
    }
    cout << K << " ";
    for (ll n = pow2M - 1; 0 <= n; --n){
        if (n == K) continue;
        cout << n << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
  while (true) {
    string s[2];
    string os1;
    vector<char> os2;
    cin >> s[0];
    if (s[0] == "-") {break;}
    cin >> s[1] >> os1;

    //cout << s[1] << endl;
    char next = s[1][0];
    s[1].erase(0, 1);
    
    while ((!s[1].empty() || !s[0].empty()) && isalpha(next)) {
      //cout << "s1, s2, os2 " << s[0] << " " << s[1] << " " << next << " " << os1  << endl;
      if (os1[0] == next) {
	//cout << "1" << endl;
	if (!os1.empty()) os1.erase(0, 1);
	if (!s[0].empty()) {
	  next = s[0][0];
	} else {
	  next = 1;
	}
	if (!s[0].empty()) s[0].erase(0, 1);
      } else {
	//cout << "2" << endl;
	os2.push_back(next);
	next = s[1][0];
	if (!s[1].empty()) {
	  s[1].erase(0, 1);
	} else {
	  next = 1;
	}
      }
    }
    if (isalpha(next)) os2.push_back(next);
    for (int i = 0; i < s[1].size(); i++) {
      os2.push_back(s[1][i]);
    }
    for (int i = 0; i < s[0].size(); i++) {
      os2.push_back(s[0][i]);
    }
    for (int i = 0; i < os2.size(); i++) {
      cout << os2[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	static int MCXI(char c) {
		if(c == 'm') return 3;
		if(c == 'c') return 2;
		if(c == 'x') return 1;
		else return 0;
	}
	
	static int change(String str) {
		char[] s = new char[str.length()];
		for(int i=0; i<str.length(); i++) {
			s[i] = str.charAt(str.length()-i-1);
		}
		
		int f = 0;
		int k = 0;
		int sum = 0;
		int[] K = {1, 10, 100, 1000};
		for(int i=0; i<str.length(); i++) {
			if(s[i]=='i' || s[i]=='x' || s[i]=='c' || s[i]=='m') {
				if(f>=1) {
					sum += k * 1;
					f = 0;
				}
				k = K[MCXI(s[i])];
				f++;
			}
			if('1'<=s[i] && s[i]<='9') {
				int sei = (int)s[i] - '0';
				sum += k * sei;
				f = 0;
			}
			if(i==str.length()-1 && f==1) {
				sum += k * 1;
			}
		}
		return sum;
	}
	
	static String rechange(int sum) {
		String ans = "";
		if(sum >= 1000) {
			if(sum/1000 >= 2) {
				ans += String.valueOf(sum/1000);
			}
			ans += "m";
			sum = sum % 1000;
		}
		if(sum>=100) {
			if(sum/100 >= 2) {
				ans += String.valueOf(sum/100);
			}
			ans += "c";
			sum = sum % 100;
		}
		if(sum>=10) {
			if(sum/10 >= 2) {
				ans += String.valueOf(sum/10);
			}
			ans += "x";
			sum = sum % 10;
		}
		if(sum>=2) {
			ans += String.valueOf(sum);
		}
		if(sum>=1) {
			ans += "i";
		}
		return ans;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int sum = 0;
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n == 0) break;
				
				for(int i=0; i<n; i++) {
					String s = sc.next();
					sum = change(s);
					s = sc.next();
					sum += change(s);
					
					System.out.println(rechange(sum));
				}
			}
		}
	}
}


Measured memory_bytes: 37728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,x;
	cin>>n>>x;
	ll arr[n];
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		ans=__gcd(ans,abs(x-arr[i]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstdlib>

int main(void){
  long a, x, max, min, i, sum;
  sum = 0;
  scanf("%ld", &a);
  scanf("%ld", &x);
  max=min=x;
  sum=x;
  for(i=0; i<a-1; i++){
    scanf("%ld", &x);
    if(max<x) max=x;
    if(min>x) min=x;
    sum+=x;
  }
  printf("%ld %ld %ld\n", min, max, sum);
  return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int N,K;
    cin >> N >> K;
    int d,a;
    int s[1001] = {0};
    int ans = 0;
    rep(i,K){
        cin >> d;
        rep(j,d){
            cin >> a;
            s[a-1]++;
        }
    }
    rep(i,N){
        if(s[i] == 0) ans++;
    }

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

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
    int H,N,A[100005],i;
    scanf("%d%d",&H,&N);

    for(i=0; i<N; i++)
    {
        scanf("%d",&A[i]);
        H= H-A[i];
    }
    if(H<=0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<long> a(x), b(y), c(z);
    for(int i = 0; i < x; i++) scanf("%ld", &a[i]);
    for(int i = 0; i < y; i++) scanf("%ld", &b[i]);
    for(int i = 0; i < z; i++) scanf("%ld", &c[i]);

    vector<long> ab;
    for (int i = 0; i < x; i++) 
        for (int j = 0; j < y; j++) {
            ab.push_back(a[i] + b[j]);
        }
    
    sort(ab.begin(), ab.end(), greater<long>());

    vector<long> abc;
    for (int i = 0; i < min(k, (int)ab.size()); i++)
        for (int j = 0; j < z; j++) {
            abc.push_back(ab[i] + c[j]);
        }
    
    sort(abc.begin(), abc.end(), greater<long>());

    for (int i = 0; i < k; i++) {
        cout << abc[i] << "\n";
    }

}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    A.at(a-1)++;
    A.at(b-1)++;
  }
  for(int i=0;i<N;i++)
    cout << A.at(i) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <limits>
#include <queue>

using namespace std;

int main() {
    auto const INF = numeric_limits<int>::max();

    int V, E;
    cin >> V >> E;

    vector<vector<int>> D(V, vector<int>(V, INF));
    for (int i = 0; i < V; ++i) D[i][i] = 0;
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        D[s][t] = d;
    }
    //  Warshall???Floyd Algorithm
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                if (D[i][k] != INF && D[k][j] != INF)
                    D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }

    for (int i = 0; i < V; ++i) {
        if (D[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            auto x = D[i][j];
            if (x != INF) {
                cout << x;
            } else {
                cout << "INF";
            }
            if (j == V-1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

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


int a[70];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int q; cin >> q;
    REP(i, q){
        int qu; cin >> qu;
        if(qu==0){
            int j; cin >> j;
            if(a[j]) cout << 1 << endl;
            else cout << 0 << endl;
        }
        if(qu==1){
            int j; cin >> j;
            a[j]=1;
        }
        if(qu==2){
            int j; cin >> j;
            a[j]=0;
        }
        if(qu==3){
            int j; cin >> j;
            if(a[j]) a[j]=0;
            else a[j]=1;
        }
        if(qu==4){
            bool flag=true;
            for(int j=0; j<=63; ++j){
                if(!a[j]) flag = false;
            }
            if(flag) cout << 1 << endl;
            else cout << 0 << endl;
        }
        if(qu==5){
            bool flag=false;
            for(int j=0; j<=63; ++j){
                if(a[j]) flag = true;
            }
            if(flag) cout << 1 << endl;
            else cout << 0 << endl;
        }
        if(qu==6){
            bool flag=true;
            for(int j=0; j<=63; ++j){
                if(a[j]) flag = false;
            }
            if(flag) cout << 1 << endl;
            else cout << 0 << endl;
        }
        if(qu==7){
            int cnt=0;
            for(int j=0; j<=63; ++j){
                if(a[j]) cnt++;
            }
            cout << cnt << endl;
        }
        if(qu==8){
            size_t res=0;
            size_t t=1;
            for(int j=0; j<=63; ++j){
                res+=a[j]*t;
                t*=2;
            }
            cout << res << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

template<class InputIterator, class UnaryPredicate>
bool all_of(InputIterator first, InputIterator last, UnaryPredicate pred) {
	while (first != last) {
		if (!pred(*first)) return false;
		++first;
	}
	return true;
}

int main() {
	int n, count = 1, k = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		if (a[k] == 2) {
			break;
		}
		else {
			k = a[k] - 1;
			count++;
		}
	}
	if (count == n+1)
		cout << -1 << endl;
	else
		cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin >> n;int a[n];memset(a,0,sizeof(a));
    for (int i = 0; i < n-1; ++i)
    {
    	int d;cin >> d;d--;
    	a[d]++;
    }
    for (int i = 0; i < n; ++i)
    {
    	cout << a[i] << "\n";
    }
    }

Measured memory_bytes: 5212
n = int(input())
h = list(map(int, input().split()))

for i in reversed(range(1, n)):
    if h[i] < h[i - 1]:
        h[i - 1] = h[i - 1] - 1
        if h[i] < h[i - 1]:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 63984
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String YYMM = sc.next();

        int YY =  Character.getNumericValue(YYMM.charAt(0)) *10 + Character.getNumericValue(YYMM.charAt(1));
        int MM =  Character.getNumericValue(YYMM.charAt(2)) *10 + Character.getNumericValue(YYMM.charAt(3));

        if(YY < 13 && YY > 0 && MM < 13 && MM >0){
            System.out.println("AMBIGUOUS");
        } else if ((YY > 12 || YY ==0) &&  MM < 13 && MM >0){
            System.out.println("YYMM");
        } else if ((MM > 12 || MM==0)&& YY <13 && YY > 0){
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }



    }
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    if(m1==0)m1==60;
    if(m2==0)m2==60;

    int H=h2-h1;
    int M=m2-m1;

    cout<<(H*60+(m2-m1))-k<<endl;
}


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

// a と b の最大公約数を返す関数
int64_t GCD(int64_t a, int64_t b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    vector<int64_t> L(N); // 左からi番目までの最大公約数
    vector<int64_t> R(N); // 左からi番目までの最大公約数
    
    L[0] = A[0];
    for ( int64_t i = 1; i < N; ++i){
        L[i] = GCD(L[i-1],A[i]);
    }
    R[N-1] = A[N-1];
    for ( int64_t i = N-2; i >= 0; --i){
        R[i] = GCD(R[i+1],A[i]);
    }
    
    int64_t ans = 1;
    for ( int64_t i = 0; i < N; ++i){
        int64_t LR;
        if ( i == 0 ){
            LR = R[1];
        } else if ( i == N-1 ){
            LR = L[N-2];
        } else {
            LR = GCD(L[i-1],R[i+1]);
        }
        ans = max(ans,LR);
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 5640
def main():
    s = list(input())
    length = len(s)
    answer = 0
    for i in range(pow(2, length - 1)):
        op = ["" for _ in range(length - 1)]
        for j in range(length - 1):
            if (i >> j) & 1:
                op[j] = "+"
        formula = s[0]
        for j in range(length - 1):
            formula += op[j] + s[j + 1]
        answer += eval(formula)
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += scan.nextInt() - 1;
		}
		System.out.println(ans);
	}
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i)=0; (i)<(n); ++(i))
#define rep1(i,n) for(int (i)=1; (i)<=(n); ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

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

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

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

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

vector<long long> frac;

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	//vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long nextsub(unsigned long long sub){
	unsigned long long tem = sub + (sub & -sub);
	unsigned long long btm = (~(tem) & sub) / (sub & -sub);
	return btm | tem;
}

inline void solve(){
	ll d=((ll)1<<62)-1+((ll)1<<62),n,l;
	ll s[300000];
	cin>>n; 
	s[0]=0;
	rep(i,n){
		cin>>l; 
		s[i+1]=l+s[i];
	}
	rep1(i,n-1) d=min(d,abs(s[n]-s[i]*2));
	cout<<d;
	return;
}

inline void input(){

	return;
}

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





Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define MAX 250
using namespace std;

inline int parent(int i) { return i / 2; }
inline int right(int i) { return 2 * i + 1; }
inline int left(int i) { return 2 * i; }

int main() {
	int H;
	int A[MAX + 1];

	cin >> H;
	for (int i = 1; i <= H; i++) cin >> A[i];
	for (int i = 1; i <= H; i++) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) != 0) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
}

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  char s[4];
  scanf("%s", s);
  int c=0,i,j;
  for(i=0;i<3;i++){
    for(j=i+1;j<4;j++){
      if(s[i] == s[j]){
        c++;
      }
    }
  }
  if(c==2){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}

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



int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s, t; cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) ans += s[i] == t[i];
  cout << ans << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll N,ans=1;
void eratosthenes(bool *prime);
ll cnt[1001];

int main(){
    cin>>N;
    bool prime[1001];
    rep(i,1001){
        prime[i]=0;
        cnt[i]=0;
    }
    eratosthenes(prime);
    repi(i,1,N+1){
        ll tmp=i;
        rep(j,sqrt(i)+1){
            if(!prime[j])continue;
            while(tmp%j==0){
                tmp/=j;
                cnt[j]++;
            }
        }
        if(tmp!=1)cnt[tmp]++;
    }
    rep(i,N+1){
        // out(ans);
        if(cnt[i]&&prime[i])ans=(ans*(cnt[i]+1))%1000000007;
    }
    out(ans);


}

void eratosthenes(bool *prime){
    rep(i,N+1) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,N+1){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
}


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

res = 0
for i in range(N):
  a = list(map(int, input().split()))
  s = C
  for j in range(M):
    s += B[j] * a[j]
  res += (s > 0)

print(res)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lowbit(x) x&(-x)
#define PA pair<int, int>
#define MK make_pair
using namespace std;
typedef long long LL;
inline int read()
{
	char s[233];
	scanf("%s", s+1);
	if (s[1] == 'M') return 0;
	if (s[1] == 'F') return 1;
	return 2;
}
int n;
void solve(int l, int r, int x, int y)
{
	if (l == r) return;
	int mid = (l+r)>>1;
	printf("%d\n", mid);
	fflush(stdout);
	int tmp = read();
	if (tmp == 2) return;
	if (((l&1)^(mid&1)) != (x^tmp)) solve(l, mid, x, tmp);
	else solve(mid, r, tmp, y);
}
int main(int argc, char const *argv[])
{
	cin >> n;
	printf("0\n");
	fflush(stdout);
	int x = read();
	if (x == 2) return 0;
	printf("%d\n", n-1);
	fflush(stdout);
	int y = read();
	if (y == 2) return 0;
	solve(0, n-1, x, y);
	return 0;
}

Measured memory_bytes: 852
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
#define   sz(x)           (LL)x.size()
LL n,i,j,ans = 0;
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL k ;
    cin>>n>>k; 
    string s ; 
    cin>>s ; 
    vector <pair<LL,LL> > V ; 
    
    LL cnt = 0 ;
    for(int i=0;i<sz(s);i++)
    {  if(s[i]=='1') cnt++ ;
       else
       {   if(cnt)
           V.pb({cnt,i-cnt}),ans = max(ans,cnt) ; 
          cnt = 0 ;  
       }
    }
    if(cnt) ans = max(ans,cnt),V.pb({cnt,sz(s)-cnt}) ; 
    
    if(k>sz(V)) ret cout<<sz(s),0 ; 
    int l =  k ;
    for(int i=0;l<sz(V);i++)
      ans = max(ans,V[l].S - V[i].S + 1 + V[l].F - 1),l++ ; 
   // cout<<"l = "<<l<<endl;
  // cout<<"l"<<ans<<endl;
    if(s[0]=='0') 
    {  LL cnt = 0 ;
        for(int i=0;i<sz(s);i++)
       {  if(s[i]=='1') break ; 
          cnt++ ; 

       }
       cnt += V[k-1].S - V[0].S + 1 + V[k-1].F - 1 ; 
       ans = max(ans,cnt) ;
      // cout<<ans<<endl ;   
    }
    if(s[sz(s)-1]=='0')
    {  LL cnt = 0 ;
       for(int i=sz(s)-1;i>=0;i--)
       {  if(s[i]=='1') break ; 
          cnt++ ; 
       }  
       cnt += V[sz(V)-1].S - V[sz(V)-k].S + 1 + V[sz(V)-1].F - 1 ; 
       ans = max(ans,cnt) ; 
          
    }

    
    cout<<ans<<endl; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main()
{
         long long int n,i,sum=0;
         cin>>n;
         while(n>=5)
         {
                  if(n>=500)
                  {
                           sum=sum+1000;
                           n=n-500;
                  }
                  else
                  {
                           sum=sum+5;
                           n=n-5;
                  }
         }
         cout<<sum<<endl;
         return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[10];
  int i,j=0,max=0;
  scanf("%s",&s);
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G') j++;
     else if(j>max){ max=j; j=0;}
  }
  if(j>max) max=j;
  printf("%d",max);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC064B()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto& x : a)
		cin >> x;
	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;
}

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

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

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

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin >> x >> y;

    COMinit();
    if((x+y)%3!=0){
        cout << 0 << "\n";
        return 0;
    }
    int n=(x*2-y)/3;
    int m=(-x+2*y)/3;
    cout << COM(n+m,m) << "\n";

    return 0;
}

Measured memory_bytes: 119808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

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

  ll ans = 0;
  if(k == 0){
    cout << n * n << endl;
  } else {
    for(int i = k + 1; i <= n; ++i){
      ll multiplier = 0;
      ll num = i - k;
      ans += max((ll)0, n % i - k + 1);
      multiplier = n / i;

      ans += num * multiplier;
    }

    cout << ans << endl;
  }

}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
dp = [0 for _ in range(n)]
dp[1] = abs(a[1] - a[0])
for i in range(2, n):
    dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2])

print(dp[-1])


Measured memory_bytes: 20616
N = int(input())
march = 'MARCH'
S = [0,0,0,0,0]
for i in range(N):
    s = input()
    for j in range(5):
        if s[0] == march[j]:
            S[j] += 1
ans = 0
for i in range(5):
    ans += S[0]*(S[1]*(S[2]+S[3]+S[4])+S[2]*(S[3]+S[4])+S[3]*S[4])
    S[0],S[1],S[2],S[3],S[4] = S[1],S[2],S[3],S[4],0

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int n;
// vector<Edge> G;
const int MAX_N=100100;
vector<int> G[MAX_N];
vector<int> A(100100);
vector<int> B(100100);

int dfs(vector<int> &vec, int i, int d)
{
  if (vec[i]) return 0;
  vec[i] = d+1;
  for (int c : G[i])
  {
    dfs(vec, c, d+1);
  }
  return 0;
}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n;
  REP(i,n-1)
  {
    int a,b; cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(A, 1, 1);
  dfs(B, n, 1);
  int cntA=0, cntB=0;
  for (int i=1; i<n+1; i++)
  {
    if (A[i]<=B[i]) cntA++;
    else            cntB++;
  }
  cout << (cntA>cntB?"Fennec":"Snuke") << endl;
}


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


int main() {
  int N;
  cin >> N;
  bool ok = true;
  for (int i = 0;i<N;i++) {
    int a;
    cin >> a;
    if (a%2==0) {
      if ((a%3!=0) && (a%5!=0)) {
        ok = false;
      }
    }
  }
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


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

int main(){
  int N,L; cin>>N>>L;
  vector<int> V(N);
  int sum=0,e=0;
  rep(i,N){
    V[i]=L+i;
    if(abs(V[e])>abs(V[i])) e=i;
    sum+=V[i];
  }
  cout<<sum-V[e]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

bool palindrome(int x){
    deque<int> q;
    while(x>0){
        q.pb(x%10);
        x/=10;
    }
    bool v = true;
    while(q.size()>1){
        if(q.front()==q.back()){
            q.pof();q.pob();
        }
        else {v=false;break;}
    }
    return v;
}
int a,b,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(palindrome(i)){ans++;}
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
  fastIO
 int n;
  cin>>n;
  int arr[n];
  int count=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    if((arr[i]%2!=0)&&((i+1)%2!=0)) {
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            int a = GetInt();
            int b = GetInt();
            var h = GetInt();
            var ans = (a + b) * h / 2.0;

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#define XOX
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define ll          long long
#define ld          long double
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
#define vvd(a,b,name)    vector<vector<double>> name(a,vector<double>(b,-1))
//const ld pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}
#define int long long

void solve(){
	int n;
	cin>>n;
	int dp[90]={0};
	dp[0]=2;
	dp[1]=1;
	rep(i,2,n+1){
		dp[i]=dp[i-1]+dp[i-2];
	}
	cout<<dp[n]<<endl;	
}

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


Measured memory_bytes: 256
b,r,g,c,s,t;main(){while(1){scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t);if(!(b+r+g+c+s+t))break;printf("%d\n",100-(t-s)*3+c*2+g*7+15*(6*b+4*r)+b*5+r*3);}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;

ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll r, d, x;
  cin >> r >> d >> x;

  for (ll i = 1; i <= 10; i++) {
    ll curr = x * r - d;
    cout << curr << en;
    x = curr;
  }
  return 0;
}

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

int ans = 0;
int N, M, Q;
int a[51], b[51], c[51], d[51];
int A[11];
void sum_d(int A[], int n)
{

    if (n == N)
    {
        int d_sum = 0;
        for (int i = 0; i < Q; i++)
        {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
            {
                d_sum += d[i];
            }
        }
        ans = max(ans, d_sum);
    }
    else
    {
        for (int i = A[n - 1]; i <= M; i++)
        {
            A[n] = i;
            sum_d(A, n + 1);
        }
    }
}

int main()
{
    A[0] = 1;
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    sum_d(A, 1);
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle
{
    int f[N2];
    int space;
    string path;

    bool operator<(const Puzzle &p) const
    {
        for (int i = 0; i < N2; i++)
        {
            if (f[i] == p.f[i])
                continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p)
{
    for (int i = 0; i < N2; i++)
        if (p.f[i] != (i + 1))
            return false;
    return true;
}

string bfs(Puzzle s)
{
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while (!Q.empty())
    {
        u = Q.front();
        Q.pop();
        if (isTarget(u))
            return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; r++)
        {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N)
                continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v])
            {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}

int main()
{
    Puzzle in;

    for (int i = 0; i < N2; i++)
    {
        cin >> in.f[i];
        if (in.f[i] == 0)
        {
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 30648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
using namespace std;

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

    rep(i,s.size()) {
        if (count(all(s),s[i]) != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define st first
#define nd second
#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)

using namespace std;

template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ','){ cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }

template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

typedef vector<vector<int>> Graph;

int Depth(vector<int> parents) {
  int n = SZ(parents) - 1;
  vector<int> depth(n + 1);
  int res = 0;
  RE (i, n) {
    if (parents[i]) {
      depth[i] = depth[parents[i]] + 1;
      maxi(res, depth[i]);
    } else {
      depth[i] = 1;
    }
  }
  return res;
}

int Magic(int n) {
  return n - (n & (n - 1));
}

int TreeTreedepth(vector<int> parents, vector<int>& msb) { // msb[0] == -1
  assert(msb[0] == -1);
  int n = SZ(parents) - 1;
  assert(SZ(msb) >= SZ(parents));
  vector<vector<int>> ch(n + 1);
  RE (i, n) {
    ch[parents[i]].PB(i);
  }
  int full_mask = (1 << 30) - 1;
  function<int(int)> Go = [&](int v) {
    int highest_repeating = -1;
    int or_so_far = 0;
    for (auto nei : ch[v]) {
      int mask = Go(nei);
      maxi(highest_repeating, msb[mask & or_so_far]);
      or_so_far |= mask;
    }
    int to_magic = (full_mask - ((1 << (highest_repeating + 1)) - 1)) & (full_mask - or_so_far);
    int lsb_pow = Magic(to_magic);
    debug(highest_repeating, lsb_pow, to_magic);
    int ret = (or_so_far + lsb_pow) & (full_mask - lsb_pow + 1);
    debug(v, ret);
    return ret;
  };
  int res = 0;
  for (auto root : ch[0]) {
    int mask = Go(root);
    maxi(res, msb[mask]);
  }
  return res + 1;
}

int main(int argc, char** argv) {

  int n;
  cin>>n;
  vector<vector<int>> graph(n + 1);
  RE (i, n - 1) {
    int a, b;
    cin>>a>>b;
    graph[a].PB(b);
    graph[b].PB(a);
  }
  vector<int> parents(n + 1);
  function<void(int, int)> Dfs = [&](int v, int p) {
    parents[v] = p;
    for (auto nei : graph[v]) {
      if (nei == p) { continue; }
      Dfs(nei, v);
    }
  };
  Dfs(1, 0);
  vector<int> msb(n + 1);
  msb[0] = -1;
  RE (i, n) {
    msb[i] = msb[i - 1] + !(i & (i - 1));
  }
  debug(msb[3]);
  cout<<TreeTreedepth(parents, msb) - 1<<endl;
  
  return 0;
}
  
  

Measured memory_bytes: 16896