akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int N = 200010;
vector<ll> t(4*N);
void update(int pos, ll value, int v, int tl, int tr) {
	if(tl==tr) {
		t[v] = value;
		return;
	} 
	int mid = tl + (tr-tl)/2;
	if(pos<=mid) {
		update(pos,value, v*2,tl,mid);
	} else {
		update(pos,value,v*2+1,mid+1,tr);
	}
	t[v] = max(t[v*2],t[v*2+1]);
}
ll query(int v, int tl, int tr, int l, int r) {
	if(l>r) return 0;
	if(l==tl && r==tr) {
		return t[v];
	} 
	int mid = tl + (tr-tl)/2;
	return max(query(v*2,tl,mid,l,min(r,mid)), query(v*2+1,mid+1,tr,max(l,mid+1),r));
}
int main() {
	int n;
	cin>>n;
	vector<ll> h(n), a(n);
	for(int i=0;i<n;i++) {
		cin>>h[i];
	}
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	vector<ll> dp(n+1,0); //max possible score taking the last tree of height i
	int root = 1, tl = 0, tr = n-1;
	for(int i=0;i<n;i++) {
		// commented code works fine but gives TLE
		//for(int j=0;j<h[i];j++) {
			//dp[h[i]] = max(dp[h[i]], dp[j] + a[i]);
		//}
		//debug()<<imie(h[i]) imie(a[i]);
		ll best = query(root, tl ,tr, 0, h[i]-1);
		//debug()<<imie(best);
		dp[h[i]] = a[i] + best;
		update(h[i], dp[h[i]], root, tl ,tr);
		//debug()<<imie(t);
	}
	//debug()<<imie(dp);
	ll ans = -1;
	for(ll it:dp) {
		ans = max(ans,it);
	}
	cout<<ans;
}



Measured memory_bytes: 14328
use std::io::*;
use std::str::*;

fn main() {
    let n: usize = read_one();
    let m: i64 = read_one();
    let a: Vec<i64> = read_vec();

    let mut sum: Vec<i64> = a.iter().scan(0i64, |state, &x| {*state = *state + x; Some(*state % m)}).collect();
    sum.insert(0, 0);
    sum.sort();


    let mut ans: i64 = 0;
    let mut state = -1;
    let mut state_num = 0;

    for k in sum.iter() {
        if *k == state {
            state_num += 1;
        } else {
            ans += state_num * (state_num - 1) / 2;
            state_num = 1;
        }
        state = *k;
    }
    ans += state_num * (state_num - 1) / 2;

    println!("{}", ans);
}

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.trim().parse().ok().unwrap()
}

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

Measured memory_bytes: 8444
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;



public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			int k=sc.nextInt();
			ar=new int[n];
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
			}
		
		System.out.println(solve(n,k));
		}

	}
	
	static long solve(int n,int k) {
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[2]=Math.abs(ar[1]-ar[0]);
		for(int i=3;i<=n;i++) {
			int l=Math.min(k, i-1);
			dp[i]=Long.MAX_VALUE;
			for(int j=1;j<=l;j++) {
				dp[i]=Math.min(dp[i], dp[i-j]+Math.abs(ar[i-1]-ar[i-j-1]));
			}
		}
		return dp[n];
		
	}


}


Measured memory_bytes: 65364
#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

using Graph = vector<vector<pair<int, int64_t>>>;

constexpr int64_t kInf = 1e17;

bool CanReach(const Graph &g, int node, int dest)
{
    vector<bool> used(g.size(), false);
    queue<int> q;

    q.push(node);
    used[node] = true;

    while (!q.empty() && !used[dest]) {
        node = q.front();
        q.pop();

        for (const auto &e : g[node]) {
            if (!used[e.first]) {
                used[e.first] = true;
                q.push(e.first);
            }
        }
    }
    return used[dest];
}

int64_t FindBestCost(const Graph &g, int source, int dest)
{
    vector<int64_t> costs(g.size(), -kInf);
    queue<int> q;

    costs[source] = 0;
    q.push(source);

    vector<int> updates(g.size(), 0);
    vector<bool> valid(g.size(), false);

    for (size_t i = 0; i < g.size(); i += 1) {
        valid[i] = CanReach(g, i, dest);
    }

    while (!q.empty()) {
        auto node = q.front();
        q.pop();

        for (const auto &e : g[node]) {
            auto next_node = e.first;
            auto next_cost = costs[node] + e.second;

            if (next_cost > costs[next_node] && valid[next_node]) {
                costs[next_node] = next_cost;
                q.push(next_node);
                updates[next_node] += 1;

                if (updates[next_node] >= (int)g.size()) {
                    return kInf;
                }
            }
        }
    }
    return costs[dest];
}

