akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

const ll MOD = 1000000007;

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

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

    vector<ll> xv(n);
    rep(i, n) cin >> xv[i];

    ll tmp_gcd = abs(xv[0]-x);
    for ( int i = 1; i < n; i++ ) {
        tmp_gcd = gcd(tmp_gcd, abs(xv[i]-x));
    }

    cout << tmp_gcd << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    int idx = -1, MIN = INF;
    rep(i, 0, n){
        cin >> h[i];
        int tmp = t * 1000 - h[i] * 6;
        if(abs(tmp - a * 1000) < MIN){
            MIN = abs(tmp - a * 1000);
            idx = i;
        }
    }
    cout << idx + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;

signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int64_t ans=0;
    for(int64_t k=1; k*k<=N; k++){
        if(N%k==0){
            if(N/k-1>k) ans+=N/k-1;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
    char S[4];
    char ABC[4] = "ABC";
    char ARC[4] = "ARC";

    scanf("%s", S, 4);
    if (!strcmp(S, "ARC")){
        printf("ABC");
    }
    else {
        printf("ARC");
    }
    return 0;
}

Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char dif = 'A' - 'a';
    printf("%c%c%c",s1[0] + dif, s2[0] + dif, s3[0] + dif);
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include<set>
#define mod 1000000007

int main() {
    int n; std::cin >> n;
    std::set<int> an;

    std::vector<int> a(n);
    for(int i = 0; i < n; i++) {
        std::cin >> a[i];
        an.insert(a[i]);
    }

    bool iszero = false;
    std::sort(a.begin(), a.end());

    for(auto itr = an.begin(); itr != an.end(); itr++) {
        int num = std::upper_bound(a.begin(), a.end(), *itr) - std::lower_bound(a.begin(),a.end(), *itr);
        if(num != 2 && *itr != 0) {
            iszero = true;
        }
    }

    int power = n / 2;

    long long ans = 1;
    for(int i = 0; i < power; i++) {
        ans *= 2;
        ans %= mod;
    }

    if(iszero) {
        ans = 0;
    }

    std::cout << ans << std::endl;

}

Measured memory_bytes: 6696
while True:
    c = 0
    [n,x] = map(int,raw_input().split())
    if n == 0 and x == 0:
        break
    for p in range(1,n-1):
        for q in range(p+1,n):
            for s in range(q+1,n+1):
                if p + q + s == x:
                    c = c + 1
    print c

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, p[1000], d[1000];
vector<vector<P> > g;

int main() {
    while(cin >> n, n){
        g.clear();
        g.resize(n);
        REP(i,n-1){
            cin >> p[i];
            p[i]--;
        }
        REP(i,n-1){
            cin >> d[i];
        }
        REP(i,n-1){
            g[i+1].push_back({p[i],d[i]});
            g[p[i]].push_back({i+1,d[i]});
        }

        bool visited[1000]{};
        ll dmin[1000], ma=0, idx=0;
        REP(k,3){
            fill(visited,visited+n,false);
            fill(dmin,dmin+n,0);
            ma = 0;
            queue<int> que;
            que.push(idx);
            dmin[idx] = 0;
            while(!que.empty()){
                int now = que.front();
                que.pop();
                visited[now] = true;
                for(auto e : g[now]){
                    if(!visited[e.first]){
                        que.push(e.first);
                        dmin[e.first] = dmin[now] + e.second;
                    }
                }
            }
            REP(i,n){
                if(int(g[i].size())>1){
                    if(dmin[i] > ma){
                        ma = dmin[i];
                        idx = i;
                    }
                }
            }
        }
        ll ans = 0;
        REP(i,n-1){
            ans += d[i]*3;
        }
        REP(i,n){
            if(int(g[i].size())==1){
                for(auto e : g[i]){
                    ans -= e.second*2;
                }
            }
        }
        ans -= ma;
        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 3280
#include <stdio.h>

int main()
{
	int count = 0;
	char S[4], T[4];
	scanf("%s", S);
	scanf("%s", T);
	if (S[0] == T[0]) count++;
	if (S[1] == T[1]) count++;
	if (S[2] == T[2]) count++;
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
use std::f64;
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();

    let strs: Vec<&str> = line.split_whitespace().collect();
    let a: f64 = strs[0].parse().unwrap();
    let b: f64 = strs[1].parse().unwrap();
    let x: f64 = strs[2].parse().unwrap();

    let s = a * a * b;
    if x > s / 2.0 {
        let y = 2.0 * (s - x) / (a * a);
        println!("{:.7}", 90.0 - (a / y).atan() / f64::consts::PI * 180.0);
    } else {
        let y = 2.0 * x / (a * b);
        println!("{:.7}", 90.0 - (y / b).atan() / f64::consts::PI * 180.0);
    }
}


Measured memory_bytes: 4352
n=int(input())
A=list(map(int,input().split()))
isApprove=True
for i in range(n):
  if A[i]%2==0 and A[i]%3!=0 and A[i]%5!=0:
    isApprove=False
    break
print('APPROVED' if isApprove else 'DENIED')


Measured memory_bytes: 38384
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int ans = 0;
		
		switch(S) {
		
		case("SUN") : ans = 7;
			break;
		case("MON") : ans = 6;
			break;
		case("TUE") : ans = 5;
			break;
		case("WED") : ans = 4;
			break;
		case("THU") : ans = 3;
			break;
		case("FRI") : ans = 2;
			break;
		case("SAT") : ans = 1;
			break;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n; cin >> n;
    map<int, int> mp;
    rep1(i, n) {
        int a; cin >> a;
        mp[a] = i;
    }
    rep1(i, n) {
        cout << mp[i] << " ";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  double N;
  cin >> N;

  rep(h, 1, 3501) {
    rep(n, 1, 3501) {
      double w = (N * h * n) / (4 * h * n - N * n - N * h);
      if (w > 0 && w == (int)w) {
        cout << h << " " << n << " " << (int)w << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	bool flag = true;
	for (ll i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		if (s.length() + 1 != t.length()) {
			flag = false;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;

}

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

dif=sum(a)-sum(b)
if dif<0:
    print(-1)
    
elif dif==0:
    cnt=0
    for i in range(n):
        if a[i]!=b[i]:
            cnt+=1
    print(cnt)
    
else:
    difference=[]
    count_0=0
    for i in range(n):
        if a[i]-b[i]>0:
            difference.append(a[i]-b[i])
        elif a[i]==b[i]:
            count_0+=1
    difference=sorted(difference)
    
    cnt=0
    keep=0
    for i in range(len(difference)):
        if cnt+difference[i]<=dif:
            cnt+=difference[i]
            keep+=1
        else:
            break
    print(n-count_0-keep)

Measured memory_bytes: 19508
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 102;
const int K = 100005;
const int mod = (int) 1e9 + 7;

int n, k;
int a[N];
int dp[N][K];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[n][0] = 1;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j <= k; j++) {
			(dp[i][j] += dp[i + 1][j]) %= mod;
			if (j > 0)
				(dp[i][j] += dp[i][j - 1]) %= mod;
			if (j - a[i] - 1 >= 0)
				dp[i][j] -= dp[i + 1][j - a[i] - 1];
			if (dp[i][j] < 0)
				dp[i][j] += mod;
		}
	}
	cout << dp[0][k] << endl;
	return 0;
}


Measured memory_bytes: 39296
#![allow(dead_code)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    bytes: Vec<u8>,
    begin: usize,
    end: usize,
}

impl Scanner {
    pub fn new() -> Self {
        use std::io::Read;
        let mut buffer: Vec<u8> = Vec::with_capacity(37_000_000);
        std::io::Read::read_to_end(&mut std::io::stdin(), &mut buffer).unwrap();
        let mut end = 0;
        while end < buffer.len() && !buffer[end].is_ascii_whitespace() {
            end += 1;
        }
        Scanner {
            bytes: buffer,
            begin: 0,
            end: end,
        }
    }
    pub fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
        let ret: T = s.parse::<T>().unwrap();
        self.skip();
        ret
    }
    pub fn next_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
    pub fn next_word(&mut self) -> Vec<u8> {
        let r = Vec::from(&self.bytes[self.begin..self.end]);
        self.skip();
        r
    }
    fn skip(&mut self) {
        let mut begin = self.end;
        while begin < self.bytes.len() && self.bytes[begin].is_ascii_whitespace() {
            begin += 1;
        }
        let mut end = begin;
        while end < self.bytes.len() && !self.bytes[end].is_ascii_whitespace() {
            end += 1;
        }
        self.begin = begin;
        self.end = end;
    }
}

fn lower_bound<T: std::cmp::Ord>(v: &Vec<T>, val: &T) -> usize {
    let mut lb: isize = -1;
    let mut ub: isize = v.len() as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        if *val <= v[mid as usize] {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub as usize;
}

fn dfs(
    u: usize,
    p: usize,
    dp: &mut Vec<i32>,
    ans: &mut Vec<usize>,
    a: &Vec<i32>,
    edge: &Vec<Vec<usize>>,
    pans: usize,
) {
    let idx = lower_bound(dp, &a[u]);
    let prev = dp[idx];
    ans[u] = if dp[idx] == i32::max_value() {
        pans + 1
    } else {
        pans
    };
    dp[idx] = a[u];

    for v in &edge[u] {
        if *v == p {
            continue;
        }
        dfs(*v, u, dp, ans, a, edge, ans[u]);
    }
    dp[idx] = prev;
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<i32> = scan.next_vec(n);
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u: usize = scan.next();
        let v: usize = scan.next();
        let (u, v) = (u - 1, v - 1);
        edge[u].push(v);
        edge[v].push(u);
    }
    let mut dp: Vec<i32> = vec![i32::max_value(); n];
    let mut ans: Vec<usize> = vec![0; n];
    dfs(0, 0, &mut dp, &mut ans, &a, &edge, 0);
    for x in ans {
        println!("{}", x);
    }
}


Measured memory_bytes: 39444
import java.util.Scanner;

class Main{

	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		System.out.print(s.next().charAt(0));
		System.out.print(s.next().charAt(1));
		System.out.print(s.next().charAt(2));
		System.out.println();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC138
    int N;
    cin>>N;
    int Q;
    cin>>Q;
    vector<vector<int> > GRAPH(N,vector<int>(0,0));
    vector<int> NODE(N,0);

    int A,B;


    for (int i = 0; i < N -1 ; i++)
    {
        /* code */
        cin>>A>>B;
        GRAPH[ A - 1].push_back(B - 1);
        GRAPH[B - 1].push_back(A - 1);
    }

    int P,X;

    for (int i = 0; i < Q; i++)
    {
        /* code */
        cin>>P>>X;
        NODE[P-1] += X;
    }

    vector<bool> used(N);
    
    


    deque<int> q;
    q.push_back(0);
    while(q.size())
    {
        int t = q[0];
        q.pop_front();
        if(used[t]) continue; //trueならスキップ
        used[t] = true;
        for(auto i : GRAPH[t])//Graph[t]の要素iについて
        {
            if(!used[i])//探索済みでなければ
            {
                NODE[i] += NODE[t];//親の値を子に足す
                q.push_back(i);//キューに子の値を追加
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << NODE[i] << " ";
    }

    return 0;

}





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

using namespace std;
int main(){
	string s;
	cin>>s;
	int a[4];
	for(int i=0;i<4;i++)a[i]=s[i]-'0';
	int m,y;
	m=a[2]*10+a[3];
	y=a[0]*10+a[1];
	if(m>=1&&m<=12&&y>=1&&y<=12) cout<<"AMBIGUOUS";
	else if(m>=1&&m<=12)cout<<"YYMM";
	else if(y>=1&&y<=12)cout<<"MMYY";
	else cout<<"NA";
	return 0;
}

Measured memory_bytes: 256
l = [int(input()) for i in range(5)]
ll = []
ans = -10
for i in range(5):
    if l[i] % 10 ==0:
        ans += l[i]
    else:
        ll.append(l[i]%10)
        ans += (l[i]//10 + 1)*10
if ll == []:
    ans += 10
else:
    ans += min(ll)
print(ans)

Measured memory_bytes: 3060
use std::vec::Vec;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b, k): (i64, i64, i64) = {
      let v = read_vec();
      (v[0], v[1], v[2])
    };

    let mut res = cmp::min(a, b);
    let mut count = 0;
    loop {
      if a % res == 0 && b % res == 0 {
        count += 1;
      }

      if count == k {
       break;
      }
      res -= 1;
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int year,month,day,a=2019,b=04,c=30;
	scanf("%d/%d/%d",&year,&month,&day);
	if(a!=year)
	{
		printf("TBD");
		return 0;
	}
	if(month>b)
	{
		printf("TBD");
		return 0;
	}
	printf("Heisei");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final int p = 3;
        switch (p) {
        case 3:
            C.answer();
            break;
        case 2:
            B.answer();
            break;
        case 1:
            A.answer();
            break;
        }
    }
}

class C {

    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int[] array = new int[n];
        array[0] = Integer.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            array[i] = sc.nextInt();
        }

        final int res = calc(array);
        System.out.println(res);
    }

    static int calc(final int[] array) {
        int total = 0;
        for (int i = 0; i < array.length - 1; i++) {
            total += Math.min(array[i], array[i + 1]);
        }
        total += array[array.length - 1];
        return total;
    }
}

class B {

    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int[] arrayA = new int[n];
        for (int i = 0; i < n; i++) {
            arrayA[i] = sc.nextInt();
        }
        final int[] arrayB = new int[n];
        for (int i = 0; i < n; i++) {
            arrayB[i] = sc.nextInt();
        }
        final int[] arrayC = new int[n];
        for (int i = 0; i < n - 1; i++) {
            arrayC[i] = sc.nextInt();
        }
        final int res = calc(arrayA, arrayB, arrayC);
        System.out.println(res);
    }

    static int calc(final int[] arrayA, final int[] arrayB, final int[] arrayC) {
        int total = 0;
        int prevRyori = -100;
        for (int i = 0; i < arrayA.length; i++) {
            final int ryoriNo = arrayA[i];
            final int manpuku = arrayB[ryoriNo - 1];
            total += manpuku;
            if (ryoriNo - prevRyori == 1) {
                total += arrayC[prevRyori - 1];
            }
            prevRyori = ryoriNo;
        }

        return total;
    }
}

class A {
    static void answer() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int res = calc(n);
        System.out.println(res);
    }

    static int calc(final int n) {
        return n * n * n;
    }
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, A[100000], count = 0, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 0; i < N; i++) {
		if (count * 2 < A[i]) ans = i;
		count += A[i];
	}
	cout << N - ans;
}

