akhauriyash/Code-Regression huggingface dataset:
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");

const dictionarySorter = (strA: string, strB: string) =>
  strA.localeCompare(strB);

// ----

function Main(input: string): void {
  const [head, ...s] = parseLines(input);

  s.sort(dictionarySorter);

  log(s.join(""));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    let mut ans = false;
    let mut k = 0;
    loop {
        if (n - k * 7) % 4 == 0 {
            ans = true;
            break;
        }
        k += 1;
        if 7 * k > n {
            break;
        }
    }
    yn(ans);
}


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

#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NULL)
#define LL long long
using namespace std;

namespace patch
{
    template < typename T > string to_string( const T& n )
    {
        ostringstream stm ;
        stm << n ;
        return stm.str();
    }
}

int main(){
    fastio1; fastio2;
	string s; cin >> s;
	int a = (int) s[0] -'0';
	int b = (int) s[1] -'0';
	int c = (int) s[2] -'0';
	int d = (int) s[3] -'0';
	
	if (a+b+c+d==7)
		cout << a << "+" << b << "+" << c << "+" << d << "=7\n";
	else if (a+b+c-d==7)
		cout << a << "+" << b << "+" << c << "-" << d << "=7\n";
	else if (a+b-c+d==7)
		cout << a << "+" << b << "-" << c << "+" << d << "=7\n";
	else if (a+b-c-d==7)
		cout << a << "+" << b << "-" << c << "-" << d << "=7\n";
	else if (a-b+c+d==7)
		cout << a << "-" << b << "+" << c << "+" << d << "=7\n";
	else if (a-b+c-d==7)
		cout << a << "-" << b << "+" << c << "-" << d << "=7\n";
	else if (a-b-c+d==7)
		cout << a << "-" << b << "-" << c << "+" << d << "=7\n";
	else if (a-b-c-d==7)
		cout << a << "-" << b << "-" << c << "-" << d << "=7\n";
}

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

int main() {
    int n;
    cin >> n;
    bool ans = false;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == n) {
                ans = true;
                goto OUT;
            }
        }
    }
    OUT:
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3600
#ABC159A
import sys
import itertools
n, m = map(int, sys.stdin.readline().split())
#print(n, m)
L = [0 for _ in range(n)] + [1 for _ in range(m)]
L = list(itertools.combinations(L, 2))
#print(L)
total = 0
for a, b in L:
    if (a+b)%2 ==0:
        total+=1

print(total)

Measured memory_bytes: 4468
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		for(int i=str.length()-1;i>=0;i--){
			System.out.print(str.charAt(i));
		}
		scan.close();
		System.out.println("");
	}

}

Measured memory_bytes: 17124
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<int, int>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

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

	SQWORD totalSize = 0;
	vector<SQWORD> a(N);
	REP(i, N) {
		cin >> a[i];
		totalSize += a[i];
	}

	SQWORD sum = 0;
	SQWORD ans = MAX_SQWORD;
	REP(i, N - 1) {
		sum += a[i];
		SQWORD diff = totalSize - 2 * sum;
		ans = min(ans, abs(diff));
	}

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



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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

    string str;
    cin >> str;

    ll x = 0;
    ll _max = 0;

    for (int i = 0; i < str.size(); ++i) {
        x += (str[i] == 'I') ? 1 : -1;
        _max = (x > _max) ? x : _max;
    }

    cout << _max << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n;
string s;
string a[105];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        rep(j, a[i].length()) {
            bool ok = false;
            rep2(k, 1, 101) {
                int now = j;
                int sidx = 0;
                while (sidx < s.length() && now < a[i].length()) {
                    if (a[i][now] != s[sidx]) break;
                    sidx++;
                    now += k;
                }
                if (sidx == s.length()) {
                    ok = true;
                    ans++;
                    break;
                }
            }
            if(ok) break;
        }
    }
    cout << ans << endl;
}

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

