akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    int K, T; cin >> K >> T;
    vector<int> a(T);
    REP(i,T){
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    cout << max(a[0]-1-(K-a[0]), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;
const long long int MOD = 1000000007;

int N;
int num[200];
int box;
int ans;

int main() {
	cin >> N;
	for (int i = 0; i < N * 2; i++) {
		cin >> num[i];
	}
	for (int i = 0; i < N * 2; i++) {
		for (int j = i + 1; j < N * 2; j++) {
			if (num[i] > num[j]) {
				box = num[i];
				num[i] = num[j];
				num[j] = box;
			}
		}
	}
	for (int i = 0; i < N * 2; i += 2) {
		ans += num[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main(){
  ll h, w;
  cin >> h >> w;
  cin.ignore();

  ll ans = 0;

  if(h == 1){
    cout << 1 << endl;
    return 0;
  } else if(w == 1){
    cout << 1 << endl;
    return 0;
  }

  if(h%2 == 0){
    ans = (h / 2) * w;
    cout << ans << endl;
    return 0;
  } else if(w%2 == 0){
    ans = h * (w / 2);
    cout << ans << endl;
    return 0;
  }

  // h も w も奇数
  ll half_h = h / 2;
  ll half_w = w / 2;
  ans = (half_h + 1) * (half_w + 1) + half_h * half_w;
  cout << ans << endl;
  return 0;
}



        
    


Measured memory_bytes: 256
'''import math
n = int(input())
x = n//1.08
o = math.floor(x*1.08)
s = math.floor((x+1)*1.08)
t = math.floor((x-1)*1.08)
if(o!=n and s!=n and t!=n):
    print(":(")
else:
    print(x)
'''
a = [0]*100001
a[0]=1
ls = [100,101,102,103,104,105]
for i in range(0,len(ls)):
    for j in range(ls[i],100001):
        a[j]+=a[j-ls[i]]
n=int(input())
if(a[n]):
    print(1)
else:
    print(0)

Measured memory_bytes: 7284
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll N;
	ll SN = 0;
	ll ans = 0;
	cin >> N;
	SN = N;
	while (N > 0) {
		ans = ans + N % 10;
		N /= 10;
	}
	if (SN % ans == 0) {
		cout << "Yes";
	}
	else cout << "No";
	

	return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


signed main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int r,s1,p;
	cin>>r>>s1>>p;
	string t;
	cin>>t;
	string s="";
	int pts=0;
	for (int i=0;i<k;i++)
	{
	    if (t[i]=='r')
	    {
	        s+="p";
	        pts+=p;
	    }
	    else if (t[i]=='p')
	    {
	        s+="s";
	        pts+=s1;
	    }
	    else
	    {
	        s+="r";
	        pts+=r;
	    }
	}
	for (int i=k;i<t.length();i++)
	{
	    if (t[i]=='r')
	    {
	        if (s[i-k]!='p')
	        {
	        s+="p";
	        pts+=p;
	        }
	        else
	        {
	            if (i+k<n)
	            s+=t[i+k];
	            else
	            s+="r";
	        }
	    }
	    else if (t[i]=='p')
	    {
	        if (s[i-k]!='s')
	        {
	        s+="s";
	        pts+=s1;
	        }
	        else
	        {
	            if (i+k<n)
	            s+=t[i+k];
	            else
	            s+="p";
	        }
	    }
	    else
	    {
	        if (s[i-k]!='r')
	        {
	        s+="r";
	        pts+=r;
	        }
	        else
	        {
	            if (i+k<n)
	            s+=t[i+k];
	            else
	            s+="s";
	        }
	    }
	}
	cout<<pts<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
int main()
{
   int N;
   scanf("%d",&N);
   double t;
   if(N%2!=0)
    t=(N+1)/2*1.0/N;
   else
    t=(N/2)*1.0/N;
   printf("%.10lf",t);
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cmath>
#include <climits>
#include <unordered_map>
using namespace std;

int main() {

int n;
cin>>n;
vector <int> dp(n+1,0);

const unsigned int M = 1000000007;
// dp[i] = how many ways to get this sum
dp[0] = 1; // there is one way to get sum 0: take nothing

for(int sum=3; sum<=n; sum++){ // what sum do we want to get
	for(int coin=3; coin<=sum; coin++){ // going through the coins, note that coins bigger than sum will not be considered because we can't get that sum using it. for example it's impossible to get sum of 5 using atleast once coin 7
		dp[sum] += dp[sum-coin];
		dp[sum] %= M; // taking mod
	}
}
cout << dp[n]<<endl;

return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define repeat(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(){
  string O,E;
  cin >>O>>E;
  
  int lenO = O.size();
  int lenE = E.size();
  
  string ans = "";
  repeat(i,0,lenE){
    cout <<O[i]<<E[i];
  }
  
  if(lenO>lenE) cout <<O[lenO-1]<< endl;
  else cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool dp[2][8010][20010];
int main()
{
	string S;
	int x, y;
	cin >> S >> x >> y;
	vector<int> F[2];
	int d = 1, cnt = 0, x0 = 0;
	bool first = true;
	for (int i = 0; i < S.size(); i++) {
		if (first) {
			if (S[i] == 'T') first = false;
			else x0++;
		}
		else {
			if (S[i] == 'F') cnt++;
			else {
				F[d].push_back(cnt);
				cnt = 0;
				d = (d + 1) % 2;
			}
		}
	}
	F[d].push_back(cnt);
	dp[0][0][8000 + x0] = true;
	dp[1][0][8000] = true;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < F[i].size(); j++) {
			for (int k = 0; k < 16000; k++) {
				if (dp[i][j][k]) {
					dp[i][j + 1][k + F[i][j]] = true;
					dp[i][j + 1][k - F[i][j]] = true;
				}
			}
		}
	}
	if (dp[0][F[0].size()][x + 8000] && dp[1][F[1].size()][y + 8000]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 35364
N , X = (int(a) for a in input().split())
L = list(map(int,input().split()))
Length = [0]
for i in range(N) :
    Length.append(Length[i] + L[i])
    if Length[i+1] > X :
        del Length[-1]
        break
    else : continue

print(len(Length))



Measured memory_bytes: 3316
Q,H,S,D=map(int,input().split())
N=int(input())
ans=min(4*N*Q,2*N*H,N*S,N//2*D)
if ans==N//2*D and N%2==1:
    ans+=min(4*Q,2*H,S)
    ans=min(ans,4*N*Q,2*N*H,N*S)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
const int inf=1e9;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct edge { int to,nxt; } e[N<<1];
int tot=1,h[N];
void adde(int u,int v) {
    e[++tot]=(edge){v,h[u]};h[u]=tot;
    e[++tot]=(edge){u,h[v]};h[v]=tot;
}
int n,sum=0,siz[N],mx[N],sx[N],l[N],r[N];
char s[N];
ll ans=0;
void dfs1(int u,int fa) {
    siz[u]=s[u]-'0';
    for(int i=h[u];i;i=e[i].nxt) {
        int v=e[i].to; if(v==fa) continue;
        dfs1(v,u); siz[u]+=siz[v];
        if(mx[v]+1>mx[u]) sx[u]=mx[u],mx[u]=mx[v]+1;
        else if(mx[v]+1>sx[u]) sx[u]=mx[v]+1;
    }
}
void dfs2(int u,int fa,int len) {
    r[u]=len>mx[u]?mx[u]:max(len,sx[u]);
    l[u]=s[u]-'0'?0:(sum-siz[u]?len:inf);
    if(fa) {
        if(len-1==mx[u]) ans++;
        else if(len-1<mx[u]) ans+=siz[u]<sum;
        else ans+=siz[u]>0;
    }
    for(int i=h[u];i;i=e[i].nxt) {
        int v=e[i].to; if(v==fa) continue;
        if(siz[v]) l[u]=min(l[u],mx[v]+1);
        if(mx[u]==mx[v]+1) dfs2(v,u,max(len,sx[u])+1);
        else dfs2(v,u,max(len,mx[u])+1);
    }
}
int main() {
    cin>>n;
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),adde(u,v);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++) sum+=s[i]-'0';
    dfs1(1,0);dfs2(1,0,0);
    for(int i=1;i<=n;i++) if(l[i]<=r[i]) ans+=r[i]-l[i]+1;
    printf("%lld\n",ans);
    return 0;
}



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

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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> dp(H + 1);
    dp.push_back(0);

    int a, b;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    for (int h = 1; h <= H; h++)
    {
        int v;
        for (int i = 0; i < N; i++)
        {
            a = A[i];
            b = B[i];
            int j;
            if (h - a >= 0)
            {
                j = h - a;
            }
            else
            {
                j = 0;
            }
            if (i == 0)
            {
                v = dp[j] + b;
            }
            else
            {
                v = min(v, dp[j] + b);
            }
        }
        dp[h] = v;
    }
    cout << dp[H] << endl;
}

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

using namespace std;
int main()
{
    // 文字列の入力
    long long A;
	double B;
	cin >> A >> B;
	
	long long qB = (long long)round(B * 100.0);

	A = A * qB;
	A /= 100;
	
	cout << A << endl;
	
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

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

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    vector<i64> v(5);
    rep(i,0,5) cin >> v[i];

    i64 k;
    cin >> k;

    rep(i,0,5){
        rep(j,0,5){
            if(abs(v[i]-v[j])>k){
                cout << ":(" << endl;
                return;
            }
        }
    }

    cout << "Yay!" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[3];
  int i,m,index;
  int sum=0;

  m=0;
  scanf("%d %d %d",&a[0],&a[1],&a[2]); 
  for (i=0;i<3;i++)
  {
    if ( m <= a[i] )
    {
      m = a[i];
      index = i;
    }
  }
  sum = m * 10;
  for (i=0;i<3;i++)
  {
    if ( index == i ) continue;
    sum += a[i];
  }

  printf ("%d\n",sum);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

using mint = modint998244353;

template<class T>
struct Optional {
    bool valid;
    T x;
    operator bool() {return valid;}
    Optional(const T& x): valid(true), x(x) {}
    Optional(): valid(false) {}
    T& value() {return x;}
};

template <class S,
          S (*op)(S, S),
          class F,
          F (*composition)(F, F),
          S (*mapping)(F, S)>
class lazy_lazy_segtree {
    template<class T, T (*f)(T, T)>
    static Optional<T> funcmap(Optional<T> x, Optional<T> y) {
        if (!x) return y;
        if (!y) return x;
        return f(x.value(), y.value());
    }
    template<class T>
    static Optional<T> idfunc() { return {};};
    static Optional<S> Optional_mapping(Optional<F> f, Optional<S> s) {
        if (f && s) {
            return mapping(f.value(), s.value());
        } else {
            return s;
        }
    }
public:
    lazy_segtree<Optional<S>,funcmap<S, op>,idfunc<S>,Optional<F>,Optional_mapping,funcmap<F, composition>,idfunc<F>> seg;
    lazy_lazy_segtree() : lazy_lazy_segtree(0) {}
    lazy_lazy_segtree(int n) : seg(std::vector<Optional<S>>(n)) {}
    lazy_lazy_segtree(const std::vector<S>& v) : seg(std::vector<Optional<S>>(v.begin(),v.end())) {}
    void set(int p, S x) {seg.set(p, x);}
    S get(int p) {
        auto x = seg.get(p);
        return x ? x.value() : S();
    }
    S prod(int l, int r) {
        auto x = seg.prod(l, r);
        return x ? x.value() : S();
    }
    S all_prod() {
        auto x = seg.all_prod();
        return x ? x.value() : S();
    }
    void apply(int p, F f) {seg.apply(p, f);}
    void apply(int l, int r, F f) {seg.apply(l, r, f);}
    template<bool (*g)(S)> bool map_g(Optional<S> x) {return x ? g(x.value()) : true;}
    template <bool (*g)(S)> int max_right(int l) {return seg.max_right<map_g<g>>(l);}
    template <class G> int max_right(int l, G g) {return seg.max_right(l, [&g](Optional<S> x){return x ? g(x) : true;});}
    template <bool (*g)(S)> int min_left(int r) {return seg.min_left<map_g<g>>(r);}
    template <class G> int min_left(int r, G g) {return seg.min_left(r, [&g](Optional<S> x){return x ? g(x) : true;});}
};



struct S {
    mint x, w;
};
S op(S l, S r) {return {l.x * r.w + r.x, l.w * r.w};}
using F = int;
F composition(F l, F r) { return l;}
mint inv9 = mint(1) / 9;
S mapping(F l, S r) { return {(r.w - 1) * inv9 * l, r.w};}

int main() {
    int n, q;
    cin >> n >> q;
    lazy_lazy_segtree<S, op, F, composition, mapping> seg(vector<S>(n, {1, 10}));
    while(q--) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        cout << seg.all_prod().x.val() << endl;
    }
}

Measured memory_bytes: 15456
#include <stdio.h>
 
int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
  do{
    e = scanf("%c", &st);
 
    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }
 
  }while(e != EOF);
 
  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);
 
  return 0;
}


Measured memory_bytes: 2052
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int n;
ll m;
ll a[25];
ll b[25];
int p[25];
double r[25];
ll dp[1<<21];
int main()
{
	scanf("%d %lld",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[i]=m/a[i];
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&p[i]);
		r[i]=p[i]/100.0;
	}
	for(int i=0;i<(1<<n);i++)
	{
		ll g=-1ll;
		bool over=false;
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1)
			{
				if(g==-1ll)g=a[j];
				else
				{
					ll A = a[j];
					ll B =g/__gcd(g,a[j]);
					if(B!=0&&LLONG_MAX/A<B)
					{
						over = true;
						break;
					}
					else g = A*B;
				}
			}
		}
		if(!over&&g!=-1ll)dp[i]=m/g;
	}
	for(int i=0;i<n;i++)for(int j=0;j<(1<<n);j++)if(j&(1<<i))dp[j]-=dp[j^(1<<i)];
	//for(int i=0;i<(1<<n);i++)cout << dp[i] << endl;
	double ans=0.0;
	for(int i=0;i<(1<<n);i++)
	{
		double R = 1.0;
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1)R*=r[j];
			else R*=(1.0-r[j]);
		}
		ans += R*abs(dp[i]);
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 11460
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		char[] arr = sc.nextLine().toCharArray();
		boolean prev = arr[0] == 'T';
		for (int i = 2; i < arr.length; i += 2) {
		    prev = check(prev, arr[i] == 'T');
		}
		String ans;
		if (prev) {
		    ans = "T";
		} else {
		    ans = "F";
		}
		System.out.println(ans);
	}
	
	static boolean check(boolean a, boolean b) {
	    if (a && !b) {
	        return false;
	    } else {
	        return true;
	    }
	}
}



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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  long long ans = 0;
  long long lef=A[0];
  long long rig=A[N-1];
  ans += rig-lef;
  int i=1, j=N-2;
  while(i<=j){
    // cout << ans << endl;
    long long hoge = max(max(abs(lef-A[i]),abs(lef-A[j])),max(abs(rig-A[i]),abs(rig-A[j])));
    if (hoge==abs(lef-A[i])){
      ans += abs(lef-A[i]);
      lef = A[i];
      i++;
    }
    else if (hoge==abs(lef-A[j])){
      ans += abs(lef-A[j]);
      lef = A[j];
      j--;
    }
    else if (hoge==abs(rig-A[i])){
      ans += abs(rig-A[i]);
      rig = A[i];
      i++;
    }
    else {
      ans += abs(rig-A[j]);
      rig = A[j];
      j--;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    int x;
    cin >> x;
    a[--x] = i+1;
  }
  rep(i,n) printf("%d ", a[i]);
  return 0;
}

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

