akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


constexpr ll mod = 1e9 + 7;

ll powm(ll x, ll p) {
	if (p == 0) return 1;
	ll res = powm(x, p / 2);
	res *= res;
	res %= mod;
	if (p % 2LL == 1) {
		res *= x;
		res %= mod;
	}
	return res;
}

int main() {
	ll N, X; cin >> N >> X;
	vector<ll> s(N);
	for (int i = 0; i < N; i++) cin >> s[i];
	sort(s.rbegin(), s.rend());
	vector<vector<ll>> dp(N + 2, vector<ll>(X + 2));
	dp[0][X] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= X; j++) {
			dp[i + 1][j] += dp[i][j] * (N - i - 1) % mod;
			dp[i + 1][j] %= mod;
			dp[i + 1][j%s[i]] += dp[i][j];
			dp[i + 1][j%s[i]] %= mod;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= X; i++) ans += dp[N][i] * i % mod, ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 159360
import sys
sys.setrecursionlimit(10**7)

N = int(input())
h = list(map(int, input().split()))

cost = [0, abs(h[1]-h[0])]
def dp(i):
  if i >= len(cost):
    cost.append(min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2])))
  return cost[i]

print(dp(N-1))

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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair <int,int>
#define piii pair < pii, int>
#define pll pair <long long , long long>
#define plll pair <pll , long long>
#define y11 y1
typedef long long ll;

ll a,b,ans;

ll f(ll a,ll b)
{
	//cout << a << " " << b << endl;
	if(b>a)swap(a,b);
	if(b==0)return 0;
	//if(a==b)return a;
	if(a%b==0)return b+(a-b)*2;
	return a/b*2*b+f(a%b,b);
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> a >> b;
	ans=a;
	ans+=f(a-b,b);
	cout << ans;
	return 0;
}

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

int main(){
    int n; 
    string s;
    cin >> n;
    cin >> s;
    vector<int> rnum(n+1, 0);
    vector<int> gnum(n+1, 0);
    vector<int> bnum(n+1, 0);
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') rnum[i]++;
        if(s[i] == 'G') gnum[i]++;
        if(s[i] == 'B') bnum[i]++;
        rnum[i+1] = rnum[i];
        gnum[i+1] = gnum[i];
        bnum[i+1] = bnum[i];
    }

    long long int res = 0;
    for(int i = 0; i < n-2; i++){
    bool rf = false;
    bool gf = false;
    bool bf = false;
        switch(s[i]){
            case 'R': rf = true; break;
            case 'G': gf = true; break;
            case 'B': bf = true; break;
        }
        for(int j = i+1; j < n-1; j++){
            if(s[i] == s[j]) continue;
            switch(s[j]){
                case 'R': rf = true; break;
                case 'G': gf = true; break;
                case 'B': bf = true; break;
            }

            if(!rf){
                int conum = rnum[n-1] - rnum[j];
                if((2*j-i) >= 0 && (2*j-i) < n && s[2*j-i] == 'R') conum--;
                res += conum;
            }

            if(!gf){
                int conum = gnum[n-1] - gnum[j];
                if((2*j-i) >= 0 && (2*j-i) < n && s[2*j-i] == 'G') conum--;
                res += conum;
            }

            if(!bf){
                int conum = bnum[n-1] - bnum[j];
                if((2*j-i) >= 0 && (2*j-i) < n && s[2*j-i] == 'B') conum--;
                res += conum;
            }
            switch(s[j]){
                case 'R': rf = false; break;
                case 'G': gf = false; break;
                case 'B': bf = false; break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int MAX=1001;
int lcs(string X,string Y) 
{
	int i=0,j=0,c[MAX][MAX],x=X.length(),y=Y.length();
	for(i=0;i<=x;i++)c[i][0]=0;
	for(i=0;i<=y;i++)c[0][i]=0;
	for(i=1;i<=x;i++) 
	for(j=1;j<=y;j++) 
	if(X[i-1]==Y[j-1])c[i][j]=c[i-1][j-1]+1; 
	else if(c[i-1][j]>c[i][j-1])c[i][j]=c[i-1][j];
	else c[i][j]=c[i][j-1];
	return c[x][y];
}
int main()
{
	int n;cin>>n;
	string X,Y;
	while(n--)
	{
		cin>>X>>Y;
		cout<<lcs(X,Y)<<endl;
	}
}

Measured memory_bytes: 6940
N,M,P=map(int,input().split())
A=[0 for i in range(M)]
B=[0 for i in range(M)]
C=[0 for i in range(M)]
G=[dict() for i in range(N)]
H=[dict() for i in range(N)]
for i in range(M):
    A[i],B[i],C[i]=map(int,input().split())
    G[B[i]-1][A[i]-1]=C[i]
    H[A[i]-1][B[i]-1]=C[i]
reached1=[0 for i in range(N)]
q=[N-1]
while(len(q)>0):
    r=q.pop()
    reached1[r]=1
    for p in G[r]:
        if reached1[p]==0:
            q.append(p)
reached2=[0 for i in range(N)]
q=[0]
while(len(q)>0):
    r=q.pop()
    reached2[r]=1
    for p in H[r]:
        if reached2[p]==0:
            q.append(p)
reached=[reached1[i]*reached2[i] for i in range(N)]
vertex_list=[]
vertex_num=[-1 for i in range(N)]
tmp=1
for i in range(N):
    if reached[i]==1:
        vertex_list.append(i+1)
        vertex_num[i]=tmp
        tmp+=1
num_v=len(vertex_list)
edges=[]
for i in range(M):
    if reached[A[i]-1]==1 and reached[B[i]-1]==1:
        edges.append((vertex_num[A[i]-1],vertex_num[B[i]-1],P-C[i]))
inf=10**10
dist=[inf for i in range(num_v)]
dist[0]=0
#print(reached)
#print(edges)
#print(vertex_list)
#print(vertex_num)
#辺の緩和
for i in range(num_v):
    for edge in edges:
        if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
            dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
            if i==num_v-1:
                print(-1)
                exit()
print(max(-dist[-1],0))


Measured memory_bytes: 53228
import java.util.*;                                                                                  

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 3000; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int x = Integer.parseInt(l[0]);
          int y = Integer.parseInt(l[1]);

          if(x == 0 && y == 0) {
            break;
          }   

          if(x <= y) {
            System.out.println(x + " " + y); 
          } else {
            System.out.println(y + " " + x); 
          }   
        }   
    }   
}

