akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

const int maxn = 1e5 + 100;

int n, m;

vector<vector<int> > graph;

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  graph = vector<vector<int> > (n);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    graph[a].pb(b);
    graph[b].pb(a);
  }
  return true;
}

bool ok;
int cols[maxn];
int k;

void dfs(int v, int c = 1) {
  if (cols[v] != -1) {
    if (cols[v] != c) {
      ok = false;
    }
    return;
  }
  k++;
  eprintf("%d %d\n", v, c);
  cols[v] = c;
  for (auto to : graph[v]) {
    dfs(to, c ^ 1);
  }
}

void solve() {
  memset(cols, -1, sizeof(cols));
  int cnt = 0;
  int cnt2 = 0;
  int cnt3 = 0;
  for (int i = 0; i < n; i++) {
    if (cols[i] == -1) {
      ok = true;
      k = 0;
      dfs(i);
      if (k > 1) {
        if (ok) {
          cnt += 1;
        }
        cnt2++;
      } else {
        cnt3++;
      }
    }
  }
  eprintf("%d %d\n", cnt, cnt2);
  ll res = (ll) cnt2 * cnt2 + (ll) cnt * cnt + (ll) n * n - (ll) (n - cnt3) * (n - cnt3);
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  map<string, int> mp;
  queue<string> Q;
  Q.push("01234567");
  mp["01234567"] = 1;
  int d[] = {-4, -1, 1, 4};
  while(!Q.empty()) {
    string s = Q.front();
    Q.pop();
    int x = s.find('0');
    REP(i,4) {
      if (!(i==0&&x<3||i==1&&x%4==0||i==2&&x%4==3||i==3&&x>=4)) {
        string ss = s;
        swap(ss[x], ss[x+d[i]]);
        if (!mp[ss]) {
          Q.push(ss);
          mp[ss] = mp[s] + 1;
        }
      }
    }
  }
  //cout << "ok" << endl;
  string s;
  while(getline(cin,s)) {
    s.erase(remove(ALL(s), ' '), s.end());
    cout << mp[s]-1 << endl;
  }
  
}

