akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a < b){
        for (int i = 0; i < b; i++){
      		System.out.print(a);
        }
      } else {
        for (int i = 0; i < a; i++){
      		System.out.print(b);
        }
      }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;
int P[65000], J[65000];


int main() {
	while (cin >> n, n) {
		REP(i, n) scanf("%d", P + i);
		REP(i, n - 1) scanf("%d", J + i);
		
		ll sum = 0;
		REP(i, n) sum += P[i];
		REP(i, n - 1) sum += J[i];
		
		sort(J, J + n - 1);
		
		ll ans = sum;
		
		REP(i, n - 1) {
			sum -= J[i];
			
			chmax(ans, (i + 2) * sum);
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, k, q;
    cin >> x >> k;
    vector<ll> r(k + 1), rs(k + 1);
    rep(i, 1, k + 1) {
        cin >> r[i];
        rs[i] = rs[i - 1] - (r[i] - r[i - 1]) * (i % 2 ? 1 : -1);
    }
    int cur = 0;
    debug(r, rs);
    cin >> q;
    pair<ll, ll> area = {0, x};
    ll lb = 0, ub = x;
    ll lpos = 0, upos = 0;
    rep(i, 0, q) {
        ll t, a;
        cin >> t >> a;
        while (cur != k && r[cur + 1] <= t) {
            cur++;
            pair<ll, ll> brea = area;
            brea.first -= (r[cur] - r[cur - 1]) * (cur % 2 ? 1 : -1);
            brea.second -= (r[cur] - r[cur - 1]) * (cur % 2 ? 1 : -1);
            brea.first = max(min(x, brea.first), 0ll);
            brea.second = min(max(0ll, brea.second), x);
            if (brea.first == 0) {
                lb = -rs[cur];
                // lpos = cur;
                // ll tmp = r[cur] - r[cur - 1] - area.first;
                // ub -= tmp;
                // upos = cur;
            } else if (brea.second == x) {
                ub = x - rs[cur];
                // upos = cur;
                // ll tmp = r[cur] - r[cur - 1] + area.second - x;
                // lb += tmp;
                // lpos = cur;
            }
            area = brea;
            debug(cur, area);
        }
        if (lb >= ub) {
            a = area.first + (t - r[cur]) * (cur % 2 ? 1 : -1);
            // if (lpos > upos) {
            //     a = rs[cur] - rs[lpos] + (t - r[cur]) * (cur % 2 ? 1 : -1);
            // } else {
            //     a = x + rs[cur] - rs[upos] + (t - r[cur]) * (cur % 2 ? 1 : -1);
            // }
        } else if (a <= lb) {
            a = area.first + (t - r[cur]) * (cur % 2 ? 1 : -1);
            // a = rs[cur] - rs[lpos] + (t - r[cur]) * (cur % 2 ? 1 : -1);
        } else if (ub <= a) {
            a = area.second + (t - r[cur]) * (cur % 2 ? 1 : -1);
            // a = x + rs[cur] - rs[upos] + (t - r[cur]) * (cur % 2 ? 1 : -1);
        } else {
            a += rs[cur] + (t - r[cur]) * (cur % 2 ? 1 : -1);
        }
        a = max(0ll, a);
        a = min(a, x);
        cout << a << endl;
        debug(lb, lpos, ub, upos);
    }
    return 0;
}


Measured memory_bytes: 2816
import collections

n = int(input())


N = n
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)

c = collections.Counter(a)

sosu_list = list(c.keys())

kosu_list = list(c.values())

count = 0

for index, num in enumerate(sosu_list):
    kosu = kosu_list[index]
    p = num
    e = 1
    while True:
        if kosu - e > e:
            z = p ** e
            kosu = kosu - e
            e = e + 1
            N = N / z
            count = count + 1
        else:
            count = count + 1
            break
print(count)

Measured memory_bytes: 9480
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
# N, K = map(int, input().split())
S = input()

first_half = int(S[0 : 2])
second_half = int(S[2 : 4])

is_YYMM = False
is_MMYY = False

if 0 <= first_half and first_half <= 99 and 1 <= second_half and second_half <= 12 :
    is_YYMM = True
if 1 <= first_half and first_half <= 12 and 0 <= second_half and second_half <= 99 :
    is_MMYY = True

print("AMBIGUOUS" if is_YYMM and is_MMYY else "YYMM" if is_YYMM else "MMYY" if is_MMYY else "NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////


void solve(){
  ini(a,b);
  out((a==b) ? "Yes" : "No");
  

}

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

int main() {
	vector<vector<int>> c(3, vector<int>(3, 0));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	bool ans = true;
	if (c[0][0] + c[1][1] + c[2][2] != c[0][1] + c[1][2] + c[2][0]) ans = false;
	if (c[0][0] + c[1][1] + c[2][2] != c[0][2] + c[1][0] + c[2][1]) ans = false;
	if (ans) cout << "Yes";
	else cout << "No";
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<map<int, int> > vec(N+1);
    for(int n=1; n<=N; n++) {
        int A;
        cin >> A;
        for(int a=0; a<A; a++) {
            int x, y;
            cin >> x >> y;
            vec[n][x]=y;
        }
    }
    
    int mx=0;
    for(int i=0; i<(1<<N); i++) {
        bool flag=true;
        int tmp=0;
        // cout << i << ": " << endl;
        for(int n=0; n<N; n++) {
            if(i & (1<<n)) {
                tmp++;
                // cout << n+1 << " says..." << endl;
                for(auto itr=vec[n+1].begin(); itr!=vec[n+1].end(); itr++) {
                    if(itr->second) {
                        // cout << itr->first << " is true.";
                        if(!(i & (1<<(itr->first-1)))) {
                            flag=false;
                            // cout << "conflict!" << endl;
                            break;
                        }
                        // cout << " and it's true." << endl;
                    } else {
                        // cout << itr->first << " is false.";
                        if(i & (1<<(itr->first-1))) {
                            flag=false;
                            // cout << "conflict!" << endl;
                            break;
                        }
                        // cout << " and it's true." << endl;
                    }
                }
            }
            if(!flag) break;
        }
        if(flag) {
            mx = max(mx, tmp);
        }
    }

    cout << mx << endl;

    return 0;
    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc123/tasks/abc123_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<int> t(5);
    for (int i = 0; i < 5; i++)
        cin >> t[i];
    sort(t.begin(), t.end(), [](int x, int y) -> bool { return ((x - 1) % 10 < (y - 1) % 10); });

    int ans = t[0];
    for (int i = 1; i < 5; i++)
    {
        ans += (t[i] + 9) / 10 * 10;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#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 << endl; }
 
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(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int maxN = 502;

const double mypi = 3.14159265359;

void solve() {
  double r;
  cin >> r;
  cout.precision(8);
  cout  << mypi * r * 2 << endl;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 3832
// file creato da gio il 2020-06-24 19:30:16.613933

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define MOD 1000000007
#define S second
#define F first
#define PB push_back
using namespace std;

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif
    char n;
	cin >> n;
    if(n<='Z') cout <<"A";
    else cout <<"a";

}


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

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

    int ans = 0;
    int money = (a + b) * (min(x, y));
    for (int i = 1; i <= min(x, y); i++) {
        money = min(money, 2 * c * i + (a + b) * (min(x, y) - i));
    }
    ans += money;

    money = 2 * c * abs(x - y);
    if (x >= y) {
        for (int i = 1; i <= x - y; i++) {
            money = min(money, 2 * c * (x - y - i) + a * i);
        }
    } else {
        for (int i = 1; i <= y - x; i++) {
            money = min(money, 2 * c * (y - x - i) + b * i);
        }
    }
    ans += money;

    cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back
#define mp make_pair

bool graph[1000][1000];

vector<int>g[100100];

int main(){
    ll r,g,b;
    cin >> r>> g>>b;
    ll mx;
    mx= r*100+g*10+b;
    if(mx%4==0){
        cout<<"YES";
    }
    else cout<<"NO";

    return 0;

}


Measured memory_bytes: 2560
H,W=map(int,input().split())

L=[[0]*W for i in range(H)]
R=[[0]*W for i in range(H)]
U=[[0]*W for i in range(H)]
D=[[0]*W for i in range(H)]

cntr=0
cntd=[0]*W
for i in range(H):
    temp=input()
    for j in range(W):
        if temp[j]!="#":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
            cntr+=1
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j]=U[i-1][j]+1
            cntd[j]+=1
        else:
            for k in range(cntr):
                R[i][j-1-k]=k+1
            cntr=0
            for k in range(cntd[j]):
                D[i-1-k][j]=k+1
            cntd[j]=0
    if cntr!=0:
        for k in range(cntr):
            R[i][W - 1 - k] = k + 1
        cntr=0
for i in range(W):
    if cntd[i]!=0:
        for k in range(cntd[i]):
            D[H-1-k][i]=k+1

ans=[]
for i in range(H):
    for j in range(W):
        ans.append(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(max(ans))








Measured memory_bytes: 293020
#include<iostream>

using namespace std;

int main()
{
	int kai,abe,isazi,abesum,isazisum;

	cin >> kai;
	while (kai!=0)
	{
		abesum = isazisum = 0;
		for (int i = 0; i < kai; i++)
		{
			cin >> abe;
			cin >> isazi;
			if (abe > isazi)
			{
				abesum += abe + isazi;
			}
			else if (abe<isazi)
			{
				isazisum += abe + isazi;
			}
			else if (abe == isazi)
			{
				abesum += abe;
				isazisum += isazi;
			}
		}
		cout << abesum << " " << isazisum << endl;
		cin >> kai;
	}

	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, n;
	cin >> k >> n;
	vector<int> a(n), b;
	for (auto&& i : a) {
		cin >> i;
		b.push_back(i);
		b.push_back(i + k);
		b.push_back(i + 2 * k);
	}
	sort(begin(b), end(b));
	int ans = k * 2;
	for (int i = 0; i < 2 * n; i++) {
		ans = min(b[i + n - 1] - b[i], ans);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7308
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(m: usize, k: i64);
    macro_rules! fail {
        () => {
            puts!("-1\n");
            return;
        };
    }
    if m == 0 {
        if k != 0 {
            fail!();
        }
        puts!("0 0\n");
        return;
    }
    if m == 1 {
        if k != 0 {
            fail!();
        }
        puts!("0 0 1 1\n");
        return;
    }
    if k >= 1 << m {
        fail!();
    }
    let mut ans = vec![];

    if k == 0 {
        for i in 0..1 << m {
            ans.push(i);
            ans.push(i);
        }
    } else {
        let vacant = k & -k;
        ans.push(0);
        ans.push(k);
        for i in 0..1 << m {
            if (i & vacant) != 0 { continue; }
            if i == 0 { continue; }
            ans.push(i);
            ans.push(i ^ k);
        }
        ans.push(k);
        ans.push(0);
        for i in 0..1 << m {
            if (i & vacant) != 0 { continue; }
            if i == 0 { continue; }
            ans.push(i ^ k);
            ans.push(i);
        }
    }

    for i in 0..ans.len() {
        puts!("{}{}", ans[i], if i + 1 == ans.len() { "\n" } else { " " });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

int memo[1 << 16][16];
int stat[5][5];

int val(int t, int b)
{
	return ((b >> 2 * t) & 3);
}

int calc(int bit, int y)
{
	int ret = 0;
	
	for (int i = 0; i < 5; i++){
		int k = stat[y][i];
		if (!~k) continue;
		k += (i ? val(i - 1, bit) + val(i + 3, bit) : 0) + (i != 4 ? val(i, bit) + val(i + 4, bit) : 0);
		k %= 4;
		ret += !!k * 50 + 10 * k;
	}
	return (ret);
}

int getMax(int bit, int pos)
{
	int ret = 0;
	
	if (pos && pos % 4 == 0) ret = calc(bit, pos / 4 - 1);
	if (pos == 16) return (ret + calc(bit & 0x00ff, 4));
	
	if (memo[bit][pos] >= 0) return (memo[bit][pos]);
	
	int t = 0;
	
	for (int i = 0; i < 4; i++) t = max(t, getMax(((bit << 2) | i) & 0xffff, pos + 1));
	
	return (memo[bit][pos] = ret + t);
}

int main()
{
	int n;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		
		for (int y = 0; y < 5; y++){
			for (int x = 0; x < 5; x++){
				scanf("%d", &stat[y][x]);
				stat[y][x]--;
			}
		}
		
		memset(memo, -1, sizeof(memo));
		printf("%d\n", getMax(0, 0));
	}
	
	return (0);
}

Measured memory_bytes: 5128
import sys
from collections import deque
import copy
import numpy as np
import math
def main():
    A, B, H, M = map(int, input().split())
    short = H * (360 / 12) + M * 1 / 2
    long_ = M * (360 / 60)
    ang = abs(long_ - short)
    ang = min(ang, 360 - ang)
    a = math.radians(ang)
    h = A * math.sin(a)
    w = B - A * math.cos(a)
    ans = math.sqrt(h ** 2 + w ** 2)
    print(ans)
    
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 27232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, q, y;
string s;

int main(){
	cin >> n >> q;
	string ans = "kogakubu10gokan";
	REP(i, n){
		cin >> y >> s;
		if (y <= q){
			ans = s;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=9)
        cout<<"Yes"<<endl;
    else if((n%2)==0&&(n/2<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%3)==0&&(n/3<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%4)==0&&(n/4<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%5)==0&&(n/5<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%6)==0&&(n/6<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%7)==0&&(n/7<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%8)==0&&(n/8<=9))
    {
            cout<<"Yes"<<endl;
    }
    else if((n%9)==0&&(n/9<=9))
    {
            cout<<"Yes"<<endl;
    }

    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>

using namespace std;

#define BUF_SIZE 22

struct Node{
	Node(){
		left_child = right_child = 0;
		data = 0;
	}
	Node *left_child,*right_child;
	long long data;
};

class Tree{
public:
	Tree(){
		root = new Node();
		num_of_node = 0;
	}
	void insert(long long insert_data){
		if(num_of_node == 0){
			root->data = insert_data;
			num_of_node++;
		}else{
			Node* tmp = root;
			while(true){
				if(tmp->data < insert_data){
					if(tmp->right_child == 0){
						tmp->right_child = new Node();
						tmp->right_child->data = insert_data;
						break;
					}else{
						tmp = tmp->right_child;
					}
				}else{
					if(tmp->left_child == 0){
						tmp->left_child = new Node();
						tmp->left_child->data = insert_data;
						break;
					}else{
						tmp = tmp->left_child;
					}
				}
			}
		}
	}

	bool find(long long data){
		if(num_of_node == 0){
			return false;
		}else{
			Node* tmp = root;
			while(true){
				if(tmp->data < data){
					if(tmp->right_child == 0){
						return false;
					}else{
						tmp = tmp->right_child;
					}
				}else if(tmp->data > data){
					if(tmp->left_child == 0){
						return false;
					}else{
						tmp = tmp->left_child;
					}
				}else{
					return true;
				}
			}
		}
	}

	void print(){
		inORDER(root);
		printf("\n");
		preORDER(root);
		printf("\n");
	}

private:
	Node* root;
	int num_of_node;

private:
	void preORDER(Node* node){
		printf(" %lld",node->data);
		if(node->left_child != 0) preORDER(node->left_child);
		if(node->right_child != 0) preORDER(node->right_child);
	}

	void inORDER(Node* node){
		if(node->left_child != 0) inORDER(node->left_child);
		printf(" %lld",node->data);
		if(node->right_child != 0) inORDER(node->right_child);
	}
};


int main(){
	int m;
	long long insert_data,search_data;
	char buf[BUF_SIZE];
	Tree tree;

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

	for(int i = 0; i < m; i++){
		fgets(buf,BUF_SIZE,stdin);
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int k = 0; buf[k] != '\0';k++){
				if(buf[k] >= '0' && buf[k] <= '9'){
					insert_data = 10*insert_data + (buf[k] - '0');
				}
			}
			tree.insert(insert_data);
		}else if(buf[0] == 'p'){
			tree.print();
		}else{
			search_data = 0;
			for(int k = 0; buf[k] != '\0';k++){
				if(buf[k] >= '0' && buf[k] <= '9'){
					search_data = 10*search_data + (buf[k] - '0');
				}
			}
			if(tree.find(search_data)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
}

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

using namespace std;

int main() {

  long long  n;
  cin >> n;



  long long h0, h1, h2;
  cin >> h0;

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

  cin >> h1;

  long long ans0, ans1, ans2;
  ans0 = 0;
  ans1 = abs(h1 - h0);

  for (int i = 3; i <= n; i++) {
    cin >> h2;
    ans2 = min(ans1 + abs(h2 - h1) , ans0 + abs(h2 - h0));
    ans0 = ans1;
    ans1 = ans2;
    h0 = h1;
    h1 = h2;
  }


  cout << ans1 << endl;
}




































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

int main(int argc, char const *argv[])
{
    int r,c,d;
    cin >> r >> c;

    int** a = new int *[r];
    for (int i=0; i<r; i++){
        a[i] = new int [c];
        for (int j=0; j<c; j++){
            cin >> d;
            a[i][j]=d;
        }
    }

    int rTotal;
    int * cTotal = new int [c];

    for (int i=0; i<c; i++){
        cTotal[i]=0;
    }

    for (int i=0; i<r; i++){
        rTotal=0;
        for (int j=0; j<c; j++){
            cout << a[i][j] << " ";
            rTotal +=  a[i][j];
            cTotal[j] += a[i][j];
        }
        cout << rTotal << endl;
    }

    int total=0;
    for (int i=0; i<c; i++){
        cout << cTotal[i] << " ";
        total += cTotal[i];
    }
    cout << total << endl;
    delete[] a;
    delete[] cTotal;
    a=0;
    cTotal=0;
    return 0;
}


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int max = -1;
		int min = 1001;
		for(int i=0;i<a;i++){
			int next = sc.nextInt();
			if(next < min){
				min = next;
			}

			if(max < next){
				max = next;
			}
		}

		System.out.println(max-min);

	}

	private static int calc(int[] a,int ans,int n) {
		int sum=a[0];
		boolean plusFlag;
		// TODO 自動生成されたメソッド・スタブ
		if(a[0] > 0){
			plusFlag = true;
		}else{
			plusFlag = false;
		}



		for(int i = 1;i<n;i++){
			sum += a[i];
			if(plusFlag){
				if(sum >= 0){
					ans += Math.abs(sum)+1;
					sum = -1;

				}
			}else{
				if(sum <= 0){
					ans += Math.abs(sum)+1;
					sum = 1;
				}
			}
			plusFlag = !plusFlag;
		}


		return ans;
	}


}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while (true) {
	    int n, w, d;
	    n = sc.nextInt();
	    w = sc.nextInt();
	    d = sc.nextInt();
	    if (w == 0) {
		break;
	    }
	    
	    ArrayList<Cake> pieces = new ArrayList<Cake>();
	    Cake c = new Cake(w, d);
	    pieces.add(c);
	    
	    for (int i = 0; i < n; i++) {
		int p, s;
		p = sc.nextInt();
		s = sc.nextInt();
		Cake piece = pieces.get(p - 1);
		pieces.remove(p - 1);
		s = s % (piece.w + piece.w + piece.d + piece.d);
		int tmpw, tmpd, tmpw2, tmpd2;
		if (s < piece.w) {
		    tmpw = s;
		    tmpd2 = tmpd = piece.d;
		    tmpw2 = piece.w - tmpw;
		} else if (s < piece.w + piece.d) {
		    tmpw2 = tmpw = piece.w;
		    tmpd = s - piece.w;
		    tmpd2 = piece.d - tmpd;
		} else if (s < piece.w + piece.w + piece.d) {
		    tmpw = s - piece.w - piece.d;
		    tmpd2 = tmpd = piece.d;
		    tmpw2 = piece.w - tmpw;
		} else {
		    tmpw2 = tmpw = piece.w;
		    tmpd = s - piece.w - piece.w - piece.d;
		    tmpd2 = piece.d - tmpd;
		}
		//System.out.println(tmpw + " " + tmpd);
		//System.out.println(tmpw2 + " " + tmpd2);
		Cake tmp1 = new Cake(tmpw, tmpd);
		Cake tmp2 = new Cake(tmpw2, tmpd2);
		
		if (tmp1.area < tmp2.area) {
		    pieces.add(tmp1);
		    pieces.add(tmp2);
		} else {
		    pieces.add(tmp2);
		    pieces.add(tmp1);
		}
	    }
	    
	    Collections.sort(pieces, new CakeSort());
	    for (int i = 0; i < pieces.size(); i++) {
		if (i != 0) {
		    System.out.print(" ");
		}
		System.out.print(pieces.get(i));
	    }
	    System.out.println();
	}
    }
}

class Cake {
    int w;
    int d;
    int area;
    
    Cake(int w, int d) {
	this.w = w;
	this.d = d;
	this.area = w * d;
    }
    
    public String toString() {
	return Integer.toString(area);
    }
}

class CakeSort implements Comparator<Cake> {
    public int compare(Cake a, Cake b) {
	return a.area - b.area;
    }
}

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k;
vector<int> g[N];
int in_deg[N];
int root = 1; //anyone
int ans;
void dfs(int v, int p = 0){
	bool pass = 0;
	for(int i=0; i<g[v].size(); i++){
		int u = g[v][i];
		if (u == p) {
			pass = 1;
			continue;
		}
		if (v == root) ans *= (k-1-i);
		else {
			if (pass) ans *= (k-1-i);
			else ans *= (k-2-i);
		}
		if (ans < 0) {
			cout << 0 << endl; 
			exit(0);
		}
		else ans %= MOD;
		dfs(u, v);
	}
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	ans = k;
	for(int i=1; i<n; i++){
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11648
n = int(input())

#文字列として渡すのはint化した時に0がなくなるようにするため
def dfs(s):
    if int(s) > n:
        return 0
    #文字列sの中に７・５・３が1つ以上含まれていればTrue
    if all(s.count(i) for i in "753"):
        ret = 1
    else:
        ret = 0
    for j in "753":
        ret += dfs(s + j)
    #このreturnで一つ浅いfor文の一周が終わる
    return ret

print(dfs("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int time=0;
    while(b<=a){
        b*=2;
        time++;
    }
    while(c<=b){
        c*=2;
        time++;
    }
    if(time<=k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<numeric>
#include<tuple>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;
const int INF = 1<<29;

int n, m, h, k, s, t, p;
struct Edge{
	int v, c, r;
	Edge(int v, int c, int r):v(v), c(c), r(r){}
};

int main(){
	while(scanf("%d%d%d%d", &n, &m, &h, &k), n){
		vector<vector<Edge>> g(n*(h+1));
		REP(i, m){
			int u, v, c, hh, r;
			scanf("%d%d%d%d%d", &u, &v, &c, &hh, &r); u--; v--; r--;
			for(int j=0;j+hh<=h;j++){
				g[n*j+u].emplace_back(n*(j+hh)+v, c, r);
				g[n*j+v].emplace_back(n*(j+hh)+u, c, r);
			}
		}
		vector<int> cost(1<<k, INF); cost[0] = 0;
		scanf("%d%d%d", &s, &t, &p); s--; t--;
		REP(i, p){
			int d, l, x = 0, y;
			scanf("%d%d", &l, &d);
			REP(j, l){
				scanf("%d", &y); y--;
				x |= 1 << y;
			}
			cost[x] = min(cost[x], d);
		}
		REP(i,1<<k)REP(j,1<<k) cost[i|j] = min(cost[i|j], cost[i] + cost[j]);
		int ans = INF;
		REP(b, 1<<k)if(cost[b] < ans){
			vector<int> dp(n*(h+1), INF);
			priority_queue<pii, vector<pii>, greater<pii>> pq;
			pq.emplace(cost[b], s);
			dp[s] = cost[b];
			while(!pq.empty()){
				int u, c; tie(c, u) = pq.top(); pq.pop();
				if(ans <= c) break;
				if(u%n == t){
					ans = c;break;
				}
				for(auto &e : g[u]){
					int nc = c;
					if(!(1&(b>>e.r))) nc += e.c;
					if(nc < dp[e.v]){
						dp[e.v] = nc;
						pq.emplace(nc, e.v);
					}
				}
			}
		}
		printf("%d\n", ans == INF ? -1 : ans);
	}
	return 0;
}

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

int main() {
    int n;
   cin >> n ;
   int s=0;
   int m=0;
   int r=0;
   for(int i=0;i<n;i++){
      cin >> s;
	  m=max(s,m);
	  r+=s;
   
   }
   
  if(r-m>m)cout <<"Yes" <<endl;
  else{
		 cout << "No" << endl;
   }
}


Measured memory_bytes: 256
from functools import reduce

def main():
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # 1文字のみを読み込み
    # s = input().rstrip()
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 1文字ずつ標準入力を文字列として読み込み
    # s = list(input().rstrip())
    
    # 1文字ずつ標準入力を数値配列として読み込み
    # X = [int(_) for _ in input().split()]
    s = input().rstrip().split(' ')
    W = int(s[0])
    W_S = 0
    H = int(s[1])
    H_S = 0
    N = int(s[2])
    x = []
    y = []
    a = []
    for i in range(N):
        s = input().rstrip().split(' ')
        x.append(int(s[0]))
        y.append(int(s[1]))
        a.append(int(s[2]))

    for i in range(N):
        if(a[i]==1 and x[i]>W_S ):
            W_S = x[i]
        elif(a[i]==2 and x[i]<W ):
            W = x[i]
        elif(a[i]==3 and y[i]>H_S ):
            H_S = y[i]
        elif(a[i]==4 and y[i]<H ):
            H = y[i]        
    if W-W_S <0 or H-H_S < 0:
        ans = 0
    else:
        ans = (W-W_S) * (H-H_S)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
h = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

even = a.select{ |n| n.even? }

even_length = even.length

ans = even.select{|n| n % 5 == 0 || n % 3 == 0}

puts ans.length == even_length ? "APPROVED" : "DENIED"


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#define END "END_OF_TEXT"
using namespace std; 
int main(){
  string W,Ti;
  int counter;
  counter=0;
  cin >> W;
  for(int i=0;i<W.size();i++){
    W[i]=tolower(W[i]);}
  while(cin>>Ti && Ti!=END){
    
 for(int i=0;i<Ti.size();i++){
    Ti[i]=tolower(Ti[i]);}

    if(Ti==W){
      counter++;}
  } 
      
  cout << counter << endl;	


 return 0;
  
}

Measured memory_bytes: 1192
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(h a)
  (ceiling (/ h a)))
(let* ((line0 (splitat #\space (read-line nil nil)))
       (s (car line0))
       (tt (cadr line0))
       (line1 (mapcar #'parse-integer (splitat #\space (read-line nil nil))))
       (a (car line1))
       (b (cadr line1))
       (u (read-line nil nil))
       )
  (format t "~A ~A~%" (if (string= u s) (1- a) a) (if (string= u tt) (1- b) b)))


Measured memory_bytes: 16484
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL C[5001];
LL rC[5001];
LL MOD=1e9+7;
LL pow(LL x,LL y){
	LL now=1;
	LL a=x;
	while(y!=0){
		if(y%2==1){
			now*=a;
			now%=MOD;
		}
		y/=2;
		a*=a;
		a=a%MOD;
	}
	return now;
}

void init(){
	C[0]=1;
	C[1]=1;
	REP(i,5001){
		if(i==0||i==1){
			continue;
		}
		C[i]=(C[i-1]*i)%MOD;
	}
	rC[5000]=pow(C[5000],MOD-2);
	for(int i=4999;i>=0;i--){
		rC[i]=(rC[i+1]*(i+1))%MOD;
	}
}

LL com(LL x, LL c){
	if(x<c)return 0;
	LL a=(C[x]*rC[c])%MOD;
	a=(a*rC[x-c])%MOD;
	return a;
}

int K;
int main(){
	init();
	cin>>N>>K;
	REP(i,K){
		LL ans=com(N-K+1,i+1);
		LL b=K-(i+1);
		LL aa=com(b+(i),i);
		//cout<<ans<<" "<<aa<<endl;
		cout<<(ans*aa)%MOD<<endl;
	}
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {

    public static class Pair implements Comparable<Pair>{
        int l; int r;
        public Pair(int x, int y){
            this.l=x; this.r=y;
        }
        public int compareTo(Pair other){
            if(this.r<other.r)return -1;
            else if(this.r==other.r){
                if(this.l<other.l)return -1;
                return 1;
            }
            return 1;
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        Pair[] arr=new Pair[N];
        String[] t; int l; int r;
        for (int i = 0; i < N; i++) {
            t=br.readLine().split("\\ ");
            l=Integer.parseInt(t[0])-Integer.parseInt(t[1]);
            r=Integer.parseInt(t[0])+Integer.parseInt(t[1]);
            arr[i]=new Pair(l,r);
        }
        Arrays.sort(arr);
        int ans=1; int cur=arr[0].r;
        for (int i =1; i < N; i++) {
            if(cur<=arr[i].l){
                cur=arr[i].r; ans++;
            }
        }
        System.out.println(ans);
    }
    
}



Measured memory_bytes: 48084
#include <stdio.h>
int main(){
    int array[10000];
    for(int i=0;i < 10000;i++){
        scanf("%d",&array[i]);
        if(array[i] == 0){
            break;
        }
    }
    for(int i=0;i < 10000;i++){
        printf("Case %d: %d\n",i+1,array[i]);
        if(array[i] == 0){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
//using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
const double PI = acos(-1.0);

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

const int MOD = 1000000007;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<ll> H(N);
  for (auto &it : H)
    cin >> it;
  Graph G(N);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll cnt = 0;
  for (int i = 0; i < N; i++)
  {
    bool high = true;
    for (auto &it : G[i])
    {
      if (H[i] <= H[it])
        high = false;
    }
    if (high)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9276
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 1<<19;
const int MM = 998244353;

pii D[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d%d", &D[i].first, &D[i].second);
	for(int i = 1; i <= N; i++){
		if((D[i].first + D[i].second + D[1].first + D[1].second) % 2 != 0) return !printf("-1\n");
	}
	int ch = 0;
	if((D[1].first + D[1].second) % 2 == 0) ch = 1;
	
	if(ch) printf("32\n1 ");
	else printf("31\n");
	for(int i = 30; i >= 0; i--) printf("%d ", 1<<i);
	printf("\n");

	for(int i = 1; i <= N; i++){
		int dx[4] = {-1, 0, 1, 0};
		int dy[4] = {0, -1, 0, 1};
		char s[5] = "LDRU";
		pii cur = pii(0, 0);
		if(ch) printf("R"), cur = pii(1, 0);
		for(int m = 30; m >= 0; m--){
			ll dist = 1e18;
			char ans;
			pii x;
			for(int d = 0; d < 4; d++){
				pii nxt = pii(cur.first + dx[d] * (1<<m), cur.second + dy[d] * (1<<m));
				ll t = abs((ll)nxt.first - D[i].first) + abs((ll)nxt.second - D[i].second);
				if(dist > t) dist = t, ans = s[d], x = nxt;
			}
			cur = x; printf("%c", ans);
		}
		printf("\n");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[100010][11];
map<string, int> mp;
int mem[100010][4][4][4], mem1[100010][4][4][4], n;
int dp(int x, int a, int b, int c){
	if(a<0 || b<0 || c<0){
		return 0;
	}
	if(x==n){
		return 1;
	}
	if(mem[x][a][b][c]!=-1){
		return mem[x][a][b][c];
	}
	int res=0, sm[333];
	sm['A']=a;
	sm['B']=b;
	sm['C']=c;
	sm[s[x][0]]++;
	sm[s[x][1]]--;
	res|=dp(x+1, sm['A'], sm['B'], sm['C']);
	if(res){
		mem1[x][a][b][c]=0;
		return res;
	}
	sm['A']=a;
	sm['B']=b;
	sm['C']=c;
	sm[s[x][0]]--;
	sm[s[x][1]]++;
	res|=dp(x+1, sm['A'], sm['B'], sm['C']);
	if(res){
		mem1[x][a][b][c]=1;
		return res;
	}
	mem[x][a][b][c]=res;
	return res;
}
int sm[333];
int main(){
    int a, b, c;
    while(cin>>n>>a>>b>>c){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%s",s[i]);
        }
        memset(mem, -1, sizeof mem);
        a=min(a, 3);
        b=min(b, 3);
        c=min(c, 3);
        ans=dp(0, a, b, c);
        if(ans){
        	cout<<"Yes"<<endl;
			sm['A']=a;
			sm['B']=b;
			sm['C']=c;
        	for(int x=0; x<n; ++x){
	        	if(mem1[x][sm['A']][sm['B']][sm['C']]==0){
	        		printf("%c\n",s[x][0]);
	        		++sm[s[x][0]];
	        		--sm[s[x][1]];
	        	}
	        	else{
	        		printf("%c\n",s[x][1]);
	        		--sm[s[x][0]];
	        		++sm[s[x][1]];
	        	}
        	}
        }
        else{
        	cout<<"No"<<endl;
        }
    }
  return 0;
}




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

int main(){
    int n;
    int score[10000]={0},a,b,c,d;

    cin >> n;
    for(int i=0;i<n*(n-1)/2;i++){
	cin>>a>>b>>c>>d;
	if(c>d){
	    score[a-1]+=3;
	}else if(c<d){
	    score[b-1]+=3;
	}else{
	    score[a-1]+=1;
	    score[b-1]+=1;
	}
    }
 
    int cnt;
    for(int i=0;i<n;i++){
	cnt=0;
	for(int j=0;j<n*(n-1)/2;j++){
     	    if(score[j]>score[i]) cnt++;
	}
	cout << cnt+1 << endl;
    }
	    

    return 0;
}

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

using namespace std;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
int n, k, c, L[MAXN], R[MAXN];
string s;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k >> c; //k days
    cin >> s;
    int i = 0, cnt = 1;
    while (i < n) {
        if (s[i] == 'o') L[cnt++] = i, i += c + 1;
        else i++;
    }
    i = n - 1, cnt = k;
    while (i >= 0) {
        if (s[i] == 'o' && cnt) R[cnt--] = i, i -= c + 1;
        else i--;
    }
    for (int i = 1; i <= k; i++)
        if (L[i] == R[i])
            cout << L[i] + 1 << endl;
    return 0;
}

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

#define N 3
#define N1 4
#define N2 9
#define N3 100

int puz[N][N];
int tmp[N][N];
int dx[N1]={0,1,0,-1};
int dy[N1]={1,0,-1,0};

void emp(int x[],int y[]) {
  int i,j;
  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) {
      if(!puz[i][j]) {
        *x = j;
        *y = i;
        return;
      }
    }
  }
}

void swap(int a[],int b[]){
  int tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}

int calsum(){
  int i,a,sum=0;
  for(i=0; i<N2; i++){
    a = puz[i/N][i%N];
    if(a){
      a--;
      sum+=abs((i/N)-(a/N))+abs((i%N)-(a%N));
    }
  }
  return sum;
}

int dfs(int x,int y,int p,int dep,const int lim){
  int i,h,nx,ny,res;
  h=calsum();
  if(h==0) return dep;
  if(dep+h>lim) return -1;
  for(i=0;i<N1;i++){
    nx=x+dx[i];
    ny=y+dy[i];
    if(~p && i==(p+2)%N2) continue;
    if(!(0<=nx && nx<N && 0<=ny && ny<N)) continue;
    swap(&puz[y][x],&puz[ny][nx]);
    res = dfs(nx,ny,i,dep+1,lim);
    if(~res) return res;
    swap(&puz[y][x],&puz[ny][nx]);
  }
  return -1;
}

int main() {
  int i,j,ans,x,y,l;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++) scanf("%d",&puz[i][j]);
  }
  emp(&x,&y);
  for(l=0;l<N3;l++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++) tmp[i][j] = puz[i][j];
    }
    ans=dfs(x,y,-1,0,l);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
    for(i=0;i<N;i++){
      for(j=0;j<N;j++) puz[i][j] = tmp[i][j];
    }
    ans = -1;
    if(l==N3-1) printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>

int main()
{
    int N,A,B;

    scanf("%d %d %d",&N,&A,&B);

    if((B-A)%2==0){
        printf("Alice\n");
    }else if((B-A)%2==1){
        printf("Borys\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,ans=0,n,m;
    cin>>n>>m;
    ll c[n];
    for (ll i=0; i<n; i++) {
        cin>>a>>b;
        c[i]=a*10000000+b;
    }
    sort(c,c+n);
    for (ll i=0; m>0; i++) {
        ans+=c[i]/10000000*min(c[i]%1000000,m);
        m-=min(c[i]%1000000,m);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
-- 139 f 

import Control.Monad
import Data.List

main :: IO()
main = do

    [n, k] <- (map (read :: String -> Int) . words) <$> getLine
    
    let maxk = (n - 1) * (n -2) `div` 2

    if maxk < k
    then 
        print (-1)
    else
        
        let arr1 = do
            i <- [2..n]
            return (1,i) in

        let arr2 = do
            i <- [2..n]
            j <- [(i+1)..n ]
            return (i,j) in
        
        let arr3 = arr1 ++ (drop k arr2) in

        let m = length arr3 in

        let printfunc d = putStrLn str
                where 
                    (i,j) = d 
                    str = (show i ) ++ " " ++ (show j) in
                        
        (print m) >> (forM_ arr3 printfunc)




Measured memory_bytes: 1660