akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 int MOD = 1000000007;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int count = 0;
    int tmp = 0;
    rep(i, 0, N) {
        if(S[i] == 'A') {
            tmp = 1;
        } else if(S[i] == 'B') {
            if(tmp == 1) {
                tmp = 2;
            } else {
                tmp = 0;
            }
        } else if(S[i] == 'C') {
            if(tmp == 2) {
                count++;
            }
            tmp = 0;
        } else {
            tmp = 0;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010;
char s[N];
int sum[N],n,m;
void init()
{
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1];
		if(s[i]=='C' && s[i-1]=='A')sum[i]++;
	}
}
int main()
{
	n=gi();m=gi();
	for(int i=1;i<=n;i++)s[i]=getchar();
	init();
	while(m--)
	{
		int l=gi(),r=gi();
		printf("%d\n",sum[r]-sum[l]);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	int* getNumber(){
		return number;
	}

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].getNumber()))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, x; cin >> n >> x;
  int acc = 0, ans = 0;
  REP (i, n) {
    int a; cin >> a;
    if (acc <= x) ans++;
    acc += a;
  }
  if (acc <= x) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
N,M = list(map(int,input().split()))
m = 0
n = 0
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if M>1:
    m =comb(M,2)
if N>1:
    n = comb(N,2)
ans = m +n
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k;cin>>n>>k;
  vector<int64_t>a(100007,0);
  int ai,bi;
  for(int i=0;i<n;i++){
    cin>>ai>>bi;
    a.at(ai-1)+=bi;
  }
  for(int i=0;i<100007;i++){
    k-=a.at(i);
    if(k<=0){
      cout <<i+1<<endl;
      return 0;
    }
  }
}

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