int main(){
  int N;
  long L1, L2, L3;
  cin >> N;
  L1 = 2;
  
  for(int i=0; i<N+1; i++){
    switch(i){
      case 0:
        L2 = 2;
        break;
      case 1:
        L2 = 1;
        break;
      default:
        L3 = L2;
        L2 = L1 + L2;
        L1 = L3;
        break;
    }
  }
  cout << L2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 300010;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 6; i <= n; i++){
        if(is_prime[i] && (i % 7 == 1 || i % 7 == 6)){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}


signed main(){
    int n;
    int sz = sieve(300010);
    while(1){
        cin >> n;
        if(n == 1) break;
        vector<int> ans;
        rep(i, 0, sz){
            if(n % prime[i] == 0){
                ans. push_back(prime[i]);
            }
        }
        cout << n << ":";
        rep(i, 0, ans.size()){
            cout << " " << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3664
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	for(int x=0;x<8;x++){
		int check = 0;
		check += S[0]-'0';
		for(int i=0;i<3;i++){
			if(x&(1<<i)) check += S[i+1]-'0';
			else check -= S[i+1]-'0';
		}

		if(check==7){
			cout << S[0];
			for(int i=0;i<3;i++){
				if(x&(1<<i)) cout << '+';
				else cout <<'-';

				cout << S[i+1];
			}
			cout << "=7" <<endl;
			return 0;
		}

	}


  	return 0;
}



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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
char s[125252];

int main(){
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    int ans = 0;
    REP(i,n-1){
        if(s[i] == s[i+1])ans++;
    }
    ans = min(n-1, ans + 2*k);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

ll n,k;
ll dp[1001][1001]={};

int main(){
	scanf("%lld %lld",&n,&k);
	if(n<k) printf("0\n");
	else{
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=k;j++){
				dp[i][j]+=dp[i-1][j-1];
				if(i>=j)
				dp[i][j]+=dp[i-j][j];
				dp[i][j]%=MOD;
			}
		}
		printf("%lld\n",dp[n][k]);
	}
}


Measured memory_bytes: 10976
#include <math.h>

#include <iostream>
using namespace std;

int main() {
    int a, b;
    char op;
    int i = 0;
    while (true) {
        cin >> a >> op >> b;
        if (op == '+') {
            cout << a + b << endl;
        }
        else if (op == '-') {
            cout << a - b << endl;
        }
        else if (op == '*') {
            cout << a * b << endl;
        }
        else if (op == '/') {
            cout << a / b << endl;
        }
        else if (op == '?') {
            break;
        }

        if (i > 100000) {
            break;
        }
        i++;
    }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, x = 0, y = 0;
int a[N], b[N];
vector<int> va, vb;

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

vector<int> work(vector<int> &a, vector<int> &b)
{
	vector<int> cur;
	for(auto &it:b)
		cur.push_back(it);
	cur.push_back(-1);
	for(auto &it:a)
		cur.push_back(it);
	vector<int> z = z_function(cur);
	vector<int> ans;
	for(int i = n + 1; i < z.size(); i++)
	{
		if(z[i] == n && i - n - 1 < n)
			ans.push_back(i - n - 1);
	}
	return ans;
}

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		x ^= a[i];
	}
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
		y ^= b[i];
	}
	if(n % 2)
	{
		int val = x ^ y;
		for(int i = 0; i < n; i++)
			va.push_back(a[i] ^ val);
		for(int i = 0; i < n; i++)
			va.push_back(va[i]);
		for(int i = 0; i < n; i++)
			vb.push_back(b[i]);
		vector<int> ans = work(va, vb);
		for(auto &it:ans)
			cout << it << " " << val << endl;
	}
	else
	{
		for(int i = 0; i < n; i++)
			va.push_back(a[i] ^ a[(i + 1) % n]);
		for(int i = 0; i < n; i++)
			va.push_back(va[i]);
		for(int i = 0; i < n; i++)
			vb.push_back(b[i] ^ b[(i + 1) % n]);
		vector<int> ans = work(va, vb);
		for(auto &it:ans)
			cout << it << " " << (b[0] ^ a[it]) << endl;
	}
	return 0;
}

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

