akhauriyash/Code-Regression huggingface dataset:
//In the Name of ̲A̲l̲l̲a̲h̲

#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;
const ll mod = 1e9 + 7;
ll h, w, dp[1001][1001];
bool grid[1001][1001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            char c;
            cin >> c;
            if (c == '.')
                grid[i][j] = 1;
        }
    }
	dp[1][1] = 1;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (grid[i][j])
            {
                if (grid[i-1][j])
                {
                    dp[i][j] = dp[i-1][j];
                    dp[i][j] %= mod;
                }
                if (grid[i][j-1])
                {
                    dp[i][j] += dp[i][j-1];
                    dp[i][j] %= mod;
                }
            }
        }
    }
    cout << dp[h][w];
}

/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (int)(n); i++)
#define RREPS(i, n) for (int i = (int)(n); i > 0; i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = K % 2 == 0 ? (A - B) : (B - A);
  if(abs(ans) <= 1e18) cout << ans << endl;
  else cout << "Unfair" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using lld=long double;
#define all(c) (c).begin(), (c).end()
#define rep( i, a, n ) for( int i=a; i<n; i++ )
#define repp( i, a, n, p ) for( int i=a; i<n; i+=p )
#define per( i, a, n ) for( int i=n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define acc accumulate

int main () {
    set <string> se;
    string s;
    ll n;
    cin >> n;

    rep ( i, 0, n ) {
        cin >> s;
        se.insert (s);
    }

    cout << se.size() << endl;
}


Measured memory_bytes: 19200
#include <stdio.h>

int main()
{
	int n,i;
	int a[10000];
	int max = -1000000,min = 1000000;
	long sum = 0;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
	}
	
	for(i = 0; i < n; i++)
	{
		if(max < a[i])
		{
			max = a[i];
		}
		if(min > a[i])
		{
			min = a[i];
		}
		sum += a[i];
	}
	
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n,c,k;
vi a;

int main(){
	cin>>n>>c>>k;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	int ans=0,I=0;
	for(int i=0;i<n;i++){
		if(i-I>=c||a[i]-a[I]>k) I=i;
		if(i==I) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 764
package main

import (
	"fmt"
)

func isBingo(hit [][]bool) bool {
	for i := 0; i < 3; i++ {
		if hit[i][0] && hit[i][1] && hit[i][2] {
			return true
		}
	}

	for i := 0; i < 3; i++ {
		if hit[0][i] && hit[1][i] && hit[2][i] {
			return true
		}
	}

	if hit[0][0] && hit[1][1] && hit[2][2] {
		return true
	}

	if hit[0][2] && hit[1][1] && hit[2][0] {
		return true
	}

	return false

}

func main() {
	a := make([][]int, 3)
	hit := make([][]bool, 3)

	for i := 0; i < 3; i++ {
		a[i] = make([]int, 3)
		hit[i] = make([]bool, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	// fmt.Println(a)

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var b int
		fmt.Scan(&b)
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if a[j][k] == b {
					hit[j][k] = true
				}
			}
		}
	}

	//fmt.Println(hit)

	if isBingo(hit) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
N = int(input())
def n_ary_notation(N, n):
  if N == 0:
    return '0'
  else:
    s = ''
    while N:
      s = str(N % abs(n)) + s
      N -= N % abs(n)
      N //= n
    return s
print(n_ary_notation(N, -2))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
using namespace std;


int main()
{
	long a;
	string s;

	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

}


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

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

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int n, m, x;
  scanf("%d%d%d", &n, &m, &x);
  vi c(n), t(m, 0);
  vector<vi> a(n, vi(m));
  rep(i, 0, n) {
    scanf("%d", &c[i]);
    rep(j, 0, m) {
      scanf("%d", &a[i][j]);
      t[j] += a[i][j];
    }
  }
  int mn = 1e7;
  rep(i, 0, m)
    mn = min(mn, t[i]);
  if (mn < x) {
    puts("-1");
    return;
  }

  int ans = 1e8;
  rep(i, 0, (1 << n)) {
    int cost = 0;
    t.assign(m, 0);
    rep(j, 0, n) if (i & (1 << j)) {
      rep(k, 0, m) t[k] += a[j][k];
      cost += c[j];
    }
    mn = 1e7;
    rep(j, 0, m)
      mn = min(mn, t[j]);
    if (mn >= x)
      ans = min(ans, cost);
  }

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

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H), debug_out(T...);}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int L;
    cin>>L;
    double ans=(L*L*L)/27.0;
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3800
h,n = map(int,input().split())