Measured memory_bytes: 1024
#include <cstdio>

int main(){
	double a,b;
	while(scanf("%lf%lf", &a, &b) != EOF){
		if(a < 35.50 && b < 71.00) printf("AAA\n");
		else if(a < 37.50 && b < 77.00) printf("AA\n");
		else if(a < 40.00 && b < 83.00) printf("A\n");
		else if(a < 43.00 && b < 89.00) printf("B\n");
		else if(a < 50.00 && b < 105.00) printf("C\n");
		else if(a < 55.00 && b < 116.00) printf("D\n");
		else if(a < 70.00 && b < 148.00) printf("E\n");
		else printf("NA\n");
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  string s;cin>>s;
  bool f=false;
  
  rep(i, s.size()/2){
    if(s[i*2]=='h' && s[i*2+1]=='i')f=true;
  }

  if(f && s.size()%2==0)cout<<"Yes";
  else cout<<"No";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
ll gcd(ll a,ll b)
{
    return b>0?gcd(b,a%b):a;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll x;
    scanf("%lld",&x);
    ll gca=x;
    for(int i=1;i<n;i++)
    {
        scanf("%lld",&x);
        ll xx=gcd(gca,x);
        gca=gca/xx*x;
    }
    printf("%lld\n",gca);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s,p;
	cin>>s>>p;
	s+=s;
	int j;
	for(int i=0;i<s.size()-p.size();i++){
		for(j=0;j<p.size();j++){
			if(s[j+i]!=p[j]) break;
		}
		if(j>=p.size()){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
	}


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

int main() {
    int N;
    cin >> N;
    long long ketasuu = 0, sum = 0;
    for (int i = 0; i < N; ++i) {
        long long d, c;
        cin >> d >> c;
        ketasuu += c;
        sum += d * c;
    }
    cout << (sum - 1) / 9 + (ketasuu - 1) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        int c = scan.nextInt();
        int[][] d = new int[c][c];
        for (int i = 0; i < c; i++) {
            for (int j = 0; j < c; j++) {
                d[i][j] = scan.nextInt();
            }
        }
        int[][] g = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = scan.nextInt() - 1;
            }
        }
        Main main = new Main();
        System.out.println(main.solve(n, c, d, g));
    }
    public int solve(int n, int c, int[][] d, int[][] g) {
        if (n == 1) {
            return 0;
        }
        Map<Integer, Map<Integer, Integer>> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if (!map.containsKey((i+j) % 3)) {
                    Map<Integer, Integer> t = new HashMap<>();
                    map.put((i+j) % 3, t);
                }
                Map<Integer, Integer> entry = map.get((i+j) % 3);
                if (!entry.containsKey(g[i][j])) {
                    entry.put(g[i][j], 0);
                }
                Integer count = entry.get(g[i][j]);
                entry.put(g[i][j], count+1);
            }
        }
        int answer = Integer.MAX_VALUE;
        for (int i = 0; i < c; i++) {
            int i_diff = subAnswer(d, map.get(0), i);
            for (int j = 0; j < c; j++) {
                if (i == j) {
                    continue;
                }
                int j_diff = subAnswer(d, map.get(1), j);
                for (int k = 0; k < c; k++) {
                    if (i == k || j == k) {
                        continue;
                    }
                    int k_diff = subAnswer(d, map.get(2), k);
                    answer = Math.min(answer, i_diff+j_diff+k_diff);
                }
            }
        }
        return answer;
    }
    public int subAnswer(int[][] d, Map<Integer, Integer> base, int color) {
        int diff = 0;
        for(int i : base.keySet()) {
            if (i == color) {
                continue;
            }
            int count = base.get(i);
            diff += count * d[i][color];
        }
        return diff;
    }

}


