akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m;
	cin>>n>>m;
	vvint vv(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		vv[a].PB(b);
		vv[b].PB(a);
	}
	int Q;
	cin>>Q;
	vint col(n);
	VV(pii) w;
	initvv(w, n, 11, pii(-1, 0));
	rep(i,Q){
		int v,d,c;
		cin>>v>>d>>c;
		v--;
		w[v][d] = pii(i, c);
		// vint used(n);
		// queue<int> q;
		// q.push(v);
		// used[v] = 1;
		// col[v] = c;
		// // cout<<v<<" "<<d<<" "<<c<<endl;
		// rep(j,d){
		// 	int qs = q.size();
		// 	rep(_, qs){
		// 		int x = q.front();
		// 		q.pop();
		// 		for(cauto y: vv[x]){
		// 			if(used[y]) continue;
		// 			used[y] = 1;
		// 			col[y] = c;
		// 			q.push(y);
		// 		}
		// 	}
		// }
		// rep(j,n){
		// 	cout<<col[j]<<endl;
		// }
		// cout<<"aa "<<endl;
	}
	rep(i,n){
		for(int j = 9; j >= 0; j--){
			maxs(w[i][j], w[i][j+1]);
		}
	}
	rep(_,10){
		VV(pii) next = w;
		rep(i,n){
			next[i][10] = pii(-1,0);
			for(cauto x: vv[i]){
				rep(j,10){
					maxs(next[i][j], w[x][j+1]);
				}
			}
			for(int j = 9; j >= 0; j--){
				maxs(next[i][j], next[i][j+1]);
			}
		}
		w = next;
	}
	rep(i,n){
		cout<<w[i][0].S<<endl;
	}
}


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

Measured memory_bytes: 30016
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;

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

int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  bool isOk = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) isOk = true;
  }
  if (isOk) cout << "OK" << endl;
  else cout << "NG" << endl;
}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll h[n+2];
    for(ll i=1;i<=n;i++) cin>>h[i];
    ll stone[n+2];
    stone[n]=0;stone[n+1]=1000000000;
    for(ll i=n-1;i>=1;i--)
    {
        stone[i]=1000000000;
        for(ll j=1;j<=k && i+j<=n;j++)
        {
            stone[i]=min(stone[i+j]+abs(h[i+j]-h[i]),stone[i]);
        }
    }
    cout<<stone[1];
    return 0;
}
    

Measured memory_bytes: 1792
import java.util.*;

public class Main{
//public class abc166_a{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] x =  new int[5];
		for(int i=0;i<5;i++){
			x[i] = scan.nextInt();
		}
		/*
		int x1 = scan.nextInt();
		int x2 = scan.nextInt();
		int x3 = scan.nextInt();
		int x4 = scan.nextInt();
		int x5 = scan.nextInt();

		if(s.equals("ABC")){
			System.out.println("ARC");
		}else{
			System.out.println("ABC");
		}
		*/
		for(int i=0; i<5; i++){
			if(x[i] == 0) System.out.println(i+1);
		}

	}

}

