akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); 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 INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int digsum(ll n) {
    int res = 0;
    while (n > 0) {
        res += n - n / 10 * 10;
        n /= 10;
    }
    return res;
}

signed main() {
    INIT;
    vector<ll> snuke;
    REP(i, 15) {
        string S;
        REP(j, i) {
            S += '9';
        }
        REPS(j, 999) {
            snuke.push_back(stoll(to_string(j) + S));
        }
    }
    sort(ALL(snuke));
    UNIQUE(snuke);
    dump(snuke.size());
    ll mns = snuke.back();
    vector<ll> res;
    RREP(i, snuke.size()) {
        if (snuke[i] * digsum(mns) <= mns * digsum(snuke[i])) {
            mns = snuke[i];
            res.push_back(snuke[i]);
        }
    }
    dump(snuke.back());
    reverse(ALL(res));
    dump(res.size(), res.back());
    cin >> K;
    REP(i, K) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

const int INF = 1e9 + 7;

int main()
{


    int N, k;
    cin >> N >> k;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i];

    vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j <= i + k; ++j)
        {
            if (j < N)
                dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
            else 
                break;
        }
    }
    cout << dp[N-1];
    return 0;
}

Measured memory_bytes: 4024
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define loop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int ans[300];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int a, b, c, n;
        cin >> a >> b >> c;
        if (a == 0 && b == 0 && c == 0) { break; }
        cin >> n;
        int ak[1000], bk[1000], ck[1000];
        loop(i, 1000) {
            ak[i] = bk[i] = ck[i] = -1;
            if (i < 300) {
                ans[i] = 2;
            }
        }
        loop(i, n) {
            int an, bn, cn, or1;
            cin >> an >> bn >> cn >> or1;
            if (or1 == 1) {
                ans[an - 1] = 1;
                ans[bn - 1] = 1;
                ans[cn - 1] = 1;
            }
            else {
                ak[i] = an - 1;
                bk[i] = bn - 1;
                ck[i] = cn - 1;
            }
        }
        loop(i, n) {
            if (ak[i] != -1) {
                if (ans[ak[i]] == 2 && ans[bk[i]] == 1 && ans[ck[i]] == 1) {
                    ans[ak[i]] = 0;
                }
                if (ans[ak[i]] == 1 && ans[bk[i]] == 2 && ans[ck[i]] == 1) {
                    ans[bk[i]] = 0;
                }
                if (ans[ak[i]] == 1 && ans[bk[i]] == 1 && ans[ck[i]] == 2) {
                    ans[ck[i]] = 0;
                }
 
            }
        }
        loop(i, a + b + c) {
            cout << ans[i] << endl;
        }
 
    }
    return 0;
 
}


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DReplacing {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      ll sum = 0;
      vector<ll> cnt(100001);
      rep(i, n) {
        int a; cin >> a;
        cnt[a]++;
        sum += a;
      }
      int q; cin >> q;
      while(q--) {
        ll b, c; cin >> b >> c;

        sum += (c-b)*cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << '\n';



      }


    }
};

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

Measured memory_bytes: 4028
n,m,*A=map(int,open(0).read().split())
D=[0]*(2*m+2)
cur = 0
S = 0
for a,b in zip(A,A[1:]):
    S += (b-a)%m
    b += m*(b<a)
    k = b-a
    if k>1:
        D[a+2] += 1
        D[b+1] -= k
        D[b+2] += k-1
for i in range(1,2*m+2):
    D[i]+=D[i-1]
for i in range(1,2*m+2):
    D[i]+=D[i-1]
print(S-max(D[a]+D[a+m]for a in A))


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

int main(){
    int a,b;
    cin >> a;
    if(a<15){
        cout << a*800 << endl;
    }
    else{
        b=a/15;
        cout << a*800-b*200 << endl;
    }
    return 0;
}

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

