akhauriyash/Code-Regression huggingface dataset:
# abc167_b.py
# https://atcoder.jp/contests/abc167/tasks/abc167_b

# B - Easy Linear Programming /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 1が書かれたカードが A 枚、0 が書かれたカードが B 枚、 −1 が書かれたカードが C枚あります。
# これらのカードから、ちょうど K枚を選んで取るとき、取ったカードに書かれた数の和として、 ありうる値の最大値はいくつですか。

# 制約
#     入力は全て整数である。
#     0≤A,B,C
#     1≤K≤A+B+C≤2×109

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B C K

# 出力
# 和としてありうる値の最大値を出力せよ。

# 入力例 1
# 2 1 1 3

# 出力例 1
# 2

# 1が書かれたカードを 2 枚、0 が書かれたカードを 1 枚取ることを考えます。 
# このときカードに書かれた数の和は 2になり、和としてありうる値の最大値になります。

# 入力例 2
# 1 2 3 4

# 出力例 2
# 0

# 入力例 3
# 2000000000 0 0 2000000000

# 出力例 3
# 2000000000


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B, C, K = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if A >= K:
        result = K
    else:
        result = A
        if A+B < K:
            result -= K - (A+B)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 1 1 3']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['1 2 3 4']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['2000000000 0 0 2000000000']
        lines_export = [2000000000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define rep(i,N) for(int i=0;i<N;i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  
  S[3] += 1;
  
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

double dp[3000][3000];
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<double> arr(n);
    for (auto &x : arr) cin >> x;
    for (int j = 0; j < n; ++j) dp[0][j] = (j == 0) ? (1-arr[j]) : dp[0][j-1]*(1-arr[j]);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < i; ++j) dp[i][j] = (j == 0) ? arr[j] : dp[i][j-1]*arr[j];
        for (int j = i; j < n; ++j) dp[i][j] = arr[j]*dp[i-1][j-1] + (1-arr[j])*dp[i][j-1];
    }
    double ans = 0;
    for (int i = (n/2)+1; i <= n; ++i) ans += dp[i][n-1];
    cout << fixed << setprecision(13) << ans << '\n';
    return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	string s;
	cin >> s;
	int r[100010],l[100010];
	int cnt=0;
	int ans[100010];
	FOR(i,s.size()){
		if(s[i]=='R'){
			cnt++;
			r[i]=cnt;
		}else{
			cnt=0;
			r[i]=cnt;
		}
	}
	cnt=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='L'){
			cnt++;
			l[i]=cnt;
		}else{
			cnt=0;
			l[i]=cnt;
		}
	}
	FOR(i,100005){
		ans[i]=0;
	}

	FOR(i,s.size()-1){
		if(s[i]=='R' && s[i+1]=='L'){
			int ll,rr;
			ll=r[i]/2+l[i+1]/2;
			rr=r[i]/2+l[i+1]/2;
			if(r[i]%2==1){
				ll++;
			}
			if(l[i+1]%2==1){
				rr++;
			}
			ans[i]=ll;
			ans[i+1]=rr;
			
		}
	}

	FOR(i,s.size()){
		cout << ans[i] << " ";
	}
	cout << endl;
	
}

Measured memory_bytes: 1792
#include<cstdio>
#include<deque>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int SIZEN=1010,inf =0x7fffffff/2;
int N,W;
int w[SIZEN],v[SIZEN];
int pos[4][SIZEN]={0},he[4][SIZEN];
int cnt[4];
int a[4][SIZEN];
bool cmp(int a,int b)
{
	return a>b;
}
void work()
{
	int lim[4];
	for(int i=0;i<4;i++)
	{
		lim[i]=min(cnt[i],W/(w[1]+i));
		for(int j=1;j<=lim[i];j++) pos[i][j]=pos[i][j-1]+a[i][j];
	}
	int ans=0;
	for(int i=0;i<=lim[0];i++)
	{
		for(int j=0;j<=lim[1];j++)
		{
			if(w[1]*i+(w[1]+1)*j>W) break;
			for(int k=0;k<=lim[2];k++)
			{
				if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k>W) break;
				for(int p=0;p<=lim[3];p++)
				{
					if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k+(w[1]+3)*p>W) break;
					ans=max(ans,pos[0][i]+pos[1][j]+pos[2][k]+pos[3][p]);
				}
			}
		}
	}
	cout<<ans<<endl;
}
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d%d",&N,&W);
	for(int i=1;i<=N;i++)
	{
	scanf("%d%d",&w[i],&v[i]);
	int t=w[i]-w[1];a[t][++cnt[t]]=v[i];
    }
    for(int i=0;i<4;i++) sort(a[i]+1,a[i]+1+cnt[i],cmp);
    work();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(2):
    S.append(input())
