akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

long long int gcd(long long int a, long long int b) {
    if (a < b)swap(a, b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL N,M; cin >> N >> M;
    VL A(N),B(N);

    REP(i,N) {
        cin >> A[i];
        A[i] /= 2;
        LL tmp = A[i];
        while(tmp%2 == 0){
            tmp /= 2;
            B[i]++;
        }
    }
    FOR(i,1,N){
        if(B[i] != B[0]){
            cout << 0 << endl;
            return 0;
        }
    }



    LL lcm = A[0];
    FOR(i,1,N){
        lcm = lcm / gcd(lcm,A[i]) * A[i];
        if(lcm > M){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M / lcm + 1) / 2 << endl;







}


Measured memory_bytes: 1792
// C - Same Integers
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int A,B,C; cin>>A>>B>>C;
	vi S{A,B,C};
	int ans = 0;
	rpz(i, 3){
		if((S[i]&1) != ((A+B+C)&1)){
			S[i]++;
			ans = 1;
		}
	}
	sort(all(S));
	ans += (S[2]-S[0])/2 + (S[2]-S[1])/2;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	bool ans = true;
	int cnt2 = 0;
	int cnt4 = 0;
	rep(i,N){
		int a;
		cin>>a;
		if(a%2==0 && a%4!=0)cnt2++;
		if(a%4==0)cnt4++;
	}
	int elses = N-cnt4-cnt2;
	if(cnt2>=2){
		if(cnt4<elses)ans = false;
	}else{
		if(cnt4<elses+cnt2-1)ans = false;
	}
	cout<<((ans)?"Yes":"No")<<endl;
	return 0;
}

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

const int BIT_LENGTH = 1024;
const int INF = 2000000000;

int nbits(int x) {
    if (x == 0)
        return 0;
    return (x & 1) + nbits(x >> 1);
}

int main() {
    int n;
    cin >> n;
    int f[n];
    fill(f, f + n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            int b;
            cin >> b;
            f[i] <<= 1;
            f[i] |= b;
        }
    }
    int p[n][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }

    int ans = - INF;
    for (int b = 1; b < BIT_LENGTH; b++) {
        int sum_p = 0;
        for (int i = 0; i < n; i++) {
            sum_p += p[i][nbits(f[i] & b)];
        }
        ans = max(ans, sum_p);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX_N = 100;

void show(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


int bubbleSort(int A[], int N) {
    int flag = 1;
    int num = 0;
    while (flag) {
        flag = 0;
        for (int i = N - 1; i > 0; i--) {
            if (A[i] < A[i - 1]) {
                int tmp = A[i];
                A[i] = A[i -  1];
                A[i - 1] = tmp;
                flag = 1;
                num++;
            }
        }
    }
    return num;
}

int main() {
    int a[MAX_N] = {0};
    int N = 0;
    cin >> N;
    for (int i = 0; i < N; i++)  cin >> a[i];
    //insertionSort(a, N);
    int num = bubbleSort(a, N);
    show(a, N);
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 3088
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

print("No" if len(set(S))==1 else "Yes")

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b,c,k;
  	cin >>a>>b>>c>>k;
  	
  	if(k - a <= 0) cout << k << endl;
  
  	else if(k-a-b<=0) cout << a << endl;
  	else cout << a -(k-a-b) << endl;
  
}

Measured memory_bytes: 3608
import java.util.*;
class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.charAt(s.length()-1)!='s')System.out.println(s+"s");
		else if(s.charAt(s.length()-1)=='s') System.out.println(s+"es");

	}

}


Measured memory_bytes: 38440
void main() {
  problem();
}