Measured memory_bytes: 2384
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut c = 0;
	for i in s.trim().chars() {
		if c % 2 == 0 {
			print!("{}", i);
		}
		c += 1;
	}
	println!("");
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  int n; cin >> n;
  vector<P> w;
  for(int i = 0; i < n; i++){
    int a,b; cin >> a >> b;
    w.push_back(P(b,a));
  }
  sort(w.begin(), w.end());
  int now = 0;
  bool flg = true;
  for(int i = 0; i < n; i++){
    now += w[i].second;
    if(now > w[i].first) flg = false;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 2420
import math

def my_solve2():
    """
    最短時間はもっとも移動可能人数が少ない区間に依存する
    """
    num = int(input())
    transpotations = []
    for _ in range(5):
        transpotations.append(int(input()))

    # print(transpotations, min(transpotations))
    # 最も移動可能人数が少ない区間の抽出
    bottleneck = min(transpotations)

    # 移動時間．切り上げの必要あり
    time = math.ceil(num / bottleneck)

    time += 4
    return time


def my_solve():
    """
    未完成
    現在の人の分布と1分後の人の分布を分けて考えるために2つの人分布リストが必要
    この方法では制限時間内に計算を終了することができない
    """
    num = int(input())
    # print("num: {}".format(num))
    traffic_a = int(input())
    traffic_b = int(input())
    traffic_c = int(input())
    traffic_d = int(input())
    traffic_e = int(input())

    city_people_num = [num, 0, 0, 0, 0, 0]

    time = 0
    # TODO: 現在の人の分布と1分後の人の分布を分けて考えるために2つのリストが必要
    while city_people_num[5] < num:
        #print(city_people_num)
        # 1->2
        if city_people_num[0] >= traffic_a:
            city_people_num[0] -= traffic_a
            city_people_num[1] += traffic_a
        else:
            city_people_num[1] += city_people_num[0]
            city_people_num[0] = 0
        #print(city_people_num)
        time += 1
        # 2->3
        if city_people_num[1] >= traffic_b:
            city_people_num[1] -= traffic_b
            city_people_num[2] += traffic_b
        else:
            city_people_num[2] += city_people_num[1]
            city_people_num[1] = 0
        #print(city_people_num)
        time += 1
        # 3->4
        if city_people_num[2] >= traffic_c:
            city_people_num[2] -= traffic_c
            city_people_num[3] += traffic_c
        else:
            city_people_num[3] += city_people_num[2]
            city_people_num[2] = 0
        time += 1
        # 4->5
        if city_people_num[3] >= traffic_d:
            city_people_num[3] -= traffic_d
            city_people_num[4] += traffic_d
        else:
            city_people_num[4] += city_people_num[3]
            city_people_num[3] = 0
        time += 1
        # 5->6
        if city_people_num[4] >= traffic_e:
            city_people_num[4] -= traffic_e
            city_people_num[5] += traffic_e
        else:
            city_people_num[5] += city_people_num[4]
            city_people_num[4] = 0
        time += 1
        #print("time {}".format(time))
        #print(city_people_num)

    return time

print(my_solve2())

Measured memory_bytes: 3188
import sys
import numpy as np
arr = [int(i) for i in sys.stdin.readline().split()]
total = 0
select_botton = np.argmax(arr)
for i in range(2):
  total += arr[select_botton]
  arr[select_botton] = arr[select_botton]-1
  select_botton = np.argmax(arr)
print(total)

Measured memory_bytes: 18024
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include <tuple>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL D;

map<tuple<int, int, LL>, LL > dp;
LL p10[30];

LL DP(int dig, int fl, LL D) {
	if (dp.find(make_tuple( dig, fl, D )) != dp.end()) return dp[make_tuple(dig, fl, D)];
	LL ret = 0;

	if (D < 0) D = -D;

	if (dig == 0) {
		return dp[make_tuple(dig, fl, D)] = D == 0;
	}
	if (D == 0) {
		ret = p10[(dig + 1) / 2];
		return dp[make_tuple(dig, fl, D)] = ret;
	}

	if (dig == 1) {
		if (D == 0) ret = 10;
		else ret = 0;
		return dp[make_tuple(dig, fl, D)] = ret;
	}

	LL mx, mn;
	if (dig % 2) {
		mx = p10[dig] - p10[dig / 2] - (p10[(dig + 1) / 2] - 1);
		mn = p10[(dig + 1) / 2] - p10[dig / 2 - 1];
	}
	else {
		mx = p10[dig] - p10[dig / 2] * 2 + 1;
		mn = p10[dig / 2] - p10[dig / 2 - 1];
	}

	if (D > mx) return dp[make_tuple(dig, fl, D)] = 0;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= i; j++) {
			int k = (10 + j - i) % 10;
			if (k != D % 10) continue;
			if (fl && j == 0) continue;
			LL contrib = (i - j) * (p10[dig - 1] - 1);
			LL tD = D - contrib;
			ret += DP(dig - 2, 0, tD / 10);
		}
	}
	return dp[make_tuple(dig, fl, D)] = ret;
}

int main()
{
	p10[0] = 1;
	for (int i = 1; i <= 20; i++) p10[i] = p10[i - 1] * 10;

	scanf("%lld", &D);
	LL ans = 0;
//	DP(9, 1, D);
	for (int i = 1; i <= 18; i++) ans += DP(i, 1, D);
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
   int X,N;
   cin >> X >> N;
   int p[N];
   for(int i=0;i<N;i++)cin >> p[i];
   int m=0;
   for(;;){
       int flag=0;
        for(int i=0;i<N;i++){
           if(p[i]==X-m)flag++;
         }
        if(flag==0){
            X = X-m;
          printf("%d\n",X);
          return 0;
        }else{
            flag=0;
            for(int i=0;i<N;i++){
                if(p[i]==X+m)flag++;
            }
            if(flag==0){
                X=X+m;
                 printf("%d\n",X);
                return 0;
            }
        }
        m++;
    }
}

