akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>

using namespace std;

int N, M;

int a[1005], b[1005], c[1005];

int dis[105][105];

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

	int tmp;

	for (int i = 1; i <= M; i++) {
		cin >> tmp; a[i] = tmp;
		cin >> tmp; b[i] = tmp;
		cin >> tmp; c[i] = tmp;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			dis[i][j] = 100002;
		}
	}

	for (int i = 1; i <= N; i++) { dis[i][i] = 0; }

	for (int i = 1; i <= M; i++) {
		dis[a[i]][b[i]] = c[i];
		dis[b[i]][a[i]] = c[i];
	}

	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}

	int ans = 0;

	for (int i = 1; i <= M; i++) {
		if (c[i] > dis[a[i]][b[i]]) { ans++; }
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<vector>
typedef long long i64;
using namespace std;
const int wa=1e9+7;
i64 sx, sy, tx, ty;
int main(void) {
	cin >> sx >>sy>>tx>>ty;
	int e = tx - sx; int o = ty - sy;
	for (int i = 0; i < e; i++)cout << "R";
	for (int i = 0; i < o; i++)cout << "U";
	for (int i = 0; i < e; i++)cout << "L";
	for (int i = 0; i < o; i++)cout << "D";
	cout << "L";o++;e++;
	for (int i = 0; i < o; i++)cout << "U";
	for (int i = 0; i < e; i++)cout << "R";
	cout << "D"<<"R";
	for (int i = 0; i < o; i++)cout << "D";
	for (int i = 0; i < e; i++)cout << "L";
	cout << "U" << endl;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x,a,b;
	cin>>x>>a>>b;
	if(b<=a) cout<<"delicious\n";
	else if(b>a) cout<<(b-a<=x?"safe\n":"dangerous\n");
}




Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] ary = new long[n];
		
		for ( int i = 0; i < n; i++ ) {
			ary[i] = in.nextInt();
		}
		
		Arrays.sort(ary);
		solve(ary[0], ary[n-1]);
	}
	
	public static void solve(long a, long b) {
		System.out.println(Math.abs(a-b));
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 200010
using namespace std;

ll n, m, a[N];

inline ll read(){							//快读 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read();								//输入n 
	REP(i, 2, n) m = read(), a[m]++;		//计算每个数的子节点个数 
	REP(i, 1, n) printf("%lld\n", a[i]);	//输出每个数的子节点个数 
}

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

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string s; cin >> s;
    cout << "ABC" << s << endl;
}

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

