akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	unionfind uni(n);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		uni.unite(u, v);
		uni.unite(v, u);
	}
	vector<vector<int>> vec(n, vector<int>());
	rep(i, n) vec[uni.find(i)].pb(a[i]);
	int s = 0;
	ll ans = 0;
	vector<ll> use;
	rep(i, n) {
		if (vec[i].size()) {
			sort(all(vec[i]));
			s++;
			ans += vec[i][0];
			for (int j = 1; j < vec[i].size(); j++) use.pb(vec[i][j]);
		}
	}
	if (s == 1) {
		cout << "0\n";
		return 0;
	}
	s -= 2;
	if (s > use.size()) {
		cout << "Impossible\n";
		return 0;
	}
	sort(all(use));
	rep(i, s) ans += use[i];
	cout << ans << '\n';
}

Measured memory_bytes: 10272
// B - Tag
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    long long d = abs(a-b);
    long long d2 = (v-w)*t;
    if(d <= d2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3600
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b

n = int(input())
X, Y = [], []
for _ in range(n):
    xi, yi = map(int, input().split())
    X.append(xi)
    Y.append(yi)
# print(X)
# print(Y)

if n == 1:
    print(1)
    exit()

# PQをバラすとだめ？
posPQ = []
score = int(1e18)
for i in range(n):
    xi, yi = X[i], Y[i]
    for j in range(n):
        if i == j:
            continue
        xj, yj = X[j], Y[j]
        p = xj - xi
        q = yj - yi

        # posPQ.append((dx, dy))
        count = n
        for k in range(n):
            for l in range(n):
                if X[l] - X[k] == p and Y[l] - Y[k] == q:
                    count -= 1
        # print(p, q, count)
        score = min(score, count)
print(score)

Measured memory_bytes: 42860
#include<stdio.h>
#define N 40
int n,ptw;
int a[N];
int b[N];
 
void solve(int,int);                \
 
int main(){
   
  int i;
  scanf("%d",&n);
  for(i = 0;i < n;i++)  scanf("%d",&a[i]);
  for(i = 0;i < n;i++)  scanf("%d",&b[i]);
  ptw = 0;
  solve(0,n-1);
  printf("\n");
  return 0;
}
 
 
 
void solve(int l,int r){
  
  int x = a[ptw],i;
      
  if(l > r)return;
 
  if(l == r){
    if(b[l] == a[0])printf("%d",b[l]); 
    else printf("%d ",b[l]);
    ptw++;
    return;
  } 
  ptw++;
 
  for(i = l;i <= r;i++) if(b[i] == x)break; 
   
  solve(l,i-1);
  solve(i+1,r);
    
  if(x == a[0])   printf("%d",x);
 
  else printf("%d ",x);
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n ;
    cin>> n ;
    string s1, s2 ;
    cin>> s1 >> s2 ;
    vi a ;
    int idx=0 ;
    while(idx<n)
      {
        if(s1[idx]!=s2[idx])
          {
            a.pb(2) ;
            idx+=2 ;
          }
        else
          {
            a.pb(1) ;
            idx++ ;
          }
      }
    vlli dp(60, 1) ;
    if(a[0]==1) dp[0]=3 ;
    else dp[0]=6 ;
    for(int i=1 ; i<a.size() ; i++)
      {
        if(a[i]==1)
          {
            if(a[i-1]==1)
              {
                dp[i]=2*dp[i-1] ;
                dp[i]=dp[i]%mod ;
              }
            else dp[i]=dp[i-1] ;
          }
        else
          {
            if(a[i-1]==1)
              {
                dp[i]=2*dp[i-1] ;
                dp[i]=dp[i]%mod ;
              }
            else
              {
                dp[i]=3*dp[i-1] ;
                dp[i]=dp[i]%mod ;
              }
          }
      }
    cout<< dp[a.size()-1] ;
  }


Measured memory_bytes: 256
from collections import Counter
R = lambda: map(int, input().split())
n, k = R()
a = list(R())
r = sum(k for i in range(n) for j in range(i) if a[i] < a[j])
r += k*(k-1)//2 * (n*(n-1)//2 - sum(x*(x-1)//2 for x in Counter(a).values()))
print(r % (10**9 + 7))


Measured memory_bytes: 3564
//
//  main.cpp
//  A
//
//  Created by Charles on 2017/9/23.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <cstring>
using namespace std;
char s[11];
int main(int argc, const char * argv[]) {
    while(~scanf("%s",s)){
        if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

int p[200010];

int main(){
  int N,K;
  cin >> N >> K;
  rep(i,N) cin >> p[i];
  double M=0;
  rep(i,K) M+=p[i];
 
  double pre = M;
  for(int i=0; i<N-K+1; i++){
    double now =  pre + p[i+K] - p[i];
    M = max(M,now);
    pre = now;
  }
  double ans = (M+K)/2;
  printf("%.10lf\n",ans);
  return 0;
}




Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

public class Program
{
    public static long ans = long.MaxValue;

    public static void Main() {
        Reader reader = new Reader(Console.In);
        long H = reader.RLong();
        long W = reader.Long();

        if (W > H) {
            long temp = H;
            H = W;
            W = temp;
        }

        CalcA(H, W);
        CalcA(W, H);
        CalcB(H, W);
        CalcB(W, H);

        Console.WriteLine((long)ans);
    }

    public static void CalcA(long H, long W) {
        for (long i = 1; i < H; i++) {
            long a = i * W;

            long bh = (H - i) / 2;
            long ch = H - i - bh;

            Diff(a, bh * W, ch * W);
            if (ans == 0) {
                return;
            }
        }
    }

    public static void CalcB(long H, long W) {
        for (int i = 1; i < H; i++) {
            long a = i * W;

            long bw = W / 2;
            long cw = W - bw;

            long b = (H - i) * bw;
            long c = (H - i) * cw;

            Diff(a, b, c);
            if (ans == 0) {
                return;
            }
        }
    }

    public static void Diff(long a, long b, long c) {
        var list = new List<long> { a, b, c };
        long diff = list.Max() - list.Min();

        if (diff < ans) {
            ans = diff;
        }
    }
}

public class Reader
{
    private readonly TextReader reader;
    private readonly char separator = ' ';
    private string[] A = new string[0];
    private int i;

    public Reader(TextReader r) { reader = r; }

    public string String() { return Set(); }
    public int Int() { return int.Parse(Set()); }
    public long Long() { return long.Parse(Set()); }
    public decimal Decimal() { return decimal.Parse(Set()); }

    public string RString() { return RSet(); }
    public int RInt() { return int.Parse(RSet()); }
    public long RLong() { return long.Parse(RSet()); }
    public decimal RDecimal() { return decimal.Parse(RSet()); }

    public int[] IntArray() { return A.Select(x => int.Parse(x)).ToArray(); }

    private void Read() {
        string line = reader.ReadLine();

        A = line.Split(separator);
        i = 0;
    }

    private string Set() { return A[i++]; }
    private string RSet() { Read(); return A[i++]; }
}

Measured memory_bytes: 17452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  cout << dup(n,2) << endl;
  return 0;
}

Measured memory_bytes: 764
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(-s[i][1] - s[i][0] <= s[i][2] <= -s[i][1] + s[i][0] and s[i][1] - s[i][0] <= s[i][2] <= s[i][1] + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(-s[i][1] + s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= -s[i][1] + s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])\
            and s[i][1] - s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i][1] - s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

ll solve(ll,ll);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>n>>x;
    cout<<solve(n,x)<<endl;
    return 0;
}

