akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def _make_minimum_prime(N: int):
    # xの最小の素因数表を作成
    min_prime = [x for x in range(N + 1)]
    # min_prime[0] = 0  # 0と1は素数ではない
    # min_prime[1] = 1
    for i in range(2, int(N ** 0.5) + 1):
        if min_prime[i] == i:  # 素数だったら更新
            for j in range(2 * i, N + 1, i):  # iの倍数は素数でない
                if min_prime[j] == j:
                    min_prime[j] = i
    return min_prime


min_prime = _make_minimum_prime(10**6)


from collections import Counter


def fast_factorization(N: int):
    # -> List[Tuple[int,int]] (素数,冪数)を格納
    # 最小素数配列min_primeを使ってO(log N)で因数分解
    if N == 1:
        return Counter()  # 1は素数ではない
    # 素因数分解
    arr = []
    tmp = N
    while tmp != 1:
        p = min_prime[tmp]
        tmp //= p
        arr.append(p)

    return Counter(arr)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from math import gcd


N = a_int()
A = ints()

# setかはすぐわかる
# setでなければ not coprime
# pairは互いに素かをみればいいのか
# つまり因数分解して足してったときにすべての素数のべき数が1以下であれば良い

g_set = 0
cnt = defaultdict(lambda: 0)
flg = 1  # pairwiseであるフラグ
for a in A:
    g_set = gcd(g_set, a)
    if flg:
        for p, n in fast_factorization(a).items():
            if cnt[p] != 0:
                flg = 0
            cnt[p] += n


# print(cnt)
# for v in cnt.values():
#     if v > 1:
#         flg = 0
#         break

if g_set > 1:
    print('not coprime')
elif flg:
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 194052
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
int n;
int arr[100005];
int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &arr[i]);
	}
	int answer = 0;
	for (int i = 0; i < n; i++){
		if (i == n - 1){
			if (arr[i] == i + 1){
				answer++;
			}
			continue;
		}
		if (arr[i] == i + 1){
			int c = arr[i];
			arr[i] = arr[i + 1];
			arr[i + 1] = c;
			answer++;
		}
	}
	printf("%d\n", answer);
	
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll x, y;
ll f[1010100], rf[1010100];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