mod = 7 + 10**9

if S[0][0] == S[1][0]: #縦置き
    ans, pre = 3, "v"
    i = 1
else: #横置き
    ans, pre = 6, "w"
    i = 2

while i < N:
    if S[0][i] == S[1][i]: #縦置き
        if pre == "v": #左が縦置き
            ans *= 2
            ans %= mod
        else: #左が横置き
            pre = "v"
        i += 1
    else: #横置き
        if pre == "v": #左が縦置き
            ans *= 2
            ans %= mod
            pre = "w"
        else: #左が横置き
            ans *= 3
            ans %= mod
        i += 2

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
long long int N;
int ans = 0;
//flag(3 5 7) -> 0 1 0: mean 5 is used
void dfs(long long int n, int flag) {
   if (N < n) {
      return;
   }
   if (N >= n && flag == 7) {
      ans++;
   } 
   dfs(10*n + 3, flag|1 );
   dfs(10*n + 5, flag|2 );
   dfs(10*n + 7, flag|4 );
}

int main(void) {
   scanf("%lld", &N);
   dfs(0, 0);
   printf("%d\n", ans);
   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
  int a,b;

  scanf("%d",&a); scanf("%d",&b);
  
  if(a == b)
    printf("a == b\n");

  else if(a > b)
    printf("a > b\n");

  else
    printf("a < b\n");

  return(0);
}

Measured memory_bytes: 2608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n,m;
  cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

int n, A[200050];
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
pi stOdd[200050][20], stEven[200050][20];
priority_queue<ppi,vector<ppi>,greater<ppi> > pq;
pi mmin(pi a, pi b){ return a.first < b.first ? a : b; }
int precomp(){
	for(int i = 0; i<n; i++) if(i%2 == 0) stEven[i][0] = pi(A[i],i), stOdd[i][0] = pi(INT_MAX,0); else stEven[i][0] = pi(INT_MAX,0), stOdd[i][0] = pi(A[i],i);
	for(int h=1; h<18; h++){
		for(int i = 0; i+(1<<h)<=n; i++){
			stEven[i][h] = mmin(stEven[i][h-1], stEven[i+(1<<(h-1))][h-1]);
			stOdd[i][h] = mmin(stOdd[i][h-1], stOdd[i+(1<<(h-1))][h-1]);
		}
	}
}
pi rmqOdd(int x, int y){ // [x,y]
	int k = 31-__builtin_clz(y-x+1);
	return mmin(stOdd[x][k], stOdd[y-(1<<k)+1][k]);
}
pi rmqEven(int x, int y){
	int k = 31-__builtin_clz(y-x+1);
	return mmin(stEven[x][k], stEven[y-(1<<k)+1][k]);
}
pi rmq(int x, int y, bool odd){ return odd ? rmqOdd(x,y) : rmqEven(x,y); }
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i<n; i++) cin >> A[i];
	precomp();
	pq.push(ppi(rmq(0,n-1,0), pi(0,n-1)));
	while(!pq.empty()){
		cout << pq.top().first.first << " ";
		int x = pq.top().second.first, y = pq.top().second.second;
		int p = pq.top().first.second;
		pq.pop();
		pi cur = rmq(p+1,y,1-x%2);
		int a = cur.first, b = cur.second;
		cout << a << " ";
		// [x, p-1], [p+1, b-1], [b+1, y]
//		printf("[%d, %d], [%d, %d], [%d, %d]\n", x, p-1, p+1, b-1, b+1, y);
		if(x<p-1) pq.push(ppi(rmq(x,p-1,x%2),pi(x,p-1)));
		if(p+1<b-1) pq.push(ppi(rmq(p+1,b-1,(p+1)%2),pi(p+1,b-1)));
		if(b+1<y) pq.push(ppi(rmq(b+1,y,(b+1)%2),pi(b+1,y)));
	}
}


