akhauriyash/Code-Regression huggingface dataset:
INF = float('inf')

def merge(lst,left,middle,right):
    cnt = 0
    left_lst  =  lst[left:middle] + [INF]
    right_lst = lst[middle:right] + [INF]

    i,j = 0,0
    for k in range(left,right):
        if left_lst[i] <= right_lst[j]:
            lst[k] = left_lst[i]
            i += 1
        else:
            lst[k] = right_lst[j]
            j += 1
            cnt += (len(left_lst)-1) - i
    return cnt

def merge_sort(lst,left,right):
    if left+1 < right:
        middle = (left+right)//2
        a = merge_sort(lst,left,middle)
        b = merge_sort(lst,middle,right)
        c = merge(lst,left,middle,right)
        return a+b+c
    return 0

n = int(input())
n_lst = list(map(int,input().split()))
ans = merge_sort(n_lst,0,n)
print(ans)



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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n=s.size();
    int l=0;
    int r=n-1;
    int cnt=0;
    while(r-l>0) {
        if(s[l]==s[r]){
            l++;
            r--;
        }
        else{
            if(s[l]=='x'){
                l++;
                cnt++;
            }
            else if(s[r]=='x'){
                r--;
                cnt++;
            }
            else{
                cout << "-1" << "\n";
                return 0;
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3768
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

int main(){
    ll N; cin >> N;
    map<ll, ll> m;
    REP(i, N){
        ll a; cin >> a;
        m[a]++;
    }
    
    ll s1 = 0, s2 = 0;
    for(auto it = m.begin(); it != m.end(); it++){
        if(it->second < 2) continue;
        ll a = it->first;
        if(a > s1){
            if(it -> second >= 4){
                s2 = a; s1 = a;
            }
            else{
                s2 = s1;
                s1 = a;
            }
        }
        else if (a > s2){
            s2 = a;
        }
    }
    cout << s1 * s2 << endstr;
    return 0;
}


Measured memory_bytes: 6528
import java.util.*;
import java.io.*;
import java.lang.*;
 
public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {

    // }    

    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();

    double ans = (double) n / x; 
    int div = (int) Math.ceil(ans);

    wr.println(div*t); 
        
    wr.flush();
    wr.close();
  }
}

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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
ll n, m, a[maxn];
map<int, int> M, N;
set<int> S;
string s;

void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        M[a[i]]++;
    }
    int cnt=0;
    for(auto u : M)
        if(u.second%2)cnt++;
    cout << cnt;
}
//1212135 34343434343
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solve();
}


Measured memory_bytes: 8952
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  string s;
  cin >> s;
  deque<char> deq;
  rep(i, s.size()) {
    deq.push_back(s[i]);
  }

  bool rev = false;
  ll q;
  cin >> q;
  rep(i, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      rev = !rev;
    } else { // t==2
      ll f;
      char c;
      cin >> f >> c;
      if (f == 1) { // prev
        if (rev) {
          deq.push_back(c);
        } else {
          deq.push_front(c);
        }
      } else { // back
        if (rev) {
          deq.push_front(c);
        } else {
          deq.push_back(c);
        }
      }
    }
  }
  // Here, deq has result.
  string res;
  rep(i, deq.size()) {
    res += deq[i];
  }
  if (rev) { // reversed
    reverse(all(res));
  }

  cout << res << endl;
}


Measured memory_bytes: 1368
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