ll cal_c(int n, int k) {
  f[0] = 1;
  FOR(i, 1, 1010100) f[i] = (f[i - 1] * i) % mod;
  FOR(i, 0, 1010100) rf[i] = inv(f[i]);
  ll a = f[n];
  ll b = rf[n-k];
  ll c = rf[k];

  ll bc = (b * c) % mod;

  return (a * bc) % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y;

  ll ans = 0;
  ll a = (2 * x - y);
  ll b = (2 * y - x);
  if(a % 3 == 0 && b % 3 == 0) {
    a /= 3;
    b /= 3;

    if(a >= 0 && b >= 0) {
      ll ma = max(a, b);
      ans = cal_c(a + b, ma);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 16000
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,
        s:Chars,
        t:Chars,
    }

    for i in 0..n {
        let mut f = true;
        for j in 0..n - i {
            if s[i + j] != t[j] {
                f = false;
            }
        }
        if f {
            println!("{}", n + i);
            return;
        }
    }
    println!("{}", n * 2);
}


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

int main() {
  string s, t; cin >> s >> t;
  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<cstdio>
#include<map>
#include<unordered_map>
#include<ios>
#include<iomanip>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
bool A[200020];
bool B[200020] = { false };
int main() {
	cin >> N;
	A[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	for (int i = N; i >= 1; i--) {
		bool tmp = false;
		for (int j = N / i; j > 1; j--) {
			tmp = tmp ^ B[i * j];
		}
		if (tmp == A[i]) {

		}
		else {
			B[i] = true;
		}
	}

	int M = 0;
	vector<int>b;
	for (int i = 1; i <= N; i++) {
		if (B[i]) {
			M++;
			b.push_back(i);
		}
	}
	cout << M << endl;
	for(int i = 0; i<M;i++) {
		cout << b[i] << ' ';
	}
	return 0;
}

Measured memory_bytes: 2040
n = int(input())
S = [input() for i in range(n)]
cnt = [[s.count(chr(97 + i)) for i in range(26)] for s in S]
ans = ''
for i in range(26):
  for j in range(min([c[i] for c in cnt])):
    ans += chr(97 + i)
print(ans)

Measured memory_bytes: 3060
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

void solve()
{
  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a + 2), t(b + 2);
  s[0] = t[0] = -LINF;
  s[a + 1] = t[b + 1] = LINF / 4;
  rep(i, a) cin >> s[i + 1];
  rep(i, b) cin >> t[i + 1];
  rep(i, q)
  {
    ll x;
    cin >> x;
    ll Min = LINF;
    ll Ls = *(upper_bound(all(s), x) - 1);
    ll Lt = *(upper_bound(all(t), x) - 1);
    ll Rs = *(lower_bound(all(s), x));
    ll Rt = *(lower_bound(all(t), x));
    Min = min(Min, max(abs(Ls - x), abs(Lt - x)));
    Min = min(Min, max(abs(Rs - x), abs(Rt - x)));
    Min = min(Min, abs(Ls - x) * 2 + abs(Rt - x));
    Min = min(Min, abs(Ls - x) + abs(Rt - x) * 2);
    Min = min(Min, abs(Rs - x) * 2 + abs(Lt - x));
    Min = min(Min, abs(Rs - x) + abs(Lt - x) * 2);
    cout << Min << "\n";
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  solve();
  return 0;
}


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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int n = s.length();
	int ret = 0;
	string tmp = "", prev = "";
	for (int i = 0; i < n; i++) {
		tmp += s[i];
		if (tmp != prev) {
			prev = tmp;
			tmp = "";
			ret++;
		}
	}
	cout << ret << "\n";

	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
 
int main(){
string N;
int ans = 0;
cin >> N;
for(int i = 0; i < 4; i++)
{
if (N[i] == '2') {
ans++;
}
}
cout << ans <<endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, k, x=1;
	scanf("%d %d", &n, &k);
	while(n--){
		if(x<k) x += x;
		else x += k;
	}
	printf("%d\n", x);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef pair<int, int> pr;
typedef vector<pr> vpr;

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

    vpr p(n);
    for (int i = 0; i < n; i++)
    {
        int pi;
        cin >> pi;
        p[i] = pr(pi, i);
    }

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

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i].second != i)
        {
            cnt++;
        }
    }

    string ans;
    if (cnt == 0 || cnt == 2)
    {
        ans = "YES";
    }
    else
    {
        ans = "NO";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
p = {}
a = N
r = 0

while a-1:
  for i in range(2,int(a**0.5)+10):
    if a%i == 0:
      p[i] = 0
      a //= i
      break
  else:
    break
    
if a != 1:
  p[a] = 0
  
a = N

while a-1:
  for i in range(2,int(a**0.5)+10):
    if a%i == 0:
      p[i] += 1
      a //= i
      break
  else:
    break
    
if a != 1:
  p[a] += 1
  
for el in p:
  a = p[el]
  i = 1
  while a >= i:
    a -= i
    i += 1
    r += 1
    
print(r)

Measured memory_bytes: 9464
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

long long dat[500200], dat2[500200];
int n = 1;
int p[100005];
ll LL[100005], LR[100005], RL[100005], RR[100005];

void init(int _n){
  while (n<_n) n*= 2;
  for (int i=0; i<2*n - 1; i++) dat[i] = LINF;
  for (int i=0; i<2*n - 1; i++) dat2[i] = -LINF;
  return;
}

void built() {
  for (int i=n-2; i>=0; i--) {
    dat[i] = min(dat[2*i+1], dat[2*i+2]);
    dat2[i] = max(dat2[2*i+1], dat2[2*i+2]);
  }
  return;
}

void update(int k, long long a) {
  k += n - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k-1)/2;
    dat[k] = min(dat[2*k+1], dat[2*k+2]);
  }
  return;
}

long long query(int a, int b, int l, int r, int k) {
  if (b <= l || a >= r) return LINF;
  if (a <= l && b >= r) return dat[k];
  
  long long vl = query(a, b, l, (r+l)/2, 2*k+1);
  long long vr = query(a, b, (r+l)/2, r, 2*k+2);
  return min(vl, vr);
}

void update2(int k, long long a) {
  k += n - 1;
  dat2[k] = a;
  while (k > 0) {
    k = (k-1)/2;
    dat2[k] = max(dat2[2*k+1], dat2[2*k+2]);
  }
  return;
}