Measured memory_bytes: 65524
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int a[N],b[N],q[N],n,w,h,Y,ans;
struct node{int x,y;}p[N];
bool cmp(node a,node b){return a.x<b.x;}
void solve(int l,int r){
	if (l==r) return;
	int mid=(l+r)>>1;
	for (int i=mid,y1=0,y2=h;i>=l;i--){
		a[i]=y1;b[i]=y2;
		if (p[i].y>=Y) y2=min(y2,p[i].y);
		if (p[i].y<=Y) y1=max(y1,p[i].y);
	}
	for (int i=mid+1,y1=0,y2=h;i<=r;i++){
		a[i]=y1;b[i]=y2;
		if (p[i].y>=Y) y2=min(y2,p[i].y);
		if (p[i].y<=Y) y1=max(y1,p[i].y);
	}
	for (int i=mid,j=mid+1,h=1,t=0;i>=l;i--){
		for (;j<=r && a[j]<=a[i];j++){
			for (;h<=t && b[q[t]]+p[q[t]].x<=b[j]+p[j].x;t--);
			q[++t]=j;
		}
		for (;h<t && b[i]+p[q[h]].x<=b[q[h+1]]+p[q[h+1]].x;h++);
		ans=max(ans,(p[q[h]].x-p[i].x+min(b[i],b[q[h]])-a[i])*2);
	}
	for (int i=mid+1,j=mid,h=1,t=0;i<=r;i++){
		for (;j>=l && a[j]<=a[i];j--){
			for (;h<=t && b[q[t]]-p[q[t]].x<=b[j]-p[j].x;t--);
			q[++t]=j;
		}
		for (;h<t && b[i]-p[q[h]].x<=b[q[h+1]]-p[q[h+1]].x;h++);
		ans=max(ans,(p[i].x-p[q[h]].x+min(b[i],b[q[h]])-a[i])*2);
	}
	solve(l,mid);solve(mid+1,r);
}
void work(){
	sort(p+1,p+n+1,cmp);
	Y=h/2;
	p[0].x=0;p[n+1].x=w;
	p[0].y=p[n+1].y=Y;
	solve(0,n+1);
}
int main(){
	scanf("%d%d%d",&w,&h,&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	ans=max(h,w)*2+2;
	work();
	swap(w,h);
	for (int i=1;i<=n;i++) swap(p[i].x,p[i].y);
	work();
	printf("%d\n",ans);
}


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

int main(){

  int n;

  while(cin >> n, n){
    int tmp, cnt = 0;
    for(int i = 1; i < n; i++){
      tmp = 0;
      for(int j = i; tmp < n; j++){
        tmp += j;
        if(tmp == n) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
#include <stdio.h>

using namespace std;

int main(){
    int C[10001];
    for(int i = 0; i < 10001; i++) C[i] = 0;
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }

    for(int i = 0,j=0; i < 10001; i++){
        if(C[i] != 0){
            for(int k = 0; k < C[i]; k++){
                B[j++] = i;
            }
        }
    }

    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}

Measured memory_bytes: 16504
N = int(input())
points = []
for i in range(N):
    points.append(input().split())
for j, point in enumerate(points):
    point.append(j+1)
points.sort(key=lambda x: int(x[1]), reverse=True)
points.sort(key=lambda x: x[0])
for p in points:
    print(p[2])

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define MAX 100005
#define ll long long
ll L[MAX];
ll x;
map<ll,int> vis;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int n;
    scanf("%d",&n);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&x);
        if(!vis[x])
            L[cnt++]=x;
        vis[x]++;
    }
    sort(L,L+cnt,cmp);
    int t=0;
    int flag1=0;
    int flag2=0;
    ll l[MAX];
    for(int i=0;i<cnt;i++)
    {
        if(vis[L[i]]>=4)
        {
            flag1=1;
            l[t++]=L[i];
            break;
        }
        else if(vis[L[i]]>=2)
        {
            flag2=1;
            l[t++]=L[i];
        }
        if(t==2)
            break;
    }
    if(!flag1&&!flag2)
        printf("0\n");
    else if(flag1&&!flag2)
        printf("%lld\n",l[0]*l[0]);
    else
        printf("%lld\n",l[0]*l[1]);
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;
    string A, B;
    cin >> N;
    cin >> A >> B;

    string res;
    for (int i = 0; i < N; ++i) {
        res = res + A[i] + B[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

const long long mod = 1e9 + 7;

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

	long long n;
	cin >> n;
	vector<long long> a(n);
	for(long long i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;

	long long two = 1;
	for(int i = 0; i < 60; i++){
		int one = 0;
		int zero = 0;
		for( long long j = 0; j < n; j++){
			 if(a[j] & (1LL << i)) one++;
		}
		//cout << one << " : " << zero << endl;
		ans += ((one * (n - one) % mod) * (two % mod)) % mod;
		two *= 2;
	}
	ans %= mod;
	cout << ans << endl;	
}


Measured memory_bytes: 5516
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
int main(void)
{
    int N, K;
    cin >> N >> K;
    long double sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i >= K)
        {
            sum += (1 / (long double)N) * (N - (i - 1));
            break;
        }
        else
        {
            //    cout << ceil(log2((long double)K / (long double)i)) << std::endl;
            sum += (1 / pow(2, (long double)ceil(log2((long double)K / (long double)i)))) * (1 / (double)N);
        }
    }
    std::cout << std::setprecision(12) << sum;

    // Your code here!
}


Measured memory_bytes: 256
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

min_ = 0
while True:
    front = X - min_
    back = X + min_
    if front in P and back in P:
        min_ += 1
    else:
        break

front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

Measured memory_bytes: 9196
n = gets.to_i
t = 0
h = 0
for i in 1..n
  st,sh = gets.split
  if st == sh
    t += 1
    h += 1
  elsif st > sh
    t += 3
  else
    h += 3
  end
end
puts t.to_s + " " + h.to_s

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, m;
  cin >> a >> b >> m;

  vll aa(a), bb(b), x(m), y(m), c(m);
  for (ll i = 0; i < a; i++) cin >> aa[i];
  for (ll i = 0; i < b; i++) cin >> bb[i];
  for (ll i = 0; i < m; i++) cin >> x[i] >> y[i] >> c[i];

  vll sa = aa, sb = bb;
  sort(all(sa));
  sort(all(sb));

  priority_queue<ll, vll, greater<ll>> ans;
  ans.push(sa[0] + sb[0]);
  for (ll i = 0; i < m; i++) {
    ans.push(aa[x[i] - 1] + bb[y[i] - 1] - c[i]);
  }
  cout << ans.top() << endl;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main(){
    int n,aux,rta=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> aux;
        if(i%2==0 && aux%2==1) rta++;
    }
    cout << rta << endl;
    return 0;
}



Measured memory_bytes: 3520
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    cout<<(c*60+d)-(a*60+b)-e<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(std::string S, std::string T){
  int count=0;
  REP(i,3){
    if(S[i]==T[i])
      count++;
  }
  cout<<count<<endl;
}

int main(){
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin>>s;
  	if(s[0]==s[s.length()-1])
    {
      	if(s.length()&1)
      		cout<<"Second\n";
  		else cout<<"First\n";
    }
  	else{
    	if(s.length()&1) cout<<"First\n";
      	else cout<<"Second\n";
    }
}

Measured memory_bytes: 512
#include<iostream>

int main()
{
    int k,s,x,y,z,ans=0;
    std::cin>>k>>s;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            for(z=0;z<=k;z++){
                if(x+y+z==s)ans++;
            }
        }
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);
        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


 