Measured memory_bytes: 3720
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	scanf("%d", &N);

	int PRIME_MAX = 55555;
	vector<bool> is_prime(PRIME_MAX + 1, true);
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i * i <= PRIME_MAX; i++) {
		if (!is_prime[i])
			continue;
		for (int j = i; i * j <= PRIME_MAX; j++)
			is_prime[i * j] = false;
	}

	vector<int> cand;
	for (int i = 2; i <= PRIME_MAX; i++) {
		if (!is_prime[i])
			continue;
		if (i % 5 == 1) {
			cand.push_back(i);
			if ((int)cand.size() >= N)
				break;
		}
	}

	for (int i = 0; i < N; i++)
		printf("%d ", cand[i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main(){

	string a;
	cin >> a;
	for(int i=0;i+1<a.length();++i){
		if(a[i]==a[i+1]){
			cout << i+1 << " " << i+2 ;
			return 0;
		}
		if(i+2<a.length() && a[i]==a[i+2]){
			cout << i+1 << " " << i+3 ;
			return 0;
		}
	}
	cout << "-1 -1" ;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    ll n, m_max=0;
    cin >> n;
    string s;
    map<string, ll> m{};
    rep(i, n){
        cin >> s;
        m[s]++;
        m_max = max(m_max, m[s]);
    }
    for(auto x : m){
        if(x.second==m_max){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25344
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N=II()
H=LI()
H.reverse()
for i in range(N-1):

    if H[i+1] - H[i] == 1:
        H[i+1] -=1
    elif H[i+1] - H[i] >1:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 16252
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  int ans = INF;
  REP(bit, (1<<(H-1))){
    int row = 1;
    REP(j, H-1) if((bit >> j)&1) row++;
    int now = row-1;
    vector<int> cnt(row, 0);
    bool ok = true;

    REP(j, W){
      vector<int> cost(row, 0);
      int p = 0;
      REP(i, H){
        if(s[i][j] == '1') cost[p]++;
        if(cost[p] > K) ok = false;
        if(bit&1 << i) p++;
      }
      bool cut = false;
      REP(i, row){
        if(cnt[i]+cost[i] > K) cut = true;
      }
      if(cut){
        now++;
        REP(i, row) cnt[i] = cost[i];
      }else{
        REP(i, row) cnt[i] += cost[i];
      }
    }
    if(ok) chmin(ans, now);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int N, X;
int x[100010];

ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	cin >> N >> X;

	rep(i, 0, N) cin >> x[i];

	ll rsl = abs(x[0] - X);
	rep(i, 1, N) rsl = gcd(rsl, abs(x[i] - X));

	cout << rsl << endl;
	

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int get_gcd(int x, int y);

int main(){
    int n;
    cin >> n;
    vector<int> a_vec(n + 1, 0);
    for(int i = 1; i != n + 1; ++i){
        cin >> a_vec[i];
    }
    
    /*for(int i = 0; i != n + 1; ++i){
        cout << "a_vec[" << i << "] = " << a_vec[i] << endl;
    }*/
    
    vector<int> l_vec(n + 2, 0);
    
    for(int i = 1; i != n + 2; ++i){
        l_vec[i] = get_gcd(l_vec[i - 1], a_vec[i - 1]);
    }

    /*for(int i = 0; i != n + 2; ++i){
        cout << "l_vec[" << i << "] = " << l_vec[i] << endl;
    }*/

    vector<int> r_vec(n + 2, 0);
    
    for(int i = n + 1; i != 0; --i){
        r_vec[i - 1] = get_gcd(r_vec[i], a_vec[i - 1]);
    }

    /*for(int i = 0; i != n + 2; ++i){
        cout << "r_vec[" << i << "] = " << r_vec[i] << endl;
    }*/

    vector<int> m_vec(n + 1, 0);
    int ans = 1;
    for(int i = 0; i != n + 1; ++i){
        m_vec[i] = get_gcd(l_vec[i], r_vec[i + 1]);
        ans = max(ans, m_vec[i]);
    }

    /*for(int i = 0; i != n + 1; ++i){
        cout << "m_vec[" << i << "] = " << m_vec[i] << endl;
    }*/

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

int get_gcd(int x, int y){
    if(x < y){
        int temp = x;
        x = y;
        y = temp;
    }

    if(y == 0) return x;
    else return __gcd(x, y);
}

Measured memory_bytes: 1792
def dijkstra(n):
    d = [None] * 100
    p = [None] * 100
    color = [None] * 100
    
    for i in xrange(n):
        d[i] = float('inf')
        p[i] = -1
        color[i] = 0
    
    d[0] = 0
    
    while(True):
        minv = float('inf')
        u = -1
        for i in xrange(n):
            if minv > d[i] and color[i] != 2:
                u = i
                minv = d[i]
        
        if u == -1:
            break
        
        color[u] = 2
        
        for v in xrange(n):
            if color[v] != 2 and data[u][v] != float('inf'):
                if d[v] > d[u] + data[u][v]:
                    d[v] = d[u] + data[u][v]
                    p[v] = u
                    color[v] = 1

    for i in xrange(n):
        if d[i] == float('inf'):
            print '%d %d' % (i, -1)
        else:
            print '%d %d' % (i, d[i])

n = input()
data = [None] * n
for i in xrange(n):
    data[i] = [float('inf')] * n
    line = map(int, raw_input().split())
    for j in xrange(1, line[1] + 1):
        v = line[2 * j]
        c = line[2 * j + 1]
        data[line[0]][v] = c
        
dijkstra(n)

Measured memory_bytes: 6532
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val st = readLine()!!.split(" ")
    val s = st[0].toCharArray()
    val t = st[1].toCharArray()
    var result = ""
    for ( i in 0 until s.count() ) {
        result += s[i].toString() + t[i].toString()
    }
    print(result)
}

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

using namespace std;

#define int long long

int inf = 4e18;
unordered_map < int, vector < int > > ask;

int get(int x, int y) {
    if (x < 0) {
        int t = (abs(x) + y - 1) / y;
        x += t * y;
    }
    return x % y;
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, d, ans = 0, sum;
    cin >> n >> x >> d;
    if (d == 0) {
        set < int > t;
        for (int k = 0; k <= n; ++k) {
            t.insert(x * (2 * k - n));
        }
        cout << t.size() << '\n';
        return 0;
    }
    sum = n * (n - 1) / 2;
    for (int k = 0; k <= n; ++k) {
        ask[get((2 * k - n) * x, abs(d))].push_back(k);
    }
    int TT = inf / d * d;
    for (auto key : ask) {
        //cout << key.first << " " << key.second.size() << '\n';
        vector < pair < int, int > > T1, T2;
        for (auto k : key.second) {
            int add = ((2 * k - n) * x + TT) / abs(d);
            if (d < 0) add *= (-1);
            //cout << k << " " << d << '\n';
            int imin = k * (k - 1) / 2, imax = n * (n - 1) / 2 - (n - k) * (n - k - 1) / 2;
            imin = max(2 * imin - sum, -3 * sum), imax = min(2 * imax - sum, sum);
            //cout << imin << " " << imax << '\n';
            int L, R;
            if (sum % 2 == 0) {
                if (imin % 2 == 0) L = imin;
                else L = imin + 1;
                if (imax % 2 == 0) R = imax;
                else R = imax - 1;
            }
            else {
                if (abs(imin) % 2 == 1) L = imin;
                else L = imin + 1;
                if (abs(imax) % 2 == 1) R = imax;
                else R = imax - 1;
            }
            //cout << L << ' ' << R << " " << add << '\n';
            if (L <= R) {
                if (abs((L + add)) % 2 == 0) T1.push_back({L + add, R + add});
                else T2.push_back({L + add, R + add});
            }
        }
        sort(T1.begin(), T1.end());
        int lef = -inf + 2, righ = -inf;
        for (auto key : T1) {
            if (key.first > righ) {
                ans += (righ - lef + 2) / 2;
                lef = key.first, righ = key.second;
            }
            else {
                righ = max(righ, key.second);
            }
        }
        ans += (righ - lef + 2) / 2;
        sort(T2.begin(), T2.end());
        lef = -inf + 2, righ = -inf;
        for (auto key : T2) {
            if (key.first > righ) {
                //cout << lef << " " << righ << '\n';
                ans += (righ - lef + 2) / 2;
                lef = key.first, righ = key.second;
            }
            else {
                righ = max(righ, key.second);
            }
        }
        ans += (righ - lef + 2) / 2;
    }
    cout << ans << '\n';
    return 0;
}




Measured memory_bytes: 17864
N = int(input())
A = list(map(int, input().split()))


def selectionSort(li: list, n: int):
    count = 0
    for i in range(n-1):
        minj = i
        for j in range(i+1, n):
            if li[minj] > li[j]:
                minj = j
        li[i], li[minj] = li[minj], li[i]
        if minj != i:
            count += 1
    print(*li)
    print(count)


selectionSort(A, N)



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

using namespace std;

const int N = 1234567;

int a[N], f[N];
int jmp[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", a + i);
  }
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = sum + 1; j <= sum + a[i]; j++) {
      jmp[j] = (i > 1) ? (2 * sum - j) : j;
    }
    sum += a[i];
  }
  for (int i = 0; i <= sum; i++) {
    if (jmp[i] > 0) {
      jmp[i] = jmp[jmp[i]];
    }
  }
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int x;
    scanf("%d", &x);
    int ans = sum - x;
    if (ans > 0) {
      ans = jmp[ans];
    }
    printf("%d\n", 2 * a[0] - ans);
  }
  return 0;
}


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

#define INF 1000000000

int calc_y(int y)
{
    int a = y / 3;
    return a * 200 + (y - a) * 195;
}

int calc_m(int y, int m)
{
    if (y % 3 == 0)
    {
        return m * 20;
    }
    int a = m / 2;
    return a * 19 + (m - a) * 20;
}

int main(void)
{
    int i;
    int n;
    int y, m, d;
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d", &y, &m, &d);
        int a = calc_y(999) + calc_m(1000, 1);
        int b = calc_y(y - 1) + calc_m(y, m) + d;
        if (y % 3 != 0 && m % 2 == 0)
        {
            a--;
        }
        printf("%d\n", a - b + 1);
    }

    return 0;
}


Measured memory_bytes: 1992
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		String s = in.nextToken();
		int i = 0;
		while (i < s.length() && s.charAt(i) != 'C') {
			i++;
		}
		while (i < s.length() && s.charAt(i) != 'F') {
			i++;
		}
		if (i < s.length()) {
			out.println("Yes");
		} else {
			out.println("No");
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const string c = "CODEFESTIVAL2016";

int main() {
  string s;
  cin >> s;

  int ans = 0;
  rep(i, 16) if (c[i] != s[i]) ans++;
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait VecFormat {
    fn spaced_horizontal(&self) -> String;
    fn spaced_vertical(&self) -> String;
}

impl<T> VecFormat for Vec<T> where T: std::fmt::Display {
    fn spaced_horizontal(&self) -> String {
        let mut s: String = self.iter().map(|x| format!("{} ", x)).collect();
        s.pop();
        s
    }
    fn spaced_vertical(&self) -> String {
        let mut s: String = self.iter().map(|x| format!("{}\n", x)).collect();
        s.pop();
        s
    }
}

trait VecVecFormat {
    fn spaced(&self) -> String;
}

impl<T> VecVecFormat for Vec<Vec<T>> where T: std::fmt::Display {
    fn spaced(&self) -> String {
        let v: Vec<_> = self.iter().map(|x| x.spaced_horizontal()).collect();
        v.join("\n")
    }
}


fn dfs(start: usize, parent: usize, values: &Vec<usize>, edges: &Vec<Vec<usize>>, current_state: &mut Vec<usize>, lis: &mut Vec<usize>) {
    let longest_found = match current_state.binary_search(&values[start]) {
        Ok(a) => a,
        Err(a) => a,
    };
    let prev_value = current_state[longest_found];
    current_state[longest_found] = values[start];
    lis[start] = current_state.binary_search(&(std::usize::MAX - 1)).unwrap_err();
    for &node in &edges[start] {
        if node != parent {
            dfs(node, start, values, edges, current_state, lis);
        }
    }
    current_state[longest_found] = prev_value;
}


fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        n: usize,
        a: [usize; n],
        edge_read: [(usize1, usize1); n-1],
    }
    let mut edges = vec![Vec::new(); n];
    for (u,v) in edge_read {
        edges[u].push(v);
        edges[v].push(u);
    }
    let mut current_state = vec![std::usize::MAX; n];
    let mut lis = vec![0; n];
    dfs(0, 0, &a, &edges, &mut current_state, &mut lis);
    println!("{}", lis.spaced_vertical());
}


Measured memory_bytes: 38504
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n, m, l = map(int, input().split())
INF = 1 << 60

dist = [[INF] * n for _ in range(n)]

for i in range(n):
    dist[i][i] = 0

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if c > l:
        continue
    dist[a][b] = c
    dist[b][a] = c


dist = floyd_warshall(csr_matrix(dist))

dist2 = np.full_like(dist, 1)
dist2[np.where(dist > l)] = INF
dist2 = floyd_warshall(dist2, directed=False)
dist2[dist2 == INF] = 0
dist2 = dist2.astype(int)

q = int(input())

ans = []
for _ in range(q):
    s, t = map(int, input().split())
    ans.append(dist2[s - 1, t - 1] - 1)

print(*ans, sep="\n")

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	m = (ll)sqrt(n);
	//cout << m;
	for(ll i = m; i >= 1; --i) {
    	if ((k = n % i) == 0) {
        	cout << n / i + i - 2 << endl;
        	return 0;
        }
    }
    //cout <<  << endl;
}


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

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  multiset<int> mst;
  mst.insert(A[N-1]);
  for(int i = N-2; i >= 0; i--) {
    if(A[i] <= *(mst.rbegin())) {
      auto beg = mst.upper_bound(A[i]);
      auto en = beg;
      en++;
      if(beg != mst.end()){
        mst.erase(beg, en);
      }
    }
    mst.insert(A[i]);
  }
  cout << mst.size() << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc int t;cin>>t;while(t--)