int N,Q,i,j,q[100001];
char S[100001];

int main(void){
  cin >> N >> Q;
  cin >> S;
  int a[Q],b[Q], cnt=0;
  for(i=0;i<Q;i++){
    cin >> a[i] >> b[i];
  }
  q[0]=0;
  if(S[0]=='A'){
    cnt = 1;
  }
  for(i=1;i<N;i++){
    if(S[i]=='A'){
      cnt=1;
      q[i]=q[i-1];
    }else if(S[i]=='C' && cnt==1){
      q[i]=q[i-1]+1;
      cnt=0;
    }else{
      cnt=0;
      q[i]=q[i-1];
    }
  }
  for(i=0;i<Q;i++){
    printf("%d\n",q[b[i]-1]-q[a[i]-1]);
  }
  return 0;
}


Measured memory_bytes: 5036
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP初期条件: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DPループ
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
}


Measured memory_bytes: 7052
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef vector<ll> vecll;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    set<ll> set;
    map<ll,ll> map;
    rep(i,n){
        ll a;
        cin >> a;
        set.insert(a);
        if(map.find(a)!=map.end()) map[a]++;
        else map[a]=1;
    }
    ll ans=0;
    for(auto itr=set.begin();itr!=set.end();itr++){
        if(map[*itr]>=*itr) ans+=map[*itr]-*itr;
        else ans+=map[*itr];
    }
    kaku(ans);
}