using Bint = mp::cpp_int;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
  Bint mul=1;
  bool che=false;
  rep(i,N) if(A[i]==0) che=true;
  if(che){
    cout << 0 << endl;
    return 0;
  }
  lint cmp=1e18;
  rep(i,N){
    mul*=A[i];
    if(mul>cmp){
      cout << -1 << endl;
      return 0;
    }
}
  if(mul>cmp) cout << -1 << endl;
  else cout << mul << endl;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int arr[n];
 for(int i=1;i<=n;i++){
   cin>>arr[i];
 }for(int i=1;i<=n;i=i+2){
   if(arr[i]%2!=0)
     c++;
 }cout<<c;
  return 0;
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	string s;
	getline(cin, s);
	int n = sz(s);
	int ans = n;
	forn(c, 26) {
		int mx = 0;
		for (int i = 0; i < sz(s);) {
			if (s[i] == char(c + 'a')) {
				i++;
				continue;
			}
			int j = i;
			for (; j < n && s[j] != char(c + 'a'); ++j);
			umx(mx, j - i);
			i = j;
		}
		umn(ans, mx);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstddef>
#include <iostream>
#include <vector>

// bool isprime[100000000];

// void eratos(int n)
// {
//     for (auto &x : isprime)
//         x = true;

//     isprime[0] = false;
//     isprime[1] = false;

//     for (int i = 2; i <= sqrt(n); ++i)
//     {
//         if (isprime[i])
//         {
//             for (int j = 2; i * j <= n; ++j)
//             {
//                 isprime[i * j] = false;
//             }
//         }
//     }
// }

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

    int maxin = 0;
    std::vector<int> inputs;
    inputs.resize(n);
    for (size_t i = 0; i < n; ++i)
    {
        std::cin >> inputs[i];
        if (inputs[i] > maxin)
            maxin = inputs[i];
    }

    //    eratos(maxin);

    int ans = 0;
    for (auto x : inputs)
    {
        // if (isprime[x])
        //     ans++;
        bool prime = true;
        for (int i = 2; i <= sqrt(x); ++i)
        {
            if (x % i == 0)
            {
                prime = false;
            }
        }
        if (prime)
            ans++;
    }

    std::cout << ans << std::endl;
}



Measured memory_bytes: 3104
H, W = map(int, input().split())
Sij = [input() for _ in range(H)]

diff = [[-1, 0], [1, 0], [0, -1], [0, 1]]
def is_isolated(y, x):
    if Sij[y][x] != "#":
        return False
    for d in diff:
        y2 = y + d[0]
        x2 = x + d[1]
        if y2 >= 0 and y2 < H and x2 >= 0 and x2 < W:
            if Sij[y2][x2] == "#":
                return False
    return True

out = "Yes"
for y in range(H):
    for x in range(W):
        if is_isolated(y, x):
            out = "No"
            break
print(out)




Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    int N, M;
    cin >> N >> M;

    vector<vector<int>> L(M, vector<int>(2));
    for(int i = 0; i < M; i++){
        cin >> L[i][0] >> L[i][1];
    }

    int first = 1;
    int end = 1000000;
    for (int i = 0; i < M; i++){
        if (first < L[i][0]) first = L[i][0];
        if (end > L[i][1]) end = L[i][1]; 
    }

    if (first <= end) cout << (end - first + 1) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,K;