Measured memory_bytes: 89932
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N,M=map(int,input().split())
A=[0]*M
B=[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

uf=UnionFind(N+1)
for i in range(M):
    uf.union(A[i],B[i])
a=[0]*(N+1)
con=0

for i in uf.parents:
    if(i<0):
        con=con+1

print(con-2)


Measured memory_bytes: 76760
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
ll k;
int lst[N];
int a[N];
int in[N];
int nxt[N];

int main() {
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", a + i);
		lst[a[i]] = i;
	}
	for (int i = 1; i <= n; i ++) {
		nxt[lst[a[i]]] = i;
		lst[a[i]] = i;
	}
	int p = 1;
	vector < int > pos;

	while (p <= n) {
		if (nxt[p] <= p) {
			pos.pb(p);
		}
		p = nxt[p] + 1;
	}

	pos.pb(1);
	k = (k - 1) % pos.size();
	vector < int > ans;
	for (int i = pos[k]; i <= n; i ++) {
		if (in[a[i]]) {
			while (ans.back() != a[i]) {
				in[ans.back()] = 0;
				ans.pop_back();
			}
			in[ans.back()] = 0;
			ans.pop_back();
			
		} else {
			ans.pb(a[i]);
			in[a[i]] = 1;
		}
	}

	for (auto x : ans) cout << x << ' ';


	return Accepted;
}
         