Measured memory_bytes: 27084
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var A = ReadSplitInt();
            var dict = new Dictionary<int, int>();

            for (int i = 0; i < A.Count; i++)
                dict.Add(A[i], i + 1);

            for (int i = 1; i <= N; i++)
            {
                if (i == N)
                    Print(dict[i]);
                else
                    Print(dict[i] + " ");
            }

            Println("");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 31576
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while (true) {
		    String s = sc.next();
		    if (s.equals("#")) {
		        break;
		    }
		    String[] arr = s.split("/");
		    int h = arr.length;
		    int w = getSize(arr[0]);
		    boolean[][] field = new boolean[h][];
		    for (int i = 0; i < h; i++) {
		        field[i] = getArray(arr[i], w);
		    }
		    field[sc.nextInt() - 1][sc.nextInt() - 1] = false;
		    field[sc.nextInt() - 1][sc.nextInt() - 1] = true;
		    for (int i = 0; i < h; i++) {
		        if (i > 0) {
		            sb.append("/");
		        }
		        sb.append(getString(field[i]));
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static String getString(boolean[] arr) {
	    StringBuilder sb = new StringBuilder();
	    int count = 0;
	    for (boolean b : arr) {
	        if (b) {
	            if (count > 0) {
	                sb.append(count);
	                count = 0;
	            }
	            sb.append("b");
	        } else {
	            count++;
	        }
	    }
	    if (count > 0) {
	        sb.append(count);
	    }
	    return sb.toString();
	}
	
	static int getSize(String s) {
	    int ans = 0;
	    for (char c : s.toCharArray()) {
	        if (c == 'b') {
	            ans++;
	        } else {
	            ans += c - '0';
	        }
	    }
	    return ans;
	}
	
	static boolean[] getArray(String s, int length) {
	    boolean[] ans = new boolean[length];
	    int idx = 0;
	    for (char c : s.toCharArray()) {
	        if (c == 'b') {
	            ans[idx] = true;
	            idx++;
	        } else {
	            idx += c - '0';
	        }
	    }
	    return ans;
	}
}



Measured memory_bytes: 26420
N=int(input())
T,A = map(int,input().split())
H_li = list(map(int,input().split()))

for i in range(N):
    H_li[i]=T-H_li[i]*0.006

ans=0
a=100000
for i in range(N):
    if abs(A-H_li[i])<a:
        a=abs(A-H_li[i])
        ans=i+1

print(ans)

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

using namespace  std;

int main(){
 int N; cin >> N ;
  vector<int> A(N);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  vector<int > L(N); vector<int> R(N);
  L[0] = A[0];
  for(int i = 0; i < N - 1; i++){
    L[i+1] = max( L[i], A[i+1]);}
   
  R[N-1] = A[N-1];
  for(int j = N - 2; j >= 0; j--){
    R[j] = max( R[j+1], A[j]);}
  
  for(int i = 0; i < N; i++){
    // A[i]を消去することを考える
    if( i == 0){ cout << R[1] << endl;}
    else if( i == N - 1){ cout << L[N-2] << endl;}
    else{
      cout << max( L[i-1], R[i+1] ) << endl;}
  }
  return 0;}

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

int main() {
	int N;
	cin >> N;
	vector<int> s(N);
	int sum = 0;
	for (int& i : s) {
		cin >> i;
		sum += i;
	}
	sort(s.begin(), s.end());
	if (sum % 10 == 0) {
		int i;
		for (i = 0; i < N; ++i) {
			if ((sum - s[i]) % 10 != 0) {
				cout << sum - s[i];
				break;
			}
		}
		if (i == N) cout << 0;
	}
	else cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
string s;
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i] == '.') a++;
        if(s[i] == '#') b++;
    }
    if(b == n){cout<<0<<endl;exit(0);}
    int A = 0,B = 0;
    int mn = 1000000009;
    for(int i=0;i<n;i++){
        if(s[i] == '.') A++;
        if(s[i] == '#') B++;
        mn = min(mn,B+a-A);
    }
    cout<<min(mn,min(a,b))<<endl;
}   

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long li;

