akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


typedef vector<int> V;
typedef vector<V> MATRIX;

int N;

MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(N,V(N));

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)ret[i][k] = 0;
	}

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			for(int a = 0; a < N; a++){
				ret[row][col] += left[row][a]*right[a][col];
				ret[row][col] %= 2;
			}
		}
	}
	return ret;
}

//MULTのT乗を計算する
MATRIX pow(MATRIX MULT,int count){

	MATRIX ret(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}

//掃き出し法により、[A|result]→[E|u]に変形する
void gauss_jordan(MATRIX A,MATRIX result){

	MATRIX C(N,V(N+1));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++)C[row][col] = A[row][col];
		C[row][N] = result[row][0];
	}

	int base_row;
	for(int i = 0; i < N; i++){
		base_row = i;
		for(int row = i+1; row < N; row++){
			if(abs(C[row][i]) > abs(C[base_row][i])){
				base_row = row;
			}
		}

		if(abs(C[base_row][i]) == 0)continue; //操作不要

		if(base_row != i)swap(C[base_row],C[i]);

		for(int row = 0; row < N; row++){
			if(row == i || C[row][i] == 0)continue; //基準行、または該当列が0ならSKIP

			for(int col = i; col < N+1; col++){
				C[row][col] -= C[i][col];
				C[row][col] += 2;
				C[row][col] %= 2;
			}
		}
	}

	//係数が全て0かつresultが1である行があればnone
	bool FLG;
	for(int row = 0; row < N; row++){
		FLG = false;
		for(int col = 0; col < N; col++){
			if(C[row][col] == 1){
				FLG = true;
				break;
			}
		}
		if(FLG == false && C[row][N] == 1){
			printf("none\n");
			return;
		}
	}
	//rankがNでなければambiguouse
	for(int row = 0; row < N; row++){
		FLG = false;
		for(int col = 0; col < N; col++){
			if(C[row][col] == 1){
				FLG = true;
				break;
			}
		}
		if(!FLG){
			printf("ambiguous\n");
			return;
		}
	}

	printf("%d",C[0][N]);
	for(int row = 1; row < N; row++){
		printf(" %d",C[row][N]);
	}
	printf("\n");
}

int main(){

	scanf("%d",&N);

	MATRIX MULT(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++)scanf("%d",&MULT[row][col]);
	}

	MATRIX result(N,V(1));
	for(int row = 0; row < N; row++){
		scanf("%d",&result[row][0]);
	}

	int T;
	scanf("%d",&T);

	MULT = pow(MULT,T);

	gauss_jordan(MULT,result);

	return 0;
}



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