void problem() {
  auto S = scan;
  auto T = scan;
    auto SL = S.length;
    auto TL = T.length;

  long solve() {
    int max_contained;

    foreach(i; 0..SL - TL + 1) {
      int contained;
      foreach(j; 0..TL) {
        if (T[j] == S[i + j]) contained++;
      }

      if (max_contained < contained) max_contained = contained;
    }

    return TL - max_contained;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2736
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
	int n,k;
	cin >> n >> k;
	if(n % k == 0){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;


bool test(const string &s,char a){
    for(auto i:s){
        if(i!=a){
            return false;
        }
    }
    return true;
}
int main()
{
    
    
    string s;
    cin>>s;
    if (test(s, 'A')||test(s, 'B')) {
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 760
use std::io::stdin;

fn main(){
    let k =  {
        let ks: Vec<usize> = getvec();
        ks[0]
    };

    let mut ans: Vec<usize> = Vec::new();

    if k==1 {
        ans.push(0);
        ans.push(2);
    } else {
        let (d, x, m) = if k > 50 {(k/50, k%50, 50)} else {(k/2, k%2, 2)};

        for _ in 0..m-x {
            ans.push(m-1+d - x);
        }
        for _ in m-x..m{
            ans.push(m-1+d -x+1+m);
        }
    }

    println!("{}", ans.len());
    for i in 0..ans.len()-1 {
        print!("{} ", ans[i]);
    }
    println!("{}", ans[ans.len()-1]);
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec<T: std::str::FromStr>() -> Vec<T>{
    let line = getline();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}


Measured memory_bytes: 4352
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    a, b, x = LI()
    if a <= x <= a + b:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    n, m, x = LI()
    a = LI()
    print(min(bisect.bisect_left(a, x), m - bisect.bisect_right(a, x)))
    return

#C
def C():
    n = II()
    x = LI()
    xb = x[::1]
    xb.sort()
    a = xb[n // 2 - 1]
    b = xb[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif x[i] >= b:
            print(a)
        
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38512
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,A,B;
char ch[110000];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	int num=0,num2=0;
	scanf("%s",ch+1);
	for (int i=1;i<=n;i++){
		int flag=0;
		if (ch[i]=='a'){
			if (num<A+B) flag=1,num++;
		} else if (ch[i]=='b'){
			if (num<A+B&&(num2<B)){
				flag=1; num++;num2++;
			}
		}
		if (flag==0) printf("No\n"); else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int a, b;

void input(){
    cin >> a >> b;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = 0;
    string rev;
    for(int i=a;i<=b;i++){
        string si = to_string(i);
        rev = si;
        reverse(rev.begin(), rev.end());
        if(si == rev) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = "";
        while(true){
            if(n%-2 == 0){
                s = "0" + s;
            }else{
                s = "1" + s;
                n--;
            }
            if(n/-2 == 0) break;
            n /= -2;
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 21204
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = float("INF")
for i in range(N-K+1):
  l = i
  r = i + K - 1
  if X[l] * X[r] < 0:
    ans = min(ans, 2 * min(abs(X[l]), abs(X[r])) + max(abs(X[l]), abs(X[r])))
  else:
    ans = min(ans, abs(X[r]) if X[r] > 0 else abs(X[l]))
print(ans)

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

using namespace std;

int main() {
  map<string, int> m;
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  m[s] = a;
  m[t] = b;

  string u;
  cin >> u;
  m[u]--;
  cout << m[s] << " " << m[t] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main()
{
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H * W) - (w * H) - (h * W) + (h * w) << endl;
    return 0;
}



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

typedef pair<int, int> P;
vector<P> v;

void search(int r, int t){
	for(int i = 0; i < (int)v.size(); i++){
		if(v[i].first == t and v[i].second == r){
			cout << i + 1;
			break;
		}
	}
	return;
}

int main(){
	//make vector
	for(int i = 0; i <= 180; i+=30){
		for(int j = 100; j <= 500; j+=100){
			v.push_back(P(i, j));
		}
	}
	int n;
	cin >> n;
	for(int loop = 0; loop < n; loop++){
		int r, t;
		//r, theat
		cin >> r >> t;

		//point num = 1
		if(r % 100 == 0 and t % 30 == 0){
			search(r, t);
			cout << endl;
		}
		//point num = 2
		else if(r % 100 == 0 and t % 30 != 0){
			int rg = 0, lf = 0;
			for(int i = 30; i <= 180; i += 30){
				rg = i;
				if(lf < t and t < rg){
					search(r, lf);
					cout << " ";
					search(r, rg);
					cout << endl;
					break;
				}
				lf = i;
			}
		}
		else if(r % 100 != 0 and t % 30 == 0){
			int top = 0, bot = 0;
			for(int i = 100; i <= 500; i += 100){
				top = i;
				if(bot < r and r < top){
					search(bot, t);
					cout << " ";
					search(top, t);
					cout << endl;
					break;
				}
				bot = i;
			}
		}
		//point num = 4
		else if(r % 100 != 0 and t % 30 != 0){
			int rg = 0, lf = 0;
			for(int i = 30; i <= 180; i += 30){
				rg = i;
				if(lf < t and t < rg){
					break;
				}
				lf = i;
			}
			int top = 0, bot = 0;
			for(int i = 100; i <= 500; i += 100){
				top = i;
				if(bot < r and r < top){
					break;
				}
				bot = i;
			}
			search(bot, lf);
			cout << " ";
			search(top, lf);
			cout << " ";
			search(bot, rg);
			cout << " ";
			search(top, rg);
			cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int n;
    char a, b;
    cin >> n;
    cin >> a;
    for (int i = 1; i < n; i++) {
        cin >> b;
        if (b == 'F' && a == 'T') a = 'F';
        else a = 'T';
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3100
import sys
N=int(input())
L=[(0,0,0)]
for i in range(N):
    t,x,y=map(int,input().split())
    L.append((t,x,y))
for i in range(1,N+1):
    t=L[i][0]-L[i-1][0]
    x=abs(L[i][1]-L[i-1][1])
    y=abs(L[i][2]-L[i-1][2])
    #print(t,x,y)
    if x+y >t:
        print('No')
        sys.exit()
    if (x+y)%2!=t%2:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 17332
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main()
{
  vector<int> abc;
  rep(i,0,3) {
    int x; cin >>x;
    abc.push_back(x);
  }

  int count_5=int(count(abc.begin(),abc.end(),5));
  int count_7=int(count(abc.begin(),abc.end(),7));

  if (count_5==2 and count_7==1) cout <<"YES" <<endl;
  else cout <<"NO" <<endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

ll n,m,a[100009][3],maxn=-(1LL<<60);

ll max(ll x,ll y){
  if(x>y) return x;
  else return y;
}

int main(){
  cin>>n>>m;
  rep(i,n)
  rep(j,3) cin>>a[i][j];

  rep(i,8){
    vector<ll>vec;
    rep(j,n){
      ll s=0;
      rep(k,3){
        if((i/(1<<k))%2==0) s+=a[j][k];
        else s-=a[j][k];
      }
      vec.push_back(s);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());

    ll ans=0;
    rep(j,m) ans+=vec[j];
    maxn=max(maxn,ans);
  }
  cout<<maxn<<endl;
}

Measured memory_bytes: 256
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![0; n];
    for i in 0..n {
        a[i] = read();
    }
    a.sort();
    let mut pre= -1;
    let mut cnt = 0;
    for i in a {
        if pre == i {
            cnt -= 1;
            pre = -1;
        }else {
            cnt += 1;
            pre = i;
        }
    }
    println!("{}", cnt);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

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

List=sorted(List,key=lambda x: x[1])

total=0
for i in range(N):
    total+=List[i][0]
    if(total>List[i][1]):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 39704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0;
        return 0;
    }
    vector<ll> prod(max(n,m)+1);
    prod[0]=1;
    rep2(i,1,max(m,n)+1){
        prod[i]=(i*prod[i-1])%MOD;
    }
    if(n==m)cout<<2*prod[n]*prod[m]%MOD;
    else cout<<prod[n]*prod[m]%MOD;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


ups = []
downs = []
eqs = []
for i in range(3):
    if A[i] < B[i]:
        ups.append((A[i], B[i]))
    elif A[i] == B[i]:
        eqs.append((A[i], B[i]))
    else:
        downs.append((A[i], B[i]))
ans = N

if len(eqs) == 3:
    print(N)
    exit()

if len(ups) == 0:
    tmp = A[:]
    A = B[:]
    B = tmp[:]
    ups = []
    downs = []
    eqs = []
    for i in range(3):
        if A[i] < B[i]:
            ups.append((A[i], B[i]))
        elif A[i] == B[i]:
            eqs.append((A[i], B[i]))
        else:
            downs.append((A[i], B[i]))

if len(ups) == 3:
    gold_diff = B[0]-A[0]
    silver_diff = B[1]-A[1]
    cupper_diff = B[2]-A[2]
    for gold in range(N//A[0]+1):
        left = N - gold*A[0]
        for silver in range(left//A[1]+1):
            cupper = (left - silver*A[1])//A[2]
            tmp_ans = (N
                       + gold*gold_diff
                       + silver*silver_diff
                       + cupper*cupper_diff)
            ans = max(ans, tmp_ans)
elif len(ups) == 2:
    gold_diff = ups[0][1]-ups[0][0]
    silver_diff = ups[1][1]-ups[1][0]
    for gold in range(N//ups[0][0]+1):
        left = N - gold*ups[0][0]
        silver = left // ups[1][0]
        tmp_ans = (N
                   + gold*gold_diff
                   + silver*silver_diff)
        ans = max(ans, tmp_ans)
    if len(downs) == 1:
        diff = downs[0][0]-downs[0][1]
        ans += (ans // downs[0][1]) * diff
elif len(ups) == 1:
    nowN = N + (N//ups[0][0])*(ups[0][1]-ups[0][0])
    if len(downs) == 2:
        gold_diff = downs[0][0]-downs[0][1]
        silver_diff = downs[1][0]-downs[1][1]
        for gold in range(nowN//downs[0][1]+1):
            left = nowN - gold*downs[0][1]
            silver = left // downs[1][1]
            tmp_ans = (nowN
                       + gold*gold_diff
                       + silver*silver_diff)
            ans = max(ans, tmp_ans)
    elif len(downs) == 1:
        ans = nowN + (nowN//downs[0][1])*(downs[0][0]-downs[0][1])
    else:
        ans = nowN
print(ans)


Measured memory_bytes: 42076
#include<stdio.h>
int main(void)
{
	int N,i;
	double A[1001];
	double sum=0.0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%lf",&A[i]);
	}
	for(i=0;i<N;i++)
	{
		sum=1/A[i]+sum;
	}
	printf("%lf",1/sum);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL n;
	cin>>n;
	cout<<180*(n-2);
	return 0;
}


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

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

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

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

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

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

ll naive_comb(ll a, ll b){
  ll res = 1;
  for (ll i = a; i > a - b; i--) res = res * i % MOD;
  for (ll i = 1; i <= b; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,y; cin>>x>>y;
  if((x+y)%3){
    cout<<0<<endl;
    return 0;
  }
  
  // if((-x+y)%3 || (2*x-y)%3){
  //   cout<<0<<endl;
  //   return 0;
  // }
  ll a=(-x+2*y)/3, b=(2*x-y)/3;
  // if(a<0 || b<0){
  //   cout<<0<<endl;
  //   return 0;
  // }
  // if(x-2*b<0 || y-2*a<0){
  //   cout<<0<<endl;
  //   return 0;
  // }
  
  // cout<<a<<' '<<b<<endl;
  cout<<comb(a+b,a)<<endl;
  
}

Measured memory_bytes: 78336
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut count = BTreeMap::new();
    for _ in 0..n {
        let v = read_vec::<usize>();
        let (a, b) = (v[0], v[1]);
        *count.entry(a).or_insert(0) += b;
    }
    let mut accum = 0;
    for (key, v) in count {
        accum += v;
        if accum >= k {
            println!("{}", key);
            return;
        }
    }
}

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()
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static int two(int a) {
		int tmp = a;
		int cnt = 0;
		while(tmp % 2 == 0) {
			tmp /= 2;
			++cnt;
		}
		return cnt;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int min = 30;
		for(int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			int tmp = two(a[i]);
			min = Math.min(min,  tmp);
		}
		sc.close();
		System.out.println(min);
	}

}


Measured memory_bytes: 24020
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18
 
N,K=rl()
 
W = [[0 for _ in range(K+3)] for _ in range(K+3)]
for i in range(N):
    x,y,c=input().split()
    x = int(x)%(2*K)
    y = (int(y) if c=='W' else int(y)+K)%(2*K)
    if (x<K)^(y<K):
        x %= K
        y %= K
        W[0][y+1] += 1
        W[x+1][y+1] -= 2
        W[0][K+1] -= 1
        W[x+1][K+1] += 1
        W[x+1][0] += 1
        W[K+1][0] -= 1
        W[K+1][y+1] += 1
    else:
        x %= K
        y %= K
        W[0][0] += 1
        W[x+1][0] -= 1
        W[0][y+1] -= 1
        W[x+1][y+1] += 2
        W[K+1][y+1] -= 1
        W[x+1][K+1] -= 1
        W[K+1][K+1] += 1
 
for x in range(0,K+2):
    for y in range(0,K+2):
        W[x][y] += W[x][y-1]
for y in range(0,K+2):
    for x in range(0,K+2):
        W[x][y] += W[x-1][y]
 
ans = 0
for x in range(K+1):
    for y in range(K+1):
        res = W[x][y]
        ans = max(ans,res,N-res)
 
print(ans)

Measured memory_bytes: 43764
#include<cstdio>
#include<cstring>
#include<algorithm>
int h, w;
unsigned int dp[64][64];
char m[64][64];
unsigned int solve(int x, int y){
  if(dp[x][y] != -1) return dp[x][y];
  if(x == w - 1 && y == h - 1) return 0;
  int ret = 99999999;
  if(x + 1 < w)
    ret = solve(x + 1, y) + m[y][x] - '0';
  if(y + 1 < h)
    ret = std::min(ret, (int)solve(x, y + 1) + m[y][x] - '0');
  return dp[x][y] = ret;
}
int main(void){
  scanf("%d %d", &h, &w);
  for(int i = 0;i < h; i++)
    scanf("%s", m[i]);
  memset(dp, -1, sizeof(dp));
  printf("%u\n", solve(0, 0));
}


Measured memory_bytes: 1060
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner112
{
    public class ABC112B
    {
        public static void Main(string[] args)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = nums[0];
            int T = nums[1];

            int minIdx = -1;
            int minCost = int.MaxValue;
            for(int i=1; i<=N; i++)
            {
                int[] linenums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int c = linenums[0];
                int t = linenums[1];

                if (t <= T && c < minCost)
                {
                    minIdx = i;
                    minCost = c;
                }
            }

            if (minIdx != -1)
            {
                Console.WriteLine(minCost);
            }
            else
            {
                Console.WriteLine("TLE");
            }
            
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d && abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }
    
    else if (abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }
    
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  char now = '.';
  REP(i,n){
    if(now!=s[i]){
      ans ++;
      now = s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for(int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;
  
  string A;
  for(int i = 0; i < H; i++){
    cin >> A;
    cout << '#' << A << '#' << endl;
  }

  for(int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    string str;
    cin >> str;
    int a = (str[0]-'0')*10 + (str[1]-'0');
    int b = (str[2]-'0')*10 + (str[3]-'0');
    if(a<=12&&b<=12&&a>0&&b>0) cout <<"AMBIGUOUS";
    else if(a<=12&&a>0) cout << "MMYY";
    else if(b<=12&&b>0) cout << "YYMM";
    else  cout << "NA";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long h = scan.nextLong();

		long ans = 0;
		long multi = 1;
		for(int i = 1; h >= 1; i++) {
			ans += multi;
			multi *= 2;
			h /= 2;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC129
{
	class Program
	{
		static void Main(string[] args)
		{
			var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var k = new bool[NM[0]];
			foreach (var a in ReadLines(NM[1]).Select(int.Parse)) { k[a - 1] = true; }
			var ans = k.Aggregate(new int[] { 0, 1 }, (p, a) => new int[] { p[1], a ? 0 : (p[0] + p[1]) % 1000000007 });
			Console.WriteLine(ans[1]);
		}

		static IEnumerable<string> ReadLines(int n) => Enumerable.Range(0, n).Select(_ => Console.ReadLine());
	}
}


Measured memory_bytes: 15480
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strArr[] = str.split(" ");
		int a, b, c, count=0;

		a = Integer.parseInt(strArr[0]);
		b = Integer.parseInt(strArr[1]);
		c = Integer.parseInt(strArr[2]);

		for(int i=a; i<=b; i++){
			for(int t=1; t*i<=c; t++){
				if(i*t==c)
					count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 18204
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{x:chars,y:chars};
    println!("{}", if x[0] < y[0] {"<"} else if x[0] > y[0] {">"} else {"="});

}

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

int main() {
  int A, B, C;
  
  cin >> A >> B >> C;
  
  if ((A == B) && (A != C)) cout << "Yes" << endl;
  else if ((A == C) && (A != B)) cout << "Yes" << endl;
  else if ((B == C) && (A != B)) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

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

int c[21][50001];
int i[21];

int minv(int a, int b){


 if(a > b)
  return b;

 else
  return a;


}

int main(){
int m, n, count, count2 = 0;


 for(m = 0; m < 21; m++){
  c[m][0] = 0;
 }
 for(m = 1; m < 50001; m++){
   c[1][m] = m;
 }


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


 for(count = 1; count <= n; count++){
  scanf("%d", &i[count]);

 }

 for(count = 2; count <= n; count++){
  for(count2 = 0; count2  <= m; count2++){
     if(count2 - i[count] >= 0)
       c[count][count2] = minv(c[count][count2 - i[count]] + 1, c[count-1][count2]);
      else
       c[count][count2] = c[count-1][count2];
  }
 }

 printf("%d\n", c[n][m]);

 return 0;
}

Measured memory_bytes: 4508
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

int n;
vector<double> x(100010), y(100010);
vector<char> d(100010);

double solve(double time){
    double xmax = -INF;
    double xmin = INF;
    double ymax = -INF;
    double ymin = INF;

    for(int i=0; i<n; i++){
        if(d[i] == 'R'){
            chmax(xmax, x[i] + time);
            chmin(xmin, x[i] + time);
            chmax(ymax, y[i]);
            chmin(ymin, y[i]);
        }
        else if(d[i] == 'L'){
            chmax(xmax, x[i] - time);
            chmin(xmin, x[i] - time);
            chmax(ymax, y[i]);
            chmin(ymin, y[i]);
        }
        else if(d[i] == 'U'){
            chmax(ymax, y[i] + time);
            chmin(ymin, y[i] + time);
            chmax(xmax, x[i]);
            chmin(xmin, x[i]);
        }
        else{
            chmax(ymax, y[i] - time);
            chmin(ymin, y[i] - time);
            chmax(xmax, x[i]);
            chmin(xmin, x[i]);
        }
    }

    return (xmax - xmin) * (ymax - ymin);
}

double ternary_search(double l, double r){
    double left = l, right = r;

    // calculate minimum value
    for(int i=0; i<500; i++){
        if(solve((left * 2 + right) / 3) < solve((left + right * 2) / 3)){
            right = (left + right * 2) / 3;
        }
        else{
            left = (left * 2 + right) / 3;
        }
    }

    return solve((left + right) * 0.5);
}

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

    cin>>n;
    for(int i=0; i<n; i++) cin>>x[i]>>y[i]>>d[i];

    double ans = ternary_search(0, 1e9);

    printf("%.10f\n", ans);
}

Measured memory_bytes: 1920
N = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
bina = 0
binc = 0
count = 0
for b_tree in b:
    while bina < N and a[bina] < b_tree:
        bina += 1
    while binc < N and c[binc] <= b_tree:
        binc += 1
    count += bina * (N-binc)
print(count)


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

#define MOD 1000000007
typedef unsigned long long ull;

int n = 0;

ull lucas[87];

int main() {
  cin >> n;

  lucas[0] = 2;
  lucas[1] = 1;
  for (int i = 2; i < 87; i++) {
    lucas[i] = lucas[i - 1] + lucas[i - 2];
  }
  cout << lucas[n] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,a[1000];
    int i;
    int flg = 0;
    scanf("%d", &n);
    for(i = 0;i < n;i ++){
        scanf("%d", &a[i]);
    }
    for(i = 0;i < n;i ++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                flg = 1;
                break;
            }
        }
    }
    if(flg == 0){
        printf("APPROVED\n");
    }
    else{
        printf("DENIED\n");
    }
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string NS;
int main() {
    std::cin >> NS;

    int sum = 0;
    for(auto c: NS) {
        sum += (c - '0');
    }
    int N = std::atoi(NS.c_str());

    if(N%sum == 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

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

class dice
{
public:
	int a, b, c, d, e, f;

	
};

void roll(dice &x, string direction)
{
	int a3 = x.a, b3 = x.b, c3 = x.c, d3 = x.d, e3 = x.e, f3 = x.f;
	
		if (direction == "W")
		{
			x.a = c3; x.d = a3; x.f = d3; x.c = f3;
		}
		if (direction == "N")
		{
			x.e = a3; x.f = e3; x.b = f3; x.a = b3;
		}
		if (direction == "E")
		{
			x.a = d3; x.c = a3; x.d = f3; x.f = c3;
		}
		if (direction == "S")
		{
			x.a = e3; x.b = a3; x.f = b3; x.e = f3;
		}
		if (direction == "R")
		{
			x.b = d3; x.c = b3; x.e = c3; x.d = e3;
		
	}
}

int same(dice x1,dice x2)
{
	if (x1.a == x2.a && x1.b == x2.b && x1.c == x2.c && x1.d == x2.d && x1.e == x2.e && x1.f == x2.f) return 1;
	else return 0;
}

int compare(dice x1, dice x2)
{
	bool f = false;
	if (same(x1, x2) == 1) f = true;
	else
	{
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1,x2) == 1) f = true;
		}
		roll(x1,"N");
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1, x2) == 1) f = true;
		}
		roll(x1,"E");
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1, x2) == 1) f = true;
		}
		roll(x1,"N");
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1, x2) == 1) f = true;
		}
		roll(x1,"N");
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1, x2) == 1) f = true;
		}
		roll(x1,"E");
		for (int i = 0; i < 4; i++)
		{
			roll(x1,"R");
			if (same(x1, x2) == 1) f = true;
		}
	}
	if (f == true) return 1;
	if (f == false) return 0;
}

int main()
{
	int n;
	cin >> n;
	dice x[100];
	bool f = true;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i].a >> x[i].b >> x[i].c >> x[i].d >> x[i].e >> x[i].f;
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (compare(x[i], x[j]) == 1) f = false;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
}


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

int C[100005];
vector< pair<int, int> > X[100005];

void dfs(int root, int par, int col)
{
    int k = 1;

    if(col == k)
        k++;

    for(auto x : X[root])
    {
        if(x.first == par)
            continue;
        
        int y = x.first;
        int indx = x.second;

        C[indx] = k++;

        if(col == k)
            k++;
        
        dfs(y, root, C[indx]);
    }
}

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

    int N;
    cin >> N;

    for(int i=1; i<=N-1; i++)
    {
        int u, v;
        cin >> u >> v;

        X[u].push_back({v, i});
        X[v].push_back({u, i});
    }

    int root = 0;

    for(int i=1; i<=N; i++)
        if(X[i].size() > X[root].size())
            root = i;
    
    cout << X[root].size() << "\n";

    dfs(root, root, 0);

    for(int i=1; i<=N-1; i++)
        cout << C[i] << "\n";

    return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
#include<cstdlib>

int main(){
    int a, b, c, d;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;

    if(std::abs(c-a) <= d){
        std::cout << "Yes" << std::endl; 
    }else if(std::abs(c-b) <= d && std::abs(b-a) <= d){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
   Author : BabaYaga42,
   BITS Pilani, Hyderabad.
   Don't give up ;)
   */
#include <bits/stdc++.h>
#include <stdint.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
#define int long long int
#define push_back pb

int h[100005],dp[100005],ans;

int32_t main()
 {
	IOS;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	dp[0] = 2000000000;
	for(int i = 2; i <= n;i++)
	{
		dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]),dp[i-1] + abs(h[i-1] - h[i]));
	}
	cout << dp[n];
	return 0;
  }


Measured memory_bytes: 1792
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
ans = 1
A = [0]*(max(D)+1)
for i in range(N):
  A[D[i]] += 1
#if D[0] != 0 or not all(D[1:]) or not all(A):
#  print(0)
#  exit()
if D[0] != 0 or not all(D[1:]):
  print(0)
  exit()
for i in range(1, max(D)+1):
#  print(A[i])
  if A[i] == 0:
    print(0)
    exit()
  ans = ans * pow(A[i-1], A[i], mod) % mod
print(ans % mod)

Measured memory_bytes: 14396
def main():
    import sys
    input=sys.stdin.readline
    n=int(input())
    h=list(map(int,input().split()))
    dp=[1e+12]*n
    dp[0]=0
    dp[1]=abs(h[0]-h[1])
    for i in range(2,n):
        dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
    #print(dp)
    print(dp[n-1])
        
    

if __name__=='__main__':
    main()

Measured memory_bytes: 13888
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    long a = kbd.nextLong();
	    long b = kbd.nextLong();
	    //  a<bにしておく
	    if(a>b) {
		long w = a;
		a = b; 
		b = w;
	    }

	    long gcd = a;

	    while(a%gcd!=0 || b%gcd!=0) {
		gcd = gcd-2;
		if(gcd==0) gcd = 1;
	    }

	    long lcm = a*b/gcd;

	    System.out.println(gcd+" "+lcm);
	}
    }
}

Measured memory_bytes: 19288