Measured memory_bytes: 35244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << a * b / __gcd(a, b) << endl;
}		

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,a[4],b[4],c=0,d=0;
    for(i=0;i<4;i++){
        scanf("%d",&a[i]);
        c+=a[i];
    }
    for(i=0;i<4;i++){
        scanf("%d",&b[i]);
        d+=b[i];
    }
    if(c>d)printf("%d\n",c);
    else printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int abs(int x){
  return max(x,-x);
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int e[100001]={};
  int a[100001]={};
  int N;cin>>N;
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  int sum=abs(a[1])+abs(a[N]);
  for(int j=2;j<=N;j++){
    sum+=abs(a[j]-a[j-1]);
  }
  e[1]=abs(a[1])+abs(a[2]-a[1])-abs(a[2]);
  e[N]=abs(a[N]-a[N-1])+abs(a[N])-abs(a[N-1]);
  for(int k=2;k<=N-1;k++){
    e[k]=abs(a[k]-a[k-1])+abs(a[k+1]-a[k])-abs(a[k+1]-a[k-1]);
  }
  for(int g=1;g<=N;g++){
    P(sum-e[g]);
  }
  return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  if(a==b){
    cout << "=" << endl;
  }
  else if(a<b){
    cout << "<" << endl;
  }
  else{
    cout << ">" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stdlib.h>

using namespace std;


int main()
{
    int64_t a;
    cin>>a;
    int64_t sum=0;
    sum+=(1+a)*a/2;
    int64_t b=a/3;
    sum-=(3+3*b)*b/2;
     b=a/5;
    sum-=(5+5*b)*b/2;
     b=a/15;
    sum+=(15+15*b)*b/2;
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3636
import Data.Char
ctoi :: Char -> Int
ctoi x = ord x - ord '0'


dfs :: Int -> Int -> [Int] -> Int
dfs sum buff rest
    | length rest == 0 = sum + buff
    | otherwise = use + unuse
    where
        head' = head rest
        rest' = tail rest
        use = dfs (sum + buff) 0 rest'
        unuse = dfs sum (buff * 10 + head') rest'

main :: IO ()
main = do
    s <- getLine
    let n = map (ctoi) s
    print $ dfs 0 0 n

Measured memory_bytes: 380
#include <iostream>
using namespace std;
int main() {
	string S;
  	string T;
  
 	cin >> S;
  	cin >> T;
  
  	int max = S.length();
  	int count = 0;
  	for (auto i = 0; i < max ; ++i) {
      if (S[i] != T[i]) {
        count++;
      }
    }
  
  	cout << count << endl;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll t = x/d;
    if (k<=t) {
        cout << x-k*d << endl;
    } else {
        cout << abs(x-(t+(k-t)%2)*d) << endl;
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll x, y, z, K;
    scan(x, y, z, K);
    vector<ll> a(x), b(y), c(z);
    scan(a);
    scan(b);
    scan(c);
    vector<ll> v;
    REP(i, x) {
        REP(j, y) { v.emplace_back(a[i] + b[j]); }
    }
    RSORT(v);
    vector<ll> ans;
    RSORT(c);
    REP(i, min((ll)v.size(), K)) {
        REP(j, z) { ans.emplace_back(v[i] + c[j]); }
    }
    RSORT(ans);
    REP(i, K) print(ans[i]);

    return 0;
}

Measured memory_bytes: 43240
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
ll a,b,c,d,p[100000],q[100000],r[100000],i,j,k,n,f;
struct Node{
	ll x;
	ll y;
	ll r;
	vector<pair<Node*,double> > p;
	double co=-1;
};
int main(){
	Node no[1002];
	cin>>no[0].x>>no[0].y>>no[1].x>>no[1].y;
	no[0].r=no[1].r=0;
	no[0].co=0;
	cin>>a;
	for(i=2;i<a+2;i++)
		cin>>no[i].x>>no[i].y>>no[i].r;
	for(i=0;i<a+2;i++){
		for(j=0;j<a+2;j++){
			if(i==j)
				continue;
			double x=max(static_cast<double>(0),hypot(no[i].x-no[j].x,no[i].y-no[j].y)-static_cast<double>(no[i].r+no[j].r));
			no[i].p.push_back(make_pair(&no[j],x));
		}
	}
	queue<Node*> que;
	que.push(&no[0]);
	while(!que.empty()){
		auto x=que.front();
		que.pop();
		for(auto y:x->p){
			auto &z=y.first->co;
			if(z==-1||x->co+y.second<z){
				z=x->co+y.second;
				que.push(y.first);
			}
		}
	}
	cout<<fixed<<setprecision(11)<<no[1].co<<endl;
}


Measured memory_bytes: 18432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll ans = 1;
    for(int i = 1; i <= k; ++i){
         ans *= (n+1)-i;
         ans /= i;
    }
    return ans;
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	vector<ld> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ld>());
    ld sum =0;
    for(int i = 0; i < a; ++i){
    	sum+=v[i];
    }
    cout << fixed << setprecision(10) <<  sum/(ld)a << endl;
    ld last = v[a-1];
    int rem=0, c =0;
    for(int i = 0; i < n; ++i){
    	if(last==v[i]){
    	    ++c;
            if(c==1){rem=i;}
        }
    }
  
    ll ans = 0;
    if(rem!=0){
    	ans=COM(c, a-rem);
    }
    else{
    	for(int i = a; i <= b; ++i){
    	    ans+=COM(c, i);
        }
    }
    cout << ans << endl;
}

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

int main() {
    int A,B,H,M;
    cin >> A >> B >> H >> M;

    long double Hx,Hy;
    long double Mx,My;

    Hx=A*cos(2.0*M_PI*(long double)(H+M/60.0)/12.0);
    Hy=A*sin(2.0*M_PI*(long double)(H+M/60.0)/12.0);

    Mx=B*cos(2.0*M_PI*M/60.0);
    My=B*sin(2.0*M_PI*M/60.0);

    cout << setprecision(21) << sqrt((Hx-Mx)*(Hx-Mx)+(Hy-My)*(Hy-My)) << endl;

    return 0;
}



Measured memory_bytes: 4228
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << "{";
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i] << ",}"[i == vec.size() - 1];
  }
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << "{" << p.first << " " << p.second << "}";
}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

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

  string s; cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC_079_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            string a = N.Substring(0, 1);
            string b = N.Substring(1, 1);
            string c = N.Substring(2, 1);
            string d = N.Substring(3, 1);
            if (b == c)
            {
                if (a == b || c == d)
                {
                    Console.WriteLine("Yes");
                }
                else if (a != b && c != d)
                {
                    Console.WriteLine("No");
                }
            }
            else if (b != c)
            {
                Console.WriteLine("No");
            }
            Console.WriteLine();
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            Console.WriteLine(getAns(n));
        }
    }
    public static string getAns (int n)
    {
        var ret = 0;
        for (int i = 1; i <= n/2; i++)
        {
            if (n % i == 0) ret += i;
            if (ret > n) return "abundant number";
        }
        if (ret == n) return "perfect number";
        if (ret < n) return "deficient number";
        return "";
    }
}



