akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

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

template<typename T> vector<T> compress(vector<T> v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    return v;
}

template<typename T> map<T,int> dict(vector<T> v){
    map<T,int> res;
    for (int i=0;i<v.size();++i) res[v[i]]=i;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    for (int i=0;i<N;++i) cin >> A[i] >> B[i];
    sort(ALL(A));
    sort(ALL(B));
    if (N&1){
        cout << B[N/2]-A[N/2]+1 << '\n';
    } else {
        ll a=A[N/2]+A[N/2-1],b=B[N/2]+B[N/2-1];
        cout << b-a+1 << '\n';
    }
}

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

using qnode = tuple<int, int, int>;
const int inf = numeric_limits<int>::max() / 3;

int main(void) {
  int n,m;
  cin >> n >> m;

  auto graph = vector<vector<int>>(n);
  for(int i = 0;i < m;++i){
    int a,b;
    scanf("%d %d", &a, &b);
    --a;--b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  int from[100010];
  int dist[100010];
  fill(dist, dist+100010, inf);
  priority_queue<qnode, vector<qnode>, greater<qnode>> que;
  que.push(qnode{0, 0, 0});
  while(!que.empty()){
    int now, d, f;
    tie(d, now, f) = que.top();
    que.pop();
    if(d >= dist[now]) {
      continue;
    }

    dist[now] = d;
    from[now] = f;
    for(int next : graph[now]) {
      int new_d = d + 1;
      if(new_d < dist[next]) {
        que.push(qnode{new_d, next, now});
      }
    }
  }

  printf("Yes\n");
  for(int i = 1;i < n;++i){
    printf("%d\n", from[i] + 1);
  }
  return 0;
}


Measured memory_bytes: 12180
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> p(N);
    for (ll i = 0; i < N; i++) {
        cin >> p[i];
    }

    vector<ll> sorted = p;
    sort(sorted.begin(), sorted.end());
    for (ll i = 0; i < N; i++) {
        for (ll j = i; j < N; j++) {
            swap(p[i], p[j]);

            bool same = true;
            for (ll k = 0; k < N; k++) {
                if (p[k] != sorted[k]) {
                    same = false;
                    break;
                }
            }
            if (same) {
                cout << "YES" << endl;
                return 0;
            }

            swap(p[i], p[j]);
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int i = 0;
  int cnt = 0;
  int r[n],l[n];
  while (i < n)
  {
    scanf("%d%d",&l[i],&r[i]);
    cnt += r[i] - l[i] + 1;
    i++;
  }
  printf("%d",cnt);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, K;
int d[105];
int A[105][105];
int main() {
    cin >> N >> K;
    set<int> snack;
    rep(i, K) {
        cin >> d[i];
        rep(j, d[i]) {
            cin >> A[i][j];
            snack.insert(A[i][j]);
        }
    }
    int res = N - snack.size();

    cout << res << endl;


    return 0;
}


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

int main()
{
	int n, c, mini=999999, br=0;
	cin >> n >> c;
	int a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
		c-=a[i];
		br++;
		if(a[i]<mini){mini=a[i];}
	}

	if(c>mini){
		br+=(c/mini);
	}

	cout << br << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m,q; cin>>n>>m>>q;
    vector<ll> a(q),b(q),c(q),d(q);
    rep(i,q) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        --a[i]; --b[i];
    }

    vector<int> x;
    int ans = -INF;
    auto dfs = [&](auto &&f, int idx, int p) -> void {
        if (x.size()==n) {
            int tmp = 0;
            rep(i,q) {
                if (x[b[i]]-x[a[i]] == c[i]) tmp += d[i];
            }
            chmax(ans,tmp);
            return;
        }

        for (int i = p; i <= m; ++i) {
            x.push_back(i);
            f(f, idx+1, i);
            x.pop_back();
        }
        return;
    };

    dfs(dfs,0,1);
    cout << ans << '\n';
    return 0;
}

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

// ??????????????????

int BubbleSort(int A[], int N){
	int move = 0;
	bool flag = 1;

	for (int i = 0; flag; i++){
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--){
			if (A[j] < A[j - 1]){
				swap(A[j], A[j - 1]);
				flag = 1;
				move++;
			}
		}
	}

	return move;
}

