akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#define N 500005
#define rint register int
using namespace std;

int tot = 0, fir[N], nxt[N << 1], to[N << 1];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int n, inc[N], cntc, cir[N], val[N], use[N], pre[N];

inline void getcircle() {
    int x = 1;
    while (!inc[x]) inc[x] = 1, x = pre[x];
    memset(inc, 0, sizeof inc);
    while (!inc[x]) inc[cir[++cntc] = x] = 1, x = pre[x];
}

void getmex(int u) {
    for (rint i = fir[u]; i; i = nxt[i])
        if (!inc[to[i]])
            getmex(to[i]);
    for (rint i = fir[u]; i; i = nxt[i])
        if (!inc[to[i]])
            use[val[to[i]]] = 1;
    val[u] = 0;
    while (use[val[u]]) ++val[u];
    for (rint i = fir[u]; i; i = nxt[i])
        if (!inc[to[i]])
            use[val[to[i]]] = 0;
}

int main() {
    cin >> n;
    for (rint i = 1, u; i <= n; ++i)
        scanf("%d", pre + i), addEdge(pre[i], i);
    getcircle();
    int mx = 0, mn = n + 1;
    for (rint i = 1; i <= n; ++i) {
        if (!inc[i]) continue;
        getmex(i);
        mx = max(mx, val[i]);
        mn = min(mn, val[i]);
    }
    if (cntc % 2 && mx == mn) puts("IMPOSSIBLE");
    else puts("POSSIBLE");
    return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    priority_queue<int> q;
    
    vector<pii> v;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        a = m - a;
        v.eb(pii{a, b});
    }

    sort(all(v));
    
    // outp(v, n);
    
    ll ans = 0;
    
    for (int i = m - 1; i >= 0; --i) {
        while (SZ(v) && v[SZ(v) - 1].F == i) {
            q.push(v[SZ(v) - 1].S);
            v.erase(v.end() - 1);
            
        }
        if (SZ(q) == 0) continue;
        ans += q.top();
        q.pop();
    }
    
    out(ans);
}


Measured memory_bytes: 1908
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long cnt=0;
    for(int i=1;i<n;i++)
    {
      for(int j=1;j<n;j++)
      {
        if(i*j>=n)
        break;
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}

  

Measured memory_bytes: 36308
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class Weight>
struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

template <class Weight>
bool operator<(const Edge<Weight> &e, const Edge<Weight> &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? (e.src < f.src) : (e.dst < f.dst);
    }
};

template <class Weight>
using Edges=vector<Edge<Weight>>;
template <class Weight>
using Vertex=vector<Edge<Weight>>;

template <class Weight>
struct Graph: public vector<Vertex<Weight>> {
    Graph() {}
    Graph(size_t V): vector<Vertex<Weight>>(V) {}
    void join(size_t s, size_t d, Weight w=1) {
        (*this)[s].push_back(Edge<Weight>(s, d, w));
        (*this)[d].push_back(Edge<Weight>(d, s, w));
    }
    void connect(size_t s, size_t d, Weight w=1) {
        (*this)[s].push_back(Edge<Weight>(s, d, w));
    }
};

template <class Weight>
vector<Weight> shortest_distance(const Graph<Weight> &g, size_t s) {
    /* Dijkstra */
    size_t V=g.size();
    vector<Weight> d(V, INF); d[s]=0;

    lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
    while (!q.empty()) {
        pair<Weight, size_t> p=q.top(); q.pop();
        size_t v=p.second;
        if (d[v] < p.first) continue;

        for (const Edge<Weight> &e: g[v])
            if (d[e.dst] > d[v] + e.weight) {
                d[e.dst] = d[v] + e.weight;
                q.push(make_pair(d[e.dst], e.dst));
            }
    }
    return d;
}

int main() {
    size_t V, E, r;
    scanf("%zu %zu %zu", &V, &E, &r);

    Graph<Weight> g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        g.connect(s, t, d);
    }

    vector<Weight> d=shortest_distance(g, r);
    for (size_t i=0; i<V; ++i)
        if (d[i] < INF) {
            printf("%lld\n", d[i]);
        } else {
            printf("INF\n");
        }

    return 0;
}