int main(){
    //freopen ("/Users/shitian/Downloads/1173-in1.txt","r",stdin);
    char f[102];int c=0,d=0;
    while(1){
        stack<char>s;
        c=0;d=0;
        cin.getline (f,156);
        if(f[0]=='.')
            return 0;
        for(int i=0;f[i]!='.';i++){
            if(f[i]=='('){
                c++;s.push('(');
            }
            if(f[i]==')'){
                c--;
                if(s.size()==0){
                    cout<<"no"<<endl;
                    goto next;
                }
                if(s.top()!='('){
                    cout<<"no"<<endl;
                    goto next;
                }
                s.pop();
            }
            if(f[i]=='['){
                d++;s.push('[');
            }
            if(f[i]==']'){
                if(s.size()==0){
                    cout<<"no"<<endl;
                    goto next;
                }
                if(s.top()!='['){
                    cout<<"no"<<endl;
                    goto next;
                }
                d--;
                s.pop();
            }
            if(c<0||d<0){
                cout<<"no"<<endl;
                goto next;
            }
        }
        if(c==0&&d==0)
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;next:;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <algorithm>

int n, k, f[305][305][305];
char s[305];

int main()
{
	scanf("%s%d", s + 1, &k);
	n = strlen(s + 1);
	for (int l = n; l; l--)
	{
		f[l][l][0] = f[l][l][1] = 1;
		for (int r = l + 1; r <= n; r++)
			for (int x = 0; x <= r - l + 1; x++)
				f[l][r][x] = std::max({f[l + 1][r][x], f[l][r - 1][x], (x >= (s[l] != s[r])) ? f[l + 1][r - 1][x - (s[l] != s[r])] + 2 : 0});
	}
	int ans = 0;
	for (int i = 0; i <= k; i++)
		ans = std::max(ans, f[1][n][i]);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  double w,h;
  long x,y;
  cin >> w >> h >> x >> y;
  long W = w,H = h;
  if(W % 2 == 0 && H % 2 == 0){
    if(W/2 == x && H/2 == y){
      cout << h*w/2 << ' ' << 1 << endl;
    }
    else{
      cout << h*w/2 << ' ' << 0 << endl;
    }
  }
  else{
    cout << h*w/2 << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template < typename T > using oset = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// find_by_order(k) (k+1)th largest element
// order_of_key(k) no of elements <=k

typedef long long ll;
typedef long double ld;
#define endl '\n'
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define pb push_back
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ld PI = 4*atan((ld)1);
const ll INF = 1e18;
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        vll a(n+1);
        repA(i,1,n){
            cin >> a[i];
        }
        sort(a.begin()+1,a.end());
        ll ans =0;
        repA(i,1,n-1){
            ans += a[n-i/2];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4768
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;


pair<int, char> getWinScore(char hand, int p, int r, int s)
{
    int score = 0;
    char myH = 'a';
    switch(hand){
        case 'r':
            score = p;
            myH = 'p';
            break;
        case 's':
            score = r;
            myH = 'r';
            break;
        case 'p':
            score = s;
            myH = 's';
            break;
    }
    return make_pair(score, myH);
}

int main(void)
{

    int n,k,r,s,p;
    cin >>n >>k;
    cin >>r >>s >>p;

    string t;
    cin >>t;

    vector<string> vv(k, "");

    long long sum = 0;
    for(int i = 0; i < n; i++){
        vv[i%k] += t[i];
    }
    char prev = 'a';
    for(int i = 0; i < k; i++){
        for(int j = 0; j < vv[i].size(); j++){
            if(j == 0){
                sum += getWinScore(vv[i][j], p, r, s).first;
                prev = getWinScore(vv[i][j], p, r, s).second;
            }else{
                if(getWinScore(vv[i][j], p, r, s).second != prev){
                    sum += getWinScore(vv[i][j], p, r, s).first;
                    prev = getWinScore(vv[i][j], p, r, s).second;
                }else{
                    prev = 'a';
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";
 
int main(){
  ll r;
  cin >> r;
  print(3 * r * r)
  
  return 0;
}

Measured memory_bytes: 384
n,ais = int(raw_input()),map(int, raw_input().split(' '))
total = sum(ais)
#ais.sort()

cumul = 0
i,j = 0,0
m = abs(total)
while(j< len(ais)):
	while(j < len(ais) and ais[j] == ais[i]):
		cumul += ais[j]
		j+=1
	i = j
	m = min(m, abs(2 *cumul - total))
print m

Measured memory_bytes: 28012
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if (set.contains(a)) {
        set.remove(a);
      } else {
        set.add(a);
      }
    }

    System.out.println(set.size());
  }
}

Measured memory_bytes: 59416
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();
    long res = (n - 1) * n / 2;

    os.println(res);
  }
}

Measured memory_bytes: 21972
n,m=map(int,input().split())
A=[]
ab={}
s=0
for i in range(n):
    a,b=map(int,input().split())
    if a in ab:
        ab[a]+=b
    else:
        ab[a]=b
        A.append(a)
A=sorted(A)
k=0
while m>0:
    if m>ab[A[k]]:
        m-=ab[A[k]]
        s+=ab[A[k]]*A[k]
    else:
        s+=A[k]*m
        m=0
    k+=1
print(s)


Measured memory_bytes: 18432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		int count =0;
		for (int i=0;i<A;i++) {
			long b= sc.nextLong();
			long c = sc.nextLong();
			if (B<=b&&C<=c) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 39496
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());
            String[] array = reader.readLine().split(" ");
            long[] H = new long[N];
            for (int i = 0; i < N; i++) {
                H[i] = Long.parseLong(array[i]);
            }

            int ans = 0;

            int count = 0;
            for (int i = 0; i < N - 1; i++) {
                if (H[i] >= H[i + 1]) {
                    count++;
                    if (ans < count) {
                        ans = count;
                    }
                } else {
                    count = 0;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 49036
#include <iostream>
#include <string>

#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() {
    string S;
    cin >> S;

    int res = 1 << 29;
    for (int start = 0; start <= 1; ++start) {
        int val = start;
        int cnt = 0;
        for (int i = 0; i < S.size(); ++i) {
            if (S[i] - '0' != val) cnt++;
            val = 1 - val;
        }
        res = min(res, cnt);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3292
a = Array.new(2).map { [] }
n, m, l = gets.split(' ').map(&:to_i)

n.times { a[0] << gets.split(' ').map(&:to_i) }
m.times { a[1] << gets.split(' ').map(&:to_i) }

n.times do |ni|
  l.times do |li|
    sum = 0
    m.times { |mi| sum += a[0][ni][mi] * a[1][mi][li] }
    print ' ' unless li.zero?
    print "#{sum}"
  end
  puts
end

Measured memory_bytes: 9052
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n, d] = nextIntArray()
    let ans = Math.ceil(n / (2*d + 1))
    console.log(ans)
}
Main()


Measured memory_bytes: 29648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1<<29)
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int p){
	for(int i=2;i<=sqrt(p);i++){
		if(!p%i)return false;
	}
	return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a%MOD;
    if(b%2)return modpow(a,b-1)*a%MOD;
    else return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
    if(b==0||a==b)return 1;
    if(b==1)return a%MOD;
    return (comb(a-1,b-1)+comb(a-1,b))%MOD;
}
// Library End !
signed main(){
    int k;
    cin>>k;
    cout<<((k+1)/2)*(k/2)<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 3010;
const ll INF = LLONG_MAX;

ll arr[MAX_N];
ll memo[MAX_N][MAX_N][2];

ll dp (int l, int r, int flag) {
  if (l > r) return 0;
  ll& ret = memo[l][r][flag];
  if (ret < INF) return ret;
  return ret = max(arr[l] - dp(l + 1, r, flag ^ 1), arr[r] - dp(l, r - 1, flag ^ 1));
}

int main () {
  for (int i = 0; i < MAX_N; i++) for (int j = 0; j < MAX_N; j++) for (int k = 0; k < 2; k++) memo[i][j][k] = INF;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << dp(0, n - 1, 0) << endl;
  return (0);
}


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

// 見ながら
int main() {

    string s;
    cin >> s;
    int a = 500000, b = 0;
    rep(i, s.size()){
        if(s[i] == 'A') a = min(a, i);
        if(s[i] == 'Z') b = max(b, i);
    }
    cout << b - a + 1 << endl;

}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  }
  else if (R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    LL X;
    cin >> X;

    LL cur_nr = 100;
    int nr_years = 0;
    while (cur_nr < X)
    {
        cur_nr += cur_nr / 100;
        ++nr_years;
    }

    cout << nr_years;
}


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

int main() {
  vector<int> iroha(3);
  for (int i = 0; i < 3; i++) cin >> iroha[i];
  cout << 
    (count(iroha.begin(), iroha.end(), 5) == 2 && count(iroha.begin(), iroha.end(), 7) == 1 ? "YES" : "NO")
    << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    double R;
    cin >> R;
    cout << M_PI * 2.0 * R << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

int dh[4] = {-1, 0, 1, 0};
int dw[4] = {0, -1, 0, 1};

bool isIn(int h, int w, int H, int W) {
    return h >= 0 && h < H && w >= 0 && w < W;
}

void dfs(int H, int W, const vector<string>& S, vector<vector<int>>& grid, int h, int w, int color) {
    grid[h][w] = color;
    rep(i, 0, 4) {
        int nxt_h = h + dh[i];
        int nxt_w = w + dw[i];
        if (isIn(nxt_h, nxt_w, H, W) && grid[nxt_h][nxt_w] < 0 && S[nxt_h][nxt_w] != '#') {
            dfs(H, W, S, grid, nxt_h, nxt_w, color);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, CH, CW, DH, DW;
    cin >> H >> W >> CH >> CW >> DH >> DW;
    --CH, --CW;
    --DH, --DW;
    vector<string> S(H);
    for (auto& s : S) {
        cin >> s;
    }
    vector<vector<int>> grid(H, vector<int>(W, -1));
    int color = 0;
    rep(i, 0, H) rep(j, 0, W) {
        if (S[i][j] != '#' && grid[i][j] < 0) {
            dfs(H, W, S, grid, i, j, color);
            ++color;
        }
    }
    set<P> exists;
    vector<vector<int>> graph(color);
    rep(i, 0, H) rep(j, 0, W) {
        if (S[i][j] == '#') {
            continue;
        }
        rep(k, -2, 3) rep(l, -2, 3) {
            int nxt_h = i + k;
            int nxt_w = j + l;
            if (isIn(nxt_h, nxt_w, H, W) && S[nxt_h][nxt_w] != '#' && grid[nxt_h][nxt_w] != grid[i][j] && !exists.count(P(grid[i][j], grid[nxt_h][nxt_w]))) {
                exists.emplace(grid[i][j], grid[nxt_h][nxt_w]);
                exists.emplace(grid[nxt_h][nxt_w], grid[i][j]);
                graph[grid[i][j]].push_back(grid[nxt_h][nxt_w]);
                graph[grid[nxt_h][nxt_w]].push_back(grid[i][j]);
            }
        }
    }
    int start_node = grid[CH][CW];
    vector<int> dist(color, -1);
    queue<int> que;
    que.push(start_node);
    dist[start_node] = 0;
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        for (auto& nxt_node : graph[now]) {
            if (dist[nxt_node] < 0) {
                dist[nxt_node] = dist[now] + 1;
                que.push(nxt_node);
            }
        }
    }
    cout << dist[grid[DH][DW]] << endl;
    return 0;
}

Measured memory_bytes: 34220
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

const ll modd=1e9+7;
const ll inf=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*    
         -> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
         -> cout<<"Case #"<<casee<<": "<<ans<<endl; // for google kickstart

*/

/*-----------------------------------------------------------------------------------------------*/

const ll N=3e5+5;
ll sum1=0;
vector <ll> arr;
vector <ll> adj[N];
vector <pii> ans;

ll dfs(ll node,ll par){
  ll sum=0;
  for(auto j : adj[node]){
    if(j == par) continue;
    sum+=dfs(j,node);
  }
  return arr[node]-sum;
}

void dfs1(ll node,ll par){
  for(auto j : adj[node]){
    if(j == par) continue;
    dfs1(j,node);
  }
  if(par != -1){
    ans.pb({arr[par],arr[node]});
    arr[par]-=arr[node];
  }
}

int main(){
   fastt;
   
   ll n,x;
   cin>>n;

   for(ll i=1;i<=n;i++){
      cin>>x;
      arr.pb(x);
   }

   sort(arr.begin(),arr.end());

   for(ll i=0;i<(ll)arr.size()-1 && arr[i]<0;i++){
     adj[(ll)arr.size()-1].pb(i);
     adj[i].pb((ll)arr.size()-1);
   }

   ll check=-1;

   for(ll i=0;i<(ll)arr.size()-1;i++){
     if( arr[i] < 0 ) continue;
     if( arr[i] >= 0 && check == -1 ){
        if( i == 0 ){
          adj[(ll)arr.size()-1].pb(i);
          adj[i].pb((ll)arr.size()-1);
        }
        else{
          adj[0].pb(i);
          adj[i].pb(0);
        }
        check=1;
     }
     else if(arr[i] >= 0 && check != -1){
        adj[0].pb(i);
        adj[i].pb(0);
     }
   }

   sum1=dfs((ll)arr.size()-1,-1);
   dfs1((ll)arr.size()-1,-1);

   cout<<sum1<<endl;

   for(ll i=0;i<n-1 && i<(ll)ans.size();i++)
      cout<<ans[i].fi<<" "<<ans[i].se<<endl;

   return 0;
}


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

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
import math

a, b, h, m = map(int, input().split())

h_angle = (h + m / 60) / 12
m_angle = m / 60

angle = (h_angle - m_angle) * 2 * math.pi

distance = float(a ** 2) + float(b ** 2) - 2 * a * b * math.cos(angle)

print(math.sqrt(distance))

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {

	int n; cin >> n;

	const int p = 100001;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
		
	vector<int> a(p, 0), b(p, 0);
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			a[v[i]]++;
		}
		else {
			b[v[i]]++;
		}
	}

	int a_max_cnt = 0;
	int b_max_cnt = 0;
	int a_second_max_cnt = 0;
	int b_second_max_cnt = 0;
	int a_max_cnt_num;
	int b_max_cnt_num;
	for (int i = 0; i < p; i++) {
		if (a_max_cnt <= a[i]) {
			a_second_max_cnt = a_max_cnt;
			a_max_cnt = a[i];
			a_max_cnt_num = i;
		}
		else if (a_second_max_cnt <= a[i]) {
			a_second_max_cnt = a[i];
		}

		if (b_max_cnt <= b[i]) {
			b_second_max_cnt = b_max_cnt;
			b_max_cnt = b[i];
			b_max_cnt_num = i;
		}
		else if (b_second_max_cnt <= b[i]) {
			b_second_max_cnt = b[i];
		}
	}

	if (a_max_cnt_num == b_max_cnt_num) {
		cout << min(n - a_second_max_cnt - b_max_cnt, n - a_max_cnt - b_second_max_cnt);
	}
	else {
		cout << n - a_max_cnt - b_max_cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <cassert>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <sstream>
#include <vector>
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, X;
  cin >> K;
  cin >> X;

  cout << (500 * K >= X ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int B[10],N,i;
int dfs(int p,int r,int l)
{
	int a=0;
	if(p==10)
		return 1;
	if(B[p]>l)
		a|=dfs(p+1,r,B[p]);
	if(B[p]>r)
		a|=dfs(p+1,B[p],l);
	return a;
}

int main()
{
	scanf("%d",&N);
	for(;N--;)
	{
		for(i=0;i<10;i++)
			scanf("%d",&B[i]);
		puts(dfs(0,0,0)?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
map<ll, ll> pref_before;
ll n, m, arr[maxn];

int main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
    }

    ll curr_sum = 0LL, result = 0LL;
    for(int i=1;i<=n;i++) {
        pref_before[curr_sum]++;
        curr_sum += arr[i];
        curr_sum %= m;
        result += pref_before[curr_sum];
    }
    cout<<result<<"\n";
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int N = 23;
const int M = 530000;
const int MOD = 1000000007;
int f[2][M], V[N][N];
int lowbit(int t) {return t & (-t);}
int trans(int t, int p, int c)
{
    if (t & (1 << p))
    {
        if (c == 0) return 1 << (n - 1);
        else return t;
    }
    else
    {
        if (c == 0) return t;
        return (((t >> p) - lowbit(t >> p) + 1) << p) | (t & ((1 << p) - 1));
    }
}
void ADD(int &t, int d)
{
    t += d; if (t >= MOD) t -= MOD;
}
int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= m; ++ i)
        for (int j = 0; j < n - 1; ++ j)
            V[i][j] = -1;
    for (int i = 1; i <= k; ++ i)
    {
        int a, b;
        cin >> a >> b; b --;
        cin >> V[a][b];
    }
    int tmp = 0;
    f[0][0] = 1;
    for (int i = 1; i <= m; ++ i)
        for (int j = 0; j < n - 1; ++ j)
        {
            memset(f[!tmp], 0, sizeof f[!tmp]);
            for (int k = 0; k < (1 << (n - 1)); ++ k)
            {
                if (V[i][j] == -1 || V[i][j] == 0) ADD(f[!tmp][trans(k, j, 0)], f[tmp][k]);
                if (V[i][j] == -1 || V[i][j] == 1) ADD(f[!tmp][trans(k, j, 1)], f[tmp][k]);
            }
            tmp ^= 1;
        }
    int ans = 0;
    for (int k = 0; k < (1 << (n - 1)); ++ k) ADD(ans, f[tmp][k]);
    cout << ans;
}


Measured memory_bytes: 4480
n = int(input())
xy = [[] for _ in range(n)]
ans = 0

for i in range(n): #証言者 i人目
    a = int(input())
    for j in range(a): #i人目の証言者のj番目の証言
        x, y = map(int, input().split())
        xy[i].append([x, y])

for b in range(1 << n): #設定上、正直者か不親切かの全パターンを探索
    cnt = bin(b).count("1") #正直者設定の人数をカウント
    judge = True
    for i in range(n):
        if judge == False:
            break
        if b & (1 << i) != 0: #i番目の証言者が正直者設定の場合
            for x, y in xy[i]:
                if y == 1 and b & (1 << x - 1) == 0:
                    #証言:正直者、設定:不親切の場合
                    judge = False
                if y == 0 and b & (1 << x - 1) != 0:
                    #証言:不親切、設定:正直者の場合
                    judge = False
    if judge == True:
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

char s[100005];

int main(){
	int len;
	cin >> s + 1;
	int l,r;
	bool flag = false;
	len = strlen(s + 1);
	for(int i = 1;i <= len;i++){
		if(s[i] == s[i + 1]) l = i,r = i + 1,flag = true;
		if(s[i] == s[i + 2]) l = i,r = i + 2,flag = true;
		if(flag){
			cout << l << ' ' << r << endl;
			return 0;
		}
	}
	cout << "-1" << ' ' << "-1" << endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    A, B = LMIIS()
    if (A+B) % 2 == 0:
        print((A+B)//2)
    else:
        print('IMPOSSIBLE ')





    pass
if __name__ == '__main__':
    main()

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

using namespace std;
int main(){
	int l,r,ans=1e9;
	cin>>l>>r;
	if(r-l>2019){
		cout<<"0";
		return 0;
	}
	r%=2019,l%=2019;
	if(r<=l||l==0||r==0){
		cout<<"0";
		return 0;
	}
	else{
		for(int i=l;i<r;i++){
			for(int j=i+1;j<=r;j++){
				ans=min(ans,i*j%2019);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    if(S.size() % 2 != 0){
        cout << "No";
        return 0;
    }
    for(int i = 0; i < S.size()-1; i += 2){
        if(!(S[i] == 'h' && S[i+1] == 'i')){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char S[1];
    int A,B,ans;
    cin >> A >> S[0] >> B;
    if (S[0]=='+'){
        ans = A + B;
    }else if (S[0]=='-'){
        ans = A - B;
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	char c;
	cin>>c;
	if (c=='A') cout << "T\n";
	if (c=='T') cout << "A\n";
	if (c=='C') cout << "G\n";
	if (c=='G') cout << "C\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int manha(int x1, int x2, int y1, int y2){
    int x = x1 - x2;
    int y = y1 - y2;
    if (x < 0){
        x = -1 * x;
    }
    if(y < 0){
        y = -1 * y;
    }

    int ans = x + y;
    return ans;
}

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

    vector<int> a(N), b(N), c(M), d(M);
    for (int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }

    for (int i = 0; i < M; i++){
        cin >> c[i] >> d[i];
    }

    vector <int> ans(N);

    for (int i = 0; i < N; i++){
        int min = 1000000007;
        for (int j = 0; j < M; j++){
            int dis = manha(a[i], c[j], b[i], d[j]);
            if (dis < min){
                min = dis;
                ans[i] = j + 1;
            }
        }
    }
    
    for (int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }
    
    
    

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, A, B;
	cin >> N >> A >> B;

	cout << ((B-A)%2==0?"Alice":"Borys") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

// S
var (
	S []string
	t [][]int
	H int
	W int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func printIntln(v ...int) {
	if len(v) == 0 {
		return
	}
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}

func bfs(q [][2]int) [][2]int {
	warpq := make([][2]int, 0)
	for len(q) != 0 {
		h, w := q[0][0], q[0][1]
		warpq = append(warpq, [2]int{h, w})
		q = q[1:]
		if h-1 >= 0 && t[h-1][w] > t[h][w] {
			q = append(q, [2]int{h - 1, w})
			t[h-1][w] = t[h][w]
		}
		if h+1 < H && t[h+1][w] > t[h][w] {
			q = append(q, [2]int{h + 1, w})
			t[h+1][w] = t[h][w]
		}
		if w-1 >= 0 && t[h][w-1] > t[h][w] {
			q = append(q, [2]int{h, w - 1})
			t[h][w-1] = t[h][w]
		}
		if w+1 < W && t[h][w+1] > t[h][w] {
			q = append(q, [2]int{h, w + 1})
			t[h][w+1] = t[h][w]
		}
	}
	return warpq
}

func main() {
	defer flush()

	H = readInt()
	W = readInt()
	Ch := readInt() - 1
	Cw := readInt() - 1
	Dh := readInt() - 1
	Dw := readInt() - 1
	S = make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	t = make([][]int, H)
	for i := 0; i < H; i++ {
		t[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if S[i][j] == '#' {
				t[i][j] = -1
			} else {
				t[i][j] = math.MaxInt64
			}
		}
	}

	t[Ch][Cw] = 0
	q := make([][2]int, 0)
	q = append(q, [2]int{Ch, Cw})

	for len(q) != 0 {
		warpq := bfs(q)
		q = nil
		if t[Dh][Dw] != math.MaxInt64 {
			break
		}
		for i := 0; i < len(warpq); i++ {
			h, w := warpq[i][0], warpq[i][1]
			for i := max(0, h-2); i <= min(H-1, h+2); i++ {
				for j := max(0, w-2); j <= min(W-1, w+2); j++ {
					if t[i][j] <= t[h][w]+1 {
						continue
					}
					t[i][j] = t[h][w] + 1
					q = append(q, [2]int{i, j})
				}
			}
		}
	}

	if t[Dh][Dw] == math.MaxInt64 {
		println(-1)
	} else {
		println(t[Dh][Dw])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 32628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    /*if(x==2||y==2){
        cout<<"No"<<endl;
        goto exit;
    }*/
    
    //vector<int> a{1,3,5,7,8,10,12},b{4,6,9,11};
    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            cout<<"Yes"<<endl;
            goto exit;
        }
    }
    int t;
    t=y;
    y=x;
    x=t;


    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            cout<<"Yes"<<endl;
            goto exit;
        }

    } 
    if(x==4||x==6||x==9||x==11){
        if(y==4||y==6||y==9||y==11){
            cout<<"Yes"<<endl;
            goto exit;
        }
    }
    
    t=y;
    y=x;
    x=t;


    if(x==4||x==6||x==9||x==11){
        if(y==4||y==6||y==9||y==11){
            cout<<"Yes"<<endl;
            goto exit;
        }
    }  
     cout<<"No"<<endl;








    exit:   ;
}

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

set<lint> divisor(lint N){
    set<lint> res;
    for(int i=1;i*i<=N;i++){
        if(N%i==0){
            res.insert(i);
            res.insert(N/i);
        }
    }
    return res; 
}

int main(void){
    lint N;
    cin >> N;
    lint ans=0;
    for(lint i=1;i<=N;i++){
        lint base=i;
        lint cnt=N/i;
        lint add=base*((cnt*(cnt+1))/2);
        ans+=add;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
    int n,a[110],flag=0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3!=0 && a[i]%5!=0)
            {
                flag=1;break;
            }
        }
    }
    if(flag==1)
        cout << "DENIED";
    else
        cout << "APPROVED";
}


Measured memory_bytes: 256
n,x = map(int,input().split())
l = list(map(int,input().split()))

k = 0
s = 1

for i in range(n):
	if k <= x:
		#print(i)
		k = k + l[i]
		#print(k)
		if k <= x:
			s = s + 1
	else:
		pass

print(s)

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

int main() {
  int n,a,b,cu,out;
  cin >> n;
  cu = 0;
  out = 0;
  vector<int> vec(0);
  for (int i = 0 ; i < n ; i++ ) {
    cin >> a;
    vec.push_back(a);
  }
  b = 1;
  for (int i = 0;i < n ; i++){
    cu++;
    if (cu == n){
      out = 1;
      break;
    }
    if (vec.at(b-1) == 2){
      break;
    }
    b = vec.at(b-1);
  }
  if (out == 1){
    cout << -1;
  }
  else {
    cout << cu;
  }
}  

Measured memory_bytes: 3840
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

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

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

ll dp[MXN];

ll solve(ll n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (!dp[n]) dp[n] = solve(n - 1) + solve(n - 2);
  return dp[n];
}

int main() {
  fast();
  ll n;
  cin >> n;
  cout << solve(n);

  return 0;
}



Measured memory_bytes: 3592
N=int(input())
S=[];Y=[0]*4
for i in range(N):
  S.append(input())
#print(S)

for i in range(len(S)):
  if S[i]=="AC":
    Y[0]+=1
  elif S[i]=="WA":
    Y[1]+=1
  elif S[i]=="TLE":
    Y[2]+=1
  elif S[i]=="RE":
    Y[3]+=1

print("AC x",Y[0])
print("WA x",Y[1])
print("TLE x",Y[2])
print("RE x",Y[3])

Measured memory_bytes: 16240
from collections import deque

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

stack = deque(sorted(a))
one = 0
right = stack.pop()
left = right
count = 0
while stack:
    if count % 2 == 0:
        if len(stack) >= 2:
            stack_right = stack.popleft()
            stack_left = stack.popleft()
            one += abs(stack_right - right) + abs(stack_left - left)
            right = stack_right
            left = stack_left
        else:
            stack_one = stack.pop()
            one += max(abs(stack_one - right), abs(stack_one - left))
    else:
        if len(stack) >= 2:
            stack_right = stack.pop()
            stack_left = stack.pop()
            one += abs(stack_right - right) + abs(stack_left - left)
            right = stack_right
            left = stack_left
        else:
            stack_one = stack.pop()
            one += max(abs(stack_one - right), abs(stack_one - left))
    count += 1
stack = deque(sorted(a))
two = 0
right = stack.popleft()
left = right
count = 0
while stack:
    if count % 2 == 1:
        if len(stack) >= 2:
            stack_right = stack.popleft()
            stack_left = stack.popleft()
            two += abs(stack_right - right) + abs(stack_left - left)
            right = stack_right
            left = stack_left
        else:
            stack_one = stack.pop()
            two += max(abs(stack_one - right), abs(stack_one - left))
    else:
        if len(stack) >= 2:
            stack_right = stack.pop()
            stack_left = stack.pop()
            two += abs(stack_right - right) + abs(stack_left - left)
            right = stack_right
            left = stack_left
        else:
            stack_one = stack.pop()
            two += max(abs(stack_one - right), abs(stack_one - left))
    count += 1
print(max(one, two))

Measured memory_bytes: 8936
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll x,r,d,last;
int32_t main(){
CODE_START;
cin>>x;
cout<<x/3;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    a = list(map(int,input().split()))
    sa = list(set(a))
    num = {}

    if sum(sa)==0:
        print("Yes")
        exit(0)
    if (n%3)!=0:
        print("No")
        exit(0)
    for i in a:
        num[i] = num.get(i,0) + 1
    
    OK = False
    if len(num)==3:
        i,j,k = num.values()
        if i==j and j==k and sa[0]==(sa[1]^sa[2]):
            OK = True
    elif len(num)==2:
        i,k = num.keys()
        j,l = num.values()
        if i==0 and j*2==l:
            OK = True
        elif k==0 and l*2==j:
            OK = True
    if(OK):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 14832
#include <bits/stdc++.h>
#define gcj "Case #"
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

int n, k, a[110], ans[2][110000];

int solve(int mode, int lef) {
	if (ans[mode][lef] != -1)
		return ans[mode][lef];

	if (lef == 0)
		return 0;

	ans[mode][lef] = 0;

	for (int i = 1; i <= n; i++) {
		if (lef >= a[i]) {
			ans[mode][lef] += (1 ^ solve(mode^1, lef - a[i]));
		} else {
			break;
		}
	}

	if (mode == 0 and ans[mode][lef] == 0) {
		ans[mode][lef] = 0;
	} else if (mode == 0) {
		ans[mode][lef] = 1;
	}

	if (mode == 1 and ans[mode][lef] > 0) {
		ans[mode][lef] = 1;
	} else if (mode == 1) {
		ans[mode][lef] = 0;
	}

	//cout<<mode<<" "<<lef<<" "<<ans[mode][lef]<<endl;

	return ans[mode][lef];
}

int main() {
	fastio;
	memset(ans, -1, sizeof(ans));
	cin>>n>>k;

	for (int i = 1; i <= n; i++)
		cin>>a[i];

	int ans = solve(1, k);

	cout<<(ans ? "First\n" : "Second\n");

	return 0;
}

Measured memory_bytes: 8960