akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 300005;
const int MMAX = 100005;

int aib[NMAX];
int aibn;

void update(int pos, int val) {
    for (++pos; pos <= aibn; pos += pos & -pos) {
        aib[pos] += val;
    }
}

int query(int pos) {
    int ret = 0;
    for (++pos; pos > 0; pos -= pos & -pos) {
        ret += aib[pos];
    }
    return ret;
}

struct Event {
    int time, type, ind;
    Event(int _time, int _type, int _ind):
        time(_time), type(_type), ind(_ind) {}
    bool operator<(const Event& o) const {
        return time < o.time;
    }
};

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> a;
    for (int i = 1; i <= m; ++i) {
        for (int j = 0; j <= m; j += i) {
            a.push_back(make_pair(j, i));
        }
    }
    aibn = n + 1;
    vector<int> lastMax(m + 1, 0);
    vector<int> fans(m + 1, 0);

    vector<pair<int, int>> segs;
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        segs.push_back(make_pair(l, r));
    }
    sort(a.begin(), a.end());
    sort(segs.begin(), segs.end());
    vector<Event> events;
    for (int i = 0; i < n; ++i) {
        events.push_back(Event(segs[i].first, 1, i + 1));
        events.push_back(Event(segs[i].second + 1, -1, i + 1));
    }
    sort(events.begin(), events.end());
    
    int pos = 0;
    int cseg = 0;
    int cntAll = 0;
    for (const pair<int, int>& p: a) {
        while (pos < SZ(events) && events[pos].time <= p.first) {
            update(events[pos].ind, events[pos].type);
            cseg = max(cseg, events[pos].ind);
            cntAll += events[pos].type;
            pos++;
        }
        fans[p.second] += cntAll - query(lastMax[p.second]);
        lastMax[p.second] = cseg;
    }
    for (int i = 1; i <= m; ++i) {
        cout << fans[i] << '\n';
    }
}


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

using namespace std;
int p = 1000000007;
void multiply(vector<vector<unsigned long long int> >&A,vector<vector<unsigned long long int> >&B,vector<vector<unsigned long long int> >&ans){
	int n = A.size();
	vector<vector<unsigned long long int> >temp(n,vector<unsigned long long int>(n,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				temp[i][j] = (temp[i][j]%p + (A[i][k]%p * B[k][j]%p)%p)%p;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans[i][j] = temp[i][j];
		}
	}
}
void power(vector<vector<unsigned long long int> >&graph,vector<vector<unsigned long long int> >&ans,unsigned long long int k){
	//cout<<k<<" ";
	if(k == 1){
		for(int i=0;i<graph.size();i++){
			for(int j=0;j<graph[i].size();j++){
				ans[i][j] = graph[i][j];
			}
		}
		return;
	}
	power(graph,ans,k/2);
	multiply(ans,ans,ans);
	if(k%2 != 0){
		multiply(ans,graph,ans);
	}
}
int main(){
	unsigned long long int n,k;cin>>n>>k;
	vector<vector<unsigned long long int> >graph(n,vector<unsigned long long int>(n,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>graph[i][j];
		}
	}
	vector<vector<unsigned long long int> >ans(n,vector<unsigned long long int>(n,0));
	power(graph,ans,k);
	unsigned long long int sum = 0;
	//cout<<endl;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
		//	cout<<ans[i][j]<<" ";
			sum = (sum%p + ans[i][j]%p)%p;
		}
	//	cout<<endl;
	}
	cout<<sum;
}


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

int main(){
  int N;
  string S1,S2;
  cin >> N;
  if(N%2==0){
    for(int i=1;i<=N/2;i++){
      char c;
      cin >> c;
      S1 += c;
    }
    for(int i=1;i<=N/2;i++){
      char c;
      cin >> c;
      S2 += c;
    }
    if(S1==S2){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def main():
  n = int(input())
  a = list(map(int, input().split()))
  d = [0]*n
  for i, x in enumerate(a):
    if i+x < n: d[i+x] += 1
  print(sum([d[i-x] for i, x in enumerate(a) if i-x >= 0]))
main()

Measured memory_bytes: 32372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  long long n, k;
  cin >> n >> k;
  long long count;
  count = pow(int(n / k), 3);
  if (k % 2 == 1){
    cout << count << endl;
    return 0;
  }
  count += pow(int((n + k / 2) / k), 3);
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
     
    int n;
    cin >> n;
     
    vector<vector<ll>> cost(n, vector<ll>(n));
    rep(i, n) rep(j, n) cin >> cost[i][j];
 
    ll ans = 0;
    rep(i, n){
        REP(j, i+1, n){
            ans += min(cost[i][j], cost[j][i]);
        }
    }
     
    cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int s = scanner.nextInt();

        int dummy = s == 1000000000 ? 999999999 : 1000000000;

        for (int i = 0; i < n; i++) {
            if (i < k) {
                System.out.print(s + " ");
            } else {
                System.out.println(dummy + " ");
            }
        }
    }
}


Measured memory_bytes: 43836
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	i64 a[2], b[2];
    cin >> a[0] >> a[1] >> b[0] >> b[1];
    i64  maxx = -1e18 -1;
    fo(i,0,1) fo(j,0,1) maxx = max(maxx,a[i]*b[j]);
    cout << maxx << '\n';
    return 0;
}