int dp[10][1000];
int w[3] = { 2, 3, 5 };
int v[3] = { 380, 550, 850 };
double r[3] = { 0.8, 0.85, 0.88 };
int d[3] = { 5, 4, 3 };

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

	int n;
	while(cin >> n, n) {
		n /= 100;
		fill((int*)begin(dp), (int*)end(dp), 1e9);
		dp[0][0] = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j <= n; j++) {
				if(dp[i][j] == 1e9) continue;
				for(int k = 0; j + w[i] * k <= n; k++) {
					int cost = v[i] * (k / d[i]) * d[i] * r[i] + v[i] * (k % d[i]);
					int nj = j + w[i] * k;
					dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + cost);
				}
			}
		}
		cout << dp[3][n] << endl;
	}
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n-1); i >= 0; i--)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a % 2 != b % 2)cout << "IMPOSSIBLE" << endl;
    else cout << (a + b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  long long a, b, n; cin>>a>>b>>n;
  long long ans = 0;
  long long x = min(b-1, n);
  ans = a * x / b - a * (x / b);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def Get(i):
    ans[i] = []
    for v in ans[i - 1]:
        if v[-1] == '0':
            ans[i].append(v + '0')
            ans[i].append(v + '1')
        elif v[-1] == '9':
            ans[i].append(v + '8')
            ans[i].append(v + '9')
        else:
            t = v[-1]
            ans[i].append(v + str(int(t) - 1))
            ans[i].append(v + str(int(t)))
            ans[i].append(v + str(int(t) + 1))


def GetValueIndex(K):
    i = 1
    while True:
        if len(ans[i]) < K:
            K -= len(ans[i])
            i += 1
        else:
            ans[i].sort()
            return ans[i][K - 1]


K = int(input())

ans = {1: [str(i) for i in range(1, 10)]}
i = 2
while sum(len(v) for v in ans.values()) < K:
    Get(i)
    i += 1

print(GetValueIndex(K))


Measured memory_bytes: 17244
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int a[4];
int b[4];
int main() {
	bool f = false;
	while (cin >> n, n) {
		if (f)cout << endl;
		f = true;
		for (int i = 0; i < 4; i++) {
			cin >> a[i];
		}
		ll sum = 0;
		for (int i = 0; i < 4; i++) {
			if (i == 0) {
				sum += 10 * a[i];
			}
			else if (i == 1) {
				sum += 50 * a[i];
			}
			else if (i == 2) {
				sum += 100 * a[i];
			}
			else {
				sum += 500 * a[i];
			}
		}
		for (int i = 0; i < 4; i++)b[i] = 0;
		sum -= n;
		while (1) {
			if (sum >= 500) {
				b[3] = sum / 500;
				sum %= 500;
			}
			else if (sum >= 100) {
				b[2] = sum / 100;
				sum %= 100;
			}
			else if (sum >= 50) {
				b[1] = sum / 50;
				sum %= 50;
			}
			else {
				b[0] = sum / 10;
				break;
			}
		}
		for (int i = 0; i < 4; i++) {
			if (i==0 && a[0] - b[0] > 0) {
				cout << 10 << " " << a[0] - b[0] << endl;
			}
			if (i==1 && a[1] - b[1] > 0) {
				cout << 50 << " " << a[1] - b[1] << endl;
			}
			if (i==2 &&a[2] - b[2] > 0) {
				cout << 100 << " " << a[2] - b[2] << endl;
			}
			if (i==3 && a[3] - b[3] > 0) {
				cout << 500 << " " << a[3] - b[3] << endl;
			}
		}
	}
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
int k,fac[2000010],inv[2000010];
char S[1000010];
int ksm(int aa,int bb)
{
	int ans=1;
	for (;bb;bb>>=1) {
		if (bb&1) ans=1LL*ans*aa%Mod;
		aa=1LL*aa*aa%Mod;
	}
	return ans;
}
int C(int N,int M)
{
	if (N<0||M<0||N<M) return 0;
	return 1LL*fac[N]*inv[N-M]%Mod*inv[M]%Mod;
}
int main()
{
	scanf("%d",&k);
	scanf("%s",S+1);
	int n=strlen(S+1),ans=0;
	fac[0]=1;for (int i=1;i<=n+k;i++) fac[i]=1LL*fac[i-1]*i%Mod;
	inv[n+k]=ksm(fac[n+k],Mod-2);
	for (int i=n+k-1;i>=0;i--) inv[i]=1LL*inv[i+1]*(i+1)%Mod; 
	for (int i=n;i<=n+k;i++) {
		ans+=1LL*C(i-1,n-1)*ksm(25,i-n)%Mod*ksm(26,n+k-i)%Mod;
		ans%=Mod;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names+1, ',');
    cout.write(names, comma - names) << " = " << arg1 <<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif

const int N = 1005;
pii ara[N];
int n;
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n;
    int ans = 0;
    bool ok = 0;
    FOR(i,1,n){
        cin >> ara[i].ff >> ara[i].ss;
        if(ara[i].ff == ara[i].ss)ans++;
        else ans = 0;
        if(ans >= 3)ok = 1;
    }
    if(ok)cout << "Yes\n";
    else cout << "No\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (long double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}



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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int k = a;
	if(a == b)
	{
		k = c;
	}
	else if(a == c)
	 {
	 	k = b;
	 }
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}



Measured memory_bytes: 3636
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
a = [0]*N

score = {'r':P,'s':R,'p':S}
ans = 0
for i in range(N):
    if i+K<=N-1:
        if a[i]==0 and T[i]==T[i+K]:
            a[i+K]=1
    if a[i]==0:
        ans+=score[T[i]]
print(ans)

Measured memory_bytes: 40816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

const llong mod = (llong)(1e9) + 7;

llong mod_pow(llong n, llong m) {
    llong ret = 1;

    while (m) {
        if (m & 1) {
            ret *= n;
            ret %= mod;
        }

        m >>= 1;
        n *= n;
        n %= mod;
    }

    return ret;
}

llong n, k;
llong sum;
llong cnt[100005];

int main() {
    cin >> n >> k;

    for (llong i = k; i >= 1; i--) {
        sum += i * ((mod_pow(k / i, n) - cnt[i] + mod) % mod) % mod;
        sum %= mod;
        
        llong add = mod_pow(k / i, n) - cnt[i];

        for (llong j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                if (i / j == j) {
                    cnt[j] += add;
                    cnt[j] %= mod;
                }
                else {
                    cnt[j] += add;
                    cnt[j] %= mod;
                    cnt[i / j] += add;
                    cnt[i / j] %= mod;
                }
            }
        }
    }

    cout << sum << endl;

    return 0;
}


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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))