ab_input = [list(map(int,input().split())) for i in range(n)]
max_d = max(a for a,b in ab_input)
#配るdp
dp =[0]*(h+max_d)
for i in range(1,h+max_d):
    dp[i]=min(dp[i-a]+b for a,b in ab_input)
print(dp[h])

Measured memory_bytes: 3664
len, n = io.read("*n", "*n", "*l")
s = io.read()
pos = 1
t = {}
cur = 0
while(pos <= len) do
    st, lst = string.find(s, "AC", pos)
    if(st == nil) then st = len + 1 end
    for i = pos, st - 1 do
        t[i] = cur
    end
    cur = cur + 1
    t[st] = cur
    pos = st + 1
end
for i = 1, n do
    x, y = io.read("*n", "*n")
    if(x == 1) then
        print(t[y - 1])
    else
        print(t[y-1] - t[x-1])
    end
end

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

typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    vector<ll>v(n);
    ll sum=0;
    for(auto &x:v)
    {
        cin>>x;
        sum+=x;
    }
    ll mx=*max_element(v.begin(),v.end());
    sum-=(mx);
    sum+=(mx/2);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll a[100010], b[100010];
    map<lpair, ll> mp;
    rep(i,0,M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        mp[make_pair(a[i], b[i])]++;
    }
    ll dist[310][310] = {};
    rep(i,0,N){
        rep(j,0,N){
            dist[i][j] = INF;
            if(i == j) dist[i][j] = 0;
        }
    }
    rep(i,0,M){
        dist[a[i]][b[i]] = 1;
    }
    rep(k,0,N){
        rep(i,0,N){
            rep(j,0,N){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector<ll> ans[310];
    rep(i,0,N){
        rep(j,0,N){
            if(dist[i][j] != INF && dist[j][i] != INF) ans[i].push_back(j+1);
        }
    }
    rep(i,0,N){
        ll sz = ans[i].size();
        rep(j,0,sz){
            cout << ans[i][j] << " \n"[j==sz-1];
        }
    }

    
}


Measured memory_bytes: 11752
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
	int n;
	int table[17][17];

	//freopen("input.txt", "r", stdin);

	memset(table, -1, sizeof(table));

	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
	{
		int num;

		scanf("%d", &num);

		for (int j = 0; j < num; j++)
		{
			int a, b;

			scanf("%d %d", &a, &b);

			table[i][a] = b;
		}
	}

	int ub;

	ub = (int)pow(2.0, n);

	int lmax = 0;

	for (int i = 0; i < ub; i++)
	{
		int truth[17];
		int cnt = 0;

		int temp;

		temp = i;

		for (int j = 1; j <= n; j++)
		{
			truth[j] = temp % 2;

			cnt += temp % 2;

			temp /= 2;

		}

		bool valid = true;

		for (int j = 1; j <= n; j++)
		{
			if (truth[j])
			{
				for (int k = 1; k <= n; k++)
				{
					if (table[j][k]!=-1 && truth[k] != table[j][k])
					{
						valid = false;

						break;
					}
				}
			}

			if (!valid)
			{
				break;
			}
		}

		/*
		if (valid)
		{
			for (int j = 1; j <= n; j++)
			{
				for (int k = 1; k <= n; k++)
				{
					if (!truth[j])
					{
						if (truth[k] && table[k][j] != -1 && table[k][j])
						{
							valid = false;

							break;
						}
					}
				}

				if (!valid)
				{
					break;
				}
			}
		}
		*/

		if (valid&&cnt > lmax)
		{
			lmax = cnt;
		}
	}

	printf("%d\n", lmax);

	return 0;
}

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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 3007
#define DIMM 100007
#define INF 1000000000007.0
#define X (ll)(1<<32)
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n;
ld a[DIM],dp[DIM][DIM];
ld res;

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    dp[0][0]=1.0;
    dp[1][1]=a[1];
    dp[1][0]=1.0-a[1];
    for(int i=2;i<=n;i++){
     dp[i][0]=dp[i-1][0]*(1.0-a[i]);
     for(int j=1;j<=i;j++)dp[i][j]=(dp[i-1][j-1]*a[i])+(dp[i-1][j]*(1.0-a[i]));
    }
    for(int j=0;(2*j)<=n;j++)res+=dp[n][n-j];
    cout<<fixed<<setprecision(10)<<res<<endl;
    return 0;
}