Measured memory_bytes: 3648
s = list(input())
n = len(s)
k = int(input())

for i in range(n):
    if k > 0 and i == n-1:
        x = ord(s[i])-ord("a")
        s[i] = chr((k+x)%26+ord("a"))
        break
    if s[i] == "a":
        continue
    x = ord(s[i])-ord("a")

    if k >= 26-x:
        s[i] = "a"
        k -= 26-x
print(*s,sep="")

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    ll q, que, x;
    set<ll> S;
    cin >> q;

    rep(i, q)
    {
        cin >> que >> x;
        if(!que)
            S.insert(x);
        cout << (que ? S.count(x) : S.size()) << endl;
    }
    return 0;
}


Measured memory_bytes: 12408
import itertools

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

perm = list(itertools.permutations(range(1,N+1)))
for i in range(len(perm)):
    if P == perm[i]:
        a = i
    if Q == perm[i]:
        b = i

print(abs(a-b))


Measured memory_bytes: 13840
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	int k, a, b;
	cin >> k >> a >> b;
	int x = (b/k) * k;
	if(x >= a)
		cout << "OK\n";
	else
		cout << "NG\n";
	return 0;
}



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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int Mod = 1e9 + 7;

const int oo = 0x3f3f3f3f;

const int maxn = 19;
const int maxm = 20;

int n, m, K;
vector<pair<int, int> > all[maxm + 5];
int ans;

int nxt[maxn + 5][(1 << maxn) + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d", &n, &m, &K);
	--n;
	REP(i, 0, K)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		--a, b = n - b;
		all[a].pb(mp(b, c));
	}
	REP(i, 0, 1 << n)
	{
		vector<int> place;
		REP(j, 0, n) if (i >> j & 1) place.pb(j);
		REP(j, 0, n)
		{
			if (j >= SZ(place)) nxt[j][i] = -1;
			else
			{
				if (place[j] == 0) nxt[j][i] = i ^ 1;
				else if ((i >> (place[j] - 1)) & 1) nxt[j][i] = -1;
				else nxt[j][i] = i ^ (1 << place[j]) ^ (1 << (place[j] - 1));
			}
		}
	}
	static int dp[(1 << maxn) + 5];
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	REP(i, 0, m)
	{
		static int sum[(1 << maxn) + 5];
		memcpy(sum, dp, sizeof sum);
		for (int j = n - 1; j >= 0; --j)
		{
			REP(k, 0, 1 << n) if (~nxt[j][k])
			{
				(sum[k] += sum[nxt[j][k]]) %= Mod;
			}
		}
		memset(dp, 0, sizeof dp);
		REP(j, 0, 1 << n)
		{
			bool failed = 0;
			for (auto u : all[i]) if ((j >> u.x & 1) != u.y) { failed = 1; break; }
			if (!failed) dp[j] = sum[j];
		}
	}
	ans = 0;
	REP(i, 0, 1 << n) (ans += dp[i]) %= Mod;
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 45440
from fractions import gcd

def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n=int(input())
    b = list(map(int, input().split()))
    ans = []
    for i in range(n):
        for j in range(len(b)-1, -1, -1):
            if b[j] == j+1:
                ans.append(j+1)
                b = b[:j] + b[j+1:]
                break
        if len(b) + i + 1 != n:
            print(-1)
            return
    ans = ans[::-1]
    for i in range(n):
        print(ans[i])

main()

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

typedef long long ll;

ll N, K, a[200002], f[200002];

bool fun(ll m){
	ll cnt = 0;
	for(int i = 1; i<=N; i++){
		ll rt = m/f[i];
		if(rt < a[i]) cnt += a[i]-rt;
	}
	return cnt <= K;
}

int main(){
	scanf("%lld %lld", &N, &K);


	for(int i = 1; i <= N; i++){scanf("%lld", &a[i]);}
	for(int i = 1; i <= N; i++){scanf("%lld", &f[i]);}
	sort(a+1, a+N+1); sort(f+1, f+N+1, greater<ll>());

	ll lo = 0, hi = 1e12;
	while(lo<=hi){
		ll mid = (lo+hi)/2;
		if(fun(mid)) hi = mid-1;
		else lo = mid+1;
	}
	printf("%lld\n", lo);
	return 0;
}

