akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> diff_weight;

    UnionFind(int n) {
        init(n);
    }

    void init(int n) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        rep(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

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

    ll weight(int x) {
        root(x);
        return diff_weight[x];
    }

    ll diff(int x, int y) {
        return weight(y) - weight(x);
    }

    bool merge(int x, int y, ll w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
};

int main() {
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        ll l, r, d; cin >> l >> r >> d; l--; r--;
        if(uf.issame(l, r) && d != uf.diff(l, r)) {
            cout << "No" << endl;
            return 0;
        }
        uf.merge(l, r, d);
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4848
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
bool jsosu(int x){
  for(int j=2;j<x;j++){
    if(x % j==0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=6;i<55555;i+=5){
    if(jsosu(i)){
      vec.push_back(i);
      if(vec.size() >= n){
        break;
      }
    }
  }

  for(auto itr = vec.begin();itr != vec.end();itr++){
    cout << *itr << " ";
  }
}


Measured memory_bytes: 256
/**
Code by Nitin1184
**/
# include <bits/stdc++.h>
# define ll long long
# define pi 3.14159265358979323846
# define M 1000000007
# define pb push_back
# define mp make_pair
# define ff first
# define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if(n%1000)
        cout<<1000-n%1000<<endl;
    else
        cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

bool eval(int n, int set) {
    for (int v = n; v > 0; v /= 10) {
        int d = v % 10;
        if (set & (1 << d)) {
            return false;
        }
    }
    return true;
}

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

    int set = 0;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        set |= 1 << d;
    }

    int ans = -1;
    for (int v = n;; v++) {
        if (eval(v, set)) {
            ans = v;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int M, K;
  std::cin >> M >> K;
  if(M==0){
    if(K==0) std::cout << "0 0" << '\n';
    else std::cout << -1 << '\n';
  }else if(M==1){
    if(K==0) std::cout << "1 1 0 0" << '\n';
    else std::cout << -1 << '\n';
  }else if((1<<(M))<=K){
    std::cout << -1 << '\n';
  }else{
    for(int i=0;i<(1<<M);i++){
      if(i!=K) std::cout << i << " ";
    }
    std::cout << K << " ";
    for(int i=(1<<M)-1;i>=0;i--){
      if(i!=K) std::cout << i << " ";
    }
    std::cout << K << '\n';
  }
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(){

}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
        sum += v.at(i);
    }
    sort(v.rbegin(), v.rend());
    cerr << v.at(M-1) * 4*M << endl;
    if(v.at(M-1) * 4*M >= sum){
        cout << "Yes" << endl;
    } else { 
        cout << "No" << endl;
    }

         
}


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

typedef long long ll;
#define INF INT_MAX

bool comp(int a,int b){
    return a > b;
}

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

    int N , K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0 ; i < N ; i++)
        cin >> v[i];
    sort(v.begin(),v.end(),comp);

    ll ans = 0;
    for(int i = K ; i < N ; i++){
        ans += v[i];
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  while(n--) {
    int dx,dy;
    int x=0,y=0;
    int m = 0;
    int ansx = 0, ansy = 0;
    while(cin>>dx>>dy,dx+dy) {
      x+=dx;
      y+=dy;
      if (x*x+y*y>=m) {
        if (x*x+y*y>m || ansx<x) {
          ansx = x;
          ansy = y;
        }
        m = x*x+y*y;
      }
    }
    printf("%d %d\n", ansx,ansy);
  }
}

Measured memory_bytes: 0
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main()
{
	auto nx = readln.split.map!( to!int );
	auto ms = nx[ 0 ].iota.map!( a => readln.strip ).map!( to!int ).array;
	writeln( solve( nx[ 1 ], ms ) );
}

int solve( in int x, in int[] ms )
{
	return ( cast(int) ms.length ) + ( ( x - ms.sum ) / ms.reduce!( min ) );
}

unittest
{
	assert( solve( 1000, [ 120, 100, 140 ] ) == 9 );
	assert( solve( 360, [ 90, 90, 90, 90 ] ) == 4 );
	assert( solve( 3000, [ 150, 130, 150, 130, 110 ] ) == 26 );
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {
        public static void Main(String[] args) {
            int n;
            while ((n = int.Parse(Console.ReadLine())) != 0) {
                int max_dist = -1;
                int num_patient = -1;
                for (int i = 0; i < n; i++) {
                    String[] strs = Console.ReadLine().Split(' ');
                    int dist = int.Parse(strs[1]) + int.Parse(strs[2]);
                    if (dist > max_dist) {
                        max_dist = dist;
                        num_patient = int.Parse(strs[0]);
                    }
                }
                Console.WriteLine(num_patient+" "+max_dist);
            }
        }      
    }
}

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

char A[3][3];

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

    for(int i=0;i<3;++i){
        cout<<A[i][i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

string S;
int main(){
    int n;
    cin>>n>>S;
    int r=0,b=0;
    for(auto s:S){
        if(s=='R'){
            r++;
        }else{
            b++;
        }
    }
    if(r>b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    /* 文字列sのABC数を「sのうち３文字に丸をつけ、
       丸をつけた文字を左から読むとABCとなるようにする方法」と言い換える*/

    vector<vector<ll>> dp(n+1, vector<ll>(4));  /* dp[i+1][j] : i文字目(iは0-index)までの処理(?の置換と丸つけ)をすでに行っていて、
                                                   これまでにj個丸をつけているときのsの残りの部分に対する処理を行う方法の数のmodでの剰余 */

    // n文字目までに３個丸をつけ終わっているのであとは何もしないの1通り
    dp[n][3] = 1LL;
    for(int i = n-1; i >= 0; i--) {
        for(int j = 3; j >= 0; j--) {
            // 丸を３個つけ終わった場合
            if(j == 3) {
                int m0 = 1;
                if(s[i] == '?') {
                    m0 = 3;
                }
                // i文字目が?だったら3倍、それ以外は1倍 
                dp[i][j] = m0*dp[i+1][j];
            }
            // まだ丸を３個つけ終わっていない場合
            else {
                // 以下の条件を満たさないときは、丸をつけない場合1倍、つける場合もう無理なので0倍する
                int m1 = 1;
                int m2 = 0;
                string x = "ABC";
                // s[i]が?のときは、丸をつけない場合は3倍、つける場合は1倍する
                if(s[i] == '?') {
                    m1 = 3;
                    m2 = 1;
                }
                // 丸をつける場合、s[i]がABCのj文字目のときも1倍する
                else if(s[i] == x[j]) {
                    m2 = 1;
                }
                // 右辺の1項目はi文字目に丸をつけない場合で、2項目は丸をつける場合
                dp[i][j] = m1*dp[i+1][j] + m2*dp[i+1][j+1];
            }
            dp[i][j] %= mod;
        }
    }

    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 7424
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		double[] a = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextDouble();
		}
		
		int m = nextInt();
		long k = nextLong();
		
		int[] b = new int[m];
		
		for (int i = 0; i < m; i++) {
			b[i] = nextInt() - 1;
		}
		
		int[] perm = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			perm[i] = i;
		}
		
		for (int pos : b) {
			pos--;
			int tmp = perm[pos];
			perm[pos] = perm[pos + 1];
			perm[pos + 1] = tmp;
		}
		
		int[] res = pow(perm, k);
		
		double[] deltas = new double[n - 1];
		for (int i = 0; i < n - 1; i++) {
			int idx = res[i];
			deltas[i] = a[idx + 1] - a[idx];
		}
		
		double tmp = a[0];
		out.println(tmp);
		for (double d : deltas) {
			tmp += d;
			out.println(tmp);
		}
	}
	
	int[] mult(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
//			c[i] = b[a[i]]; // or???
			c[i] = a[b[i]];
		}
		return c;
	}
	
	int[] pow(int[] p, long k) {
		int[] ret = new int[p.length];
		for (int i = 0; i < p.length; i++) {
			ret[i] = i;
		}
		
		for (; k > 0; k >>= 1) {
			if ((k & 1) == 1) {
				ret = mult(ret, p);
			}
			p = mult(p, p);
		}
		return ret;
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 49192
n,MA,MB=map(int,input().split())
INF=10**10
A=[]
B=[]
C=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if MA*b-MB*a>0:
    A.append([MA*b-MB*a,c])
  elif MA*b-MB*a<0:
    B.append([MB*a-MA*b,c])
  else:
    C.append(c)
dp1=[[INF]*10010 for i in range(len(A)+1)]
for i in range(1,len(A)+1):
  for j in range(1,10010):
    if j<A[i-1][0]:
      dp1[i][j]=dp1[i-1][j]
    elif j==A[i-1][0]:
      dp1[i][j]=min(A[i-1][1],dp1[i-1][j])
    else:
      dp1[i][j]=min(dp1[i-1][j],dp1[i-1][j-A[i-1][0]]+A[i-1][1])
dp2=[[INF]*10010 for i in range(len(B)+1)]
for i in range(1,len(B)+1):
  for j in range(1,10010):
    if j<B[i-1][0]:
      dp2[i][j]=dp2[i-1][j]
    elif j==B[i-1][0]:
      dp2[i][j]=min(B[i-1][1],dp2[i-1][j])
    else:
      dp2[i][j]=min(dp2[i-1][j],dp2[i-1][j-B[i-1][0]]+B[i-1][1])
ans=INF
for i in range(10010):
  a=dp1[-1][i]+dp2[-1][i]
  if a<ans:
    ans=a
for i in range(len(C)):
  if C[i]<ans:
    ans=C[i]
if ans<INF:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 7028
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

import itertools
import bisect

N, M, K = ri_()
A = [0] + list(itertools.accumulate(ri_()))
B = list(itertools.accumulate(ri_()))
ans = 0
for i in range(N + 1):
    if K - A[i] >= 0:
        j = bisect.bisect_right(B, K - A[i])
        ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 45172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var k = cin.nextInt();

            var que = new Queue<long>();
            for (int i = 1; i <= 9; i++)
            {
                que.Enqueue(i);
            }

            for (int i = 0; i < k-1; i++)
            {
                var x = que.Dequeue();
                if (x % 10 != 0) que.Enqueue(10 * x + x % 10 - 1);
                que.Enqueue(10 * x + x % 10);
                if (x % 10 != 9) que.Enqueue(10 * x + x % 10 + 1);                
            }
            
            Console.WriteLine(que.Dequeue());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 15200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <unordered_map>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

int N,K;
ll x[100500];
ll ans = 1e18;
int main(){
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) scanf("%lld",x+i);
	for(int i=1;i<=N-K+1;i++){
		ll L = x[i], R = x[i+K-1];
		if( L <= 0 && R <= 0 ){
			ans = min(ans, abs(L));
		}
		else if( L <= 0 && R >= 0 ){
			ans = min(ans, abs(L)*2 + R);
			ans = min(ans, abs(L) + 2*R);
		}
		else{
			ans = min(ans, R);
		}
	}
	printf("%lld\n",ans);
}













Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    double C;
    scanf("%d %d %lf", &a, &b, &C);
    C *= M_PI/180;

    double S=0.5*a*b*sin(C);
    double L=a+b+sqrt(a*a+b*b-2*a*b*cos(C));
    double h=b*sin(C);

    printf("%.12f\n", S);
    printf("%.12f\n", L);
    printf("%.12f\n", h);
    return 0;
}