Measured memory_bytes: 139904
#include <cstdlib>
#include<iostream>
#include<vector>
#include<iterator>
#include<string>
#include<algorithm>
using namespace std;


int main(void)
{

    int i,j;
    cin>>j;
    int a[j];
    for(i=0;i<j;i++)
    {
        cin>>a[i];
    }

    int count=0;

    for(i=1;i<j-1;i++)
    {
        int c=i-1;
        int d=i+1;
        if(((a[c]>a[i])&&(a[i]>a[d]))||((a[c]<a[i])&&(a[i]<a[d])))
        {
         count++; 
        }
    }
    cout<<count<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
use proconio::marker::Usize1;
use proconio::*;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };
    input! {
        t: [Usize1; d],
    };
    // let mut t = vec![26; d];
    let mut lasts = [-1; 26];
    let mut score = 0;

    for i in 0..d {
        score += calc_score(i, t[i], &c, &s, &mut lasts);
        lasts[t[i]] = i as i64;
        println!("{}", score);
    }
    // for i in 0..d {
    //     let mut high = -10000;
    //     for j in 0..26 {
    //         let tmp = calc_score(i, j, &c, &s, &mut lasts);
    //         if tmp > high {
    //             high = tmp;
    //             t[i] = j;
    //             lasts[j] = i as i64;
    //         }
    //     }

    //     score += high;
    // }

    // for &v in &t {
    //     println!("{}", v + 1);
    // }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}


Measured memory_bytes: 2224
import sys

n = int(sys.stdin.readline())
values = []

dp = [[0,0,0] for i in range(n+1)]


for i in range(1,n+1):
    values = list(map(int, sys.stdin.readline().split()))
    
    if i == 1:
        dp[1] = values
        
    else:
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + values[0]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + values[1]
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + values[2]
        
print(max(dp[n]))

Measured memory_bytes: 22772
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

double dmax(double x, double y){
    if(x < y) return y;
    return x;
}

int pcount = 0;
int qcount = 0;

void foo(int n,int* a, int p, int q, int keta){
    int i, j;
    //printf("keta:%d n:%d\n", keta, n);
    if(keta == n){
        int tmp = 0;
        for(i=n-1;i >= 0;i--){
            //printf("%d %d\n", i, tmp);
            tmp *= 10;
            tmp += a[i];
        }
        //printf("%d\n", tmp);
        if(tmp < p) pcount++;
        if(tmp < q) qcount++;

        return;
    }else{
        for(i=1;i <= n; i++){
            a[keta] = i;
            int flag = 0;
            for(j=0;j<keta;j++){
                if(a[keta] == a[j]) flag = 1;
            }
            if(flag) continue;

            foo(n, a, p, q, keta+1);
        }
    }
}



int main() {
    int i,j;
    int n;

    scanf("%d", &n);

    int tmpp,p = 0;
    int tmpq,q = 0;

    for(i = 0 ;i < n; i++){
        scanf("%d", &tmpp);
        p *= 10;
        p += tmpp;
    }


    for(i = 0 ;i < n; i++){
        scanf("%d", &tmpq);
        q *= 10;
        q += tmpq;
    }

    //printf("%d %d\n", p, q);
    int* a = (int*)malloc(sizeof(int) * n);
    foo(n, a, p, q, 0);

    printf("%d", abs(pcount-qcount));
    
    return 0;

}

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