int main() {
    li n, k, q;
    cin >> n >> k >> q;

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

    li ans = *max_element(xs.begin(), xs.end()) - *min_element(xs.begin(), xs.end());

    for (int i = 0; i < n; ++i) {
        vector<vector<li>> subs;
        vector<li> sub;
        for (int j = 0; j <= n; ++j) {
            if (j == n || xs[j] < xs[i]) {
                subs.push_back(sub);
                sub.clear();
            } else {
                sub.push_back(xs[j]);
            }
        }

        vector<li> removed;
        for (auto &&sub : subs) {
            li elems = max((li)sub.size() - k + 1, 0LL);
            sort(sub.begin(), sub.end());
            removed.insert(removed.end(), sub.begin(), sub.begin() + elems);
        }

        sort(removed.begin(), removed.end());
        if (removed.size() >= q) {
            ans = min(ans, removed[q - 1] - removed[0]);
        }
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	ll n,k;
	cin >> k >> n;
	vl d,s;
	ll sum = 0,min = k+1;
	rep(i,n) {
		ll x;
		cin >> x;
		d.push_back(x);
	}
	rep(i,n-1) {
		s.push_back(d[i+1]-d[i]);
	}
	s.push_back(k-d[n-1]+d[0]);
	rep(i,n) {
		sum += s[i];
	}
	rep(i,n) {
		if (min > sum-s[i])
			min = sum-s[i];
	}
	out1(min);
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,k;
int a[55];
int ans;
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (int i=1;i<=k;i++){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
used = [[0]*3 for _ in range(3)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j] == b[k]:
        used[i][j] = 1 

for i in range(3):
  if sum(used[i]) == 3:
    print('Yes')
    exit()

if used[0][0] + used[1][0] + used[2][0] == 3:
  print('Yes')
  exit()
if used[0][1] + used[1][1] + used[2][1] == 3:
  print('Yes')
  exit()
if used[0][2] + used[1][2] + used[2][2] == 3:
  print('Yes')
  exit()

if used[0][0] + used[1][1] + used[2][2] == 3:
  print('Yes')
  exit()
if used[0][2] + used[1][1] + used[2][0] == 3:
  print('Yes')
  exit()

  
print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;

typedef pair<int,bool> Pair;

int main(){

  int ans = 0;
  int N;
  int d[101];

  cin >> N;

  for(int i = 0; i < N; ++i) cin >> d[i];

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

    for(int j = i; j < N; ++j){

      if(i != j){

      ans = ans + (d[i]*d[j]);

      }

    }

  }

  cout << ans << endl;

  return 0;

}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/
int n, m;

void solve() {
    cin >> n >> m;
    vector<vector<char>> grid(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
        }
    }
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i < n; i++) {
        if (grid[i][0] == '#') break;
        dp[i][0] = 1;
    }
    for (int j = 1; j < m; j++) {
        if (grid[0][j] == '#') break;
        dp[0][j] = 1;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            if (grid[i][j] == '#') continue;
            if (grid[i-1][j] != '#' && grid[i][j-1] != '#') {
                dp[i][j] = add(dp[i-1][j], dp[i][j-1]);
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    cout << dp[n-1][m-1];
}

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

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

    return 0;
}


Measured memory_bytes: 8204
import java.util.Scanner;
     
    public class Main {
     
    static Scanner sc = new Scanner(System.in);
    static int H, W;
    static int[][] f;
     
    static void solve() {
    int[] rsum = new int[H];
    int[] csum = new int[W];
    int all = 0;
    for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
    if (f[i][j] == 0) {
    ++rsum[i];
    ++csum[j];
    }
    }
    all += rsum[i];
    }
    if (all != 0 && H * W % 2 != 0) {
    System.out.println("Impossible");
    return;
    }
    boolean[][] ans = new boolean[H][W];
    for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
    ans[i][j] = (rsum[i] + csum[j] - f[i][j]) % 2 != 0;
    }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
    sb.append(ans[i][j] ? '0' : '1');
    if (j != W - 1) {
    sb.append(' ');
    }
    }
    sb.append('\n');
    }
    System.out.print(sb);
    }
     
    public static void main(String[] args) {
    H = sc.nextInt();
    W = sc.nextInt();
    f = new int[H][W];
    sc.nextLine();
    for (int i = 0; i < H; ++i) {
    String line = sc.nextLine();
    for (int j = 0; j < W; ++j) {
    f[i][j] = line.charAt(2 * j) - '0';
    }
    }
    solve();
    }
    }