ll solve(ll n,ll x) {
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll maki=pow(2,n+1)-3;
    if(x<=1+maki){
        return solve(n-1,x-1);
    }
    else{
        return pow(2,n)+solve(n-1,x-2-maki);
    }
}

Measured memory_bytes: 384
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, y = mput()
    hoge = (x * 4 - y) / 2
    if hoge % 1 == 0 and x >= hoge >= 0:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 9244
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MEM(v,x) memset(v,x,sizeof v)

const double eps=1e-7,PI=3.1415926;
const int N=2e5+10;

using namespace std;

LL n,r,p,s,q,m,k,x,y,a[N][5],mx=-1,mn=1e9,sum,t;
char c[N];
string str,s1,s2;
map < int , int > mp;
vector < int > vec;

int main(){
    cin>>n>>k>>r>>s>>p>>str;
    for (int i=0;i<n;i++){
        if (str[i]=='r'){
            if (i<k)sum+=p,a[i][2]=1;
            else {
                if (a[i-k][2])continue;
                else sum+=p,a[i][2]=1;
            }
        }
        if (str[i]=='p'){
            if (i<k)sum+=s,a[i][3]=1;
            else {
                if (a[i-k][3])continue;
                else sum+=s,a[i][3]=1;
            }
        }
        if (str[i]=='s'){
            if (i<k)sum+=r,a[i][1]=1;
            else {
                if (a[i-k][1])continue;
                else sum+=r,a[i][1]=1;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

#define INF 1234567890
#define ll long long
#define MOD 1000000007
#define inv2 500000004

int N;
ll A[200201];

int main()
{
	scanf("%d", &N);
	ll sum = 0, res = 0;
	for(int i=1; i<=N; i++)
	{
		scanf("%lld", &A[i]);
		sum += A[i];
	}
	sum %= MOD;
	res += sum*sum; res %= MOD;

	for(int i=1; i<=N; i++)
		res -= A[i]*A[i]%MOD;
	res %= MOD;

	res *= inv2; res %= MOD;
	
	res %= MOD; res += MOD; res %= MOD;
	printf("%lld", res);
	return 0;
}

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

void warshall_floyd(const int n,
                    vector<vector<int64_t>>& cost) {
    // 辺が存在しない場合は(1LL << 60)で初期化する
    for (auto i = 0; i < n; i++) cost[i][i] = 0;
    for (auto k = 0; k < n; k++) {
        for (auto i = 0; i < n; i++) {
            for (auto j = 0; j < n; j++) {
                // 直接行く場合とkを経由する場合でより小さい距離を採用する
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
}

int main(){
    int n, m, r; cin >> n >> m >> r;
    vector<int> v(r); for (auto i = 0; i < r; i++) cin >> v[i], v[i]--;
    vector<vector<int64_t>> cost(n, vector<int64_t>(n, (1LL << 60)));
    for (auto i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        cost[a][b] = c; cost[b][a] = c;
    }
    warshall_floyd(n, cost);
    vector<int> num(r); int64_t ans = INT64_MAX;
    iota(num.begin(), num.end(), 0);
    do {
        int64_t tmp = 0;
        for (auto i = 1; i < (int)num.size(); i++) 
            tmp += cost[v[num[i - 1]]][v[num[i]]];
        ans = min(ans, tmp);
    } while(next_permutation(num.begin(), num.end()));

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

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    vector<ll> v(3);
    for(auto& i : v){
        cin >> i;
    }
    sort(all(v));
    if(v[0]*v[1]*v[2]%2 == 0){
        cout << 0 << endl;
    }else{
        cout << v[0]*v[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i = 0;i < N;++i){
    cin >> a[i];
  }
  
  int num = 0;
  
  int num2 = 1;
  
  for(int i = 0;i < N;++i){
    if(a[i] == num2){
      num2++;
      num++;
    }
  }
  
  int num3;
  
  if(num == 0){
    cout << "-1" << endl;
  }
  else{
    num3 = N - num;
    cout << num3 << endl;
  }
  
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, d;
  cin >> n >> d;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector <int> suf(n + 1);
  suf[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (suf[i + 1] <= a[i] / 2) {
      suf[i] = suf[i + 1];
    } else {
      suf[i] = suf[i + 1] + a[i];
    }   
  }
  vector <int> pref(n + 1);
  pref[0] = d;
  for (int i = 0; i < n; ++i) {
    pref[i + 1] = pref[i];
    pref[i + 1] = min(pref[i + 1], abs(pref[i] - a[i]));
  }
  int q;
  cin >> q;
  while (q--) {
    int id;
    cin >> id;
    --id;
    int go = pref[id];
    int mn = suf[id + 1];
    if (mn <= go) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
 


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

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<Integer>();
			used[i].add(-1);
		}
		int sat = 0;
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used[j].last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used[now].add(d);
			sat += max;
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		Random r = new Random();
		while(true) {
			int temp = 0;
			int d = r.nextInt(D);
			for(int q = 0; q < 26; q++) {
				temp -= s[d][con[d]];
				temp += s[d][q];
				temp -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
				temp += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
				if(temp > 0) {
					sat += temp;
					con[d] = q;
					used[con[d]].remove(d);
					used[q].add(d);
				}
			}
			if(System.currentTimeMillis() - start < 1850)
				break;
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


Measured memory_bytes: 44636
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
const int N = 2e5 + 7;
int n, a[N], b[N], in[N], out[N], d[N], sum = 0;
vector <int> c, g[N];
bool used[N];
void dfs(int u) {
    used[u] = 1;
    for (int v : g[u]) if (!used[v]) dfs(v);
}   
bool check() {
    for (int i = 0; i < N; ++i) if (in[i] != out[i]) return 0;
    return 1;
}   
void rebuild() {
    for (int i = 0; i < N; ++i) {
        g[i].clear(); in[i] = out[i] = 0;
    }   
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) continue;
        g[b[i]].app(a[i]);
        ++in[a[i]]; ++out[b[i]];
    }   
}   
int ans;
void anime() {
    rebuild();
    if (!check()) exit(1);
    
 
    for (int i = 0; i < n; ++i) ans -= a[i] == b[i];
    for (int i = 0; i < N; ++i) if (g[i].size() && !used[i]) { ++ans; dfs(i); }
    bool have = 0;
    for (int i = 0; i < n; ++i) have |= a[i] == sum;
    cout << max(0ll, ans - have) << '\n';
    exit(0);
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n; ans = n;
    for (int i = 0; i < n; ++i) { cin >> a[i]; c.app(a[i]); }
    for (int i = 0; i < n; ++i) { cin >> b[i]; c.app(b[i]); }
    for (int i = 0; i < n; ++i) sum ^= a[i];
    c.app(sum);
    sort(all(c)); c.resize(unique(all(c)) - c.begin());
    sum = lower_bound(all(c), sum) - c.begin();
    for (int i = 0; i < n; ++i) a[i] = lower_bound(all(c), a[i]) - c.begin();
    for (int i = 0; i < n; ++i) b[i] = lower_bound(all(c), b[i]) - c.begin();
    rebuild();
    if (check()) anime();
    for (int i = 0; i < n; ++i) ++d[a[i]];
    for (int i = 0; i < n; ++i) --d[b[i]];
    vector <int> t;
    for (int i = 0; i < N; ++i) if (d[i]) t.app(i);
    if (t.size() != 2 || abs(d[t[0]]) != 1) {
        cout << "-1\n";
        exit(0);
    }   
    int x, to;
    if (d[t[0]] > 0) {
        x = t[0];
        to = t[1];
    }
    else {
        x = t[1];
        to = t[0];
    }
    if (to != sum) {
        cout << "-1\n";
        exit(0);
    }   
    for (int i = 0; i < N; ++i) {
        if (a[i] == b[i]) continue;
        if (a[i] == x && b[i] != to) {
            a[i] = to;
            anime();
        }   
    }   
    for (int i = 0; i < N; ++i) {
        if (a[i] == b[i]) continue;
        if (a[i] == x) {
            ans += 2;
            a[i] = to;
            anime();
        }   
    }   
    cout << "-1\n";
}   

Measured memory_bytes: 20208
// Mon Sep 14 19:59:49 IST 2020  


#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = INT64_MAX;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
void printSet(multiset <int>v){
    cout << "===\n";
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
  
int tests(){ 
    int n;
    cin >> n;
     
    vector <int> seive(n);
    forn(i,1,n)
        for(int j = i ; j < n ; j += i)
            seive[j]++;
    int sum  = 0;
    for(auto  &t : seive)
        sum +=t;
    cout << sum << '\n';

    // seive[1] = true;
    // int ans = 0;
    // forn(i,1,n)
    //     if(!seive[i])
    //         ans += 2;
    //     else{
    //     for(int h = 1; h*h <= i ; h++ )
    //         if(i%h == 0){
    //             ans++;
    //             if(h*h != i)
    //                 ans++;
    //         }
    //     } 
    // cout << ans << '\n';    
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 


Measured memory_bytes: 7120
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <pair <int,int>>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;
int n;
vvint adj;
vector <lli> dist;

void dfs(int s,int pred){
	for(auto uu : adj[s]){
		int u = uu.first;
		if(u == pred) continue;
		int d = uu.second;
		dist[u] = dist[s] + d;
		dfs(u,s);
	}
	return;
}

void solve(){
	cin >> n;
	adj = vvint(n);
	dist = vector <lli>(n);
	for(int i = 0;i < n - 1;++i){
		int u,v,w;
		cin >> u >> v >> w;
		--u,--v;
		adj[u].push_back({v,w});
		adj[v].push_back({u,w});
	}
	dfs(0,-1);
	for(int i = 0;i < n;++i){
		if(dist[i] % 2 == 0) cout << 1 << newl;
		else cout << 0 << newl;
	}

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

     signed main(){
 int n;
 string t;
 cin>>n>>t;
 int al2[t.size()]={};
 set<int> x[3];int y[3];
 int k=3;
 int kk=1;for(int i=0;i<n;i++)kk*=3;
 int ans[kk]={};
int z[kk];
 for(int i=0;i<n;i++){
      for(int j=0;j<k;j++)z[j]=j/(k/3);
      
   y[0]=0;y[1]=1;y[2]=2;
   for(int j=0;j<t.size();j++){
        if(t[j]=='S'){swap(y[1],y[2]);continue;}
        int h[3];
      for(int q=0;q<3;q++) h[y[z[al2[j]+q*k/3]]]=al2[j]+q*k/3;
      for(int q=0;q<3;q++)z[h[q]]=y[(q+1)%3];
       
        al2[j]=h[2];
   }

   for(int j=0;j<kk;j++){
       ans[j]+=y[z[j%k]]*k/3;
   }
   k*=3;

 }
 for(int i=0;i<kk;i++)cout<<ans[i]<<' ';






    }





      

        


Measured memory_bytes: 14188
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

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

    set<int> row, column;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        row.insert(a);
    }
    for(int j=0; j<m; j++){
        int b = 0;
        cin >> b;
        column.insert(b);
    }
    if(row.size() != n || column.size() != m){
        cout << 0 << endl;
        return 0;
    }

    long long int ans = 1, h = 0, w = 0;
    for(int i=n*m; i>0; i--){
        if(row.empty()    == false && *prev(row.end())    == i 
        && column.empty() == false && *prev(column.end()) == i){// uniquely determined
            row.erase(prev(row.end()));
            h += 1;
            column.erase(prev(column.end()));
            w += 1;
        }
        else if(row.empty()    == false && *prev(row.end())    == i){ ans *= w; row.erase(prev(row.end()));       h += 1; }
        else if(column.empty() == false && *prev(column.end()) == i){ ans *= h; column.erase(prev(column.end())); w += 1; }
        else ans *= max(0LL, h*w - (n*m - i));

        // cout << i << " " << h << " " << w << endl;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;

using namespace std;

inline int input(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template

int mo(int a, int m){
    return (a % m + m) % m;
}

int solve(int S, int T){
    if (S == T) {
        return 0;
    }
    return mo(S, 2) + mo(T, 2) + solve((S + mo(S, 2)) / 2, (T - mo(T, 2)) / 2);
}

int main() {
    cin.tie(0);
    // source code
    int N = input();
    rep(i, N){
        int S, T;
        cin >> S >> T;
        output(solve(S, T), 0);
    }
    
    return 0;
}

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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int ans = 0;
    for(int i = 0; i < n / r + 1; i++) {
        for(int j = 0; j < n / g + 1; j++) {
            int a = i * r + j * g;
            if (n - a >= 0 && (n - a) % b == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

void solve(long long A, long long B){
    long long r = A * B;
    cout << r << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3744
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

a,b,n=MI()
s=min(n,b-1)
ans=floor(a*s/b)-a*floor(s/b)
print(ans)

Measured memory_bytes: 9516
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e2 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
char s[N][N];
int dp[N][N];

signed main() {
	IOS;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> s[i][j];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i][j] == '.'){
				if(i == 1 && j == 1)
					dp[i][j] = 0;
				else if(i == 1){
					dp[i][j] = dp[i][j-1];
				}
				else if(j == 1){
					dp[i][j] = dp[i-1][j];
				}
				else
					dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
			}
			else{
				if(i == 1 && j == 1)
					dp[i][j] = 1;
				else if(i == 1){
					dp[i][j] = dp[i][j-1];
					if(s[i][j-1] == '.')
						dp[i][j]++;
				}
				else if(j == 1){
					dp[i][j] = dp[i-1][j];
					if(s[i-1][j] == '.')
						dp[i][j]++; 
				}
				else{
					dp[i][j] = inf;
					if(s[i-1][j] == '.')
						dp[i][j] = min(dp[i][j], dp[i-1][j] + 1);
					else 
						dp[i][j] = min(dp[i][j], dp[i-1][j]);
					if(s[i][j-1] == '.')
						dp[i][j] = min(dp[i][j], dp[i][j-1] + 1);
					else
						dp[i][j] = min(dp[i][j], dp[i][j-1]);
				}
			}
		}
	}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::process;

fn main() {
    input! {
        N: i32,
        M: i32,
        X: i32,
        Y: i32,
        x: [i32; N],
        y: [i32; M],
    }
    for z in -100..101 {
        if X < z && z <= Y {
            let mut ok: bool = true;
            for val in &x {
                if val >= &z {
                    ok = false;
                    break;
                }
            }
            for val in &y {
                if val < &z {
                    ok = false;
                    break;
                }
            }
            if ok {
                println!("No War");
                process::exit(0);
            }
        }
    }
    println!("War");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l=s.length();
    int ans=0;
    int counter=0;
    for(int i=0;i<l;++i) {
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            ++counter;
        }
        else {
            ans=max(counter,ans);
            counter=0;
        }
    }
    ans=max(counter,ans);
    cout << ans << endl;
}

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

typedef long long i64;

using namespace std;

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

    for(int i=0;i<s.size();i++){
        if(s[i]=='+') ans++;
        else ans--;
    }

    cout<<ans<<endl;
    


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, M;
  cin >> N >> M;
  vll X(M);
  rep(i, M) {
    cin >> X[i];
  }

  if (N >= M) {
    COUT(0);
    return 0;
  }

  SORT(X);

  ll ans = X[M - 1] - X[0];

  vll sa(M - 1);
  rep(i, M - 1) {
    sa[i] = X[i + 1] - X[i];
  }

  SORT(sa);
  REVERSE(sa);

  rep(i, N - 1) {
    ans -= sa[i];
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define all(v)   v.begin(),v.end()  
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main ()
{
  speed();
  ll int n,m;
    cin>>n>>m;
    vector<pair<ll int,ll int>>v(m);
    map<ll int,ll int>id;
    for(ll int i=0;i<m;i++){
        ll int li,ri;
        cin>>li>>ri;
        pair<ll int,ll int>p=mp(li,ri);
        v[i]=p;
    }
    
    ll int ids=0;
    ll int lmax=0,rmin=100000;
    for(ll int i=0;i<m;i++){
      lmax=max(v[i].first,lmax);
       rmin=min(rmin,v[i].second);
    }
    
    if(rmin>=lmax){
        cout<<(rmin-lmax+1);
    }
    else{
        cout<<"0";
    }
 return 0;
}

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

int N, p[20005], unp[20005];
vector<int> a, b;

vector<int> readjust(vector<int> v) {
	int mini = 2000000000;
	for (int i = 0; i < v.size(); i++) mini = min(mini, v[i]);
	for (int i = 0; i < v.size(); i++) v[i] += 1 - mini;
	return v;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &p[i]);
	for (int i = 0; i < N; i++) p[i]--;
	for (int i = 0; i < N; i++) unp[p[i]] = i;
	int cura = 0, curb = unp[0], cursum = unp[0];
	a.push_back(cura);
	b.push_back(curb);
	for (int i = 1; i < N; i++) {
		int target = unp[i];
		int diff = target - cursum; // diffa - diffb = diff
		int diffa, diffb;
		if (diff > 0) {
			diffb = 1;
			diffa = diff + 1;
		} else {
			diffa = 1;
			diffb = 1 - diff;
		}
		cura += diffa;
		curb -= diffb;
		cursum = target;
		a.push_back(cura);
		b.push_back(curb);
	}
	a = readjust(a);
	b = readjust(b);
	for (int i = 0; i < a.size(); i++) {
		if (i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	for (int i = 0; i < a.size(); i++) {
		if (i) printf(" ");
		printf("%d", b[i]);
	}
	printf("\n");
}


Measured memory_bytes: 1072
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;
const double PI = 3.141592653589793;

int main(){
    long double a, b, x;
    cin >> a >> b >> x;
	cout << fixed << setprecision(10);
    if(x > a * a * b / 2){
        long double p = atan(2*b/a - 2*x/(a*a*a)) / PI * 180.0;
        cout << p << endl;
    }else{
        long double q = atan((a*b*b)/(2*x)) / PI * 180.0;
        cout << q << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI 3.1415926535897932384626433832795


int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    ci>>n;
    ll ab[n+1];
    mem(ab,0);
    f(1,n+1)
    {
        for(ll j=i;j<n+1;j+=i) ab[j]++;
    }
    res=0;
    f(1,n+1)
    {
        res+=i*ab[i];
    }
    co<<res;
}



Measured memory_bytes: 81720
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int sy, sx, ty, tx;
  string s, t, ss, tt;
  cin >> sx >> sy >> tx >> ty;
  rep(i, sx, tx) s += "R";
  rep(i, sy, ty) s += "U";
  rep(i, sx, tx) t += "L";
  rep(i, sy, ty) t += "D";
  ss += "D";
  rep(i, sx, tx) ss += "R";
  ss += "RU";
  rep(i, sy, ty) ss += "U";
  ss += "L";
  tt += "U";
  rep(i, sx, tx) tt += "L";
  tt += "LD";
  rep(i, sy, ty) tt += "D";
  tt += "R";
  print(s + t + ss + tt);
}


Measured memory_bytes: 384
#include <stdio.h>

#define PI 3.14159265359

int main()
{
	double r, s, l= 0.0;
	
	scanf("%lf", &r);
	
	s = r*r*PI;
	l = 2*PI*r;
	
	printf("%lf %lf", s, l);
	
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    string a,b,c;

    cin >> a >> b >> c;

    a[0] = toupper(a[0]);
    b[0] = toupper(b[0]);
    c[0] = toupper(c[0]);

    cout << a[0] << b[0] << c[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAX=100005;
const ll MOD=1000000007;
vector<int> conn[MAX];
int cnt[MAX],o1,o2,p[MAX],pt[MAX],n,chk[MAX],chk2[MAX],pt2[MAX],p2[MAX];
void bone(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk[x]=1;
    p[u]=u+t-1;
    for(int i=1;i<t;i++) p[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk[conn[x][i]]==0) {
            bone(conn[x][i],u+t);
            return;
        }
    }
}
void bone2(int x,int u){
    int t=conn[x].size()-cnt[x]+1;
    chk2[x]=1;
    p2[u]=u+t-1;
    for(int i=1;i<t;i++) p2[u+i]=u+i-1;
    for(int i=0;i<conn[x].size();i++){
        if(cnt[conn[x][i]]!=0&&chk2[conn[x][i]]==0) {
            bone2(conn[x][i],u+t);
            return;
        }
    }
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++) {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        conn[t1].push_back(t2);
        conn[t2].push_back(t1);
    }
    for(int i=1;i<=n;i++) cnt[i]=conn[i].size();
    for(int i=1;i<=n;i++) if(conn[i].size()==1&&cnt[conn[i][0]]>2){
        cnt[i]--,cnt[conn[i][0]]--;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>=3){
            printf("-1\n");
            return 0;
        }
        if(cnt[i]==1){
            if(o1==0) o1=i;
            else o2=i;
        }
    }
    bone(o1,1);
    bone2(o2,1);
    for(int i=1;i<=n;i++) pt[p[i]]=i;
    for(int i=1;i<=n;i++) pt2[p2[i]]=i;
    int l;
    for(int i=1;i<=n;i++){
        if(pt[i]<pt2[i]) {l=0; break;}
        else if(pt2[i]<pt[i]) {l=1;break;}
    }
    //if(o2==0) l=0;
    if(l==0) for(int i=1;i<=n;i++)printf("%d ",pt[i]);
    else for(int i=1;i<=n;i++)printf("%d ",pt2[i]);
    printf("\n");
}



Measured memory_bytes: 9216