akhauriyash/Code-Regression huggingface dataset:
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    li = get_list()
    li.sort()
    if li[0]==li[1]!=li[2] or li[0]!=li[1]==li[2]:
        print("Yes")
    else: print("No")


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


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

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 long long inf = 1e9+7;
const long long mod = 1e9+7;

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

    int t=0,ans=0;
    rep2(i,1,x){
        ans++;
        t+=ans;
        if(t>=x)break;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3648
// AtCoder ABC122: C - GeT AC
// 2019.9.9 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

int  N;
int  a[100005];
char S[100005];

int main()
{
	int i, Q;
		
	N = in(), Q = in(), ins(S+1);
	for (i = 2; i <= N; i++) {
		if (S[i-1] == 'A' && S[i] == 'C') a[i] = a[i-1]+1;
		else a[i] = a[i-1];
	}
	
	while (Q--) {
		int l = in(), r = in();
		if (l == 1) out(a[r]);
		else if (a[l] != a[l-1]) out(a[r]-a[l-1]-1);
		else out(a[r]-a[l-1]);
	}
	return 0;
}


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

int main(){
  int a, b, count=0;
  cin >> a >> b;
  for(int i=a; i<=b; i++){
    if(i/10000 == i%10 && i%10000/1000 == i%100/10){
      count++;
    }
  }
  cout << count << endl;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

bool used[30];
bool used1[30];

string ma = "zyxwvutsrqponmlkjihgfedcba";

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        used[s[i]-'a'] = true;
    }
    if (s.size() < 26) {
        rep(i, 26) {
            if (!used[i]) {
                s += char('a'+i);
                break;
            }
        }
        cout << s << endl;
    }
    else {
        if (ma == s) {
            cout << -1 << endl;
            return 0;
        }
        vector<string> ret;
        if (s[0] < 'z') {
            string tmp = "";
            tmp += s[0];
            tmp[0]++;
            ret.push_back(tmp);
        }
        rep(i, s.size()) {
            used1[s[i]-'a'] = true;
            string tmp = "";
            tmp += s.substr(0, i+1);
            rep(j, 26) {
                if (!used1[j]) {
                    string tmp2 = tmp + char('a'+j);
                    ret.push_back(tmp2);
                }
            }
        }
        sort(ret.begin(), ret.end());
        rep(i, ret.size()) {
            if (s < ret[i]) {
                cout << ret[i] << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String _s = s.toLowerCase();
        boolean f = (s.charAt(0) == 'A');
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'C'){
                if(i <= 1 || i == s.length()-1){
                    f = false;
                }
                cnt++;
            }else{
                if(i != 0){
                    f = f & (s.charAt(i) == _s.charAt(i));
                }
            }
        }
        f = f & (cnt == 1);
        System.out.println(f?"AC":"WA");
        sc.close();
    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



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

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
s = input()

if len(s) == 1:
  print(0)
  exit()

left = 0
right = 0

count = 0
while True:
  if s[right+1] != s[left]:
    count += 1
    right += 1
    left = right
    if right == len(s) - 1:
      break
  else:
    right += 1
    if right == len(s) - 1:
      break

print(count)

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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define pi              3.1415926536
#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define printl(n)       printf("%lld\n", n)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define SIZE            100005
#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)

ll n, cap;
ll v[105], w[105];
ll dp[105][SIZE];

ll knapsack(ll in, ll weight) {
    if(in == n+1) return 0;
    if(dp[in][weight] != -1) return dp[in][weight];

    ll p1(0), p2(0);

    if(weight+w[in] <= cap) p1 = v[in] + knapsack(in+1, weight+w[in]);
    p2 = knapsack(in+1, weight);

    return dp[in][weight] = max(p1, p2);
}

int main() {
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    ms(dp, -1);

    scl2(n, cap);

    for1(i, n) scl2(w[i], v[i]);

    ans = knapsack(1, 0);
    printl(ans);

    return 0;
}



Measured memory_bytes: 82432
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

route = [1]
index = k
hit = set([1])
for i in range(n+1):
    _next = a[route[-1]]
    if _next in hit:
        route.append(_next)
        index -= (i+1)
        break
    route.append(_next)
    hit.add(_next)

if index <= 0:
    print(route[k])
else:
    route = route[route.index(route[-1]):-1]
    print(route[index % len(route)])


Measured memory_bytes: 126816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<bool> ans(100001,false);
    rep(i,n){
      int l,r;
      cin>>l>>r;
      FOR(j,l,r+1){
        ans[j]=true;
      }
    }
    cout<<count(begin(ans),end(ans),true)<<endl;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

s = input()
idxs = [[] for i in range(26)]
def wid(w):
    return ord(w)-ord("a")
for i in range(len(s)):
    w = s[i]
    idxs[wid(w)].append(i)
a=-1
b=-1
for i in range(26):
    if len(idxs[i])>=2:
        prev = idxs[i][0]
        for nex in idxs[i]:
            d = nex-prev
            if 1<=d<=2:
                a=prev+1
                b=nex+1
                break
            prev=nex
print(a,b)


Measured memory_bytes: 13684
#include<stdio.h>
#include<math.h>
long long int f(long long int n)
{
	if (n < 2)
		return 1;
	long long int i;
	for (i = 2; i <= sqrt(n); i++)
		if (n % i == 0)
			return i;
	return n;
}
int main()
{
	long long int n, p;
	scanf("%lld %lld", &n, &p);
	long long int ans = 1;
	long long int count, x;
	while (p > 1)
	{
		x = f(p);
		count = 0;
		while (p % x == 0)
		{
			count++;
			p /= x;
		}
		while (count >= n)
		{
			ans *= x;
			count -= n;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n;
  cin >> n;

  if(n%2 == 0) cout << n/2-1 << endl;
  else cout << n/2 << endl;

  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, n[4], op = 0;
	{
		string s;
		cin >> s;
		for (i = 0; i < 4; i++) n[i] = s[i] - '0';
	}
	for (op = 0; op < 8; op++){
		int N = n[0], p = 4;
		for (i = 0; i < 3; i++){
			if (op / p % 2 == 0) N += n[i + 1];
			else N -= n[i + 1];
			p /= 2;
		}
		if (N == 7){
			cout << n[0];
			p = 4;
			for (i = 0; i < 3; i++){
				if (op / p % 2 == 0) cout << "+" << n[i + 1];
				else cout << "-" << n[i + 1];
				p /= 2;
			}
			cout << "=7" << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;
const int mod = 998244353;
ll ans[200005];
int c[200005];
ll cnt[200005];
ll cur[200005];
ll sz[200005];
vector<int>g[200005];
void dfs(int now, int pre) {
    sz[now] = 1;
    int in = cur[c[now]];
    for (auto i : g[now]) {
        if (i == pre) continue;
        int be = cur[c[now]];
        dfs(i, now);
        int af = cur[c[now]];
        int mt = sz[i] - (af-be);
        ans[c[now]] -= cnt[mt];
        sz[now] += sz[i];
    }
    cur[c[now]] = in + sz[now];
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    f1 (n) {
        ans[i] = n * (n + 1) / 2;
        cnt[i] = (ll)i * (i + 1) / 2;
        cin >> c[i];
    }
    f (n - 1) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1, 0);
    f1 (n) {
        ans[i] -= cnt[n - cur[i]];
        cout << ans[i] << '\n';
    }
}


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

plan = True

pret = 0
prex = 0
prey = 0
for i in range(N):
    t,x,y = (int(k) for k in input().split())
    distance = abs(prex - x) + abs(prey - y)
    if distance > (t - pret):
        plan = False
    elif (distance - (t - pret)) % 2 != 0:
        plan = False
    pret = t
    prex = x
    prey = y

if plan:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
vector<int>mmp[M];
int col[M],du[M],val[M],dp1[M],dp2[M],n,rt,tot,more;
bool allb[M];
char ch[M];
void in()
{
    int a,b;
    scanf("%d",&n);
    for(int i=1;i<n;++i)
    scanf("%d%d",&a,&b),mmp[a].push_back(b),mmp[b].push_back(a);
    scanf("%s",ch+1);
    for(int i=1;i<=n;++i)col[i]=ch[i]=='W'?0:1,rt=col[i]?rt:i;
}
void dfs(int v,int f)
{
    allb[v]=col[v];int to;
    for(int i=mmp[v].size()-1;i>=0;--i)
    {
        to=mmp[v][i];if(to==f)continue;
        dfs(to,v);
        if(!allb[to])++du[v],++du[to];
        allb[v]&=allb[to];
    }
}
void dp(int v,int f)
{
    tot+=du[v];
    if((du[v]+col[v])&1)val[v]=0;
    else val[v]=2,++tot;
    int mx1=0,mx2=0,to;bool flag=0;
    for(int i=mmp[v].size()-1;i>=0;--i)
    {
        to=mmp[v][i];if(to==f||allb[to])continue;
        flag=1;dp(to,v);
        more=max(more,max(dp1[to]+mx2+val[v],dp2[to]+mx1+val[v]));
        mx1=max(dp1[to],mx1);mx2=max(dp2[to],mx2);
    }
    dp1[v]=mx1+val[v];dp2[v]=flag?mx2+val[v]:-INT_MAX;
}
void ac()
{
    dfs(rt,0);dp(rt,0);
    if(rt)printf("%d",tot-more);
    else printf("0");
}
int main()
{
    in();ac();
    return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct RUQ{
	using T = int;
	T operator()(const T &a, const T &b) { return min(a,b); };
	static constexpr T identity() { return INT_MAX; }
};

template<class Monoid>
class rangeUpdateQuery{
	private:
		using T = typename Monoid::T;
		Monoid op;
		const int n;
		vector<T> dat, lazy;
		int query(int a, int b, int k, int l, int r){
			evaluate(k);

			if(b <= l || r <= a) return INT_MAX;
			else if(a <= l && r <= b) return dat[k];
			else{
				int vl = query(a, b, k * 2, l, (l + r) / 2);
				int vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
				return min(vl, vr);
			}
		}
		inline void evaluate(int k){
			if(lazy[k] == op.identity()) return;
			dat[k] = lazy[k];
			if(k < n){
				lazy[2 * k] = lazy[k];
				lazy[2 * k + 1] = lazy[k];
			}
			lazy[k] = op.identity();
		}
		void update(int a, int b, int k, int l, int r, int x){
			evaluate(k);
			if(r <= a || b <= l) return;
			if(a <= l && r <= b){
				lazy[k] = x;
			}else if(l < b && a < r){
				evaluate(k);
				update(a, b, k * 2, l, (l + r) / 2, x);
				update(a, b, k * 2 + 1, (l + r) / 2, r, x);
			}
		}
		int power(int n){
			int res = 1;
			while(n >= res) res*=2;
			return res;
		}
	public:
		rangeUpdateQuery(int n) : n(power(n)), dat(4 * n, op.identity()), lazy(4 * n, op.identity()) {}
		rangeUpdateQuery(const vector<T> &v) : n(v.size()), dat(4 * n), lazy(4 * n, op.identity()){
			copy(begin(v), end(v), begin(dat) + n);
			for(int i = n - 1; i > 0; i--) dat[i] = op(dat[2 * i], dat[2 * i + 1]);
		}
		int query(int a, int b){ return query(a,b,1,0,n); }
		void update(int s, int t, int x){ update(s, t, 1, 0, n, x); }
		int get(int a){ return query(a, a + 1); };
};

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

	rangeUpdateQuery<RUQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(not com){
			int s, t, x;
			cin >> s >> t >> x;
			//cout << s << ' ' << t << endl;
			seg.update(s + 1, t + 2, x);
		}else{
			int p;
			cin >> p;
			cout << seg.get(p + 1) << endl;
		}
	}
}



Measured memory_bytes: 5968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main()
{
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < n; i++)
    {
        cout << s.at(i) << t.at(i);
    }

    cout << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[200000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


Measured memory_bytes: 7060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll L, R;
  while (cin >> L >> R) {
    int M = 2019;
    vector<ll> mini(M), maxi(M);
    for (int i = 0; i < M; i++) mini[(L + i) % M] = L + i;
    for (int i = 0; i < M; i++) maxi[((R - i) % M + M) % M] = R - i;
    int res = M;
    for (int mi = 0; mi < M; mi++) {
      for (int mj = 0; mj < M; mj++) {
        int i = mini[mi], j = maxi[mj];
        if (L <= i && i < j && j <= R) {
          res = min(res, mi * mj % M);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

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

  int n = s.size();
  if (n <= k) {
    cout << s << endl;
  } else {
    rep(i,k) {
      cout << s[i];
    }
    cout << "..." << endl;
  }

}


Measured memory_bytes: 3608
#include <stdio.h>
#define MAX 45

int main(){

  int n,i,ans;
  int fib[MAX];

  scanf("%d",&n);

  fib[0] = 1;
  fib[1] = 1;

  if(n != 0 || n != 1){
    for(i = 2 ; i <= n ; i++){
      fib[i] = fib[i-1] + fib[i-2];
    }
  }
  
  printf("%d\n",fib[n]);

  return 0;

}



Measured memory_bytes: 2056
R,C,K=map(int,input().split())
m=[[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
  r,c,v=map(int,input().split())
  m[r][c]=v
d=[[0]*4 for _ in range(R+1)]
for j in range(1,C+1):
  for i in range(1,R+1):
    t=m[i][j]
    if t>0:
      d[i][3]=max(d[i][3],d[i][2]+t)
      d[i][2]=max(d[i][2],d[i][1]+t)
      d[i][1]=max(d[i][1],d[i][0]+t,max(d[i-1])+t)
      d[i][0]=max(d[i][0],max(d[i-1]))
    else:
      d[i][0]=max(d[i][0],max(d[i-1]))
print(max(d[R]))

Measured memory_bytes: 141208
import java.util.*;

public class Main {
    static int n;
    static int m;
    static List<List<Integer>> children;
    static int[] degree;


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        children = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            children.add(new ArrayList<>());
        }
        degree = new int[n];
        for (int i = 0; i < m+n-1; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            degree[b]++;
            children.get(a).add(b);
        }
        List<Integer> sorted = new ArrayList<>();
        Queue<Integer> s = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            if(degree[i] == 0) {
                s.add(i);
                sorted.add(i);
            }
        }
        while (!s.isEmpty()) {
            int node = s.poll();
            for (Integer child: children.get(node)) {
                if(--degree[child] == 0) {
                    s.add(child);
                    sorted.add(child);
                }
            }
        }
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int node = sorted.get(n- i-1);
            for(Integer child: children.get(node)) {
                if(ans[child] == 0) {
                    ans[child] = node + 1;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(ans[i]);
        }
    }


}

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

using namespace std;

int n, m, ans;
vector<int> to[9];
bool visit[9];

void dfs(int from) {
	for (int i = 1; i <= n; ++i) {
		if (visit[i] == false) {
			break;
		}
		if (i == n) {
			ans++;
			return;
		}
	}

	for (int i = 0; i < to[from].size(); ++i) {
		if (visit[to[from][i]] == false) {
			visit[to[from][i]] = true;
			dfs(to[from][i]);
			visit[to[from][i]] = false;
		}
	}
}

int main() {
	int a, b;

	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	visit[1] = true;
	dfs(1);

	cout << ans << endl;

	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,K;
	cin >> n >> K;

	vector<int> v[10];
	rep(i,0,n){
		int c,g;
		cin >> c >> g;
		--g;
		v[g].push_back(c);
	}

	rep(i,0,10) sort(v[i].rbegin(),v[i].rend());

	vector<int> s[10];
	rep(i,0,10){
		s[i].resize(v[i].size()+1);
		rep(j,1,s[i].size()){
			s[i][j]=s[i][j-1]+v[i][j-1]+2*(j-1);
		}
	}

	rep(i,0,10) dump(s[i]);

	//static vector<vector<int>> dp(10,vector<int>(K+1));
	static int dp[10][3000];
	rep(i,0,s[0].size()) dp[0][i]=s[0][i];
	rep(i,1,10){
		rep(j,0,s[i].size()){
			for(int k=0; k+j<=K; ++k){
				dp[i][j+k]=max(dp[i][j+k],dp[i-1][k]+s[i][j]);
			}
		}
	}

	rep(i,0,10) dump(dp[i]);

	cout << dp[9][K] << endl;
}

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

Measured memory_bytes: 1344
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> tmp(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        tmp[i] = a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    for (int i = 0; i < n; i++)
    {
        if (a[0] == tmp[i])
        {
            cout << a[1] << endl;
        }
        else
        {
            cout << a[0] << endl;
        }
    }
}

Measured memory_bytes: 4736
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;


int main() {
 int n,ans;
  cin >> n;
  ans=1;
  
  vector<int> vec(n);
  cin >> vec.at(0);
  for(int i=1;i<n;i++){
    cin >> vec.at(i);
    bool tmp=true;
    for(int j=0;j<i;j++){
      if(vec.at(j)>vec.at(i)){
        tmp=false;
        break;
      }
    }
    if(tmp){
      ans++;
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto&p:mp){
        int pf=p.first,ps=p.second;
        if(pf==ps)continue;
        if(pf<ps)ans+=ps-pf;
        if(pf>ps)ans+=ps;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4736
namespace ABC124_C
{
    using System;
    using System.Linq;
    using static System.Console;

    public class Program
    {
        public static void Main(string[] args)
        {
            var input = ReadLine();
            WriteLine(Solve(input));
        }

        public static int Solve(string input)
        {
            var rep1 = input.Where((c, i) => (c == '1') != (i % 2 == 0)).Count();
            var rep2 = input.Where((c, i) => (c == '1') != (i % 2 == 1)).Count();
            return Math.Min(rep1, rep2);
        }
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin >> N >> M;
    vector<int> Ans(N);
    REP(i,M*2){
        int x;
        cin >> x;
        Ans.at(x-1)++;
    }
    REP(i,N){
        cout << Ans.at(i) <<  "\n";
    }
}

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

int main() {
	int n, input;
	int min, max;
	long long int sum=0;

	cin >> n;
	
	for(int i=0; i<n; i++) {
		cin >> input;
		if(i==0) {
			min = input;
			max = input;
		}
		
		if(input > max) max = input;
		else if(input < min) min = input;

		sum += input;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstring>
#include <unordered_map>
#include <sstream>
using namespace std;
std::string to_binString(unsigned int val)
{
    if( !val )
        return std::string("0");
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 ) 
            str.insert(str.begin(), '0');  
        else
            str.insert(str.begin(), '1');  
        val >>= 1;
    }
    return str;
}
std::string to_binString2(unsigned int val, int n)
{
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  
            str.insert(str.begin(), '0');
        else
            str.insert(str.begin(), '1');
        val >>= 1;
    };
    while (str.size() != n) {
      str.insert(str.begin(), '0');
    }
    return str;
}
int jpre(string a, string b) 
{
  if ((a.find(b) == 0) || (b.find(a) == 0)){
    return 1;
  }
  return 0;

}
void nodup_push(vector<string>&newspace, string &b) 
{
  for (auto p : newspace) {
    if (jpre(p,b)) {
      cout << "  --  nodup_push (skipped): " << b << ", (because of p: " << p << ")" << endl;
      return ;
    }   
  }

  newspace.push_back(b);
  //a.insert(b);


}
void nodup_insert(set<string> &a, string b) 
{
  for (auto p : a) {
    if (jpre(p,b)) {
      return ;
    }
  }

  //a.push_back(b);
  a.insert(b);


}

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a+b) > (c+d))
    cout << "Left" << endl;
  else if ((a+b) == (c+d))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;

}

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

using namespace std;

struct Bulb {
    vector<int> xs;
    int p;
    friend istream& operator>>(istream& in, Bulb& b) {
        int k;
        cin >> k;
        b.xs = vector<int>(k);
        for (auto& x : b.xs) {
            cin >> x;
            --x;
        }
        return in;
    }
    bool is_on(int mask) {
        int r = 0;
        for (auto x : xs) {
            if (mask & (1 << x)) {
                r = 1-r;
            }
        }
        return r == p;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<Bulb> bulbs(m);
    for (Bulb& bulb : bulbs) {
        cin >> bulb;
    }
    for (Bulb& bulb : bulbs) {
        cin >> bulb.p;
    }
    int count = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        int bulb_mask = 0;
        for (Bulb& bulb : bulbs) {
            bulb_mask = 2*bulb_mask + bulb.is_on(mask);
        }
        if (bulb_mask+1 == (1 << m)) {
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,mx,mn;
	scanf("%d%d",&n,&mx);mn=mx;
	for(int i=1;i<n;i++)
	{
		int x;scanf("%d",&x);
		if(x>mx) mx=x;
		if(x<mn) mn=x;
	}
	printf("%d\n",mx-mn);
	return 0;
} 

Measured memory_bytes: 128
n, m = map(int, input().split())
l = [0]*n

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l[b] += 1
    elif b == n:
        l[a] += 1

for i in l:
    if i >= 2:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')



Measured memory_bytes: 76236
using System;


public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];

        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) a[i] = int.Parse(line[i]);
        var q = int.Parse(Console.ReadLine().Trim());
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        
        for (int i = 0; i < q; i++)
        {
            var targ = int.Parse(line2[i]);
            if (Solve(a, 0, targ)) Console.WriteLine("yes");
            else Console.WriteLine("no");
        }

    }
public static bool Solve ( int[] a ,int i , int m  )
    {
        if (m == 0) return true;
        if (i >= a.Length) return false;
        var res = Solve(a,i + 1, m) | Solve(a,i + 1, m - a[i]);
        return res;
    }


}

Measured memory_bytes: 8984
#include <bits/stdc++.h>
using namespace std;
#define int long long
//ask the right questions.		

// let dp[i][value] be the minimum capacity when deciding upon i th item that achieves  
// [value] quantity
int dp[101][100001];  //must declare outside in heap for large dp arrays!!!!!!!!

int32_t main() 
{
	int N, W;
	cin >> N >>W;
	int weights[N];
	int value[N];

	int x;
	for(int i=0;i<2*N;i++)
	{
		cin >> x;
		if(i%2==0)
		{
			weights[i/2]=x;
		}
		else
		{
			value[(i-1)/2]=x;
		}
	}

	//trivial case
	for(int i=0;i<=100000;i++)
 	{
 		dp[0][i]=INT_MAX;
 	}

 	//base case
 	for(int i=0;i<=N;i++)
 	{
 		dp[i][0]=0;
 	}

 	for(int i=1;i<=N;i++)
 	{
 		for(int j=1;j<=100000;j++)
 		{
 			if(j>=value[i-1])
 				dp[i][j] = min(dp[i-1][j], dp[i-1][j-value[i-1]] + weights[i-1]);
 			else
 				dp[i][j] = dp[i-1][j];
 		}
 	}

 	//check the maximum value achievable within our given W value
 	for(int i=100000;i>=0;i--)
 	{
 		if(dp[N][i]<=W)
 		{
 			cout << i <<endl;
 			break;
 		}
 	}
 	


	return 0;
	
}

Measured memory_bytes: 82540
#include<stdio.h>
int main(void)
{
  int num,eat,ans=0;
  scanf("%d%d",&num,&eat);
  int i,j,l,fav[eat],hito[num][eat],k[num];
  for(i=0;i<num;i++)
  {
    scanf("%d",&k[i]);
    for(j=0;j<k[i];j++)
    {
      scanf("%d",&hito[i][j]);
     // printf("%d ",hito[i][j]);
    }
    //j++;
    while(j<eat)
    {
      hito[i][j]=-1;
      //printf("%d ",hito[i][j]);
      j++;
    }
   // printf("\n");
  }
  for(i=0;i<eat;i++)
  {
    fav[i]=0;
  }
  
  for(i=0;i<num;i++)
  {
    for(j=0;j<eat;j++)
    {
      for(l=1;l<eat+1;l++)
      {
        if(hito[i][j]==l) fav[l-1]++;
      }
    }
  }
  for(i=0;i<eat;i++)
  {
    if(fav[i]==num)ans++;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import math

def search(w,h,data): 
    for i in range(h):
        if '@' in data[i]:
            stx,sty = i,data[i].index('@')

    stack = [[stx,sty]]
    check = [[stx,sty]]
    while True:
        if len(stack) != 0:
            s = stack[-1]
            Hnow,Wnow = s[0],s[1]
        else:
            return len(check)

        stack.pop()
        
        if Hnow < h-1:
            if (data[Hnow+1][Wnow] == '.') and ([Hnow+1,Wnow] not in check):
                stack.append([Hnow+1,Wnow])
                check.append([Hnow+1,Wnow])

        if Wnow < w-1:
            if (data[Hnow][Wnow+1] == '.') and ([Hnow,Wnow+1] not in check):
                stack.append([Hnow,Wnow+1])
                check.append([Hnow,Wnow+1])

        if Hnow > 0:
            if (data[Hnow-1][Wnow] == '.') and ([Hnow-1,Wnow] not in check):
                stack.append([Hnow-1,Wnow])
                check.append([Hnow-1,Wnow])

        if Wnow > 0:
            if (data[Hnow][Wnow-1] == '.') and ([Hnow,Wnow-1] not in check):
                stack.append([Hnow,Wnow-1])
                check.append([Hnow,Wnow-1])

a = []


while True:
    w,h = list(map(int,input().split()))
    if (w == 0)and(h == 0):
        break
    else:
        data = [list(input()) for l in range(h)]
        a.append(search(w,h,data))

for i in a:
    print(i)


Measured memory_bytes: 5736
#include<cstdio>

using namespace std;

int K, A, B;

void input(){
	scanf("%d%d%d", &K, &A, &B);
}

long long solve(){
	if(B <= A + 1) return K + 1;
	int d = B - A;
	if(K <= A) return K + 1;
	int t = (K - A + 1) / 2;
	int u = (K - A + 1) % 2;
	return A + (long long)d * t + u;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 100000
#define G 100000

int partition(int A[],int p,int r){
  int x,i,j,V,Q;

  x=A[r];
  i=p-1;

  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      V=A[i];
      A[i]=A[j];
      A[j]=V;
    }
  }
  Q=A[i+1];
  A[i+1]=A[r];
  A[r]=Q;

  return i+1;
}
      


int main(){
  int A[N],B[N],i,x,g;

  scanf("%d",&x);

  for(i=0;i<x;i++){
    scanf("%d",&A[i]);
  }
  g=partition(A,0,x-1);
  for(i=0;i<x-1;i++){
    if(i==g) printf("[%d]",A[g]);
    else printf("%d",A[i]);
    if(i>=0) printf(" ");
  }
  printf("%d\n",A[i]);
  return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

	return 0;
}


Measured memory_bytes: 3116
import sys
from collections import deque

sys.setrecursionlimit(10**9)


def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(lambda x: int(x)-1, input().split())
        edges[a].append(b)
        edges[b].append(a)

    cnt = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        cnt[p-1] += x

    visited = [False]*N
    visited[0] = True
    q = deque([0])
    while q:
        v = q.pop()
        for n in edges[v]:
            if visited[n]:
                continue
            visited[n] = True
            cnt[n] += cnt[v]
            q.append(n)
    print(*cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 56168
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)1e5 * 5 + 22;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int a, b;
int gcd (int x, int y)  {
    while (x != 0 && y != 0) {
        x %= y;
        if (x == 0) break;
        y %= x; 
    }
    return x + y;
}

main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> a >> b;
    int c = gcd(a, b), cnt = 0;
    for (int i = 2; i <= sqrt(c); ++i) {
        bool ok = 0;
        while (c % i == 0) {
            if (ok == 0) cnt++;
            c /= i;
            ok = 1;
        }
    }
    cnt++;
    if (c != 1) {
        cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;
    int64_t ans = 0;
    ans += min(A, K);
    if (K > A + B) ans -= min(C, K - A - B);
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll happiness[3];
  ll n,a,b,c,i,j,k;
  cin>>n;
  vector<ll>arr[n];
  for(i=0;i<n;i++)
  {
    cin>>a>>b>>c;
    arr[i].push_back(a);
    arr[i].push_back(b);
    arr[i].push_back(c);
  }
  for(i=0;i<3;i++)
  {
    happiness[i]=0;
  }
  if(n>1)
  {
    for(i=n-2;i>=0;i--)
    {
      for(j=0;j<3;j++)
      {
        for(k=0;k<3;k++)
        {
          if(j!=k)
          {
            happiness[j]=max(arr[i+1][k]+arr[i][j],happiness[j]);
          }
        }
        arr[i][j]=happiness[j];
      }
    }
  }
  else
  {
    for(i=0;i<3;i++)
    {
      happiness[i]=arr[0][i];
    }
  }
  
  cout<<*max_element(happiness,happiness+3)<<endl;

}
  

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

int n;
vector<int> a;
long long gcd(long long x, long long y){
	while(x % y != 0){
		long long r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(auto &i:a) cin >> i;
	long long ans = 1;
	for(auto i:a) ans = ans * i / gcd((long long)ans, (long long)i);
	cout << ans << "\n";
}


Measured memory_bytes: 3196
#include<stdio.h>
int main()
{
	long long a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF)
	{
		long long c,d;
		scanf("%lld%lld",&c,&d);
		int ans=(a*b)-((c*b)+(d*a)-(c*d));
		printf("%lld\n",ans);
	}
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int N;cin>>N;
	
	vector<ll>A(N),B(N);
	vector<pair<ll,int>>AB(N);
	for (int i = 0; i < N; i++)
	{
		cin>>A[i]>>B[i];
		AB[i] = make_pair(A[i]+B[i], i);
	}
	sort(AB.begin(), AB.end(), greater<pair<ll,int>>());

	ll a=0,b=0;
	for (int i = 0; i < N; i++)
	{
		if(i%2==0)a+=A[AB[i].second];
		else if(i%2==1)b+=B[AB[i].second];
	}

	cout<<a-b<<endl;

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) vl a(n + 1, 0); fab(i,0,n) cin>>a[i]
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N =(ll)3e5;
const ll inf =(ll)1e18 + 7;
const ll mod =(ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for(ll i = 3;i * i <= n; i += 2)
        if(prime[i])
            for(ll j = i; j * i <= n; j += 2)
                prime[j * i] = false;
        
    for(ll i = 3; i <= n; i += 2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result = n;
    for(ll p = 2; p * p <= n; p++)
    {
        if(n % p == 0)
        {
            while(n % p == 0)
                n /= p;
            result -= result/p;
        }
    }

    if(n > 1)
        result -= result/n;
    return result;
}

ll nCr(ll n, ll k) 
{ 
    vl C(k + 1, 0); 
    ll i, j; 
    C[0] = 1; 
    for (i = 1; i <= n; i++) { 
        for (j = min(i, k); j > 0; j--) { 
            add(C[j], C[j - 1]); 
        } 
    }
    return C[k] % mod; 
}


int main()
{
	sup;
    
    in(n); in(k);
    arr(a, n);
    vector<double> expected(n + 1);
    vector<double> sum(n + 1);
    fab(i, 0, n) {
        expected[i] = ((double)a[i] * (a[i] + 1) / 2) / a[i];
        sum[i + 1] = sum[i] + expected[i];
    }
    double ans = 0.0;
    fab(i, k, n + 1) {
        ans = max(ans, sum[i] - sum[i - k]);
    }
    cout << fixed << setprecision(12);
    pr(ans);
    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Numerics;

    class Program
    {
        static void Main(string[] args)
        {
            var N = BigInteger.Parse(Console.ReadLine());
            var Ts = new List<BigInteger>();
            for(var i = 0; i < N; i++)
            {
                Ts.Add(BigInteger.Parse(Console.ReadLine()));
            }

            BigInteger answer = 0;
            if(N==1)
            {
                Console.WriteLine(Ts[0]);
                return;
            }

            for (int i = 0; i < 1; i++)
            {
                var a = Ts[i];
                var b = Ts[i + 1];
                BigInteger mul = a * b;
                if (a < b)
                {
                    var tmp = a;
                    a = b;
                    b = tmp;
                }

                var r = a % b;
                while (r != 0)
                {
                    a = b;
                    b = r;
                    r = a % b;
                }
                answer = mul / b;
            }

            for (int i=2;i<N;i++)
            {
                var a = Ts[i];
                var b = answer;
                var mul = a*b;
                if(a<b)
                {
                    var tmp = a;
                    a = b;
                    b = tmp;
                }

                var r = a % b;
                while(r!=0)
                {
                    a = b;
                    b = r;
                    r = a % b;
                }
                answer = mul / b;
            }

            Console.WriteLine(answer);
        }
    }

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

int main() {
  int N, l, r, x;
  x = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    x += r - l + 1;
    if (i == N - 1) {
      cout << x << endl;
    }
  }
}


Measured memory_bytes: 256