Measured memory_bytes: 27000
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define mp make_pair
#define ll long long
IL int read(){int x;int _w=scanf("%d",&x);return x; }
IL void write(ll x){ printf("%lld\n",x); }
const int maxn=1e5+10;
int a[maxn];
int main() {
	int n=read();
	rep(i,1,n)a[i]=read();
	sort(a+1,a+1+n);
	int t=a[n],ans=0,p=0;
	rep(i,1,n-1)if(min(a[i],t-a[i])>ans)ans=min(a[i],t-a[i]),p=i;
	cout<<a[n]<<' '<<a[p]<<endl;
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint LCM(lint a,lint b){
  if(a==0 || b==0) return 0;
  lint tmp,r,x;
  x=a*b;
  if(a<b) tmp=a,a=b,b=tmp;
  r=a%b;
  while(r!=0) a=b,b=r,r=a%b;
  x=x/b;
  return x;
}

lint GCD(lint a,lint b){
  if(a==0 || b==0) return max(a,b);
  else return (a*b)/LCM(a,b);
}

lint segdata[(1<<19)-1];

lint neutral(){
    return 0;
}
lint calc(lint a,lint b){
    return GCD(a,b);
}
void seginit(){
    rep(i,(1<<19)-1) segdata[i]=neutral();
}
void update(lint i,lint x){ // i番目の値をxに更新
    i+=(1<<18)-1;
    segdata[i]=x;
    while(i>0){
        i=(i-1)/2;
        segdata[i]=calc(segdata[i*2+1],segdata[i*2+2]);
    }
}
lint seg(lint a,lint b,lint k,lint l,lint r){
    if(r<=a || b<=l) return neutral();
    if(a<=l && r<=b) return segdata[k];
    else{
        lint left=seg(a,b,k*2+1,l,(l+r)/2);
        lint right=seg(a,b,k*2+2,(l+r)/2,r);
        return calc(left,right);
    }
}
lint query(lint a,lint b){
    if(a>b) return 0;
    return seg(a,b+1,0,0,1<<18);
}

int main(void){
    seginit();
    int N;
    cin >> N;
    rep(i,N){
        int A;
        cin >> A;
        update(i,A);
    }
    lint ans=1;
    rep(i,N){
        lint left=query(0,i-1);
        lint right=query(i+1,N-1);
        ans=max(ans,GCD(left,right));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int kInfinity = 0x3F3F3F3F;
const int kNil = -1;
const int kMaxV = 10010;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
decltype(auto) ChuLiu(vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num,
                 typename vector<Edge>::size_type root) {
  using size_type = typename vector<Edge>::size_type;
  using const_it = typename vector<Edge>::const_iterator;
  using w_type = typename Edge::w_type;

  w_type weight_sum{0};
  vector<w_type> min_in(node_num, kInfinity);
  vector<int> parent(node_num, kNil);

  while (1) {
    min_in = vector<w_type>(node_num, kInfinity);
    parent = vector<int>(node_num, kNil);

    for (const auto & e: edges) {
      if (e.w < min_in[e.v] && e.u != e.v) {
        min_in[e.v] = e.w;
        parent[e.v] = e.u;
      }
    }
    min_in[root] = 0;

    // Impossible
    // for (unsigned i = 0; i < node_num; ++i) {
    //   if (min_in[i] == kInfinity) { cout << "IMPOSSIBLE\n"; }

    size_type group_count = 0;
    vector<int> new_no(node_num, kNil);
    vector<int> group(node_num, kNil);
    for (unsigned i = 0; i < node_num; ++i) {
      if (i == root) { continue; }
      weight_sum += min_in[i];
      auto j = i;
      while (group[j] != i && new_no[j] == kNil && j != root) {
        group[j] = i;
        j = parent[j];
      }
      if (new_no[j] == kNil && j != root) {
        // contract the circuit
        auto k = j;
        do {
          new_no[k] = group_count;
          k = parent[k];
        } while (k != j);
        ++group_count;
      }
    }

    if (group_count == 0) { break; }
    // new graph
    for (unsigned i = 0; i < node_num; ++i) {
      if (new_no[i] == kNil) {
        new_no[i] = group_count++;
      }
    }
    for (auto & e: edges) {
      auto origin_v = e.v;
      e.u = new_no[e.u];
      e.v = new_no[e.v];
      if (e.u != e.v) {
        e.w -= min_in[origin_v];
      }
    }
    node_num = group_count;
    root = new_no[root];
  }

  return weight_sum;
}

int main(int argc, char const *argv[]) {
  vector<Edge<unsigned>> edges;
  unsigned V, E, r;
  cin >> V >> E >> r;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    unsigned w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }
  cout << ChuLiu(edges, V, r) << endl;
  return 0;
}

Measured memory_bytes: 3120
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endN "\n"

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

bool solve(){
  ll x,y;cin>>x>>y;
  if(abs(x-y)<=1)cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    long x=1, y=1;
    for (int i=0; i<N; i++){
        long T, A, p, q;
        cin >> T >> A;
        p = (x + T - 1)/T;
        q = (y + A -1)/A;
        x = T * max(p, q);
        y = A * max(p, q);
    }

    cout << x + y << endl;
    return 0;
}

Measured memory_bytes: 3592
/*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { x = (x > y ? y: x);}
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { x = (x < y ? y: x);}
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
using ll = long long;
const string FILENAME = "input";
const int Mod = 998244353;


int n;
string s;
vector<int> pos[3];
int cnt[8];


int get(char c) {
    if (c == 'R') {
        return 0;
    }
    if (c == 'G') {
        return 1;
    }
    return 2;
}


int mul(int a, int b) {
    return (1LL * a * b) % Mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  //  read(FILENAME); 
    cin >> n;
    n *= 3;
    cin >> s;
    cnt[0] = n / 3;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        int c = get(s[i]);
        int cand = -1;
        for (int j = 0; j < 7; j++) {
            if (cnt[j]) {
                if (((1 << c) ^ j) > j) {
                    cand = j;
                }
            }
        }
        ans = mul(ans, cnt[cand]);
        cnt[cand]--;
        cnt[cand ^ (1 << c)]++; 
    }
    cout << ans << '\n';
    return 0; 
}




Measured memory_bytes: 720
T = input()
count = 0

for c in T:
  count += 1
  if c == '?' and T[count-1] == 'D':
    c = 'P'
    print(c, end="")
  elif c == '?':
    c = 'D'
    print(c, end="")
  else:
    print(c, end="")

Measured memory_bytes: 9336
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
const int N = 510000;
int n, k, ind[N];
int a[N], b[N];
set<int>f, g;
struct Edge {
	int to;
	Edge *next;
}*h[N], e[N<<2];
int _;
inline void add(int u, int v) {
	Edge *tmp = &e[++_];
	tmp -> to = v;
	tmp -> next = h[u];
	h[u] = tmp;
}
inline char nc() {
	static char buf[100000], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf, 1, 100000, stdin)), p1==p2?EOF:*p1++;
}
int read() {
	int x = 0; char ch = nc();
	while(!isdigit(ch)) ch = nc();
	while(isdigit(ch)) x = x*10+ch-48, ch = nc();
	return x;
}
int main() {
	n = read(), k = read();
	for(int i = 1; i <= n; i ++ ) b[a[i]=read()] = i;
	for(int i = 1; i < k; i ++ ) f.insert(a[i]);
	for(int i = 1; i <= n; i ++ ) {
		if(i+k-1 < n) f.insert(a[i+k-1]);
		f.erase(a[i-1]);
		g.insert(a[i]);
		if(i > k) g.erase(a[i-k]);
		set<int>::iterator cur;
		cur = f.upper_bound(a[i]);
		if(cur != f.end())
			add(b[*cur], i), ind[i]++;
		cur = g.upper_bound(a[i]);
		if(cur != g.end()) {
			add(b[*cur], i), ind[i]++;
		}
	}
	f.clear();
	for(int i = 1; i <= n; i ++ ) if(!ind[i]) f.insert(-i);
	int top = 0;
	while(f.size()) {
		int  u = -(*f.begin());
		a[++top] = u;
		f.erase(f.begin());
		for(Edge *i = h[u]; i; i = i->next) {
			if(--ind[i->to] == 0) {
				f.insert(-i->to);
			}
		}
	}
	for(int i = 1; i <= n; i ++ ) {
		b[a[i]] = n-i+1;
	}
	for(int i = 1; i <= n; i ++ ) cout << b[i] << endl;
}


Measured memory_bytes: 54528
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()

// greedy
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  ll ans = 1000;
  rep(i, N - 1)
  {
    if (A[i] < A[i + 1])
    {
      auto x = A[i + 1] - A[i];
      auto n = ans / A[i];
      ans += x * n;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int a, b, c,m,j,e;
	e=0;
	scanf("%d",&a);
	int d[a];
		for(b=0;b<a; b++)
	{
		scanf("%d",&d[b]);
	}
	for(b=0;b<a; b++)
	{
		m=b;
		for(j=b; j<a; j++)
		{
			if(d[j]<d[m])
			{
				m=j;
			}
		}
			if(d[b]!=d[m])e++;
				c=d[b];
				d[b]=d[m];
				d[m]=c;
		
	}
	
	for( int b = 0; b < a; b++)
	{
		if(b != a-1) printf("%d ",d[b]);
			else{printf("%d\n",d[b]);}
	}
	
	printf("%d\n",e);
	return 0;
}


Measured memory_bytes: 2040
x=int(input())

if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

int n,cnt=1; cin>>n;
  map<int,int> m;
  int tmp=n;
  while(1){
    if(!m.count(tmp)){
      m[tmp]=1;
      if(tmp%2==0)tmp/=2;
      else tmp= tmp*3+1;
      cnt++;
    }
    else {cout<<cnt<<endl;break;}
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect

a,b,q = map(int,readline().split())
s = [int(readline()) for i in range(a)]
t = [int(readline()) for i in range(b)]

for i in range(q):
  x = int(input())
  ss = bisect(s,x)
  if ss == 0:
    sR = s[0]
    sL = s[0]
  elif ss == len(s):
    sR = s[-1]
    sL = s[-1]
  else:
    sR = s[ss]
    sL = s[ss-1]
    
  sRt = bisect(t,sR)
  sLt = bisect(t,sL)
  if sRt == 0:
    sRtL = t[0]
  else:
    sRtL = t[sRt-1]
  if sLt == len(t):
    sLtR = t[-1]
  else:
    sLtR = t[sLt]
  if sRt == len(t):
    sRtR = t[-1]
  else:
    sRtR = t[sRt]
  if sLt == 0:
    sLtL = t[0]
  else:
    sLtL = t[sLt-1]
  chk = min(abs(x-sL)+abs(sL-sLtL),abs(x-sL)+abs(sL-sLtR),abs(x-sR)+abs(sR-sRtR),abs(x-sR)+abs(sR-sRtL))
  ss = bisect(t,x)
  if ss == 0:
    sR = t[0]
    sL = t[0]
  elif ss == len(t):
    sR = t[-1]
    sL = t[-1]
  else:
    sR = t[ss]
    sL = t[ss-1]
  sRt = bisect(s,sR)
  sLt = bisect(s,sL)
  if sRt == 0:
    sRtL = s[0]
  else:
    sRtL = s[sRt-1]
  if sLt == len(s):
    sLtR = s[-1]
  else:
    sLtR = s[sLt]
  if sRt == len(s):
    sRtR = s[-1]
  else:
    sRtR = s[sRt]
  if sLt == 0:
    sLtL = s[0]
  else:
    sLtL = s[sLt-1]  
  chk = min(chk,abs(x-sL)+abs(sL-sLtL),abs(x-sL)+abs(sL-sLtR),abs(x-sR)+abs(sR-sRtR),abs(x-sR)+abs(sR-sRtL))
  print(chk)

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

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> ans;
    vector<int> road(n+1, -1);
    int tail = 0;
    int roop = 1;

    int i = 1;
    while (road[i] == -1) {
        road[i] = ans.size();
        ans.push_back(i);
        i = a[i - 1];
    }
    roop = ans.size() - road[i];
    tail = road[i];

    if (k < tail) cout << ans[k] << '\n';
    else {
        k -= tail;
        k %= roop;
        cout << ans[tail + k] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define R register
using namespace std;
typedef long long LL;
int u,n,C,D;LL l,ll,r,rr;
int main(){
	cin>>n>>C>>D;u=C-D;cin>>C>>D;--n;ll=(LL)C*n,
	rr=(LL)D*n;for (R int i=n; ~i; --i){
		if (l+ll<=u&&u<=r+rr) return 0*puts("YES");
		ll-=C;rr-=D;
		l-=D;r-=C;
	}puts("NO");
}

Measured memory_bytes: 256
N = int(input())

dp = [[0] * 3 for _ in range(N)]

for i in range(N):
    abc = list(map(int, input().split()))
    if i == 0:
        dp[i] = abc
    else:
        for j in range(3):
            dp[i][j] = max([dp[i-1][k] for k in range(3) if k != j]) + abc[j]

print(max(dp[N-1]))

Measured memory_bytes: 22772
A, B, K = list(map(int, input().split()))

for i in range(K):
    if i%2==0:
        if A%2==1:
            A -= 1
        n = int(A//2) 
        A -= n
        B += n
    else:
        if B%2==1:
            B -= 1
        n = int(B//2) 
        B -= n
        A += n
print(A, B)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	ans := math.MaxInt32
	for k := min(a); k <= max(a); k++ {
		cnt := 0
		for _, ai := range a {
			cnt += pow(ai-k, 2)
		}
		ans = min([]int{ans, cnt})
	}
	fmt.Println(ans)
}

func min(a []int) (result int) {
	for i, v := range a {
		if i == 0 || v < result {
			result = v
		}
	}
	return
}

func max(a []int) (result int) {
	for i, v := range a {
		if i == 0 || v > result {
			result = v
		}
	}
	return
}

func pow(a, x int) int {
	result := 1
	for i := 0; i < x; i++ {
		result *= a
	}
	return result
}


Measured memory_bytes: 512
n = int(input())
a = [0]*n
max1=0
max2=0

for i in range(n):
    a[i] = int(input())
    if max1 < a[i]:
        max1 = a[i]
    elif max2 < a[i]:
        max2 = a[i]
for i in range(n):
    if max1 == a[i]:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 12508
# coding: utf-8
# Your code here!
N=int(input())
M=[]
for i in range(2):
    M.append(list(map(int,input().split())))
ans=M[0][0]+sum(M[1])
m1=[0]*N
m2=[0]*N
m1[0]=M[0][0]
m2[0]=M[1][0]
for i in range(N-1):
    m1[i+1]=m1[i]+M[0][i+1]
    m2[i+1]=m2[i]+M[1][i+1]
for i in range(1,N):
    ans=max(ans,m1[i]+m2[N-1]-m2[i-1])
print(ans)

Measured memory_bytes: 3064
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

A = np.array(A)
ans = 0
while all(A % 2 == 0):
    A //= 2
    ans += 1
print(ans)


Measured memory_bytes: 12508
def gcd(n,m):
  if n>m:
    return gcd(m,n);
  if n==0:
    return m;
  return gcd(m-n*(m//n),n)

def lcm(x, y):
    return (x * y) // gcd(x, y)
  
n=int(input())
a=list(map(int,input().split()))
s=1
for i in a:
  s=lcm(s,i)
ans=0
for i in a:
  ans+=s//i
print(ans % 1000000007)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
/*
 * 自明
 */

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll n,k;
	cin>>n>>k;
	if(k%2==1){
	    ll p=0;
	    for(int i=k;i<=n;i+=k)p++;
	    cout<<p*p*p<<endl;
	}else{
	    ll p=0,q=0;
	    for(int i=k;i<=n;i+=k)p++;
	    for(int i=k/2;i<=n;i+=k)q++;
	    cout<<p*p*p+q*q*q<<endl;
	}
	
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int a,sum=0;
    rep(i,3)
    {
        cin>>a;
        sum+=a;
    }
    if(sum>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> a(N+1, 0);
  a[0]=2; a[1]=1;
  for (int i=2; i<=N; i++) {
    a[i]=a[i-2]+a[i-1];
  }
  cout << a[N] << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

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

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    string s;
    cin >> s;
    vector<int> a(3,0);
    rep(i,s.size()){
        a[s[i]-'a']++;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    if(a[0]-1<=a[2]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<map>

int n,m,a,b,w;

int main(){
	std::map<int, int> br;
	std::map<int, int>::iterator it;
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			std::cin >> m >> a >> b;
			if(br.find(a) == br.end())
				br[a] = 0;
			if(br.find(b) == br.end())
				br[b] = 0;
			br[a] += m;
			br[b] -= m;
		}
		it = br.begin();
		int w=0;
		while(it != br.end()){
			w += (*it).second;
			if(w > 150){
				std::cout << "NG\n";
				break;
			}
			it++;
		}
		if(it == br.end())
			std::cout << "OK\n";
		br.clear();
	}
}

Measured memory_bytes: 0
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
GA, SA, BA = list(map(int, sys.stdin.readline().split()))
GB, SB, BB = list(map(int, sys.stdin.readline().split()))


def knapsack(n, ga, sa, ba, gb, sb, bb):
    values = []
    weights = []
    if gb / ga > 1:
        values.append(gb - ga)
        weights.append(ga)
    if sb / sa > 1:
        values.append(sb - sa)
        weights.append(sa)
    if bb / ba > 1:
        values.append(bb - ba)
        weights.append(ba)
    if len(values) == 3:
        # dp[i]: 重さ i 以下で選ぶのの価値の最大値
        dp = [0] * (n + 1)
        dp[0] = n
        for i in range(1, n + 1):
            x = dp[i - 1]
            for w, v in zip(weights, values):
                if i - w >= 0:
                    x = max(x, dp[i - w] + v)
            dp[i] = x
        return dp[n]
    if len(values) == 2:
        w1, w2 = weights
        v1, v2 = values
        if (v1 + w1) / w1 < (v2 + w2) / w2:
            v1, v2 = v2, v1
            w1, w2 = w2, w1
        c1 = n // w1
        c2 = (n - w1 * c1) // w2
        ret = n + v1 * c1 + v2 * c2
        while c1 >= 0:
            a = n - w1 * c1 - w2 * c2
            c1 -= max(1, math.ceil((w2 - a) / w1))
            c2 = (n - w1 * c1) // w2
            ret = max(ret, n + v1 * c1 + v2 * c2)
            if w1 * c1 + w2 * c2 == n:
                break
        return ret
    if len(values) == 1:
        return n + n // weights[0] * values[0]
    return n


ans = knapsack(N, GA, SA, BA, GB, SB, BB)
ans = knapsack(ans, GB, SB, BB, GA, SA, BA)
print(int(ans))


Measured memory_bytes: 3192
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

int student[100001];

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
    int temp;    // 値を一時保存する変数
    
    temp = *x;
    *x = *y;
    *y = temp;
    
    return;
}

/***
 * pivotを決め、
 * 全データをpivotを境目に振り分け、
 * pivotの添え字を返す
 ***/
int partition (int array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;   // 先頭要素をpivotとする
    
    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        // pivotより小さいものを左へ、大きいものを右へ
        if (i < j) {
            swap(&array[i], &array[j]);
            swap(&student[i],&student[j]);
        }
    } while (i < j);
    
    swap(&array[pivot], &array[j]);   //pivotを更新
    swap(&student[pivot],&student[j]);
    
    return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
    int pivot;
    
    if (left < right) {
        pivot = partition(array, left, right);
        quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
        quick_sort(array, pivot+1, right);
    }
}

int main(void){
    int i,j;
    int N,K,h[100001];
    int answer = 0;
   
    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&h[i]);
        student[i] = i+1;
    }
    scanf("%d",&h[i]);
    student[i] = i+1;
    
    quick_sort(h,0,N-1);
    
    for(i = 0;i < N;i++){
        printf("%d ",student[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N,x;cin >> N >> x;
    vector<LL> a(N);
    rep(i,N)cin >> a[i];
    LL ct = 0;

    rep(i,N-1){
        if(a[i] > x){
            LL t  = a[i] - x;
            ct += t;
            a[i] = x;
        }
        LL tmp = a[i] + a[i+1];
        if(tmp > x){
            LL t2 = tmp - x;
            ct += t2;
            a[i+1] = a[i+1] - t2;
        }
    }

    cout << ct << endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int a, b;
  char op;

  while(1){
    cin  >> a >> op >> b;
    if ( op == '?') break;
    
    if ( op == '+') cout << a + b << endl;
    else if ( op == '-') cout << a - b << endl;
    else if ( op == '*') cout << a * b << endl;
    else cout << a / b << endl;
  }
  
  return 0;

}


Measured memory_bytes: 3052
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)3e5 + 5;
const int mod = (int)1e9 + 7;
using namespace std;

int main()
{
	int a, b; 
	cin >> a >> b;
	int ans = max(max(a + b, a - b), a * b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
   # 作りたい要素数nで初期化
   # 使用するインスタンス変数の初期化
   def __init__(self, n):
       self.n = n
       # root[x]<0ならそのノードが根かつその値が木の要素数
       # rootノードでその木の要素数を記録する
       self.root = [-1]*(n+1)
       # 木をくっつける時にアンバランスにならないように調整する
       self.rnk = [0]*(n+1)
   # ノードxのrootノードを見つける
   def Find_Root(self, x):
       if(self.root[x] < 0):
           return x
       else:
           # ここで代入しておくことで、後の繰り返しを避ける
           self.root[x] = self.Find_Root(self.root[x])
           return self.root[x]
   # 木の併合、入力は併合したい各ノード
   def Unite(self, x, y):
       # 入力ノードのrootノードを見つける
       x = self.Find_Root(x)
       y = self.Find_Root(y)
       # すでに同じ木に属していた場合
       if(x == y):
           return
       # 違う木に属していた場合rnkを見てくっつける方を決める
       elif(self.rnk[x] > self.rnk[y]):
           self.root[x] += self.root[y]
           self.root[y] = x
       else:
           self.root[y] += self.root[x]
           self.root[x] = y
           # rnkが同じ（深さに差がない場合）は1増やす
           if(self.rnk[x] == self.rnk[y]):
               self.rnk[y] += 1
   # xとyが同じグループに属するか判断
   def isSameGroup(self, x, y):
       return self.Find_Root(x) == self.Find_Root(y)
   # ノードxが属する木のサイズを返す
   def Count(self, x):
       return -self.root[self.Find_Root(x)]
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
h=UnionFind(n)
d=[0]*(2*n-2)
for i in range(n-1):
    d[i]=[i,i+1,min(b,a*(x[i+1]-x[i]))]
    d[i+n-1]=[i,n-1,b]
d.sort(key=lambda x:x[2])
cnt = 0
for i in d:
    if not h.isSameGroup(i[0],i[1]):
        h.Unite(i[0],i[1])
        cnt += i[2]
print(cnt)

Measured memory_bytes: 44040