akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e7;
vector<int> pr;
int z[N+1];
int d(int a){
  int p=-1, c=1, r=1;
  while(a>1){
    if(z[a] != p){
      r *= c;
      c = 1;
    }
    a /= p = z[a];
    c++;
  }
  return r*c;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int i=2; i<=N; ++i) {
    if(!z[i]) pr.push_back(z[i]=i);
    for(int j=0, k, p=pr.size(); j<p && (k=pr[j])<=z[i] && i*k<=N; ++j) z[i*k]=k;
  }
  int n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n+1) ans += ll(i) * d(i);
  cout << ans << endl;
}

Measured memory_bytes: 46380
X, Y = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

step1_cnt = 0
step2_cnt = 0
if Y == X:
    if Y % 3 == 0:
        step1_cnt = step2_cnt = Y//3
        print(cmb(step1_cnt+step2_cnt,step1_cnt,mod))
    else:
        print(0)
if Y > X:
    step1_cnt = Y-X
    Y = Y - step1_cnt*2
    X = X - step1_cnt
    if Y % 3 == 0:
        step1_cnt += Y//3
        step2_cnt += Y//3
        print(cmb(step1_cnt+step2_cnt,step1_cnt,mod))
    else:
        print(0)

if X > Y:
    step2_cnt = X - Y
    Y = Y - step2_cnt
    X = X - step2_cnt*2
    if Y % 3 == 0:
        step1_cnt += Y//3
        step2_cnt += Y//3
        print(cmb(step1_cnt+step2_cnt,step1_cnt,mod))
    else:
        print(0)


Measured memory_bytes: 128332
s = input()
if s == "SUN":
  print(7)
if s == "MON":
  print(6)
if s == "TUE":
  print(5)
if s == "WED":
  print(4)
if s == "THU":
  print(3)
if s == "FRI":
  print(2)
if s == "SAT":
  print(1)

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

struct Edge
{
    int nxt, to;
};
Edge e[200010];
int head[200010], cnt;
const int LG = 65;
int dp[200010][LG + 2];

void add_edge(int a, int b)
{
    e[++cnt] = (Edge){ head[a], b };
    head[a] = cnt;
}

void dfs(int nod, int tata)
{
    for (int i = head[nod]; i; i = e[i].nxt) {
        int v = e[i].to;
        if (v == tata)
            continue;
        dfs(v, nod);
        for (int j(0); j <= LG; j++)
            dp[nod][j] += dp[v][j];
    }
    for (int i(LG); i >= 0; i--) {
        if (dp[nod][i] <= 1)
            continue;
        int p(i);
        while (dp[nod][p])
            p++;
        dp[nod][p] = 1;
        for (int j(0); j < p; j++)
            dp[nod][j] = 0;
        return;
    }

    int p(0);
    while (dp[nod][p])
        p++;
    dp[nod][p] = 1;
    for (int i(0); i < p; i++)
        dp[nod][i] = 0;
}