Measured memory_bytes: 3328
a,b,c,x,y=map(int,input().split())
if a+b<2*c:
    print(a*x+b*y)
else:
    if x>y:
        if a<2*c:
            print(a*(x-y)+2*c*y)
        else:
            print(2*c*x)
    else:
        if b<2*c:
            print(b*(y-x)+2*c*x)
        else:
            print(2*c*y)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll oddsolve(ll a) {
	return (a + 1) / 2 % 2;
}
ll solve(ll a) {
	if (a % 2 == 1)return oddsolve(a);
	else return oddsolve(a + 1) ^ (a + 1);
}
int main() {
	ll A, B;
	cin >> A >> B;
	cout << (solve(B) ^ solve(A - 1)) << endl;
	return 0;
}


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

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

#define MAX 1000000
#define NEXT(d) ((d) % 4)

int mas[2000][2000];
iP idx[MAX + 1];
vector< bool > isP(MAX + 1, true);

void makePrime() {
    isP[0] = isP[1] = false;
    for(int i = 2; i * i <= MAX; i++)
        for(int j = i + i; j <= MAX; j += i)
            isP[j] = false;
}

void makeMap() {
    //> ^ < v
    int x = 1000, y = 1000;
    int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
    int dir = 0;
    for(int i = 1; i <= MAX; i++) {
        mas[y][x] = i;
        idx[i] = iP(y, x);
        x += dx[dir], y += dy[dir];
        if(!mas[y + dy[NEXT(dir + 1)]][x + dx[NEXT(dir + 1)]]) dir = NEXT(dir + 1);
    }
}

int M;
iP dp[MAX + 1];

iP rec(int now) {
    int x = idx[now].sc, y = idx[now].fr;
    if(mas[y][x] > M || !mas[y][x]) return iP(0, 0);
    if(dp[now].fr) return dp[now];
    iP ret = iP(0, 0);
    int dx[] = {-1, 0, 1}, dy[] = {1, 1 ,1};
    for(int i = 0; i < 3; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        ret = max(ret, rec(mas[ny][nx]));
    }
    if(!ret.sc && isP[mas[y][x]]) ret.sc = mas[y][x];
    return dp[now] = iP(ret.fr + isP[mas[y][x]], ret.sc);
}

int main() {

    makePrime();
    makeMap();

    int n;
    while(cin >> M >> n, M) {
        fill_n(dp, MAX + 1, iP(0, 0));
        iP ans = rec(n);
        cout << ans.fr << " " << ans.sc << endl;;
    }
}

Measured memory_bytes: 28072
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        System.out.println(N*M);
    }
}

Measured memory_bytes: 35704
import collections
import itertools

n, k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(2*k)]

sunuke_list = a[1::2]
sunuke_list2 = list(itertools.chain.from_iterable(sunuke_list))

ans = n - len(set(sunuke_list2))

print(ans)

Measured memory_bytes: 9448
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

g = Graph()
N,M = list(map(int, input().split()))
INF = 10**9+7
A = [[INF if i!=j else 0 for i in range(N)] for j in range(N)]
S=[]
E=[]
W=[]

for i in range(M):
    s,e,w=list(map(int,input().split()))
    g.add_edge(s-1, e-1, w)
    g.add_edge(e-1, s-1, w)
    S.append(s-1)
    E.append(e-1)
    W.append(w)

for i in range(N):
    d = Dijkstra(g, i)
    for j in range(i+1,N):
        dist = d.shortest_distance(j)
        A[i][j] = dist
        A[j][i] = dist
        
ans=M
for i in range(M):
    shortest = False
    for j in range(N):
        if A[j][S[i]] + W[i] == A[j][E[i]]:
            shortest = True
    if shortest:
        ans-=1

print(ans)

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

using namespace std;