int main() {
  int sum = 0;
  int N;
  cin >> N;
  rep(i,N){
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[10000];
int n;
signed main(){
	while(1){
		scanf("%lld", &n);
		if(n == 0)break;
		rep(i,n)scanf("%lld", &a[i]);
		int cnt = 0, sum = 0, ans = 0;
		rep(i,n)if(a[i] >= 2)cnt++;
		rep(i,n)sum += a[i];
		if(cnt == 0){printf("NA\n");continue;}
		if(cnt == 1){printf("%lld\n", sum-(*max_element(a, a+n)-2));continue;}
		if(cnt > 1){
			rep(i,n)if(a[i] < 2)ans += a[i];
			rep(i,n)if(a[i] > 1)ans++;
			printf("%lld\n", ans+1);
		}
	}
	return 0;
}








Measured memory_bytes: 3296
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
using ll = long long;

int main() {
    int n; cin >> n;
    ll ans = 1;
    for (int i = 2; i <= n; i++) {
        bool flg = true;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) flg = false;
        }
        if (flg) {
            int ord = 0;
            int v = n;
            while (v) {
                ord += v / i;
                v /= i;
            }
            ans = ans * (ord + 1) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
dp = [[0 for j in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
    w, v = items[i-1]
    for j in range(W+1):
        if j - w >= 0:
            dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
print(max(dp[N]))


Measured memory_bytes: 171656
N = input()

l = len(N)

_sum = 0
if l % 2 == 0:
    for i in range(l):
        _sum += 9*10**(i) if i % 2 == 0 else 0
else:
    for i in range(l-1):
        _sum += 9*10**(i) if i % 2 == 0 else 0
    _sum += int(N) - 10**(l-1) + 1

print(int(_sum))


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

int main() {
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



def pop(stack):
	return stack[0],stack[1:]

def push(stack,x):
	stack.append(x)
	s = set(stack)
	p = list(s)
	p.sort()
	return p

n = int(input())
#a = sympy.factorint(n)
a = factorization(n)
ans = 0
if n != 1:
	for i in a:
		t = 1
		k = 1
		while t <= i[1]:
			#print(t,k,i[1])
			ans += 1
			k += 1
			t += k
			#print(t,k,i[1])
	
print(ans)		
		
		



Measured memory_bytes: 63536
n,m = map(int,input().split())
if n % 2 == 1:
    for i in range(1,m+1):
        print(i,n-i)
    exit()
ans = []
if n % 4 == 0:
    for i in range(1,n//4+1):
        ans.append((i,n//2-i+1))
    for i in range(m-len(ans)):
        ans.append((n//2+2+i,n-i))
else:
    for i in range(2,n//4+2):
        ans.append((i,n//2-i+2))
    for i in range(m-len(ans)):
        ans.append((n//2+i+1,n-i))
for i in range(m):
    print(ans[i][0],ans[i][1])

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

struct Point{double x, y; };

void koch(int n, Point a, Point b){
    if(n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;
    
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main(){
    Point a, b;
    int n;
    
    scanf("%d", &n);
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    
    return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 
 
int main()
{
    fastio();
    int n,count=0; cin>>n; int arr[n]; for(int i=0;i<n;i++) {cin>>arr[i]; count+=arr[i];}
    int mid=count/n; lli zeke=0,zeke1=0,zeke2=0;
    for(int i=0;i<n;i++) zeke+=1LL*(arr[i]-mid)*(arr[i]-mid);
    for(int i=0;i<n;i++)zeke1+=1LL*(arr[i]-mid-1)*(arr[i]-mid-1);
    for(int i=0;i<n;i++)zeke2+=1LL*(arr[i]-mid+1)*(arr[i]-mid+1);
    cout<<min(min(zeke1,zeke2),zeke)<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
import itertools
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
l = list(itertools.combinations_with_replacement(range(k+1)[1:], 3))
s = 0
n = 0

for i in l:
    x = len(set(i))
    if x == 3:
        n = 6
    elif x == 2:
        n = 3
    elif x == 1:
        n = 1

    s += gcd_list(list(i)) * n


print(s)

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

using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
string s;
cin>>s;
ll j=s.length();
ll cnt=0,steps=0;
for(ll i=0;i<j-2;)
{
    if(s[i]=='A')
    {cnt++;
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
    {
        steps+=cnt;
        s[i+2]='A';
        i=i+2;
        cnt--;
    }
    else i++;
    }
    else
    {
        cnt=0;
        i++;
    }
}
cout<<endl<<steps;
	return 0;
	
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i64 x;
    cin >> x;
    cout << x / 500 * 1000 + x % 500 / 5 * 5 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  int x,y;
  cin>>x>>y;
  for(int i=0;i<=x;i++)
  {
   if((x-i)*2+i*4==y)
   {
      cout<<"Yes";
      return;
   }
  }
  cout<<"No";
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#define NIL -2000000001 
using namespace std;

long long middlePrintT[500005];
long long firstPrintT[500005];
int mcount = 0;
int fcount = 0;

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

Node *nil, *root;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->key = NIL;
    nil->l = nil;
    nil->r = nil;
    root = nil;
}

void insert(long long k) {
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = nil;
    z->r = nil;
    Node *y = nil;  // xの親
    Node *x = root;

    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; // zをyの左の子にする
    else y->r = z;  // zをyの右の子にする
}

void middlePrint(Node *u) {
    if (u == nil) return;
    middlePrint(u->l);
    middlePrintT[mcount++] = u->key;
    middlePrint(u->r);
}

void firstPrint(Node *u) {
    if (u == nil) return;
    firstPrintT[fcount++] = u->key;
    firstPrint(u->l);
    firstPrint(u->r);
}

int main() {
    init();
    int m;
    long long key;
    string command;
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> command;
        if (command[0] == 'i') {
            cin >> key;
            insert(key);
        }
        else if (command[0] == 'p') {
            mcount = fcount = 0;
            middlePrint(root);
            firstPrint(root);
            for (int j = 0; j < mcount; j++) cout << " " << middlePrintT[j];
            cout << "\n";
            for (int j = 0; j < fcount; j++) cout << " " << firstPrintT[j];
            cout << "\n";
        }
    }

    return 0;
}


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

vector<pair<ll, ll>> pf(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i != 0) continue;
        ll e = 0;
        while (n % i == 0) {
            e++;
            n /= i;
        }
        res.emplace_back(i, e);
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n-2; ++i) {
        vector<pair<ll, ll>> A = pf(n - i);
        // printf("pf(%lld-%d) = ", n, i);
        ll s = 1;
        for (auto a : A) {
            // printf("%lld^%lld ", a.first, a.second);
            s *= a.second + 1;
        }
        // cout << endl;
        ans += s;
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,k;
	cin>>a>>b>>k;
	ll l=k;
	k=k-a;
	if(k>=0){
		a=0;
		b=max(ll(0),b-k);
	}
	else{
		a=a-l;
		
	}
	cout << a << " "<<b;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <unordered_set>
const int MAXN = 1005;
int A[MAXN][MAXN];
int dex[MAXN];
int P[MAXN];
int N;
std::unordered_set<int> cur, nxt;

void init() {
  cur.clear();
  nxt.clear();
  for (int i = 1; i <= N; ++i) {
    dex[i] = 1;
  }
}

void push_next(int k) {
  if (dex[k] >= N) return;
  P[k] = A[k][dex[k]];
  if ((k == P[P[k]]) &&
      !nxt.count(k) &&
      !nxt.count(P[k])) {
    nxt.insert(k);
  }
}

int solve() {
  for (int i = 1; i <= N; ++i) push_next(i);
  cur = std::move(nxt);

  int ret = 0;
  while (!cur.empty()) {
    for (auto a: cur) {
      int b = P[a];
      ++dex[a];
      ++dex[b];
      push_next(a);
      push_next(b);
    }
    cur = std::move(nxt);
    ++ret;
  }
  for (int i = 1; i <= N; ++i) {
    if (dex[i] != N) {
      return -1;
    }
  }
  return ret;
}

int main() {
  scanf("%d", &N);
  init();
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j < N; ++j) {
      scanf("%d", &A[i][j]);
    }
  }
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    
    rep(i,s.size()){
        if(s[i]=='1'){
            k--;
        }else{
            cout<<s[i]<<endl;
            return 0;
        }
        if(k==0){
            cout<<s[i]<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && b < c ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
using namespace std;
 
int n, k; 
int d[10];
 
bool ok(int x) {
while (x > 0) {
for (int i = 0; i < k; i++) if (d[i] == x%10) return false;
x/=10;
}
return true;
}
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> d[i];
 
int x = n;
while (!ok(x++));
x--;
cout << x << "\n";
return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int ans = 0;
  rep(i,n){
    if(i == 0) ans++;
    else if(s[i] != s[i-1]) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
import math
a, b, x = map(int, input().split())
remain = a * a * b - x
ans = 0
if remain <= x:
    c = remain / a / a * 2
    ans = math.degrees(math.atan2(c, a))
else:
    c = x / a / b * 2
    ans = math.degrees(math.atan2(b, c))
print(ans)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n+1),b(n);
  for(int i=0;i<n+1;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  long long sum=0;
  for(int i=0;i<n+1;i++)sum+=a[i];
  for(int i=0;i<n;i++){
    int left=min(a[i],b[i]);
    a[i]-=left;
    b[i]-=left;
    a[i+1]-=b[i];
    if(a[i+1]<0)a[i+1]=0;
}
  long long sum1=0;
  for(int i=0;i<n+1;i++)sum1+=a[i];
  cout<<sum-sum1<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ASSERT(C, ...) assert( (C) || (PRINT(__VA_ARGS__), false) )
template <class Head> void PRINT(Head head) {
    std::cout << head << "\n";
}
template <class Head, class... Tail> void PRINT(Head head, Tail... tail) {
    std::cout << head << " ";
    PRINT(tail...);
}

vector<ll> solve(ll N, ll Q, vector<ll>& A, vector<ll>& X) {
    vector<ll> sl(N+1), ss2(N+2);
    for ( int i = 0; i < N; i++ ) {
        sl[i+1] = sl[i] + A[i];
    }
    for ( int i = N-1; i >= 0; i-- ) {
        if ( i % 2 ==  0 ) ss2[i] = ss2[i+2] + A[i];
    }

    // k個の連続した領域を取れるか
    auto check = [&](ll x, ll k) {
        if ( k == 0 ) return true;
        if ( 2*k-2 >= N ) return false;
        else {
            return abs(A[k-1] - x) >= abs(A[2*k-2] - x);
        }
    };

    vector<ll> ans;
    for ( int q = 0; q < Q; q++ ) {
        ll x = X[q];
        ll l = 0, r = (N+1)/2+1;
        while ( r - l > 1 ) {
            ll m = (l+r)/2;
            if ( check(x, m+1) ) l = m;
            else r = m;
        }
        ll a = sl[l+1];
        if ( 2*(l+1) < N ) a += ss2[2*(l+1)];
        ans.push_back(a);
    }
    return ans;
}

vector<ll> solve_naive(ll N, ll Q, vector<ll>& A, vector<ll>& X) {
    vector<ll> ans;
    using pii = pair<ll,int>;
    for ( int q = 0; q < Q; q++ ) {
        ll x = X[q];
        vector<bool> used(N);
        priority_queue<pii> q1, q2;
        for ( int i = 0; i < N; i++ ) {
            q1.push(pii(A[i], i));
            q2.push(pii(-abs(A[i]-x), i));
        }
        ll a = 0;
        for ( int i = 0; i < N; i++ ) {
            if ( i % 2 == 0 ) {
                while ( used[q1.top().second] ) q1.pop();
                auto p = q1.top();
                q1.pop();
                used[p.second] = true;
                a += p.first;
            } else {
                while ( used[q2.top().second] ) q2.pop();
                auto p = q2.top();
                q2.pop();
                used[p.second] = true;
            }
        }
        ans.push_back(a);
    }
    return ans;
}

void test() {
    mt19937_64 mt64(0);
    uniform_int_distribution<ll> rnd(1, 10000);

    for ( int t = 0; t < 200; t++ ) {
        ll N = t > 100 ? 2 + rnd(mt64) % 4 : 100 + rnd(mt64) % 10;
        ll Q = N;
        vector<ll> A, X;
        set<ll> as;
        while ( as.size() < N ) {
            as.insert(1+rnd(mt64));
        }
        for ( auto aa : as  ) {
            A.push_back(aa);
        }
        for ( int i = 0; i < Q; i++ ) {
            X.push_back(1+rnd(mt64));
        }
        sort(A.rbegin(), A.rend());

        auto v1 = solve(N, Q, A, X);
        auto v2 = solve_naive(N, Q, A ,X);
        for ( int i = 0; i < Q; i++ ) {
            ASSERT(v1[i] == v2[i], t, i, v1[i], v2[i]);
        }
    }
}

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N), X(Q);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    for ( int i = 0; i < Q; i++ ) cin >> X[i];
    sort(A.rbegin(), A.rend());

    auto ans = solve(N, Q, A, X);
    for ( int i = 0; i < Q; i++ ) {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4472
import copy
n = int(input())

ans = 0
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if i == k or j == k:
                    continue
                elif d[i][j] > d[i][k] + d[k][j]:
                    return -1
                elif d[i][j] == d[i][k] + d[k][j]:
                    blist[i][j] = 0
    return sum([sum(l) for l in blist])//2

alist = []
blist = []
for i in range(n):
    a = list(map(int,input().split()))
    alist.append(copy.copy(a))
    blist.append(copy.copy(a))


ans = warshall_floyd(alist)
print(ans)

Measured memory_bytes: 43740
import sys 
import numpy as np
from numba import jit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@jit(cache=True)
def solve(A):
  count = np.zeros(10**6+10)
  for x in A:
    if count[x] > 1:
      continue
    count[::x] += 1
  ans = 0
  for x in A:
    ans += count[x] == 1
  return ans

N = int(readline())
A = list(map(int,readline().split()))
A = np.array(A)
print(solve(A))



Measured memory_bytes: 133484
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
  
   while (b<=a && k>0)
    {
        b *= 2;
        k--;
    }
    while (c <= b && k > 0)
    {
        c *= 2;
        k--;
    }
    
     if (a < b  && b< c && k >= 0)
        cout << "Yes"<<endl;
    else
        cout << "No"<<endl;
    return 0;
}

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


int main (){
    int N, X;
    cin>>N>>X;
    vector<int> Vec(N);
    for (int i=0; i<N; i++){
        cin>>Vec.at(i);
    }
    int count =1;
    while(count<N+1){
        X -= Vec.at(count-1);
        if(X>-1){
          count ++;
        }
      	else{
			break;
     	}
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, Y;

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

	int ans[3] = { -1,-1,-1 };

	cin >> N >> Y;
	rep(i, 0, N + 1)
	{
		if (i * 10000 > Y)break;

		rep(j, 0, N + 1)
		{
			if (i + j > N || i * 10000 + j * 5000 > Y)break;
			if (i * 10000 + j * 5000 + (N - (i + j)) * 1000 == Y)
			{
				ans[0] = i;
				ans[1] = j;
				ans[2] = N - (i + j);
				break;
			}
		}

		if (ans[0]!=-1)break;
	}

	printf("%d %d %d\n", ans[0], ans[1], ans[2]);

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

class DisjointSet:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1] * n
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def has_same_root(self, x, y):
        return self.root(x) == self.root(y)

    def get_size(self, x):
        return self.size[self.root(x)]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n, m, k = [int(item) for item in input().split()]
edge = [[] for _ in range(n)]
friends = [set() for _ in range(n)]
DS = DisjointSet(n)
for _ in range(m):
    a, b = [int(item) for item in input().split()]
    a -= 1; b -= 1
    edge[a].append(b)
    edge[b].append(a)
    friends[a].add(b)
    friends[b].add(a)
    if not DS.has_same_root(a, b):
        DS.unite(a, b)

h_cnt = [0] * n
hostiles = [set() for _ in range(n)]
for _ in range(k):
    c, d = [int(item) for item in input().split()]
    c -= 1; d -= 1 
    hostiles[c].add(d)
    hostiles[d].add(c)

visited = [0] * n
def dfs(par, p, v):
    queue = deque()
    queue.append((p, v))
    visited[v] = True
    while queue:
        p, v = queue.popleft()
        for h in hostiles[v]:
            if h not in friends[v] and DS.has_same_root(h, v):
                h_cnt[v] += 1
        for nv in edge[v]:
            if visited[nv]:
                continue
            if nv == p:
                continue
            queue.append((v, nv))
            visited[nv] = True

for i in range(n):
    if visited[i]:
        continue
    visited[i] = True
    dfs(i, -1, i)

ans = []
for i in range(n):
    ans.append(DS.get_size(i) - 1 - h_cnt[i] - len(edge[i]))
    
print(*ans)

Measured memory_bytes: 127944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<ll,ll> dp;
ll f(ll x)
{
    if(dp[x]!=0)
        return dp[x];
    else
    return dp[x]=((f(x/2)+f((x-1)/2)+f((x-2)/2)))%mod;
}
int main()
{
    dp[0]=1;
    dp[1]=2; 
    ll n;
    cin>>n;
    ll ans=f(n);
    cout<<ans;
    return 0;
}

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

int compare(int n,int k,int x){
  if(n<pow(k,x)){
    return x;
  }else{
    return compare(n,k,x+1);
  }
}

int main(){
  int n,k;
  cin >> n >> k;
  cout << compare(n,k,1) << endl;
  return 0;
}

Measured memory_bytes: 384
using System;
 
namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1001;
        static void Main()
        {
            string input;
            int[] com = new int[Max];
            while((input = Console.ReadLine()).Length != 0) {
                --com[int.Parse(input.Split(',')[0])];
            }
            while((input = Console.ReadLine()) != null) {
                int i = int.Parse(input.Split(',')[0]);
                if(com[i] != 0) {
                    if(com[i] > 0) {
                        ++com[i];
                    }
                    else {
                        com[i] = ~com[i] + 2;
                    }
                }
            }
            for(int i=1; i < Max; ++i) {
                if(com[i] > 0) {
                    Console.WriteLine("{0} {1}", i, com[i]);
                }
            }
        }
    }
}

Measured memory_bytes: 19952
n, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]

t = 0
l = []
c = 0
d = {}
while True:
    d[t+1] = c
    c += 1
    l.append(t+1)
    t = a[t] - 1
    # if t == 0:
    #     break
    if t + 1 in d:
        s = l[d[t+1]:]
        q = d[t+1]
        break
# print(l)
# print(s)
# print(d)
# print(q)

if k <= q:
    print(l[k])
else:
    print(s[(k-q) % len(s)])


Measured memory_bytes: 131568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
#define PI 3.14159265359

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    int r;
    cin>>r;
    float ans=r*2*PI;
    
    cout<<ans<<endl;


}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrep1(i,n) for(ll i=n;i>=1;i--)
#define FOR(i,a,b) for(ll i=a;i<b;i++)

int main(){
	ll N,x; cin>>N>>x;
	vector<ll> ans(2*N);
	if(x==1 || x==2*N-1) cout<<"No";
	else{
		if(N==2){
			cout<<"Yes"<<endl;
			cout<<1<<endl<<2<<endl<<3;
		}
		else if(x!=2){
			ll tmp=1;
			rep1(i,2*N-1){
				if(i==N-1) ans[i]=x-1;
				else if(i==N) ans[i]=x;
				else if(i==N+1) ans[i]=x+1;
				else if(i==N+2) ans[i]=x-2;
				else{
					ans[i]=tmp++;
					if(ans[i]>=x-2) ans[i]+=4;
				}
			}
			cout<<"Yes"<<endl;
			rep1(i,2*N-1) cout<<ans[i]<<endl;
		}
		else{
			ll tmp=1;
			rep1(i,2*N-1){
				if(i==N-1) ans[i]=x+2;
				else if(i==N) ans[i]=x;
				else if(i==N+1) ans[i]=x-1;
				else if(i==N+2) ans[i]=x+1;
				else{
					ans[i]=tmp++;
					if(ans[i]>=x-1) ans[i]+=4;
				}
			}
			cout<<"Yes"<<endl;
			rep1(i,2*N-1) cout<<ans[i]<<endl;
		}
	}
}

Measured memory_bytes: 3072
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
import numpy as np

nmod = 1000000007

(N,) = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
tsum = 0
for i in range(N - 1, 0, -1):
    tsum += A[i]
    tsum %= nmod
    tmp = (A[i - 1] * tsum) % nmod
    ans += tmp
    ans %= nmod

print(int(ans))


Measured memory_bytes: 49652
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::cmp;

fn main() {
    input! {
        n: i32, x: i32,
        m: [i32; n],
    }
    let mut mindo = i32::max_value();
    let mut sum = 0;
    for i in m {
        mindo = cmp::min(mindo, i);
        sum += i;
    }

    let num = (x - sum) / mindo;
    let ans = n + num;
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
//typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int P = 200003;
Int order[200004];
Int cnt[200004];
Int cntr[200004];
Int sum, sqsum;
Int n, a;

CP primitive_root(Int n){
    double theta = 2 * PI/ n;
    return CP(cos(theta), sin(theta));
}

vector<CP> INV_FFT(vector<CP>&);
vector<CP> FFT2POW(vector<CP> &x, CP w){
    int n = x.size();
    int msb = n / 2;
    int other = 0;
    auto res = x;
    for(int i = 1;i < n;i++){
        for(int j = msb;j > 0;j /= 2){
            other ^= j;
            if(other & j)break;
        }
        if(other < i)swap(res[i], res[other]);
    }

    for(int width = 2;width <= n;width *= 2){
        CP w = primitive_root(width);
        for(int i = 0;i < n;i += width){
            CP ww = 1;
            for(int j = 0;j < width / 2;j++){
                int ind = i + j;
                auto a = res[ind];
                auto b = res[ind + width / 2] * ww;
                ww *= w;
                res[ind] = a + b;
                res[ind + width / 2] = a - b;
            }
        }
    }    
    return res;
}

vector<CP> FFT(vector<CP> &a){
    Int n = a.size();
    if((n & -n) == n)return FFT2POW(a, primitive_root(n));
    
    Int m = 1;
    while(m < 2*n)m <<= 1;
    
    CP w = primitive_root(2 * n);
    vector<CP> ws(2*n+1,1);
    for(Int i = 1;i <= 2*n;i++)ws[i] = ws[i-1] * w;

    vector<CP> winv(m, 0);
    vector<CP> aw(m, 0);
    for(Int i = 0;i < n;i++){
        Int p = -(i*i) % (2*n) + 2*n;
        winv[n-i] = winv[n+i] = ws[p];
        aw[i] = a[i] * ws[i*i%(2*n)];
    }
    auto AW = FFT(aw);
    auto WINV = FFT(winv);
    for(int i = 0;i < m;i++)WINV[i] *= AW[i];
    vector<CP> c = INV_FFT(WINV);
    vector<CP> A(n);
    for(Int i = 0;i < n;i++){
        A[i] = ws[i*i%(2*n)] * c[n+i]; 
    }
    return A;    
}

vector<CP> INV_FFT(vector<CP>& x){
    reverse(x.begin() + 1, x.end());
    auto res = FFT(x);
    for(auto &elem:res)elem /= res.size();
    return res;
}



int main(){
    Int now = 1;
    bool ok = true;
    Int extra = 0;
    for(Int i = 0;i < P-1;i++){
        order[now] = i;
        now = now * 2 % P;
    }
    vector<CP> cnt(1 << 19, 0);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a;
        extra += a * a % P;
        if(a == 0)continue;
        cnt[order[a]] += 1;
    }
    auto CNT = FFT(cnt);
    for(auto &elem:CNT)elem *= elem;
    auto result = INV_FFT(CNT);
    Int ans = 0;
    now = 1;
    for(Int i = 0;i < (1 << 19);i++){
        Int r = Int(result[i].real() + 0.5);
        ans += now * r;
        now = now * 2 % P;
    }
    ans -= extra;    
    cout << ans / 2<< endl;
    return 0;
}

Measured memory_bytes: 53960
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string Si = Console.ReadLine();
            for (int cnt = 1; cnt <= 4; cnt++)
            {
                char[] SW = new char[N+2];
                switch (cnt)
                {
                    case 1:
                        SW[0] = 'S';
                        SW[1] = 'S';
                        break;
                    case 2:
                        SW[0] = 'W';
                        SW[1] = 'S';
                        break;
                    case 3:
                        SW[0] = 'S';
                        SW[1] = 'W';
                        break;
                    case 4:
                        SW[0] = 'W';
                        SW[1] = 'W';
                        break;
                }
                for (int i = 0; i < N; i++)
                {
                    SW[i+2] = Ans(Si.Substring(i, 1), SW[i],SW[i+1]);
                }
                if (SW[0] == SW[N] & SW[1] == SW[N+1])
                {
                    string output = new String(SW);
                    Console.WriteLine(output.Substring(1,N));
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("-1");
            Console.ReadKey();
        }

        static char Ans(string Si, char type1,char type2)
        {
            if (Si == "o" & type1 == 'S' & type2 =='S') { return 'S'; }
            else if (Si == "o" & type1 == 'W' & type2 == 'S') { return 'W'; }
            else if (Si == "o" & type1 == 'W' & type2 == 'W') { return 'S'; }
            else if (Si == "o" & type1 == 'S' & type2 == 'W') { return 'W'; }
            else if (Si == "x" & type1 == 'S' & type2 == 'S') { return 'W'; }
            else if (Si == "x" & type1 == 'W' & type2 == 'S') { return 'S'; }
            else if (Si == "x" & type1 == 'W' & type2 == 'W') { return 'W'; }
            else { return 'S'; }
        }

    }
}

Measured memory_bytes: 16856
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<list>
#include<map>
#include<unordered_map>
#include<unordered_set>
using namespace std;

unordered_map<int, int>U;
signed main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		int c; scanf("%d", &c);
		U[c]++;
	}
	int s = 0;
	for (auto k = U.begin(); k != U.end(); k++) {
		if ((k->second&1) != 1)s++;
	}
	if ((s&1) == 1)cout << U.size() - 1 << endl;
	else cout<<U.size()<<endl;
}

Measured memory_bytes: 4388
function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var H = arg.split("\n")[1].split(" ");

    var ans = new Array();
    var a = 0;
    for (var i = 0; i < N; i++){
        a = 0;
        for (var j = i; j < N-1; j++){
            var s = H[j] - 0;
            var t = H[j+1] - 0;
            if (s < t) break;
            a++;
        }
        ans.push(a);
        i += a;
    }

    console.log(Math.max.apply(null, ans));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

class DSwapAndFlip {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n), b(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n) {
        cin >> b[i];
      }

      int ans = INT_MAX;

      int s = 1<<n;
      rep(i, s) {
        vector<P> vec1;
        vector<P> vec2;
        vector<P> vec;

        rep(k, n) {
          if (i&(1<<k)) {
            if (k%2==0) {
              vec1.emplace_back(a[k], k);
            } else {
              vec2.emplace_back(a[k], k);
            }
          } else {
            if (k%2==0) {
              vec2.emplace_back(b[k], k);
            } else {
              vec1.emplace_back(b[k], k);
            }
          }
        }

        if (vec1.size() != (n+1)/2) {
          continue;
        }

        sort(all(vec1));
        sort(all(vec2));

        rep(j, n/2) {
          vec.push_back(vec1[j]);
          vec.push_back(vec2[j]);
        }
        if (n%2==1) {
          vec.push_back(vec1.back());
        }

        bool flag = true;
        rep(j, n-1) {
          if (vec[j].first > vec[j+1].first) {
            flag = false;
          }
        }
        if (!flag) continue;

        int now = 0;
        rep(j, n) {
          for (int k = j + 1; k < n; k++) {
            if (vec[j].second > vec[k].second) {
              now++;
            }
          }
        }

        /*
        debug(now);
        rep(j, n) {
          debug(vec[j].first, vec[j].second);
        }*/

        chmin(ans, now);
      }

      if (ans == INT_MAX) {
        cout << -1 << endl;
      } else {
        cout << ans << endl;
      }

    }
};


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

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

#define int long long
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
 
using namespace std;

typedef long long ll; 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
 
const  int mxN = 1e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;
 	
signed main(){
	double r;
	cin >> r;
	r = r * 2;
	r = r * 3.14159265359;
	cout << r;
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	



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

typedef long long int lli;

int main(void){
    // Here your code !
    lli N;
    cin >> N;
    
    vector<lli> a(N);
    vector<lli> b(N);
    
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    
    
    lli res = 0;
    for(int i = N-1; i >= 0; i--){
        lli tmp = ((b[i]+a[i]-1+res)/b[i])*b[i];
        res = tmp - a[i];
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ff first
#define ss second
const ll mod = 1e9 + 7 ;
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
///////////////////////////////////////////////////////////
const int nmax = 1e4 + 5 ;
const ll inf = 1e15 ;
vector < ll > seg(nmax*4,inf);
void update(int node , int l , int r , int pos , int val){
    if(l==r){
        seg[node] = val ;
        return ;
    }
    int mid = (l+r)/2;
    if(pos<=mid){
        update(node*2,l,mid,pos,val);
    }
    else{
        update(node*2+1,mid+1,r,pos,val);
    }
    seg[node] = min(seg[node*2],seg[node*2+1]);
}
ll query( int node , int l , int r , int start , int end){
    if(start > r || end < l || l>r){
        return inf ;
    }
    if( start <= l && end >= r){
            return seg[node] ;
    }
    int mid = (l+r)/2;
    return min(query(node*2,l,mid,start,end),query(node*2+1,mid+1,r,start,end));
}
//////////////////////////////////////////////////////////
void solve( ){
    ll h , n ;
    cin >> h >> n ;
    vector < pair < ll , ll > > a(n) ;
    for( int i = 0 ; i< n ; i++) cin >> a[i].ff >> a[i].ss ;
    vector < ll > dp(h+1,inf);
    dp[0] = 0 ;
    update(1,0,h,0,0);
    for( int i = 0 ; i < n ; i++){
        for( int j = 1 ; j <= h ; j++){
                if(j>a[i].ff){
                    //ll minm = query(1,0,h,j-a[i].ff,j-1);
                    dp[j] = min(dp[j],dp[j-a[i].ff]+a[i].ss);
                    //update(1,0,h,j,dp[j]);
                }
                else{
                    dp[j] = min(dp[j],a[i].ss);
                    //update(1,0,h,j,dp[j]);
                }
        }
//        for( int j = 0 ; j <= h ; j++) cout << dp[j] << " ";
//        cout << "\n";
    }
    cout << dp[h] ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test_case=1 ;
    //cin >> test_case ;
    for( int i = 1 ; i <= test_case ; i++){
        solve( );
    }
}


Measured memory_bytes: 640
n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:
        cnt[b - 1] = 1
    elif h[a - 1] < h[b - 1]:
        cnt[a - 1] = 1
    else:
        cnt[b - 1] = 1
        cnt[a - 1] = 1
print(cnt.count(0))


Measured memory_bytes: 20116
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main() {
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
}


Measured memory_bytes: 3172
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let c: Vec<Vec<i64>> = {
        let mut c = vec![];
        for _ in 0..3 {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            c.push(
                line.split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect()
            );
        }
        c
    };

    let s = (0..3).map(|i| c[i][i]).sum::<i64>();
    let ans = if (0..3).all(|i| (0..3).all(|j| i == j || c[0][i] + c[1][j] + c[2][3 - i - j] == s)) { "Yes" } else { "No" };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2);
    rep(i,a) cin >> s[i+1];
    rep(i,b) cin >> t[i+1];
    s[0] = t[0] = -INF;
    s[a+1] = t[b+1] = INF;
    rep(i,q){
        ll x;
        cin >> x;
        auto Sleft = lower_bound(s.begin(), s.end(), x);
        auto Sright = lower_bound(s.begin(), s.end(), x);
        auto Tleft = lower_bound(t.begin(), t.end(), x);
        auto Tright = lower_bound(t.begin(), t.end(), x);
        Sleft--;
        Tleft--;
        ll ans = abs(x - min(*Sleft, *Tleft));
        chmin(ans, abs(max(*Sright, *Tright) - x));
        chmin(ans, abs((x - *Sleft)*2 + *Tright - x));
        chmin(ans, abs((x - *Tleft)*2 + *Sright - x));
        chmin(ans, abs((*Sright - x)*2 + x - *Tleft));
        chmin(ans, abs((*Tright - x)*2 + x - *Sleft ));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
S = input()
N = len(S)
nx = S.replace('x', '')
N2 = len(nx)
for i in range(N2):
  if nx[i] != nx[N2-i-1]:
    print(-1)
    exit()

if N == N2:
  # x not inclueded
  print(0)
else:
  cnt = 0
  i = 0
  j = N-1
  while i < j:
    if S[i] == 'x':
      if S[j] == 'x':
        i += 1
        j -= 1
      else:
        i += 1
        cnt += 1
    else:
      if S[i] == S[j]:
        i += 1
        j -= 1
      elif S[j] == 'x':
        cnt += 1
        j -= 1
  print(cnt)
      
        
        
  

Measured memory_bytes: 9244
#include <cstdio>
int n,m;
int main() {
    scanf ("%d %d",&n,&m);
    if (n <= 0 && m >= 0) printf("Zero");
    if (n > 0) printf("Positive");
    if (m < 0){
    	if ((n - m) % 2 == 0) printf("Negative");
    	else printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
a_score = 0
for i in range(1,a+1):
    a_score += b * 10**(i-1)
b_score = 0
for i in range(1,b+1):
    b_score += a * 10**(i-1)
if a_score > b_score:
    print(a_score)
else:
    print(b_score)

Measured memory_bytes: 3060