template <typename T> void debug(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void debug(T t, Args... args) { cout<<t<<" "; debug(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ct=0;
    for(int i=0;i<n;i++)
        if(i%2==0 && arr[i]%2==1)
            ct++;
    cout<<ct;
}

Measured memory_bytes: 3608
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
    	if(i%n==0){
    		cout<<"OK"<<endl;
    		return 0;
    	}
    }
    cout<<"NG"<<endl;
    return 0;
}


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

using namespace std;

bool checkpalindrome(int i){
	string s=to_string(i);
	string r=s;
	reverse(r.begin(),r.end());
	if(s==r){
		return true;
	}
	return false;
}



int main(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=a;i<b+1;i++){
		if(checkpalindrome(i)){
			cnt++;
		}
	}
	cout<<cnt<<endl;





	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100009];
int res[100009];
/*lets try to understand how to write recursive eqn for the current problem
 mincost(i,n)={min(a[i+1]-a[i]+mincost(i+1,n),a[i+2]-a[i]+mincost(i+2,n)) if i<n
                  ,0 if i>=n}         
 */
int mincost(int i)
{
   if(res[i]>=0)
	   return res[i];
  		if(i==n)
		 return 0;
	
	
  if(i<n-1)
  res[i]=min(abs(a[i+1]-a[i])+mincost(i+1),abs(a[i+2]-a[i])+mincost(i+2));
  else
    res[i]=abs(a[i+1]-a[i])+mincost(i+1);
 return res[i]; 
}
int main()
{  
for(int i=1;i<=100000;i++)
    res[i]=-1;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	 cout<<mincost(1);
}


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>b)
	printf("a > b\n");
	if(a<b)
	printf("a < b\n");
	if(a==b)
	printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 1816
N,L = map(int, input().split())
if L >= 0:
  print(L * (N-1) + N * (N-1) // 2)
elif L+N-1 <= 0:
  print((L-1) * (N-1) + N * (N-1) // 2)
else:
  print((L-1) * N + N * (N+1) // 2)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int k = a + b;

            if(k % 2 == 0)
            {
                Console.WriteLine(k / 2);
            }

            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }


        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <complex>
#include <map>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
#define X real()
#define Y imag()
const double EPS = (1e-7);
const int INF = 1 << 20;
double dot(P &a, P &b){ return a.X*b.X + a.Y*b.Y;}
double cross(P &a, P &b){ return a.X*b.Y - a.Y*b.X;}

int ccw( P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < EPS) return 2;
  if(norm(c) > norm(b) - EPS) return -2;
  return 0;
}

bool is_adjacent(vector<P> &A, vector<P> &B){
  int n = A.size(), m = B.size();
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      P x = A[i], y = A[(i+1)%n], z = B[j], w = B[(j+1)%m];
      int s = ccw(x,y,z), t = ccw(x,y,w);
      if(abs(s) == 1 or abs(t) == 1) continue;
      if(s*t > 0) continue;
      return true;
    }
  }
  return false;
}

int main(){
  int n;
  while(cin >> n, n){
    map<string, int> M;
    vector< vector< vector<P> > > V(n);
    int t = 1;
    for(int i = 0; i < n; ++i){
      string s;
      cin >> s;
      vector<P> Poly;
      if(!M[s]){
        M[s] = t;
        ++t;
      }
      double x;
      while(cin >> x, x != -1){
        double y;
        cin >> y;
        Poly.emplace_back(x,y);
      }
      V[M[s]-1].emplace_back(Poly);
    }
    int c = t-1;
    vector< vector<int> > G(c, vector<int>(c,0));
    for(int i = 0; i < c; ++i){
      for(int j = 0; j < i; ++j){
        for(int k = 0; k < V[i].size(); ++k){
          for(int l = 0; l < V[j].size(); ++l){
            if(is_adjacent(V[i][k], V[j][l])) ++G[i][j], ++G[j][i];
          }
        }
      }
    }

    /*
    for(int i=0; i<c; i++) {
      for(int j=0; j<c; j++) {
        fprintf(stderr, "%d ", G[i][j]);
      }
      fprintf(stderr, "\n");
    }
    */
    

    vector<int> dp(1 << c, INF);
    dp[0] = 0;
    for(int bit=0; bit<(1<<c); bit++) {
      for(int mask=0; mask<(1<<c); mask++) {
        if((bit & mask) != 0) continue;
        bool ok = true;
        for(int i=0; i<c; i++) {
          for(int j=0; j<c; j++) {
            if(!(mask >> i & 1)) continue;
            if(!(mask >> j & 1)) continue;
            if(G[i][j]) ok = false;
          }
        }

        int nbit = bit | mask;
        if(ok) dp[nbit] = min(dp[nbit], dp[bit] + 1);
      }
    }
    cout << dp[(1<<c) - 1] << endl;
  }
}



