akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007,N=200001;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

//階乗とか
ll fac[N],finv[N],inv[N];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

vector<vector<ll> > g(N);
ll pa[N],dpin[N],dpout[N],inl[N],outl[N];//ans,line

//dp[now]=(SUM(line)!)*PI(dp[to]/(line!))
inline ll in(int n){return (dpin[n]*finv[inl[n]])%mod;}
inline ll out(int n){return (dpout[n]*finv[outl[n]])%mod;}


void dfs1(ll now,ll p){
	pa[now]=p;
	ll ans=1,sum=0;
	for(auto& to:g[now]){
		if(to==p)continue;
		dfs1(to,now);
		sum+=inl[to];
		(ans*=in(to))%=mod;
	}
	(ans*=fac[sum])%=mod;

	inl[now]=sum+1;
	dpin[now]=ans;
	return;
}

void dfs2(ll now,ll p){
	int niko=g[now].size();
	vector<ll> v1,v2,v3,v4;

    //累積
	for(auto& to:g[now]){
		if(to==p)v1.pb(1),v2.pb(1),v3.pb(0),v4.pb(0);
		else{
			v1.pb(in(to));
			v2.pb(in(to));
			v3.pb(inl[to]);
			v4.pb(inl[to]);
		}
	}
    for(int i=1;i<niko;i++) (v1[i]*=v1[i-1])%=mod,v3[i]+=v3[i-1];
	for(int i=niko-2;i>=0;i--) (v2[i]*=v2[i+1])%=mod,v4[i]+=v4[i+1];

    //out
	for(int i=0;i<niko;i++){
		int to=g[now][i];
		if(to==p) continue;
		ll ans=out(now),sum=outl[now];
		if(i>0) (ans*=v1[i-1])%=mod,sum+=v3[i-1];
		if(i<niko-1) (ans*=v2[i+1])%=mod,sum+=v4[i+1];
        (ans*=fac[sum])%=mod;
	    outl[to]=sum+1,dpout[to]=ans;
		dfs2(to,now);
	}
	return;
}

int main(){
	cin.tie(0);cout.tie(0);
	ios::sync_with_stdio(false);
    cominit();
	ll n,a,b;
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a>>b;
		a--,b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	dfs1(0,-1);

	dpout[0]=1;
	outl[0]=0;
	dfs2(0,-1);

	for(int i=0;i<n;i++){
		ll sum=outl[i],ans=out(i);//親
		for(auto& to:g[i]){
			if(to==pa[i])continue;
			//子
			sum+=inl[to];
			(ans*=in(to))%=mod;
		}
		(ans*=fac[sum])%=mod;
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    long long n,m;
    long long sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        long long a;
        cin>>a;
        sum+=a;
    }
    if(sum>n){
        cout<<"-1"<<endl;
    }else{
        cout<<n-sum<<endl;
    }
    return 0;
}

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


int main(){
  ll a,b; cin >> a >> b;
  if((b-a)%2 != 0){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << (b+a)/2 << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<tuple<string, int, int>> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> get<0>(A[i])>>get<1>(A[i]);
		get<1>(A[i]) = -get<1>(A[i]);
		get<2>(A[i]) = i + 1;
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; ++i) {
		cout << get<2>(A[i]) << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

int main() {
  string s;
  cin >> s;
  int price = 700;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') {
      price += 100;
    }
  }

  cout << price << "\n";
}

Measured memory_bytes: 256
n = int(input())
l = [{}, {}, {}, {2, 5, 63}, {2, 5, 20, 63}, {2, 3, 4, 6, 9}]
if n <= 5:
  print(*l[n])
  exit(0)