// B...a

Measured memory_bytes: 6260
#coding:utf-8
import math

def primeFact(P):
    s = math.floor(math.sqrt(P))
    result = {}

    for i in range(2, s + 1):
        if P % i == 0:
            r = 0
            while P % i == 0:
                r += 1
                P = P // i
            result[i] = r

    if P > s:
        result[P] = 1
    return result

def gcd(N, fact):
    gcd = 1
    for key in fact.keys():
        if fact[key] >= N:
            gcd *= key ** (fact[key] // N)
    return int(gcd)

if __name__ == "__main__":
    N, P = map(int, input().split())
    fact = primeFact(P)
    print(gcd(N, fact))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] line = sc.nextLine().split(" ");
    int a = Integer.parseInt(line[0]);
    int b = Integer.parseInt(line[1]);
    if ((a + b) % 2 == 0) {
    	System.out.println((a + b) / 2);
    } else {
    	System.out.println("IMPOSSIBLE");
    }
    
    }
}

Measured memory_bytes: 21844
program main;
var N, i : LongInt;
    c, b : real;
    A : array[1..1000000] of LongInt;
    sum : int64;
begin
	read(N);
    sum := 0;
    for i := 1 to N do begin
        c := frac(i / 3);
        b := frac(i / 5);
        if (c = 0) or (b = 0)
        then A[i] := 0
        else A[i] := i;
        sum := sum + A[i];
    end;
    writeln(sum);