int main()
{
    int nodes, edges;
    cin >> nodes >> edges;

    Graph graph(nodes);
    for (auto i = 0; i < edges; i += 1){
        int a, b, cost;
        cin >> a >> b >> cost;
        graph[a - 1].push_back({b - 1, cost});
    }

    auto res = FindBestCost(graph, 0, nodes - 1);
    if (res >= kInf) {
        cout << "inf\n";
    } else {
        cout << res << "\n";
    }

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> v(n);
  vector<int> vf(n);
  vector<int> vs(n);
  rep(i,n){
    cin >> v[i].first;
    if(i==0){
      vf[i]=v[i].first;
    }
    else{
      vf[i]=vf[i-1]+v[i].first;
    }
  }
  rep(i,n){
    cin >> v[i].second;
  }
  irep(i,n){
    if(i==n-1){
      vs[i]=v[i].second;
    }
    else{
      vs[i]=vs[i+1]+v[i].second;
    }
  }
  int max=0;
  rep(i,n){
    if(max<vf[i]+vs[i]){
      max=vf[i]+vs[i];
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DHandstand2 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vvc<int> F(10, vc<int>(10, 0));
        FOR(i, 1, N+1){
            vc<int> d;
            int x = i;
            while(x){
                d.pb(x%10);
                x /= 10;
            }
            F[d.back()][d.front()]++;
        }
        lint ans = 0;
        REP(i, 10) REP(j, 10){
            ans += F[i][j] * F[j][i];
        }
        out<<ans<<'\n';
    }
};


int main() {
	DHandstand2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int nums[100009];

int main() {
    int N;
    cin >> N;
    
    rep1(i,N){
        int x;
        cin >> x;
        nums[i] = x;
    }
    
    int ans=0;
    rep1(i,N-1){
        if( nums[i]==i){
            swap(nums[i],nums[i+1]);
            ans++;
        }
    }
    if(nums[N]==N)ans++;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#define inf 1e9
using namespace std;
int main() {
    int *p, *a;
    int n, k;
    cin>>n>>k;
    p = new int[n];
    a = new int[n];
    for (int i=0;i<n;i++) cin>>a[i];
    p[0]=0;
    p[1]= abs(a[0]-a[1]);
    for (int i=2;i<n;i++){
        p[i] = inf;
        for (int j = 1; j<=k && i-j>=0; j++)
            p[i] = min(p[i-j]+abs(a[i-j]-a[i]), p[i]);
    }
    cout<<p[n-1];
}


Measured memory_bytes: 4380
#include<iostream>
using namespace std;
const int maxn=2*1e3+100;
int write[maxn];
int main()
{   
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n-1;i++) write[i]=n-i;
    for(int i=1;i<=x;i++){
        for(int j=x;j<=y;j++){
            if(y-j+1<j-x){
                write[j-i]--;
                write[y-j+1+x-i]++;
            }
        }
    }
    for(int i=1;i<=x;i++){
        for(int j=y+1;j<=n;j++){
            write[j-i]--;
            write[x-i+j-y+1]++;
        }
    }
    for(int i=x+1;i<=y;i++){
        for(int j=y;j<=n;j++){
            if(i-x+1<y-i){
                write[j-i]--;
                write[i-x+1+j-y]++;
            }
        }
    }
    for(int i=x+1;i<=y;i++){
        for(int j=i;j<y;j++){
            if(i-x+1+y-j<j-i){
                write[j-i]--;
                write[i-x+1+y-j]++;
            }
        }
    }
    for(int i=1;i<=n-1;i++) cout<<write[i]<<" ";
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static final int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		long[] factorial = new long[n];
		long[] inverse = new long[n];
		long[] factorial_inverse = new long[n];

		factorial[0] = 1;
		factorial[1] = 1;
		inverse[1] = 1;
		factorial_inverse[0] = 1;
		factorial_inverse[1] = 1;
		for (int i = 2; i < n; i++) {
			factorial[i] = factorial[i - 1] * i % MOD;
			inverse[i] = MOD - inverse[MOD % i] * (MOD / i) % MOD;
			factorial_inverse[i] = factorial_inverse[i - 1] * inverse[i] % MOD;
		}

		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);

		long max = 0;
		long min = 0;

		for (int i = k; i <= n; i++) {
			long combination = factorial[i - 1] * (factorial_inverse[k - 1] * factorial_inverse[i - k] % MOD) % MOD;
			max = (max + array[i - 1] * combination) % MOD;
		}

		for (int i = k; i <= n; i++) {
			long combination = factorial[i - 1] * (factorial_inverse[k - 1] * factorial_inverse[i - k] % MOD) % MOD;
			min = (min + array[n - i] * combination) % MOD;
		}

		print((max + MOD - min) % MOD);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}

Measured memory_bytes: 61936
/*
* Golangの練習
*
*/

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
  
func main(){
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// 1行目
	k := nextInt(sc)
	n := nextInt(sc)
	
	// 2行目
	var a = make([]int, n+1)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	a[n] = k+a[0]
 
	// NOTE: REの原因個所の特定
	maxCost := 0
	for i := 0; i < n; i++ {
		tmp := a[i+1] - a[i]
		if tmp > maxCost {
			maxCost = tmp
		}
	}
	fmt.Println(k - maxCost)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



ll n;
int main() {
	cin >> n;
	vector<ll> s(n);
	REP(i, n)cin >> s[i];
	REPR(i, n - 2) {
		if (s[i] > s[i + 1])s[i]--;
		if (s[i] > s[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}
	


Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[55][55];//dp[y][x]:=(x,y)を通った時の最小の不快度
string board[55];
int main(){
	int H,W;
	cin>>H>>W;
	for(int i =0;i <55;i++){
		for(int j =0;j <55;j++){
			dp[i][j]=0;

		}
	}
	for(int i =1;i <=H;i++){
		cin>>board[i];
	}
	for(int i =1;i <=H;i++){
		for(int j =1;j <=W;j++){
			int x;
			stringstream ss;
			ss <<board[i][j-1];
			ss >>x;
			//cout <<x<<endl;
			if(i==1){
				dp[i][j]=dp[i][j-1]+x;
			}else if(j==1){
				dp[i][j]=dp[i-1][j]+x;
			}else{
				dp[i][j]=min(dp[i][j-1],dp[i-1][j])+x;
			}
		}
	}
	cout <<dp[H][W]<<endl;
	return 0;
}

Measured memory_bytes: 1240
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

st = lambda n: bin(n)[2:]
n,k = map(int,readline().split())
a = [int(i) for i in readline().split()]

INF = 10**12
mm = INF.bit_length()
chk = np.array([list(st(i).zfill(mm)) for i in a])

ll = []
q = 0
for num,i in enumerate(chk.T):
  cc = np.count_nonzero(i == '1')
  if cc < n/2:
    q += 2**(mm-1-num)
  ll.append((mm-1-num,2**(mm-1-num)*(n-cc),2**(mm-1-num)*cc))
    
max_V = 0
KK = (k+1).bit_length()
sk = st(k+1).zfill(mm)
sq = st(q).zfill(mm)

for i in range(KK):
  if (k+1)>>i&1 == 1:
    op = q
    if q>>i&1 == 1:
      op -= 2**i
    I = KK-i
    for j in range(mm-KK+I):
      if sq[j] == '1' and sk[j] == '0':
        op -= 2**(mm-1-j)
    V = 0
    for nm,v_1,v_0 in ll:
      if op>>nm & 1 == 1:     
        V += v_1
      else:
        V += v_0
    max_V = max(max_V, V)
    
print(max_V)

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

using namespace std;

int main() {
    ios::sync_with_stdio();
    cin.tie(0);
    vector <int> a(2);
    cin >> a[0] >> a[1];
    sort(a.begin(), a.end());
    for (int i=0;i<3;i++) {
        if (a[i]!=i+1) {
            cout << i+1;
            return 0;
        }
    }
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. \n";
    return 0;
}



Measured memory_bytes: 3640
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int n,q;
	int C=0;
	int[] S,T;
	int left,mid,right;
	
	public void input() {
		n = sc.nextInt();
		S = new int[n];
		for(int i=0; i<n; i++) S[i] = sc.nextInt();
		q = sc.nextInt();
		T = new int[q];
		for(int i=0; i<q; i++) T[i] = sc.nextInt();
	}
	
	public void search() {
		for(int i=0; i<q; i++) {
			left = 0;
			right = S.length;
			while(left < right) {
				mid = (left + right) / 2;
				if(T[i] == S[mid]) {
					C++;
					break;
				}else if(T[i] > S[mid]) {
					left = mid +1;
				}else {
					right = mid;
				}
			}
		}
		System.out.println(C);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.search();
	}
}



Measured memory_bytes: 69640
#include<stdio.h>

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

int main(void){
  int n;
  scanf("%d",&n);
  
  int a[n] , b[n];
  for(int i = 0;i < n;i ++){
    scanf("%d",&a[i]);
    b[i] = a[i];
  }
  
  qsort(a,n,sizeof(int),up);
  
  for(int  i = 0;i < n;i ++){
    if(b[i] == a[n-1]){
      printf("%d\n",a[n-2]);
    }
    else{
      printf("%d\n",a[n-1]);
    }
  }
  
  return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(void)
{
  double templ, tempr;
  int al=0,ar=0,bl=0,br=0,cl=0,cr=0,dl=0,dr=0;

  while(scanf("%lf %lf",&templ,&tempr)!=EOF)
    {
      if(templ>=1.1)
	al++;
      else if(templ>=0.6 && templ<1.1)
	bl++;
      else if(templ>=0.2 && templ<0.6)
	cl++;
      else
	dl++;

      if(tempr>=1.1)
	ar++;
      else if(tempr>=0.6 && tempr<1.1)
	br++;
      else if(tempr>=0.2 && tempr<0.6)
	cr++;
      else
	dr++;
    }
  printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
  return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

ll BS(vector<pair<ll , ll > > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}

ll explore(vector<vector<ll > > &graph,ll s,ll SA,vector<ll> &vis,ll &cutted)
{
    SA++;
    vis[s]=1;
    for(ll i=0;i<graph[s].size();i++)
    {
        if(vis[graph[s][i]] == 0)
        {
           SA += explore(graph,graph[s][i],0,vis,cutted);
        }
    }
    if(SA%2==0)
    {
        cutted++;

            return 0;
    }
    else
        return SA;
}

ll DFS(vector<vector<ll> > &G,ll s,vector<ll> &vis)
{
    if(vis[s]!=-1)
        return vis[s];
    if(G[s].size()==0)
    {
        vis[s]=0;
        return 0;
    }
    ll temp=0;
    for(int i=0;i<G[s].size();i++)
    {
        temp = max(temp,DFS(G,G[s][i],vis));
    }
    return vis[s]=temp+1;
}


int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,i,j,k,l,w,q,u,r,v,c,h,p,d;
    cin >> n >> m;
    vector<vector<ll> > G(n+1);
    for(i=0;i<m;i++)
    {
        cin >> u >> v;
        G[u].pb(v);
    }

    vector<ll> vis(n+1,-1);
    for(i=1;i<=n;i++)
    {
        DFS(G,i,vis);
    }
    ll ans = 00;
    for(i=1;i<=n;i++)
    {
        ans = max(ans,vis[i]);
    }

    cout << ans;


}
return 0;
}


Measured memory_bytes: 9216
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    c_n = []
    for i in range(n + 1):
        c_n.append(i * (i - 1) // 2)

    sorted_a = sorted(a)
    g = {}
    count = 1
    tmp = 0
    for ai in sorted_a:
        if tmp == ai:
            count += 1
        else:
            g[tmp] = count
            count = 1
        tmp = ai
    g[tmp] = count

    ans = 0
    for k in g:
        ans += c_n[g[k]]

    for ai in a:
        print(ans - g[ai] + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 72100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    int i = 0;
    int sum = 0;
    while(sum < n){
        i++;
        sum += i;
    }
    for(int j = 1; j <= i; j++){
        if(j != sum - n){
            cout << j << " ";
        }
    }
    cout << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
public:
    UnionFind(size_t n){
        m_parent.resize(n);
        iota(m_parent.begin(), m_parent.end(), 0);

        m_rank.resize(n);
        fill(m_rank.begin(), m_rank.end(), 0);

        m_size.resize(n);
        fill(m_size.begin(), m_size.end(), 1);
    }

    int Find(int x){
        if(m_parent[x] == x){
            return x;
        }else{
            m_parent[x] = Find(m_parent[x]);
            return m_parent[x];
        }
    }

    void Union(int x, int y){
        auto xroot = Find(x);
        auto yroot = Find(y);
        if(m_rank[xroot] > m_rank[yroot]){
            m_parent[yroot] = xroot;
            m_size[xroot] += m_size[yroot];
            m_size[yroot] = 0;
        }else if(m_rank[xroot] < m_rank[yroot]){
            m_parent[xroot] = yroot;
            m_size[yroot] += m_size[xroot];
            m_size[xroot] = 0;
        }else if(xroot != yroot){
            m_parent[yroot] = xroot;
            m_size[xroot] += m_size[yroot];
            m_size[yroot] = 0;
            m_rank[xroot] = m_rank[xroot] + 1;
        }
    }

    int GetSize(){
        for(size_t i=0;i<m_parent.size();i++){
            m_parent[i] = Find(m_parent[i]);
        }
        std::set<int> s(m_parent.begin(), m_parent.end());
        return s.size();
    }

    int GetSize(int x){
        auto xroot = Find(x);
        return m_size[xroot];
    }

    std::vector<int> m_parent;
    std::vector<int> m_rank;
    std::vector<int> m_size;
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    map<int, int> num_friends;
    map<int, vector<int>> block;
    for(int i=0; i<N; i++){
        num_friends[i] = 0;
        block[i] = vector<int>();
    }
    UnionFind uf(N);
    int a, b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        a--; b--;
        num_friends[a]++;
        num_friends[b]++;
        uf.Union(a, b);
    }
    for(int i=0;i<K;i++){
        cin >> a >> b;
        a--; b--;
        block[a].push_back(b);
        block[b].push_back(a);
    }

    for(int i=0; i<N; i++){
        auto cand_friends = uf.GetSize(i) - num_friends[i] - 1;
        auto i_root = uf.Find(i);
        for(auto j : block[i]){
            if(i_root == uf.Find(j)) cand_friends--;
        }
        cout << cand_friends << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 17280
/**
 * 
 */
import java.util.Scanner;

/**
 * @author Neeraj
 *
 */
 class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		String s=sc.next();
		
		if(s.length()<=k)
			System.out.println(s);
		else
			System.out.println(s.substring(0,k)+"...");
	}

}


Measured memory_bytes: 38592
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	ll n;
	rl(n);
	string ans;
	while(n>0){
		n--;
		int rem = n%26;
		ans.pb('a'+rem);
		n = n/26;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 36

struct cards{
  char Name;
  char Value;
};

void bubble(struct cards p[],int n){
  int i,j;
  struct cards tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i;j--){
      if(p[j].Value<p[j-1].Value){
        tmp=p[j];
        p[j]=p[j-1];
        p[j-1]=tmp;
      }
    }
  }
}

void selection(struct cards p[],int n){
  int i,j,minj;
  struct cards tmp;
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(p[j].Value<p[minj].Value) minj=j;
    }
    tmp=p[i];
    p[i]=p[minj];
    p[minj]=tmp;
  }
}

int main(){
  int i,j,n,flag=0,a1[N],a2[N];
  scanf("%d",&n);
  struct cards p1[N],p2[N];
  for(i=0;i<n;i++){
    scanf(" %c%c",&p1[i].Name,&p1[i].Value);
  }
  for(i=0;i<n;i++){
    p2[i]=p1[i];
  }

  bubble(p1,n);
  selection(p2,n);

  for(i=0;i<n;i++){
    if(i==n-1)printf("%c%c\nStable\n",p1[i].Name,p1[i].Value);
    else printf("%c%c ",p1[i].Name,p1[i].Value);
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%c%c\n",p2[i].Name,p2[i].Value);
    else printf("%c%c ",p2[i].Name,p2[i].Value);
  }
  for(i=0;i<n;i++){
    if(p1[i].Name != p2[i].Name){
      printf("Not stable\n");
      flag=1;
      break;
    }
  }
  if(flag==0)printf("Stable\n");
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  int h,w;
  int k;
  char c[10][10];
  vector<int> th;
  vector<int> tw;
  int ans = 0;
  int cnt = 0;
  int mx = 0;

  scanf("%d %d %d", &h, &w, &k);
  int i,j,r,l;
  for(i = 0;i < h;i++) scanf("%s", c[i]);

  for(i = 0;i < h;i++){
    for(j = 0;j < w;j++) if(c[i][j] == '#') mx++;
  }

  for(i = 0;i < (1 << h);i++){
    for(j = 0;j < (1 << w);j++){
      cnt = 0;
      th.clear();
      tw.clear();

      for(r = 0;r < h;r++){
        if((i >> r) & 1) th.push_back(r);
      }

      for(r = 0;r < w;r++){
        if((j >> r) & 1) tw.push_back(r);
      }

      // printf("%d %d\n", th.size(), tw.size());

      for(r = 0;r < th.size();r++){
        for(l = 0;l < w;l++) if(c[th[r]][l] == '#') cnt++;
      }

      for(r = 0;r < tw.size();r++){
        for(l = 0;l < h;l++) if(c[l][tw[r]] == '#') cnt++;
      }

      for(r = 0;r < th.size();r++){
        for(l = 0;l < tw.size();l++){
          if(c[th[r]][tw[l]] == '#') cnt--;
        }
      }

      // printf("%d\n", cnt);

      if(mx - cnt == k) ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> S;
    ans =700;
    
    if(S[0]=='o')
	ans +=100;
    if(S[1]=='o')
	ans +=100;
    if(S[2]=='o')
	ans +=100;

    
    // ans = min(A, B) + min(C, D);
    cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(flag)
    // 	puts("YES");
    // else
    // 	puts("NO");
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    long ans = 0;
    for(long i = 0;i < n;i++){
          cin >> a[i];
          ans += a[i] - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
N = int(input())
S = str(input())
K = list()
for i in S:
  K.append(i)
  

if N%2 != 0:
  print("No")



else:
  A = K[0:N//2]
  B = K[N//2:N+1]
  
  if A == B:
    print("Yes")
    
  else:
    print("No")



  

Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N;
  ll Min=1100000000,Max=0,temp;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>temp;
    Min=min(Min,temp);
    Max=max(Max,temp);
  }
  cout<<Max-Min<<endl;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 50;
int N;
int X[MAX_N], Y[MAX_N];

struct Pos {
  int x, y;
  bool operator < (const Pos& p) const {
    if(x != p.x) return x < p.x;
    else return y < p.y;
  }
};

vector<Pos> vec;
vector<II> PQ;

void input()
{
  cin >> N;
  REP(n,N) {
    Pos p;
    cin >> p.x >> p.y;
    vec.push_back(p);
  }
}

int tmp = 0;
int ans = MAX_N;

class UnionFind{
public:
  UnionFind(int aN)
  {
    init(aN);
  }

  void init(int aN)
  {
    par.clear(); cnt.clear();
    par.resize(aN); cnt.resize(aN);
    for (size_t i = 0; i < aN; i++) {
      par[i] = i;
      cnt[i] = 1;
    }
  }

  int find(int aX)
  {
    if(aX == par[aX]) return aX;
    else return par[aX] = find(par[aX]);
  }

  bool same(int aX, int aY)
  {
    return find(aX) == find(aY);
  }

  int size(int aX)
  {
    return cnt[find(aX)];
  }

  void unite(int aX, int aY)
  {
    aX = find(aX);
    aY = find(aY);
    if(aX == aY) return;

    par[aX] = aY;
    cnt[aY] += cnt[aX];
    tmp++;
  }
private:
  vector<int> par;
  vector<int> cnt;
};

signed main()
{
  input();

  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }

  sort(begin(vec), end(vec));

  REP(n1,N) {
    FOR(n2, n1+1, N) {
      PQ.push_back(II(vec[n1].x - vec[n2].x, vec[n1].y - vec[n2].y));
      PQ.push_back(II(vec[n2].x - vec[n1].x, vec[n2].y - vec[n1].y));
    }
  }

  for(II pq : PQ) {
    UnionFind uf(N);
    tmp = 0;
    REP(n1,N) {
      FOR(n2, n1+1, N) {
        II pq1 = II(vec[n1].x - vec[n2].x, vec[n1].y - vec[n2].y);
        II pq2 = II(vec[n2].x - vec[n1].x, vec[n2].y - vec[n1].y);
        if(pq1 == pq || pq2 == pq) {
          uf.unite(n1,n2);
        }
      }
    }

    ans = min(ans, N-tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);
const nin=()=>{const r = input[0];input.shift();return Number(r)};
const nrin=(n)=>{const a=[];rep(n,()=>a.push(nin()));return a};
const sin=()=>{const r = input[0];input.shift();return String(r);}
const out = (...a) => {console.log(...a);}
const min = (...a) => {return Math.min(...a);}
const rep = (n, callback) => {for(let i = 0;i < n; i++){callback();}}

const main = () => {
  let [a,b] = [...nrin(2)];
  if(a >= 13) out(b)
  else if(a >= 6) out(b/2)
  else out(0);
}
main();


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int N;
	cin >> N;
	cout << ((N%1000==0) ? 0 : 1000-N%1000) << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)
#define pyfor(j,s,n,i) for(int j = s;j < n;j += i)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = INT_MAX;

const int max_n = 1e3;

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

  int W, H;
  cin >> W >> H;

  ull p[W], q[H];
  REP(i, W) {
    cin >> p[i];
  }
  REP(i, H) {
    cin >> q[i];
  }

  sort(p, p + W);
  sort(q, q + H);

  ull total = 0;
  int pi = 0, qi = 0;
  int pc = 0, qc = 0;

  REP(i, H + W){
    if (pi >= W) {
      total += q[qi] * (W + 1 - pi);
      qi++;
    }
    else if (qi >= H) {
      total += p[pi] * (H + 1 - qi);
      pi++;
    }
    else if (p[pi] < q[qi]) {
      total += p[pi] * (H + 1 - qi);
      pi++;
    }
    else {
      total += q[qi] * (W + 1 - pi);
      qi++;
    }
  }

  cout << total << "\n";

  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod = 1e9 + 7;
const int MX = 1e5+10;
int a[MX];
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
  int n;
  cin>>n;
  for(int i=1;i<=100;i++){
	  for(int j=1;j<=100;j++){
		  for(int k=1;k<=100;k++){
			  int x=i*i+j*j+k*k+i*j+j*k+k*i;
			  if(x<=10000)a[x]=a[x]+1;
		  }
	  }
  }
  for(int i=1;i<=n;i++)cout<<a[i]<<endl;
   
   return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mk make_pair
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[500];
int h,w,sum=0;
vector<int>x,y;
void del(int t1,int t2){
  vector<pair<char,pair<int,int> > >p;
  for(int i=t1;i<h;i++)if(s[i][t2]!='.'){
    p.push_back(mk(s[i][t2],mk(i,t2)));
    break;
  }
  for(int i=t1;i>=0;i--)if(s[i][t2]!='.'){
    p.push_back(mk(s[i][t2],mk(i,t2)));
    break;
  }
  for(int i=t2;i<w;i++)if(s[t1][i]!='.'){
    p.push_back(mk(s[t1][i],mk(t1,i)));
    break;
  }
  for(int i=t2;i>=0;i--)if(s[t1][i]!='.'){
    p.push_back(mk(s[t1][i],mk(t1,i)));
    break;
  }
  sort(p.begin(),p.end());
  if(p.size()>=2){
    r(i,p.size()-1){
      if(p[i].first==p[i+1].first){
        sum++;
        s[p[i].second.first][p[i].second.second]='.';
        s[p[i+1].second.first][p[i+1].second.second]='.';
      }
    }
  }
}
int main(){
  cin>>h>>w;
  r(i,h)cin>>s[i];
  r(i,h)r(j,w)if(s[i][j]!='.'){
      y.push_back(i),x.push_back(j);
      if(i+1<h)y.push_back(i+1);
      if(j+1<w)x.push_back(j+1);
    }
  r(k,7)r(i,y.size())r(j,x.size())
    if(s[y[i]][x[j]]=='.')del(y[i],x[j]);
  cout<<sum*2<<endl;
}

Measured memory_bytes: 3380
def resolve():
    H, W = map(int, input().split())
    A = []
    count = 0
    ans = []
    for _ in range(H):
        a = input()
        flag = 0
        for __ in range(W):
            if a[__] == "#":
                flag = 1
        if flag == 1:
            A.append(a)
            count += 1
    for i in range(W):
        flag = 0
        for j in range(count):
            if A[j][i] == "#":
                flag = 1
        if flag == 0:
            ans.append(i)
    for p in range(count):
        anan = ""
        for q in range(W):
            if q not in ans:
                anan += A[p][q]
        print(anan)
resolve()

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

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

    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z), d, ans;
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());

    rep(i, x) rep(j, y) d.push_back(a[i] + b[j]);
    sort(d.begin(), d.end(), greater<ll>());

    rep(i, z) rep(j, min(x * y, k)) ans.push_back(c[i] + d[j]);
    sort(ans.begin(), ans.end(), greater<ll>());

    rep(i, k) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 43368
import math
A,B,H,M=map(int,input().split())
h1=H*30+(M/60)*30
C=min(abs(((H+(M/60))*30)-M*6),abs(abs(((H+(M/60))*30)-M*6)-360))

ansr=A**2+B**2-(2*A*B*round(math.cos(math.radians(C)),10**9))
print(ansr**0.5)

Measured memory_bytes: 62608
S = input()

S = sorted(S)

S_dict = {}
cnt = 0
#ord : return number of character based on character
#chr : return character based on number of character
for i in range(ord("a"), ord("z") +1):
  S_dict[i] = S.count(chr(i))

#print(S_dict)

ans =None
for i in range(ord("a"), ord("z") +1):
  if S_dict[i] == 0:
    ans = chr(i)
    break
    
print(ans)

Measured memory_bytes: 4408
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;





string S[2 * 10000];
int main() {
	cin >> N;
	rep(i, N)
		cin >> S[i];


	ll ans = 0;
	ll cntA = 0, cntB = 0, cntAB = 0;
	rep(i, N) {
		rep(j, S[i].size() - 1) {

			if (S[i][j] == 'A' && S[i][j + 1] == 'B') {
				ans += 1;
			}




		}

		if (S[i][S[i].size() - 1] == 'A' && S[i][0] != 'B') {
			cntA += 1;
		}

		if (S[i][S[i].size() - 1] != 'A' && S[i][0] == 'B') {
			cntB += 1;
		}

		if (S[i][S[i].size() - 1] == 'A' && S[i][0] == 'B') {
			cntAB += 1;
		}

	}

	

	if (cntAB != 0) {
		ans += cntAB - 1;
	
	}

	if (cntAB != 0 && cntA > 0) {
		ans += 1;
		cntA--;
	}

	if (cntAB != 0 && cntB > 0) {
		ans += 1;
		cntB--;
	}
	
	
	ans += min(cntA, cntB);

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1404
N,K,S = map(int,input().split())

ans = []
for i in range (K):
    ans.append(S)
for i in range (N-K):
    if S == 1:
        ans.append(2)
    elif S == 2:
        ans.append(3)
    else:
        ans.append(S-1)

answer = " ".join(map(str,ans))
print(answer)

Measured memory_bytes: 66208
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int m,n,K,d;
#define INF (1<<21)
struct EDGE{
	int from,to,cost;
	EDGE(int a,int b,int c){from = a , to = b , cost = c;}
};
int get(string s){
	if(s[0] == 'H')return n+m;
	if(s[0] == 'D')return n+m+1;
	if(s[0] == 'L')return m+atoi(s.substr(1).c_str())-1;
	if(s[0] == 'C')return atoi(s.substr(1).c_str())-1;
}
int main(){
	while(cin >> m >> n >> K >> d , m ){
		vector<int> cake(m);
		rep(i,m)cin >> cake[i];
		vector<EDGE> E;
		rep(i,d){
			string a,b; int c;
			cin >> a >> b >> c;
			E.push_back(EDGE(get(a),get(b),c*K));
			E.push_back(EDGE(get(b),get(a),c*K));
		}
		
		int d[1<<6][108];
		rep(i,1<<6)rep(j,108) d[i][j] = INF;
		d[0][n+m] = 0;
		
		while(true){
			bool update = false;
			rep(i,E.size()){
				EDGE e = E[i];
				rep(bit,1<<m){
					if( e.to < m && (bit & (1<<e.to))) continue;
					if( e.to < m ){
						if( d[bit|(1<<e.to)][e.to] > d[bit][e.from] + e.cost - cake[e.to]){
							d[bit|(1<<e.to)][e.to] = d[bit][e.from] + e.cost - cake[e.to];
							update = true;
						}
					}else{
						if( d[bit][e.to] > d[bit][e.from] + e.cost){
							d[bit][e.to] = d[bit][e.from] + e.cost;
							update = true;
						}
					}
				}
			}	
			if(!update)break;
		}
		int ans = INF;
		rep(i,1<<m){
			ans = min(ans,d[i][n+m+1]);
		}
		cout << ans << endl;
	}
}
	
	
	

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
ll n,k;
cin>>n>>k;
vector<ll > ans;
ll arr[n],sum=0;;
rep(i,0,n)
{

cin>>arr[i];
sum+=arr[i];
}
ll id=0;
rep(i,0,n-1)
{
	if(arr[i]+arr[i+1]>=k)
	{
		id=i;
		break;
}
	
}
if(arr[id]+arr[id+1]<k)
{
	cout<<"Impossible";
	return 0;
}
cout<<"Possible\n";
rep(i,1,id+1)
cout<<i<<endl;
rep(i,n,id+2)
cout<<i<<endl;
cout<<id+1;

}


Measured memory_bytes: 1664
#include <stdio.h>
 
int main(void)
{
    int i,k,n;
  k=0;
  n=0;
  scanf("%d",&k);
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++)
  {
  scanf("%d",&a[i]);
  }
  int kyori[n];
  
  for(i=0;i<n-1;i++)
  {
  kyori[i]=a[i+1]-a[i];
  }
  kyori[n-1]=k+a[0]-a[n-1];
  int max=kyori[0];
  for(i=0;i<n;i++)
  {
  if(kyori[i]>max)
    max=kyori[i];
  }
  int total=0;
  for(i=0;i<n;i++)
  {
  total=total+kyori[i];
  }
  total=total-max;
  printf("%d",total);
  
  return 0;
}

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

using namespace std;

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second


double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=200010;


int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
int n,m;
cin>>n>>m;
vector<vector<int> > dp(n+1,vector<int>(m+1,0));
char a[n+1][m+1];
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        cin>>a[i][j];
    }
}
if(a[1][1]!='*')dp[1][1]=1;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(a[i][j]=='.'){
            if(j-1>=1)(dp[i][j]+=dp[i][j-1])%=M;
            if(i-1>=1)(dp[i][j]+=dp[i-1][j])%=M;
        }
    }
}
cout<<dp[n][m]<<"\n";
}
return 0;
}