#define otc int t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b)
{return (a.fi > b.fi);}

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool f=0;
	while (a > 0 && c > 0)
	{
		if (f==0)
		{c -= b;
		    f=1;
		    continue;
		}
		
		if(f==1)
		{a -= d;
		    f=0;
		    continue;
		}
	}
	//cout<<a<<" "<<c<<endl;
	
	if (a > 0)
		puts("Yes");
	else
		puts("No");

	return 0;

}

Measured memory_bytes: 3588
# ABC148a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    a = int(input())
    b = int(input())
    print(*set([1, 2, 3]).difference(set([a]), set([b])))
    sys.stderr.write('Error occurred!')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38452
#include <stdio.h>
int main(void) {
long long int a,b,c,d,e,f,g,h,z;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
e=a*c;
f=a*d;
g=b*c;
h=b*d;
z=e;
if(z<f)
z=f;
if(z<g)
z=g;
if(z<h)
z=h;
printf("%lld",z);
return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int n; cin >>n;
	int i;
	for(i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3;
		cin >>x1>>y1>>x2>>y2>>x3>>y3;
		
		double a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1-x2*x2+y1*y1-y2*y2;
		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1-x3*x3+y1*y1-y3*y3;
		
		double x = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double y = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		double r = sqrt( (x-x1)*(x-x1)+(y-y1)*(y-y1) );
		
		// 小数点第４位を四捨五入
		x = floor(1000*x + 0.5)/1000;
		y = floor(1000*y + 0.5)/1000;
		r = floor(1000*r + 0.5)/1000;
		
		printf("%.3lf %.3lf %.3lf\n", x,y,r);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	string s, t;
	cin >> s >> t;
	t += s;
	cout << t;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
import math

global csA
MAXINT = 2 ** 63 - 1

def getsumanddiff(i, j, k):
    tmp = csA[j+1]
    p = tmp - csA[i]
    q = csA[k+1] - tmp
    return p, q, abs(p - q)

N = int(input())
# A = np.array(list(map(int, input().split())))
# csA = np.cumsum(A)

csA = [0] * (N+1)
for i, v in enumerate(input().split()):
    csA[i+1] = csA[i] + int(v)

# init
mid0 = 0
mid2 = 2

p, q, r, s = [0]*4
diff = MAXINT

csAN = csA[N]
for mid1 in range(1, N - 2):
    diff0 = MAXINT
    diff2 = MAXINT
    csAmid1 = csA[mid1+1]

    # mid0 search
    for i in range(mid0, mid1):
        # tmpp, tmpq, tmpdiff0 = getsumanddiff(0, i, mid1)
        tmpp = csA[i+1]
        tmpq = csAmid1 - tmpp
        tmpdiff0 = abs(tmpp - tmpq)
        if diff0 > tmpdiff0:
            mid0 = i
            diff0 = tmpdiff0
            p = tmpp
            q = tmpq
        else:
            break

    # mid2 search
    start = mid1 if mid2 < mid1 else mid2
    for i in range(start, N - 1):
        # tmpr, tmps, tmpdiff2 = getsumanddiff(mid1+1, i, N - 1)
        csAi = csA[i+1]
        tmpr = csAi - csAmid1
        tmps = csAN - csAi
        tmpdiff2 = abs(tmpr - tmps)
        if diff2 > tmpdiff2:
            mid2 = i
            diff2 = tmpdiff2
            r = tmpr
            s = tmps
        else:
            break

    tmpdiff = max(p, q, r, s) - min(p, q, r, s)
    if diff > tmpdiff:
        diff = tmpdiff

print(diff)


Measured memory_bytes: 35152
SA = input()
SB = input()
SC = input()

card = SA[0]
SA = SA[1:] 

checker = '' 

while checker == '':
    if card == 'a':
        if SA == '':
            print('A')
            checker += '*'
        else:
            card = SA[0]
            SA = SA[1:]
    elif card == 'b':
        if SB == '':
            print('B')
            checker += '*'
        else:
            card = SB[0]
            SB = SB[1:]
    else:
        if SC == '':
            print('C')
            checker += '*'
        else:
            card = SC[0]
            SC = SC[1:]

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	optimizar_io
	lli a;
	fori(i, 1, 5) {
		cin >> a;
		if(!a) {cout << i << endl; break;}
	}
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    string s;
    cin >> s;
    for(char i = 'a'; i <= 'z'; ++i){
        if(s.find(i) == string::npos){
            cout << s + i << "\n";
            return 0;
        }
    }
    for (auto i = s.length()-1; i >= 1; --i) {
        if(s[i]<s[i-1]) continue;
        else {
            for (char j = static_cast<char>(s[i - 1] + 1); j <= 'z'; ++j) {
                if(s.substr(0,i-1).find(j) == string::npos) {cout << s.substr(0,i-1)+j;
                return 0;
                }
            }
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
long long int n,k,x,y,sum=0;
scanf("%lld\n%lld\n%lld\n%lld",&n,&k,&x,&y);
if(n-k>0 && n>k)
{
    printf("%lld",(x*k)+((n-k)*y));
}else{
    printf("%lld",x*n);
}

    return 0;
}


Measured memory_bytes: 128
l = list(map(int, input().split()))
ans = 0
while( l[0]%2==0 and l[1]%2==0 and l[2]%2==0):
    if l[0]==l[1]and l[1]==l[2]:
        ans = -1
        break
    else:
        a = l[0]
        b = l[1]
        c = l[2]
        l[0]=(b+c)/2
        l[1]=(a+c)/2
        l[2]=(a+b)/2
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

struct line {
    double m/*-->slope*/, c/*-->y(0)*/;
    double eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};

int main(int argc, char const *argv[])
{
	int n;
	double h;
	long long C;
	cin >> n >> C;

	vector<line> dq;

	int i = 0;

	cin >> h;
	dq.push_back({-2*h, h * h});
	long long ans;
	for(int z = 1; z < n; z ++){
		cin >> h;

		while(dq.size() - 1 != i){
			if(dq[i].intersectX(dq[i+1]) > h) break;
			i ++;
		}
		double y = dq[i].eval(h);

		double fi = y + h*h + C;
		ans = fi;
		int j = dq.size() - 1;
		line l{-2*h, fi + h * h};
		while(dq[j].intersectX(dq[j-1]) >= l.intersectX(dq[j]) && j >= i){
			dq.pop_back();
			j --;
		}
		dq.push_back(l);
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 6512
using System;

namespace AGC020A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);

            Console.WriteLine((b - a) % 2 != 0 ? "Borys" : "Alice");
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(){
  int s[100];
  int a[5000];
  int b[5000];
  int n;
  scanf("%d\n",&n);
  printf("%d\n",n*(n-1)/2-n/2);
  int even = (n+1)%2;
  for(int i=1; i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j==n+even) continue;
      printf("%d %d\n",i, j);
    }
  }
  return 0;
}

Measured memory_bytes: 128
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    x,y = readInts()
    cnt = 0
    while x <= y:
        cnt += 1
        x *= 2
    print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int r;
    cin >> r;
    printf("%.3f\n", double(r * 2 * M_PI));
}

Measured memory_bytes: 3724
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
x0=0
x1=10**9
while(1):
    sum=0
    mid=(x0+x1)//2
    for i in range(n):
        sum+=math.ceil(a[i]/mid)-1
    if(sum<=k):
        x1=mid
    if(sum>k):
        x0=mid
    if(x0+1==x1):
        print(x1)
        break

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

        int N, D;
        std::cin >> N >> D;

        vector<vector<int>> X(N, vector<int>(D));
        REP(i, N) {
            REP(j, D) {
                std::cin >> X[i][j];
            }
        }

        int ans = 0;
        REP(i, N) {
            for(int j = i; j < N; j++) {
                if(i == j) continue;
                double val = 0;
                REP(k, D) {
                    val += pow(X[i][k] - X[j][k], 2);
                }
                val = sqrt(val);
                if(val == floor(val)) {
                    ans++;
                }
            }
        }

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

    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[100010][3];
		int[][] dp = new int[100010][3];

		for (int i = 0; i < n; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
			a[i][2] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k) {
						continue;
					}
					dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + a[i][j]);
					//					System.out.print(dp[i+1][j] + " ");
				}
			}
			//			System.out.println();
		}

		int ans = 0;
		for (int i = 0; i < 3; i++) {
			ans = Math.max(ans, dp[n][i]);
		}

		System.out.println(ans);
		sc.close();

	}
}