int main(){

	int N;
	int A[100];
	int move = 0;

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	move = BubbleSort(A, N);
	
	for (int i = 0; i < N; i++){
		if (i) cout << ' ';
		cout << A[i];
	}

	cout << endl;
	cout << move << endl;

	return 0;
	
}

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

int main(){
  int a,b;
  cin >>a >>b;
  if (a<b){
      cout <<"a < b"<<endl;
  }else if(a>b){
      cout << "a > b"<<endl;
  }else{
      cout << "a == b"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3068
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  cin >> a;
  auto itr = max_element(a.begin(), a.end());
  int ans = *itr - (K - *itr) - 1;
  cout << max(0, ans) << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,k;cin>>n>>k;
    int ans = 0;
    rep(i,n){
        int tmp; cin>>tmp;
        if(tmp>=k)++ans;
    }
    cout<<ans<<endl;return 0;
}


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

const int MAXN = 1 + (int) 2.0e5; 

int main(){
    int N;
    int Anum[MAXN]={};
    cin >> N;
    int A[N];
    int Amax=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        Anum[A[i]]++; 
        Amax=max(Amax,A[i]);
    }

    long long sum=0;
    long long ans;

    for(int i=1; i<MAXN; i++){
        sum += ( (long long) Anum[i]) * ( ( (long long) Anum[i] )-1ll)/2ll;
        //if(i<=Amax) cout << "i Anum[i] sum " << i << " " << Anum[i] << " " << sum << endl;
        //if(i%100000==0) cout << "i Anum[i] sum " << i << " " << Anum[i] << " " << sum << endl;
    }

    //cout << "sum " << sum << endl;

    for(int i=0; i<N; i++){
        ans = sum - ( (long long) Anum[A[i]]) * ( ( (long long) Anum[A[i]] )-1ll)/2ll + ( ( (long long) Anum[A[i]] ) - 1ll) * ( ( (long long) Anum[A[i]] )-2ll)/2ll;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a==b){
        cout << a*2 << endl;
    }else if(a > b){
        cout << a+(a-1) << endl;
    }else{
        cout << b+(b-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let _ = scan!(usize);
    let v = scan!(i64;;);

    let mut ans = v[0];
    for &i in v[1..].iter() {
        ans = gcd(ans, i)
    }
    println!("{}", ans)
}


Measured memory_bytes: 6396
N = int(input())
count = 0
flag = False
for i in range(N):
  x, y = map(int, input().split())
  if x==y:
    count += 1
    if count == 3:
      flag = True
      break
  else:
    count = 0
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62360
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    while (true) {
		    String line = br.readLine();
		    int H = Integer.parseInt(line.split(" ")[0]);
		    int W = Integer.parseInt(line.split(" ")[1]);

		    if (H == 0 && W == 0) break;

		    display(H, W);
	    }
	}

	public static void display(int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i % 2 == 0) {
					// row 0,2,4...
					if (j % 2 == 0) {
						// col 0,2,4..
						System.out.print("#");
					} else {
						// col 1,3,5..
						System.out.print(".");
					}
				} else {
					// row 1,3,5...
					if (j % 2 == 0) {
						// col 0,2,4..
						System.out.print(".");
					} else {
						// col 1,3,5..
						System.out.print("#");
					}
				}
			}
			System.out.println("");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 31072
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000007;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
int n;
int a[22][22];
lli dp[1<<21][22];
lli solve(lli mask,int ind)
{
	if(ind>=n)
	{
		if(mask==(1<<n)-1)
			return 1;
		else 
			return 0;
	}
	if(dp[mask][ind]!=-1)
		return dp[mask][ind];
	lli temp=0;
	lli nmask=mask;
	for(int j=0;j<n;j++)
	{
		if(mask&(1<<j))
			continue;
		if(a[ind][j])
			temp+=solve(nmask|(1<<j),ind+1);

	}
	return dp[mask][ind]=temp%MOD;

}	
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	// clock_t start,end;
	// start=clock();
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	
	
	// end=clock();
	
	// double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
	// cout<<fixed<<setprecision(10)<<time_taken<<" sec"<<endl;
	
	
	cin>>n;
	//int a[n][n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	mset(dp,-1);
	cout<<solve(0,0)<<endl;
}