Measured memory_bytes: 23024
s = list(input())
q = int(input())
for i in range(q):
    cmd = list(input().split())
    m = int(cmd[1])
    n = int(cmd[2])
    if cmd[0] == "print":
        for i in range(m, n + 1):
            print(s[i], end="")
        print()

    if cmd[0] == "reverse":
        half = int((n - m) / 2)
        while m <= half\
        or    m < n:
            t = s[m]
            s[m] = s[n]
            s[n] = t
            m += 1 
            n -= 1
    if cmd[0] == "replace":
        r = cmd[3]
        j = 0
        for i in range(m, n + 1):
            s[i] = r[j]
            j += 1

Measured memory_bytes: 7824
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,m,a,g;

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

int main(){
	scanf("%lld",&n);
	scanf("%lld",&m);
	for (int i=2;i<=n;i++)
	{
	  scanf("%lld",&a);
	  g=gcd(a,m);
	  m=m/g*a;
	}
	printf("%lld\n",m);
	return 0;
}

Measured memory_bytes: 128
s = raw_input()
if len(s) == 2:
    if s[0] == s[1]:
        print "1 2"
        exit()

for i in range(len(s)-2):
    if len(set(s[i:i+2])) == 1:
        print i+1, i+2
        break
    elif len(set(s[i:i+3])) == 2:
        print i+1, i+3
        break
else:
    print "-1 -1"


Measured memory_bytes: 5892
#include<iostream>
using namespace std;
int main (void)
{
  int n,i,j,k;
  string s;
  cin>>n>>s;
  if(n%2==0)
  {
     for(i=0;i<n/2;i++)
     {
       if(s[i]!=s[i+n/2])
       {
         cout<<"No";return 0;
       }
     }
     cout<<"Yes";
  }
  else{cout<<"No";}
}

Measured memory_bytes: 3564
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Highest3 h3 = new Highest3();
			for(int i=0;i<10;i++){
				int a=Integer.parseInt(sc.next());
				h3.renew(a);
			}
			for(int i=0;i<3;i++)System.out.println(h3.get(i));
		}
	}
}
class Highest3{
	private int[] height=new int[3];
	Highest3(){
		for(int i=0;i<3;i++)this.height[i]=0;
	}
	public void renew(int height){
		int[] h4= new int[4];
		for(int i=0;i<3;i++)h4[i]=this.height[i];
		h4[3]=height;
		Arrays.sort(h4);
		for(int i=0;i<3;i++)this.height[i]=h4[3-i];
	}
	public int get(int i){
		return this.height[i];
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> s;
  rep(i,n) s.insert(a[i]);
  if (n == s.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


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

    vector<LL> A(n);
    map<LL,LL> nums;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (nums.count(A[i])) {
            nums[A[i]]++;
        }else{
            nums[A[i]] = 1;
        }
    }

    LL total=0;
    for(map<LL,LL>::iterator i = nums.begin(); i != nums.end(); i++){
        // cout << i-> first << " " << i->second << endl;
        if (i->second - i->first < 0) {
            total += i->second;
        }else{
            total += i->second - i->first;
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int freq[MAX];
int cs[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    for(int i=1; i<n; i++)
    {
        if(s[i]=='C' && s[i-1]=='A' )
            freq[i]=1;
        cs[i]=cs[i-1]+freq[i];
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        int ans=cs[r]-cs[l-1];
        if(freq[l])
            ans--;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 4524
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nxy[0];
        var x = nxy[1] - 1;
        var y = nxy[2] - 1;
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                var dist = j - i;
                dist = Min(dist, Abs(i - x) + 1 + Abs(j - y));
                res[dist]++;
            }
        }

        Console.WriteLine(string.Join("\n", res.Skip(1)));
    }
}


Measured memory_bytes: 13472
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

#define SIZE 400000
#define SIZE0 200000
#define INF 1000000000

typedef long long ll;

struct Dinic{

  struct edge{
    int to, cap, rev;
    edge(int a, int b, int c): to(a), cap(b), rev(c){}
  };

  vector<vector<edge>>G;
  vector<int> level, itr;
  int MAX_V;

  Dinic(int max_v): G(max_v), MAX_V(max_v) {}

  int add_edge(int from, int to, int cap) {
    int id = G[from].size();

    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size() - 1));

    return id;
  }

  void bfs(int s) {
    queue<int> q;
    level.assign(MAX_V, -1);
    level[s] = 0;
    q.push(s);
    while(q.size()) {
      int v = q.front(); q.pop();
      for(edge e: G[v])
        {
          if(e.cap > 0 && level[e.to] < 0) {
            level[e.to] = level[v] + 1;
            q.push(e.to);
          }
        }
    }
  }

  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int &i = itr[v]; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }

    return 0;
  }

  int solve(int s, int t) {
    int flow = 0, f;

    while(1) {
      bfs(s);
      if(level[t] < 0) return flow;
      itr.assign(MAX_V, 0);
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
  }

};