Measured memory_bytes: 8816
tmp = (input())

A = int(tmp.split(" ")[0])
B = int(tmp.split(" ")[1])
C = int(tmp.split(" ")[2])
D = int(tmp.split(" ")[3])

Alice = {str(x): "A" for x in range(A, B + 1)}
Bob = {str(x): "A" for x in range(C, D + 1)}

cnt = 0

for k, v in Alice.items():
  if k in Bob:
    cnt += 1
    
if cnt -1 == -1:
  print(0)
else:
  print(cnt - 1)



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll h, w;
    cin >> h >> w;
    vll a(h), b(h);
    rep(i, h) cin >> a[i] >> b[i];
    set<pll> s;
    rep(i, w) s.emplace(i+1, i+1);  // (now, start)
    multiset<ll> ms;
    rep(i, w) ms.insert(0); // (now - start)
    rep(i, h) {
//        cout << "loop: " << i << endl;
        auto start = s.lower_bound(pll(a[i], 0));
//        cout << start->first << ' ' << start->second << endl;
        ll stmax = -1;
        for(auto it = start; it != s.end() && it->first <= b[i]; ) {
            chmax(stmax, it->second);
            ms.erase(ms.find(it->first - it->second));
            s.erase(it++);
        }
        if(stmax != -1 && b[i] < w) {
            s.emplace(b[i]+1, stmax);
            ms.insert(b[i]+1 - stmax);
        }
        /*
        for(auto it = s.begin(); it != s.end(); ++it) {
            cout << it->first << ' ' << it->second << endl;
        }
        */
        ll ans = -1;
        if(!ms.empty()) ans = *ms.begin() + i+1;
        cout << ans << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 28260
#include<stdio.h>
int main(void){
int x,a,b,y,z;
scanf("%d",&x);
scanf("%d",&a);
scanf("%d",&b);

y = b - a;
if (a >= b) {
printf("delicious\n");
} else if (y <= x) {
printf("safe\n");
}  else if (y > x) {
printf("dangerous\n");
}
return 0;
}


Measured memory_bytes: 128
import bisect
import queue

N,M=[int(a) for a in input().split()]
A=[int(a) for a in input().split()]

#優先度付きキューの作成とpush
q=queue.PriorityQueue()
for i in A:
    q.put(-i)

#最大値を取り出し,1/2倍した後push
for i in range(M):
    num = - q.get()
    #print(num)
    num=num//2
    q.put(-num)

total=0
for i in A:
    total+= - q.get()

print(total)

Measured memory_bytes: 15276
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll x[5];
  cin >> x[0] >> x[1] >> x[2] >>x[3] >> x[4];

  ll s=0;
  for(int i=0;i<5;i++){
    if(x[i]%10==0);
    else s=max(x[i]/10*10+10-x[i],s);
  }
  ll l=0;
  for(int i=0;i<5;i++){
    if(x[i]%10==0)l+=x[i];
    else l+=x[i]/10*10+10;
  }

  cout << l-s << endl;

  

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll unsigned long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,m;
ll up[2005][2005],dn[2005][2005],lf[2005][2005],rt[2005][2005];
char a[2005][2005];
int main()
{	
	IOS
	cin>>n>>m;
	ll i,j;
	for(i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(j=1;j<=m;j++)
			a[i][j]=s[j-1];
	}
	for(j=1;j<=m;j++)
	{
		ll cnt=0;
		for(i=1;i<=n;i++)
		{
			if(a[i][j]=='.')
				cnt++;
			else
				cnt=0;
			up[i][j]=cnt;
		}
		cnt=0;
		for(i=n;i>=1;i--)
		{
			if(a[i][j]=='.')
				cnt++;
			else
				cnt=0;
			dn[i][j]=cnt;
		}
	}
	for(i=1;i<=n;i++)
	{
		ll cnt=0;
		for(j=1;j<=m;j++)
		{
			if(a[i][j]=='.')
				cnt++;
			else
				cnt=0;
			lf[i][j]=cnt;
		}
		cnt=0;
		for(j=m;j>=1;j--)
		{
			if(a[i][j]=='.')
				cnt++;
			else
				cnt=0;
			rt[i][j]=cnt;
		}
	}
	ll maxi=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(a[i][j]=='.')
				maxi=max(maxi,up[i-1][j]+dn[i+1][j]+lf[i][j-1]+rt[i][j+1]+1);
	cout<<maxi;
	return 0;
}

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

#define ll long long
int n, m, x, ans=1e9, v[12], p;
vector<int> g[12];

int checkk() {
    int b[m]={}, res = 0;
    for(int i=0;i<n;i++) {
        if(v[i] != 0) {
            res += g[i][0];
            for(int j=1;j<m+1;j++)
                b[j-1] += g[i][j];
        }
    }

    for(int i=0;i<m;i++) {
        if(b[i] < x)
            return -1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m >> x;
    int t = (1<<n); t--;

    for(int i=0;i<n;i++) {
        for(int j=0;j<m+1;j++) {
            cin >> p;
            g[i].push_back(p);
        }
    }

    for(int i=0;i<=t;i++) {
        for(int j=0;j<12;j++) {
            int k = (1<<j) & i;
            if(k != 0) k=1; 
            v[j] = k;
        }
        int temp = checkk();
        if(temp != -1)
            ans = min(ans, temp);
    }
    if(ans == 1e9) cout << -1 << endl;
    else    cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    priority_queue<int, vector<int>, greater<int> >pq;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        pq.push(a[i]);
    }
    int ans = 0;
    int tmp = 0;
    int t = 0;
    while(!pq.empty()) {
        int p = pq.top(); pq.pop();
        if(p == 0) continue;
        tmp = p;
        p -= t;
        bool flag = true;
        bool f = true;
        for(int i = 0; i < n; ++i) {

            if(a[i] > 0) {
                a[i] -= p;
                flag = false;
                f = false;
            } else {
                if(!f) {
                    ans += p;
                    f = true;
        
                }
            }
        }
        if(!f) ans += p;
        if(flag) break;
        t = tmp;
    }
    cout << ans << endl;
    return 0;
}
    

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

int main(){
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    A--; B--; C--; D--;
    
    bool able = true;
    int swapable = 0;
    
    for(int i = A; i < min(C, D) - 1; i++){
        if(S[i] == '#' && S[i + 1] == '#')
            able = false;
        if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')
            swapable++;
    }
    
    /*
    cout << swapable;
    if(able) cout << "  true";
    cout << "\n";
    */
    for(int i = B; i >= 0; i--){
        if(S[i - 2] == '.' && S[i - 1] == '.')
            swapable--;
        else
            break;
    }
    //cout << swapable << "\n";
    
    if(D < C){
        if(S[D - 1] == '#' || S[D + 1] == '#')
            if(swapable <= 0)
                able = false;
    }
    
    //cout << swapable << "\n";
    
    for(int i = min(C, D) + 1; i < max(C, D); i++){
        if(S[i] == '#' && S[i + 1] == '#')
            able = false;
    }
    
    //cout << swapable << "\n";
    
    if(able)
        cout << "Yes" <<  "\n";
    else
        cout << "No" << "\n";
    return 0;
} 


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;

    for (int i = 0; i < s.size(); i++)
        cout << 'x';
    cout << endl;  

    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

static int n;
static int k;
static int w[100000];

static int check(int P)
{
    int i = 0;

    for (int j = 0; j < k; j++) {
        for (int s = 0; s + w[i] <= P;) {
            s += w[i];
            i++;
            if (i == n)
                return n;
        }
    }

    return i;
}

static int solve()
{
    int left = 0;
    int right = 100000 * 10000;

    while (right > left) {
        int mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }

    return right;
}

int main()
{
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++) {
        scanf("%d", &w[i]);
    }

    int ans = solve();
    printf("%d\n", ans);
}


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