end.

Measured memory_bytes: 4100
#include<iostream>
 using namespace std;
 bool isHuiWen(int num){
  int temp;
  int sum = 0;
  temp = num;
  while (num)
  {
   sum = sum * 10 + num % 10;
   num /= 10;
  }
  if (temp == sum)
   return true;
  else
   return false;
 }
 int main()
 {


  int a, b;
  while (cin >> a >> b)
  {
  int count = 0;
  for (int i = a; i <= b; i++){
   if (isHuiWen(i))
    count++;
  }
  cout  << count << endl;
  }
  return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll a;
  cin >> a;
  
  cout << a +a * a + a * a * a << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

namespace {
    const int offset = 97;
}

int main() {
    int res[26] = {0};
    while(true) {
        string s;
        cin >> s;
        if (cin.eof())
            break;
        
        for (char& c : s) {
            int i = static_cast<int>(tolower(c));
            res[i-offset]++;
        }
    }
    for (int i = 0; i < 26; i++) {
        char c = static_cast<char>(i+offset);
        cout << c << " : " << res[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    double a, b, x;
    cin >> a >> b >> x;
    double l = 2 * x / (a * a) - b;
    if (l < 0) {
        double h = 2 * x / (a * b);
        cout << 90 - (180 * atan(h / b) / M_PI) << endl;
        return 0;
    }
    
    cout << 90 - (180 * atan(a / (b - l)) / M_PI) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

string str;

bool check(int i, string de) {
    bool ret = true;
    for (int j = 0; j < de.size() - 1; j++) {
        if (str[i - 1 - j] != de[de.size() - 2 - j]) {
            ret = false;
            break;
        }
    }
    return ret;
}

int main() {
    cin >> str;

    string dm = "dream", dmr = "dreamer", es = "erase", esr = "eraser";
    bool flag = true;
    for (int i = str.size() - 1; i >= 0; i--) {
        if (str[i] == 'm') {
            flag = check(i, dm);
            i -= 4;
        } else if (str[i] == 'e') {
            flag = check(i, es);
            i -= 4;
        } else if (str[i] == 'r') {
            if (i - 2 >= 0) {
                if (str[i - 2] == 'm') {
                    flag = check(i, dmr);
                    i -= 6;
                } else if (str[i - 2] == 's') {
                    flag = check(i, esr);
                    i -= 5;
                } else {
                    flag = false;
                }
            } else {
                flag = false;
            }
        } else {
            flag = false;
        }
        if (!flag) {
            break;
        }
    }
    if (flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

using std::cin;
using std::cout;
using std::endl;

#define ForIndex(N) for (size_t index = 0; index < (N); index++)
#define ForIndex2D(X, Y) \
    for (size_t i = 0; i < (X); i++) {\
        for (size_t j = 0; j < (Y); j++)

template<typename T>
void input2DArray(T**& outArray, size_t xsize, size_t ysize)
{
    outArray = new T*[xsize];

    for (size_t i = 0; i < xsize; i++)
    {
        outArray[i] = new T[ysize];
        for (size_t j = 0; j < ysize; j++)
        {
            cin >> outArray[i][j];
        }
    }
}

template<typename T>
void input2DArrayForQ(T**& outArray, size_t xsize)
{
    outArray = new T*[xsize];

    for (size_t i = 0; i < xsize; i++)
    {
        outArray[i] = new T[2];
        cin >> outArray[i][0] >> outArray[i][1];
    }
}

// char は一気に入力できるので特殊化
template<>
void input2DArray(char**& outArray, size_t xsize, size_t ysize)
{
    outArray = new char*[xsize];

    for (size_t index = 0; index < xsize; index++)
    {
        outArray[index] = new char[ysize];
        cin >> outArray[index];
    }
}

template<typename T>
void delete2DArray(T**& array, size_t size)
{
    for (size_t index = 0; index < size; index++)
    {
        delete [] array[index];
    }

    delete [] array;
}

int calcCost(const std::pair<int, int>& c, const std::pair<int, int>& o)
{
    return std::abs(c.first - o.first) + std::abs(c.second - o.second);
}

int main()
{
    int H, W, D;
    cin >> H >> W >> D;

    int** s;
    input2DArray(s, H, W);

    uint32_t Q;
    cin >> Q;

    int** lr;
    input2DArrayForQ(lr, Q);

    // index map を作っておく
    std::unordered_map<int, std::pair<int, int>> mapMemo;
    ForIndex2D(H, W)
    {
        mapMemo.emplace(s[i][j], std::make_pair(i, j));
    }}

    // 完全なコストマップを作る
    std::unordered_map<int, int> costMemo;
    // const auto searchIndex = [](int l, int r) {
    //     return 1000 * r + l;
    // };

    const int maxSize = H * W;
    // for (int l = 1; l <= maxSize; l++)
    // {
    //     int prevIndex = searchIndex(l, l);
    //     costMemo[prevIndex] = 0; // l が同じ時はコストゼロ

    //     for (int r = l + D; r <= maxSize; r += D)
    //     {
    //         const auto& currentPair = mapMemo[r];
    //         const auto& prevPair = mapMemo[r - D];

    //         const int newIndex = searchIndex(l, r);

    //         // 1つ手前のコストは必ず計算済み
    //         costMemo.emplace(newIndex, costMemo[prevIndex] + calcCost(currentPair, prevPair));
    //         prevIndex = newIndex;
    //     }
    // }
    for (int i = 1; i <= maxSize - D; i++)
    {
        const auto& currentPair = mapMemo[i];
        const auto& nextPair = mapMemo[i + D];
        costMemo[i + D] = costMemo[i] + calcCost(nextPair, currentPair);
    }

    ForIndex(Q)
    {
        const int l = lr[index][0];
        const int r = lr[index][1];
        cout << (costMemo[r] - costMemo[l]) << endl;
    }

    // delete2DArray(lr, Q);
    // delete2DArray(s, H);
    return 0;
}

Measured memory_bytes: 12964
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=998244353;

vector<vector<int>> q(2),w(2),tmp(2);

int mi[28]={1,1,2,3,5,8,13,1,2,4,7,12,20,33,1,3,7,14,26,46,79,1,4,11,25,51,97,176};
int b[223456],nCkm[223456];//nCkm[i]:nCk(i+m-1,i-1)
void mul(vector<vector<int>> &s,vector<vector<int>> t){
  tmp[0][0]=s[0][0]*t[0][0]+s[0][1]*t[1][0];
  tmp[0][1]=s[0][0]*t[0][1]+s[0][1]*t[1][1];
  tmp[1][0]=s[1][0]*t[0][0]+s[1][1]*t[1][0];
  tmp[1][1]=s[1][0]*t[0][1]+s[1][1]*t[1][1];
  for(int i=0;i<2;i++)for(int j=0;j<2;j++)s[i][j]=tmp[i][j]%MOD;
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
int fi(int a){
  q[0][0]=1,q[0][1]=1,q[1][0]=1,q[1][1]=0;
  w[0][0]=1,w[0][1]=w[1][0]=0,w[1][1]=1;
  while(a){
    if(a&1)mul(w,q);
    mul(q,q);
    a>>=1;
  }
  return w[1][0];
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  for(int i=0;i<2;i++){
    q[i].resize(2);
    w[i].resize(2);
    tmp[i].resize(2);
  }
  int n,m;cin>>n>>m;n--;
  nCkm[1]=1;
  for(int i=2;i<=n;i++)nCkm[i]=((nCkm[i-1]*((i+m-1)%MOD))%MOD*pw(i-1,MOD-2))%MOD;
  if(n<4&&m<8)fin(mi[n*7+m-1]);
  b[0]=MOD-1,b[1]=MOD-2;
  for(int i=2;i<223456;i++)b[i]=(3*b[i-1]-b[i-2]+MOD)%MOD;
  int ans=0;
  for(int i=1;i<=n;i++)ans+=(nCkm[i]*b[n-i])%MOD,ans%=MOD;
  ans+=(fi(m+1)*(2*b[n]-b[n+1]+MOD)+fi(m)*(-3*b[n]+b[n+1]+3*MOD))%MOD,ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 3584
# ABC 123: A – Five Antennas
import sys

a, b, c, d, e, k = [int(input()) for _ in range(6)]
can_directly = True

for i in [a, b, c, d, e]:
    for j in [a, b, c, d, e]:
        if j - i > k:
            can_directly = False

print('Yay!' if can_directly else ':(')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define ai64(v) (v).begin(), (v).end()
#define eb emplace_back

struct mint{
    using i64 = int_fast64_t;
    i64 x;
    const i64 MOD = 1000000007;

    mint(const i64 y = (i64)0) noexcept : x(y) { if(x >= MOD) x %= MOD; }
    mint operator+() const noexcept {return x;}
    mint operator-() const noexcept {return -x;}

    mint operator+(const mint y) const noexcept {return (mint)*this += y; }
    mint operator-(const mint y) const noexcept {return (mint)*this -= y; }
    mint operator*(const mint y) const noexcept {return (mint)*this *= y;}
    mint operator/(const mint y) const noexcept {return (mint)*this /= y;}

    mint& operator+=(const mint y) noexcept {
        x += y.x; 
        if(x >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint y) noexcept {
        x -= y.x;
        if(x < 0) x += MOD;
        return *this;
    }
    mint& operator*=(const mint y) noexcept {
        x *= y.x;
        if(x >= MOD) x %= MOD;
        return *this;
    }
    mint& operator/=(mint y) noexcept {
        i64 exp = MOD - 2;
        while(exp){
            if(exp & 1) *this *= y;
            y *= y;
            exp /= 2;
        }
        return *this;
    }
    friend std::ostream& operator<< (std::ostream& os, const mint& m);
    friend std::istream& operator>> (std::istream& in, mint& m);
};
std::ostream& operator<<(std::ostream& os, const mint& m){
    os << m.x;
    return os;
}
std::istream& operator>> (std::istream& in, mint& m){
    in >> m.x; 
    if(m.x < 0) m.x += 1000000007;
    if(m.x >= 1000000007) m.x %= 1000000007;
    return in; 
}

mint fact(i64 n){

    const i64 mod = 1000000007;

    if(n >= mod){
        cout << 0 << endl;
        return 0;
    }

    i64 ume[11] = {1, 927880474, 933245637, 668123525, 429277690, 733333339, 
                    724464507, 957939114, 203191898, 586445753, 698611116};

    i64 x = 100000000;
    i64 ans = ume[n/x];

    for(i64 i = n/x*x+1; i <= n; i++){
        ans *= i;
        ans %= mod;
    }

    return mint(ans);
}

mint POW(mint x, i64 n){
    mint res = 1;
    while(n){
        if(n&1) res *= x; 
        x *= x;
        n >>= 1;
    }
    return res;
}

int main(){
    i64 N, A, B;
    cin >> N >> A >> B;
    mint ans(POW(mint(2), N) - 1);
    mint n(fact(N)), a(fact(A)), b(fact(B));
    mint c(fact(N-A)), d(fact(N-B));
    ans -= ((n/(a*c)) + n/(b*d));
    cout << ans << endl;
}

Measured memory_bytes: 256
s = int(input())
mod = 10**9+7
d = [0]*(s+1)

for i in range(3,s+1):
    for j in range(3,s+1):
        
        if i-j < 3:
            break
        d[i] += d[i-j]
        d[i] %= mod
    d[i] += 1
    d[i] %= mod
        
print(d[-1]%mod)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  vector<int>m(4,0);
  for(int i=0;i<3;i++)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    m[a]++;m[b]++;

  }
  for(int i=0;i<4;i++)
  {
    if(m[i]==0 or m[i]==3){cout<<"NO";return 0;}
  }
   cout<<"YES";

}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	Scanner in = new Scanner(System.in);
	char[][] map = new char[10][10];
	boolean flag = true;
	int[] dirx = {-1, 0, 1, -1, 1, -1, 0, 1};
	int[] diry = {-1, -1, -1, 0, 0, 1, 1, 1};
	
	int put(char color, int y, int x) {
		int ret = 0;
		if (map[y][x] != '.') return ret;
		for (int i = 0; i < dirx.length; i++) {
			int stoneNum = checkDir(color, x, y, i);
			ret += stoneNum;
		}
		return ret;
	}
	
	int checkDir(char color, int x, int y, int dir) {
		char c = map[y+diry[dir]][x+dirx[dir]];
		if (c == 0 || c == '.' || c == color) return 0;
		else {
			for (int j = 2; j < dirx.length; j++) {
				c = map[y+diry[dir]*j][x+dirx[dir]*j];
				if (c == 0 || c == '.') return 0;
				else if (c == color) return j - 1;
				else continue;
			}
		}
		return 0;
	}
	
	void flip(char color, int x, int y) {
		for (int i = 0; i < dirx.length; i++) {
			int stoneNum = checkDir(color, x, y, i);
			for (int k = stoneNum; k >= 0; k--) {
				map[y+diry[i]*k][x+dirx[i]*k] = color;
			}
		}
	}
	
	public void run() {
		for (int i = 1; i <= 8; i++) {
			String s = in.next();
			for (int j = 0; j < 8; j++) {
				map[i][j+1] = s.charAt(j);
			}
		}
		
		int max;
		int x, y;
		while (flag) {
			flag = false;
			max = 0;
			x = -1; y = -1;
			for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (max < put('o', i, j)) {
						y = i; x = j;
						max = put('o', i, j);
					}
				}
			}
			if (max != 0) {
				flip('o', x, y);
				flag = true;
			}
			max = 0;
			x = -1; y = -1;
			for (int i = 8; i > 0; i--) {
				for (int j = 8; j > 0; j--) {
					if (max < put('x', i, j)) {
						y = i; x = j;
						max = put('x', i, j);
					}
				}
			}
			if (max != 0) {
				flip('x', x, y);
				flag = true;
			}
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				System.out.print(map[i][j]);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 18840
#include <iostream>

using namespace std;

int N, M, Q;
int dif[505][505];
int sum[505][505];

int main(void)
{
	cin >> N >> M >> Q;
	for(int i = 0; i < M; i++){
		int l, r;
		cin >> l >> r;
		dif[l][r]++;
	}
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			sum[i][j] = dif[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
		}
	}
	
	for(int q = 0; q < Q; q++){
		int a, b;
		cin >> a >> b;
		cout << sum[N][b] - sum[a-1][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
/*
1000000000000
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y) { cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}

void Main() {
  ll h, ans = 0, num = 1;
  cin >> h;
  while (h) {
    ans += num;
    h /= 2;
    num *= 2;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 256