int main()
{
  long long a,b,c,k;
  
  cin>>a>>b>>c>>k;
  if(k<a) cout<<k;
 else if(k<=a+b) cout<<a;
  
  else {
         cout<<2*a+b-k;}
  
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


ll calcSum(string s)
{
	string tmp;
	ll ret = 0;

	REP(i, SZ(s))
	{
		if (s[i] == '+')
		{
			ret += stoll(tmp);
			tmp.clear();
		}
		else
		{
			tmp.PB(s[i]);
		}
	}

	ret += stoll(tmp);

	return ret;
}

int main()
{
	string s; cin >> s;
	int n = SZ(s);
	ll ans = 0;

	REP(mask, (1 << n - 1))
	{
		string tmp;
		REP(i, n - 1)
		{
			tmp.PB(s[i]);

			if (mask & (1 << i))
				tmp.PB('+');
		}
		tmp.PB(s.back());
		
		//cout << tmp << endl;

		ans += calcSum(tmp);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
/*
tx-sx = dxとか書く。
右にdx,上にdy、左にdx,下にdy,下に1,右にdx+1,上にdy+1,左に1,上に1,左にdx+1,下にdy+1,右に1
*/


int main() {
	int sx, sy, tx, ty, dx, dy;
	int i;

	scanf("%d %d %d %d", &sx, &sy, &tx,&ty);
	dx = tx - sx;
	dy = ty - sy;
	for (i = 0; i < dx; i++) {
		printf("R");
	}
	for (i = 0; i < dy; i++) {
		printf("U");
	}
	for (i = 0; i < dx; i++) {
		printf("L");
	}
	for (i = 0; i < dy+1; i++) {
		printf("D");
	}
	for (i = 0; i < dx+1; i++) {
		printf("R");
	}
	for (i = 0; i < dy+1; i++) {
		printf("U");
	}
	printf("LU");
	for (i = 0; i < dx + 1; i++) {
		printf("L");
	}
	for (i = 0; i < dy + 1; i++) {
		printf("D");
	}
	printf("R\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int mod = 1e9+7;

ll pow(ll a, ll n){
    if(n == 0)  return 1;
    if(n%2 == 0){
        ll tmp = pow(a, n/2);
        return (tmp*tmp)%mod;
    }else{
        return (a*pow(a, n-1))%mod;
    }
}

int main(){
    int n;  cin>>n;
    ll ans = pow(10, n);
    (ans = ans + mod - pow(9, n)) %= mod;
    (ans = ans + mod - pow(9, n)) %= mod;
    (ans += pow(8, n)) %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  string s,t,ans="zero";
  cin>>s>>t;
  int x,y;
  if(s.size()>t.size())
    cout<<"GREATER"<<endl;
  else if(s.size()<t.size())
    cout<<"LESS"<<endl;
  else{
    for(int i=0;i<s.size();i++){
      x=s[i]-'0';
      y=t[i]-'0';
      if(x>y){
        ans="ss";
        break;
      }
      else if(x<y){
        ans="tt";
        break;
      }
    }
    if(ans=="ss")
      cout<<"GREATER"<<endl;
    else if(ans=="tt")
      cout<<"LESS"<<endl;
    else if(ans=="zero")
      cout<<"EQUAL"<<endl;
  }
}

Measured memory_bytes: 256
// considering rotation of string T instead of S


#include <bits/stdc++.h>

#define int long long
#define inf  1000000007
#define pb push_back
  using namespace std;

string s,t;
int ls,lt;
int I,E,S,R;
int dp[110][110];

int ch(int k){
	
	for(int i=0;i<=ls;i++)for(int j=0;j<=lt;j++)dp[i][j]=inf*10000000ll;
	string tt=t.substr(lt-k)+t.substr(0,lt-k);
	dp[0][0]=0;
	for(int i=0;i<=ls;i++)for(int j=0;j<=lt;j++){
		if(i){
			dp[i][j]=min(dp[i][j],dp[i-1][j]+E);	
		}
		if(j){
			if(j<=k)dp[i][j]=min(dp[i][j],dp[i][j-1]+I-R);
			else dp[i][j]=min(dp[i][j],dp[i][j-1]+I);
				
		}
		if(i>0 && j>0){
			if(s[i-1]!=tt[j-1]){
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]+S);
			}
			else{
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
			}
		}
	}

	return dp[ls][lt] + k*R;
}

int solve(){
	
	cin>>s;
	if(s=="#") exit(0);
	cin>>t;
	

	cin>>I>>E>>S>>R;
	
	ls=s.length(),lt=t.length();
	int ans=inf*100000000ll;
	for(int i=0;i<lt;i++){
		
		ans=min(ans,ch(i));
		
	}
	return ans;
	
	
}

 signed main(){
 	while(1)cout<<solve()<<endl;
 	return 0;

  }
  


Measured memory_bytes: 3240
#include<iostream>

using namespace std;

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

int main(){
    int n, x;
    cin >> n >> x;
    int l[n];
    rep(i, n) cin >> l[i];
    int ans = 1;
    int d = 0;
    rep(i, n){
        if (d + l[i] <= x) {
            d += l[i];
            ans++;
        }else{
            break;
        }
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
import math
n, h = map(int, input().split())

atk = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    atk.append((a, 0))
    atk.append((b, 1))

atk.sort(key=lambda x: x[0], reverse=True)

# 通常の思考回路だと初めに何度か切り付けてそのあとに投げつけるが、初めに投げておいて繰り返すという逆の視点を持つ
max_blade = 0
for blade in atk:
    if blade[1] == 0:
        max_blade = max(max_blade, blade[0])
        break
    else:
        h = max(0, h - blade[0])
        ans += 1
        if h <= 0:
            break

if (h <= 0):
    print(ans)
else:
    print(math.ceil(h / max_blade) + ans)


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

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

fn h_comb(n: i64, r: i64, bins: &Vec<Vec<i64>>) -> i64 {
    // nHr = n + r - 1Cr
    bins[(n + r - 1) as usize][r as usize]
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0], v[1]);
    let big_int = 1000_000_000 + 7;

    let bins = create_mod_bins(2 * n, big_int);

    for i in 1..k + 1 {
        if n - k < i - 1 {
            println!("0");
            continue;
        }
        let blue_pattern = bins[(k - 1) as usize][(i - 1) as usize];
        let red_pattern = bins[((n - k) - (i - 1) + i) as usize][(i) as usize];
        let ans = (blue_pattern * red_pattern) % big_int;
        // debug!(blue_pattern, red_pattern);
        println!("{}", ans);
    }
}

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

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

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

struct ModFactorial {
    fact: Vec<i64>,
}

// returns n! under mod m
impl ModFactorial {
    fn new(n: i64, m: i64) -> ModFactorial {
        let mut fact = vec![1; n as usize + 1];
        for i in 2..fact.len() {
            fact[i] = (i as i64 * fact[i - 1]) % m;
        }
        ModFactorial { fact: fact }
    }
}

// returns bin[i] = nCi under mod m
struct ModBinominal {
    bin: Vec<i64>,
}

impl ModBinominal {
    fn new(n: i64, m: i64, fact: &Vec<i64>, inv_fact: &Vec<i64>) -> ModBinominal {
        let mut bin = vec![1; n as usize + 1];
        if n == 0 {
            return ModBinominal { bin: bin };
        }
        for i in 1..n + 1 {
            let a2 = inv_fact[i as usize] % m;
            let a3 = inv_fact[(n - i) as usize] % m;
            bin[i as usize] = fact[n as usize] * ((a2 * a3) % m) % m;
        }
        ModBinominal { bin: bin }
    }
}

fn create_mod_bins(n: i64, big_int: i64) -> Vec<Vec<i64>> {
    // bins[n][i] = nCi
    let fact = ModFactorial::new(n, big_int).fact;
    let inv_fact = (0..fact.len())
        .map(|x| mod_inverse(fact[x as usize], big_int))
        .collect::<Vec<_>>();
    let mut bins = Vec::with_capacity(n as usize + 1);
    for i in 0..n + 1 {
        bins.push(ModBinominal::new(i, big_int, &fact, &inv_fact).bin);
    }
    bins
}


Measured memory_bytes: 84220
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        System.out.println(N * (N - 1) / 2 + M * (M - 1) / 2);
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
vector<int>e[400010];
int zj=0;
int dfs(int x,int pre){
	int m1=0,m2=0;
	for(auto i:e[x])if(i!=pre){
		int gg=dfs(i,x);
		if(gg>m1)m2=m1,m1=gg;
		else if(gg>m2)m2=gg;
	}
	zj=max(zj,m1+m2+1);
	return m1+1;
}
bool ans[400010];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,1);
	ans[1]=1;ans[2]=0;
	for(int i=3;i<=zj;i++)ans[i]=!(ans[i-1]&ans[i-2]);
	puts(ans[zj]==1?"First":"Second");
	return 0;
}


Measured memory_bytes: 28032
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using LL = long long;
using P = pair<int,int>;


int main(){
	int N;
	cin >> N;
	vector<LL> H(N);
	rep(i,N) cin >> H[i];
	int ans = 0;
	int tmp = 0;
	rep(i,N-1){
		if(H[i] >= H[i+1]) tmp++;
		else {
			
			tmp = 0;
		}ans = max(ans, tmp);
	}
	cout << ans << endl;
		

}














Measured memory_bytes: 4036
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0

for i in B:
    ans += bisect.bisect_left(A,i)*(N-bisect.bisect_right(C,i))
print(ans)

Measured memory_bytes: 23240
import itertools
from collections import defaultdict

N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[defaultdict(lambda: 0) for j in range(50*N+1)] for i in range(N+1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(50*N+1):
        for k, v in dp[i][j].items():
            dp[i+1][j][k] += v
        if j >= X[i]:
            for k, v in dp[i][j-X[i]].items():
                dp[i+1][j][k+1] += v

ans = 0
for j in range(1, N+1):
    ans += dp[N][j*A][j] 

print(ans)

Measured memory_bytes: 78576
N, x = map(int, input().split())
L = 2 * N - 1
if x == 1 or x == L:
  print('No')
else:
  print('Yes')
  P = [0] * L
  P[L // 2] = x - 1
  P[L // 2 - 1] = x
  P[L // 2 + 1] = x - 2
  for i in range(2, N):
    P[L // 2 - i] = (x - i - 1) % L
    P[L // 2 + i] = (x + i - 1) % L
  print('\n'.join([str(p + 1) for p in P]))

Measured memory_bytes: 25016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BComparingStrings solver = new BComparingStrings();
        solver.solve(1, in, out);
        out.close();
    }

    static class BComparingStrings {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();

            int digit = Math.min(a, b), rep = Math.max(a, b);

            StringBuilder answer = new StringBuilder();
            for (int i = 0; i < rep; i++) {
                answer.append(digit);
            }
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main()
{
   int n , k;
  	
  	cin >>  k >> n;
  
	k = k *500;
  if( k >= n ){
       cout << "Yes";
  }else{

      cout << "No";
  }
	
   
}

Measured memory_bytes: 256
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,l,r) for(int i=l;i>=r;--i)
#define clr(a,b) memset(a,b,sizeof(a))

inline ll ksm(ll a, ll b) {
	ll res(1);
	while (b) {
		if (b & 1) res *= a;
		a *= a;
		b >>= 1;
	}
	return res;
}
ll x;
ll a[100000][2];
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll cnt(0);

	a[0][0] = 0, a[0][1] = 0;
	for (int i = 1;; ++i) {
		ll k = ksm(i, 5);
	//	cout << k << "\n";
		if (k > 2e18) break;
		a[++cnt][0] = k, a[cnt][1] = i;
		a[++cnt][0] = -k, a[cnt][1] = -i;
	}
	//rep(i, 0, cnt) cout << a[i][1] << " " << a[i][0] << "\n";

	cin >> x;
	rep(i, 0, cnt) {
		ll k = a[i][0] - x;
		rep(j, 0, cnt) {
			if (a[j][0] == k) {
				cout << a[i][1] << " " << a[j][1] << "\n";
				return 0;
			}
		}

	}
	
	
	return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>


int main(){
	int a, b, k, i, aux;
	scanf("%i %i %i", &a, &b, &k);
	if(a>=b)
		i=a;
	else
		i=b;
	while(k>0){
		if((a%i==0)&&(b%i==0)){
			k--;
			aux=i;
		}
		i--;

	}
	printf("%i\n", aux);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	x := 0
	ans := 9999999999999
	for i := 0; i < n-1; i++ {
		x += a[i]
		y := sum - x
		if abs(x-y) < ans {
			ans = abs(x - y)
		}
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5376
// AtCoder NOMURA Programming Competition 2020 C
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_c
// Samuel Tang
// 2020.05.30

#include <cstdio>
#include <cstdlib>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#define N 111111
#define ll long long
#define md 1000000007
using namespace std;

int n;
ll a[N], b[N];

ll solve() {
  // b[i] = the maximum number of nodes that a[i] has
  memset(b, 0x3f, sizeof b);

  b[n] = a[n];
  for (int i = n; i > 0; i--)
    b[i-1] = b[i] + a[i-1];

  b[0] = 1;
  for (int i = 0; i < n; i++) {
    if (i == n-1 && b[i+1] > (b[i] - a[i]) * 2) return -1;
    b[i+1] = min((b[i] - a[i]) * 2, b[i+1]);
    if (b[i+1] <= 0) return -1;
  }

  ll ans = 0;
  for (int i = 0; i <= n; i++) ans += b[i];
  return ans;
}

int main(){
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) scanf("%lld", &a[i]);
  if (n == 0 && a[n] != 1)
    printf("-1\n");
  else
    printf("%lld\n", solve());
  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, s;
  cin >> n >> s;
  /*
   * if n == s then base must be n + 1
   * so that we can write n = n * (n + 1)^0 as dig must be < base always. 
   */
  if (n == s) {
    cout << (n + 1) << "\n";
    exit(0);
  }
  // b <= sqrt(n)
  for (long long b = 2; b * b <= n; b++) {
    long long digSum = 0, num = n;
    while (num >= b) {
      digSum += num % b;
      num /= b;
    }
    digSum += num;
    if (digSum == s) {
      cout << b << "\n";
      exit(0);
    }
  }
  // b > sqrt(n)
  auto ok = [](long long p, long long q, long long b) {
    return p >= 0 && p < b && q >= 0 && q < b;
  };
  long long ans = LONG_LONG_MAX;
  for (long long x = 1; x * x <= n - s; x++) {
    if ((n - s) % x == 0) {
      long long y = (n - s) / x;
      long long b = x + 1;
      long long p = (n - s) / x, q = s - p;
      if (ok(p, q, b)) ans = min(ans, b);
      b = y + 1;
      p = (n - s) / y;
      q = s - p;
      if (ok(p, q, b)) ans = min(ans, b);
    }
  }
  cout << ((ans == LONG_LONG_MAX) ? -1 : ans) << "\n"; 
  return 0;
}



Measured memory_bytes: 256
n,x,y = map(int,input().split())
ans = [0 for i in range(n)]

x-=1
y-=1
for i in range(n):
    if i <= x:
        for j in range(i+1,n):
            d = min(abs(j-i),abs(i-x)+1+abs(y-j))
            ans[d] += 1
    elif i < y:
        for j in range(i + 1, n):
            d = min(abs(j-i),abs(x-i)+1+abs(y-j))
            ans[d] += 1
    else:
        for j in range(i + 1, n):
            ans[abs(j-i)] += 1

for i in range(1,n):
    print(ans[i])


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] fs = new int[n][10];
        for(int i = 0; i < n; i++)
            for(int j = 0; j < 10; j++)
                fs[i][j] = sc.nextInt();

        int[][] ps = new int[n][11];
        for(int i = 0; i < n; i++)
            for(int j = 0; j < 11; j++)
                ps[i][j] = sc.nextInt();

        long max = Long.MIN_VALUE;
        //bit全探索
        for(int i = 1; i < (1 << 10); i++) {
            long profit = 0;
            //店の数ループ
            for(int j = 0; j < n; j++) {
                int cnt = 0;
                //各曜日・午前/午後 に営業しているか
                for(int k = 0; k < fs[j].length; k++)
                    //他店がやってるかつ自店もやってる
                    // （i >> k) -> 10ビットでｋ個目が1かどうか
                    // 例えば、月・午後の場合「0000000010」
                    if((fs[j][k] & (i >> k)) == 1) {
                        cnt++;
                    }
                profit += ps[j][cnt];
            }
            max = Math.max(max, profit);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 28064
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//


        signed main() {
           float a,b;
            cin>>a>>b;
            for(int i=1;i<=100000;i++){
                    if((int)(i*0.08)==a&&(int)(i*0.1)==b){
                            cout<<i;
                            return 0;
                    }
            }
            cout<<-1;

        
        
        


      }


        


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

vi nums;

void dfs(string n)
{
    //cout << n << endl;
    if(n.length() > 11) return;
    nums.push_back(stoll(n));
    if(n[n.length()-1] != '0') 
    {
        dfs(n+to_string(n[n.length()-1]-'0'-1));
    }
    dfs(n+n[n.length()-1]);
    if(n[n.length()-1] != '9') 
    {
        dfs(n+to_string(n[n.length()-1]-'0'+1));
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int K; cin >> K;
    REPS(i, 9) dfs(to_string(i));
    sort(ALL(nums));
    cout << nums[K-1] << endl;
}

Measured memory_bytes: 10604
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

Menu = [A,B,C,D,E]
ans = 0
mint = 9
maxt = 0

for i in Menu :
    ans += (i+9)//10
    maxt = max(i%10, maxt)
    if i%10 != 0 :
        mint = min(i%10, mint)

if maxt == 0 :
    ans = ans * 10
else :
    ans = ans * 10 - 10 + mint
print(ans)


Measured memory_bytes: 3064
// 6_abc144_f
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

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

    int a,b,x; cin >> a >> b  >> x;
    long double A,B,X;
    A=(long double)a;B=(long double)b;X=(long double)x;
    long double ans;
    if (2.0*X/(A*A)>B){
        ans = atanl(2.0*( B/A - X/(A*A*A)))*180.0/M_PI;
    }
    else{
        ans = 90.0 - atanl(2.0* X/(A*B*B) )*180.0/M_PI;
    }
    cout << setprecision(15) << ans  <<"\n";

    return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    x,y=map(int,readline().split())
    ans=0
    while x<=y:
        x*=2
        ans+=1
    print(ans)

if __name__=="__main__":
    main()

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

int main() {
  int n;
  cin >> n;
  int count[n + 1];
  int rank[n + 1];

  for (int i = 0; i < n + 1; i++) {
    count[i] = 0;
  }

  int game = n * (n - 1) / 2;
  for (int i = 0; i < game; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (c > d) {
      count[a] += 3;
    } else if (c < d) {
      count[b] += 3;
    } else {
      count[a]++;
      count[b]++;
    }
  }

  int r = 1;
  while (r <= n) {
    int maxi, maxip[n], maxinum;
    for (int i = 0; i < n; i++) {
      maxip[i] = 0;
    }
    maxi = count[1];
    maxip[0] = 1;
    maxinum = 1;
    for (int i = 2; i < n + 1; i++) {
      if (count[i] == maxi) {
	maxip[maxinum] = i;
	maxinum++;
      } else if (count[i] > maxi) {
	maxi = count[i];
	maxip[0] = i;
	for (int j = 1; j < n; j++) {
	  maxip[j] = 0;
	}
	maxinum = 1;
      }
    }

    for (int i = 0; i < maxinum; i++) {
      rank[maxip[i]] = r;
      count[maxip[i]] = 0;
    }
    r += maxinum;
  }

  for (int i = 1; i < n + 1; i++) {
    cout << rank[i] << endl;
  }

  return 0;
}

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

int main() {
 long long int a,b;
 cin >> a >> b;
 long long int sum = a*b;
 long long int count = sum/4;
 long long int pp = sum%4;
 if(a==1 || b==1){
     cout << 1 << endl;
     return 0;
 }
 if(pp%2==0){
    cout << (count*2)+(pp/2) << endl;
 }else if(pp%2!=0){
    cout << (count*2)+(pp/2)+1 << endl;
 }else{
     cout << (count*2) << endl;
 }
 return 0;
}


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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
	ll a,b;
	cin>>a>>b;
	ll l1 = (a*100+7)/8;
	ll l2 = (b*100+9)/10;
	ll ans = max(l1, l2);
	a++;
	b++;	
	l1 = (a*100)/8;
	l2 = (b*100)/10;
	if(ans < l1 and ans < l2){
		cout << ans << endl;
	}
	else{
		cout << -1 << endl;
	}
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} tree;
tree t[10000];

int gh(int);
int main(){
  int a,b,c,e,f,id,m;
  int dp = 0;
  int dg = 0;
  int hei = 0;

    scanf("%d",&a);

  for(b = 0; b < a; b++){
    t[b].parent = -1;
  }

  for(b = 0; b < a; b++){
    scanf("%d%d%d",&id,&e,&f);
    t[id].left = e;
    t[id].right = f;
    if(e != -1 && f != -1){
      t[e].parent = id;
      t[f].parent = id;
    }
    else if(e != -1 && f == -1){
      t[e].parent = id;
    }
    else if(e == -1 && f != -1){
      t[f].parent = id;
    }
  }


  for(b = 0; b < a; b++){
    printf("node %d: parent = %d, ",b,t[b].parent);
    if(t[b].parent == -1){
      printf("sibling = -1, ");
    }
    else if(t[t[b].parent].left == b){
      printf("sibling = %d, ",t[t[b].parent].right);
    }
    else{
      printf("sibling = %d, ",t[t[b].parent].left);
    }
    printf("degree = ");
    if(t[b].left != -1 && t[b].right != -1){
      printf("2, ");
    }
    else if(t[b].left == -1 && t[b].right == -1){
      printf("0, ");
    }
    else{
      printf("1, ");

    }
      m = b;
      while(t[m].parent != -1){
	dp++;
	m = t[m].parent;
      }

      printf("depth = %d, ",dp);
      dp = 0;

      /* if(t[b].left == 0 && t[b].right == 0 && t[b].parent == -1){
	printf(" root, []");
	return 0;
	}*/

      printf("height = ");
      hei = gh(b);
      printf("%d,",hei);


      if(t[b].parent == -1){
	printf(" root\n");
      }
      else if(t[b].left == -1 && t[b].right == -1){
	printf(" leaf\n");
      } 
      else{
	printf(" internal node\n");
      }
    }
    return 0;
  
}
   


int gh(int i){

  int n = 0, m = 0;
  if(t[i].left == -1 && t[i].right == -1){
    return 0;
  }

  if(t[i].left != -1){
    n = gh(t[i].left)+1;
  }
  if(t[i].right != -1){
    m = gh(t[i].right)+1;
  }
  if(n > m){
    return n;
  }
  else{
    return m;
      }
}



Measured memory_bytes: 2108
# C - Digits in Multiplication
N = int(input())

A = int(N**0.5)
# print(A)
ans = 1
for i in range(A,0,-1):
    if N % i == 0:
        tmp = N / i
        ans = len(str(int(tmp)))
        break
    else:
        pass

print(ans)

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,m;
    cin >> n >> m;
    vector<int> X(m),Y;

    for(auto &i: X)
        cin >> i;

    sort(X.begin(),X.end());

    FOR(i,1,m)
        Y.pb(X[i]-X[i-1]);

    sort(Y.begin(),Y.end());
    int res=0,cc=max(m-n,0);

    FOR(i,0,cc)
        res+=Y[i];

    cout << res << endl;

    return 0;
}




Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll deg10[20];

int main()
{
    ios_base::sync_with_stdio(false);

    deg10[0] = 1;
    for (int i = 1; i < 20; ++i)
        deg10[i] = 10 * deg10[i - 1];

    ll x;
    cin >> x;
    ll ans = 0, cur = 0;
    for (int i = 16; i >= 0; --i) {
        cur += x / deg10[i] % 10;
        if (x / deg10[i] % 10)
            ans = max<ll>(ans, cur + 9 * i - 1);
    }
    ans = max(ans, cur);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764