int main(){
    solve();
};



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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<string> split(const string &s, const string& seps) {
  vector<string> res;
  int pos = 0, sz = seps.size();
  size_t find_pos = string::npos;
  while (true) {
    for (int i = 0; i < sz; i++) {
      size_t tmp = s.find(seps[i], pos);
      if (find_pos == string::npos || tmp < find_pos) find_pos = tmp;
    }
    if (find_pos == string::npos) break;
    res.emplace_back(s.substr(pos, find_pos - pos));
    pos = find_pos + 1;
    find_pos = string::npos;
  }
  if (pos < (int)s.size()) res.emplace_back(s.substr(pos));
  return res;
}

string &replaceAll(string &s, const string &from, const string &to) {
  int pos = 0;
  size_t find_pos = string::npos;
  while ((find_pos = s.find(from, pos)) != string::npos) {
    s.replace(find_pos, from.size(), to);
    pos = find_pos + to.size();
  }
  return s;
}

string sum_string(string s, string t) {
  if ((int)s.size() < (int)t.size()) swap(s, t);
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  for (int i = 0; i < (int)t.size(); i++) {
    if ((s[i] - '0') + (t[i] - '0') < 10) {
      s[i] += (t[i] - '0'); 
    } else {
      s[i] = s[i] + (t[i] - '0') - ('9' + 1) + '0';
      int tmp = i + 1;
      while (tmp < (int)s.size() && s[tmp] == '9') s[tmp++] = '0';
      if (tmp == (int)s.size()) s += "1";
      else s[tmp] += 1;
    }
  }
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  while (cin >> s) {
    auto v = split(s, "+=");
    int ans = -1;
    for (int i = 0; i < 10; i++) {
      auto w = v;
      for (int j = 0; j < 3; j++) {
        replaceAll(w[j], "X", to_string(i));
      }
      if (sum_string(w[0], w[1]) == w[2]) ans = i;
    }
    if (ans < 0) cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3248
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		char a = sc.next().charAt(0);
		if('A' <= a && a <= 'Z') {
			System.out.println('A');
		}
		else {
			System.out.println('a');
		}

	}

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


Measured memory_bytes: 35708
#include<bits/stdc++.h>
#define N 300005
#define pii pair<int,int>
#define mp make_pair
using namespace std;

int n,a[N],B,W,tot,fa[N],sum[N];
pii q[N];
bool f[N];

inline bool check(int x)
{
	int minn=0;
	for(int i=2;i<=n;i+=2)
	{
		if(sum[i-1]-x>=minn) f[i]=1;
		else f[i]=0;
		if(f[i]) minn=min(minn,sum[i]);
	}
	return f[n];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(i&1) B+=a[i],sum[i]=sum[i-1]+a[i];
		else W+=a[i],sum[i]=sum[i-1]-a[i];
	}
	if(n&1)
	{
		n++;sum[n]=sum[n-1];
		sort(q+1,q+1+tot);
		int l=0,r=B+W;
		while(l<r)
		{
			int mid=l+r>>1;
			if(check(mid)) l=mid+1;
			else r=mid;
		}
		printf("%d %d",W+l-1,B-l+1);
	}
	else printf("%d %d",max(W,B),min(W,B));
}