using namespace std;

const int P = 998244353;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

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

	vector<long long> f(n);
	vector<bool> vis(n);

	long long cnt = 0;

	for(int i = 0; i < n; ++i) {
		dp[i + 1][0] = dp[i][0] * 2 % P;
		dp[i + 1][1] = dp[i][1];
		if(s[i] == '1') {
			dp[i + 1][0] = (dp[i + 1][0] + dp[i][1]) % P;
		}
	}

	for(int i = 0; i + i + i + 3 <= n; ++i) {
		if((n * 2) % (2 * i + 2) == 0 && ((n * 2) / (2 * i + 2)) % 2 == 1) {
			string tmp = "";
			string t = "";
			for(int j = 0; j <= i; ++j) {
				tmp += s[j];
			}
			for(int j = 0; j <= i; ++j) {
				if(s[j] == '0') {
					tmp += '1';
				} else {
					tmp += '0';
				}
			}
			for(int j = 0; j < n; ++j) {
				t += tmp[j % (i * 2 + 2)];
			}
			long long x = dp[i + 1][0] + (t <= s);
			f[i] = x % P;
			vis[i] = true;
		} 
	}

	for(int i = 1; i <= n; ++i) {
		if(vis[i - 1]) {
			for(int j = i + i; j <= n; j += i) {
				if(vis[j - 1]) {
					f[j - 1] = (f[j - 1] - f[i - 1] + P) % P;
				}
			}
		}
	}

	long long ans = 0;
	long long tot = (dp[n][0] + dp[n][1]) % P;
	for(int i = 0; i < n; ++i) {
		if(vis[i]) {
			tot = (tot - f[i] + P) % P;
		}
	}
	ans = (ans + tot * n * 2) % P;
	for(int i = 0; i < n; ++i) {
		if(vis[i]) {
			ans = (ans + f[i] * (i + 1) * 2) % P;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 16516
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <cstdio>
using namespace std;

int main() {
    const int m_max = 200000;
    const int q_max = 100000;

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

    alignas(32) short L[m_max], R[m_max];

    for (int i = 0; i < M; i++) {
        scanf("%hd%hd", &L[i], &R[i]);
    }

    int ans[q_max];
    alignas(32) short p[q_max], q[q_max];

    for (int i = 0; i < Q; i++) {
        ans[i] = 0;
    }

    for (int i = 0; i < Q; i++) {
        scanf("%hd%hd", &p[i], &q[i]);
    }

    const int Q1 = Q / 6 * 6;
  
    for (int i = 0; i < Q1; i += 6) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]);
            ans[i + 1] += (p[i + 1] <= L[j] & R[j] <= q[i + 1]);
            ans[i + 2] += (p[i + 2] <= L[j] & R[j] <= q[i + 2]);
            ans[i + 3] += (p[i + 3] <= L[j] & R[j] <= q[i + 3]);
            ans[i + 4] += (p[i + 4] <= L[j] & R[j] <= q[i + 4]);
            ans[i + 5] += (p[i + 5] <= L[j] & R[j] <= q[i + 5]);
        }
    }
  
    for (int i = Q1; i < Q; i++) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]); 
        }
    }

    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) {
    cout << "Left" << endl;
  } else if (a+b == c+d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
  return 0;
}


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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define ss second
#define ff first
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()