long long query2(int a, int b, int l, int r, int k) {
  if (b <= l || a >= r) return -LINF;
  if (a <= l && b >= r) return dat2[k];
  
  long long vl = query2(a, b, l, (r+l)/2, 2*k+1);
  long long vr = query2(a, b, (r+l)/2, r, 2*k+2);
  return max(vl, vr);
}

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

  rep(i, 0, N) cin >> p[i];
  init(N+5);
  
  rep(i, 0, N) {
      dat[p[i]+n-1] = (ll)i;
      dat2[p[i]+n-1] = (ll)i;
    }
  
  built();
  
  rep (i, 0, N) {
      ll l = LINF, r = LINF;
      l = query(p[i]+1, N+1, 0, n, 0);
      if (l!=LINF) {
          update(p[l], LINF);
          r = query(p[i]+1, N+1, 0, n, 0);
          update(p[l], l);   
      }
      update(p[i], LINF);
      if(l==LINF) l=N;
      if(r==LINF) r=N;

      RL[p[i]] = l;
      RR[p[i]] = r;
  }

  for (int i=N-1; i>=0; i--) {
      ll l = -LINF, r = -LINF;
      r = query2(p[i]+1, N+1, 0, n, 0);
      if (r!=-LINF) {
          update2(p[r], -LINF);
          l = query2(p[i]+1, N+1, 0, n, 0);
          update2(p[r], r);   
      }
      update2(p[i], -LINF);
      
      if(l==-LINF) l=-1;
      if(r==-LINF) r=-1;
      
      LL[p[i]] = l;
      LR[p[i]] = r;
  }

  ll ans = 0;
  rep(i, 0, N) {
      int x = p[i];
      //printf("x:%d, LL[x]:%lld, LR[x]:%lld, RL[x]:%lld, RR[x]:%lld\n", x, LL[x], LR[x], RL[x], RR[x]);
      ans += (RR[x]-RL[x])*(i-LR[x])*x;
      ans += (LR[x]-LL[x])*(RL[x]-i)*x;
      //printf("%lld\n", ans);
  }
  
  
  
  cout << ans << endl;
    return 0;
}





Measured memory_bytes: 11160
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	int mina = 1000000;
	int maxa = -1;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		mina = min(mina, a[i]);
		maxa = max(maxa, a[i]);
	}
	int minc = 0;
	int maxc = 0;
	if ((mina + 1 == maxa) || (mina == maxa)) {
		for (int i = 0; i < N; i++) {
			if (a[i] == mina) {
				minc++;
			}
			else if (a[i] == maxa) {
				maxc++;
			}
		}
		if (mina == maxa) {
			minc = 0;
		}
		if ((maxa - minc) * 2 <= maxc && (maxa - minc > 0)) {
			cout << "Yes" << endl;
		}
		else {
			if (mina == maxa && (mina == N - 1 || mina * 2 <= N)) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;
const ll N = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;

map<ll, ll> mp;
vector<ll> c(4);

ll solve(ll n) {
    //cerr << n << endl;
    if (n == 0) 
        return 0;
    if (n == 1) {
        return c[3];
    }
    if (n == 2) {
        return min(2 * c[3], c[3] + c[0]);
    }
    //cerr << n << " " << mp.size() << endl;
    if (mp.find(n) != mp.end()) {
        return mp[n];
    }
    ll res = N;
    if (n <= res / c[3])
        res = c[3] * n;
    vector<ll> r = {n % 2, n % 3, n % 5};
    vector<int> d = {2, 3, 5};
    for (int i = 0; i < 3; ++i) {
        if (i == 0) {
            res = min(res, solve((n - r[i]) / d[i]) + r[i] * c[3] + c[i]);
            if (r[i] != 0)
                res = min(res, solve((n + d[i] - r[i]) / d[i]) + (d[i] - r[i]) * c[3] + c[i]);
            continue;
        }
        if (r[i] * 2 < d[i])
            res = min(res, solve((n - r[i]) / d[i]) + r[i] * c[3] + c[i]);
        else
            res = min(res, solve((n + d[i] - r[i]) / d[i]) + (d[i] - r[i]) * c[3] + c[i]);
    }
    mp[n] = res;
    return res;
}

void solveCase() {
    ll n;
    cin >> n;
    mp.clear();
    for (int i = 0; i < 4; ++i)
        cin >> c[i];
    cout << solve(n) << endl;
    //cout << mp.size() << endl;
}

void solve() {
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        solveCase();
    }

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    solve();

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 3824
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, X = LI()
    X -= 1

    # バーガーの厚さ
    l = [0] * (N + 1)
    l[0] = 1
    for i in range(N):
        l[i+1] = 2 * l[i] + 3

    # バーガーのパティ数
    p = [0] * (N + 1)
    p[0] = 1
    for i in range(N):
        p[i+1] = 2 * p[i] + 1

    def rec(n, x):
        if n == 0:
            return 1
        else:
            if x == 0:
                return 0
            elif 1 <= x <= l[n-1]:
                return rec(n - 1, x - 1)
            elif x == l[n-1] + 1:
                return p[n-1] + 1
            elif l[n-1] + 2 <= x <= l[n] - 2:
                return p[n-1] + 1 + rec(n - 1, x - 2 - l[n-1])
            elif x == l[n] - 1:
                return p[n]

    ans = rec(N, X)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10164
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];
        if (a == 0 || b == 0 || a < 0 && b > 0)
        {
            Console.WriteLine("Zero");
        }
        else if (a < 0)
        {
            if (Math.Abs(a - b - 1) % 2 == 0) Console.WriteLine("Positive");
            else Console.WriteLine("Negative");
        }
        else
        {
            Console.WriteLine("Positive");
        }
    }
}

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