Measured memory_bytes: 4608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(void) {

	ll N, K;
	cin >> N >> K;

	if (K <= N) cout << min(N % K, abs(N % K - K)) << endl;
	else cout << min(abs(N - K), N) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
all_a = sum(a)
half_a = all_a / 2
a_sum = 0
for j,i in enumerate(a):
    if a_sum + i < half_a:
        a_sum += i
    else:
        if abs(a_sum -  half_a) >= abs((a_sum + i) -  half_a):
            print(abs((all_a - 2*(a_sum + i)) ))
            break
        else:
            print(abs(all_a - 2*(a_sum)))
            break

Measured memory_bytes: 26056
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(x,y) 			fixed << setprecision(y) << x
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
#define pr(a) 				cout<<a<<endl;
#define pr2(a,b) 			cout<<a<<" "<<b<<"\n"
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

ll modp(ll a, ll b){
    ll res = 1;
    while(b>0){
        if (b&1) res = (res*a)%M1;
        a = (a*a)%M1;
        b>>=1;
    }
    return res;
}



void solve()
{
    ll n,k;
    cin>>n>>k;
   
    ll dp[k+1] = {0};
    repp(i,k+1,1){
        ll multiples = k/i;
        dp[i] = modp(multiples,n);
        for(ll j=2*i;j<=k;j+=i){
            dp[i] -= dp[j];
        }
    }
    ll ans = 0;
    rep(i,1,k+1){
        ans = (ans + (i*dp[i])%M1)%M1;
    }
    cout << ans << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4356
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n-1):
  if a[i]+1 == a[i+1]:
    ans = ans + c[a[i]-1]
    
ans = ans + sum(b)
print(ans)
    

Measured memory_bytes: 3060
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class RH {
	string s;
	int n, m, base;
	int* has;
	int mypow(int x, int y) {
		if (!y)return 1;
		if (y % 2)return this->mypow(x, y - 1) * x % m;
		int memo = this->mypow(x, y / 2);
		return memo * memo % m;
	}
public:
	RH() {}
	RH(string s, int m, int b) { init(s, m, b); }
	~RH() { delete[] has; }
	void init(string s, int m, int b) {
		n = s.size();
		has = new int[n];
		base = b;
		this->s = s;
		this->m = m;
		rep(i, n) {
			has[i] = (int)s[i];
			if (i)has[i] += base * has[i - 1] % m;
			has[i] %= m;
		}
	}
	int query(int a, int b) {
		assert(!(a >= b || a < 0 || n < b));
		return (has[b - 1] - this->mypow(base, b - a) * (!a ? 0 : has[a - 1]) % m + m) % m;
	}
};
int n;
string s;
signed main() {
	cin >> n >> s;
	RH rh1(s, mod, 1007), rh2(s, mod, 10007);
	int ans = 0;
	rep(i, n) {
		if ((n - i) / 2 <= ans)break;
		for (int j = i + ans; j < n; j++) {
			if ((n - i) / 2 <= ans)goto kaage2;
			j = max(j, i + ans);
			if (n <= j)break;
			if (n < j + ans)break;
			for (int k = 0; k < j - i; k++) {
				if (s[i + k] != s[j + k]) {
					ans = max(ans, k);
					goto kaage;
				}
			}
			ans = max(ans, j - i);
		kaage:;
		}
	}
kaage2:;
	cout << ans << endl;
}

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

int main(){
  int R,G;
  cin >> R >> G;
  if (R<=G){
    int a,b;
    a = (G-R)*2;
    b = a+R;
    cout << b << endl;
  }
  else if (R>G) {
    int a,b;
    a = (R-G)*2;
    b = R-a;
    cout << b << endl;
  }
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 303

int n;
int a[MAXN][MAXN];
int g[MAXN][MAXN];

priority_queue < pair<int, pair<int, int> > > q;

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

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

	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			q.push(mp(-a[i][j], mp(i, j)));
		}

	memset(g, -1, sizeof(g));

	ll ans = 0;
	while(!q.empty()) {
		int cost = -q.top().f;
		int v1 = q.top().s.f;
		int v2 = q.top().s.s;
		q.pop();
		int ok = 1;
		for (int i = 0; i < n; ++i) {
			if (v1 == i || v2 == i) continue;
			if (g[v1][i] == -1 || g[v2][i] == -1) continue;
			if (g[v1][i] + g[v2][i] < cost) {
				puts("-1");
				return 0;
			}
			if (g[v1][i] + g[v2][i] == cost) {
				ok = 0;
			}
		}
		if (ok) {
			ans += cost;
		}
	   g[v1][v2] = g[v2][v1] = cost;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define sort(v) sort(all(v))
#define rev(x) reverse(all(x))
 
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
 
const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

int main() {
  int n,m,x;cin>>n>>m>>x;
  vi c(n,0);
  vector<vi> an(n, vi(m,0));
  
  rep(i,n) {
    cin>>c[i];
    rep(j,m) cin>>an[i][j];
  }
  
  vi dp(m,0);
  int money, moneymin=INF;
  bool flg;
  
  rep(k, 1<<n) {
    rep(j,m) dp[j]=0;
    money=0;
    rep(i,n) {
      if (k & (1<<i)) {
        money += c[i];
        rep(j,m) dp[j] += an[i][j];
      }
    }
    flg = true;
    rep(j,m) if (dp[j]<x) {
      flg=false;
      break;
    }
    if (flg && money < moneymin) moneymin = money;
  }
  if (moneymin == INF) cout<<-1;
  else cout << moneymin;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b, c;
    int n, k;
    int d; cin >> a >> b >> c >> d;
    out(min(a, b) + min(c, d));
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

ll n,m;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n>>m;
  UnionFind uf(n);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    uf.connect(a,b);
  }
  
  ll ans=0;
  rep(i,n){
    ll x=uf.size(i);
    chmax(ans, x);
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1)puts("Brown");
	else puts("Alice");
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
ai = defaultdict(int)
aj = defaultdict(int)

for i, a in enumerate(A):
    ai[i + 1 + a] += 1
    aj[i + 1 - a] += 1

ans = 0
for k, v in ai.items():
    ans += v * aj[k]
print(ans)

Measured memory_bytes: 73860
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main() {
	int x = nxt(), y = nxt(), z = nxt();
	int n = x + y + z;
	vector<vector<int>> a(n);
	for (int i = 0; i < n; ++i) {
		a[i].resize(3);
		for (int j = 0; j < 3; ++j) {
			a[i][j] = nxt();
		}
	}

	long long cur = 0;
	for (int i = 0; i < n; ++i) {
		cur += a[i][0];
		a[i][1] -= a[i][0];
		a[i][2] -= a[i][0];
	}

	sort(all(a), [](const vector<int>& v1, const vector<int>& v2) {
		return v1[2] - v1[1] < v2[2] - v2[1];
	});

	// for (auto v : a) {
	// 	cerr << v[1] << " " << v[2] << "\n";
	// }

	long long ans = 0;

	vector<long long> ys(n + 1);
	ys[0] = 0;
	priority_queue<int, vector<int>, greater<int>> q;
	for (int i = 0; i < n; ++i) {
		ys[i + 1] = ys[i];
		q.push(a[i][1]);
		ys[i + 1] += a[i][1];
		if (q.size() > y) {
			// cerr << "rem: " << q.top() << "\n";
			ys[i + 1] -= q.top();
			q.pop();
		}
	}

	vector<long long> zs(n + 1);
	zs[0] = 0;
	while (!q.empty()) {
		q.pop();
	}
	for (int i = 0; i < n; ++i) {
		zs[i + 1] = zs[i];
		q.push(a[n - 1 - i][2]);
		zs[i + 1] += a[n - 1 - i][2];
		if (q.size() > z) {
			zs[i + 1] -= q.top();
			q.pop();
		}
	}

	// for (int i : ys) {
	// 	cerr << i << " ";
	// }
	// cerr << "\n";
	// for (int i : zs) {
	// 	cerr << i << " ";
	// }
	// cerr << "\n";

	for (int i = y; i + z <= n; ++i) {
		ans = max(ans, cur + ys[i] + zs[n - i]);
	}

	cout << ans << "\n";

	return 0;
}

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


int main() {
	int i, j, k;
	int m, n;
	int f = 0;
	int g = 0;
	int x[110] = {0};
	int a, b, c, d;


	scanf("%d %d", &n, &k);

	f = n * k;

	printf("%d", f);

	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
typedef long long ll;
using namespace std;



int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    ll k;
    cin>>k;
    if(k%2 == 0 || k%5 == 0){
        cout<<"-1\n";
    }
    else{
        ll p = 7%k;
        int cnt = 1;
        while(p != 0){
            p = (p*10+7)%k;
            ++cnt;
        }
 
        cout<<cnt<<"\n";
    }
 
}

Measured memory_bytes: 3136
#include<iostream>
#include<iomanip>
#include<string>

using namespace std;

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

	if (N <= 999) {
		cout << "ABC" << endl;
		return 0;
	}
	else {
		cout << "ABD" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[205],dp[205][100005],hell=pow(10,9)+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x;
    cin>>n>>x;
    for(ll i=1;i<=n;i++)
    cin>>arr[i];
    sort(arr+1,arr+n+1);
    for(ll i=0;i<=x;i++)
    dp[0][i]=i;
    for(ll i=1;i<=n;i++)
    for(ll j=0;j<=x;j++)
    dp[i][j]=(dp[i-1][j%arr[i]]+(dp[i-1][j]*(i-1))%hell)%hell;
    cout<<dp[n][x];
}

Measured memory_bytes: 157952
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  double p;
  while(cin>>p,p!=0) {
    for (int i=1;;++i) {
      int j=PI*i+EPS;
      int k=PI*i+EPS+1;
      double d1 = abs((double)j/i-PI);
      double d2 = abs((double)k/i-PI);
      if (d1<=p||d2<=p) {
        if (d1<=d2) cout << j;
        else cout<< k;
        cout << "/" << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 0
ARGF.each_line do |line|
  a, op, b = line.split
  a = a.to_i
  b = b.to_i
  case op
  when "+"
    answer = a + b
  when "-"
    answer = a - b
  when "*"
    answer = a * b
  when "/"
    answer = a / b
  when "?"
    break
  end
  puts answer
end

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

using ll = long long;
using ull = unsigned long long;

using namespace std;

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

    ll N,K, prevN;

    cin>>N>>K;

    N = N%K;

    if(N==0)
    {
        cout<<"0\n";
    }

    else
    {
        prevN = N;

        while(1)
        {
            N = llabs(N-K);
            if(N>=prevN)
            {
                cout<<prevN<<'\n';
                break;
            }
            prevN = N;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(v,a) for(auto &v:a)
#define fi first
#define se second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(a) a.begin(),a.end()
#define int long long
int re(){int x=0; char c; bool neg=false;while(c!='-'&&(c<'0'||'9'<c)) c=getchar();if (c=='-'){neg=true; c=getchar();}while ('0'<=c && c<='9'){x=x*10+c-'0';c=getchar();}if (neg) x=-x;return x;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ran(int l, int r) {return l+rng()%(r-l+1);}
typedef long long ll;
const int N=100010;
int n,m;
int f[110][N],a[N],c[N];
main()
{
    //freopen("knapsack1.inp","r",stdin);
    cin>>n>>m;
    forinc(i,1,n) cin>>a[i]>>c[i];
    memset(f,-1,sizeof(f)); f[0][0]=0;
    forinc(i,0,n-1) forinc(j,0,m) if (f[i][j]!=-1)
    {
        f[i+1][j]=max(f[i+1][j],f[i][j]);
        if (j+a[i+1]<=m) f[i+1][j+a[i+1]]=max(f[i+1][j+a[1+i]],f[i][j]+c[i+1]);
    }
    int kq=0;
    forinc(i,0,m) kq=max(kq,f[n][i]);
    cout<<kq;
}


Measured memory_bytes: 86144