struct UF{
  vector<int> data;
  UF(int s): data(s, -1) {}

  int root(int x) {
    if(data[x] < 0) return x;
    return data[x] = root(data[x]);
  }

  bool set(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  bool check(int x, int y) {
    return root(x) == root(y);
  }
};

int h[SIZE], w[SIZE];
int x[SIZE], y[SIZE];

int main() {
  int N, M;

  scanf("%d%d", &N, &M);

  int ans1 = 0, ans2 = 0;

  for(int i=0; i<1000; i++) h[i] = w[i] = -1;

  UF uf(M);

  for(int i=0; i<M; i++) {
    scanf("%d%d", x+i, y+i);
    x[i]--; y[i]--;

    if (h[y[i]] >= 0)
      ans1 += uf.set(h[y[i]], i);

    if (w[x[i]] >= 0)
      ans1 += uf.set(w[x[i]], i);

    h[y[i]] = i;
    w[x[i]] = i;
  }

  int K = 1000;

  Dinic dinic(K * 2 + M + 2);

  for(int i=0; i<M; i++) {
    dinic.add_edge(x[i], K*2 + i, 1);
    dinic.add_edge(K*2 + i, y[i] + K, 1);
  }

  for(int i=0; i<K; i++) {
    dinic.add_edge(K*2 + M, i, 1);
    dinic.add_edge(i + K, K*2 + M + 1, 1);
  }

  //cerr << dinic.solve(K*2+M, K*2+M+1) << endl;

  ans2 = M - dinic.solve(K*2+M, K*2+M+1);

  printf("%d %d\n", ans2, ans1);
}



Measured memory_bytes: 3452
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

bool isprime(ll n)
{
	if (n == 1)
	{
		return false;
	}
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

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

	ll n;
	cin >> n;
	map<ll, ll>mp;
	vector<ll>v;
	for (ll i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			if (i * i == n)
			{
				v.pb(i);
			}
			else
			{
				v.pb(i);
				v.pb(n / i);
			}
		}
	}
	for (auto x : v)
	{
		if (isprime(x))
		{
			ll temp = n;
			while (temp % x == 0)
			{
				mp[x]++;
				temp /= x;
			}
		}
	}
	if (isprime(n))
	{
		mp[n]++;
	}
	ll ans = 0;
	for (auto x : mp)
	{
		ans += (-1 + sqrt(1 + 8 * (x.se))) / 2;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3628
import sys

# N: コマ数
# M: 地点数

N,M,*X = map(int, open(0).read().split())

# コマ数が地点数以上の場合、各地点にコマを配置できる
# よって 0 回の移動で目的を達成できる
if N >= M:
    print(0)
    sys.exit()

X.sort()
D = sorted([abs(X[i+1] - X[i]) for i in range(M-1)], reverse=True)
print(X[-1] - X[0] - sum(D[:N-1]))

Measured memory_bytes: 20196
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string cf = "CF";
	int index = 0;
	string buff;
	bool success = false;
	getline(cin, buff);
	for (int i = 0; i < buff.length(); ++i) {
		if(buff[i] == cf[index]){
          ++index;
          if(index >= cf.length()){
            success = true;
            break;
          }
        }
	}
	cout << (success ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.io.InputStream

val input = FastScanner()

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val a = Array<Pair<Int, Int>>(n) { nextInt() to nextInt() }

    val xi = a.indices.sortedBy { a[it].first }
    val yi = a.indices.sortedBy { a[it].second }

    val edges = mutableListOf<Pair<Int, Int>>()

    (1 until n).forEach { edges += xi[it - 1] to xi[it] }
    (1 until n).forEach { edges += yi[it - 1] to yi[it] }

    fun Pair<Int, Int>.dist(): Int {
        val (x1, y1) = a[first]
        val (x2, y2) = a[second]
        return Math.min(Math.abs(x1 - x2), Math.abs(y1 - y2))
    }

    edges.sortBy { it.dist() }

    val ds = UnionFind(n)

    var ans = 0L

    edges.forEach {
        val (s, t) = it
        if (ds.find(s) != ds.find(t)) {
            ans += it.dist()
            ds.union(s, t)
        }
    }

    println(ans)
}

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

class UnionFind(size: Int) {
    private val parent: IntArray = IntArray(size) { it }
    private val rank = IntArray(size)

    fun find(u: Int): Int {
        if (parent[u] != u) {
            parent[u] = find(parent[u])
        }
        return parent[u]
    }

    fun union(u: Int, v: Int): Int {
        val uRoot = find(u)
        val vRoot = find(v)
        if (uRoot == vRoot) {
            return uRoot
        }
        if (rank[uRoot] == rank[vRoot]) {
            rank[uRoot]++
        }
        return if (rank[uRoot] < rank[vRoot]) {
            parent[uRoot] = vRoot
            vRoot
        } else {
            parent[vRoot] = uRoot
            uRoot
        }
    }
}

Measured memory_bytes: 129288
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int,n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)