#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

/*int seive(int N){
    bool primes[N+1];
    int cnt=0;
    mem(primes, true); primes[1] = false;
    int m = sqrt(N);
    for(int i=2; i<=m; i++){
        if(primes[i]){
            for(int p = i*i; p<=N; p+=i)
                primes[p] = false;
        }
    }

    for(int i=2; i<=N; i++){
        if(primes[i])
            cnt++;
    }

    return cnt;
} */

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


   
int main()
{

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

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

    int A, B, C, K, ops=0;
    cin >> A >> B >> C >> K;
    while(B<=A){
        B *= 2;
        ops++;
    }

    while(C<=B){
        C *= 2;
        ops++;
    }

    if(ops > K) cout << "No\n";
    else cout << "Yes\n";

    return 0;
   
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
    char s[100000][4];
    int n=0,i,c[4]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",s[i]);
    for(i=0;i<n;i++){
        if(s[i][0]=='A')
            c[0]++;
        else if(s[i][0]=='W')
            c[1]++;
        else if(s[i][0]=='T')
            c[2]++;
        else 
            c[3]++;
    }
    printf("AC x %d\n",c[0]);
    printf("WA x %d\n",c[1]);
    printf("TLE x %d\n",c[2]);
    printf("RE x %d\n",c[3]);
    return 0;
}