Measured memory_bytes: 8196
#include "bits/stdc++.h"

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

int H, W;
char field[50][51];
int d[50][50];

int wnum;

void bfs() {
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++) d[i][j] = INF;

	queue<P> que;
	que.push(make_pair(0, 0));
	d[0][0] = 1;
	while(que.size()) {
		P p = que.front(); que.pop();

		for(int i=0;i<4;i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
			if(field[nx][ny] == '#' || d[nx][ny] != INF) continue;

			que.push(make_pair(nx, ny));
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}
	return ;
}

int main(void){
	cin>>H>>W;
	for(int i=0;i<H;i++) {
		for(int j=0;j<W;j++) {
			cin>>field[i][j];
			if(field[i][j] == '.') wnum++;
		}
	}

	bfs();

	if(d[H - 1][W - 1] == INF) cout<< -1 <<endl;
	else cout<< wnum - d[H - 1][W - 1] <<endl;	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int64_t dp[3005][3005][5];
int main() {
  int R,C,K;
  cin>>R>>C>>K;
  vector<vector<int>>val(3005,vector<int>(3005));
  for(int i=0;i<K;i++){
    int a,b,v;
    cin>>a>>b>>v;
    a--;b--;
    val[a][b]=v;
  }

  dp[0][0][0]=0;
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      for(int k=3;k>=0;k--){
        if(val[i][j]>0&&k<=2){chmax(dp[i][j][k+1],dp[i][j][k]+val[i][j]);}
       for(int k=0;k<=3;k++){
        chmax(dp[i+1][j][0],dp[i][j][k]);
        chmax(dp[i][j+1][k],dp[i][j][k]);
       }
      }
    }
  }
  int64_t MAX=0;
  for(int k=0;k<=3;k++){
    chmax(MAX,dp[R-1][C-1][k]);
  }
  cout<<MAX<<endl;
  return 0;  
}

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

int f(ll n){
    int sum = 0;
    while(n){
        n/=10;
        sum++;
    }
    return sum;
}

int main(){
    ll n;
    cin>>n;
    int ans = 1e9;
    for(int i=1; i<=sqrt(n); i++){
        if(n%i==0){
            ans = min(ans, f(n/i));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256