#ifndef ONLINE_JUDGE
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#else
#define trace(args...) { }
#endif

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

int main()
{
  IOS;
  int a, b, k;
  cin >> a >> b >> k;
  int c = 0;
  for(int i = max(a, b); i >= 1; i--){
    if(a % i == 0 && b % i == 0){
      c++;
      if(c == k){
        cout << i << '\n';
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(register int i=a;i<=b;i++)
#define dep(i,a,b) for(register int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
	ll f=1,x=0;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;
}
//**********head by yjjr**********
#define pb push_back
#define inf 1e9
const int maxn=66,maxm=1e6+6,dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},mod=1e9+7;
struct node{int x,y;}a[maxn<<1],que[maxn*maxn*4];
int n,m,K,ans,lx,ly,cnt[maxn][maxn],s1[maxm],s2[maxm],dis[maxn][maxn],head,tail;
bool fb[maxn][maxn],mark1[maxm],mark2[maxm];
vector<int>px,py;
void vnique(vector <int> &r){
	sort(r.begin(),r.end());
	auto t=unique(r.begin(),r.end());
	r.erase(t,r.end());
}
void bfs(int x,int y){
	rep(i,0,lx)rep(j,0,ly)dis[i][j]=inf;
	dis[x][y]=0;que[head=tail=1]=(node){x,y};
	while(head<=tail){
		int nx=que[head].x,ny=que[head++].y;
		rep(i,0,3){
			int nex=nx+dx[i],ney=ny+dy[i];
			if(nex>lx||nex<0||ney>ly||ney<0||dis[nex][ney]<=dis[nx][ny]+1||fb[nex][ney])continue;
			dis[nex][ney]=dis[nx][ny]+1;que[++tail]=(node){nex,ney};
		}
	}
}
int main() {
	n=read(),m=read(),K=read();
	px.pb(1);px.pb(n+1);py.pb(1);py.pb(m+1);
	rep(i,1,n)s1[i]=m;
	rep(i,1,m)s2[i]=n;
	rep(i,1,K){
		a[i].x=read()+1,a[i].y=read()+1;
		px.pb(a[i].x),px.pb(a[i].x+1);
		py.pb(a[i].y),py.pb(a[i].y+1);
		s1[a[i].x]--,mark1[a[i].x]=1;
		s2[a[i].y]--,mark2[a[i].y]=1;
	}
	rep(i,1,n)s1[i]=(s1[i]+s1[i-1])%mod;
	rep(i,1,m)s2[i]=(s2[i]+s2[i-1])%mod;
	rep(i,1,n-1)if(!mark1[i]&&!mark1[i+1])ans=(ans+1ll*2*s1[i]*(s1[n]-s1[i]))%mod;
	rep(i,1,m-1)if(!mark2[i]&&!mark2[i+1])ans=(ans+1ll*2*s2[i]*(s2[m]-s2[i]))%mod;
	vnique(px);vnique(py);lx=px.size()-2;ly=py.size()-2;
	rep(i,1,K)
		fb[lower_bound(px.begin(),px.end(),a[i].x)-px.begin()][lower_bound(py.begin(),py.end(),a[i].y)-py.begin()]=1;
	rep(i,0,lx)rep(j,0,ly)cnt[i][j]=1ll*(px[i+1]-px[i])*(py[j+1]-py[j])%mod;
	rep(i,0,lx)rep(j,0,ly)
		if(!fb[i][j]){
			bfs(i,j);
			rep(k,0,lx)rep(p,0,ly)
				if(!fb[k][p])ans=(ans+1ll*cnt[i][j]*dis[k][p]%mod*cnt[k][p])%mod; 
   		}
	ans=(ans+mod)%mod;ans=1ll*ans*(mod/2+1)%mod;
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

std::string s;
int n;
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> s;
    n = (int)s.size();

    int ans = n;
    bool before = false;
    for (int i = 1; i < n; ++i)
        if (!before && s[i - 1] == s[i])
        {
            before = true;
            ++i;
            --ans;
        }
        else
            before = false;

    std::cout << ans << std::endl;

    return 0;
}


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

int main()
{
	int a,b,aa,s=0;
	cin>>a>>b;
	aa=b;
	while (aa!=0){
		aa/=10;
		s++;
	}
	for (int i=1;i<=s;i++) a*=10;
	
	for (int i=1;i<=400;i++)
		if (i*i==a+b){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";	  
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a % b !=0);





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

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

    bool flag = true;

    for(int i = 0; i < N; i++)
    {
        if(A[i] % 2 == 0)
        {
            if(A[i] % 3 != 0 && A[i] % 5 != 0)
            {
                flag = false;
                break;
            }
        }
    }

    if(flag)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::f64::consts::PI;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<f64>();
    let b = read::<f64>();
    let mut x = read::<f64>();
    x /= a;
    let ans = if x < a * b / 2.0 {
        let c = x / b * 2.0;
        90.0 - c.atan2(b) / PI * 180.0
    } else {
        let c = (a * b - x) / a * 2.0;
        c.atan2(a) / PI * 180.0
    };
    println!("{:.8}", ans);
}


Measured memory_bytes: 2976
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


int main() {
	ll N, K;
	cin >> N >> K;
	vll a(N + 1);
	repn(i, N) cin >> a[i];

	vector<bool> dp(K + 1,0);
	repn(i, K) {
		repn(j, N) {
			if (i >= a[j]) { dp[i] = dp[i] | !dp[i - a[j]]; }
		}
	}

	if (dp[K]) { cout << "First" << endl; }
	else { cout << "Second" << endl; }
}

Measured memory_bytes: 3668
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	char c;
	rep(i,0,9){
		cin >> c;
		if( i == 0 || i == 4 || i == 8 )
			cout << c;
	}
	P("");
	ret 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

string s;

int main() {
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 256
n,l = map(int,input().split())

apples = [ i for i in range(l,n+l)]

min = 10000000

for apple in apples:
    if abs(apple) < min:
        min_index = apples.index(apple)
        min = abs(apple)
        
        
print(sum(apples)-apples[min_index])

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

template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}

const string akiba = "AKIHABARA";
vector<string> v;

vector<int> pos{0, 4, 6, 8};
void dfs(int i, string s) {
    if (i >= 4) { v.push_back(s); return;}
    string ns(s);
    ns[pos[i]] = ' ';
    dfs(i + 1, s);
    dfs(i + 1, ns);
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    dfs(0, akiba);
    vector<string> answers;
    for (string& s : v ) {
        string ns = "";
        for (int i = 0; i < s.length(); i++) {
            if (s[i] != ' ' ) ns.push_back(s[i]);
        }
        answers.push_back(ns);
    }
    string input;
    cin >> input;
    sort(answers.begin(), answers.end());
    bool find = binary_search(answers.begin(), answers.end(), input);
    cout << (find ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
def ascending_range(i):
    return (a+c*i, a+d*i)

def descendable_range(i, m, M):
    j = n-1-i
    floor = b+c*j
    ceil = b+d*j
    return not (m > ceil or M < floor)

def solve_local(i):
    return descendable_range(i, *ascending_range(i))

n, a, b, c, d = map(int, input().split())

print("YES" if any(solve_local(i) for i in range(n)) else "NO")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 標準入力より週数を取得
		Scanner stdId = new Scanner(System.in);
		int deptWeek = stdId.nextInt();

		// 借金
		int dept = 100000;

		// 借金の残高を出力
		System.out.println(String.valueOf(deptCalc(dept, deptWeek)));

	}

	// 借金(baseMoney)と経過した週数(deptweek)より現時点での借金残高を計算
	public static int deptCalc(int baseDept, int deptWeek) {

		// 変数宣言
		double dept = (double) baseDept; // 借金
		int ceilLength = 1000; // 切り上げ時の数値

		// n週分、借金に5%の利子を加算(1000円未満は切り上げとする)
		dept = dept / ceilLength;
		for (int i = 0; i < deptWeek; i++) {
			dept *= 1.05;
			dept = Math.ceil(dept);
		}
		dept *= ceilLength;

		return (int) dept;
	}

}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
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++)
typedef int64_t Int;


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

    if(N < 1000){
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(){
	double a[1010];
	double b[1010];
	int n;
	double m=0;
	double ans=0;
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf",&a[i]);
	}
	for(i=0;i<n;i++){
		scanf("%lf",&b[i]);
	}
	for(i=1;i<4;i++){
		m=0;
		for(j=0;j<n;j++){
			m+=pow(abs(a[j]-b[j]),i);
		}
		printf("%lf\n",pow(m,1.0/(double)i));
	}
	m=0;
	for(i=0;i<n;i++){
		m=fmax(m,abs(a[i]-b[i]));
	}
	printf("%lf\n",m);
	return 0;
}

Measured memory_bytes: 728
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

const int INF = 1e+9;
const int MAX_V = 40320;
struct edge{ int to, cost; };
typedef pair<int,int> P;

int n;
int c[10][10];
map<vector<int>,int> m;
int fact[9] = {1,1,2,6,24,120,720,5040,40320};

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill( d , d+V , INF );
	d[s] = 0;
	que.push( P(0,s) );
	
	while( !que.empty() ){
		P p = que.top(); que.pop();
		int v = p.second;
		if( d[v] < p.first ) continue;
		for(int i=0 ; i < G[v].size() ; i++ ){
			edge e = G[v][i];
			if( d[e.to] > d[v] + e.cost ){
				d[e.to] = d[v] + e.cost;
				que.push( P(d[e.to],e.to) );
			}
		}
	}
}