Measured memory_bytes: 2120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var s = new int[M];
            for (int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToList();

                for (int j = 1; j <= r[0]; j++)
                {
                    s[i] += (1 << (r[j]-1));
                }

            }
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;
            for (int i = 0; i < (1<<N); i++)
            {
                int num = i;
                int[] frags = new int[M];
                for(int j = 0; j < N; j++)
                {
                    if ((num & (1 << j)) > 0)
                    {
                        for (int k = 0; k < M; k++)
                        {
                            if ((s[k] & (1 << j)) > 0)
                                frags[k] = (frags[k] + 1) % 2;
                        }
                    }
                }

                bool f = true;
                for (int j = 0; j < M; j++)
                {
                    if (p[j] != frags[j]) f = false;
                }
                if (f) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28232
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> sum(n + 1, 0);
  for(int i = 0; i < n - 1; i++) {
    if(s[i] == 'A' && s[i + 1] == 'C'){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  vector<int> l(n), r(n);
  for(int i = 0; i < q; i++) {
    int lq, rq;
    cin >> lq >> rq;
    lq--;
    rq--;
    l[i] = lq;
    r[i] = rq;
  }
  for(int i = 0; i < q; i++){
    cout << sum[r[i]] - sum[l[i]] << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

import static java.lang.Math.max;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long A[] = new long[N+1];

        for (int i = 1; i < N+1; i++) {
            A[i] = sc.nextInt();
        }

        long dp[][] = new long[N+1][2];
        dp[0][0] = 0;
        dp[0][1] = -100000000000000000L;

        for (int i = 0; i < N; i++) {
            dp[i + 1][0] = max(dp[i][0] + A[i+1], dp[i][1] - A[i+1]);
            dp[i + 1][1] = max(dp[i][0] - A[i+1], dp[i][1] + A[i+1]);
        }

        System.out.println(dp[N][0]);
    }
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int m = *max_element(a, a+n);
  int s = accumulate(a, a+n, 0);

  bitset<2000*2000+1> b;

  b[0] = true;
  for (int i = 0; i < n; i++)
      b |= b << a[i];

  int i = s % 2 == 0 ? s / 2 : s / 2 + 1;
  while (!b[i]) i++;
  cout << i << endl;

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int flag=0;
	int n=s1.size();
	for(int i=0;i<n;i++)
	{
		if(s1[i]!=s2[i]) flag=1;	
	}	
	if(flag) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
} 

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


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

  double ans = 0;

  for(int i=1;i<=n;i++){
    double point =1.0/n;
    int x = i;
    while(x<k){
      x *=2;
      point /=2;
    }
    ans += point;
  }
  printf("%.12f\n",ans);
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String str = scan.nextLine();
			for(int i = 0;i < str.length();i++){
				int t = (int)str.charAt(i) - 3;
				System.out.print((char)((t < 65)?t+26:t));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int x = 0;
		int y = 0;
		int z = 0;
		try {
			Scanner sc = new Scanner(System.in);
			// 入力された値を取得
			x = sc.nextInt();
			y = sc.nextInt();
			z = sc.nextInt();

			// バリデーション
			if (x < 1 || x > 100) {
				return;
			}
			if (y < 1 || y > 100) {
				return;
			}
			if (z < 1 || z > 100) {
				return;
			}

		} catch (Exception e) {
			return;
		}

		// 出力
		System.out.println(z + " " + x + " " + y);

	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  vector<int> x(n);
  rep(i, n) cin >>x.at(i);

  int res = MOD;
  for (int p=1; p<=100; p++){
    int sum = 0;
    for (int i=0; i<n; i++){
      sum += (x.at(i) - p) * (x.at(i) - p);
    }
    res = min(res, sum);
  }
  cout <<res <<endl;
}

Measured memory_bytes: 256
N = int(input())
W = input().split(" ")
W = [int(i) for i in W]
T = 1
ans_list = []
for i in range(N-1):
    G1 = []
    G2 = []

    for j in range(T):
        G1.append(W[j])
    for j in range(N - T):
        G2.append(W[j+T])

    ans_list.append(abs(sum(G1)-sum(G2)))

    T += 1



#print(ans_list)
print(min(ans_list))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int A, B, C ,D;
    cin >> A >> B >> C >> D;
    int S1 = A * B;
    int S2 = C * D;
    cout << max(S1, S2) << endl;
    return 0;    
}

Measured memory_bytes: 256
[n, k] = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

l = []
c = 1
l2 = [0 for _ in range(n)]
for _ in range(n):
    c = a[c - 1]
    if len(l) + 1 == k:
        print(c)
        break
    elif l2[c - 1] == 1:
        i = l.index(c)
        l2 = l[i:]
        print(l2[(k - i) % len(l2) - 1])
        break
    else:
        l.append(c)
        l2[c - 1] = 1

Measured memory_bytes: 112120
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int n,i;
ll s,s2;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(i=0;i<n;i++)
    {
        ll c,d;
        cin>>c>>d;
        s+=c*d;
        s2+=d;
    }
    cout<<s2-1+(s-1)/9<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
res = 0
while True:
    change = 0
    for i in range(n - 1):
        if a[i] == i + 1:
            a[i], a[i + 1] = a[i + 1], a[i]
            res += 1
            change = 1
    for i in range(n - 1, 1, -1):
        if a[i] == i + 1:
            a[i], a[i - 1] = a[i - 1], a[i]
            res += 1
            change = 1
    if change == 0:
        break

print(res)

Measured memory_bytes: 14008
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;
typedef unsigned long long ull;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 405;

map<ull,int>cnt;
int a[N][4];
int n;
LL ans;
ull id[N];
int w[4][4]={{1,0,1,0},{2,1,0,3},{3,2,3,2},{0,3,2,1}};

int trs(int *a){
	ull mv;
	fo(st,0,3){
		ull tmp=0;
		for(int i=st;i<4;i++)tmp=tmp*1003+a[i];
		for(int i=0;i<st;i++)tmp=tmp*1003+a[i];
		if (st==0||tmp<mv)mv=tmp;
	}
	return mv;
}

int calc(int *a){
	int t=0;
	fo(d,0,3){
		bool pd=1;
		fo(i,0,3)
		if (a[i]!=a[(i+d)%4])pd=0;
		if (pd)t++;
	}
	return t;
}

int main(){
	n=get();
	fo(i,1,n){
		a[i][0]=get();a[i][1]=get();a[i][2]=get();a[i][3]=get();
		cnt[id[i]=trs(a[i])]++;
	}
	ans=0;
	fo(i,1,n)
		fo(j,i+1,n){
			cnt[id[i]]--;cnt[id[j]]--;
			fo(tim,0,3){
				ull t[4];
				LL tv=1;
				fo(c,0,3){
					int col[4];
					col[0]=a[i][w[c][0]];col[1]=a[i][w[c][1]];
					col[2]=a[j][(w[c][2]+tim)%4];col[3]=a[j][(w[c][3]+tim)%4];
					ull tmp=trs(col);
					tv=tv*calc(col)*cnt[tmp];
					cnt[tmp]--;
					t[c]=tmp;
				}
				ans=ans+tv;
				fo(c,0,3)cnt[t[c]]++;
			}
			cnt[id[i]]++;cnt[id[j]]++;
		}
	printf("%lld\n",ans/3);
	return 0;
}

Measured memory_bytes: 80128
/**
 * author: Behradm
 * Created: 2020.08.22 16:40:01
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << '\n'; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<long long> p(n);
  p[0] = a[0];
  for (int i = 1; i < n; i++) {
    p[i] = max(p[i - 1], a[i]);
  }

  long long res = 0;
  for (int i = n - 1; i >= 1; i--) {
    //long long t = Max(0, i + 1);
    //cerr << 0 << " " << i + 1 << " " <
    long long t = p[i];
    if (a[i] < t) {
      res += t - a[i];
      a[i] = t;
    }
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<string>w={"Sunny","Cloudy","Rainy","Sunny"};
  string x;cin>>x;
  int i=0;
  while(w.at(i)!=x)i++;
  cout<<w.at(i+1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>t(n+2),a(n+1);
    rep(i,n)cin>>t[i+1];
    rep(i,n)cin>>a[i+1];
    vector<ll>mt(n+2);
    bool f=1;
    rep(i,n){
        if(t[i]!=t[i+1])mt[i+1]=t[i+1];
    }
    ll ma=0;
    for(int i=n;i>0;i--){
        ma=max(mt[i],ma);
        if(ma>a[i])f=0;
        if(a[i]!=a[i+1]){
            if(mt[i]>0&&mt[i]!=a[i])f=0;
            mt[i]=a[i];
        }
    }
    ll ans=1;
    ll k=1;
    rep(i,n){
        if(mt[i+1]){
        }else{
            ans*=min(a[i+1],t[i+1]);
            ans%=inf;
        }
    }
    cout<<(f?ans:0)<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans;
char S[100];
string a;
map<string,int>M;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%s",S);
		sort(S,S+10),a.clear();
		for(int j=0; j<10; j++)a+=S[j];
		ans+=M[a],M[a]++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
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 REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

bool func(int node);
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    ll X;  cin >> X;
    vector<ll> plus(1000);
    for(ll i = 0 ; i <= 1000 ; i++){
      ll in = i*i*i*i*i;
      plus[i] = in;
    }
    
    for(int i = 0 ; i <= 1000; i++){
      for(int j = 0 ; j <= 1000 ; j++){
        if(plus[i] + plus[j] == X){  cout << i << " " << -j << endl; return 0;  }
        else if(plus[i] - plus[j] == X){  cout << i << " " << j << endl;  return 0;  }
      }
    }    
    
	return 0;
}


Measured memory_bytes: 3660
a, b, c, x, y = map(int, input().split())
tot = 0
while x * y > 0:
    if c + c < a + b:
        tot += c + c
        x -= 1
        y -= 1
    else:
        tot += a + b
        x -= 1
        y -= 1
if x > 0:
    tot += min(x * a, x * 2 * c)
if y > 0:
    tot += min(y * b, y * 2 * c)
print(tot)


Measured memory_bytes: 3064
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<ulong, int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var n = int.Parse(line[2]);
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            putDict(d, h, w, a, b);
        }
        var ret = new long[10];
        var rsum = 0;
        foreach (var x in d)
        {
            ret[x.Value]++;
            rsum++;
        }
        ret[0] = (long)(w - 2) * (h - 2) - rsum;
        foreach (var x in ret) Console.WriteLine(x);
    }
    public static void putDict(Dictionary<ulong, int> d, int h, int w, int a, int b)
    {
        if (a - 2 >= 0)
        {
            if (b - 2 >= 0) putDict2(d, a - 2, b - 2);
            if (b - 1 >= 0 && b + 1 < w) putDict2(d, a - 2, b - 1);
            if (b + 2 < w) putDict2(d, a - 2, b);
        }
        if (a - 1 >= 0 && a + 1 < h)
        {
            if (b - 2 >= 0) putDict2(d, a - 1, b - 2);
            if (b - 1 >= 0 && b + 1 < w) putDict2(d, a - 1, b - 1);
            if (b + 2 < w) putDict2(d, a - 1, b);
        }
        if (a + 2 < h)
        {
            if (b - 2 >= 0) putDict2(d, a, b - 2);
            if (b - 1 >= 0 && b + 1 < w) putDict2(d, a, b - 1);
            if (b + 2 < w) putDict2(d, a, b);
        }
    }
    public static void putDict2(Dictionary<ulong, int> d, int a, int b)
    {
        var hash = Hash(a, b);
        var v = 0;
        d.TryGetValue(hash, out v);
        d[hash] = v + 1;
    }
    public static ulong Hash(int a1, int a2)
    {
        return (ulong)a1 * 0x9ddfea08eb382d69 + (ulong)a2;
    }
}



Measured memory_bytes: 58808
#include<stdio.h>

int main(void){
    int n;
    double m,am=0;
    scanf("%d %lf",&n,&m);
    int a[n];
    for(int i=0;i<=n-1;i++){
        scanf("%d",&a[i]);
        am+=a[i];
    }
    int cou=0;
    for(int i=0;i<=n-1;i++){
        if(m!=0 && a[i]>=am/(4*m)){
            cou++;
        }
    }
    if(cou>=m){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int i,n;
	ll a,s=0ll,ans=0ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		add_mod(ans,a*s%MOD);
		add_mod(s,a);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3628
import math
def rad(a):
    return a*2*math.pi

A,B,H,M = map(int, input().split())
M /= 60.0
H = (H + M)/12;
H = rad(H)
M = rad(M)
ans = A*A+B*B-2*A*B*math.cos(H-M)
ans = math.sqrt(ans)
print(ans)

Measured memory_bytes: 9392
// D - String Equivalence
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<string> s(1,"a");
	while(--N){
		vector<string>t; swap(s,t);
		rp(i, 0, t.size()){
			char mx='a'; rp(j, 1, t[i].size()) mx = max(mx, t[i][j]); mx++;
			rp(c, 'a', mx+1) s.push_back(t[i] + string(1,c));

		}
	}
	rp(i, 0, s.size()) cout<< s[i] <<endl;
}

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

int main()
{
    int board[] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    int x, y;
    cin >> x >> y;
    if (board[x] < board[y])
    {
        cout << "Bob" << endl;
    }
    else if (board[y] < board[x])
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Draw" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = np.array([lr() for _ in range(H)])
B = np.array([lr() for _ in range(H)])
diff = np.abs(A - B).tolist()

X = (H+W) * 80
L = X + X + 1 #真ん中を0とする、最後に-X
dp = [[None] * W for _ in range(H)]
dp[0][0] = np.zeros(L, np.bool)
di = diff[0][0]
dp[0][0][X+di] = 1; dp[0][0][X-di] = 1
for h in range(H):
    for w in range(W):
        if h == 0 and w == 0:
            continue
        di = diff[h][w]
        x = np.zeros(L, np.bool)
        if h > 0:
            prev = dp[h-1][w]
            x[di:] |= prev[:L-di]
            x[:L-di] |= prev[di:]
        if w > 0:
            prev = dp[h][w-1]
            x[di:] |= prev[:L-di]
            x[:L-di] |= prev[di:]
        dp[h][w] = x

dp = dp[-1][-1][X:]
possible = np.nonzero(dp)[0]
answer = possible.min()
print(answer)
#


Measured memory_bytes: 173492
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, p;
  string s;
  cin >> n >> p >> s;
  if(10%p == 0){
    ll ans = 0;
    REP(r, n){
      if((s[r]-'0')%p == 0){
        ans += r+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<ll> d(n+1);
  map<ll, ll> mp;
  d[n] = 0;
  mp[0]++;
  ll digit = 1;
  REPr(i, n){
    int a = (s[i]-'0') * digit % p;
    d[i] = (d[i+1]+a)%p;
    mp[d[i]]++;
    digit *= 10;
    digit %= p;
  }
  ll ans = 0;
  for(auto p : mp) ans += p.second*(p.second-1)/2;
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n + 1);
  vector<int> dp(n + 1, 2'000'000'000);

  for (auto i = 1; i <= n; i++) {
    cin >> h[i];
  }
  dp[1] = h[1];
  for (auto i = 1; i <= n; i++) {
    for (auto j = 1; j <= k; j++) {
      if (i + j <= n) {
        dp[i + j] = min(dp[i + j], dp[i] + (h[i] < h[i + j] ? h[i + j] - h[i] : h[i] - h[i + j]));
      }
    }
  }
  cout << dp[n] - dp[1] << endl;
}


Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    vector<ll> diff(n);
    ll over = 0;
    ll under = 0;
    int ucnt = 0;
    vector<ll> olist;
    for(int i = 0; i < n; i++){
        diff[i] = a[i] - b[i];
        if(diff[i] > 0){
            over += diff[i];
            olist.push_back(diff[i]);
        } else if(diff[i] < 0){
            under += abs(diff[i]);
            ucnt++;
        }
    }

    if(over < under){
        cout << -1 << endl;
        return 0;
    }

    if(ucnt == 0){
        cout << 0 << endl;
        return 0;
    }

    sort(olist.begin(), olist.end(), greater<ll>());

    ll tmp = 0;
    int cnt = 0;
    for(int i = 0; i < olist.size(); i++){
        tmp += olist[i];
        cnt++;
        if(tmp >= under){
            break;
        }
    }

    cout << ucnt + cnt << endl;
}


Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    REP(i, 0, 4)cout << S[i];
    cout << " ";
    REP(i, 6, 12) cout << S[i];
    cout << " ";
    REP(i, 14, 18) cout << S[i];
    cout << endl;


    return 0;
}


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

using namespace std;

bool are_even(vector<int> vec);

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

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int count = 0;
    for (;;) {
        if (are_even(a)) {
            for (int i = 0; i < n; ++i)
                a[i] = a[i] / 2;
            ++count;
        } else
            break;
    }
    cout << count << '\n';
}

bool are_even(vector<int> vec)
{
    for (auto v : vec) {
        if (v % 2 == 1)
            return false;
    }
    return true;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
int main() {
 ll n,a,b;cin>>a>>b;
 n=__gcd(a,b);
 auto p=prime_factor(n);
 cout<<p.size()+1<<endl;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+1]=min(dp[i]+abs(h[i+1]-h[i]) , dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n, ans = 0;
	map<string, int> M;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		M[s]++;
		ans += (M[s] == 1 ? 1 : 0);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 19280