		as[i] = a
	}

	sort.IntSlice(as).Sort()

	fmt.Println(int(math.Abs(float64(as[0] - as[len(as)-1]))))
}

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

using ll = long long;

const int MAXN = 1.1e5;
int N;
ll L[MAXN], R[MAXN];


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
	}

	ll cost = 0;

	ll lo_shift = 0;
	priority_queue<ll> lo;
	ll hi_shift = 0;
	priority_queue<ll, vector<ll>, greater<ll>> hi;
	lo.push(L[0] - lo_shift);
	hi.push(L[0] - hi_shift);

	for (int i = 1; i < N; i++) {
		lo_shift -= (R[i] - L[i]);
		hi_shift += (R[i-1] - L[i-1]);

		ll vlo = lo.top() + lo_shift;
		ll vhi = hi.top() + hi_shift;
		if(vlo <= L[i] && L[i] <= vhi) {
			lo.push(L[i] - lo_shift);
			hi.push(L[i] - hi_shift);
		} else if (vhi < L[i]) {
			cost += L[i] - vhi;
			hi.pop();
			lo.push(vhi - lo_shift);
			hi.push(L[i] - hi_shift);
			hi.push(L[i] - hi_shift);
		} else if (L[i] < vlo) {
			cost += vlo - L[i];
			lo.pop();
			hi.push(vlo - hi_shift);
			lo.push(L[i] - lo_shift);
			lo.push(L[i] - lo_shift);
		} else assert(false);
	}

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


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  vector <ll> a;
  vector <ll> b;
  REP(i,10){
    ll c;
    cin >> c;
    a.pb(c);
  }
  REP(i,10){
    ll c;
    cin >> c;
    b.pb(c);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll sum = 0;
  ll s = 0;
  for(int i = b.size()-1;i > b.size()-4;i--){
    sum += a[i];
    s += b[i];
  }
  cout << sum << " " << s << endl;
  
}

Measured memory_bytes: 3156
import sys
from operator import itemgetter

n, *xd = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
xd = sorted(zip(xd[0::2], xd[1::2]))
xxx = list(map(itemgetter(0), xd)) + [10 ** 10]
ans = [0] * n + [1]
stack = [n]

for i in range(n - 1, -1, -1):
    x, d = xd[i]
    r = x + d
    while r > xxx[stack[-1]]:
        stack.pop()
    ans[i] = (ans[i + 1] + ans[stack[-1]]) % MOD
    stack.append(i)
print(ans[0])


Measured memory_bytes: 45432
#include <iostream>
#include <algorithm>

using namespace std;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int x[1000],y[1000];

int main(){
  int n,p,d;


  while(1){
    cin >> n;

    if(n == 0)break;

    int mN,mS,mE,mW;
    mN = mS = mE = mW = 0; 
    x[0] = y[0] = 0;
    for(int i = 1; i < n ; i++ ){
      cin >> p >> d;

      x[i] = x[p] + dx[d];
      y[i] = y[p] + dy[d];

      mN = min(mN,y[i]);
      mS = max(mS,y[i]);
      mE = max(mE,x[i]);
      mW = min(mW,x[i]);
      //     cout << "y[i] "<< y[i]<<endl; 
      //      cout << "mN "<< mN<<"　" <<"mS "<<mS<<endl; 
      //      cout << "mN-mS "<< mN-mS<<endl; 
    }

    cout << mE - mW + 1 << " ";
    cout << mS - mN + 1 << endl;


  }


}

Measured memory_bytes: 1164
let range a b = 
    let rec range' i j xs =
        if i > j then xs
        else range' i (j - 1) (j :: xs) in
    range' a b [];;