int main()
{
  string s;
  cin >> s;
  vector<vector<int> > vp;
  bool flag = false;
  bool vflag = false;
  vector<int> v;
  REP(i, 0, s.size())
  {
    if(s[i]=='A'){
      if(flag){
        if(v.size()!=0){
          vp.push_back(v);
          v.clear();
          if(i==s.size()-1){
            vflag = true;
          }
        }
        v.push_back(1);
        flag = false;
      }
      else
      {
        v.push_back(1);
        flag = false;
      }
    }
    else if (s[i] == 'B')
    {
      if(!flag){
      flag = true;
      }else{
        if(v.size()!=0){
          vp.push_back(v);
          v.clear();
          if(i==s.size()-1){
            vflag = true;
          }
        }

      }
    }else if(s[i]=='C'){
      if(flag){
        flag = false;
        v.push_back(0);
      }
      else
      {
        if(v.size()!=0){
          vp.push_back(v);
          v.clear();
          if(i==s.size()-1){
            vflag = true;
          }
        }
      }
    }

    if(i==s.size()-1&&!vflag){
      vp.push_back(v);
    }
  }
  /*
  REP(i, 0, vp.size())
  {
    REP(j, 0, vp[i].size())
    {
      cout << vp[i][j];
    }
    cout << endl;
  }
  */
  

  ll ans = 0;
  REP(i, 0, vp.size())
  {
    ll vv = 0;
    REP(j, 0, vp[i].size())
    {
      if(vp[i][j]==0){
        ans += j - vv;
        vv++;
      }
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let d = input::<usize>();
    let g = input::<i64>();
    let (p, c) = (0..d)
        .map(|_| {
            let p = input();
            let c = input();
            (p, c)
        })
        .unzip::<i64, i64, Vec<_>, Vec<_>>();

    println!("{}", dfs(d, 0, 0, d, d, g, &p, &c));
}

fn dfs(
    k: usize,
    count: i64,
    score: i64,
    h: usize,
    d: usize,
    g: i64,
    p: &Vec<i64>,
    c: &Vec<i64>,
) -> i64 {
    if k == 0 {
        if score >= g {
            return count;
        } else if score + (h as i64 * 100 * p[h - 1]) < g {
            return i64::max_value();
        } else {
            let mut c = 0;
            let mut s = score;
            while s < g {
                c += 1;
                s += h as i64 * 100;
            }
            return count + c;
        }
    }

    let mut ans = i64::max_value();
    ans = std::cmp::min(ans, dfs(k - 1, count, score, h, d, g, p, c));
    ans = std::cmp::min(
        ans,
        dfs(
            k - 1,
            count + p[k - 1],
            score + (k as i64 * 100) * p[k - 1] + c[k - 1],
            if k == h { k - 1 } else { h },
            d,
            g,
            p,
            c,
        ),
    );
    ans
}


Measured memory_bytes: 4352
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static long[] HP;
    static long A;
    static long B;
    static long N;
    static void Main(string[] args) {
        
        var NAB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        N = NAB[0];
        A = NAB[1];
        B = NAB[2];
        
        HP = new long[N];
        for(int i = 0;i < N;i++){
            HP[i] = long.Parse(Console.ReadLine());
        }
        
        long no = 0;
        long yes = 1000000000; 
        //キューの最大値が0になるまで
        while(yes- no > 1){
            long mid = (yes+no)/2;
            
            if(check(mid)){
                yes = mid;
            }else{
                no = mid;
            }
        }
        Console.WriteLine(yes);
     }
     
     static bool check(long mid){
         long sum = 0;
         for(int i =0;i < N; i++){
             long tmp = HP[i]-B*mid;
             if(tmp > 0){
                 sum += (tmp-1)/(A-B)+1;
             }
         }
         if(sum <= mid){
             return true;
         }else{
             return false;
         }
     }
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }


Measured memory_bytes: 18256
k=int(input())
if k<=500:
    n=k
    print(n)
    for i in range(n):
        print(*list(range(1,1+n)))
else:
    n=2*((k+3)//4)
    ans=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            ans[i][j]=(i+j)%n+1
            if i%2 and ans[i][j]+n<=k:
                ans[i][j]+=n
    print(n)
    for i in ans:
        print(*i)



Measured memory_bytes: 13712
#include <stdio.h>

int main(void){

  double r, are, circ, pi;
  pi=3.141592653589;

  scanf("%lf", &r);
  are = pi * r * r;
  circ = 2 * pi *r;

  printf("%f %f\n", are, circ);

  return 0;

}

Measured memory_bytes: 648
n = int(input())
a = list(map(int, input().split()))
s = [[0]*20]
for i in a:
    tmp = []
    for j in range(20):
        tmp.append((i>>j&1)+s[-1][j])
    s.append(tmp)
l = 0
r = 0
ans = 0
while l < n:
    for j in range(20):
        if s[r+1][j]-s[l][j]>1:
            ans += r-l
            l += 1
            break
    else:
        if r < n-1:
            r += 1
        else:
            ans += n-l
            l += 1
print(ans)


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

class Dice{
    public:
        int s[6];
        void roll(char c){
            int temp;
            if(c=='E'){
                temp=s[2];
                s[2]=s[0];
                s[0]=s[3];
                s[3]=s[5];
                s[5]=temp;
            }
            if(c=='N'){
                temp=s[4];
                s[4]=s[0];
                s[0]=s[1];
                s[1]=s[5];
                s[5]=temp;
            }
            if(c=='S'){
                temp=s[1];
                s[1]=s[0];
                s[0]=s[4];
                s[4]=s[5];
                s[5]=temp;
            }
            if(c=='W'){
                temp=s[3];
                s[3]=s[0];
                s[0]=s[2];
                s[2]=s[5];
                s[5]=temp;
            }
            if(c=='R'){
                temp=s[1];
                s[1]=s[3];
                s[3]=s[4];
                s[4]=s[2];
                s[2]=temp;
            }
        }
        int top(){
            return s[0];
        }
        int front(){
            return s[1];
        }
        int right(){
            return s[2];
        }
        int left(){
            return s[3];
        }
};
bool same(Dice a,Dice b){
    bool check=true;
    for(int i=0;i<6;i++){
        if(a.s[i]!=b.s[i]){
            check=false;
        }
    }
    return check;
}
int main(){
    Dice dice1;
    Dice dice2;
    for(int i=0;i<6;i++){
        cin>>dice1.s[i];
    }
    for(int i=0;i<6;i++){
        cin>>dice2.s[i];
    }
    bool check=false;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(same(dice1,dice2)){
                check=true;
            }
            dice2.roll('R');
        }
        dice2.roll('N');
    }
    dice2.roll('E');
    for(int j=0;j<4;j++){
        if(same(dice1,dice2)){
            check=true;
        }
        dice2.roll('R');
    }
    dice2.roll('E');
    dice2.roll('E');
    for(int j=0;j<4;j++){
        if(same(dice1,dice2)){
            check=true;
        }
        dice2.roll('R');
    }
    if(check){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;

    vint a(3*N);
    REP(i,3*N)
        cin>>a[i];
    sort(ALL(a),greater<int>());

    int ans=0;
    REP(i,2*N){
        if(i%2==1) ans+=a[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int InN, L,total;
  string stN, stDig; 
  cin >> InN;
  stN = to_string(InN);
  L = stN.size();                    //桁数を取得

  vector<int>indig(L);               //各桁を収納する変数numを作成
  for(int i = 0;i < L;i++){        //桁数ぶんの収納を行う 
  stDig = stN.at(i);
  indig.at(i) = atoi(stDig.c_str()); //各桁を収納
  total = total + indig.at(i);
  }
  
  if(InN % total == 0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register long long
#define int long long
using namespace std;
inline int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=0;c=getchar();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=getchar();
	return f?s:-s;
}
struct hhd{
	int x,id,type;
	friend bool operator < (hhd a,hhd b){
		return a.x<b.x;
	}
}a[100010],b[100010],c[200010];
int n,m,num,ans,cnt,fa[100010];
int get_fa(int x){
	return x==fa[x]?x:fa[x]=get_fa(fa[x]);
}
void add_a(int p){
	c[++num].x=a[p].x-a[p-1].x;
	c[num].id=p-1; c[num].type=1;
}
void add_b(int p){
	c[++num].x=b[p].x-b[p-1].x;
	c[num].id=p-1; c[num].type=2;
}
void merge_a(int p){
	int id=c[p].id;
	int fa_x=get_fa(a[id].id),fa_y=get_fa(a[id+1].id);
	if(fa_x==fa_y) return;
	fa[fa_x]=fa_y; ans+=c[p].x;
	++cnt;
}
void merge_b(int p){
	int id=c[p].id;
	int fa_x=get_fa(b[id].id),fa_y=get_fa(b[id+1].id);
	if(fa_x==fa_y) return;
	fa[fa_x]=fa_y; ans+=c[p].x;
	++cnt;
}
signed main(){
	n=read();
	for(rint i=1;i<=n;++i){
		a[i].x=read(); b[i].x=read();
		a[i].id=b[i].id=i;
	}
	sort(a+1,a+n+1); sort(b+1,b+n+1);
	for(rint i=2;i<=n;++i) add_a(i),add_b(i);
	sort(c+1,c+num+1);
	for(rint i=1;i<=n;++i) fa[i]=i;
	for(rint i=1;i<=num;++i){
		if(c[i].type==1) merge_a(i);
		else merge_b(i);
		if(cnt==n-1)break;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10368
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [0]*m
x = [0]*m
for i in range(m):
    p[i], x[i] = map(int, input().split())


result = sum(t)
#print(result)
for i in range(m):
    result = sum(t)
    #print(result-t[p[i]])
    result =result - t[p[i]-1] + x[i]
    #print(x[i])
    print(result)   

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    ll x, count = 0;
    cin >> x;
    for(ll i = 100; i < x; i *= 1.01) count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3624
L, R = map(int, input().split())

ind_s = L
ind_e = min(L + 2019, R)

choices_mod = [x%2019 for x in range(ind_s, ind_e+1)]

if len(choices_mod) == 1:
    print(choices_mod[0])
elif 0 in choices_mod:
    print(0)
else:
    import itertools
    pairs = list(itertools.combinations(choices_mod, 2))
    
    ans_list = []
    for a, b in pairs:
        ans_list.append((a*b)%2019)
        
    print(min(ans_list))


Measured memory_bytes: 220732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  bool flag = false;
  rep(i,n){
    int a;
    cin >> a;
    if(a % 2 == 1) flag = true;
  }
  if(flag) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")


signed main() {
	int A, B, C, X, count = 0;
	cin >> A >> B >> C >> X;
	for (int i = 0; i < C + 1; i++) {
		for (int j = 0; j < B + 1; j++) {
			for (int k = 0; k < A + 1; k++) {
				if (X == 500 * k + 100 * j + 50 * i) {
					count++;
				}
			}
		}
	}


	cout << count << endl;

	pause;
}

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

int n, k, x[200000], fn[200001];
ll mp[200000];

inline void ad(int i) { while (i <= n)++fn[i], i += i & -i; }
inline int gt(int i) { int an = 0; while (i)an += fn[i], i ^= i & -i; return an; }

int main(){
	scanf("%d%d", &n, &k);
	ll s = 0;
	f(i, 0, n){
		scanf("%d", x + i);
		x[i] -= k;
		s += x[i];
		mp[i] = x[i] - s;
	}
	sort(mp, mp + n);
	int sz = unique(mp, mp + n) - mp;
	ll an = 0;
	s = 0;
	f(i, 0, n){
		s += x[i];
		ad(lower_bound(mp, mp + sz, x[i] - s) - mp + 1);
		an += i + 1 - gt(lower_bound(mp, mp + sz, -s) - mp);
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int X; cin >> X;
    int res = 1;
    for(int i = 2; i <= X; ++i) {
        int a = i * i;
        if (a > X) continue;
        while ( a * i <= X) {
            a *= i;
        }
        res = max(res, a);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, P = MAP()

print((3*A+P)//2)

Measured memory_bytes: 4200
#include <iostream>
#include <iomanip>
#include <vector>
#define ll long long
#define ALL(a)  (a).begin(),(a).end()

//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i, n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
	int N;cin>>N;
	int P[N];REP(i,N)cin>>P[i];
	int min=0;int count=0;
	REP(i,N){
		if(i==0){
			count++;
			min=P[i];
			continue;
		}
		
		if(P[i]>=min)continue;
		else{
			min=P[i];
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int answer = 0;

    List<Integer> ds = new ArrayList<>();
    for (int z = 0; z < N; z++) {
        ds.add(sc.nextInt());
    }
    for(int i = 0; i < N - 1; i++) {
        for(int j = i+1; j < N; j++) {
            answer += ds.get(i) * ds.get(j);
        }
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(void)
{
    int card[150];
    int N,Alicepoint=0,Bobpoint=0,cnum;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&card[i]);
    }
    for(int i = 0;i<N;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            if(card[j]>card[i])
            {
                cnum = card[j];
                card[j] = card[i];
                card[i] = cnum;
            }
        }
    }
    //printf("%d\n",card[0]);
    //printf("%d\n",card[1]);
    //printf("%d\n",card[2]);
    for(int i=0;i<N/2;i++)
    {
        Alicepoint = Alicepoint + card[2*i];
    }
    for(int i=0;i<N/2;i++)
    {
        Bobpoint = Bobpoint + card[2*i+1];
    }
    if(N%2==1)
    {
        Alicepoint = Alicepoint + card[N-1];
    }
    printf("%d",Alicepoint-Bobpoint);
}

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

using namespace std;

int main() {

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

	int n;
	cin >> n;

	vector<long long> a(3*n);

	for (auto& x : a) {
		cin >> x;
	}

	sort(a.begin(), a.end());

	long long ans = 0;

	for (int i = 0; i < n; i++) {
		ans += a[3 * n - 2 * (i + 1)];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int N,M;
		ArrayList<Integer> a = new ArrayList<Integer>();
		ArrayList<Integer> b = new ArrayList<Integer>();
		ArrayList<Integer> c = new ArrayList<Integer>();
		ArrayList<Integer> d = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();

		for(int i = 0; i < N; i++) {
			a.add(sc.nextInt());
			b.add(sc.nextInt());
		}

		for(int i = 0; i < M; i++) {
			c.add(sc.nextInt());
			d.add(sc.nextInt());
		}

		for(int i = 0; i < N; i++) {
			int k = 2147483647;
			int n = 0;
			for(int j = 0; j < M; j++) {
				int l = Math.abs(a.get(i) - c.get(j)) + Math.abs(b.get(i) - d.get(j));
				if(l < k) {
					k = l;
					n = j + 1;
				}
			}
			System.out.println(n);
		}

		sc.close();
	}
}

Measured memory_bytes: 22736
/*  ex6_2
    hangan2020 */

#include <stdio.h>
#include <string.h>
//Intial string array length
#define IS 102

int main(void){
    char eng_str[IS] = {};
    int len, inbetween_no;

  	//Input character string (including null)
    fgets(eng_str, IS, stdin);
    len = strlen(eng_str);
  
    inbetween_no = len - 3; // String length include null at the end of string (thus -3)
    
  	//Print out in the followning order
    printf("%c%d%c\n", eng_str[0], inbetween_no, eng_str[len - 2]);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
ll ans=0;
int main(){
	cin>>x;
	ans+=x/500;
	ans*=1000;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		s.insert(a);
	}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  double stack[128];
  int n,i;
  char str[128],*adr;
  //int l;
  while(fgets(str,sizeof(str),stdin)!=NULL){
    adr=strtok(str," \n");
    n=0;
    for(i=0;i<128;i++) stack[i]=0;
    while(adr!=NULL){
      if(*adr=='+'){
	stack[n-2]+=stack[n-1];
	n--;
      }else if(*adr=='-' && strlen(adr)==1){
	stack[n-2]-=stack[n-1];
	n--;
      }else if(*adr=='*'){
	stack[n-2]*=stack[n-1];
	n--;
      }else if(*adr=='/'){
	stack[n-2]/=stack[n-1];
	n--;
      }else{
	stack[n]=atof(adr);
	n++;
      }
      adr=strtok(NULL," \n");
    }
    
    printf("%f\n",stack[0]);
  }
  return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using R = long double;

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

    vi face;
    rep(i, 2){
        string edge; cin >> edge;
        int th, L; cin >> th >> L;

        if(edge == "BC") th += 60;
        else if(edge == "CD") th += 120;

        R theta = (th * PI) / 180.;
        R x = L * cos(theta);
        R y = L * sin(theta);

        x = x + sqrt(3) / 3. * y;

        while(x < 0.) x += 2.; while(x > 2. + EPS) x -= 2.;
        while(y < 0.) y += sqrt(3); while(y > sqrt(3) + EPS) y -= sqrt(3);

        bool rev = false;
        if(y > sqrt(3) / 2.){
            y -= sqrt(3) / 2.;
            rev = true;
        }

        int f = -1;
        if((x < 1.) ^ rev){
            if(rev) x -= 1;
            if(sqrt(3) / 2. * x - y + EPS > 0){
                f = rev ? 1:0;
            }
            else {
                f = rev ? 0:1;
            }
        }
        else {
            if(not rev) x -= 1.;
            if(sqrt(3) / 2. * x - y + EPS > 0){
                f = rev ? 2:3;
            }
            else {
                f = rev ? 3:2;
            }
        }
        face.emplace_back(f);
    }

    cout << (face[0] == face[1] ? "YES":"NO") << endl;

    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;
const LL mo=998244353;
char s[201];
LL v[201];
map < pair <string,bool> ,LL > f;
void dfs(string s);
int Query(string s,int k) {
    int len=s.length();
    string nows="";
    for (int i=1;i<=len/k;i++) v[i]=1;
    for (int i=1;i<=k;i++)
        for (int j=(i-1)*len/k,j2=1;j<=i*len/k-1;j++,j2++)
            if (s[j]=='0') v[j2]=0;
    for (int i=1;i<=len/k;i++) if (v[i]) nows+='1';else nows+='0';
    dfs(nows);
    return f[make_pair(nows,1)];
}
void dfs(string s) {
    if (f.find(make_pair(s,0))!=f.end()) return;
    int len=s.length();
    LL ans=0;
    for (int i=1;i*i<=len;i++) {
        if (len%i) continue;
        if (i!=1) ans=(ans+Query(s,i))%mo;
        if (i*i!=len) ans=(ans+Query(s,len/i))%mo;
    }
    f[make_pair(s,0)]=ans;
    string t="";
    for (int i=0;i<len-1;i++) {
        t+=s[i];
        dfs(t);
        string t2="";
        for (int j=i+1;j<len;j++) t2+=s[j];
        dfs(t2);
        ans=(ans+f[make_pair(t,0)]*f[make_pair(t2,1)]%mo)%mo;
    }
    f[make_pair(s,1)]=ans;
}
int main() {
    cin>>s; 
    f[make_pair("0",0)]=1;
    f[make_pair("1",0)]=2;
    f[make_pair("0",1)]=1;
    f[make_pair("1",1)]=2;
    dfs(s);
    printf("%lld\n",f[make_pair(s,1)]);
    return 0;
}


Measured memory_bytes: 15360
from math import sqrt


if __name__ == "__main__":
    c1x, c1y, c1r = map(float, input().split())
    c2x, c2y, c2r = map(float, input().split())

    dx, dy = c2x - c1x, c2y - c1y
    cdist = dx ** 2 + dy ** 2
    a = (cdist + c1r ** 2 - c2r ** 2) / 2
    df = sqrt(cdist * c1r ** 2 - a ** 2)
    ix1, ix2 = (a * dx + dy * df) / cdist, (a * dx - dy * df) / cdist
    iy1, iy2 = (a * dy - dx * df) / cdist, (a * dy + dx * df) / cdist

    if (ix1, iy1) > (ix2, iy2):
        ix1, ix2, iy1, iy2 = ix2, ix1, iy2, iy1

    print(ix1 + c1x, iy1 + c1y, ix2 + c1x, iy2 + c1y)



Measured memory_bytes: 5664
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    unordered_map<int, long long> mp;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        if (i == 0) {
            cin >> a;
            mp[a + i]++;
        } else {
            cin >> a;
            if (i >= a && mp[i - a] != 0) { ans += mp[i - a]; }
            mp[a + i]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

void add (ll& a, ll b) {
  a = (a + b) % MOD;
}

ll dp[101][4][4][4]; // 0123 : TAGC

bool ng(int a, int b, int c) {
  return (a == 1 and b == 2 and c == 3);
}

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

  dp[0][0][0][0] = 1;

  rep(i, N) rep(a, 4) rep(b, 4) rep(c, 4) rep(d, 4) {
    // 3文字がNG 左から a, b, c, d(AGC, GAC, ACG)
    if (ng(b, c, d) or ng(c, b, d) or ng(b, d, c)) {
      continue;
    }

    if (ng(a, c, d) or ng(a, b, d)) continue;

    add(dp[i+1][b][c][d], dp[i][a][b][c]);
  }

  ll ans = 0;
  rep(a, 4)rep(b, 4)rep(c, 4) add(ans, dp[N][a][b][c]);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, z, w;
vector<lli> a;
int main() {
  cin >> n >> z >> w;
  read_n(a, n);
  lli ans;
  if (n == 1) ans = abs(a[0] - w);
  else {
    ans = max(abs(a[n-2] - a[n-1]), abs(a[n-1] - w));
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256