int main() {
	int n;
	string s;
	cin >> n;
	for(int i=0;i<n;i++){
		int d;
		cin >> d;
		s+=to_string(d);
	}
	for(int i=0;1;i++){
		if(s.find(to_string(i)) != string::npos) continue;
		cout << i << endl;
		break;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i+1; j < n -1; ++j) {
      if (l[i] == l[j]) continue;
      for (int k = j+1; k < n; ++k) {
        if (l[j] == l[k]) continue;
        if (l[i] + l[j] > l[k]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> D(13);
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D[d]++;
	}

	int ans = 0;
	for (int bit = 0b0; bit < (1 << 13); bit++) {

		vector<int> time{ 0 };
		time.reserve(N);
		for (int i = 0; i < 13; i++) {
			for (int j = 0; j < min(D[i],3); j++) {
				if (!(bit & (1 << i) ^ (j & 1))) time.emplace_back(i);
				else time.emplace_back(24 - i);
			}
		}

		DMP(time);

		int s = INF;
		for (int i = 0; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				chmin(s, min(abs(time[i] - time[j]), 24 - abs(time[j] - time[i])));
			}
		}
		chmax(ans, s);

	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector <char>> a(h, vector<char>(w));
    vector<int> b(h), c(w);

    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> a.at(i).at(j);
        }
    }

    int flg;
    for (int i=0; i<h; i++){
        int flg = 1;
        for (int j=0; j<w; j++){
            if (a.at(i).at(j) == '.'){
                flg *= 1;
            }else{
                flg *= 0;
            }
        }
        b.at(i) = flg;
    }

    for (int j=0; j<w; j++){
        int flg = 1;
        for (int i=0; i<h; i++){
            if (a.at(i).at(j) == '.'){
                flg *= 1;
            }else{
                flg *= 0;
            }
        }
        c.at(j) = flg;
    }

    for(int i=0; i<h; i++){
        if (b.at(i) == 1){
            continue;
        }
        for (int j=0; j<w; j++){
            if(c.at(j) == 0){
                cout << a.at(i).at(j);
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1000005,MK=20005;
const long long P=1000000007;
long long Fac[M],IFac[M],dp[M];
int n,m,K,x,y;
struct node{
	int x,y;
	bool operator <(const node &_)const{
		if(x!=_.x)return x<_.x;
		return y<_.y;
	}
}A[MK];
int C(int K,int m){
	return Fac[K]*IFac[m]%P*IFac[K-m]%P;
}
int main(){
	Fac[0]=IFac[0]=IFac[1]=1;
	for(int i=1;i<M;i++)Fac[i]=i*Fac[i-1]%P;
	for(int i=2;i<M;i++)IFac[i]=-P/i*IFac[P%i]%P;
	for(int i=1;i<M;i++)IFac[i]=IFac[i]*IFac[i-1]%P;
	scanf("%d%d%d",&n,&m,&K);
	for(int i=0;i<K;i++)
		scanf("%d%d",&A[i].x,&A[i].y);
	sort(A,A+K);
	A[K]=(node){n,m};
	for(int i=0;i<=K;i++){
		dp[i]=C(A[i].x+A[i].y-2,A[i].x-1);
		for(int j=0;j<i;j++){
			int x=A[i].x-A[j].x,
				y=A[i].y-A[j].y;
			if(x>=0&&y>=0)dp[i]=(dp[i]-dp[j]*C(x+y,x))%P;
		}
	}
	printf("%lld\n",(dp[K]+P)%P);
	return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B;
  C = (B - 1) / (A - 1);
  if ((B - 1) % (A - 1) == 0)
    cout << C << endl;
  else
    cout << C + 1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T, class U> inline T GCD_L(T a, U b){
  T r;
  while(b){
    r=a;
    a=b;
    b=r%a;
  }
  return a;
}
int main(){
  int i;
  int K;
  long long res = 0;
  rd(K);
  for(i=(1);i<(K+1);i++){
    int j;
    for(j=(1);j<(K+1);j++){
      int k;
      for(k=(1);k<(K+1);k++){
        res +=GCD_L(GCD_L(i, j), k);
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200412-1

// --- original code ---
// {
//   int K;
//   ll res = 0;
//   rd(K);
//   rep(i,1,K+1) rep(j,1,K+1) rep(k,1,K+1) res += gcd(i,j,k);
//   wt(res);
// }


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        long[] input = new long[3];
        for(int i = 1; i <= n; i++){
            input[0] = i;
            for(int j = 1; j <= n; j++){
                input[1] = j;
                for(int k = 1; k <= n; k++){
                    input[2] = k;
                    ans += gcd(input);
                }
            }
        }
        System.out.println(ans);
    }

    private static long gcd(long a, long b){
        while (b > 0){
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }
    private static long gcd(long[] input){
        long result = input[0];
        for(int i = 1; i < input.length; i++){
            result = gcd(result, input[i]);
        }
        return result;
    }

    private static long lcm(long a, long b){
        return a * (b / gcd(a, b));
    }

    private static long lcm(long[] input){
        long result = input[0];
        for(int i = 1; i < input.length; i++){
            result = lcm(result, input[i]);
        }
        return result;
    }

    public static int gcd(int num1,int num2) {
        if(num2==0) return num1;
        else return gcd(num2,num1%num2);
    }


}

Measured memory_bytes: 27348
H, W = [int(n) for n in input().split()]

matrix = []

for i in range(H):
  matrix.append(list(input()))

white = ['.'] * W

pop_list = []
counter = 0

i = H - 1
while i >= 0:
  if matrix[i] == white:
    matrix.pop(i)
    counter += 1
  i -= 1

white = ['.'] * (H - counter)
i = W - 1
 
while i >= 0:
  current_col = [r[i] for r in matrix]
  if current_col == white:
    for j, r in enumerate(matrix):
      matrix[j].pop(i)
  i -= 1

for r in matrix:
  for rr in r:
    print(rr, end = '')
  print('\n')

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

using namespace std;

struct UnionFind {
    std::vector<int> par; // pos: parent node, neg: rank of tree

    UnionFind(int N) : par(N, -1) {}

    int find(int x){
        if(par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;

        int rx = -par[x], ry = -par[y];
        if(rx < ry) std::swap(x, y); // merge technique
        par[x] = -(rx+ry);
        par[y] = x;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};


int main(void){
    int N, M;
    cin >> N >> M;

    vector<int> p(N);
    for(auto& x : p) {
        cin >> x;
        x--;
    }

    UnionFind uf(N);
    for(int i=0;i<M;i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        if(uf.same(i, p[i])) ans++;
    }

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

Measured memory_bytes: 1024
n=int(input())
a_=[]
b_=[]

for i in range(n):
    a,b = map(int,input().split())
    a_.append([a+b,a,i])
    b_.append([a+b,b,i])

sa_ = sorted(
  a_,
  key = lambda x: (x[0], x[1]),
)
sb_ = sorted(
  b_,
  key = lambda x: (x[0], x[1]),
)

i_={}
res=0

for i in range(n):
    if i % 2 :
        item = sb_.pop()
        while ( item[2] in i_ ) :
            item = sb_.pop()
        res -= item[1]
        i_[item[2]]=1
    else :
        item = sa_.pop()
        while ( item[2] in i_ ) :
            item = sa_.pop()
        res += item[1]
        i_[item[2]]=1

print(res)

Measured memory_bytes: 55476
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<size_t> sort_indexes(const vector<int> &v) {

  // initialize original index locations
  vector<size_t> idx(v.size());
  for(int i=0; i<v.size();i++){
      idx[i]=i;
  }

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});

  return idx;
}

int main(int argc, char const *argv[]){
    int n;
    cin >> n;
    vector<int> a, b;
    int work = 0;
    for(int i=0;i<n;i++){
        int _a, _b;
        cin >> _a >> _b;
        a.push_back(_a);
        b.push_back(_b);
    }
    vector<size_t> idx(n);
    idx = sort_indexes(b);
    for(int i=0;i<n;i++){
        work += a[idx[i]];
        if(work>b[idx[i]]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
int main() {
	int q;
	std::cin >> q;
	std::set<int> set;
	for (int i = 0; i < q; ++i) {
		int t, x;
		std::cin >> t >> x;
		switch (t) {
		case 0: set.insert(x);
			std::cout << set.size() << std::endl;
			break;
		case 1:
			std::cout << set.count(x) << std::endl;
			break;
		default:
			set.erase(x);
		}
	}
}


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


int main() {
  int N,M,R;
  cin >> N>>M>>R;
  vector<int>r(R);
  rep(i,R){
    cin>>r.at(i);
    r.at(i)--;
  }
  vector<int>a(M),b(M),c(M);
  rep(i,M){
    cin>>a.at(i)>>b.at(i)>>c.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<vector<int>>dist(N,vector<int>(N));
  rep(i,N) {
      rep(j,N) {
        dist[i][j]=1001001001;
      }
  }
  rep(i,N){
    dist[i][i]=0;
  }
  rep(i,M){
    dist[a.at(i)][b.at(i)]=c.at(i);
    dist[b.at(i)][a.at(i)]=c.at(i);
  }
  rep(k,N){
    rep(i,N) {
      rep(j,N) {
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  int ans=1001001001;
  
  sort(r.begin(), r.end());
  do {
    int an=0;
    rep(i,r.size()-1){
      an+=dist[r.at(i)][r.at(i+1)];
    }
    ans=min(ans,an);
  } while (next_permutation(r.begin(), r.end()));

  cout<<ans<<endl;
}




Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>

int main(int argc, char const *argv[]) {
  int x=0,t=0;
  std::cin >> x;
  std::vector<int> v(x);
  for (size_t i = 0; i < x; i++) {
    std::cin >> v[i];
    //std::cout << v[i] << '\n';
  }
  std::sort(v.begin(),v.end());
  t=v[x-1]-v[0];
  std::cout << t << '\n';

  return 0;
}


Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
l=360/60*m
s=360/12*(h+m/60)
if abs(l-s)>180:
 t=360-abs(l-s)
else:
 t=abs(l-s)
ans=(a**2+b**2-2*a*b*(math.cos(t*(math.pi)/180)))**(1/2)
print(ans)

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  
  int count = 0;
  
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
    if(h.at(i)>=k){
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mx 10000000000008
#define mod 1000000007
ll n,t,arr[sz],brr[sz];
vector<ll>v;
char c[sz];
int main()
{
   // scanf("%lld",&t);
    t=1;
    while(t--)
    {
        scanf("%lld",&n);
        while(n--)
            printf("ACL");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n), s(n+1, 0);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        s[i+1] = s[i] + a[i];
    }

    ll mina = s[n];
    rep(i, n){
        // cout << s[i] << " " << s[n] - s[i] << endl;
        mina = min(mina, abs(s[i] - (s[n] - s[i])));
    }


    cout << mina << endl;

}

Measured memory_bytes: 6436
// abc159_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    int N = S.size();

    string a, b;
    REP(i, N/2+1){
        a += S[i];
        b += S[N-i-1];
    }

    if (a != b){
        print("No");
        return 0;
    }

    a = "";
    b = "";
    int x = (N-1)/2;
    REP(i, x/2){
        a += S[i];
        b += S[x-i-1];
    }

    if (a != b){
        print("No");
        return 0;
    }

    a = "";
    b = "";
    int y = (N + 3)/2 - 1;
    REP(i, x/2){
        a += S[y+i];
        b += S[N-i-1];
    }

    if (a != b){
        print("No");
        return 0;
    }

    print("Yes");


    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N);
    rep(i,N) cin>>a[i];
    vector<mint> sum(N+1);
    rep(i,N) sum[i+1]=sum[i]+a[i];
    mint ans = 0;
    RFOR(i,N-1,0){
        ans+=sum[i]*a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6336
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	ll tmp = m / 2;
	ll p = min(tmp, n);
	ll ans = p;
	m -= 2 * p;
	ans += m / 4;
	cout << ans << endl;
	return 0;
}



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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [usize; n]
    }
    let t = v.iter().cloned().sum::<usize>();
    let c = v.iter().filter(|&x| x * 4 * m >= t).count();
    println!("{}", if c < m {"No"} else {"Yes"});
}


Measured memory_bytes: 4352
from _collections import deque


def bfs(init, n, gi):
    queue = deque([init])
    d = [-1] * n
    d[init] = 0
    while queue:
        popped = queue.popleft()
        for ii in gi[popped]:
            if d[ii] == -1:
                d[ii] = popped + 1
                queue.append(ii)
    return d


N, M = map(int, input().split())
g = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

get = bfs(0, N, g)
ans = [0] * N
if -1 in get:
    print('No')
else:
    print('Yes')
    for i in range(1, len(get)):
        print(get[i])



Measured memory_bytes: 37332
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

const int N=705;

int n,m,x,y,c1,c2;
int dp[2][N],g[N][N],c[N];

bool dfs(int k,int col){
	if (!c[k]){
		c[k]=col;
		if (col==1) c1++;
		else c2++;
	}
	else return (c[k]==col);
	int i;
	for (i=1;i<=n;i++)
		if (!g[k][i]){
			if (!dfs(i,-col)) return 0;
		}
	return 1;
}

int main(){
	int i,j,now,pre;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) g[i][i]=1;
	for (i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		g[x][y]=g[y][x]=1;
	}
	dp[0][0]=1; now=0; pre=1;
	for (i=1;i<=n;i++) if (!c[i]){
		c1=c2=0;
		if (!dfs(i,1)){
			printf("-1\n");
			return 0;
		}
		now^=1; pre^=1;
		memset(dp[now],0,sizeof(dp[now]));
		for (j=0;j<=n;j++)
			if (dp[pre][j]){
				dp[now][j+c1]=1;
				dp[now][j+c2]=1;
			}
	}
	for (i=n/2;i>=1;i--) if (dp[now][i]){
		printf("%d\n",i*(i-1)/2+(n-i)*(n-i-1)/2);
		return 0;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int n, y;

int main()
{
	cin >> n >> y;
	vector<int> mi(n + 1);
	vector<int> hm(n + 1);
	vector<int> th(n + 1);
	rep(i, n + 1) {
		mi[i] = 10000 * i;
		hm[i] = 5000 * i;
		th[i] = 1000 * i;
	}
	
	int ans[3] = { 0 };
	bool flag = false;
	rep(i, n + 1) {
		rep(j, n + 1) {
			int tt = n - i - j;
			if (tt < 0)  continue;
			if (mi[i] + hm[j] == y - th[tt]) {
				ans[0] = i;
				ans[1] = j;
				ans[2] = tt;
				flag = true;
				break;
			}
		}
	}
	if (flag) {
		rep(i, 3) {
			if (i)cout << ' ';
			cout << ans[i];
		}
		cout << endl;
	}
	else  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  vector<string> a(n);
  for (auto& s : a) {
    cin >> s;
  }
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, 1, 0, -1};
  auto bfs = [&] (int x, int y) {
    queue<pair<int, int>> q;
    q.emplace(x, y);
    int res = 0;
    vector<vector<int>> dist(n, vector<int>(m, -1));
    dist[x][y] = 0;
    while (!q.empty()) {
      tie(x, y) = q.front();
      q.pop();
      for (int i = 0; i < 4; ++i) {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if (0 <= tx && tx < n && 0 <= ty && ty < m &&
            a[tx][ty] == '.' && dist[tx][ty] == -1) {
          q.emplace(tx, ty);
          dist[tx][ty] = dist[x][y] + 1;
          res = max(res, dist[tx][ty]);
        }
      }
    }
    return res;
  };
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == '.') {
        ans = max(ans, bfs(i, j));
      }
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int ans[100][2],degree,count=1;
int arr[100][100],visible[100];
void dfs(int i)
{
	for(int j=0;j<degree;j++)
	{
		if(arr[i][j]==1 && visible[j]==0)
		{			
			ans[j][0]=count++;
			visible[j]=1;
			dfs(j);
			ans[j][1]=count++;
		}
	}
}
int main()
{
	int number,num;
	cin>>degree;

	for(int i=0;i<100;i++)
	{
		visible[i]=0;
	}	
	for(int i=0;i<degree;i++)
	{
		for(int j=0;j<degree;j++)
		{
			arr[i][j]=0;
		}
	}
	for(int i=0;i<degree;i++)
	{
		cin>>number;
		cin>>number;
		for(int j=0;j<number;j++)
		{
			cin>>num;
			arr[i][num-1]=1;
		}
	}
	for(int i=0;i<degree;i++)
	{
		if(visible[i]==0)
		{
			ans[i][0]=count++;
			visible[i]=1;
			dfs(i);
			ans[i][1]=count++;
		}
	}
	for(int i=0;i<degree;i++)
	{
		cout<<i+1<<" "<<ans[i][0]<<" "<<ans[i][1]<<endl;
	}
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=5e3;
const int mod=998244353;
template <typename T> inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
typedef long long ll;
template<typename T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;return;}
template<typename T>inline void Dec(T&x,int y){x-=y;if(x <  0) x+=mod;return;}
template<typename T>inline int fpow(int x,T k){int ret=1;for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;return ret;}
inline int Sum(int x,int y){x+=y;if(x>=mod) return x-mod;return x;}
inline int Dif(int x,int y){x-=y;if(x < 0 ) return x+mod;return x;}
int n,k;
int fac[N],finv[N];
inline void Sieve(const int n){
	fac[0]=finv[0]=1;
	for(int i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod;
	finv[n]=fpow(fac[n],mod-2);
	for(int i=n-1;i;--i) finv[i]=(ll)finv[i+1]*(i+1)%mod;
	return;
}
inline int C(int n,int m){return n<m? 0:((ll)fac[n]*finv[m]%mod*finv[n-m]%mod);}
inline int CalcUP(int K,int n){return C(K,n);}
inline int CalcDO(int K,int n){return C(n+K-1,K-1);}
int main()
{
	init(k),init(n);Sieve(4000);
	for(int i=2;i<=(k<<1);++i) {
		int UP=0,DO=0;

		for(int j=1;j<=k;++j) {
			int l=i-j;
			if(j==l) ++UP;
			else if(j<l) {
				if(l<=k) ++UP,++DO;
				else ++DO;
			}else if(l<=0) ++DO;
		}
		int ans=0;
		for(int j=0;j<=n;++j) Inc(ans,(ll)CalcUP(UP,j)*CalcDO(DO,n-j)%mod);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int n, l, r;
    while (cin >> n >> l >> r, n) {
        vector<int> A(n);
        REP (i, n) cin >> A[i];
        A.push_back(1);
        int ans = 0;
        FOR (y, l, r + 1) {
            REP (i, A.size()) {
                if (y % A[i] == 0) {
                    if (i % 2 == 0) ans++;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


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

int main() {
    int t[4][13];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char item;
        int rank;
        
        cin >> item >> rank;
        
        if ( item == 'S') {
            t[0][rank - 1] = rank;
        }else if (item == 'H') {
            t[1][rank - 1] = rank;
        }else if (item == 'C') {
            t[2][rank - 1] = rank;
        }else if (item == 'D') {
            t[3][rank - 1] = rank;
        }
    }
    for (int k = 0; k < 4; k++) {    
        for (int j = 0; j< 13; j++) {
            if (t[k][j] != j + 1) {
                if (k == 0) {
                cout << "S" << " " << j + 1 << endl;
                }else if (k == 1) {
                cout << "H" << " " << j + 1 << endl;
                }if (k == 2) {
                cout << "C" << " " << j + 1 << endl;
                }if (k == 3) {
                cout << "D" << " " << j + 1 << endl;
                }
            }
        }
    }

        
}


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <complex>
#include <cmath>
using namespace std;


int main(int argc, char const *argv[]) {
    long long n;cin>>n;
    long long a,b;cin>>a>>b;
    long long s=0,t=0,u=0;
    for(int i=0;i<n;++i){
        long long tmp;cin>>tmp;
        if(tmp<=a)s++;
        else if(tmp<=b)t++;
        else u++;
    }
    cout<<min(s, min(t,u))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b)
{
  if(b < a){
    int c = a;
    a = b;
    b = c;
  }
  int r;
  while((r = b%a) > 0){
    b = a;
    a = r;
  }
  return a;
}

int max(int a, int b)
{
  if(a < b){
    return b;
  } else {
    return a;
  }
}

int main(void){
  int N;
  scanf("%d", &N);
  int A[N];
  int B[N];
  int C[N];
  for(int i = 0; i < N; i++){
    scanf("%d", &(A[i]));
  }
  B[0] = A[0];
  for(int i = 1; i < N; i++){
    B[i] = gcd(B[i-1], A[i]);
  }
  C[N-1] = A[N-1];
  for(int i = N-2; 0 <= i; i--){
    C[i] = gcd(C[i+1], A[i]);
  }
  int m = max(B[N-2], max(C[0], C[1]));
  for(int i = 1; i < N-1; i++){
    int g = gcd(B[i-1], C[i+1]);
    m = max(m, g);
  }
  printf("%d", m);
	return 0;
}


Measured memory_bytes: 1280
n,t0=input().split()

ans=1000
flag=0

for i in range(int(n)):
  c,t=input().split()
  if int(t) <=int(t0):
    flag=1
    if int(c) < ans:
      ans=int(c)
      
print(ans if flag==1 else 'TLE')



Measured memory_bytes: 2940
///WRONG LIFE
///DIE(RETRY)
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using row = vector<int>;
using ii = pair<int, int>;

const int N = 2e5 + 5, M = 26, A = 6561, LG = 19, MOD = 998244353;
const int BLOCK = 500;
const long double EPS = 1e-7;
using pii = pair<int,int>;
ll X[N];
int n, L;
ll sum[2][N];

int main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  cin >> L >> n;
  f(i,1,n+1)
    cin >> X[i];
  f(i,1,n+1){
    sum[0][i] = sum[0][i-1]+X[i];
  }
  for(int i=n;i>=1;--i){
    sum[1][i]=sum[1][i+1]+L-X[i];
  }

  ll ans = max(L-X[1],X[n]);

  f(i,1,n){
    int idx = min(i,n-i);
    ll val = 2 * (sum[0][i] - sum[0][i-idx] + sum[1][i+1] - sum[1][i+1+idx]);
    ans = max(ans, (val - X[i]) + ((i > idx) ? 2 * X[i-idx] : 0));
    ans = max(ans, val - (L - X[i+1]) + (((n-i) > idx) ? 2 * (L-X[i+1+idx]): 0));
//    cerr<<ans<<'\n';
  }

  cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if(a == b && b == c) {
		printf("No");
	} else if(a == b || a == c || b == c) {
		printf("Yes");
	} else printf("No");
	
	
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  //
  using ll = long long;
  ll n, m;
  cin >> n >> m;
  if (n >= 2) {
    n -= 2;
  }

  if (m >= 2) {
    m -= 2;
  }

  cout << n * m << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int x,y,t,lastx,lasty,lastt,dist;
    lastt = 0; lastx = 0; lasty = 0;
    for (int i = 0; i < n; i++){
      t = Integer.parseInt(sc.next());
      x = Integer.parseInt(sc.next());
      y = Integer.parseInt(sc.next());
      dist = Math.abs(x-lastx) + Math.abs(y-lasty);
      if (!(dist <= (t-lastt) && (t-lastt-dist)%2 == 0)){
        System.out.println("No");
        return;
      }
      lastx = x; lasty = y; lastt = t;
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 57944
def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a+1
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3))  


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			if(n==0){
				break;
			}
			int num = app.countNum(n);
			System.out.println(app.toYear(num));
		}
	}
	
	public int countNum(int n){
		int count;
		
		if(n==1){
			count = 1;
		}else if(n==2){
			count = 2;
		}else if(n==3){
			count = 4;
		}else{
			count = countNum(n-3)+countNum(n-2)+countNum(n-1);
		}
		
		return count;
	}
	
	public int toYear(int num){
		return (num/10/365)+1;
	}
}

Measured memory_bytes: 19296
n, p = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr


ans = 1
for a, b in factorization(p):
    ans *= pow(a, b // n)

print(ans)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  rep(i, 101) rep(j, 101) {
    int H;
    rep(k, n) if (h[k] > 0) H = h[k] + abs(i - x[k]) + abs(j - y[k]);
    bool flg = true;
    rep(k, n) {
      if (h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0)) flg = false;
    }
    if (flg) {
      cout << i << " " << j << " " << H << endl;
      return 0;
    }
  }
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;
  
  //main
  map<char,int> mp;
  for(int i=0; i<S.length(); i++){
    if(mp.find(S[i]) != mp.end()){ mp[S[i]] ++; }
    else{ mp.insert({S[i],1}); }
  }
  
  // output
  if(mp.size() == 2 && mp[S[0]] == 2){ cout << "Yes" << endl;}
  else{ cout << "No" << endl; }

  return 0;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
if N==2:
    if x==2:
        print('Yes')
        for i in range(1,4):
            print(i)
    else:
        print('No')
else:
    if x==1 or x==2*N-1:
        print('No')
    elif x==2:
        print('Yes')
        S=[]
        T=[2*N-1,1,2,3,2*N-2]
        U=[]
        count=0
        for i in range(1,2*N):
            if (not i in T) and N-3>count:
                S.append(i)
                count+=1
                continue
            if (not i in T) and count>=N-3:
                U.append(i)
                continue
        ans=S+T+U
        for i in range(0,2*N-1):
            print(ans[i])
    elif x==2*N-2:
        print('Yes')
        S=[]
        T=[3,1,2*N-2,2*N-1,2]
        U=[]
        count=0
        for i in range(1,2*N):
            if (not i in T) and N-3>count:
                S.append(i)
                count+=1
                continue
            if (not i in T) and count>=N-3:
                U.append(i)
                continue
        ans=S+T+U
        for i in range(0,2*N-1):
            print(ans[i])
    else:
        print('Yes')
        S=[]
        T=[2*N-1,2,x,2*N-2,1]
        U=[]
        count=0
        for i in range(1,2*N):
            if (not i in T) and N-3>count:
                S.append(i)
                count+=1
                continue
            if (not i in T) and count>=N-3:
                U.append(i)
                continue
        ans=S+T+U
        for i in range(0,2*N-1):
            print(ans[i])

Measured memory_bytes: 52896
using System;
using System.Collections.Generic;

namespace B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());

            List<int> candidates = new List<int>();
            for(int i = 1; i < 10; i++)
            {
                for(int j = 1; j < 10; j++)
                {
                    candidates.Add(i * j);
                }
            }

            if(candidates.Exists(c => c == N))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  cin>>N>>M>>C;
  
  int B[M];
  int A[N][M];
  
  for(int i=0;i<M;i++){
  	cin>>B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
  		cin>>A[i][j];
    }
  }
  int count=0;
  for(int i=0;i<N;i++){
    int ans=0;
    for(int j=0;j<M;j++){
      ans+= A[i][j] * B[j] ;
    }
    ans+=C;
    if(ans > 0)count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256