Measured memory_bytes: 102380
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		int min = Integer.MAX_VALUE;
		int mini = 0;
		for (int i = 0; i < n; i++) {
			int tmp = Math.abs(n * a[i] - sum);
			if (tmp < min) {
				min = tmp;
				mini = i;
			}
		}
		
		pr.println(mini);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<double> q;
    REP(i, n) {
        int a;
        cin >> a;
        q.push(double(a));
    }
    REP(i, m) {
        double a = q.top();
        q.pop();
        q.push(a/2);
    }
    ll cnt = 0;
    REP(i, n) {
        cnt += int(q.top());
        q.pop();
    }
    std::cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n; cin >> n;
	string s; cin >> s;
	string t;

	string T[4] = { "SS","SW","WW","WS" };

	rep(k, 0, 4) {
		t = T[k];
		rep(i, 1, s.size() - 1) {
			if (s[i] == 'o') {
				if (t[i] == 'S') {
					if (t[i - 1] == 'S') t += 'S';
					else t += 'W';
				}
				else {
					if (t[i - 1] == 'S') t += 'W';
					else t += 'S';
				}
			}
			else {
				if (t[i] == 'S') {
					if (t[i - 1] == 'S') t += 'W';
					else t += 'S';
				}
				else {
					if (t[i - 1] == 'S') t += 'S';
					else t += 'W';
				}
			}
		}

		//check
		ll x = n - 1;
		bool ok = false;
		if (s[x] == 'o') {
			if (t[x] == 'S') {
				if (t[x - 1] == 'S' && t[0] == 'S') ok = true;
				else if (t[x - 1] == 'W' && t[0] == 'W') ok = true;
			}
			else {
				if (t[x - 1] == 'S' && t[0] == 'W') ok = true;
				else if (t[x - 1] == 'W' && t[0] == 'S') ok = true;
			}
		}
		else {
			if (t[x] == 'S') {
				if (t[x - 1] == 'S' && t[0] == 'W') ok = true;
				else if (t[x - 1] == 'W' && t[0] == 'S') ok = true;
			}
			else {
				if (t[x - 1] == 'S' && t[0] == 'S') ok = true;
				else if (t[x - 1] == 'W' && t[0] == 'W') ok = true;
			}
		}

		x = 0;
		bool ok2 = false;

		if (s[x] == 'o') {
			if (t[x] == 'S') {
				if (t[n - 1] == 'S' && t[1] == 'S') ok2 = true;
				else if (t[n - 1] == 'W' && t[1] == 'W') ok2 = true;
			}
			else {
				if (t[n - 1] == 'S' && t[1] == 'W') ok2 = true;
				else if (t[n - 1] == 'W' && t[1] == 'S') ok2 = true;
			}
		}
		else {
			if (t[x] == 'S') {
				if (t[n - 1] == 'S' && t[1] == 'W') ok2 = true;
				else if (t[n - 1] == 'W' && t[1] == 'S') ok2 = true;
			}
			else {
				if (t[n - 1] == 'S' && t[1] == 'S') ok = true;
				else if (t[n - 1] == 'W' && t[1] == 'W') ok = true;
			}
		}

		if (ok & ok2) {
			cout << t << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 776