int a[12][12];
int main() {
    long long N, M, X;
    cin >> N >> M >> X;
    vector<int> c(N);
    rep(i, N) {
        cin >> c[i];
        rep(j, M) { cin >> a[i][j]; }
    }

    int ans = 100000000;
    rep(s, 1 << N) {
        int cost = 0;
        vector<int> d(M);
        rep(i, N) {
            if (s >> i & 1) {
                cost += c[i];
                rep(j, M) { d[j] += a[i][j]; }
            }
        }
        bool ok = true;
        rep(j, M) {
            if (d[j] < X) {
                ok = false;
            }
        }
        if (ok) {
            ans = min(ans, cost);
        }
    }
    if (ans == 100000000) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
n = int(input())
k = int(input())
d = 2**15
for i in range(1 << n):
    c = 1
    for j in range(n):
        if ((i >> j) & 1) == 1:
            c *= 2
        else:
            c += k
    else:
        d = min(c,d)
print(d)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>bri(N + 1, 0);
  bri[0] = 0;
  int key = 0;
  int ans = 0;
  int last = 0;
  for (int i = 1; i <= N; i ++) {
    int a;
    cin >> a;
    if (a == key + 1) {
      ans += i - last - 1;
      key ++;
      last = i;
    }
  }
  ans += N - last;
  if (ans == N) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    cout<<min(A,B)<<" "<<max(0LL,A+B-N)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
s = str(input())

input_array = list(s)

# patarn 0
correct_data = []
patarn0 = 0
for i in range(len(input_array)):
  if (i % 2) == 0:
    correct_data.append("0")
  else:
    correct_data.append("1")

for i in range(len(input_array)):
  if correct_data[i] != input_array[i]:
    patarn0 += 1


# patarn 1
correct_data = []
patarn1 = 0
for i in range(len(input_array)):
  if (i % 2) == 0:
    correct_data.append("1")
  else:
    correct_data.append("0")


for i in range(len(input_array)):
  if correct_data[i] != input_array[i]:
    patarn1 += 1


if patarn1 > patarn0:
  print(patarn0)
else:
  print(patarn1)


Measured memory_bytes: 4852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#define PI acos(-1.0)
using namespace std;

int a,b,x;

int main()
{
    cin>>a>>b>>x;
    int v=a*a*b;
    double angel;
    if(x>=v/2.0)
    {
        angel=atan((v-x)*2/(1.0)/a/a/a);
        angel=(double)(angel*180.0/PI);
    }
    else if(x<v/2.0)
    {
        angel=atan(b/(2*x*(1.0)/a/b));
        angel=(double)(angel*180.0/PI);
    }
    printf("%.10f",angel);
}


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

int main(){
  
  int result,i,j,n,m,c[21],t[50001];  
  
  cin >> n >> m;

  for(i = 0; i < m; i++){
    cin >> c[i];
  }
 
  for(j = 0; j <= n; j++){
    t[j]=10001;
  }
  
  t[0]=0;
  
  for(i = 0; i < m; i++){
    for(j = c[i]; j <= n; j++){
      t[j]=min(t[j],t[j-c[i]]+1);
      // cout <<"j" << j << " " << "t[" << j << "]" <<"=" << t[j] << " ";
    }
    //  cout << endl;
  }  
 
  result = t[n];

  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 1356
object Main extends App {
  val nkInput = scala.io.StdIn.readLine()
  val nkArray =  nkInput.split(" ").map(_.toInt).toVector
  val n = nkArray(0)
  var k = nkArray(1)

  val aInput = scala.io.StdIn.readLine()
  val aArray =  aInput.split(" ").map(_.toLong).toVector

  var hikakuMotoIndex = 0

  (k to n - 1).foreach { i =>
    val hikakuSaki = aArray(i)
    val hikakuMoto = aArray(hikakuMotoIndex)

    if (hikakuSaki > hikakuMoto) {
      println("Yes")
    } else {
      println("No")
    }
    hikakuMotoIndex = hikakuMotoIndex + 1
  }

}

Measured memory_bytes: 88264
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
int n,m;
vector<pair<int,int> >g[305];
long long ans,dp[305][305][305];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		g[r].push_back(make_pair(l,x));
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int k=0;k<=n;k++)
	{
		int r=max(i,max(j,k));
		for(int l=0;l<g[r].size();l++)if((i>=g[r][l].first)+(j>=g[r][l].first)+(k>=g[r][l].first)!=g[r][l].second)dp[i][j][k]=0;
		if(r==n)ans=(ans+dp[i][j][k])%md;
		else
		{
			dp[r+1][j][k]=(dp[r+1][j][k]+dp[i][j][k])%md;
			dp[i][r+1][k]=(dp[i][r+1][k]+dp[i][j][k])%md;
			dp[i][j][r+1]=(dp[i][j][r+1]+dp[i][j][k])%md;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 219392
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
int dp[MAXN + 5];
int main() {
	for(int i=0;i<=MAXN;i++)
		dp[i] = i;
	int now = 6;
	while( now <= MAXN ) {
		for(int i=now;i<=MAXN;i++)
			dp[i] = min(dp[i], dp[i-now] + 1);
		now *= 6;
	}
	now = 9;
	while( now <= MAXN ) {
		for(int i=now;i<=MAXN;i++)
			dp[i] = min(dp[i], dp[i-now] + 1);
		now *= 9;
	}
	int N;
	scanf("%d", &N);
	printf("%d\n", dp[N]);
}

Measured memory_bytes: 512
mod = 1e9+7
n, m = [int(i) for i in input().strip().split()]

oks = [True]*(n+1)
for i in range(m):
  a = int(input())
  oks[a] = False


dp = [0]*(n+1)
dp[0] = 1
for i in range(1, n+1):
  if oks[i-1]:
    dp[i] += dp[i-1]
    dp[i] %= mod
  if i-2>-1 and oks[i-2]:
    dp[i] += dp[i-2]
    dp[i] %= mod
print(int(dp[n]))

Measured memory_bytes: 6900
A, B, K = (map(int, input().split()))

def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a
	
num = gcd(A, B)
ans = []
for i in range(num, 0, -1):
  if num % i == 0:
    	ans.append(i)
      
print(ans[K - 1])

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 5010
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n,m;
char s[MAXN];
ll dp[MAXN][MAXN];
int main(){
	SF("%d",&m);
	SF("%s",s);
	n=strlen(s);
	if(n>m){
		PF("0");
		return 0;
	}
	dp[0][0]=1;
	for(int k=1;k<=m;k++)
		for(int i=0;i<=m;i++){
			if(i!=m)
				dp[i][k]+=2ll*dp[i+1][k-1];
			if(i!=0)
				dp[i][k]+=dp[i-1][k-1];
			if(i==0)
				dp[i][k]+=dp[i][k-1];
			dp[i][k]%=MOD;
		//	PF("%d %d %lld\n",i,k,dp[i][k]);
		}
	PF("%lld",dp[n][m]);
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(long long int i = 0; i < n; i ++)
#define forn1(i, n)            for(long long int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

    //freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    ll n;cin>>n;
	string s;cin>>s;
	ll ans = 1;
	ll above = 0;
	forn(i,2*n){
		if(s[i] == 'W'){
			if((above&1) == 1)above++;
			else{
				ans *= above;
				ans %= MOD;
				above--;
			}
		}
		else{
			if((above&1) == 0)above++;
			else{
				ans *= above;
				ans %= MOD;
				above--;
			}
		}	
	}        
	if(above != 0)ans = 0;
	forn1(i,n){
		ans *= i;
		ans %= MOD;
	}
	cout<<ans;
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }


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

    cin >> N;
    
    if(N%2 == 0){
        cout << N << endl;
    }else{
        cout << 2 * N << endl;
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
S = input()

tmp = []
for s in S:
    if ord(s)+n > ord('Z'):
        tmp.append(ord('A')+(ord(s)+n)%ord('Z')-1)
    else:
        tmp.append(ord(s)+n)

ans = ''
for i in tmp:
    ans += chr(i)
print(ans)

Measured memory_bytes: 73584
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int x; cin >> x;
        puts(x >= 30 ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 3628
import sys
import math


def main():
    """
    2 <= K <= N <= 10^5
    1 <= ai <= N
    1 <= i <= N
    """
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    ans = f_K(N, K, A)
    #ans = editorial(N, K, A)
    print(ans)


def test_examples():
    nka_ans = [
        (4, 3, [2, 3, 1, 4], 2),
        (3, 3, [1, 2, 3], 1),
        (8, 3, [7, 3, 1, 8, 4, 6, 2, 5], 4),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def test_ans():
    nka_ans = [
        (5, 2, [1, 2, 3, 4, 5], 4),
        (5, 3, [1, 2, 3, 4, 5], 2),
        (5, 2, [5, 4, 3, 2, 1], 4),
        (5, 3, [5, 4, 3, 2, 1], 2),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def f_K(N, K, A):
    """
    最初に置く範囲は、 1_idx - K + 1 から 1_idx
    """
    idx = [i for i, a in enumerate(A) if a == 1][0]
    left_idx = max(0, idx - K)
    ans = float("inf")
    for i in range(left_idx, idx + 1):
        left = i
        right = max(0, N - left - K)
        tmp = (left + (K - 1) - 1) // (K - 1)
        tmp += 1
        tmp += (right + (K - 1) - 1) // (K - 1)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right
 
//#define int ll
//#define int long long
 
 array<int,200010> a;
signed main()
{
  int n, k;
  cin>>n>>k;
  REP(i,n){//backet law
    int t;cin>>t;
    ++a[t];
  }
  
  sort(&a[0],&a[n+1]);//sort(begin,end)でfirst~lastまでがsortされるから+1
  
  int ans = 0;
  //{0,1,1,2,2,3}の時n-k=変更したい玉の数より6-2なら{0+1+1+2}のように変更されるやつが足される
  for(int i = 0; i <= n-k; ++i)
    ans += a[i];
  
    cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

def bisA(x,vec):
   left_index_OK=-1
   right_index_NG=len(vec)
   while(left_index_OK<right_index_NG-1):
      mid=int((left_index_OK+right_index_NG)/2)
      if x > vec[mid]:
         left_index_OK=mid
      else:
         right_index_NG=mid
   #print(vec[left_index_OK])
   return left_index_OK

def bisC(x,vec):
   left_index_NG=-1
   right_index_OK=len(vec)
   while(left_index_NG<right_index_OK-1):
      mid=int((left_index_NG+right_index_OK)/2)
      if x < vec[mid]:
         right_index_OK=mid
      else:
         left_index_NG=mid
   #print(vec[right_index_OK])
   return right_index_OK

alltypes=0
atypes=0
ctypes=0
for i in range(N):
   b=B[i]
   if b<=A[0]:
      continue
   else:
      atypes=bisA(b,A)+1
      ctypes=len(C)-bisC(b,C)
      alltypes+=atypes*ctypes

print(alltypes)

Measured memory_bytes: 22720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>

int main() {
	while (1) {
		int N;
		cin >> N;
		if (N == 0) {
			return 0;
		}
		vector<lint>A(N);
		rep(i, N) {
			cin >> A[i];
		}
		vector<lint>S(N);
		S[0] = A[0];
		for (int i = 1; i < N; i++) {
			S[i] = S[i - 1] + A[i];
		}
		reverse(S);
		S.push_back(0);
		reverse(S);
		lint ans = -10000000000;
		for (int i = 1; i < N + 1; i++) {
			for (int j = 0; j < N + 1; j++) {
				if (j < i) {
					ans = max(ans, S[i] - S[j]);
				}
			}
		}
		cout << ans << endl;
	}
}


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

int main(void)
{
	int n;
	cin >> n;
	vector<int>res(n);
	for (int i = 0; i < n; i++)cin >> res[i];
	sort(res.begin(), res.end());
	vector<int>::iterator end=unique(res.begin(), res.end());
	res.erase(end, res.end());
	for (vector<int>::iterator it = res.begin(); it != res.end(); it++)
		if (it == res.begin())cout << *it;
		else cout << " " << *it;
	cout << endl;
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int r, g, b; cin >> r >> g >> b;
  if((10*g+b)%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3568
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>

using namespace std;

constexpr auto DIV = 1000000007ull;
using ULL = decltype(0ull);

void Func(ULL& r, ULL& v) {
  r += v / 2;
  v = v % 2;
}

int main() {
  ULL n, result = 0;
  cin >> n;
  if (n != 1) {
    std::vector<ULL> table(n, 0);
    cin >> table[0];
    Func(result, table[0]);
    for (int i = 1; i < n; ++i) {
      cin >> table[i];
      if (table[i] != 0) {
        if (table[i - 1] == 1) {
          --table[i - 1], --table[i];
          ++result;
        }
        Func(result, table[i]);
      }
    }
  }
  else if (n == 1) {
    int val;
    cin >> val;
    result = val / 2;
  }
  cout << result << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200020
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(k, n);
	int a[lim5] = {};
	int s[lim5] = {};
	rep(i, n) {
		cin >> a[i];
		if (i) {
			s[i - 1] = a[i] - a[i - 1];
		}
	}
	s[n - 1] = a[0] + k - a[n - 1];

	sort(s, s + n);

	int ans = 0;
	rep(i, n - 1) {
		ans += s[i];
	}
	out(ans);

	return 0;
}


Measured memory_bytes: 1792
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

a=[]
r=[]
for i in range(5):
  s=ii()
  a.append(s)
  r_=s%10
  if r_==0:
    r_=10
  r.append(r_)
  
ans=0
while len(r)>1:
  k=r.index(max(r))
  remain=r.pop(k)
  A=a.pop(k)
  #print(A)
  ans+=A-remain+10
  
print(ans+a[0])

Measured memory_bytes: 61984
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a) % b << endl;

  return 0;
}


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

//型定義
typedef long long ll;

//定数
const ll INF=1e+9+7;
const ll MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> x(n),y(m);
    REP(i,n){
        cin>>x[i];
    }
    REP(i,m){
        cin>>y[i];
    }

    vector<ll> sum_x(n+1,0),sum_y(m+1,0);
    REP(i,n){
        sum_x[i+1]=sum_x[i]+x[i];
        sum_x[i+1]%=MOD;
    }

    REP(i,m){
        sum_y[i+1]=sum_y[i]+y[i];
        sum_y[i+1]%=MOD;
    }

    ll tmp_x=(x[n-1]-x[0])%MOD;
    ll tmp_y=(y[m-1]-y[0])%MOD;
    REP2(i,1,n-1){
        tmp_x+=sum_x[n]-sum_x[i+1]-sum_x[i];
        while(tmp_x<0){
            tmp_x+=MOD;
        }
        tmp_x%=MOD;
    }

    REP2(i,1,m-1){
        tmp_y+=sum_y[m]-sum_y[i+1]-sum_y[i];
        while(tmp_y<0){
            tmp_y+=MOD;
        }
        tmp_y%=MOD;
    }

    ll ans=tmp_x*tmp_y;
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 6428
import Foundation

let N = Int(readLine()!)
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

input.sortInPlace { $0 > $1 }

var sum = 0
for i in input {
    sum += i
}

if input[0] < sum - input[0] {
    print("Yes\n")
} else {
    print("No\n")
}


Measured memory_bytes: 1152
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local N = read.n()
local D = read.N(N)
local sum = 0
for i=1,N-1 do
    for j=i+1,N do
        sum = sum + D[i] * D[j]
    end
end
print(sum)

Measured memory_bytes: 888
x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True);b.sort(reverse=True);c.sort(reverse=True)
ng = 10**12
ok = 0
def check(chk):
    cnt=0
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k]<chk:
                    break
                cnt+=1
                if cnt>K:
                    return True
    return False
while ng-ok>1:
    if check((ok+ng)//2):ok=(ok+ng)//2
    else:ng=(ok+ng)//2
cnt=0
l=[]
for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k]<ok:
                    break
                l.append(a[i]+b[j]+c[k])
l.sort(reverse=True)
for i in range(K):print(l[i])

Measured memory_bytes: 189420
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int judge(int i,int n,int variable,vector< vector<int> > &v)
{
  for(int j=0;j<v[variable].size();++j){
    if(i==v[variable][j]){
      return 1;
      break;
    }
  }
  return 0;
}
int main()
{
  int n,u,k,vv;
  cin>>n;
  vector< vector<int> > v(n),a(n,vector<int>(n));
  for(int variable=0;variable<n;++variable){
    cin>>u>>k;
    for(int i=0;i<k;++i){
      cin>>vv;
      v[variable].push_back(vv);
    }
  }
  for(int variable=0;variable<n;++variable)
    for(int i=1;i<=n;++i)
      a[variable][i-1]=judge(i,n,variable,v);
  for(int variable=0;variable<n;++variable){
    for(int i=0;i<n;++i){
        printf("%d%c", a[variable][i], i == n - 1 ? '\n' : ' ');
    }
  }
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "CAUTION: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

constexpr int MAX_N = 2000003;
Mint fact[MAX_N], inv[MAX_N];

void init_fact() {
	fact[0] = inv[0] = 1;
	for (ll i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * Mint(i);
		inv[i] = fact[i].inv();
	}
}

// aCb
Mint C(int a, int b) {
	if (a < b) return 0;
	Mint res = fact[a];
	res *= inv[b];
	res *= inv[a - b];
	return res;
}

int main() {
	init_fact();
	int x, y; cin >> x >> y;
	int a = (2 * x - y) / 3;
	int b = x - 2 * a;
	if (2 * a + b != x || a + 2 * b != y) {
		cout << 0 << endl;
		return 0;
	}
	if (a < 0 || b < 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << C(a + b, a) << endl;
	return 0;
}


Measured memory_bytes: 31996
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int K;
    cin >> K;
    int ans = 0;
    FOR (i, 1, K + 1) FOR (j, 1, K + 1) FOR (k, 1, K + 1) {
        ans += gcd(i, gcd(j, k));
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3648