l = [2, 3, 4, 6]
s = set()
for i in range(n):
  s.add(l[i%4] + 6*(i//4))
if sum(s) % 6 == 2:
  s.remove(8)
  s.add(30000)
if sum(s) % 6 == 3:
  s.remove(9)
  s.add(30000)
if sum(s) % 6 == 5:
  s.remove(9)
  s.add(29998)
print(*s)


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
const int MOD = 998244353;

void dfs(string s, set<string>& st) {
	if (st.count(s)) return;
	st.insert(s);
	int N = s.length();
	rep(i, N - 1) if (s[i] != s[i + 1]) {
		string t = s;
		t[i] = t[i + 1] = 'a' + 'b' + 'c' - s[i] - s[i + 1];
		dfs(t, st);
	}
}

int f(string s) {
	set<string> st;
	dfs(s, st);
	return st.size();
}

int solve(string s) {
	int N = s.length();
	bool same = true, diff = true;
	rep(i, N - 1) {
		if (s[i] != s[i + 1]) same = false;
		else diff = false;
	}
	if (same) return 1;
	int ans = 1;
	rep(i, N - 1) ans = (ll)ans * 3 % MOD;
	int unko = 0;
	rep(i, N) unko = (unko + s[i] - 'a') % 3;
	vector<vector<int>> dp(3, vector<int>(3));
	dp[0][0] = dp[1][1] = dp[2][2] = 1;
	rep(i, N - 1) {
		vector<vector<int>> _dp(3, vector<int>(3));
		rep(x, 3) rep(y, 3) rep(z, 3) if (x != z)
			_dp[z][(y + z) % 3] = (_dp[z][(y + z) % 3] + dp[x][y]) % MOD;
		dp = _dp;
	}
	rep(x, 3) ans = (ans - dp[x][unko]) % MOD;
	if (diff) ans = (ans + 1) % MOD;
	return (ans + MOD) % MOD;
}

int main() {
	/*
	for (;;) {
		string s; cin >> s;
		cout << f(s) << ' ' << solve(s) << endl;
	}
	*/
	string s; cin >> s;
	if (s.length() <= 3) {
		cout << f(s) << endl;
		return 0;
	}
	cout << solve(s) << endl;
}


Measured memory_bytes: 772
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        
        if (X < A){
            System.out.println("NO");
        }else if(X > (A + B)) {
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
    
}


Measured memory_bytes: 24276
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, h = LI()
A = []
B = []
for a, b in LIR(n):
    A += [a]
    B += [b]



max_a = max(A)
B.sort(reverse=True)
ret = 0
i = 0
while i < n and ret < h and B[i] > max_a:
    ret += B[i]
    i += 1


if ret < h:
    i += ceil((h - ret) / max_a)


print(i)

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

int main() {
  int k, n, m = 0, o, p, fst;
  
  scanf("%d %d",&k,&n);
  
  scanf("%d",&fst);
  o = fst;
  n--;
  
  while (n--) {
    scanf("%d",&p);
    m = max(m,p-o);
    o = p;
  }

  m = max(m,fst-p+k);
  
  k-=m;
  printf("%d \n",k);
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	ll N, K; cin >> N >> K;

	ll a = N % K;
	ll b = K -a ;
	cout << min(a, b) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        // 変数宣言
        long total = 0;
        long blue = 0;
        long result = 0;
        long n;
        long a;
        long b;

        // 入力
        Scanner sc = new Scanner(System.in);
        
        n = Long.parseLong(sc.next());
        a = Long.parseLong(sc.next());
        b = Long.parseLong(sc.next());

        sc.close();

        // 演算処理
        long i = n / ( a + b );
        long j = n % ( a + b ); 
        result = a*i;

        if( j < a ){
            result = result + j;
        }else{
            result = result + a;
        }

        // resultを出力
        System.out.println( result );

    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

const long long MOD = (long long)(1e9 + 7);

long long powerf(long long a, long long b) {
    long long res = 1;
    while(b > 0) {
        if((b%2 == 1)) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        b/=2;
    }
    return res;
}


const long long N = (long long)(1e5 + 7);
int dsu[N];
vector<int> adj[N];
vector<int> ign[N];
map<int, int> adj_m[N];
int sz[N];

int parent(int x) {
    while(x != dsu[x]) {
        dsu[x] = dsu[dsu[x]];
        x = dsu[x];
    }
    return x;
}

void unionf(int x, int y) {
    int px = parent(x);
    int py = parent(y);
    if(px == py) {
        return;
    }
    dsu[py] = px;
    sz[px] = sz[py] + sz[px];
    return;
}

void init(int n) {
    for(int i=1; i<=n; i++) {
        dsu[i] = i;
        sz[i] = 1;
    }
    return;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    init(n);
    for(int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        adj_m[y][x] = 1;
        adj_m[x][y] = 1;
        unionf(x, y);
    }

    for(int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        ign[x].push_back(y);
        ign[y].push_back(x);
    }

    for(int i=1; i<=n; i++) {
        int ans = sz[parent(i)] - 1 - adj[i].size();
        for(auto j : ign[i]) {
            if(adj_m[i][j] == 1) continue;
            if(parent(i) == parent(j)) ans-=1;
        }
        cout << ans << " ";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 36092
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
int gcd(int x, int y) {
	/*最大公約数 O(log MAX_X)*/
	if (y == 0) return x;
	return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {

	int n, m, k;
	cin >> n >> m >> k;
	
	vector<int> a(n);
	vector<int> b(m);

	rep(i, n) cin >> a[i];
	rep(i, m)cin >> b[i];

	ll t = 0;
	rep(i, m) t += b[i];

	int j = m;
	int ans = 0;
	rep(i, n + 1) {
		while (j > 0 && t > k) {
			--j;
			t -= b[j];
		}
		if (t > k) break;
		ans = max(ans, i + j);
		t += a[i];
	}
	cout << ans << endl;;
	return 0;
}

Measured memory_bytes: 4840
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃだめだよ！
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  ll mi = INF;
  for (int i = 0; i <= 200000; i++) {
    if (i % 2 == 1) continue;
    int newx, newy;
    if (x - i / 2 < 0)
      newx = 0;
    else
      newx = x - i / 2;
    if (y - i / 2 < 0)
      newy = 0;
    else
      newy = y - i / 2;
    ll total = i * c + a * newx + b * newy;
    mi = min(total, mi);
  }
  cout << mi << endl;
}

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

using namespace std;

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

    vector<pair<long long, long long>> key(m, make_pair(0, 0));
    for (int i = 0; i < m; i++) {
        long long a, b;
        cin >> a >> b;

        key[i].second = a;
        for (int j = 0; j < b; j++) {
            int c;
            cin >> c;

            key[i].first = (key[i].first | (1 << (c - 1)));
        }
    }

    vector<vector<long long>> dp(1 << n, vector<long long>(m + 1, 1LL << 48));
    dp[0][0] = 0;

    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < m; j++) {
            if (dp[i][j + 1] > dp[i][j]) {
                dp[i][j + 1] = dp[i][j];
            }

            if (dp[i | key[j].first][j + 1] > dp[i][j] + key[j].second) {
                dp[i | key[j].first][j + 1] = dp[i][j] + key[j].second;
            }
        }
    }

    if (dp[(1 << n) - 1][m] < (1LL << 48)) {
        cout << dp[(1 << n) - 1][m] << endl;
    } else {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 32384
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
const int maxn = 105;
using namespace std;
bool cmp(char a, char b) {
	return a > b;
}
int main()
{
	char s1[maxn], s2[maxn];
	cin >> s1 >> s2;
	sort(s1, s1 + strlen(s1));
	sort(s2, s2 + strlen(s2), cmp);
	if (strcmp(s1, s2) < 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int D, a[20], b[20], l;
ll ans, bin[20], c[20], ans1;
inline void dfs(int i, ll D, ll now){
	if(!now)return;
	if(i==l+1){if(!D)ans1+=now; return;}
	for(int j=-9; j<=9; j++)if(c[i]*(j-1)<D&&D<c[i]*(j+1))dfs(i+1, D-c[i]*j, now*(i==1?a[j+9]:b[j+9]));
}
inline ll check(int n){
	l=0; for(int i=1; i<=n/2; i++)c[++l]=bin[n-i]-bin[i-1];
	ans1=0; dfs(1, D, 1);
	if(n&1)return ans1*10; else return ans1;
}
int main(){
	scanf("%d", &D); ans=0;
	bin[0]=1; for(int i=1; i<=18; i++)bin[i]=bin[i-1]*10;
	memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b));
	for(int i=0; i<=9; i++)for(int j=1; j<=9; j++)a[i-j+9]++;
	for(int i=0; i<=9; i++)for(int j=0; j<=9; j++)b[i-j+9]++;
	for(int i=2; i<=18; i++)ans+=check(i);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,C=get_i.sort{|x,y| y<=>x}
ab=(A-B).abs
ac=(A-C).abs
if (ab+ac).even?
    puts (ab+ac)/2
else
    puts (ab+ac+1)/2+1
end

Measured memory_bytes: 14272
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
char MAP[20][20];
int ans;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
void dfs(int x, int y,int w,int h) 
{
	if (x < 0 || x>=w || y < 0 || y>=h)return;
	else if (MAP[y][x] == '#')return;
	else
	{
		MAP[y][x] = '#';
		::ans++;
		for (int r = 0; r < 4; r++)
		{
			int nx = x + dx[r];
			int ny = y + dy[r];
			dfs(nx, ny,w,h);
		}
	}
}
int main()
{
	while (1)
	{
		int w, h;
		::ans = 0;
		cin >> w >> h;
		if (w == 0)break;
		PII self;
		REP(y, h)
		{
			REP(x, w)
			{
				cin >> MAP[y][x];
				if (MAP[y][x] == '@')self = MP(y, x);
			}
		}
		dfs(self.second, self.first,w,h);
		cout << ::ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double pi = acos(-1);

double deg2rad(double theta){
  return pi*theta/180.;
}

int main(){
  double a, b, deg;
  double rad, h, c, S, L;

  cin >> a >> b >> deg;

  rad = deg2rad(deg);

  h = b*sin(rad);
  S = a*h/2.;
  c = sqrt(a*a+b*b-2*a*b*cos(rad));
  L = a + b + c;

  cout << fixed << setprecision(8);
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;

}



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


int main(){
	int n,m;
	string a[100];
	int b[100];
	string kuji[1000];
	while(cin>>n>>m&&n){
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(int i=0;i<m;i++){
			cin>>kuji[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				bool f=true;
				for(int k=0;k<8;k++){
					if(a[i][k]!='*'&&a[i][k]!=kuji[j][k]){
						f=false;
					}
				}
				if(f)ans+=b[i];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var even = new int[100001];
        var odd = new int[100001];
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0) even[v[i]]++;
            else odd[v[i]]++;
        }
        int e1 = 0, e2 = 0, o1 = 0, o2 = 0;
        for (int i = 1; i <= 100000; i++)
        {
            if (even[i] >= even[e1])
            {
                e2 = e1;
                e1 = i;
            }
            else if (even[i] >= even[e2])
            {
                e2 = i;
            }
            if (odd[i] >= odd[o1])
            {
                o2 = o1;
                o1 = i;
            }
            else if (odd[i] >= odd[o2])
            {
                o2 = i;
            }
        }
        if (o1 == e1) Console.WriteLine(Math.Min(n - even[e2] - odd[o1], n - even[e1] - odd[o2]));
        else Console.WriteLine(n - even[e1] - odd[o1]);
    }
}

Measured memory_bytes: 17632
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long num = X;
		int ans = 1;
		while(num <= Y) {
			num *= 2;
			ans++;
		}
		ans--;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
num = input().split()
num_i = [int(s) for s in num]

a,b,c = num_i
min_1 = a+b
min_2 = b+c
min_3 = c+a

min_a1 = min(min_1, min_2)
min_a = min(min_a1, min_3)
print(min_a)

Measured memory_bytes: 3060
n, m = map(int, input().split())
a = [[v for v in list(map(int, input().split()))] for i in range(n)]
b = [int(input()) for i in range(m)]
c = [sum([a[i][j] * b[j] for j in range(m)]) for i in range(n)]
print('\n'.join(map(str, c)))

Measured memory_bytes: 8104
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
dp=[0]*3000
for i in range(n):
    dp[i]=a[i]
for i in range(1,n):
    for j in range(i-1,-1,-1):
        dp[j]=max(a[i]-dp[j],a[j]-dp[j+1])
print(dp[0])

Measured memory_bytes: 41580
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

dictD = {}
for d in D:
    if d in dictD:
        dictD[d] += 1
    else:
        dictD[d] = 1

dictT = {}
for t in T:
    if t in dictT:
        dictT[t] += 1
    else:
        dictT[t] = 1


for k, v in dictT.items():
    if k in dictD:
        if v > dictD[k]:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 56672
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n;
	cin>>n;
	vector<int> W;
	int w;
	int sum=0;
	rep(i,n){
		cin>>w;
		sum+=w;
		W.push_back(w);
	}
	int sum_ = sum;
	int max = INF;
	rep(i,n){
		sum -= W[i];
		chmin(max, abs(sum-(sum_-sum)));
	}
	cout<<max<<endl;
    return 0;
}


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

using namespace std;

int solve( int D, int G, const pair< int, int > p[], int x )
{
    int m = 0;

    for( int i = D - 1, s = 100 * D; G > 0 and i >= 0; i--, s -= 100, x >>= 1 )
        if ( x & 1 )
        {
            int n = min( G / s, p[ i ].first ); G -= n * s, m += n;

            if ( n == p[ i ].first )
                G -= p[ i ].second;
        }

    return ( G > 0 ) ? INT_MAX : m;
}

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    int D, G, m = INT_MAX; cin >> D >> G; pair< int, int > p[ D ];

    for( int i = 0; i < D; i++ )
        cin >> p[ i ].first >> p[ i ].second;

    for( int x = 1, y = 1 << D; x < y; x++ )
        m = min( m, solve( D, G, p, x ) );

    cout << m;
}

Measured memory_bytes: 256
import java.util.*; // headers MUST be above the first class

public class Main
{
  public static void main(String[] args)
  {
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
	int a[] = new int[n];
	int min = sc.nextInt(), max = min;
    for (int i=1; i<n; i++) {
      a[i] = sc.nextInt();
      if (a[i] < min) min = a[i];
      if (a[i] > max) max = a[i];
    }
    System.out.println(max - min);
  }
}


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

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

  int N;
  cin >> N;

  vector<int> A(N + 2, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }

  int S = 0;
  for (int i = 0; i <= N; i++) S += abs(A.at(i) - A.at(i + 1));
  
  for (int i = 1; i <= N; i++) {
    int ans = S - (abs(A.at(i - 1) - A.at(i)) + abs(A.at(i) - A.at(i + 1))) +
              abs(A.at(i - 1) - A.at(i + 1));
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 1664
# coding: utf-8
import sys
input = sys.stdin.readline

mod = 10 ** 9 + 7

def f(h, w, grid):
    dp = [[0] * (w + 1) for _ in range(h + 1)]
    dp[1][1] = 1
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if grid[i][j] == ".":
                dp[i][j] += dp[i - 1][j] + dp[i][j - 1]
                if dp[i][j] > mod:
                    dp[i][j] -= mod
    return(dp[h][w])

h, w = map(int, input().split()) # 2 <= h, w <= 10000
grid = [["#"] + list(input().rstrip()) for _ in range(h)]
grid = [["#"] * (w + 1)] + grid
print(f(h, w, grid))


Measured memory_bytes: 50460
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int taro_card_number = 0;
		Main fmc = new Main();

		// トランプの各図柄の配列を作る

		int[] S;
		S = new int[13];
		int[] D;
		D = new int[13];
		int[] H;
		H = new int[13];
		int[] C;
		C = new int[13];


		// テキスト入力
		Scanner sc = new Scanner(System.in);
		// タローが持っているカードの数
		while (sc.hasNext()) {
			taro_card_number = sc.nextInt();

		// ループ処理
		for (int i = 0; i < taro_card_number; i++) {

		
				// 図柄
				String design = sc.next();
				// 数
				int number = sc.nextInt();

				// 図柄の指定に従い、数字を配列に格納
				if (design.equals("S")) {
					//
					fmc.set_property(S, number);
				}
				if (design.equals("H")) {
					fmc.set_property(H, number);
				}
				if (design.equals("D")) {
					fmc.set_property(D, number);
				}
				if (design.equals("C")) {
					fmc.set_property(C, number);
				}

		}
		// //配列に入力情報が格納されたので、入力情報にないものをピックアップして出力

		// スペードから順にないものを出力
		for (int i = 0; i < 13; i++) {

			// ないものをピックアップ
			if (S[i] == 0) {
				System.out.println("S " + (i + 1));
			}
		}

		for (int i = 0; i < 13; i++) {

			// ないものをピックアップ
			if (H[i] == 0) {
				System.out.println("H " + (i + 1));
			}
		}

		for (int i = 0; i < 13; i++) {

			// ないものをピックアップ
			if (C[i] == 0) {
				System.out.println("C " + (i + 1));
			}
		}

		for (int i = 0; i < 13; i++) {

			// ないものをピックアップ
			if (D[i] == 0) {
				System.out.println("D " + (i + 1));
			}
		}
		}
	}

	// 図柄の属性と数を取ってきて、配列に格納する
	public void set_property(int[] design, int number) {
		design[number - 1] = 1;
	}

	// //配列に格納しなかったものを表示する
	// public void output_result(int[] design,int i){
	// if(design[i] == 0){
	// System.out.println()
	// }
	// }

}

Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int D;
  rd(D);
  if(D==25){
    wt_L("Christmas");
    wt_L('\n');
  }
  else if(D==24){
    wt_L("Christmas Eve");
    wt_L('\n');
  }
  else if(D==23){
    wt_L("Christmas Eve Eve");
    wt_L('\n');
  }
  else{
    wt_L("Christmas Eve Eve Eve");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// {
//   int D;
//   rd(D);
//   wt( if[D==25, "Christmas", D==24, "Christmas Eve", D==23, "Christmas Eve Eve", "Christmas Eve Eve Eve"] );
// }


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

if x >= (a**2)*b/2:
  tan = float(2*(b*a**2-x)/a**3)
  theta = math.degrees(math.atan(tan))
  print("{:.10f}".format(theta))
else :
  tan = float((a*b**2)/(2*x))
  theta = math.degrees(math.atan(tan))
  print("{:.10f}".format(theta))

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, m := nextInt(), nextInt()
	pp := map[int][]Pair{}
	vv := make([]Pair, 0, n)

	for i := 0; i < m; i++ {
		k, v := nextInt(), nextInt()
		pp[k] = append(pp[k], Pair{
			Value: v,
		})
		vv = append(vv, Pair{
			Key:   k,
			Value: v,
		})
	}

	sort.Sort(ByValue(pp[1]))

	res := map[int]map[int]string{}

	for c, item := range pp {
		sort.Sort(ByValue(item))
		res[c] = map[int]string{}

		for idx, i := range item {
			res[c][i.Value] = fmt.Sprintf("%06d", idx+1)
		}
	}

	for _, item := range vv {
		fmt.Printf("%06d%s\n", item.Key, res[item.Key][item.Value])
	}
}

type Pair struct {
	Key   int
	Value int
}

// sort.Sort(ByKey(pairs))
type ByKey []Pair

func (s ByKey) Len() int {
	return len(s)
}

func (s ByKey) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByKey) Less(i, j int) bool {
	return s[i].Key < s[j].Key
}

// sort.Sort(ByValue(pairs))
type ByValue []Pair

func (s ByValue) Len() int {
	return len(s)
}

func (s ByValue) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s ByValue) Less(i, j int) bool {
	return s[i].Value < s[j].Value
}


Measured memory_bytes: 45056
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 2005

int main(){

    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> color(9,0);
    REP(i,n){
        cin >> arr[i];
        if(arr[i] >= 3200){
            color[8]++;
        }else{
            color[arr[i]/400]++;
        }
    }

    int va = 0;
    REP(i,8){
        if(color[i] > 0){
            va++;
        }
    }

    if(color[8] == 0){
        cout << va << " " << va << endl;
    }else{
        int mini,maxi;
        if(va == 0){
            mini = 1;
            maxi = color[8];
        }else{
            mini = va;
            maxi = va+color[8];
        }
        cout << mini << " " << maxi << endl;
    }





    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int T[] = new int[w];
		for(int i=0;i<w;i++){
				T[i]=i+1;
				//System.out.println(T[i]);
			}
		int n = sc.nextInt();
			for(int i = 0;i<n;i++ ){
				int temp = 0;
				String A = sc.next();
				String[] fruit = A.split(",");
				int a = Integer.parseInt(fruit[0]);
				int b = Integer.parseInt(fruit[1]);
				temp = T[a-1];
				T[a-1]=T[b-1];
				T[b-1]=temp;
				
			}
			for(int i = 0;i<w;i++){
				System.out.println(T[i]);
			}
	}
}

Measured memory_bytes: 26224
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(x - r < 0 || x + r > w) {
			System.out.println("No");
		}else if(y-r < 0|| y+ r >h) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

	}
}