Measured memory_bytes: 3380
n = int(input())
a = list(map(int, input().split()))

ans = "APPROVED"
for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            ans = "DENIED"
            break
    else:
        pass
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1)<< endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	ysp48 := getNextString(scanner)
	rng58 := "CODEFESTIVAL2016"
	n := len(ysp48)
	ans := 0
	for i := 0; i < n; i++ {
		if ysp48[i] == rng58[i] {
			continue
		}
		ans++
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
double p[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int t;scanf("%d",&t);
		p[i]=(t+1)*0.5;
	}
	double ret=0;
	double now=0;
	for(int i=0;i<a;i++){
		now+=p[i];
		if(i>=b)now-=p[i-b];
		if(i>=b-1)ret=max(ret,now);
	}
	printf("%.12f\n",ret);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;
int a, b;

signed main() {
  cin >> a >> b;
  if (a < b) {
    rep(i, b) { cout << a; }
  } else {
    rep(i, a) { cout << b; }
  }
  cout << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, c;
  cin >> n >> c;
  vint x(n), v(n);
  vector<Pi> vec;
  rep(i, n) {
    cin >> x[i] >> v[i];
    vec.emplace_back(x[i], v[i]);
  }
  sort(all(vec));
  rep(i, n) tie(x[i], v[i]) = vec[i];
  vint rv(n+1);
  vint mi(n+1);
  vint mi2(n+1);
  int mx = 0;
  int mx2 = 0;
  mi[0] = -1;
  mi2[0] = -1;
  rep(i, n) {
    rv[i+1] = rv[i] + v[i];
    if(mx < rv[i+1]-x[i]) mi[i+1] = i+1;
    else mi[i+1] = mi[i];
    chmax(mx, rv[i+1]-x[i]);
    if(mx2 < rv[i+1]-2*x[i]) mi2[i+1] = i+1;
    else mi2[i+1] = mi2[i];
    chmax(mx2, rv[i+1]-2*x[i]);
  }
  int res = max(0ll, mx);
  int sum = 0;
  for(int i = n-1; i >= 0; --i) {
    sum += v[i];
    //cout<<mi[i]<<" "<<rv[mi[i]]<<" "<<x[mi[i]-1]<<endl;
    chmax(res, sum-(c-x[i]));
    if(mi[i] != -1) {
      chmax(res, sum-2*(c-x[i])+rv[mi[i]]-x[mi[i]-1]);
      //chmax(res, sum-(c-x[i])+rv[mi[i]]-2*x[mi[i]-1]);

    }
    if(mi2[i] != -1) {
      chmax(res, sum-(c-x[i])+rv[mi2[i]]-2*x[mi2[i]-1]);
    }
  }

  cout << res << endl;

  return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		bool f = true;
		for (int j = 0; j < 2; j++) {
			f &= s[i + j] == "AC"[j];
		}
		if (f) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int arr[n];
    read(arr);
    int total = n;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= 1000; ++j){
            if(((arr[i] * j) + 1) <= d) total++;
            else break;
        }
    }
    cout << total + x;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	int A = 0, B = 0, a;
	for_(i,0,4) scanf("%d", &a), A += a;
	for_(i,0,4) scanf("%d", &a), B += a;
	cout << max(A, B) << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;