int main()
{
    int n, a, b;
    cin >> n;

    while (--n) {
        cin >> a >> b;
        add_edge(a, b);
        add_edge(b, a);
    }

    dfs(1, 0);

    for (int i(LG); i >= 0; i--) {
        if (dp[1][i]) {
            cout << i;
            return 0;
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 36096
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;

int
main(void)
{
    unordered_set<string> seen;
    string temp;
    int T;
    char last;

    cin >> T;
    cin >> temp;
    
    last = temp.back();
    T--;
    seen.insert(temp);

    while(T--)
    {
	cin >> temp;
	if(temp.front() != last || seen.find(temp) != seen.end())
	{
	    cout << "No\n";
	    return 0;
	}

	last = temp.back();
	seen.insert(temp);
    }

    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 256
// D-Preparing Boxes
// https://atcoder.jp/contests/abc134/tasks/abc134_d?lang=ja

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MAX 200000 + 4
ll n;
int a[MAX];

int main() {
  scanf("%lld", &n);
  for (ll i=0; i<n; i++)
    scanf("%d", &a[i+1]);

  ll m = 0;
  vector<int> b(n+1, 0);
  for (ll i=n; i>=1; i--) {
    ll s=0;
    for (ll j=i*2; j<=n; j+=i) {
      s^=b[j];
    }
    b[i]=s^a[i];
  }

  vector<int> ans;
  for (int i=1; i<=n; i++) {
    if (b[i] != 0) ans.push_back(i);
  }

  printf("%ld\n", ans.size());
  for (ll i=0; i<ans.size(); i++)
    printf("%d ", ans[i]);
  printf("\n");
}


Measured memory_bytes: 3064
#C
k, n = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
max=0
for i in range(n):
    if i == n - 1:
        b[i] = k - a[i] + a[0]
    else:
        b[i] = a[i + 1] - a[i]
    if max < b[i]:
        max = b[i]
        ii=i
# print(b,max)
b.pop(ii)
# print(b)
print(sum(b))

Measured memory_bytes: 25840
# Takahashi Calender

m, d = map(int, input().split())
count = 0

for cm in range(1, m+1):
    for cd in range(21, d + 1):
        if (cd // 10) * (cd % 10) == cm and cd % 10 > 1:
            count += 1

print(count)


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


int main() {
  string s0, s1, s2 ;
  cin >> s0 ;
  cin >> s1 ;
  cin >> s2 ;

  cout << "A" << s1[0] << "C" << endl ;
 
  return 0 ;
}



Measured memory_bytes: 256
def actual(N):
    max_count = 0
    max_number = 1

    for i in range(1, N + 1):
        num = i
        count = 0

        while num % 2 == 0:
            num = num // 2
            count += 1

        if count >= max_count:
            max_number = i
            max_count = count

    return max_number

  
N = int(input())

print(actual(N))

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#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 fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

vector<string> split(const string &str, char sep){
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while(getline(ss, buffer, sep)){
    v.push_back(buffer);
  }
  return v;
}

int main(){
  string S; cin >> S;
  vector<string> vec = split(S, '/');
  int year = stoi(vec[0]);
  int month = stoi(vec[1]);
  int day = stoi(vec[2]);
  if(year>=2019){
    if(month <= 4){
      cout << "Heisei" << endl;
    }
    else{
      cout << "TBD" << endl;
    }
  }
  else{
    cout << "Heisei" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0




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

lst = [-1] * (N + 1)
for i in range(N + 1):
    a = A[i]
    if lst[a] == -1:
        lst[a] = i
    else:
        left = lst[a]
        right = i
        break
# print (left, right)
F = Factorial(N + 1, MOD).comb

for i in range(1, N + 2):
    if left + N - right >= i - 1:
        tmp = F(N + 1, i) - F(left + (N- right), i - 1)
    else:
        tmp = F(N + 1, i)
    print (tmp % MOD)






Measured memory_bytes: 20456
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};


class UnionFind{
private:
	vector<int> par;
	vector<int> sz;
public:
	UnionFind(int n){ 
		par = vector<int>(n);
		sz = vector<int>(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if (sz[x] < sz[y]) swap(x,y);
		par[y] = x;
		sz[x] += sz[y];
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};


int main()
{
	int n,m;
	cin >> n >> m;
	vi x(m),y(m),z(m);
	rep(i,m) cin >> x[i] >> y[i] >> z[i];

	UnionFind uni(n+10);
	for(int i = 0; i < m; i++) uni.unite(x[i],y[i]);

	set<int> st;
	for(int i = 1; i <= n; i++) st.insert(uni.find(i));

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    long long int money = 1000, stock = 0;
    A.push_back(0);
    for (int i = 0; i < N; i++) {
        if (A[i] == A[i + 1]) continue;
        if (A[i] < A[i + 1]) {
            long long int tmp = money / A[i];
            money -= A[i] * tmp;
            stock += tmp;
        }
        else if (A[i] > A[i + 1]){
            money += stock * A[i];
            stock = 0;
        }
    }
    cout << money << endl;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i=1;
		while(true){
			int x = sc.nextInt();
			if(x==0){
				break;
			}else{
				System.out.println("Case "+i+": "+x);
				i++;
			}
		}
	}
}

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

using namespace std;

int main()
{
    int a[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);

        sort(a,a+3);
    int t=0;
    while(a[1]-a[0]>1)
    {
        a[0]+=2;t++;
    }
    t=a[1]-a[0]+t+a[2]-a[0];
    printf("%d\n",t);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,k;
  cin >> n >> k;
  ll h[n];
  rep(i,n) cin >> h[i];
  sort(h,h+n);
  reverse(h,h+n);
  ll ans=0;
  rep(i,n){
    if(i>=k){
      ans += h[i];
    }
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> v(n);
  for(int i=0; i<n; i++){
    int a,b;
    cin>>a>>b;
    v.at(i)=make_pair(b,a);
  }
  sort(v.begin(), v.end());
  int time=0;//現在時刻
  bool ok=true;
  for(int i=0; i<n; i++){
    time += v.at(i).second;
    if(time>v.at(i).first){
      ok=false;
      break;
    }
  }
  string ans;
  if(ok) ans="Yes";
  else ans="No";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for D - Floor Function
	var A, B int
	var N int
	fmt.Scan(&A, &B, &N)

	/*
		var ans int
		var max int

		for i := 0; i <= B-1; i++ {
			ans = int(math.Ceil(float64((A * i) / B)))
			if max < ans {
				max = ans
			}
		}
	*/

	//fmt.Println(max)
	i := int(math.Min(float64(B-1), float64(N)))
	fmt.Println(int(math.Ceil(float64((A * i) / B))))
}


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

void maxHeapify(int *A, int h, int i) {
	int left, right, largest, tmp;
	left = i * 2;
	right = left + 1;

	if (left <= h && A[left] > A[i]) largest = left;
	else largest = i;

	if (right <= h && A[right] > A[largest]) largest = right;

	if (largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;

		maxHeapify(A, h, largest);
	}
}

void buildMaxHeap(int *A, int h) {
	int i;
	for (i = h / 2; i > 0; i--)
		maxHeapify(A, h, i);
}

int main() {

	int h, i;
	int *A;

	scanf("%d", &h);
	A = (int*)malloc(sizeof(int) * (h + 1));
	for (i = 0; i < h; i++) {
		scanf("%d", &A[i + 1]);
	}

	buildMaxHeap(A, h);

	for (i = 1; i <= h; i++) {
		printf(" %d", A[i]);
	}

	printf("\n");

	return 0;
}


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

int maxSum(int A,int B,int C,int K)
{
	int s = 0;
	if(A >= K)
		return K;
	else if(B >= (K-A))
		return A;
	else if(C >= (K-A-B))
		return 2*A + B - K;
	return -1;
}

int main()
{
	int A,B,C,K;
	cin>>A>>B>>C>>K;
	cout<<maxSum(A,B,C,K);


}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
long long h,w,n,a,b,s[1000010],dem,kq[20];
const long long d=1e9+7;
int main()
{
	cin>>h>>w>>n;
	dem=0;
	for(int i=1;i<=n;i++)
	 {
	 	cin>>a>>b;
	 	for(int j=-2;j<=0;j++)
	 	  for(int o=-2;o<=0;o++)
	 	     if(a+j<=h-2 && b+o<=w-2 && a+j>=1 && b+o>=1) 
			    {
			     dem++;
			     s[dem]=d*(a+j)+(b+o);
			    }
     }
    sort(s+1,s+1+dem);
    long long t,ti;
    t=(h-2)*(w-2);
    ti=1;
    for(int i=1;i<=dem;i++)
      if(s[i]==s[i+1]) ti++;
        else kq[ti]++,ti=1;
    for(int i=1;i<=9;i++)
      t=t-kq[i];
	cout<<t<<endl;
	for(int i=1;i<=9;i++)
	   cout<<kq[i]<<endl;
}

Measured memory_bytes: 7296
#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;


ll calc(ll x,ll y){

	if(y > x)swap(x,y);

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


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	if(N > K){
		printf("0\n");
		return 0;
	}

	//KPN
	ll ans = 1;
	for(ll i = 0; i < N; i++){
		ans *= (K-i);
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 3216
// AtCoder ABC070 D - Transit Tree Path
// 2020.1.25 bal4u

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(ll n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

//// 優先度付きキュー（ダイクストラ法用）
#define MAX 1000000
typedef struct { ll t; int n; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, ll t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].t = t, que[i].n = n;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

//// 本問題関連
#define MAXV 100005
int N; // グラフの頂点数
int M; // 枝数
int hi[MAXV], *to[MAXV], *cost[MAXV]; // 頂点から本数、次のノード、次のノードまでのコスト
ll dis[MAXV];

void dijkstra(int start) {
	int i, u, v;
	ll t;

	memset(dis, 0x55, sizeof(dis));
	enq(start, 0);
	while (qsize) {
		u = que[0].n, t = que[0].t, deq();
		if (dis[u] <= t) continue;
		dis[u] = t;
		for (i = 0; i < hi[u]; i++) {
			v = to[u][i];
			if (dis[v] > t) enq(v, t + cost[u][i]);
		}
	}
}

void getGraph(void) {
	int i, k, a, b, c;
	int *memo, sz;
	
// 入力　N、M
// a1, b1, c1
// a2, b2, c2
// ...
// aM, bM, cM
	N = in(), M = N-1; // 頂点数、枝数の入力
	memo = malloc(M*3*sizeof(int));
	sz = 0; for (i = 0; i < M; ++i) {
		a = in(), b = in(), c = in();
		hi[a]++, hi[b]++;
		memo[sz++] = a, memo[sz++] = b, memo[sz++] = c;
	}
	for (i = 1; i <= N; ++i) if (hi[i]) {
		to[i] = malloc(hi[i]*sizeof(int)), cost[i] = malloc(hi[i]*sizeof(int));
	}
	memset(hi, 0, sizeof(hi));
	
	i = 0; while (i < sz) {
		a = memo[i++], b = memo[i++], c = memo[i++];
		k = hi[a]++, to[a][k] = b, cost[a][k] = c; // 有向グラフのみ
		k = hi[b]++, to[b][k] = a, cost[b][k] = c; // 無向グラフ
	}
	free(memo);
}

int main()
{
	int K, Q;
	
	getGraph();
	Q = in(), K = in();
	dijkstra(K);
	while (Q--) {
		int x = in(), y = in();
		out(dis[x] + dis[y]);
	}
	return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

lli dp[1002][1002][3];

int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);

    FastIO;
    int n,m;
    while(cin>>n>>m)
    {
        lli a[n+1][3];

        for(int i=1; i<=n; i++)
        {

            for(int j=0; j<3; j++) cin>>a[i][j];
        }

        lli ans = 0;
        for(int mask=0; mask<8; mask++){
            vector<lli>v(n,0);
            for(int i=1; i<=n; i++){
                for(int j=0; j<3; j++){
                    if((1<<j)&mask) v[i-1] += a[i][j];
                    else v[i-1] -= a[i][j];
                }
            }
            sort(atoz(v));
            int mm = m;
            lli now = 0;
            while(mm--){
                now += v.back();
                v.pop_back();
            }
            ans = max(ans , now);
        }
        cout<<ans<<endl;
    }

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n,m;
	while (cin >> n>>m&&n != 0) {
		if (n*m%2==1) cout << "no" << endl;
		else cout << "yes" << endl;
	}
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstring>
using namespace std;
int a[1000][2];
bool st[1000];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;++i){
        sum+=(n-1)/i;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>

using namespace std;

#define A first
#define B second

typedef long long ll;
constexpr int MOD = 1000000007;

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> dp(K + 1);
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  dp[0] = 0;
  for(int i = 1; i <= K; i++){
    dp[i] = 0;
    for(int j = 0; j < N; j++){
      if(i >= A[j] && dp[i - A[j]] == 0){
        dp[i] = 1;
        break;
      }
    }
  }
  cout << ((dp[K] == 1) ? "First" : "Second");
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int n, i, temp = 0, cnt=0, ans=0;
  scanf("%d",&n);
  int a[n];
  for (i = 0; i < n; i++) {
  	scanf("%d",&a[i]);
    if(!temp) {temp = a[i]; cnt++;}
    else if (a[i] == temp){cnt++;}
    else {ans += cnt/2; cnt = 1;temp = a[i];}
  }
  ans += cnt/2;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
def resolve():
    n = input()
    check = ""
    true_check = ""
    for i in range(len(n)):
        true_check += "T"
        if n[i] == n[len(n)-i-1]:
            check += "T"
        else:
            check += "F"
            print("No")
            break
    if not("F" in check) and check == true_check:
        print("Yes")
resolve()

Measured memory_bytes: 8944
X, Y = map(int,input().split())

t = (4 * X - Y) / 2
k = (-2 * X + Y) / 2

if (t % 1 == 0) and (k % 1 == 0) and (t >= 0 and k >= 0):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9244
/*input
1000000009 9
*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
    return (fir*sec)/(gcd(fir, sec));
}

//x^n%M
// log(n) time, log(n) memory
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}

const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


// ios_base::sync_with_stdio(false);
// cin.tie(NULL);

int main(){
    ll n,m;
    cin>>n>>m;
    if(n==1 && m==1){
        syso(1);
    }
    else if(n==1){
        syso(m-2);
    }
    else if(n==2){
        syso(0);
    }
    else if(m==1){
        syso(n-2);
    }
    else if(m==2){
        syso(0);
    }
    else{
        ll ans = (m-2)*(n-2);
        syso(ans);
    }

}

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

int gcd(int a, int b);
int gcd(const std::vector<int>& arr);

int main() {

        int n, x;
        std::cin >> n >> x;
        std::vector<int> L(n);
        for (auto& v : L) {
                std::cin >> v;
        }

        int max_v = 0;
        int p = 0;
        for (const auto& v : L) {
                if (p <= x) {
                        ++max_v;
                }

                p += v;
        }
        if (p <= x) {
                ++max_v;
        }

        std::cout << max_v << std::endl;

        return 0;
}

int gcd(int a, int b) {
        if (a > b) {
                std::swap(a, b);
        }

        for (int r = b % a; r != 0; b = a, a = r, r = b % a)
                ;

        return a;
}

int gcd(const std::vector<int>& arr) {
        const int size = arr.size();
        if (size == 0) {
                return 0;
        }
        else if (size == 1) {
                return arr[0];
        }

        int ret = gcd(arr[0], arr[1]);

        for (std::size_t i = 2; i < size && ret != 1; ++i) {
                ret = gcd(arr[i], ret);
        }

        return ret;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b;
}
void usaco() {
	freopen("problem.in", "r", stdin); 
	freopen("problem.out", "w", stdout);
}
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {

	ran(); fast();
	
	int n, d;
	cin >> n >> d;
	int c = 0;
	d *= d;
	
	for (int i=0; i<n; i++) {
		int x, y;
		cin >> x >> y;
		int l = x * x + y * y;
		if (l <= d) c++;
	}
	
	cout << c << endl;

}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int WE,N;
vector<ll int> W,V;
ll int dp[105][100005];
ll int fun(ll int i,ll int w)
{
    if(i==N-1)
    {
        if((w+W[i])<=WE)
        dp[i][w]=V[i];
        else
        dp[i][w]=0;
    }
    else
    {
        if(dp[i+1][w]==-1)
        dp[i+1][w]=fun(i+1,w);
        if((w+W[i])<=WE)
        {
            if(dp[i+1][w+W[i]]==-1)
            dp[i+1][w+W[i]]=fun(i+1,w+W[i]);
            dp[i][w]=(V[i]+dp[i+1][w+W[i]])>=(dp[i+1][w])?(V[i]+dp[i+1][w+W[i]]):(dp[i+1][w]);
        }
        else
        {
            dp[i][w]=dp[i+1][w];
        }
    }
    return dp[i][w];
}
int main()
{
    ll int i,x,y,j;
    cin>>N>>WE;
    for(i=0;i<N;i++)
    {
        cin>>x>>y;
        W.pb(x);
        V.pb(y);
    }
    for(i=0;i<105;i++)
    {
        for(j=0;j<100005;j++)
        dp[i][j]=-1;
    }
    dp[0][0]=fun(0,0);
    cout<<dp[0][0]<<endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> Pint;

//-----------------------------------------------------------------------

const int MAX=100001;
int sum[MAX+1];

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

    int n; cin>>n;
    REP(i,n){
        int a,b; cin>>a>>b;
        sum[a]++; sum[b+1]--;
    }
    REP(i,MAX) sum[i+1]+=sum[i];

    int ans=0;
    REP(i,MAX+1){
        if(sum[i]>=i-1) ans=i-1;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3964
#include<stdio.h>

int main() {
   int N;
   int sum;
   int allsum = 0;
   scanf("%d", &N);
   int H[N];
   for(int i = 0; i < N; i++) {
      scanf("%d", &H[i]);
   }
   for(int i = 0; i < N; i++) {
      sum = 0;
      for(int j = 0; j < i; j++) {
         if(H[j] <= H[i]) {
            sum++;
         }
      }
      if(sum == i) {
         allsum++;
      }
   }
   printf("%d\n", allsum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int sx,sy,tx,ty,answer;
  cin>>sx>>sy>>tx>>ty;

  REP(i,ty-sy){
    cout<<'U';
  }

  REP(i,tx-sx){
    cout<<'R';
  }

  //1回目行き

  REP(i,ty-sy){
    cout<<'D';
  }

  //1回目帰り

  REP(i,tx-sx){
    cout<<'L';
  }

  cout<<'L';

  REP(i,ty-sy+1){
    cout<<'U';
  }

  REP(i,tx-sx+1){
    cout<<'R';
  }

  cout<<'D';

  //2回目行き

  cout<<'R';

  REP(i,ty-sy+1){
    cout<<'D';
  }

  REP(i,tx-sx+1){
    cout<<'L';
  }

  cout<<'U';

  return 0;
}


Measured memory_bytes: 256
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    vector<int>v(n);

    int x = 0;
    for(int i=0;i<n;i++)
        cin>>v[i] , x ^= v[i];


    for(int i=0;i<n;i++)
        cout<<(v[i]^x)<<" ";
    cout<<endl;


    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 3988
n, m = list(map(int, input().split()))
a_list = list(map(int, input().split()))

sum_a = sum(a_list)
cnt = 0

for a in a_list:
    if a >= sum_a/(4*m):
        cnt += 1

if cnt >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n:usize,
        k:usize,
        a:[usize; n]
    }

    let mut costs = BTreeMap::new();
    let mut pos = 1;
    let mut loop_length = 0;
    let mut loop_start = 0;

    for i in 1..=k {
        pos = a[pos - 1];
        match costs.get(&pos) {
            Some(x) => {
                loop_length = i - x;
                loop_start = *x;
                break;
            }
            None => {
                costs.insert(pos, i);
            }
        }
    }

    dbg!(loop_start, loop_length);
    dbg!(&costs);
    if loop_length != 0 {
        for _ in 0..(k - loop_start) % loop_length {
            dbg!("HI");
            pos = a[pos - 1]
        }
    }

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


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n;
    cin >> n;
    ll p[n];
    rp(i, 0, n) cin >> p[i];
    sort(p, p + n);
    ll ans = 0;
    rp(i, 0, n) ans += p[i];
    ce(ans - p[n - 1] / 2);
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500 * a + 100 * b + 50 * c
            if (total == X):
                res += 1
print(res)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(c <= a){
    if(d <= a) cout << 0 << endl;
    else if(a < d && d < b) cout << d-a << endl;
    else cout << b-a << endl;
  }else if(a < c && c < b){
    if(d <= b) cout << d-c << endl;
    else cout << b-c << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N, X, i, cnt, dis ;
	int L[101];
	scanf("%d %d", &N, &X);

	cnt = 1;
	dis = 0;

	for (i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	
	for (i = 0; i < N; i++) {
		dis = dis + L[i];
		if (dis > X) break;
		cnt++;
	}
	printf("%d", cnt);

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h> 
int main()
{
	int N;
	scanf("%d", &N);
	
	char S[N];
	scanf("%s", S);
	
	if(N%2 == 1) printf("No");
	
	else{
		int M = N / 2;
		int r;
		int c = 0;
		for(r=0; r<M; r++){
			if(S[r] == S[M+r]) c++;
		}
		
		if(c == M) printf("Yes");
		else printf("No");
    }
	return 0;
}

Measured memory_bytes: 128
//Create Time: 2018-05-03 18:50:56
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
int main(){
    int n;cin>>n;
    pii p={0,0};
    int time=0;
    bool gg=0;
    rep(i,0,n){
        int t,x,y;scanf("%d%d%d",&t,&x,&y);
        int s=abs(x-p.x)+abs(y-p.y),nt=t-time;
        if(s>nt || (nt-s)%2!=0){
            // OUT(i,nt,s);
            gg=1;break;
        }
        p={x,y};
        time=t;
    }
    puts(gg?"No":"Yes");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
lli MOD = 1000000007;
int main()
{
    lli a[7] = {};

    rep(i, 7) cin >> a[i];
    lli ans = a[1];
    int b = a[0] % 2;
    int c = a[3] % 2;
    int d = a[4] % 2;
    if (b + c + d <= 1 || b + c + d == 3 || a[0] == 0 || a[3] == 0 || a[4] == 0) {
        ans += (a[0] / 2) * 2;
        ans += (a[3] / 2) * 2;
        ans += (a[4] / 2) * 2;
        if (a[0] & 1 && a[3] & 1 && a[4] & 1)
            ans += 3;
    } else {
        if (!b)
            a[0]--;
        ans += (a[0] / 2) * 2;
        if (!c)
            a[3]--;
        if (!d)
            a[4]--;
        ans += (a[3] / 2) * 2;
        ans += (a[4] / 2) * 2;
        ans += 3;
    }
    cout << ans << endl;
}


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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( stdin.hasNextDouble() ) {

	    double a = stdin.nextDouble();
	    double sum = a;
	    for ( int i = 2; i <= 10; i++ ) {
		if ( i % 2 == 0 ) {
		    a *= 2; 
		} else {
		    a /= 3;
		}
		sum += a;
	    }
	    System.out.println( sum );	    
	}	
    }    
}

Measured memory_bytes: 17360
n = int(input())

pn = list(map(int,input().split()))
count = 0
for x in range(1,n-1):
  if pn[x+1] > pn[x] > pn[x-1] or pn[x-1] > pn[x] > pn[x+1]:
    count += 1
print(count)

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

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

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

int main() {
    int ans = 0;
	int n, tmp;
	int sum = 0, ma = -1;
	cin >> n;
	REP(i, n){
		cin >> tmp;
		ma= max(ma, tmp);
		sum += tmp;
	}
	if(sum - ma > ma) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int ans;

  if(k<=a) ans = k;
  else if(k<=a+b) ans = a;
  else ans = a - (k - a - b);

  cout << ans << endl;

  return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var rate = int.Parse(Console.ReadLine());

            if (rate < 1200)
            {
                Console.WriteLine("ABC");
            }
            else if (1200 <= rate && rate < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y;
  cin>>x>>y;
  int l=x.length(),m=y.length(),j;
  if(l<m) cout<<"LESS"<<endl;
  else if(l>m) cout<<"GREATER"<<endl;
  else{
    for(j=0;j<l;j++){
      if(x.at(j)<y.at(j)){
        cout<<"LESS"<<endl;
        break;
      }
      else if(x.at(j)>y.at(j)){
        cout<<"GREATER"<<endl;
        break;
      }
    }
    if(j==l) cout<<"EQUAL"<<endl;
  }
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> a = new ArrayList<Integer>();

		int N = scanner.nextInt();
		for (int i = 0 ; i < N ; i++) {
			a.add(scanner.nextInt());
		}
		double average = (double)a.stream().mapToInt(x -> x).sum() / N;

		System.out.println(calc_cost(a, (int)Math.round(average)));

		scanner.close();
	}

	private static int calc_cost(ArrayList<Integer> a, int rewrite_num) {
		return a.stream().map(i -> (int)Math.pow((rewrite_num - i), 2))
				.mapToInt(x -> x)
				.sum();
	}
}


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

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a+0, a+3);
	for (int i = 0; i < 3; i++) {
		cout << a[i];
		if (i != 2) {
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int fuck[100002];
int shit[100002];
int main(){
    int n,m;
    cin>>n>>m;
    int l[m],r[m];
    for(int i=0; i<m; i++){
        cin>>l[i]>>r[i];
        fuck[l[i]]++;
        fuck[r[i]+1]--;
    }
    shit[1]=fuck[1];
    for(int i=2; i<n+1; i++){
        shit[i]=shit[i-1]+fuck[i];
    }int count=0;
    for(int i=1; i<=n+1; i++){
        if(shit[i]==m)count++;
    }cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    long int x[N],y[N],sum[N],dif[N];
    rep(i,N){
        cin>>x[i]>>y[i];
        sum[i]=x[i]+y[i];
        dif[i]=x[i]-y[i];
    }
    sort(sum,sum+N);
    sort(dif,dif+N);
    long long ans=sum[N-1]-sum[0];
    if (ans<dif[N-1]-dif[0]) ans=dif[N-1]-dif[0];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 9872
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
C.sort()
ans=0
for b in B:
    ok=-1
    ng=N
    while ng-ok > 1:
        mid = (ok+ng) // 2 # 平均(小数切り捨て)
        if A[mid]<b:
            ok = mid
        else:
            ng = mid
    A_num=ok+1

    ok=N
    ng=-1
    while ok-ng > 1:
        mid = (ok+ng) // 2 # 平均(小数切り捨て)
        if C[mid]>b:
            ok = mid
        else:
            ng = mid
    C_num=N-(ng+1)
    ans+=A_num*C_num
print(ans)



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

struct zahyou{
    long long no;
    long long p;
    long long q;
};

using namespace std;
int main(){
    int n;
    cin >> n;

    vector<long long> x(n), y(n);

    for(int i = 0; i < n; i++)cin >> x[i] >> y[i];

    long long res = 10000000000000000;
    long long ap, aq;
    for(int i = 0; i < n; i++){//h
        for(int j = 0; j < n; j++){//x
            if(i == j)continue;
            long long p = x[i] - x[j];
            long long q = y[i] - y[j];
            long long ans = 0;
            for (int k = 0; k < n; k++){
                bool flag = false;
                for(int l = 0; l < n; l++){
                    if(k == l)continue;
                    if((x[k] - x[l] == p) && (y[k] - y[l] == q)){
                        flag = true;
                        break;
                    }
                    if(k == n-1 && l+1 == n-1)flag = false;
                    if(l+1 == n)flag = false;
                }
                 if(flag == false)ans++;
            }
            if(ans < res){
                res = ans;
                ap = p;
                aq = q;
            }
        }

    }

    //cout << ap << " " << aq << endl;
    if(n== 1)res = 1;
    printf("%lld", res);

    return 0;
}

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

void main()
{
    long A, B;
    scan(A, B);
    writeln(A < 10 && B < 10 ? A * B : -1);
}


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

int a,b;
bool v[5];

int main()
{
	cin>>a>>b;
	v[a] = 1,v[b] = 1; 
	for(int i = 1;i <= 3;i++)
	if(v[i] == 0) cout<<i;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w0,r0,c,r,c0,i=0;
  while(1){
	i = 0;
	cin >> r0 >> w0 >> c >> r;
	if(w0==0 && r0==0 && c==0 && r==0) break;
	while(1){
	  c0 = r0/w0;
	  if(c0<c){
		r0 += r;
		i++;
	  }else{
	    break;
	  }
	}
	cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0);cin.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int s, w;
  cin >> s >> w;
  if (s <= w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;


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


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  sortd(a);
  sortd(b);
  sortd(c);

  priority_queue<ll> que;

  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      // cout << a[i] + b[j] << endl;
      que.push(a[i] + b[j]);
    }
  }

  vector<ll> t;

  rep(i, k) {
    if (que.size() == 0) {
      break;
    }
    ll tmp = que.top();
    que.pop();
    t.push_back(tmp);
  }

  priority_queue<ll> ans;

  ll s = min<ll>(k, t.size());
  rep(i, s) {
    rep (j, z) {
      ans.push(t[i] + c[j]);
    }
  }
  rep (i,k) {
    cout << ans.top() << endl;
    ans.pop();
  }
}


Measured memory_bytes: 43400