Measured memory_bytes: 364124
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
    N, M, K = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    CD = [list(map(int, input().split())) for _ in range(K)]
    friends = [0 for _ in range(N)]
    blocks = [0 for _ in range(N)]
    unions = UnionFind(N)
    for a, b in AB:
        unions.union(a-1, b-1)
        friends[a-1] += 1
        friends[b-1] += 1
    for c, d in CD:
        if unions.same(c-1, d-1):
            blocks[c-1] += 1
            blocks[d-1] += 1
    ans = []
    for i in range(N):
        ans.append(unions.size(i)-friends[i]-blocks[i]-1)
    print(*ans)


if '__main__' == __name__:
    resolve()


Measured memory_bytes: 122036
#include <iostream>
using namespace std;
int main(void){
  int N,Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for(int a = 0; a <= N; ++a){
    for(int b = 0; b + a <= N; ++b){
      int c = N-a-b;
      int total = 10000*a+5000*b+1000*c;
      if(total == Y){
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  cout << res10000 << ' ' << res5000 << ' ' << res1000 <<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7

t=[0,0,0]
ans=1

for i in range(n):
    now=A[i]
    cnt=0
    for q in range(3):
        if t[q]==now:
            cnt+=1
    ans=ans*cnt%mod
    for q in range(3):
        if t[q]==now:
            t[q]+=1
            break

print(ans)

Measured memory_bytes: 20324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans=0;
	if(a[0]!=0)cout<<-1<<endl;
	else{
		ll cnt=1;
		for(int i=1;i<=n;i++){
			if(a[i]==a[i-1])cnt++;
			else if(a[i]>a[i-1]){
				if(a[i]-a[i-1]>1){
					cout<<-1<<endl;
					return 0;
				}
				ans+=(cnt-1)*a[i-1];
				cnt=1;
			}else{
				ans+=cnt*a[i-1];
				cnt=1;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 5188
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MAXN (100000*2+1)
#define MOD (1000000007)

//Union Find
int uf[MAXN];
int ufSize[MAXN];
void UFinit(int n)
{
    for(int i=0;i<n;i++)
    {
        uf[i] = i;
        ufSize[i] = 1;
    }
}

int UFroot(int i)
{
    if(uf[i]==i) return i;
    uf[i] = UFroot(uf[i]);
    return uf[i];
}

// 元々根が同じならfalse 違うなら統合してtrue
bool UFunite(int i,int j)
{
    int ri = UFroot(i);
    int rj = UFroot(j);

    if(ri == rj) return false;
    ufSize[ri] += ufSize[rj];
    uf[rj] = ri;
    return true;
}

typedef struct
{
    int r;
    int c;
    int a;
}card;

card cs[MAXN];
int des_cs(const void *a, const void *b){return (*(card*)b).a - (*(card*)a).a;} /* 8,7,6,5.. */

bool close[MAXN];

int main(void)
{
    int n,h,w;
    scanf("%d %d %d",&n, &h, &w);

    for(int i=0;i<n;i++) scanf("%d %d %d",&(cs[i].r),&(cs[i].c),&(cs[i].a));
    qsort(cs, n, sizeof(card), des_cs);

    UFinit(h+w+1); // c は h+1からスタート

    uint64_t ans = 0;
    for(int i=0;i<n;i++) 
    {
        int rr = UFroot(cs[i].r);
        int cr = UFroot(cs[i].c+h);
        if(rr == cr)
        {
            //既に同じ連結成分
            if(!close[rr])
            {
                close[rr] = true;
                ans += cs[i].a;
            }
        }else
        {
            if( !(close[rr] && close[cr]) )
            {
                UFunite(rr, cr);
                close[rr] = close[rr] || close[cr];
                ans += cs[i].a;
            }
        }
    }
    printf("%ld\n",ans);

    return 0;
}





Measured memory_bytes: 5480
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 100005
#define NIL -1

using namespace std;
using LL=long long;

struct Node { int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    cout<<"depth = "<<D[u]<<", ";
    if(T[u].p==NIL) cout<<"root, ";
    else if(T[u].l==NIL) cout<<"leaf, ";
    else cout<<"internal node, ";
    cout<<"[";
    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i) cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

void rec(int u,int p){
    D[u]=p;
    if(T[u].r!=NIL) rec(T[u].r,p);
    if(T[u].l!=NIL) rec(T[u].l,p+1);
}

int main(){
    int i,j,d,v,c,l,r;
    cin>>n;
    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
    for(i=0;i<n;i++){
        cin>>v>>d;
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0) T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL) r=i;
    }
    rec(r,0);
    for(i=0;i<n;i++) print(i);
    return 0;
}



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

ll n;
vector<ll>now,nextt;

int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        ll val;
        scanf("%lld",&val);
        now.push_back(val);
    }
    nextt.push_back(now[0]);
    for(ll i=1;i<now.size();i++)
    {
        if(now[i]==nextt[nextt.size()-1])continue;
        else nextt.push_back(now[i]);
    }
    for(ll i=0;i<nextt.size();i++){if(i>0)printf(" ");cout<<nextt[i];}
    printf("\n");
    return 0;
}




Measured memory_bytes: 5192
#include<stdio.h>



int main()
{
	int a,b,c=0,i,flag;

	for (;;c++)
	{
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
		{
			break;
		}
		if (c != 0)
		{
			printf("\n");
		}
		flag = 1;
		for (i = a; i < b + 1; i++)
		{
			if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
			{
				flag = 0;
				printf("%d\n",i);
			}
		}
		if (flag)
		{
			printf("NA\n");
		}
		
		
	}


	return 0;
}


Measured memory_bytes: 616
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    s = input()
    d = {"R":0,"G":1,"B":2}
    nm = 1
    nc = [0,0,0]
    stt = [0,0,0]
    res = [0,0,0]
    for si in s:
        i = d[si]
        nc[i] += 1
        if nc[i] > nc[i-1] and nc[i] > nc[i-2]:
            stt[i] += 1
        elif nc[i] <= nc[i-1] and nc[i] <= nc[i-2]:
            nm *= res[i]
            res[i] -= 1
        else:
            if stt[i-1] == 0:
                res[i-1] += 1
                nm *= stt[i-2]
                stt[i-2] -= 1
            else:
                res[i-2] += 1
                nm *= stt[i-1]
                stt[i-1] -= 1
        nm %= mod

    for i in range(1,n+1):
        nm *= i
        nm %= mod
    print(nm)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 77116
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 2;
	x %= mod;
	return x;
}
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
char a[501][501];
bool seen[1000][1000] = { false };
void dfs(int x,int y,int h,int w) {
	seen[x][y] = true;
	for (int i = 0; i < 4; i++) {
		int Nx = x + dx[i];
		int Ny = y + dy[i];
		if (Nx >= h || Ny >= w || seen[Nx][Ny] || a[Nx][Ny] == '#' || Nx < 0 || Ny < 0)continue;
		dfs(Nx, Ny,h,w);
	}
}
int main() {
	double a,ans;
	cin >> a;
	ans = 3.14 * a * 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3800
#include <iostream>

int H, W;
char color[100][100];               //マス(i,j)の色
int distance[100][100];             //マス(i,j)に辿り着くための最小移動回数

//深さ優先探索でスタートからゴールまでの最短経路を求める
void dfs(int i, int j, int d){
  if(i < 0 || i >= H || j < 0 || j >= W){           //範囲外の場合
    return;
  }
  if(color[i][j] == '#'){           //黒のマスに到達した場合は行き止まりなのでそれ以上探索しない
    return;
  }
  if(d < distance[i][j] || distance[i][j] == -1){          //最短経路であれば値を更新
    distance[i][j] = d;
  }else{                            //最短経路でなければそれ以上探索しない
    return;
  }
  //上下左右の隣接マスについて再帰
  dfs(i-1, j, distance[i][j]+1);
  dfs(i, j-1, distance[i][j]+1);
  dfs(i+1, j, distance[i][j]+1);
  dfs(i, j+1, distance[i][j]+1);
}

int main(){
  int black = 0, change = 0;
  std::cin >> H >> W;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      std::cin >> color[i][j];
      if(color[i][j] == '#'){
        ++black;                    //初期状態の黒のマスをカウント
      }
      distance[i][j] = -1;
    }
  }

  dfs(0,0,1);

  if(distance[H-1][W-1] == -1){
    change = -1;
  }else{
    //全マス目の総数-最短経路のマス目の総数が黒のマスの総数
    //塗り替えるのは黒のマスの総数-初期状態の黒のマス
    change = H*W - distance[H-1][W-1] - black;
  }
  std::cout << change << std::endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int L;
    cin >> L;

    int N = 20;
    int M = 0;
    WGraph res(N);
    for (int i=0; i<N-1; ++i) {
        res[i].push_back({i+1, 0});
        ++M;
    }
    --L;
    int cur = 0;
    for ( ; cur<N-1; ++cur) {
        if (L >= (1 << (cur+1))) {
            res[N-cur-2].push_back({N-cur-1, (1<<cur)});
            ++M;
        } else {
            break;
        }
    }
    int mod = L - (1<<cur) + 1;
    int c = 1 << cur;
    if (cur == 19) --cur;
    for (int i=0; i<cur+1; ++i) {
        if (mod & (1<<i)) {
            res[N-cur-2].push_back({N-i-1, c});
            ++M;
            c += (1<<i);
        }
    }

    cout << N << ' ' << M << '\n';
    for (int i=0; i<N; ++i) for (auto p : res[i]) cout << i+1 << ' ' << p.first+1 << ' ' << p.second << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int h, w;
	cin >> h >> w;
	char field[100][100] = {};

	REP(i, h) {
		REP(j, w) {
			cin >> field[i][j];
		}
	}

	VI yoko(0);
	VI tate(0);
	REP(i, h) {
		REP(j, w) {
			if (field[i][j] == '#') {
				yoko.push_back(i);
				tate.push_back(j);
			}
		}
	}

	SORT(yoko);
	SORT(tate);

	yoko.erase(unique(yoko.begin(), yoko.end()), yoko.end());
	tate.erase(unique(tate.begin(), tate.end()), tate.end());

	REP(i, yoko.size()) {
		REP(j, tate.size()) {
			cout << field[yoko[i]][tate[j]];
		}
		cout << endl;
	}


	return 0;
}



Measured memory_bytes: 384
#create date: 2020-06-29 13:35

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    k = ni()
    q = deque(map(str, range(1, 10)))
    for i in range(k):
        n = q.popleft()
        last_n = n[-1]
        for diff in range(-1, 2):
            next_n = int(last_n) + diff
            if next_n >= 0 and next_n <= 9:
                q.append(n+str(next_n))
    print(n)
if __name__ == "__main__":
    main()

Measured memory_bytes: 22528
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<String,Integer>hm = new HashMap<String,Integer>();
		
		hm.put("SUN",7);
		hm.put("MON",6);
		hm.put("TUE",5);
		hm.put("WED",4);
		hm.put("THU",3);
		hm.put("FRI",2);
		hm.put("SAT",1);
		
		String s = sc.next();
		
		System.out.println(hm.get(s));


	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()

int main(){
  int x;
  cin >> x;
  if (x == 0)
    cout << 1;
  else 
    cout << 0;

}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long N,M,cnt=0;
    cin >> N >>M;
    vector<long>H(N),A(M),B(M),check(N,1);
    for(int i=0;i<N;i++){
        cin >>H[i];
    }
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
    }
    for(int i=0;i<M;i++){
        if(H[A[i]-1]>H[B[i]-1]){
            check[B[i]-1]=0;
        }else if(H[A[i]-1]<H[B[i]-1]){
            check[A[i]-1]=0;
        }else{
            check[A[i]-1]=0;
            check[B[i]-1]=0;
        }
    }
    for(int i=0;i<N;i++){
        if(check[i]==1){
            cnt++;
        }   
    }
    cout << cnt;
}

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