int main() {
  ll A, B, cnt = 0; cin >> A >> B;
  while (A <= B) {
    A = 2 * A;
    cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  int s[3]={a,b,c};
  if(s[0]>s[1]){
    tmp=s[0],s[0]=s[1],s[1]=tmp;
  }
  if(s[1]>s[2]){
    tmp=s[1],s[1]=s[2],s[2]=tmp;
  }
  if(s[0]>s[1]){
    tmp=s[0],s[0]=s[1],s[1]=tmp;
  }
    printf("%d %d %d\n",s[0],s[1],s[2]);
    return 0;
}



Measured memory_bytes: 2732
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

int main() {

    int N;
    cin >> N;

    vector<int> L(2 * N);
    for (int i = 0; i < 2 *N; i++) cin >> L[i];

    sort(L.rbegin(), L.rend());

    int ans = 0;
    for (int i = 0; i < N; i++) ans += min(L[i * 2], L[i * 2 + 1]);

    cout << ans << endl;

    return 0;
}



























Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  long long int N,M;
  cin>>N>>M;
  long long int A[M];
  for(int i=0; i<M; ++i) cin>>A[i];
  long long int ans=1;
  
  vector<long long int> LL;
  LL.push_back(0);
  for(int i=0; i<M; ++i){
    LL.push_back(A[i]-1);
    LL.push_back(A[i]+1);
  }
  LL.push_back(N);
  
  long long int S[1000001];
  S[0]=1;
  S[1]=1;
  for(int i=2; i<1000001; ++i) S[i]=(S[i-1]+S[i-2])%1000000007;
  
  for(int i=0; i<LL.size()/2; ++i){
    ans*=S[LL.at(2*i+1)-LL.at(2*i)];
    ans%=1000000007;
  }
  
  for(int i=1; i<M; ++i){
    if(A[i]-A[i-1]==1) ans=0;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 10480
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n){
        int s=0,a,b;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            s+=b-a+1;
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int alpha[26] = {};
	string alph = "zyxwvutsrqponmlkjihgfedcba";
	string s;
	char remind;
	cin >> s;
	if (s == alph) {
		cout << -1 << endl;
		return 0;
	}
	int tmp = 0, ans, cnt = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		alpha[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (alpha[i] == 0) {
			s += 'a' + i;
			cout << s << endl;
			return 0;
		}
	}
	int cmp[26] = {};
	for (int i = (int)s.size() - 1; i > 1; i--) {
		if (s[i] > s[i - 1]) {
			tmp = i - 1;
			//cout << "tmp:" << tmp << endl;
			remind = s[i - 1];
			//cout << "remind:" << remind << endl;
			break;
		}
	}
	for (int i = tmp; i < (int)s.size(); i++) {
		cmp[s[i] - 'a']++;
	}
	//cout << "tmp:" << tmp << endl;
	if (tmp == 0) {
		for (int i = 0; i < 26; i++) {
			if (cmp[i] > 0 && (s[0] - 'a') < i) {
				cout << (char)('a' + i) << endl;
				return 0;
			}
		}
	} else {
		for (int i = 0; i < tmp; i++) {
			cout << s[i];
		}
		for (int i = 0; i < 26; i++) {
			if (cmp[i] > 0 && i > remind - 'a') {
				cout << char('a' + i) << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  while (true) {
    int n, x; cin >> n >> x;
    if (n == 0 && x == 0) break;

    int db[n+1][n+1][n+1];
    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
	for (int k = j+1; k <= n; k++) {
	  db[i][j][k] = i+j+k;
	}
      }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
	for (int k = j+1; k <= n; k++) {
	  if (db[i][j][k] == x) ans++;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4868
M = 10 ** 9 + 7

X, Y = map(int, input().split())
N = max(X, Y)

def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

fact_list = [1, 1]
inv_fact_list = [1, 1]
f = 1
i_f = 1
for i in range(2, N + 1):
	f = (f * i) % M
	fact_list.append(f)
	i_f = (i_f * calc_inverse(i, M)) % M
	inv_fact_list.append(i_f)

total = 0

for i in range(X + 1):
	x = X - i
	y = Y - i * 2
	if x == y * 2:
		total = (total + fact_list[i + y] * inv_fact_list[i] * inv_fact_list[y]) % M

print(total)


Measured memory_bytes: 124384
sub f{($i,$x)=@_;$B[$i]+=$x,$i+=$i&-$i until$i>5e5}sub a{($i,$s)=@_;$s+=$B[$i],$i&=$i-1while$i>0;$s}<>;f++$j,$_ for glob<>;/ .* />$`?f$&+1,$':print$/,a($')-a$&for<>

Measured memory_bytes: 382792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::sort;

int main() {
  int n, l;
  vector<string> v;

  cin >> n >> l;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }

  sort(v.begin(), v.end());
  for (string x : v) cout << x;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=0
h=0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        a=a+1
    else:
        a=0
    if a==3:
        h=1
if h==1:
    print("Yes")
else:
    print("No")

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

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

  vector<long> a(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }

  sort(a.begin(),a.end());
  
  int ans=0;
  int count=1;
  long prev=a[0];
  for (int i=1;i<n;i++){
    if (a[i]!=prev){
      if(count%2!=0)
        ans++;
      prev=a[i];
      count=1;
    }else{
      count++;
    }
  }
  if (count%2!=0)ans++;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 998244353LL;
const int maxn = 3000010;
ll qpow(ll a,ll x){
    ll ret=1;
    while (x){
        if (x&1)
            ret = ret*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return ret;
}
ll fac[maxn],inv[maxn];
 
ll init(){
    fac[0]=1;
    for (int i=1;i<maxn;i++)
        fac[i]=fac[i-1]*i%mod;
    inv[maxn-1]=qpow(fac[maxn-1],mod-2);
    for (int i=maxn-2;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%mod;
    return 0;
}
 
ll c(ll n,ll m){
    if (n<m) return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
    init();
    ll N,A,B,K;
    cin>>N>>A>>B>>K;
    ll ans=0;
    for(int i=0;i<=N;i++){
        if(K-A*i<0) continue;
        if((K-A*i)%B!=0) continue;
        ll y=(K-A*i)/B;
        if(y>N)continue;
        ans=(ans+c(N,i)*c(N,y)+mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 47104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double pi = Math.PI;
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		
		double ans= a*2*pi;
		
		System.out.print(ans);
	}

}

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

int main() {
  
  int a,b;
  
  cin >> a >> b;
  
  if (a*b % 2 == 1) {
    cout << "Odd" << endl;
  }
  
  if (a*b % 2 == 0) {
    cout << "Even" << endl;
  }
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> a;
    rep(i, h){
        string s;
        cin >> s;
        a.push_back(s);
    }
    
    vector<bool> col(h, true), row(w, true);
    rep(i, h){
        rep(j, w){
            if(a[i][j]=='#'){
                col[i] = false;
                row[j] = false;
            }
        }
    }

    rep(i, h){
        if(col[i]){
            continue;
        }
        rep(j, w){
            if(row[j]){
                continue;
            }
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#define maxn 200005
using namespace std;
int n,x,y,dep[maxn],fa[maxn],l[maxn],r[maxn],cnt,u1[maxn],v1[maxn],dist[maxn],ans;
bool vis[maxn],islong[maxn];
struct node { int v; node *nxt; } edge[maxn*4],*head[2][maxn],*ncnt;
queue<int> q;
void addedge(int x,int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[x][u];
	head[x][u]=ncnt;
}
void dfs(int u)
{
	l[u]=++cnt;
	for(node *p=head[1][u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa[u]) continue;
		fa[v]=u,dep[v]=dep[u]+1;
		dfs(v);
	}
	r[u]=++cnt;
}
bool check(int x,int y)
{
	if(l[x]>l[y]) swap(x,y);
	if(l[x]<=l[y]&&r[y]<=r[x]) return dep[y]-dep[x]>2;
	else return fa[x]!=fa[y];
}
void bfs()
{
	while(!q.empty()) q.pop();
	vis[x]=true; q.push(x);
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		for(node *p=head[0][u];p;p=p->nxt)
		{
			int v=p->v;
			if(vis[v]) continue;
			dist[v]=dist[u]+1;
			if(dist[v]<dep[v]) { vis[v]=true; q.push(v); }
		}
	}
}
void read(int &x)
{
	char ch=getchar(); x=0;
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
}
int main()
{
	while(~scanf("%d%d%d",&n,&x,&y))
	{
		ans=0;
		memset(vis,0,sizeof(vis));
		memset(islong,0,sizeof(islong));
		memset(head,0,sizeof(head));
		ncnt=&edge[0];
		for(int i=1;i<n;i++) { read(u1[i]); read(v1[i]); }//scanf("%d%d",&u1[i],&v1[i]);
		for(int i=1;i<n;i++)
		{
			int u,v;
			read(u); read(v);//scanf("%d%d",&u,&v);
			addedge(1,u,v); addedge(1,v,u);
		}
		fa[y]=dep[y]=0; dfs(y);
		for(int i=1;i<n;i++)
			if(check(u1[i],v1[i])) islong[u1[i]]=islong[v1[i]]=true;
			else { addedge(0,u1[i],v1[i]); addedge(0,v1[i],u1[i]); }
		dist[x]=0; bfs();
		int ans=0;
		for(int i=1;i<=n&&ans!=-1;i++)
			if(vis[i]&&islong[i]) ans=-1;
			else if(vis[i]) ans=max(ans,dep[i]*2);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 27392
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    zip(S, T).map!"a[0] != a[1]"().sum().writeln();
}


Measured memory_bytes: 4244
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int A = sc.nextInt();
      int B = sc.nextInt();

      if(A>=13){
        System.out.println(B);
      }else if(A>=6&&A<=12){
        System.out.println(B/2);
      }else{
        System.out.println(0);
      }


  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

int main() {
	ll a, b, k, n = 0, z = 0,x,y;
	ll p[1000] = {};
	cin >> x >> n;
	rep(i, n) {
		cin >> b;
		p[b]++;
	}

	for(i=1;i<102;i++) {
		if (p[i] == 1)continue;
		else {
			if (abs(x - i) < abs(x - z))z = i;
		}
	}
	
	

	cout << z;


	return 0;

}



Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;ll k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];
  int l=0,r=INF;
  auto check = [&](int x){
    ll res=0;
    rep(i,n){
      res += (a[i]+x-1)/x-1;
    }
    return res<=k;
  };
  while(r-l>1){
    int mid=(l+r)/2;
    if(check(mid))r=mid;
    else l=mid;
  }
  cout << r << endl;
}

Measured memory_bytes: 4372
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

P unit(const P &p){
    return p/abs(p);
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}
VP crosspointCC(C a, C b){
    VP ret;
    if(a.r < b.r) swap(a,b);
    double dist = abs(b.p-a.p);
    P dir = a.r*unit(b.p-a.p);
    if(EQ(dist, a.r+b.r) || EQ(dist, a.r-b.r)){
        ret.push_back(a.p +dir);
    }else if(a.r-b.r < dist && dist < a.r+b.r){
        double cos = (a.r*a.r +dist*dist -b.r*b.r)/(2*a.r*dist);
        double sin = sqrt(1 -cos*cos);
        ret.push_back(a.p +dir*P(cos, sin));
        ret.push_back(a.p +dir*P(cos, -sin));
    }
    return ret;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<C> c(n);
        for(int i=0; i<n; i++){
            double x,y,r;
            cin >> x >> y >> r;
            c[i] = C(P(x, y), r);
        }

        double ans = 0;
        for(int i=0; i<n; i++){
            vector<double> ar{-PI, PI};
            for(int j=0; j<n; j++){
                if(i==j) continue;
                VP ret = crosspointCC(c[i], c[j]);
                for(int k=0; k<(int)ret.size(); k++){
                    ar.push_back(arg(ret[k] -c[i].p));
                }
            }
            sort(ar.begin(), ar.end());
            ar.erase(unique(ar.begin(), ar.end()), ar.end());
            for(int j=0; j<(int)ar.size()-1; j++){
                double mid = (ar[j] +ar[j+1])/2;
                P p = c[i].p +rotate(P(c[i].r, 0), mid);
                bool out = true;
                for(int k=0; k<n; k++){
                    if(abs(p -c[k].p) +EPS < c[k].r){
                        out = false;
                    }
                }
                if(out){
                    ans += (ar[j+1] -ar[j]) *c[i].r;
                }
            }
        }
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var aList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			var aDictionary = new Dictionary<int, int>();

			foreach(var a in aList)
			{
				if(aDictionary.ContainsKey(a))
				{
					aDictionary[a]++;
				}
				else
				{
					aDictionary.Add(a, 1);
				}
			}

			int duplication = n - aDictionary.Keys.Count;

			if(duplication % 2 == 0)
			{
				n -= duplication;
			}
			else
			{
				n -= duplication + 1;
			}

			Console.WriteLine(n);
        }
	}
}

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

int main(){
    int K, S;
    cin >> K >> S;
    int res = 0;
    for (int X = 0; X <= K; ++X){
        for (int Y = 0; Y <= K; ++Y){
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K){
                ++res;
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

int main()
{
    int N,D;
    cin >> N >> D;
    int perOne = 2 * D + 1;
    cout << (N % perOne == 0 ? N / perOne : N / perOne + 1) << endl;
}

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

int main() {

    string a;
    int num = 0;
    
    cin >> a;

    if(a[0] == '1'){
        num++;
    }
    if(a[1] == '1'){
        num += 1;
    }
    if(a[2] == '1'){
        num += 1;
    }
    

    cout << num << endl;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int h, w;
//int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[8] = {-1,  0,  1,-1, 1,-1, 0, 1};
int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1};

bool is_wall(int x, int y){
	if(x<0|| y<0|| x>=h || y>=w) return true;
	else return false;
}

int main() {
	ll ans = 0;
	int tmp;
	cin >> h >> w;
	string mp[h];
	REP(i, h) cin >> mp[i];
	ll bl, wh;
	bool ch[h][w] ={};
	queue<pair<int, int>> q;
	pair<int, int> now;
	int x, y;
	REP(i, h){
		REP(j, w){
			if(ch[i][j]) continue;
			q.push(make_pair(i, j));
			ch[i][j] = true;
			bl = 0;
			wh = 0;
			while(!q.empty()){
				now = q.front();
				q.pop();
				x = now.first;
				y = now.second;
				if(mp[x][y] == '#') bl++;
				else wh++;
				REP(k, 4){
					if(!is_wall(x+dx[k], y+dy[k])
					&& !ch[x+dx[k]][y+dy[k]] 
					&& mp[x+dx[k]][y+dy[k]]  != mp[x][y]){
						q.push(make_pair(x+dx[k], y+dy[k]));
						ch[x+dx[k]][y+dy[k]] = true;
					}
				}
			}
			ans += bl * wh;
		}
	}
	cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++){
            if (i*j == N) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
  #include<math.h>

  struct Point{
    double x;
    double y;
  };

  void koch(int d, struct Point p, struct Point q){
    struct Point s, t, u;
    double k;

    if(d == 0) return;
    k = M_PI * 60.0 / 180.0;
    s.x = (2.0 * p.x + 1.0 * q.x) / 3.0;
    s.y = (2.0 * p.y + 1.0 * q.y) / 3.0;
    t.x = (1.0 * p.x + 2.0 * q.x) / 3.0;
    t.y = (1.0 * p.y + 2.0 * q.y) / 3.0;
    u.x = (t.x - s.x) * cos(k) - (t.y - s.y) * sin(k) + s.x;
    u.y = (t.x - s.x) * sin(k) + (t.y - s.y) * cos(k) + s.y;
    koch(d-1, p, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(d-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(d-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(d-1, t, q);
  }

  int main(){
    struct Point p, q;
    int n;

    scanf("%d", &n);
    p.x = 0;
    p.y = 0;
    q.x = 100;
    q.y = 0;
   printf("%.8f %.8f\n", p.x, p.y);
   koch(n, p, q);
   printf("%.8f %.8f\n", q.x, q.y);

   return 0;
  }


Measured memory_bytes: 2092
N = int(input())
S = input().strip()
A = [[0,0] for _ in range(N+1)]
for i in range(N):
    if S[i]=="E":
        A[i+1][0] = A[i][0]+1
        A[i+1][1] = A[i][1]
    else:
        A[i+1][0] = A[i][0]
        A[i+1][1] = A[i][1]+1
cmin = N
for i in range(N):
    a,b = A[i][0],A[i][1]
    c,d = A[N][0]-A[i+1][0],A[N][1]-A[i+1][1]
    cmin = min(cmin,b+c)
print(cmin)

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

int main()
{
  long a[100010]={0};
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>a[i];
    a[i]*=1000000;
    a[i]+=i;
  }
  sort(a,a+N+1);
  for(int i=1;i<=N;i++) cout<<a[i]%1000000<<' ';
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>

int connect[100000];

int topreturn(int n){
	while(connect[n]!=n){
		n=connect[n];
	}
	return n;
}

int main(void){
	int n,m,x,y,i,tmp;
	int p[100000];
	int j;

	scanf("%d %d",&n,&m);

	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		connect[i]=i;
	}

	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		x=topreturn(x-1);
		y=topreturn(y-1);
		if(x>y){tmp=x; x=y; y=tmp;}
		connect[y]=connect[x];
	}

	tmp=0;
	for(i=0;i<n;i++){
		if(topreturn(i)==topreturn(p[i]-1)){
			tmp++;
		}
	}
	printf("%d\n",tmp);

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>


using namespace std;

int main()
{
	int s, w;

	cin >> s >> w;

	if (s <= w)
		cout << "unsafe";
	else
		cout << "safe";

	return 0;
}

Measured memory_bytes: 3632
n=int(input())
lis=[]
for i in range(n):
    v,w,t,d,s=input().split()
    vv=int(v)
    ww=int(w)
    dd=int(d)
    lis.append((vv,ww,t,dd,s))
lis.sort()
for i in lis:
    print(*i)
    


Measured memory_bytes: 31304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }

    for(int i=0; i<N; i++){
        if(vec.at(i) % 2 == 0 && vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
a, b = list(map(int, input().split()))

def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = sorted(prime(a))
b = sorted(prime(b))

c = set()


def cal(a, b):
    c = set()
    for i in range(len(a)):
        c.add(a[i])
    for i in range(len(b)):
        c.add(b[i])
    ans = []
    e = 1
    for i in range(len(c)):
        d =c.pop()
        if a.count(d) >= b.count(d):
            for j in range(a.count(d)):
                ans.append(d)
        else:
            for j in range(b.count(d)):
                ans.append(d)

    for i in range(len(ans)):
        e *= ans[i]

    return e

print(cal(a, b))



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

int main()
{
	int N, R;
	cin >> N >> R;
	if (N >= 10) cout << R << endl;
	else cout << R + 100 * (10 - N) << endl;
}

Measured memory_bytes: 256