int main()
{
    int r;
    cin >> r;
    double ans = 2 * r * M_PI;
    cout << ans << endl;
    return 0;
}


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

struct SCC{
  int n;
  vector<vector<int> > G,rG,T,C;
  vector<int> vs,used,belong;
  SCC(){}
  SCC(int sz):n(sz),G(sz),rG(sz),used(sz),belong(sz){}
  
  void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }
  
  void dfs(int v){
    used[v]=1;
    for(int i=0;i<(int)G[v].size();i++){
      if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }
  
  void rdfs(int v,int k){
    used[v]=1;
    belong[v]=k;
    C[k].push_back(v);
    for(int i=0;i<(int)rG[v].size();i++){
      if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }
  }
  
  int build(){
    fill(used.begin(),used.end(),0);
    vs.clear();
    for(int v=0;v<n;v++){
      if(!used[v]) dfs(v);
    }
    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
	T.push_back(vector<int>());
	C.push_back(vector<int>());
	rdfs(vs[i],k++);
      }
    }
    for(int i=0;i<n;i++)
      for(int u:G[i])
	if(belong[i]!=belong[u])
	  T[belong[i]].push_back(belong[u]);
    for(int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
};

signed main(){
  int n,m;
  cin>>n>>m;
  SCC scc(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    scc.add_edge(a,b);
  }
  scc.build();
  auto T=scc.T;
  int x=T.size();
  if(x==1){
    cout<<0<<endl;
    return 0;
  }
  vector<int> ind(x,0),oud(x,0);
  for(int i=0;i<x;i++){
    for(int u:T[i]){
      oud[i]++;
      ind[u]++;
    }
  }
  int a1=0,a2=0;
  for(int i=0;i<x;i++){
    if(!oud[i]) a1++;
    if(!ind[i]) a2++;
  }
  cout<<max(a1,a2)<<endl;
  return 0;
}

Measured memory_bytes: 7092
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