int main(){
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j < n ; j++ ){
			cin >> c[i][j];
		}
	}
	
	// m[hÍ n!
	V = fact[n];
	// {1, 2, ... , n}ÌñðÂ­é
	vector<int> p;
	for(int i=1 ; i <= n ; i++ ){
		p.push_back( i );
	}
	// CÓÌñ p É 0 ©ç (n!-1)ÌÔðUé
	int k = 0;
	do{
		m[p] = k;
		k++;
	}while( next_permutation(p.begin(),p.end()) );
	
	// CÓÌñ p ÉÂ¢ÄCÓÌi,j(0 <= i < j < n )ðð··éRXgc[i][j]ÅGbWÌRXgð£é
	do{
		for(int i=0 ; i < n ; i++ ){
			for(int j=i+1 ; j < n ; j++ ){
				int u = m[p];
				swap( p[i] , p[j] );
				int v = m[p];
				swap( p[i] , p[j] );
				
				edge e;
				e.to = v;
				e.cost = c[i][j];
				G[u].push_back( e );
				e.to = u;
				G[v].push_back( e );
			}
		}
	}while( next_permutation(p.begin(),p.end()) );
	
	// m[h0 ({1, 2, ... , n}) ©çÌÅZoH(f(p)É)ðßé
	dijkstra( 0 );
	// f(p)ÌÅålðßé
	int ans = 0;
	for(int i=1 ; i < V ; i++ ){
		ans = max( ans , d[i] );
	}
	cout << ans << endl;
}

Measured memory_bytes: 26000