let (a, b, c) = Scanf.sscanf(read_line()) "%d %d %d" (fun x y z -> (x, y, z)) in
Printf.printf "%d\n" (range a b |> List.filter (fun x -> c mod x = 0) |> List.length);


Measured memory_bytes: 2612
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_PRM_MAX		200000									// 最大素数リスト数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Prm[D_PRM_MAX];									// 素数リスト
static char sc1PWork[D_PRM_MAX + 5];							// 素数リスト作成用ワーク
static int siPCnt;												// 素数リスト数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 素数リスト - 作成 - エラトステネスの篩
int
fMakePrm(
	int piMax					// <I> 最大値
)
{
	// 初期化
	siPCnt = 0;
	memset(sc1PWork, D_OFF, sizeof(sc1PWork));

	// 開始値
	int liNow = 2;

	// 上限値
	int liLimit = (int)sqrt((double)piMax);

	// 作成 - 開始
	while (1) {

		// 素数の検索
		while (sc1PWork[liNow] != D_OFF) {
			liNow++;
		}

		// 上限チェック
		if (liNow > liLimit) {
			break;
		}

		// 素数リスト - 追加
		si1Prm[siPCnt] = liNow;
		siPCnt++;

		// ワークに素数以外をセット
		int liVal = liNow;
		while (liVal <= piMax) {
			sc1PWork[liVal] = D_ON;
			liVal += liNow;
		}
	}

	// 残った素数を追加
	while (liNow <= piMax) {
		if (sc1PWork[liNow] == D_OFF) {
			si1Prm[siPCnt] = liNow;
			siPCnt++;
		}
		liNow++;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// X - 取得
	int liX;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liX);

	// 素数リスト - 作成
	fMakePrm(liX * 2);

	// 素数 - 取得
	for (i = 0; i < siPCnt; i++) {
		if (si1Prm[i] >= liX) {
			return si1Prm[i];
		}
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
int dp[3000003][3],sum[3000003][3];
int main()
{
  int t;
  cin>>t;
  double sum=0;
  for(int i=1;i<=t;i++)
  {
      double x;
      cin>>x;
      sum+=1.0/x;
  }
  printf("%.6f\n",1.0/sum);
return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main() {
    int A, B, K;
    scanf("%d%d%d", &A, &B, &K);
    int i;
    for(i = A; i < A + K; ++i) {
        if(B < i) return 0;
        printf("%d\n", i);
    }
    if(i <= B-K) i = B - K + 1;
    for(; i <= B; ++i) {
        printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
#define endl '\n'

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

    ll money = 1000;
    for (int start = 0 ; start+ 1 < n ; start++){
        ll end = start+1;
        if (a[start] >= a[end]) continue;
        ll buy = money/a[start];
        money %= a[start];
        money += (a[end])*buy;
    }
    cout << money << endl;
}


int main(){

    #ifndef ONLINE_JUDGE 
  
    // For getting input from input.txt file 
    freopen("input.txt", "r", stdin); 
  
    // Printing the Output to output.txt file 
    freopen("output.txt", "w", stdout); 
  
    #endif 

    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 

    int t = 1;
    // cin >> t;
    
    while(t--){
        solve();
        // cout << "Case #" << (tt+1) <<":" << endl;
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<tuple>
#include<map>
#define DB double
#define LL long long
#define PP std::pair<DB,DB>
#define MPP std::make_pair
#define TT std::tuple<int,int,int>
#define INF (100000000000000000)
struct edge {
	int from, to, cost;
};
LL D[1010];
int N, M;
edge es[2010];
bool negative[1010];

void negative_loop() {
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < M; j++) {
			edge e = es[j];
			if (D[e.from] != INF&& D[e.to] > D[e.from] + e.cost) {
				D[e.to] = D[e.from] + e.cost;
				negative[e.to] = true;
			}
			if (negative[e.from])negative[e.to] = true;
		}
	}
}


void short_path(int s) {
	for (int i = 1; i <= N; i++) {
		D[i] = INF;
	}
	D[s] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < M; j++) {
			edge e = es[j];
			if (D[e.from] != INF&&D[e.to] > D[e.from] + e.cost) {
				D[e.to] = D[e.from] + e.cost;
			}
		}
	}
}

int main() {
	std::cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		es[i] = { a,b,-c };
	}
	short_path(1);
	LL ans = -D[N];
	negative_loop();
	if (negative[N]) {
		std::cout << "inf" << std::endl;
		return 0;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
sub max {
    my ($x, $y) = @_;
    return $x if $x > $y;
    return $y;
}

my ($n, $c) = split(/[\s\n\r]+/, <STDIN>);
my @x, @v, @left, @right;

$x[0] = $v[0] = 0;
$x[$n+1] = $v[$n+1] = 0;
$right3[0] = $left3[0] = 0;
$right3[$n+1] = $left3[$n+1] = 0;

for (1..$n) {
    ($x[$_], $v[$_]) = split(/[\s\n\r]+/, <STDIN>);
}

for (1..$n) {
    $left[$_] = $left[$_-1] + $v[$_];
    $left2[$_] = $left[$_] - $x[$_] * 2;
    $left3[$_] = max($left3[$_-1], $left2[$_]);
}
for (reverse(1..$n)) {
    $right[$_] = $right[$_+1] + $v[$_];
    $right2[$_] = $right[$_] - ($c-$x[$_]) * 2;
    $right3[$_] = max($right3[$_+1], $right2[$_]);
}

#print join(" ", @x), "\n";
#print join(" ", @v), "\n";
#print join(" ", @left), "\n";
#print join(" ", @left2), "\n";
#print join(" ", @left3), "\n";
#print "\n";
#print join(" ", @right), "\n";
#print join(" ", @right2), "\n";
#print join(" ", @right3), "\n";

my $this = 0;
my $max = 0;
my $last_pos = 0;

sub add_max {
    my ($this) = @_;
    $max = $this if $max < $this;
}

for my $i (1..$n) {
    $this = $left[$i] - $x[$i];
    add_max($this);
    add_max($this + $right3[$i+1]);
}

for my $i (reverse(1..$n)) {
    $this = $right[$i] - ($c-$x[$i]);
    add_max($this);
    add_max($this + $left3[$i-1]);
}

print $max, "\n";


Measured memory_bytes: 52356
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void  tlow(char *c)
{
	int i=0;
	while(c[i]!='\0')
	{
		if(isupper(c[i]))
			c[i] = tolower(c[i]);
		i++;
	}
	
}

int main(void)
{
	char search[11],source[1001];
	int cnt;
	
	scanf("%s",search);
	
	tlow(search);
	
	while(1)
	{
		scanf("%s",source);
		if(strcmp(source,"END_OF_TEXT")==0)
			break;
		
		tlow(source);
		if(strcmp(search,source)==0)
			cnt++;
		
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int N;
int A, B, C;
vector<int> l;
int dfs(int cur, int a, int b, int c)
{
    if (cur == N)
    {
        return min({a, b, c}) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
    }
    else
    {
        int res0 = dfs(cur + 1, a, b, c);
        int res1 = dfs(cur + 1, a + l[cur], b, c) + 10;
        int res2 = dfs(cur + 1, a, b + l[cur], c) + 10;
        int res3 = dfs(cur + 1, a, b, c + l[cur]) + 10; //最初虚無からマージしてもコストが発生。
        return min({res0, res1, res2, res3});
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> A >> B >> C;
    l.resize(N);
    //    cout << l.size() << endl;
    REP(i, N)
    {
        cin >> l.at(i);
    }
    cout << dfs(0, 0, 0, 0) << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var gred = Input.gred(num);
        var res = 0;
        for(var i = 0; i < num; i++)
        {
            var g = Enumerable.Repeat(0, num).Select(_ => new char[num]).ToArray();
            for (var j = 0; j < num; j++)
                for (var k = 0; k < num; k++)
                    g[j][k] = gred[j][(k + i) % num];
            var q = true;
            for (var j = 1; j < num; j++)
                for (var k = 0; k < j; k++)
                    q &= g[j][k] == g[k][j];
            if (q) res += num;
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  string A, B, C;
  IN(N, A, B, C);
  i64 res = 0;
  rep(i, N) {
    char a = A[i], b = B[i], c = C[i];
    if (a != b && a != c && b != c) res += 2;
    else if (a != b || a != c || b != c) res++;
  }
  OUTL(res);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000];
  rep(i,n) cin>>a[i];
  int ans=a[0];
  rep(i,n){
    ans=gcd(ans,a[i]);
  }
  cout<<ans<<endl;

  return 0;
}


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

int main()
{
	int a, b;
	string str;
	cin >> a >> b;
	cin >> str;
	
	bool isOK = true;
	
	for (int i = 0; i < a + b + 1; i++)
	{
		if ( i == a  )
		{
			if ( str[i] != '-' ) isOK = false;
		}
		else
		{
			if ( !('0' <= str[i] && str[i] <= '9') ) isOK = false;
		}
	}
	
	cout << (isOK ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}
const int MOD = int( 1e9 ) + 7;
const int N = int( 1e5 ) + 42;

void __answer()
{
    int x;
    cin >> x;
    int ans = 0;
    for(int i = 1; i < 1000; i++) {
        for(int j = 2; j < 12; j++) {
            int res = i;
            for(int k = 1; k < j && res <= x; k++) res *= i;
            if(res <= x) ans = max(ans, res);
            else break;
        }
    }
    cout << ans;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(1) << fixed;
    #ifdef LOCAL
        freopen("TEST2.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
const int INF = 1e9;
using namespace std;

int main(void) {
    int H,W;cin>>H>>W;
    int HW[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin>>HW[i][j];
        }
    }
    int mi = INF;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            // 幹線道路ごとに処理
            int cur = 0;
            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    cur += min(abs(j - l), abs(i - k)) * HW[k][l];
                }
            }
            if (mi > cur) mi = cur;
        }
    }
    cout << mi << endl;
    return 0;
}


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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long s[4];
    s[0] = a * c;
    s[1] = a * d;
    s[2] = b * c;
    s[3] = b * d;
    long long ans;
    ans = max({s[0], s[1], s[2], s[3]});
    cout << ans << endl;
    return 0;
}

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


using namespace std;

typedef long long ll;


ll bigmod(string s,ll m)
{
    ll res = 0;
    ll z = s.size();
    for(ll i=0;i<z;i++)
    {
        res = (res*10 + s[i]-'0')%m;
    }
    return res%m;
}

int main(void)
{
   // ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);

   ll k;
   cin>>k;
   ll ans=-1;
   ll x=1;

   string s="7";
   ll res=0;
   for(int i=1;i<=1000000;i++)
   {
     res = (res*10 + 7)%k;
    if(res==0)
    {
     ans=i;
     break;
    }

   }
   cout<<ans<<endl;



}





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

int main(void){
    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    for(auto& x : v) cin >> x.first >> x.second;
    
    double len = 0.0;
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            double p = v[i].first-v[j].first;
            double q = v[i].second-v[j].second;
            len += sqrt(p*p+q*q);
        }
    }
    printf("%f\n", len*2/N);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979

int main(){
  double ans;
  int a, b, x;
  scanf("%d%d%d", &a, &b, &x);

  if (x<=a*a*b/2) {
    //    ans = atan(a*b*b/x/2.0);
    //ans = atan2(b, x*2.0/a/b);
    ans = atan(1.0*a*b*b/x/2);
  } else {
    //    ans = atan((x-a*a*b)*2.0/a/a);
    //    ans = atan2((x*1.0/a-a*b)*2.0/a, a);
    // ans = atan2((a*b-x*1.0/a)/a*2, a);
     ans = atan((a*b-x*1.0/a)/a*2/a);
  }
 
    ans = (ans*180)/M_PI;
    // ans = (ans*180)/PI;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 384
import sys  
import numpy as np

input = sys.stdin.readline
N = int(input())
S = list(input())

S = S[:-1]

temp = []
for i in range(1,N):
    a = S[:i]
    b = S[i:]
    a = list(set(a))
    b = list(set(b))

    j = list(set(a+b))
    
    temp.append(len(a) + len(b) - len(j))
    

print(max(temp))

Measured memory_bytes: 21292
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
//------------------------------>> coding space <<------------------------------//



int main() {
	int N;
	cin >> N;
	
	Vec< int > a(N);
	for_(i,0,N) cin >> a[i];
	
	map< int, int > cnt;
	for_(i,0,N) {
		++cnt[a[i]];
		++cnt[a[i]+1];
		++cnt[a[i]-1];
	}
	
	int ans = 0;
	for (auto p : cnt) maxUpdate(ans, p.second);
	cout << ans << endl;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int n,a[200010];
long long m;
inline int erfen(long long limit,int p)
{
	int l=1,r=n,ans=0;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(1LL*a[mid]*a[p]<=limit)ans=mid,l=mid+1;
		else r=mid-1;
	}return ans;
}
inline int fener(long long limit,int p)
{
	int l=1,r=n,ans=n+1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(1LL*a[mid]*a[p]<=limit)ans=mid,r=mid-1;
		else l=mid+1;
	}return ans;
}
inline bool check(long long limit)
{
	long long ans=0;limit--;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			if(limit>=0)ans+=n-1;
		}
		else
		{
			if(a[i]>0)
			{
				int p=erfen(limit,i);ans+=p;
				if(p>=i)ans--;
			}
			else
			{
				int p=fener(limit,i);ans+=n-p+1;
				if(p<=i)ans--;
			}
		}
	}ans>>=1;
	if(ans<m)return true;
	else return false;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    n=read();scanf("%lld",&m);
    for(int i=1;i<=n;i++)a[i]=read();
    sort(a+1,a+n+1);
    long long l=-1000000000000000000,r=-l,ans;
    while(l<=r)
    {
    	long long mid=l+r>>1;
    	if(check(mid)==true)ans=mid,l=mid+1;
    	else r=mid-1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using data_t = pair<ll, ll>;

ll N, T;
vector<data_t> data;

int main() {
    cin >> N;
    for (auto i = 0; i < N; i++) {
        ll a, b; cin >> a >> b;
        data.emplace_back(make_pair(a, b));
    }
    sort(data.begin(), data.end(), [](data_t a, data_t b) { return a.second < b.second; });
    T = 0;
    for (const auto& item : data) {
        T += item.first;
        if (T > item.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int flag=0;
	string s;
	cin >> s;
	for (int j = 0; j<3; j++)
	{
		if (s.at(j) == s.at(j+1)) flag++;
	}
	if (flag == 0) cout << "Good";
	else cout << "Bad";
}

Measured memory_bytes: 256
n=int(input())
C=[chr(i) for i in range(97,123)]
L=[50]*26
for i in range(n):
  a=input()
  for j in range(26):
    L[j]=min(L[j],list(a).count(C[j]))
for i in range(26):
  print(C[i]*L[i],end="")
print("\n",end="")

Measured memory_bytes: 3064
N = int(input())
B = list(map(int,input().split()))
B.insert(0,0)
A = []
while True:
    flag = 0
    for i in range(len(B)-1,0,-1):
        if B[i]==i:
            A.append(B.pop(i))
            flag = 1
            break
    if flag==0 and len(B)>1:break
    if len(B)==1:break
if len(B)>1:
    print(-1)
else:
    for _ in range(N):
        print(A.pop())

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

int main() {
  int N,Nc,i = 8,a[9],s = 0;cin >> N;
  Nc = N;

  while(i > 0){
    a[i] = N / std::pow(10,i-1);
    s += a[i];
    N -= a[i] * std::pow(10,i-1);
    i--;
  }

  if(Nc%s) cout <<"No";
  else cout <<"Yes";
}

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

int main ()
{
string S,T;
string A="CSR";
int tot=0;
cin>>S>>T;
if(S.length()==3&&T.length()==3){
    for(int i=0;i<3;i++){
        if(S[i]==T[i]&&(S[i]==A[0]||S[i]==A[1]||S[i]==A[2])&&(T[i]==A[0]||T[i]==A[1]||T[i]==A[2])){
            tot++;
        }
    }
    cout<<tot;   
}

return 0;
}

Measured memory_bytes: 3548
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
LL n,m;
int main()
{
    LL md=1e9+7;
scanf("%lld%lld",&n,&m);
if (abs(n-m)>=2) printf("0\n"); else
{
    LL ans=1;
    for (int i=1;i<=n;i++)
    ans=ans*(LL)i%md;
    if (m==n-1)
    {
        for (int i=1;i<=m;i++)
            ans=ans*(LL)i%md;
    } else
    if (m==n)
    {
        for (int i=2;i<=m;i++)
            ans=ans*(LL)i%md;
        ans=ans*2%md;
    } else
    if (m==n+1)
    {
        for (int i=1;i<=m;i++)
        ans=ans*(LL)i%md;
    }
    printf("%lld\n",ans);
}
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
#define MP make_pair
typedef long long int ll;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  
  rep(i,2){
    rep(j,2){
      rep(k,2){
        int a = ((i%2 == 0)?1:(-1));
        int b = ((j%2 == 0)?1:(-1));
        int c = ((k%2 == 0)?1:(-1));
        
        if((s[0]-'0') + a * (s[1]-'0') + b * (s[2]-'0') + c * (s[3]-'0') == 7){
          cout << s[0] << (a==1?'+':'-') << s[1] << (b==1?'+':'-') << s[2] << (c==1?'+':'-') << s[3] << "=7"<< endl;
          return 0;	
        }
      }
    }
  }

}



Measured memory_bytes: 256