Measured memory_bytes: 26288
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int s=a;s<=100000;s+=a)
    {
        if(s%b==c)
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main() {
	int d, n,a=1;
	cin >> d >> n;
	for (int i = 0; i < d; i++) {
		a *= 100;
	}
	cout << a*(n+n/100) << endl;
}

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

using namespace std;

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

const int N = 1e5 + 5;
const ll M = 1e10;

vector <ll> cubes,pr;
vector <pair <ll,ll> > v;
map <ll,int> mpx;

bool h[N];
int sz,n,ans;
ll a[N],b[N];

void sieve() {
  for (int i = 2 ; i < N ; i++) {
    if (h[i] == false) {
      pr.push_back(i);
      for (int j = i ; j < N ; j += i)
        h[j] = true;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];

  sieve();

  for (auto i : pr)
    if (i * i * i <= M)
      cubes.push_back(i);

  for (int i = 1 ; i <= n ; i++)
    for (auto j : cubes)
      while(a[i] % (j * j * j) == 0)
        a[i] /= (j * j * j);

  for (int i = 1 ; i <= n ; i++) {
    ll x = a[i];
    b[i] = 1;
    for (auto j : cubes) {
      if (x % j == 0) {
        int cnt = 0;        
        while(x % j == 0) {
          cnt++;
          x /= j;
        }
        if (cnt == 1)
          b[i] *= j * j;
        else
          b[i] *= j;
      }
    }
    if (x != 1) {
      ll sq = sqrt(x);
      if (sq * sq == x) {
        b[i] *= sq;
      }
      else {
        b[i] *= x * x;
      }
    }
    // cerr << a[i] << " " << b[i] << endl;
    mpx[a[i]]++;
    v.push_back({a[i],b[i]});
  }

  for (auto i : v) {
    if (i.first == 1) {
      if (mpx[1])
        ans++;
    }
    else
      ans += max(mpx[i.first],mpx[i.second]);
    mpx[i.first] = mpx[i.second] = 0;
  }
 
  cout << ans << endl;

}


Measured memory_bytes: 16112
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

struct Node * find(struct Node *u , int k)
{
	while( u != NIL && k != u->key)
	{
		if( k < u->key)u = u->left;
		else u = u ->right;
	}
	return u;
}

void insert(int k)
{
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL)
	{
		y = x;
		if(z->key < x->key)
		{
			x = x->left;
		}
		else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL)
	{
		root = z;
	}
	else{
		if(z->key < y->key)
		{
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u)
{
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u)
{
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void)
{
	int n , i , x;
	char com[100];
	char str1[] = "insert";
	char str2[] = "print";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		while(scanf("%s",com) != EOF)
		
		if( com[0] == 'f')
		{
			scanf("%d",&x);
			struct Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if(strcmp(com,str1)==0)
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(strcmp(com,str2)==0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 20476
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve() {
	int n, k, d;
	cin >> n >> k >> d;
	n = abs(n);
	int req = (n / d);
	if (req > k) {
		cout << abs(n - k * d);
	} else {
		k -= req;
		int	ans = n - (req * d);
		if (k % 2 == 0) {
			cout << ans;
		} else {
			cout << min(abs(ans - d), abs(ans + d));
		}
	}
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=2*1e5+2,M=201;

void solve()
{
	int n;
	string s,t;
	cin>>n>>s>>t;
	string ans=s;
	for(int i=0;i<n;i++)
	{
		int j=i;
		int k=0;
		while(j<n&&t[k]==ans[j])
		{
			j++;
			k++;
		}
		if(j==n)
		{
			// cout<<"*";
			cout<<n+(n-k)<<"\n";
			return;
		}
	}
	cout<<n+n<<"\n";
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

	vector<ll> tmp = divisor(m);

	int ans = 0;
	rep (i, tmp.size()) {
		if (m / tmp[i] >= n) ans = tmp[i];
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T>
void swap(T &a, T &b)
{
	T t = a;
	a = b;
	b = t;
}

// Utility functions.
void swap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////


void solve(int tc)
{
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int dp[n]; // dp[i] : min cost to reach i - 1th stair;
	dp[0] = 0;

	for (int i = 1; i < n; i++)
	{
		dp[i] = INF;
		for (int j : {i - 1, i - 2})
			if (j > -1)
				dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
	}

	cout << dp[n - 1] << "\n";
}

int32_t main()
{	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,M; cin >> N >> M;
	V<int> a(N+10,0);
	for(int i = 0; i < M; ++i){
		int L,R; cin >> L >> R;
		a[L]++;a[R+1]--;
	}
	for(int i = 1; i < N+10; ++i) a[i] += a[i-1];
	int ans = 0;
	for(int i = 0; i < N+10; ++i) if(a[i]==M) ans++;
	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
L, R = map(int, input().split())
x = L%2019
y = R%2019
z = []
a = 0
if x ==0 or (R-L) + x >= 2019:
  print(a)
else:
  for j in range(y-x):
    for i in range (y-x-j):
      z.append(((x+j)*(x+j+i+1))%2019)
  print(min(z))

Measured memory_bytes: 75320
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    int N, A, B;
    float f;
    string s;
    
    cin >> N >> A >> B;
    //for (int i=0;i<N;i++) cin >> A[i];
    
    if (A>=B) cout << B << " ";
    else cout << A << " ";
    
    if (A+B<=N) cout << 0 << endl;
    else cout << A+B-N << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
//合成数xはx**0.5以下の約数を持つ
int main(){
    int x,y;
    cin>>x>>y;
    if (x>y){
        cout<<"safe"<<endl;
    }
    else{
        cout<<"unsafe"<<endl;
    }
}

Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=2e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

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

#define pb push_back
#define ll long long
#define inf 1e18

using namespace std;


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

	int n;
	scanf("%d", &n);
	vector<vector<ll>>dp(n, vector<ll>(n));
	vector<ll>pre(n, 0), a(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		dp[i][i] = 0;
		if(i == 0){
			pre[i] = a[i];
		}
		else{
			pre[i] = pre[i-1]+a[i];
		}
	}

	// printf("prefix array\n");

	// for(int i = 0; i<n; i++){
	// 	printf("for %d prefix sum is %lld \n",i,  pre[i]);
	// }
	for (int l = 2; l <= n; ++l)
	{
		for (int i = 0; i+l-1<n; ++i)
		{
			ll ss;
			int j = i+l-1;

			if(i == j){
				ss = a[i];
			}
			else if(i == 0){
				// printf("hrer %d\n", pre[j]);
				ss = pre[j];
			}
			else{
				// printf("subrecting\n");
				ss = pre[j] - pre[i-1];
			}
			dp[i][j] = inf;
			// printf("for %d -> %d , prefix sum is %lld\n",i, j, ss);
			for (int k = i; k < j; ++k)
			{
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + ss);
			}
		}
	}
	printf("%lld\n", dp[0][n-1]);

	
}




Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	ll h,n;
	cin>>h>>n;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		sum+=x;
	}
	if(sum>=h)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632