ll fac[MAX], finv[MAX], inv[MAX];
void init_comb(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll comb(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector< int > graph[MAX_N];

ll dfs(int v, int p, int k){
  int count = (p != -1) ? 
    graph[v].size() - 1 : graph[v].size();
  int kk = ((p != -1) ? k - 2: k - 1);
  ll sum = (comb(kk, count) * fac[count]) % MOD;
  for(int w :graph[v]){
    if(w != p) sum = (sum * dfs(w, v, k)) % MOD;
  }
  return sum;
}

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

  int n, k;
  cin >> n >> k;
  int a[n - 1], b[n - 1];
  for(int i = 0; i < n - 1; i++){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }

  for(int i = 0; i < n - 1; i++){
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  init_comb();
  ll ans = dfs(0, -1, k);
  ans = (ans * k) % MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--){
		string s;
		cin>>s;
		int a,b,c,d;
		a=int(s[0]-'0');
		b=int(s[1]-'0');
		c=int(s[2]-'0');
		d=int(s[3]-'0');
		int f=a*10+b;
		int se=c*10+d;
		if(f>=1&&f<=12){
			if(se>=1&&se<=12){
				cout<<"AMBIGUOUS"<<endl;
			}
			else{
				cout<<"MMYY"<<endl;
			}
		}
		else if(se>=1&&se<=12){
			if(f>=1&&f<=12){
				cout<<"AMBIGUOUS"<<endl;
			}
			else{
				cout<<"YYMM"<<endl;
			}
		}
		else{
			cout<<"NA"<<endl;
		}
	}
}

Measured memory_bytes: 256
n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
ans = 0
# (edgesの長さの総和)/(edgeの本数)*(1つのpathを構成するedgesの数)
# = (edgesの長さの総和)/ (n*(n-1)) * (n-1)
for x1, y1 in L:
    for x2, y2 in L:
        ans += ((x1 - x2)**2 + (y1 - y2)**2)**.5
print(ans/n)

Measured memory_bytes: 2940
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

template<typename T> T gcd(T x, T y){
  if (x % y == 0) return y;
  else return gcd(y, x % y);
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  int a[n]; rep(i, n) cin >> a[i];
  int left[n], right[n];

  left[0] = a[0];
  for (int i = 1; i < n; ++i){
    left[i] = gcd(left[i - 1], a[i]);
  }

  right[n - 1] = a[n - 1];

  for (int i = n - 2; i >= 0; --i){
    right[i] = gcd(right[i + 1], a[i]);
  }

  int ans = 1;
  ans = max(left[n - 2], right[1]);

  for (int i = 1; i <= n - 2; ++i){
    ans = max(ans, gcd(left[i - 1], right[i + 1]));
    //debug(ans);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e8+7;
const int mod=1e9+7;
int m[maxn];
int main()
{
	int n;
	cin>>n;
	int t;
	long long sum=1;
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		m[t]++;
	}
	if(n&1)
	{
		if(m[0]!=1)flag=1;
		for(int i=2;i<=n;i+=2)if(m[i]!=2)flag=1;
		if(flag)puts("0");
		else
		{
			for(int j=0;j < floor(n/2);j++)
		    sum = ((sum % mod) * 2)% mod;
		    cout<<sum<<endl;
		}
	
	}
	else
	{
		for(int i=1;i<n;i+=2)if(m[i]!=2)flag=1;
		if(flag)puts("0");
		else
		{
			for(int j=0;j < floor(n/2);j++)
		    sum = ((sum % mod) * 2)% mod;
		    cout<<sum<<endl;
		}
	}
	return 0;
 } 

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

using namespace std;

int main(void){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> v(N);
    v[0] = 0;
    for(int i = 1; i < N; i++){
        if(S[i - 1] == 'A' && S[i] == 'C') v[i] = v[i - 1] + 1;
        else v[i] = v[i - 1];
    }
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << v[r - 1] - v[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
    {
        if (A == B && B == C)
        {
            cout << -1 << endl;
            return;
        }

        int a = A, b = B, c = C;
        A = b / 2 + c / 2;
        B = c / 2 + a / 2;
        C = a / 2 + b / 2;
        ++ans;
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, K;
    cin >> N >> K;

    vec csum(N+1, 0);
    REP(i,1,N+1) csum[i] = csum[i-1] + i;

    ll min, max, cnt = 0;
    REP(i,K,N+1) {
        min = csum[i-1];
        max = csum[N] - csum[N-i];
        cnt = (cnt + max - min + 1) % MOD;
    }
    PR(cnt+1);

    return 0;
}

/*

0 ... N -> k ko

*/

Measured memory_bytes: 4848
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int a[205][205], dp[205][205][205];
int h, w;

int func(int sx, int sy, int ex, int ey) {
  if(sx >= w || ex >= w || sy >= h || ey >= h) return -INF;
  if(dp[sx][sy][ex] != -1) return dp[sx][sy][ex];
  int res = 0;
  res = max(res, func(sx, sy+1, ex+1, ey));
  res = max(res, func(sx, sy+1, ex, ey+1));
  res = max(res, func(sx+1, sy, ex+1, ey));
  res = max(res, func(sx+1, sy, ex, ey+1));
  if(sx == ex && sy == ey) res += a[sy][sx];
  else res += a[sy][sx] + a[ey][ex];

  // cout << sx << " " << sy << " " << ex << " " << ey << endl;
  // cout << res << endl;
  return dp[sx][sy][ex] = res;
}

signed main(void)
{
  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> a[i][j];
  REP(i, 205) REP(j, 205) REP(k, 205) dp[i][j][k] = -1;

  cout << func(0, 0, 0, 0) << endl;

  return 0;
}


Measured memory_bytes: 34048
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)
for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    count+=pro//ai
print(count%mod)


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>

 

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

#define ic(n) int (n); cin>>(n);

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;






int main(){


	ic(a);ic(b);
	int k = a*b;
	if(k%2==0){
		cout <<"No"<<endl;
	  }
	  else{
		  cout<<"Yes"<<endl;
		}

	  }


	
	

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
const double eps=1e-7;
const int maxn=110;
const int maxm=110;
double lin[maxm][maxm],tmp[maxm][maxm],c[maxm][maxm],ans[maxm],p[maxm],v[maxm],t[maxm];
int main()
{
	for(int i=0;i<maxm;i++)
	{
		c[i][0]=c[i][i]=1;
		for(int j=1;j<i;j++) c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	int n,m;
	double l;
	while(scanf("%d%d%lf",&n,&m,&l)!=EOF)
	{
		for(int i=0;i<n;i++) scanf("%lf%lf%lf",&p[i],&t[i],&v[i]);
		for(int i=0;i<n;i++) p[i]/=100;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				tmp[i][j]=l/v[i]+j*t[i];
				lin[i][j]=pow(p[i],j)*pow((1-p[i]),m-j)*c[m][j];
			}
			for(int j=m-1;j>=0;j--) lin[i][j]+=lin[i][j+1];
			//for(int j=0;j<=m;j++) printf("%f ",lin[i][j]);
			//printf("\n");
			lin[i][m+1]=0;	
		}
		for(int i=0;i<n;i++)
		{
			for(int k=0;k<=m;k++) ans[k]=pow(p[i],k)*pow((1-p[i]),m-k)*c[m][k];
			for(int j=0;j<n;j++) 
				if(j!=i)
				{
					int q=m;
					for(int p=m;p>=0;p--)
					{
						while(q>=0 && tmp[i][q]>=tmp[j][p]-eps) 
						{
							ans[q]*=lin[j][p+1];
							q--;
						}
						if(q==-1) break;
					}
				}
			double sum=0;
			for(int k=0;k<=m;k++) sum+=ans[k];
			printf("%.9f\n",sum);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int a,b;
int main(){
  cin >> a >> b;
  if(a%2 == b%2)cout << (a+b)/2;
  else cout << "IMPOSSIBLE";
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
 
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    ll n,m,i,j,s=0;
    cin>>n>>m;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i],s+=a[i];
    ll c=0;
    for(i=0;i<n;i++)
    {
        if(a[i]<(s/(4.0*m))) continue;
        c++;
    }
    if(c>=m) cout<<"Yes\n";
    else cout<<"No\n";
    
}

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

long long lower(vector<long long>& vec, int num, int N) {
  if (num + 1 >= N) {
    return 0;
  }
  if (vec[num] < vec[num + 1]) {
    return 0;
  }

  return lower(vec, num + 1, N) + 1;
}

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

  vector<long long> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }

  long long ans = 0;
  int i = 0;
  while (i < N - 1) {
    long long count = lower(vec, i, N);
    ans = max(ans, count);
    i += (count + 1);
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  int i_max, j_max;
  int total, count = 0;
  int judge = 0;
  
  cin >> N;
  
  i_max = N / 4 + 1;
  j_max = N / 7 + 1;
  
  for (int i = 0; i <= i_max; i++) {
    for (int j = 0; j <= j_max; j++) {
      total = 4*i + 7*j;
      if (total == N) {
		judge = 1;
        break;
      } else {
        continue;
      }
    }
  }
  
  if (judge == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }    
    
}


Measured memory_bytes: 256
n,k=gets.chomp.split(" ").map { |e| e.to_i }

number = n/k
x = n%k
ans = 0

k.times do |i|
  if ((i+1)*2) % k == 0
    if x != 0
      ans += (number+1)**3
    else
      ans += (number)**3
    end
  end
  if x>0
    x -= 1
  end
end

puts ans

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > H(N);
  cin >> H;
  int ret = 0, add = -inf;
  for(int i = N - 1; i >= 0; i--) {
    if(i + 1 < N && H[i] >= H[i + 1]) add++;
    else add = 0;
    chmax(add, 0);
    chmax(ret, add);
  }
  cout << ret << endl;
}




Measured memory_bytes: 640
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

int main() {
	ll N; cin >> N;
	ll A[2][N]; rep(i, 2)rep(j, N) cin >> A[i][j];

	ll mx = 0;
	for (int j = 0; j < N; j++) {
		ll sum = 0;
		ll flag = 0;
		rep(i, N) {
			if (i == j) {
				sum += (A[0][j] + A[1][j]);
				flag = 1;
				continue;
			}
			if (flag == 0) sum += A[0][i];
			else sum += A[1][i];
		}

		mx = max(mx, sum);
	}

	cout << mx << endl;
}

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

int main(){
	string s;
	cin >> s;
	int n=s.size();
	bool flag=false;
	
	if(s[0]=='0')flag=true;
	if(s[n-1]=='1')flag=true;
	for(int i=1;i<n-1;i++){
		int j=n-2-i;
		if(s[i]!=s[j])flag=true;
	}
	
	if(flag){
		cout << "-1" << endl;
		return 0;
	}
	
	s[n-1]='1';
	int min1=n-1;
	for(int i=n-2;i>=0;i--){
		cout << i+1 << " " << min1+1 << endl;
		if(s[i]=='1')min1=i;
	}
	return 0;
}

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

int main() {
  int n; cin  >> n;
  vector<int> dp(10);
  rep(i,n) {
    int a;
    cin >> a;
    a /= 400;
    if (a >= 8) a = 8;
    dp[a]++;
  }

  int ans = 0;
  for (int i = 0; i <= 7; i++) {
    if (dp[i] > 0) ans++;
  }
  int minans=ans, maxans=ans;
  if (minans == 0 && dp[8] > 0) minans = 1;
  maxans = ans + dp[8];

  cout << minans << " " << maxans << endl;
  return 0;
}

Measured memory_bytes: 3612
a = int(input())
b = list(map(int,list(input())))
cnt = 0
for i in range(10):
	if i in b:
		one = b.index(i)
		if one < a-1:
			bb = b[one+1:]
			for j in range(10):
				if j in bb:
					two = bb.index(j)
					if two < a-1:
						bbb = bb[two+1:]
						for k in range(10):
							if k in bbb:
								three = bbb.index(k)
								cnt += 1
print(cnt)

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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m;
ll a[100005],b[100005],pl[200005],s[200005];
pll p[200005];

int main(){
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint(),b[i]=readint(),p[++m]=mp(a[i],i),p[++m]=mp(b[i],i+n);
	ll num1=0,num2=0;
	for(int i=1;i<=n;i++) num1+=a[i],num2+=b[i];
	ll ans=min(num1,num2);
	sort(p+1,p+m+1);
	for(int i=1;i<=m;i++) pl[p[i].se]=i;
	for(int i=1;i<=m;i++) s[i]=s[i-1]+p[i].fi;
	for(int i=1;i<=n;i++){
		ll tmp=s[n],now=n;
		if(pl[i]>now) tmp+=a[i]-p[now].fi,now--;
		if(pl[i+n]>now){
			if(p[now].se!=i) tmp+=b[i]-p[now].fi;
			else tmp+=b[i]-p[now-1].fi;
		}
		chkmin(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
N =int(input())
AB=[]
for i in range(N):
    AB.append(list(map(int, input().split())))
AB.sort(key=lambda x:x[1])
time=0
flag=0
for ab in AB:
    time+=ab[0]
    if time > ab[1]:
        flag=1
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 88152
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define LL long long
#define M 100005
using namespace std;
LL l[M*2],pla[M*2],a[M];
int main(){
//	freopen("in.in","r",stdin);
//	freopen("1.out","w",stdout);
	int n,m,i,k,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	LL ans=0;
	for(i=2;i<=n;i++){
//		printf("->%lld %d\n",ans,i);
		if(a[i-1]<a[i]){
			if(a[i-1]+1==a[i]){
				ans++;
				continue;
			}
			l[a[i-1]+2]++,l[a[i]+1]--,ans+=a[i]-a[i-1];
		}
		else {
			if(a[i-1]+1==a[i]+m){
				ans+=a[i]+m-a[i-1];
				continue;
			}
			l[a[i-1]+2]++,l[a[i]+m+1]--,ans+=a[i]+m-a[i-1];
		}
	}
	LL x=0;
	for(i=1;i<=m*2;i++){
		x+=l[i];
		l[i]=x;
//		printf("%d %d\n",i,l[i]);
	}
	for(i=2;i<=n;i++){
		if(a[i-1]<a[i]){
			if(a[i-1]+1==a[i])continue;
			l[a[i]+1]-=a[i]-a[i-1]-1;
		}
		else {
			if(a[i-1]+1==a[i]+m)continue;
			l[a[i]+m+1]-=a[i]+m-a[i-1]-1;
		}
	}
	LL p=0;
	for(i=1;i<=2*m;i++){
		p+=l[i];
		pla[i]+=p;
	}
	LL re=0;
	for(i=1;i<=m;i++){
		re=max(re,pla[i]+pla[i+m]);
//		printf("%d %lld\n",i,pla[i]+pla[i+m]);
	}
	printf("%lld\n",ans-re);
	return 0;
}

Measured memory_bytes: 4096
/*
 * Problem Description: Binary Search Tree I
 * Category: Binary Search Trees
 * Author: Khan
 * Date: 21th October, 2017
 */

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

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

Node *root, *NIL;

void Insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while(x != NIL)
    {
        y = x;
        if(z->key < x->key)
            x = x->l;
        else
            x = x->r;
    }

    z->p = y;
    if(y == NIL)
        root = z;
    else
    {
        if(z->key < y->key)
            y->l = z;
        else
            y->r = z;
    }
}

void Inorder(Node *u)
{
    if(u == NIL)
        return;
    Inorder(u->l);
    printf(" %d", u->key);
    Inorder(u->r);
}

void Preorder(Node *u)
{
    if(u == NIL)
        return;
    printf(" %d", u->key);
    Preorder(u->l);
    Preorder(u->r);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int n, i, x;
    string cmd;

    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
    {
        cin >> cmd;
        if(cmd == "insert")
        {
            scanf("%d", &x);
            Insert(x);
        }
        else if(cmd == "print")
        {
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 26700
#include <bits/stdc++.h>
#define int long long
using namespace std;
int INF = 1e18;
signed main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int v[m][3];
    vector<set<int> > ms(n);
    for (int i=0; i < m; i++){
        for (int j=0; j < 3; j++) cin >> v[i][j];
        for (int j=0; j < 2; j++) v[i][j]--;
        ms[v[i][0]].insert(i);
        ms[v[i][1]].insert(i);
    }
    vector<int> ans(n);
    fill(ans.begin(), ans.end(), INF);
    for (int i=0; i < n; i++){
        if (ans[i] != INF) continue;
        queue<int> k;
        k.push(i);
        ans[i] = 0;
        while (!k.empty()){
            int V = k.front();
            //cout << V << endl;
            k.pop();
            for (set<int>::iterator it=ms[V].begin(); it != ms[V].end(); it++){
                int S = *it;
                if (v[S][0] == V){
                    int Q = v[S][1];
                    if (ans[Q] != INF) continue;
                    ans[Q] = ans[V] + v[S][2];
                    k.push(Q);
                }
                else{
                    int Q = v[S][0];
                    if (ans[Q] != INF) continue;
                    ans[Q] = ans[V] - v[S][2];
                    k.push(Q);
                }
            }
        }
    }
    //for (int i=0; i < n; i++) cout << ans[i] << endl;
    for (int i=0; i < m; i++){
        int A = v[i][0];
        int B = v[i][1];
        int C = v[i][2];
        if (ans[B] - ans[A] != C){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}








Measured memory_bytes: 29952
//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() {
	VI v(3);
	REP(i, 3) {
		cin >> v[i];
	}

	SORT(v);

	int ans =  -v[0] + v[2] ;

	ANS(ans);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
			using namespace std;
			#define rep(i,a,n) for (int i=a;i<n;i++)
			#define per(i,a,n) for (int i=n-1;i>=a;i--)
			#define pb push_back
			#define mp make_pair
			#define all(x) (x).begin(),(x).end()
			#define fi first
			#define se second
			#define SZ(x) ((int)(x).size())
			typedef vector<int> VI;
			typedef long long ll;
			typedef pair<int,int> PII;
			typedef double db;
			mt19937 mrand(random_device{}()); 
			const ll mod=1000000007;
			int rnd(int x) { return mrand() % x;}
			ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
			ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
			int main() {
				 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
				 unsigned long long n,k;
				 cin>>n>>k;
				if(n==k || k==1)
				cout<<"0"<<"\n";
				else if(n>k)
				cout<<min((n%k),k-(n%k))<<"\n";
				else
				{
					cout<<min(n%k,(k-n))<<"\n";
				}
			}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
              
string s;     
              
void solve(){                                                                   
  cin >> s;   
  int l = s.size()/2;
  while(1){   
    l--;      
    int flag = true;
    for(int i = 0; i < l; i++){
      if(s[i] != s[i+l]){
        flag = false;
        break;
      }       
    }         
    if(flag){ 
      cout << l*2 << endl;
      break;  
    }         
  }           
}             
              
int main(){   
  solve();    
  return 0;   
}       

Measured memory_bytes: 256