int main() {
 int n; cin >> n;
 vector<string> s(n); rep(i,n)cin >> s[i];
 rep(i,n) sort(s[i].begin(), s[i].end());
 sort(s.begin() , s.end());
 ll ans = 0;
 ll x = 0;//それぞれの区間での値
 rep(i,n-1){
   if(s[i] == s[i+1])x++;
   else{
     ans += x * (x + 1) / 2;
     x = 0;
   }}
  ans += x * (x + 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 7296
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

void solve()
{
	string s;
	cin>>s;
	int n=s.length();
	int ans=0;
	for (int i=0; i<n/2; i++)
	{
		if (s[i]!=s[n-1-i])
			ans++;
	}
	cout<<ans<<endl;
}
int32_t main()
{
    fast_cin();
    int t;
    t=1;
    while (t--)
    {
    	solve();
    }
    return 0;
} 

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if(k&1) cout << b-a;
	else cout << a-b;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>
#include <set>
#include <bitset>

#define forin(i, f, t) for(ll i = f; i < t; i++)

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

ll N, X;
vector<ll> xs;

void input() {
    cin >> N >> X;
    xs.resize(N);
    for (auto& v : xs)
        cin >> v;
}

ull solve() {
    ll cxs[N];
    cxs[0] = xs[0];
    for (int i = 1; i < N; i++) {
        cxs[i] = cxs[i - 1] + xs[i];
        cerr << cxs[i] << endl;
    }
    
    ull ans = numeric_limits<ull>::max();
    for (auto k = 1; k <= N; k++) {
        ull cAns = X * k;
        for (auto i = 0; i < ceil(float(N) / k); i++) {
            ll b = N - k * i - 1;
            ll clen = (b - k) >= 0 ? cxs[b] - cxs[b - k] : cxs[b];
            if (i == 0) {
                cAns += clen * 5;
            } else {
                cAns += clen * (2 * (i + 1) + 1);
            }
         }
        ans = min(ans, cAns);
    }
    
    return ans + X * N;
}

int main() {
    input();
    
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back


int n,r;
const int INF = 1000000007;

map<int,int> bill;

bool input(){
	cin>>r>>n;
	if(n==0 && r==0)return false;
	
	bill.clear();
	reps(i,-20,20+1)bill[i] = 0;
	
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		
		reps(j,a,b){
			bill[j] = max(bill[j], c);
		}
	}
	return true;
}

double check(int x, int h){
	
	if(abs(x) >= r)return INF;
	
	double t = r - sqrt(r*r - x*x) + h;
	//printf("x = %d  h = %d  t=%lf\n",x,h,t);
	
	
	return t;
}

void solve(){
	
	double ans = INF;
	
	typedef map<int,int>::iterator itr;
	
	for(itr a = bill.begin(); a!=bill.end(); a++){
		ans = min(ans, check(a->first, a->second));
		ans = min(ans, check(a->first+1, a->second));
	}
	
	printf("%.9lf\n",ans);
}

int main(){
	while(input())solve();
}

Measured memory_bytes: 1224
# C - Tsundoku

import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum = [0]
for i in range(N):
    Asum.append(Asum[i] + A[i])

Bsum = [0]
for j in range(M):
    Bsum.append(Bsum[j] + B[j])

ans = 0
for i in range(N+1):
    if Asum[i] > K:
        continue
    tmp = K - Asum[i]
    j = bisect.bisect_right(Bsum, tmp) - 1
    ans = max(ans, i+j)
print(ans)


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

const int MAX_N = 1<<17;
int N, dt[MAX_N*2-1];

void init(int n){
    N=1;
    while(N<n)N*=2;
    REP(i,2*N-1)dt[i]=0;
}

void add(int i,int x){
    i+=N-1;
    dt[i]+=x;
    while(i>0){
        i=(i-1)/2;
        dt[i]=dt[i*2+1]+dt[i*2+2];
    }
}

int getSum(int s,int t,int k,int l,int r){
    if(r<=s||t<=l)return 0;
    if(s<=l&&r<=t)return dt[k];
    else{
        int vl = getSum(s,t,k*2+1,l,(l+r)/2);
        int vr = getSum(s,t,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}

void solve() 
{
    int n,q;
    cin>>n>>q;
    init(n);
    while(q--){
        int com,x,y;
        cin>>com>>x>>y;
        if(com) cout<<getSum(x-1,y,0,0,N)<<endl;
        else add(x-1,y);
    }
}

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


Measured memory_bytes: 4160
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	double n;cin>>n;
	printf("%.2lf\n",n*PI*2.0);

}
int main()
{
	solve();
	return 0;
}




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

int main()
{
  string s,ring;
  int n,ans=0;

  cin>>s>>n;
  for(int i=0;i<n;i++){
    cin>>ring;
    ring=ring+ring;
    bool flag=false;
    for(int i=0;i<ring.length()-s.length();i++){
      if(ring.substr(i,s.length())==s)flag=true;
    }
    if(flag)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

bool range2d(int x, int y, int W, int H) { return (x >= 0) && (y >= 0) && (W > x) && (H > y); }

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

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  vector<char> c(N);
  vector<vector<int>> white(2*K+1, vector<int>(2*K+1, 0));
  REP(i, N){
    cin >> x[i] >> y[i] >> c[i];
    if(c[i] == 'B'){
      y[i] += K;
    }
    x[i] %= 2*K, y[i] %= 2*K;
    white[y[i]+1][x[i]+1]++;
  }
  // cout << "------------------" << endl;
  // REP(i, 2*K+1){
  //   REP(j, 2*K+1){
  //     cout << white[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  REP(i, 2*K){
    REP(j, 2*K){
      white[i+1][j+1] += white[i][j+1] + white[i+1][j] - white[i][j];
    }
  }
  // cout << "------------------" << endl;
  // REP(i, 2*K+1){
  //   REP(j, 2*K+1){
  //     cout << white[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << "------------------" << endl;
  // REP(i, 2*K){
  //   FOR(j, 1, 2*K){
  //     white[i][j] += white[i][j-1];
  //   }
  // }
  // FOR(i, 1, 2*K){
  //   REP(j, 2*K){
  //     white[i][j] += white[i-1][j];
  //   }
  // }
  int ans = 0;
  REP(i, K){
    REP(j, K){
      // cout << "i:" << i << " j:" << j << endl;
      int cnt = 0;
      cnt += white[i][j];
      // cout << "1:" << white[i][j] << endl;
      cnt += white[i+K][j+K] - white[i][j+K] - white[i+K][j] + white[i][j];
      // cout << "2:" << white[i+K][j+K] - white[i][j+K] - white[i+K][j] + white[i][j] << endl;
      cnt += white[2*K][j] - white[2*K][0] - white[i+K][j] + white[i+K][0];
      // cout << "3:" <<  white[2*K][j] - white[2*K][0] - white[i+K][j] + white[i+K][0]<< endl;
      cnt += white[i][2*K] - white[i][j+K] - white[0][2*K] + white[0][j+K];
      // cout << "4:" << white[i][2*K] - white[i][j+K] - white[0][2*K] + white[0][j+K]<< endl;
      cnt += white[2*K][2*K] - white[2*K][j+K] - white[i+K][2*K] +white[i+K][j+K];
      // cout << "5:" << white[2*K][2*K] - white[2*K][j+K] - white[i+K][2*K] +white[i+K][j+K]<< endl;
      // cout << "cnt:" << cnt << endl;
      ans = max(ans, max(cnt, N- cnt));
    }
  }
  cout << ans << endl;
  
  return 0; 
}

Measured memory_bytes: 16896
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>

using namespace std;

int main(void){

    long long int n, m;
    cin>>n>>m;
    priority_queue<long long int> que;

    for(int i=0;i<n;i++){
        long long int a;
        cin>>a;
        que.push(a);
    }

    for(int i=0;i<m;i++){
        long long int x;
        x = que.top() / 2;
        que.pop();
        que.push(x);
    }

    long long int sum = 0;

    for(int i=0;i<n;i++){
        sum += que.top();
        //cout<<i<<" "<<que.top()<<endl;
        que.pop();
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
bool vis[100005];
int arr[100005];
class Graph
{
	map<int,vector<int>>adj;
	int V;
public: Graph(int ver)
         {
          V=ver;	
		 }
		 void add_edge(int u,int v)
		 {
		  adj[u].push_back(v);
//		  adj[v].push_back(u);	
		 }
		 int dfs(int node,map<int,bool>&visited)
		 {
		 	if(vis[node]==true)
		 	return arr[node];
		 	vis[node]=true;
		 	visited[node]=true;
		 	int cnt=0;
		 	for(auto nbr:adj[node])
		 	{
		 		cnt++;
		 		if(visited[nbr]==false)
		 		{
		 		 arr[node]=max(arr[node],1+dfs(nbr,visited));	
				}
			}
			if(cnt==0)
			{
				arr[node]=0;
			}
		 	visited[node]=false;
		 	return arr[node];
		 }
		 void fun()
		 {
		 	int ans=0;
		  for(int i=1;i<=V;i++)
		  {
		   if(vis[i]==false)
		   {
		   	map<int,bool>visited;
		   	arr[i]=dfs(i,visited);
		   	if(ans<arr[i])
		   	ans=arr[i];
		   }
		   	
		  }	
		  cout<<ans<<endl;
		 }	
		 
};
int main()
{
	long int n,m,x,y,i;
	cin>>n>>m;
	 Graph g(n);
	for(i=1;i<=m;i++)
	{
	  cin>>x>>y;
	  g.add_edge(x,y);
//	  cout<<endl;	
    }
    g.fun();
return 0;	
}
	

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

typedef int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], int first, int last){
    int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int gcd(int x, int y){
    if (y == 0) return x;
    else        return gcd(y, x % y);
}

int main() {
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d",&k);
    printf("%d",a[k-1]);
    return 0;
}


Measured memory_bytes: 128
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    ptr = 0
    l = len(s)
    res = [0] * l

    for i in range(l):
        c = s[i]
        if c == "B":
            ptr = max(0, ptr - 1)
        else:
            res[ptr] = c
            ptr += 1

    print("".join(res[0:ptr]))



if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import collections
n = int(input())
v = list(map(int, input().split()))

v0 = collections.Counter([v[2 * i] for i in range(n // 2)])
v1 = collections.Counter([v[2 * i + 1] for i in range(n // 2)])

if v0.most_common()[0][0] != v1.most_common()[0][0]:
    ans = n - v0.most_common()[0][1] - v1.most_common()[0][1]
else:
    if len(v0) == 1:
        if len(v1) == 1:
            ans = n // 2
        else:
            ans = n - v1.most_common()[1][1]
    else:
        if len(v1) == 1:
            ans = n - v0.most_common()[1][1]
        else:
            ans = min(n - v0.most_common()[0][1] - v1.most_common()[1][1], n - v0.most_common()[1][1] - v1.most_common()[0][1])

print(ans)

Measured memory_bytes: 18656