void solve()
{     
    int s, w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int e; cin >> e;
    if(e == 0) break;
    int mi = 1000000;
    REP(i, 100+1) {
      REP(j, 1000+1) {
        int x = e - i*i*i - j*j;
        if(x >= 0) {
          mi = min(mi, x+i+j);
        } else {
          break;
        }
      }
    }
    cout << mi << endl;
  }
}



Measured memory_bytes: 2956
S = input()
s1,s2 = int(S[0:2]),int(S[2:4])

def f(n):
  if n >= 1 and n <= 12:
    return True
  else:
    return False

if f(s1) and f(s2):
  print("AMBIGUOUS")
elif f(s1) and (s2 > 12 or s2 ==0):
  print("MMYY")
elif f(s2) and (s1 > 12 or s1 ==0):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>

int main(){
  int t, h, m, s;
  std::cin >> t;
  h = t / 3600;
  m = (t - h*3600) / 60;
  s = t - h*3600 - m*60;
  std::cout << h << ":" << m << ":" << s << std::endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
const int MAX_D=10,INF=1e8;
int D,P[MAX_D],C[MAX_D],G;

int main(){
	cin>>D>>G;
	REP(i,D){
		cin>>P[i]>>C[i];
	}
	int ans=INF;
	REP(i,1<<D){
		int s=0,c=0,k=-1;
		REP(j,D){
			if ((i>>j)&1){
				s+=P[j]*(j+1)*100+C[j];
				c+=P[j];
			}else{
				k=j;
			}
		}
		if ((k==-1) || s+(P[k]-1)*(k+1)*100>=G){
			if (k!=-1){
				c+=max((G-s+(k+1)*100-1)/((k+1)*100),0);
			}
			ans=min(ans,c);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int N = 1100;
const int mod = 1e9+7;

int prime[N];
vector <int> lista;
long long qtd[N];

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

	//map <int, int> mp;

	for (int i = 2; i <= n; ++i) {
		if(prime[i]==0) {
			lista.push_back(i);
			for (int j = 2*i; j <= n; j+=i) {
				prime[j] = 1;
			}
		}
	}

	for (int i = 1; i <= n; ++i) {
		int at = i;
		for (int j = 0; j < lista.size(); ++j) {
			if (at % lista[j] == 0) {
				while(at % lista[j] == 0) {
					at /= lista[j];
					qtd[j]++;
				}
			}
		}
	}

	long long ans = 1;
	for (int i = 0; i < lista.size(); ++i) {
		ans = (ans * 1ll * (qtd[i]+1)) % mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

// Time Complexity: O(items.size() * capacity)
// Space Complexity: O(capacity)
fn knapsack(items: &[(usize, u64)], capacity: usize) -> u64 {
    let mut dp = vec![0; capacity + 1];
    for i in 1..capacity + 1 {
        for &(weight, value) in items {
            if weight <= i {
                dp[i] = std::cmp::max(dp[i], dp[i - weight] + value);
            }
        }
    }
    dp[capacity]
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let N: usize = stdin.read();
    let W: usize = stdin.read();
    let mut items = Vec::<(usize, u64)>::new();
    for _ in 0..N {
        let value: u64 = stdin.read();
        let weight: usize = stdin.read();
        items.push((weight, value));
    }
    println!("{}", knapsack(&items, W));
}

#[allow(unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
bool pf(ll n) {
  if (n == 1) {
    return false;
  }
  if (n == 2) {
    return true;
  }
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  vector<int> a(100001, 0), rui(100002, 0);
  for (int i = 1; i <= 100000; i++) {
    if (i % 2 == 1) {
      a[i] = pf(i) && pf((i + 1) / 2);
    }
  }
  for (int i = 0; i < a.size(); i++) {
    rui[i + 1] = rui[i] + a[i];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << rui[r + 1] - rui[l] << endl;
  }
}


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

int main(){
  int64_t A, B, K;
  cin >> A >> B >> K;
  
  if(A>K)
    cout << A-K << " " << B << endl;
  else if(A<=K && B>K-A)
    cout << "0 " << A+B-K << endl;
  else if(A<=K && B<=K-A)
    cout << "0 0" << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()

    ans = 0
    ar, br, abr = 0, 0, 0
    for i in range(N):
        s = in_s()
        ans += s.count('AB')
        if s[0] == 'B' and s[-1] == 'A':
            abr += 1
        elif s[0] == 'B':
            br += 1
        elif s[-1] == 'A':
            ar += 1

    # print(ans)
    #print(ar, br, abr)

    t = abr
    if ar > 0:
        ar -= 1
        t += 1
    if br > 0:
        br -= 1
        t += 1
    if t > 1:
        ans += t - 1

    ans += min(ar, br)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
 
int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
 
    ll ans(0);
    rep(i,n-k){
        ans += v[i];
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 4852
package main

import "fmt"

const (
	maxBufferSize     = 2000000 // check
	initialBufferSize = 20000
)

func solve() {
	//	sc := bufio.NewScanner(os.Stdin)
	//	buffer := make([]byte, initialBufferSize)
	//	sc.Buffer(buffer, maxBufferSize)
	var a, b int
	fmt.Scan(&a, &b)

	if (a+b)%2 == 1 {
		fmt.Println("IMPOSSIBLE")
	} else {
		fmt.Println((a + b) / 2)
	}
}

func main() {
	solve()
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


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

    ll m = -1;
    string ans;
    if (n == 0) {
        ans += "0";
    }
    while(n != 0) {
        if(n % (2* abs(m)) != 0) {
            ans += "1";
            n += m;
        } else {
            ans+= "0";
        }
        m *= -2;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
ll aa[300][300];
ll dist[300][300];
ll INF = 1001001001001;

// 返り値は与えられた最短距離行列が正しいか
bool warshall_floyd(int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for (int j = 0; j < n; ++j) {
    for (int k = 0; k < n; ++k) {
      if (aa[j][k] > dist[j][k]) return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<tuple<ll, int, int>> costs;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> aa[i][j];
      dist[i][j] = aa[i][j];
      if (i < j) {
        costs.emplace_back(aa[i][j], j, i);
      }
    }
  }
  bool ok = warshall_floyd(n);
  if (!ok) { 
    cout << "-1" << endl;
    return 0;
  }
  sort(costs.begin(),
       costs.end(), 
       [](tuple<ll, int, int> const &lhs, tuple<ll, int, int> const &rhs) {
          return get<0>(lhs) < get<0>(rhs);
       });
  ll ans = 0;
  for (auto c : costs) {
    ll d;
    int a, b;
    tie(d, a, b) = c;
    bool removable = false;
    for (int i = 0; i < n; ++i) {
      if (i == a || i == b) continue;
      if (dist[a][b] == dist[a][i] + dist[i][b]) {
        removable = true;
        break;
      }
    }
    if (!removable) ans += dist[a][b];
    // cout << d << " " << a << " " << b << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 2420
fn main() {
    let (n, m) = read_tuple();
    let mut ret: Vec<i32> = vec![-1; n];

    for _ in 0..m {
        let (i, c) = read_tuple();
        if ret[i-1] != -1 && ret[i-1] != c as i32 {
            println!("-1");
            return
        }
        ret[i-1] = c as i32;
    }

    if ret[0] == -1 && n != 1 {
        ret[0] = 1;
    }
    for i in 0..n {
        if ret[i] == -1 {
            ret[i] = 0;
        }
    }

    if n != 1 && ret[0] == 0 {
        println!("-1");
        return
    }

    println!("{}", ret.iter().map(|e| e.to_string()).collect::<String>());
}

fn read_tuple() -> (usize, usize) {
    let v = read_vec::<usize>();
    (v[0], v[1])
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int i;
		for(i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '7') break;
		}	
		if(i < s.length()) System.out.println("Yes");
		else System.out.println("No");
	}
} 


Measured memory_bytes: 35664
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
int main () {
	int n;
    cin >> n;
	vector<ll> v(n);
	rep(i,n) {
		cin >> v[i];
	}
	ll ans = 0;
	int right = 0;
	ll s = 0;
	for (int left = 0; left < n; ++left) {
		while (right < n && (s ^ v[right]) == (s + v[right])) {
			s += v[right];
			++right;
		}
		ans += 1LL * right - 1LL * left;
		if (right == left)
			++right;
		else {
			s -= v[left];
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
# [箱A, 箱B, 箱C]
list = input().split()
 
# 箱Aと箱B入れ替え
list[0], list[1] = list[1], list[0]
 
# 箱Aと箱C入れ替え
list[0], list[2] = list[2], list[0]    
              
print(' '.join(list))

Measured memory_bytes: 9000
class PriorityQueue # DESC
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end
  def push(element)
    @data.push(element)
    bottom_up
  end
  def pop
    return nil if size == 0
    return @data.pop if size == 1
    min = @data[0]
    @data[0] = @data.pop
    top_down
    min
  end
  def size
    @data.size
  end
  def length
    @data.length
  end
  def empty?
    @data.empty?
  end
  def array
    @data
  end
  private
  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end
  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end
  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] < @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end
  def top_down
    target_idx = 0
    while (has_child?(target_idx))
      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] >= @data[b] ? a : b
      end
      if @data[target_idx] < @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end
  def left_child_idx(idx)
    (idx * 2) + 1
  end
  def right_child_idx(idx)
    (idx * 2) + 2
  end
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end #DESC

N, M = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
pq = PriorityQueue.new(arr)

M.times do
  cost = pq.pop / 2
  pq.push(cost)
end

puts pq.array.inject(:+)

Measured memory_bytes: 13996
#include <stdio.h>
#include <string.h>
 int main(void){
    char s[11],t[11],u[11];
    int a,b;
   //gets(s);
   //gets(t);
   scanf("%s %s",&s,&t);
   scanf("%d %d",&a,&b);
   scanf("%s",&u);
   // gets(u);
  // printf("%d %d %s",a,b,u);
   if(strcmp(u,s)==0)
     printf("%d %d",a-1,b);
   else if(strcmp(u,t)==0)
     printf("%d %d",a,b-1);
} 

Measured memory_bytes: 128
#01:15
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] -= 1
  a[i] %= k
b = [0]
for i in range(n):
  b.append((b[-1]+a[i]) % k)
ans = 0
now = {}
for i in range(n+1):
  tmp = b[i]
  if tmp in now:
    ans += now[tmp]
    now[tmp] += 1
  else:
    now[tmp] = 1
  if i - k + 1 >= 0:
    now[b[i-k+1]] -= 1
print(ans)

Measured memory_bytes: 40612
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
 
using namespace std;
 
int main(){
 
    int n;
    cin >> n ;
    int cnt = 0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a%2) cnt++;
    }

    if(cnt%2) cout << "NO";
    else cout <<"YES";


    return 0;
}

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

int main(){
int x[3000],y[3000];
for(int i=0;i<3000;i++){
cin >> x[i] >> y[i];
if(x[i]==0 && y[i]==0) break;
}
for(int j=0;j<3000;j++){
if(x[j] == 0 && y[j] == 0) break;
if(x[j] < y[j]) cout << x[j] << " " << y[j] << endl;
else cout << y[j] << " " << x[j] << endl;
}
return 0;
}

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

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    double ad = (double) a;
    double bd = (double) b;
    double xd = (double) x;

    if( 2 * x >= a * a * b )
    {
        cout << std::fixed << std::setprecision(15) << atan2( 2 * bd - 2 * xd / ad / ad, ad ) * 180 / M_PI;
    }
    else
    {
        cout << std::fixed << std::setprecision(15) << atan2(bd, 2 * xd / ad / bd) * 180 / M_PI;
    }
}

Measured memory_bytes: 4064
#include <stdio.h>
int main(){
    int num=0,a[100],tmp,min=0,max = 0;
    scanf("%d",&num);
    for(int i=0;i<num;i++){
        scanf("%d",&a[i]);
    }
    min=a[0];
    max=a[0];
    for(int i=0;i<num;i++){
        if(min>=a[i])
            min=a[i];
        if(max<=a[i])
            max=a[i];
    }
    printf("%d\n",max-min);
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	cout << n * n * n << endl;
    
    return 0;
}



Measured memory_bytes: 3648
S = input()
a = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == "<":
        a[i+1] = max(a[i+1], a[i] + 1)
for i in range(len(S)-1,-1,-1):
    if S[i] == ">":
        a[i] = max(a[i], a[i+1] + 1)
        
print(sum(a))

Measured memory_bytes: 23336
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
    int mi = 1e9 + 5, ma = 0, n, k, gcd;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        mi = min(a[i], mi);
        ma = max(a[i], ma);
    }
    if (n == 1) {
        if (a[0] == k) printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
        return 0;
    }
    gcd = __gcd(a[0], a[1]);
    for (int i = 2; i < n; i++) {
        gcd = __gcd(a[i], gcd);
    }
    if (k > ma || k < mi) {
        printf("IMPOSSIBLE\n");
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (abs(a[i] - k) % gcd == 0) {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


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

int main() {
    ll N,M,V,P;
    cin >> N >> M >>V >> P;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.rbegin(),A.rend());
    ll sum[N+1] = {};
    for(int i=0;i<N;i++){
        sum[i+1] += (sum[i]+A[i]);
        if(i>=P && ((i-P+1)*(A[i]+M) < (sum[i]-sum[P-1])+M*max(V-(P-1)-(N-1-i)-1,0LL) || A[i] +M < A[P-1])){
            cout << i<<endl;
            return 0;
        }
    }
    cout << N <<endl;
    return 0;
}

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int z = sc.nextInt();
      int k = sc.nextInt();
      long[] A = new long[x];
      long[] B = new long[y];
      long[] C = new long[z];
      for(int i = 0; i < x; i++) A[i] = sc.nextLong();
      for(int i = 0; i < y; i++) B[i] = sc.nextLong();
      for(int i = 0; i < z; i++) C[i] = sc.nextLong();
      Arrays.sort(A);
      Arrays.sort(B);
      Arrays.sort(C);

      PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> (int)((A[b[0]] + B[b[1]] + C[b[2]]) - (A[a[0]] + B[a[1]] + C[a[2]])));
      pq.offer(new int[]{x-1, y-1, z-1});
      Set<String> visited = new HashSet<>();
      visited.add((x-1) + "," + (y-1) + "," + (z-1));
      for(int i = 0; i < k; i++) {
        int[] ele = pq.poll();
        System.out.println(A[ele[0]] + B[ele[1]] + C[ele[2]]);
        for(int j = 0; j < 3; j++) {
          if(ele[j] == 0) continue;
          int[] newEle = ele.clone();
          newEle[j]--;
          String key = newEle[0] + "," + newEle[1] + "," + newEle[2];
          if(visited.contains(key)) continue;
          visited.add(key);
          pq.offer(newEle);
        }
      }
  }
}

Measured memory_bytes: 33516
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

vector<int> edge[101000];
ll dp[101000];
ll K;

void solve(int x, int par, ll k){
    for(auto c: edge[x]){
        if(c == par){
            continue;
        }
        dp[c] = k;
        solve(c, x, K-2);
        k--;
    }
}


int main(){
    ll N;
    cin >> N >> K;
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    fill(dp, dp+101000, 0);
    dp[0] = K;
    solve(0, 0, K-1);

    ll res = 1;
    for(int i = 0; i < N; i++){
        if(dp[i] <= 0){
            res = 0;
            break;
        }
        else {
            res = mul(res, dp[i]);
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 11008
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int> ii;
struct seg {
	int s, e, m, v;
	seg *l, *r;
	seg(int _s, int _e) {
		s = _s, e = _e, m = (s + e) / 2, v = -1;
		if (s != e) {
			l = new seg(s, m);
			r = new seg(m + 1, e);
		}
	}
	void update(int i, int nv) {
		if (s == e) {
			v = nv;
			return;
		} else if (i > m) r -> update(i, nv);
		else l -> update(i, nv);
		v = max(l -> v, r -> v);
	}
	int query(int a, int b) {
		if (s == a && e == b) return v;
		if (a > m) return r -> query(a, b);
		if (b <= m) return l -> query(a, b);
		return max(l -> query(a, m), r -> query(m + 1, b));
	}
} *root;
int main() {
	int N;
	scanf("%d", &N);
	ii XD[N];
	for (int i = 0; i < N; ++i) scanf("%d %d", &XD[i].first, &XD[i].second);
	sort(XD, XD + N);
	root = new seg(0, N - 1);
	int reach[N];
	for (int i = N - 1; i >= 0; --i) {
		int ptr = lower_bound(XD, XD + N, ii(XD[i].first + XD[i].second, 0)) - XD;
		if (ptr == i + 1) reach[i] = i, root -> update(i, i);
		else reach[i] = root -> query(i + 1, ptr - 1), root -> update(i, reach[i]);
	}
	int dptable[N + 1];
	dptable[N] = 1;
	for (int i = N - 1; i >= 0; --i) dptable[i] = (dptable[reach[i] + 1] + dptable[i + 1]) % 998244353;
	printf("%d", dptable[0]);
	return 0;
}

Measured memory_bytes: 22144
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    map<string, int> cnt;
    REP(i, n){
        string s;
        cin >> s;
        cnt[s]++;
    }
    int maxx = -1;
    set<string> ans;
    for(auto t: cnt){
        maxx = max(maxx, t.second);
    }
    for(auto t: cnt){
        if(t.second == maxx)
            ans.insert(t.first);
    }
    for(auto t: ans)
        cout << t << endl;
    return 0;
}

Measured memory_bytes: 34560
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    ans = N*(N-1)//2
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9168