Measured memory_bytes: 3068
# numが100で何回割れるか
def getDevide100Count(num: int):
    n = 0
    while num % 100 == 0:
        num = num / 100 
        n += 1
    return n


d, n = map(int, input().split())
count = 0
i = 0
while count != n:
    i += 1
    if getDevide100Count(i) == d:
        count += 1

print(i)

Measured memory_bytes: 71612
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

for i in range(N):
    a = min(A[i], B[i])
    b = min(A[i+1], B[i] - a)
    A[i+1] -= b
    ans += (a + b)

print(ans)

Measured memory_bytes: 19116
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    int n,x;
    cin>>n;
    vector<int>a(n);
    map<int,int>b;
    vector<int>c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(int i=0;i<n;i++){
        cin>>x;
        b[i]=x;
    }
    for(int i=0;i<n-1;i++)cin>>c[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(i==0){
            ans+=b[a[i]];
        }
        else{
            ans+=b[a[i]];
            if(a[i]==a[i-1]+1){
                ans+=c[a[i-1]];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 45


int N,K;
ll MIN,MAX;
ll POW[SIZE];
ll coin[SIZE];
vector<ll> A[SIZE],B[SIZE];


int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %lld %lld",&N,&K,&MIN,&MAX);

	for(int i = 0; i < N; i++){

		scanf("%lld",&coin[i]);
	}

	if(N == 1){

		ll ans = 0;
		for(int i = 0; i < N; i++){

			if(coin[i] >= MIN && coin[i] <= MAX){

				ans++;
			}
		}

		printf("%lld\n",ans);
		return 0;
	}

	vector<ll> LEFT,RIGHT;
	for(int i = 0; i < N/2; i++){

		LEFT.push_back(coin[i]);
	}
	for(int i = N/2; i < N; i++){

		RIGHT.push_back(coin[i]);
	}

	for(int state = 0; state < POW[LEFT.size()]; state++){

		int num = 0;
		ll sum = 0;

		for(int loop = 0; loop < LEFT.size(); loop++){
			if(state & POW[loop]){

				num++;
				sum += LEFT[loop];
			}
		}
		A[num].push_back(sum);
	}

	for(int i = 0; i < LEFT.size(); i++){

		sort(A[i].begin(),A[i].end());
	}

	for(int state = 0; state < POW[RIGHT.size()]; state++){

		int num = 0;
		ll sum = 0;

		for(int loop = 0; loop < RIGHT.size(); loop++){
			if(state & POW[loop]){

				num++;
				sum += RIGHT[loop];
			}
		}
		B[num].push_back(sum);
	}

	for(int i = 0; i < RIGHT.size(); i++){

		sort(B[i].begin(),B[i].end());
	}

	int limit = min(K,(int)LEFT.size());

	ll ans = 0;
	int L,R,left,right,mid;

	for(int a = 0; a <= limit; a++){

		int b = K-a;
		if(B[b].size() == 0)continue;

		for(int i = 0; i < A[a].size(); i++){

			L = B[b].size();
			left = 0,right = B[b].size()-1,mid = (left+right)/2;
			while(left <= right){

				if(A[a][i]+B[b][mid] >= MIN){

					L = mid;
					right = mid-1;
				}else{

					left = mid+1;
				}
				mid = (left+right)/2;
			}

			if(L == B[b].size())continue;

			R = -1;
			left = 0,right = B[b].size()-1,mid = (left+right)/2;
			while(left <= right){

				if(A[a][i]+B[b][mid] <= MAX){

					R = mid;
					left = mid+1;
				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}
			ans += max(0,R-L+1);
		}
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 23384
h,w=map(int,input().split())
da=[input() for i in range(h)]
for i in range(h):
    da[i]='.'+da[i]+'.'
sample='.'*(w+2)
da.insert(0,sample)
da.append(da)
ju=False
for i in range(h):
    for j in range(w):
        if(da[i+1][j+1]=='#'):
            if(not(da[i][j+1]=='#' or da[i+1][j]=='#' or da[i+1][j+2]=='#' or da[i+2][j+1]=='#')):
                print('No')
                ju=True
                break
    if(ju):
        break
if(not ju):
    print('Yes')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    ll n; cin >> n;
    vector<ll> a(n+1);
    ll sum = 0;
    REP(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> x(n);
    ll tmp = 0;
    REP(i,n) {
        tmp += (i%2==0 ? a[i]*2 : 0);
    }
    x[0] = tmp-sum;
    REP(i,n-1) {
        x[i+1] = 2*a[i] - x[i];
    }
    REP(i,n) {
        if(i==n-1) cout << x[i] << endl;
        else cout << x[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	char a,b,c,d;
	cin>>a>>d>>d>>d>>b>>d>>d>>d>>c;
	cout<<a<<b<<c;
	}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC103B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            T += T;

            bool ans = false;
            for (int i = 0; i < S.Length; i++)
            {
                bool ok = true;
                for (int j = 0; j < S.Length; j++)
                {
                    if (S[j] != T[i + j]) ok = false;
                }
                if (ok) ans = true;
            }

            if (ans) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#define max(x, y) (x) > (y) ? (x):(y) 

using namespace std;

int main(void)
{
	int x;
	cin >> x;
	short a, b, c, d;
	a = x / 1000;
	b = x / 100 % 10;
	c = x / 10 % 10;
	d = x % 10;

	if (a == b || b == c || c == d) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};


int main() {
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 1, cnt = 0;
    if(s.front()!='B' || s.back()!='B') ans = 0;
    for(int i=0;i<n*2;i++){
        if((cnt+s[i])%2 == 0) cnt++;
        else{
            ans *= cnt;
            cnt--;
            ans %= MOD;
        }
    }
    if(cnt != 0) ans = 0;
    for(int i=1;i<=n;i++){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

long inf = 1000000007;


int main() {
	long n, a, b;
	cin >> n >> a >> b;
	string s; cin >> s;
	long counta = 0, countb = 0;
	for (long i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (counta + countb < a + b) {
				cout << "Yes" << endl;
				counta++;
			}
			else cout << "No" << endl;
		}

		if (s[i] == 'b') {
			if (counta + countb < a + b and countb < b) {
				cout << "Yes" << endl;
				countb++;
			}
			else cout << "No" << endl;
		}
		
		if (s[i] == 'c') cout << "No" << endl;
	}
}




Measured memory_bytes: 896
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a


n, m = map(int, input().split())
mod = 10 ** 9 + 7

if abs(n - m) > 1:
    print(0)
    exit()

x = factorial_mod(n, mod) * factorial_mod(m, mod)
print((x * 2 % mod) if n == m else x % mod)

Measured memory_bytes: 3060
n=int(raw_input())
s=raw_input()
state=[['W','S'],['S','W'],['W','W'],['S','S']]
for now in state:
    for i in xrange(1,n):
        if s[i]=="o":
            if now[i]=="S":
                now.append(now[i-1])
            else:
                if now[i-1]=="S":
                    now.append("W")
                else:
                    now.append("S")
        else:
            if now[i]=="W":
                now.append(now[i-1])
            else:
                if now[i-1]=="S":
                    now.append("W")
                else:
                    now.append("S")
    ok=False
    if now[0]==now[n]:
        if s[0]=="o":
            if now[0]=="S":
                if now[1]==now[n-1]:
                    ok=True
            else:
                if now[1]!=now[n-1]:
                    ok=True
        else:
            if now[0]=="W":
                if now[1]==now[n-1]:
                    ok=True
            else:
                if now[1]!=now[n-1]:
                    ok=True
    if ok:
        print "".join(now[0:n])
        exit()
print -1

Measured memory_bytes: 55660
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 100000;
bool bad[N];
int h[N];
int n;
int m;

int main() 
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) scanf("%d", h + i);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		int mn = min(h[a - 1], h[b - 1]);
		if (h[a - 1] == mn) bad[a - 1] = true;
		if (h[b - 1] == mn) bad[b - 1] = true;
	}
	int c = 0;
	for (int i = 0; i < n; ++i) c += !bad[i];
	printf("%d\n", c);
	return 0;
}


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

int64_t dfact(int64_t n){
    if(n % 2 == 1 || n < 2)return 0;
    int64_t i = 0, comp = 2, num = 0;
    while(n >= comp){
        ++i;
        comp *= 5;
    }
    --i;
    comp /= 5;
    for(int64_t j = 0; j < i; j++){
        num *= 5;
        num++;
    }
    return dfact(n - comp) + num;
}

int main(){
    int64_t N;
    cin >> N;
    cout << dfact(N) << endl;
}

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

using namespace std;
#define char int
int N;
int MS[101];
vector<vector<char> > howToGet;
map<vector<char>,char> dp;
void dfs(int kind,int wgt,const vector<char> &v){
  if(kind==0){
    vector<char> nv=v;
    nv.push_back(0);
    dfs(kind+1,wgt,nv);
  }
  else if(wgt==0)howToGet.push_back(v);
  else if(kind==10)return;
  else{
    for(int i=0;i*kind<=10;i++){
      if(wgt-i*kind>=0){
	vector<char> nv=v;
	nv.push_back(i);
	dfs(kind+1,wgt-i*kind,nv);
      }
    }
  }
}

int dfs2(const vector<char> &v){
  if(dp.count(v)!=0)return dp[v];
  int res=0;
  for(int pos=0;pos<(int)howToGet.size();pos++){
    // 1セット分取れるか
    vector<char> nv=v;
    bool ok=true;
    for(int j=1;j<(int)howToGet[pos].size();j++){
      nv[j]-=howToGet[pos][j];
      if(nv[j]<0){
	ok=false;
	break;
      }
    }
    // iセット取れるならとる
    if(ok)res=max(res,dfs2(nv)+1);
  }
  return dp[v]=res;
}

int main(){
  dfs(0,10,vector<char>());
  while(cin>>N&&N){
    vector<char> cnts;
    for(int i=0;i<N;i++)cin>>MS[i];
    for(int i=0;i<=10;i++)cnts.push_back(0);
    for(int i=0;i<N;i++)cnts[MS[i]]++;
    int sum=0;
    for(int i=1;i<=4;i++){
      int a=min(cnts[i],cnts[10-i]);
      cnts[i]-=a;cnts[10-i]-=a;
      sum+=a;
    }
    int a=cnts[5]/2;
    cnts[5]-=2*a;
    sum+=a;
    int res=dfs2(cnts)+sum;
    cout<<res<<endl;
  }
  return 0;
}

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

int main(){
	int n, q;
	int count = 0;
	long S[10000],T[500];

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> T[i];
	}

	for(int i = 0; i < q; i++){
		for(int j = 0; j < n; j++){
			if(T[i] == S[j]){
				count++;
				j = n;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define MAX 50
int fibonacci(int);
int F[MAX];

int main(){
  int i,n;
  for(i = 0; i < MAX; i++){
    F[i] = -1;
  }
  cin >> n;
  cout << fibonacci(n) << endl;
  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  if(F[n] != -1){
    return F[n];
  }
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

Measured memory_bytes: 3012
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	int d[10000];
	for (int e = 0; e < b; e++)scanf("%d", &d[e]);
	sort(d, d + b);
	int mincost = d[b-1]-d[0] + min({abs(d[b-1]-c),abs(c-d[0]),abs(a-(d[b-1]-c)),abs(a-(c-d[0]))});
	for (int i = 0; i < b - 1; i++) {
		mincost = min(mincost, a - (d[i + 1] - d[i]) + min({ abs(d[i] - c),abs(d[i+1]-c),a-(abs(d[i] - c)),a-(abs(d[i + 1] - c))}));
	}
	cout << mincost*100<< endl;
}

Measured memory_bytes: 3232
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  P.append([])
  for j in range(26):
    P[i].append(j)
  P[i].sort(reverse=True,key=lambda x:X[x]+S[i][x])
  XX[P[i][0]]-=X[P[i][0]]
  X[P[i][0]]=0
SC,SC2=0,0
for i in range(D):
  SC+=S[i][P[i][0]]
YY=[]
Y=[]
k=0
L=[]
for i in range(25):
  for j in range(26-i):
    L.append(i)
for l in range(666):
  for i in range(D):
    k=L[randrange(0,len(L))]
    SC2=SC
    YY=XX[:]
    Y=X[:]
    SC2-=S[i][P[i][0]]
    SC2+=S[i][P[i][k+1]]
    for j in range(26):
      Y[j]=0
    YY[P[i][0]],YY[P[i][k+1]]=0,0
    for j in range(D):
      if j==i:
        Z=P[j][k+1]
      else:
        Z=P[j][0]
      Y[P[i][0]]+=C[P[i][0]]
      Y[P[i][k+1]]+=C[P[i][k+1]]
      Y[Z]=0
      YY[P[i][0]]+=Y[P[i][0]]
      YY[P[i][k+1]]+=Y[P[i][k+1]]
    if SC2-sum(YY)>SC-sum(XX):
      P[i].insert(0,P[i][k+1])
      del P[i][k+2]
      XX=YY[:]
      SC=SC2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 85992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000+10;
const int dem = 2;
const int INF = 0x3f3f3f3f;

struct Point{
    int x[dem];
}p[maxn];

int n;
int minx[1<<dem], maxx[1<<dem];

ll solve() {
    int tmp = 1<<dem;

    for(int i=0; i<tmp; i++) {
        minx[i] = INF;
        maxx[i] = -INF;
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<tmp; j++) {
            int t = j;
            int s = 0;
            for(int k=0; k<dem; k++) {
                if(t & 1) s += p[i].x[k];
                else s -= p[i].x[k];
                t >>= 1;
            }
            if(maxx[j] < s) maxx[j] = s;
            if(minx[j] > s) minx[j] = s;
        }
    }
    ll ans = -1 * INF;
    for(int i=0; i<tmp; i++) {
        if(maxx[i] - minx[i] > ans)
            ans = maxx[i] - minx[i];
    }

    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<dem; j++) {
            cin >> p[i].x[j];
        }
    }
    cout << solve() << endl;
    

    return 0;
}

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

int main(){
    long long int Y,N;
    cin>>N>>Y;
    int c=0;
    for(int a=0;10000*a<=Y;a++){
        for(int b=0;5000*b<=Y;b++){
            int sub = Y-10000*a-5000*b;
            c = sub/1000;
            if(sub/1000==N-a-b&&c>=0){
                printf("%d %d %d\n",a,b,c);
                return 0;
            }
            
        }

    }
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,c;
  cin >> a >>  c;
  if(c >= 500)
    cout << "Yes" << endl;
  else{
    if(a%500 <= c)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;

  int n,m,v;
  set<int> a,b;
  cin >> n;

  for(ii=0;ii<n;ii++){
    cin >> v;
    a.insert(v);
  }

  cin >> m;

  for(ii=0;ii<m;ii++){
    cin >> v;
    b.insert(v);
  }

  set<int>::iterator it;
  set<int> c;
  
  it = a.begin();

  while(it != a.end()){
    if(b.find(*it) == b.end()){
      c.insert(*it);
    }
    it++;
  }

  it = b.begin();

  while(it != b.end()){
    if(a.find(*it) == a.end()){
      c.insert(*it);
    }
    it++;
  }
  
  
  it = c.begin();
  
  while(it != c.end()){
    cout << *it << endl;
    it++;
  }
  
  return 0;
  
}



Measured memory_bytes: 40544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

int const nmax = 100000;
std::vector<int> g[1 + nmax];
int nimber[1 + nmax];

void dfs(int node, int parent) {
  for(int h = 0; h < g[node].size(); h++) {
    int to = g[node][h];
    if(to != parent) {
      dfs(to, node);
      nimber[node] ^= nimber[to] + 1;
    }
  }
}

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i < n; i++) {
    int x, y;
    std::cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  if(nimber[1] == 0)
    std::cout << "Bob";
  else
    std::cout << "Alice";
  return 0;
}


Measured memory_bytes: 17144
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	//
	if n >= 13 {
		fmt.Println(m)
	} else if n >= 6 {
		fmt.Println(m / 2)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
package main

import "fmt"

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

	a := make([]int, n)

	for i := range a {
		fmt.Scan(&a[i])
	}

	s := selection(a)

	for i := range a {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(a[i])
	}
	fmt.Println()

	fmt.Println(s)
}

func bubble(a []int) int {
	s := 0
	for i := 0; i < len(a); i++ {
		for j := len(a) - 1; j >= i+1; j-- {
			if a[j-1] > a[j] {
				a[j-1], a[j] = a[j], a[j-1]
				s++
			}
		}
	}

	return s
}

func selection(a []int) int {
	s := 0
	for i := 0; i < len(a); i++ {
		mini := i
		for j := i; j < len(a); j++ {
			if a[j] < a[mini] {
				mini = j
			}
		}
		if i != mini {
			a[i], a[mini] = a[mini], a[i]
			s++
		}
	}
	return s
}



Measured memory_bytes: 1168
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    max_diff = A[0] + (K - A[-1])
    for i in range(len(A)-1):
        max_diff = max(max_diff, A[i+1] - A[i])
    
    print(K - max_diff)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26444
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int main() {
	LL a, b, x;
	cin >> a >> b >> x;
	if (2 * x >= a * a * b) {
		db tt = (2.0 * a * a * b - 2.0 * x) / (1.0 * a * a * a);
		printf("%.10f\n", 180.0 / acos(-1) * atan(tt));
	} else {
		db tt = 1.0 / (2.0 * x / (1.0 * a * b * b));
		printf("%.10f\n", 180.0 / acos(-1) * atan(tt));
	}
	return 0;
}

Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val n = readInt()
    val a = readLongList().sortedDescending().flatMap { listOf(it, it) }.drop(1)
    val res = a.subList(0, n-1).sum()
    println(res)
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> X(N), A(M, 0), B(M, 0);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    A[X[i] % M]++;
  }
  sort(X.begin(), X.end());
  for (int i = 0; i < N - 1; i++) {
    if (X[i] == X[i + 1]) {
      B[X[i] % M]++;
      i++;
    }
  }
  int res = A[0] / 2;
  if (M % 2 == 0) {
    res += A[M / 2] / 2;
  }
  for (int i = 1; i < M / 2 + (M % 2 == 0 ? 0 : 1); i++) {
    int p = min(A[i], A[M - i]);
    A[i] -= p, A[M - i] -= p;
    res += p + min(A[i] / 2, B[i]) + min(A[M - i] / 2, B[M - i]);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
  
		// 出力
		System.out.println(a * b - (a + b - 1));
	}
}


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

using namespace std;

#define endl "\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1n(i, n) for (int i = 1; i < (int)(n); ++i)
#define forln(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define forl1n(i, n) for (long long i = 1; i < (long long)(n); ++i)

const ld EPS = 1e-9;
#define mod 1000000007

//          U   R  D  L
int dx[] = {-1, 0, 1, 0, -1, +1, +1, -1}; // dx for the 8 adjacent places in matrix
int dy[] = {0, 1, 0, -1, +1, +1, -1, -1};// dy for the 8 adjacent places in matrix
vector<ll> v;
vector<pair<ll, ll>> minn;
vector<pair<ll, ll>> maxx;
ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp) {
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n) {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r) {
    if (r == 0)return 1;
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll md(ll n, ll z) {
    return (n % z + z) % z;
}

int main() {

    ios_base::sync_with_stdio(false), cin.tie(NULL);
    calcFacAndInv(1000000);

    ll n;
    cin >> n;
    ll k;
    cin >> k;
    v.resize(n);
    forn(i, n)cin >> v[i];
    sort(v.begin(), v.end());
    for (ll i = 0; n - 1 - i >= k - 1; i++) {
        if (n - 1 - i >= 0 && n - 1 - i >= k - 1)
            minn.push_back({v[i], ncr(n - 1 - i, k - 1)});
    }
    for (ll i = n - 1; i >= k - 1; i--) {
        maxx.push_back({v[i], ncr(i, k - 1)});
    }

    ll res = 0;
    forn(i, maxx.size()) {
        ll a = md(maxx[i].first, mod);
        ll b = md(maxx[i].second, mod);
        ll d = md((a * b), mod);

        res = md((md(res, mod) + d), mod);
    }
    ll res2 = 0;
    forn(i, minn.size()) {
        ll a = md(minn[i].first, mod);
        ll b = md(minn[i].second, mod);
        ll d = md((a * b), mod);

        res2 = md((md(res2, mod) + d), mod);
    }

   cout<<md(res-res2,mod);


}

Measured memory_bytes: 18932
#include <iostream>

std::string str;

int main() {
    getline(std::cin, str);

    int len = str.length();
    for(int i=0; i < len; ++i) {
        char c = str[i];
        if(c >= 'a' && c <= 'z') {
            char upper = (c - 'a') + 'A';
            std::cout << upper;
        } else {
            std::cout << c;
        }
    }
    std::cout << std::endl;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(ll i = 0; i < n; ++i)
#define REP3(i, B, E) for(ll i = B; i <= E; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

template<class T> T& chmin(T &obj, T val){ return obj = min(obj, val); }
template<class T> T& chmax(T &obj, T val){ return obj = max(obj, val); }

// 二分探索 : [low, high) の範囲で述語 pred がtrue を返す最大の値を返す
template<class Pred>
ll bsearch(ll low, ll high, Pred pred){
    while(low + 1 < high){
        const ll mid = low + (high - low) / 2;
        if(pred(mid)){ low = mid; }
        else{ high = mid; }
    }
    return low;
}

int main() {
    ll N;
    cin >> N;
    auto P = read<ll>(N);
    auto Q = read<ll>(N);
    
    v<ll> v(N);
    REP3(i, 1, N){ v[i-1] = i; }
    ll px = 0, qx = 0;
    ll i = 0;
    do {
        if(v == P){ px = i; }
        if(v == Q){ qx = i; }
        ++i;
    } while (std::next_permutation(v.begin(), v.end()));
    cout << abs(px - qx) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

class Dice {
    array<int, 6> dice;

    void _roll(int a, int b, int c, int d)
    {
        int tmp = dice[a];
        dice[a] = dice[b];
        dice[b] = dice[c];
        dice[c] = dice[d];
        dice[d] = tmp;
    }

public:
    Dice(int d1, int d2, int d3, int d4, int d5, int d6)
    {
        dice[0] = d1;
        dice[1] = d2;
        dice[2] = d3;
        dice[3] = d4;
        dice[4] = d5;
        dice[5] = d6;
    }

    int top()
    {
        return dice[0];
    }

    void roll(char dir)
    {
        switch (dir) {
        case 'S':
            _roll(0, 1, 5, 4);
            _roll(0, 1, 5, 4);
        case 'N':
            _roll(0, 1, 5, 4);
            break;
        case 'E':
            _roll(0, 2, 5, 3);
            _roll(0, 2, 5, 3);
        case 'W':
            _roll(0, 2, 5, 3);
            break;
        }
    }
};

int main()
{
    array<int, 6> d;
    for (auto&& i : d) {
        cin >> i;
    }
    Dice dice(d[0], d[1], d[2], d[3], d[4], d[5]);

    string str;
    cin >> str;
    for (auto&& c : str) {
        dice.roll(c);
    }

    cout << dice.top() << endl;
}



Measured memory_bytes: 3148