akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=0;
    rep(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <deque>

using namespace std;

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

ll e1[101000];
ll e2[101000];
int dis[101000];
deque<P> q;


int main(){
    ll K;  cin >> K;
    for(int i = 0; i < K-1; i++){
        e1[i] = i+1;
        e2[i] = i*10%K;
    }
    e1[K-1] = 0;
    e2[K-1] = (K-1)*10 % K;

    fill(dis, dis+K, INT32_MAX);
    dis[1] = 0;

    q.push_front(P(e2[1], 0));
    q.push_back(P(e1[1], 1));

    while(!q.empty()){
        P s = q.front();
        q.pop_front();
        if(dis[s.first] == INT32_MAX){
            dis[s.first] = s.second;
            q.push_front(P(e2[s.first], s.second));
            q.push_back(P(e1[s.first], s.second+1));
        }
    }

    cout << dis[0] + 1 << endl;

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <limits>
#include <queue>
#include <set>
using namespace std;
typedef long long int lld;
int T;

int main(void){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
    int n;
    int *x,*y;
    cin>>n;
    x=new int [n];
    if (x==NULL){
        cout<<"Error!"<<endl;
        return -1;
    }
    y=new int [n];
    if (y==NULL){
        cout<<"Error!"<<endl;
        delete [] x;
        return -1;
    }
    int i;
    
    for (i=0;i<n;i++) cin>>x[i];
    for (i=0;i<n;i++) cin>>y[i];
    
    cout<<fixed<<setprecision(6);
    double d;
    for (int p=1;p<=3;p++){
        d=0;
        for (i=0;i<n;i++){
            d+=pow(abs(x[i]-y[i]),(double)p);
        }
        d=pow(d,1.0/p);
        cout<<d<<endl;
    }
    d=0;
    //?????§????????§????????¢
    for (i=0;i<n;i++)
        if (abs(x[i]-y[i])>d) d=abs(x[i]-y[i]);
    cout<<d<<endl;
    delete [] x;
    delete [] y;
    return 0;
}

Measured memory_bytes: 1332
H,W=map(int, input().split())
S=[list(input()) for _ in range(H)]
l=[]
flag=0

for h in range(H):
	for w in range(W):
		if S[h][w]=="#":
			if h>0:
				l.append(S[h-1][w])
			if h<H-1:
				l.append(S[h+1][w])
			if w>0:
				l.append(S[h][w-1])
			if w<W-1:
				l.append(S[h][w+1])
			if "#" not in l:
				flag=1
				break
			l=[]

print("Yes" if flag==0 else "No")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
Read1();
      string tmp="";
      bool MY;
      bool YM;
if(N/100>12 || N/100==0){MY=false;}else{MY=true;}
      if(N%100>12 || N%100==0){YM=false;}else{YM=true;}
      if(YM && MY){tmp="AMBIGUOUS";}
      if(YM && !MY){tmp="YYMM";}
      if(!YM && MY){tmp="MMYY";}
      if(!YM && !MY){tmp="NA";}
      
                    Console.WriteLine(tmp);

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
using namespace std;

#define int long long
using namespace std;

class UF {
public:
	vector<int> rank;
	vector<int> p;

	UF() {}
	UF(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0;i < size;i++) makeSet(i);
	}
	
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};


signed main() {
	int N, K, L;
	cin >> N >> K >> L;
	UF load(N), train(N);

	for (int i = 0;i < K;i++) {
		int p, q;
		cin >> p >> q;
		p--; q--;//0-indexed
		load.unite(p, q);
	}

	for (int i = 0;i < L;i++) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		train.unite(r, s);
	}
	
	map<pair<int,int>, int> mp;
	for (int i = 0;i < N;i++) {
		mp[pair<int, int>(load.findSet(i), train.findSet(i))]++;
	}


	for (int i = 0;i < N;i++) {
		cout << mp[pair<int, int>(load.findSet(i), train.findSet(i))] << endl;
	}
}

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

struct d{
  int time, prob, team;
};
bool operator<(const d &a, const d &b){
  if(a.prob == b.prob){
    if(a.time == b.time){
      return a.team > b.team;
    }else{
      return a.time < b.time;
    }
  }else{
    return a.prob > b.prob;
  }
}
int main(){

  int M, T, P, R;
  int m, t, p, j, i;

  while(cin >> M >> T >> P >> R, M+T+P+R){
    d res[T+1];
    for(i = 1; i <= T; i++){
      res[i].time = res[i].prob = 0;
      res[i].team = i;
    }
    int rank[T+1][P+1];
    for(i = 1; i <= T; i++){
      for(j = 1; j <= P; j++){
        rank[i][j] = 0;
      }
    }
    for(i = 0; i < R; i++){
      cin >> m >> t >> p >> j;
      if(m > M) break;
      if(j){
        rank[t][p]++;
      }else{
        res[t].time += m + rank[t][p]*20;
        res[t].prob++;
      }
    }
    /* cerr << "debug" << endl;
    for(i=1; i<=T; i++)
    {
      cerr << res[i].team << "," << res[i].prob << "," << res[i].time << endl;
    }
    cerr << "debug" << endl;
*/
    sort(res+1, res+T+1);
    cout << res[1].team;
    for(i=2; i<=T; i++)
    {
      cout << ((res[i].prob==res[i-1].prob && res[i].time==res[i-1].time) ? "=" : ",") << res[i].team;
    }
    cout << endl;
    //cerr << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int h, w;
string fld[444];
bool vis[444][444];

pair<LL, LL> dfs(int i, int j){
    pair<LL, LL> ret = make_pair(0, 0);
    vis[i][j] = true;
    if(fld[i][j] == '#')ret.first++;
    if(fld[i][j] == '.')ret.second++;
    REP(k, 4){
        int ni = i + dy[k], nj = j + dx[k];
        if(0 <= ni && ni < h && 0 <= nj && nj < w && fld[i][j] != fld[ni][nj] && vis[ni][nj] == false){
            pair<LL, LL> ii = dfs(ni, nj);
            ret.first += ii.first;
            ret.second += ii.second;
        }
    }
    return ret;
}

int main(){
    INIT;
    cin >> h >> w;
    REP(i, h){
        cin >> fld[i];
    }
    LL ans = 0;
    REP(i, h)REP(j, w){
        pair<LL, LL> ret = make_pair(0, 0);
        if(fld[i][j] == '#' && vis[i][j] == false)ret = dfs(i, j);
        ans += ret.first*ret.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define PPB pop_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define loop(i,start,end) for(ll i=start; i<end; i++)
#define rloop(j,start,end) for(ll j=start-1; j>=end; j--)

int main()
{   
    IOS;

    
    ll n;
    cin>>n;

    ll a[n][3],dp[n+1][3],maxi=INT_MIN,cnt=0;
    
    loop(i,0,n)
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0]; 
    dp[0][1]=a[0][1]; 
    dp[0][2]=a[0][2];

    loop(i,1,n)
    {
        dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);  
        dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
        dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
    }
    
    d1(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}

Measured memory_bytes: 4992
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	rate := 1.08

	res := float64(n) / 1.08
	t1 := int(res)
	if int(float64(t1) * rate) == n {
		fmt.Println(t1)
	} else if int(float64(t1 + 1) * 1.08) == n {
		fmt.Println(t1 + 1)
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i][j] == '#')
                cout << a[i][j];
            else
            {
                int il = 0;
                for (int k = 0; k < n; ++k)
                {
                    for (int l = 0; l < m; ++l)
                    {
                        if (abs(k - i) <= 1 && abs(l - j) <= 1 && a[k][l] == '#')
                            ++il;
                    }
                }
                cout << il;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  
  int A = 0;
  rep (i, 0, b) {
    A *= 10;
    A += a;
  }

  int B = 0;
  rep (i, 0, a) {
    B *= 10;
    B += b;
  }

  
  if (A >= B)
    cout << A << endl;
  else
    cout << B << endl;
  
}


Measured memory_bytes: 256
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
using namespace std;
// int inf = INFINITY;
int main(){
  ll N;
  cin>>N;

  ll ans = 0;
  for(int i=0;i<pow(10,5);i++){
    if(i*i>N){
      ans = pow((i-1),2);
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;

long long N, M;
string S, T;
map<ll, char> m;

int main(){
  cin >> N >> M;
  cin >> S >> T;

  ll gcd = __gcd(N, M);
  ll lcm = N*M/gcd;
  
  for(int i=0; i<N; i++){
    m[i*lcm/N] = S[i];
  }
  bool pos = true;
  for(int i=0; i<M; i++){
    if(m.count(i*lcm/M)){
      pos &= m[i*lcm/M] == T[i];
    }
  }
  if(pos){
    cout << lcm << endl;
  }
  else{
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <queue>
#include <map>
#include <cmath>
#include <sstream>
#include <bitset>
using namespace std;
typedef long long int ll;
#define MAX_V 16
int adjMat[MAX_V][MAX_V];
bool visited[MAX_V][1<<MAX_V];//visited????????????????????????????¨???????,????????????????????????????????????
int dp[MAX_V][1<<MAX_V];//DP??¨???,?¬¬???????????¬?????£??¨???????????¨??????
//?¬¬???????????¬?????£??¨?????????????????????(ex:0101011,??¨???1,3,5??????????????°???,?????\??´??\??¨bitwise?????????????????????)
//??????DP??¨??????N*2^N?¬????,?????\????????????????°±???O(N*2^N)
int v,e;

const char *byte_to_binary(int x)
{
    static char b[9];
    b[0] = '\0';

    int z;
    for (z = 128; z > 0; z >>= 1)
    {
        strcat(b, ((x & z) == z) ? "1" : "0");
    }

    return b;
}
int TSP(int at,int state)
{
    // printf("at=%d,state=%s\n",at, byte_to_binary(state));
    if(state == (1<<v)-1 && at==0){ //??¨??¨??????????????°??????????????°?????????
        visited[at][state]=true;
        return dp[at][state];
    }
    if(dp[at][state]) //??????????????????,??´??\????????????
        return dp[at][state];
    int ans = INT_MAX>>1;
    int cost;
    for(int i=0;i<v;i++){
        //state&(1<<i)==0??¨?????????????????????????¬¬i???bit?????????0,??¨?????????????????????????????°???
        //state|(1<<i)??¨????°???????????¨??????°???
        if(adjMat[at][i]!=-1 && (state & (1<<i))==0){
            // printf("at=%d->i=%d\n",at,i);
            cost = TSP(i,state|(1<<i)) + adjMat[at][i];//???????¨??????\??°??????????????°??????
            // printf("at=%d->i=%d,cost=%d\n",at,i,cost);
            ans = min(ans,cost);//?±????????°????
        }
    }
    return dp[at][state] = ans;
}
//
int main()
{   
    // freopen("in","r",stdin);
    while(~scanf("%d %d",&v,&e)){
        memset(adjMat,-1,sizeof(adjMat));
        for(int i=0;i<e;i++){
            int u,v,w;
            scanf("%d%d%d",&u,&v,&w);
            adjMat[u][v]=w;
        }
        memset(dp,0,sizeof(dp));
        memset(visited,0,sizeof(visited));
        int ans = TSP(0,0);
        if(ans>=INT_MAX>>1)
            puts("-1");
        else
            printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 6316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const long double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double cr = 360.0;
    long double hcr = 180.0;
    
    long double dega = h/12.0+(m/60.0/12.0);
    long double rada = dega*2.0*PI;
    long double y1 = sin(rada)*a;
    long double x1 = cos(rada)*a;

    long double degb = m/60.0;
    long double radb = degb*2.0*PI;
    long double y2 = sin(radb)*b;
    long double x2 = cos(radb)*b;

    long double ans = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 4176
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main() {
	auto nm = readln.chomp.split.map!(to!long);
	long n = nm[0];
	long m = nm[1];
	long atom = min(n, m / 2);
	m -= atom * 2;
	long next = m / 4;
	writeln = atom + next;
}



Measured memory_bytes: 256
"""

https://atcoder.jp/contests/arc074/tasks/arc074_d
適当に最小カットを求めればいい
→縦横を別ノードで持っておいてつなぐ

0～99 列
100～199 横
200 = start
201 = goal

"""



from collections import defaultdict
from collections import deque

def Ford_Fulkerson_Func(s,g,lines,cost):

    N = len(cost)
    ans = 0
    queue = deque([ [s,float("inf")] ])

    ed = [True] * N
    ed[s] = False

    route = [0] * N
    route[s] = -1

    while queue:

        now,flow = queue.pop()
        for nex in lines[now]:

            if ed[nex]: 
                flow = min(cost[now][nex],flow)
                route[nex] = now
                queue.append([nex,flow])
                ed[nex] = False

                if nex == g:
                    ans += flow
                    break
            
        else:
            continue
        break

    else:
        return False,ans


    t = g
    s = route[t]

    while s != -1:
        cost[s][t] -= flow
        if cost[s][t] == 0:
            lines[s].remove(t)

        if cost[t][s] == 0:
            lines[t].add(s)
        cost[t][s] += flow
        t = s
        s = route[t]

    return True,ans

def Ford_Fulkerson(s,g,lines,cost):

    ans = 0

    while True:
        fl,nans = Ford_Fulkerson_Func(s,g,lines,cost)

        if fl:
            ans += nans
            continue
        else:
            break
    
    return ans

H,W = map(int,input().split())

lines = defaultdict(set)
cost = [ [0] * 202 for i in range(202) ]

for i in range(H):

    a = input()
    for j in range(W):
        if a[j] == "S":
            lines[200].add(i)
            cost[200][i] = 20000

            lines[200].add(100+j)
            cost[200][100+j] = 20000

        elif a[j] == "T":
            lines[i].add(201)
            cost[i][201] = 20000

            lines[100+j].add(201)
            cost[j+100][201] = 20000
    
        elif a[j] == "o":
            lines[i].add(j+100)
            cost[i][j+100] = 1
            lines[j+100].add(i)
            cost[j+100][i] = 1

ans = (Ford_Fulkerson(200,201,lines,cost))
if ans >= 20000:
    print (-1)
else:
    print (ans)


Measured memory_bytes: 76924
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,S,Q;
  cin >> X;
  Q = X;
  for(;Q != 0;){
    S += Q % 10;
    Q /= 10;
  }
  if(X % S == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort{|x,y|y<=>x} end##
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,c=gsmi
puts_yesno(a<=c&&c<=b||b<=c&&c<=a)

Measured memory_bytes: 1788
import functools
def solve(N, A, B, C, D):
    @functools.lru_cache(None)
    def dp(N):
        if N<=0:
            return float('inf')
        if N == 1:
            return 0
        ans = (N-1)*D
        # BY TWO
        mod_2 = N % 2
        if not mod_2:
            ans = min(ans, dp(N//2)+A)
        else:
            ans =min(ans, dp((N+(2-mod_2))//2)+(A+D*(2-mod_2)))
            ans = min(dp((N-mod_2)//2)+(A+D*mod_2), ans)
        mod_3 = N % 3
        if not mod_3:
            ans = min(ans, dp(N//3)+B)
        else:
            ans =min(ans, dp((N+(3-mod_3))//3)+(B+D*(3-mod_3)))
            ans = min(dp((N-mod_3)//3)+(B+D*mod_3), ans)
        mod_5 = N % 5
        if not mod_5:
            ans = min(ans, dp(N//5)+C)
        else:
            ans =min(ans, dp((N+(5-mod_5))//5)+(C+D*(5-mod_5)))
            ans = min(dp((N-mod_5)//5)+(C+D*mod_5), ans)
        return ans
        
    return dp(N)+D
t = int(input())
for _ in range(t):
    N, A, B, C, D = list(map(int, input().split()))
    print(solve(N, A, B, C, D))

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, k;
    string s;
    
    cin >> n;
    cin >> s;
    cin >> k;
    
    for(auto i : s)
    {
        if(i != s[k - 1])
            cout << "*";
        else cout << i;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
vector<set<pair<ll,ll>>> pq,qp;
vector<vector<ll>> p,q;
vector<ll> used;
vector<pair<ll,ll>> xy;
unordered_map<ll, ll> ma,mb;
void dfs(ll node,ll k)
{
  //cout<<node<<endl;
  ll x=xy[node].first,y=xy[node].second;
  used[node]=1;
  vector<ll> aa={x+k,x-k,y+k,y-k},bb={y-k,y-k,x-k,x-k},nn;
  rep(i,2)
  {
    if(!ma.count(aa[i]))continue;
    ll idx=ma[aa[i]];
    auto s=pq[idx].lower_bound(make_pair(bb[i],0LL)),
         t=pq[idx].upper_bound(make_pair(bb[i]+2*k+1,0LL));
    vector<pair<ll,ll>>tv(s,t);
    for(auto tp:tv)
    {
      pq[ma[aa[i]]].erase(tp);
      qp[mb[tp.first]].erase({aa[i],tp.second});
      nn.push_back(tp.second);
    }
  }
  repi(i,2,4)
  {
    if(!mb.count(aa[i]))continue;
    ll idx=mb[aa[i]];
    auto s=qp[idx].lower_bound(make_pair(bb[i]+1,0LL)),
         t=qp[idx].upper_bound(make_pair(bb[i]+2*k,0LL));
     vector<pair<ll,ll>>tv(s,t);
     for(auto tp:tv)
     {
      pq[ma[tp.first]].erase({aa[i],tp.second});
      qp[mb[aa[i]]].erase(tp);
      nn.push_back(tp.second);
     }
  }
  for(auto t:nn)dfs(t,k);
}
ll cal(ll x,ll y,ll k)
{
  vector<ll> aa={x+k,x-k,y+k,y-k},bb={y-k,y-k,x-k,x-k};
  ll res=0;
  rep(i,2)
 {
   if(!ma.count(aa[i]))continue;
   ll idx=ma[aa[i]];
   auto s=lower_bound(all(p[idx]),bb[i]),t=upper_bound(all(p[idx]),bb[i]+2*k);
   res+=t-s;
 }
 repi(i,2,4)
 {
   if(!mb.count(aa[i]))continue;
   ll idx=mb[aa[i]];
   auto s=lower_bound(all(q[idx]),bb[i]+1),t=upper_bound(all(q[idx]),bb[i]+2*k-1);
   res+=t-s;
 }
 return res;
}

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

  ll  n,a,b;
  cin>>n>>a>>b;
  a--;b--;
  ll cnt=0;
  xy.resize(n);
  rep(i,n)
  {
    ll x,y;
    cin>>x>>y;
    xy[i]={x+y,x-y};
    mb[x-y]=cnt;
    ma[x+y]=cnt++;
  }
  pq.resize(cnt);
  qp.resize(cnt);
  p.resize(cnt);
  q.resize(cnt);
  rep(i,n)
  {
    ll id=ma[xy[i].first];
    pq[id].insert({xy[i].second,i});
    p[id].push_back(xy[i].second);
    id=mb[xy[i].second];
    qp[id].insert({xy[i].first,i});
    q[id].push_back(xy[i].first);
  }
  rep(i,cnt)
  {
    sort(all(p[i]));
    sort(all(q[i]));
  }
  used.resize(n,0);
  ll k=abs((xy[a].first+xy[a].second)-(xy[b].first+xy[b].second))+abs((xy[a].first-xy[a].second)-(xy[b].first-xy[b].second));
  k/=2;
  dfs(a,k);
  ll res=0;
  rep(i,n)
  {
    if(used[i]){res+=cal(xy[i].first,xy[i].second,k);}
  }
  cout<<res/2<<endl;


  return 0;

}


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

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#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 all(x)  (x).begin(), (x).end()
#define MAX powl(2, 63)-1
using namespace std;
typedef long long ll;

int main(){
  string N; cin >> N;
  int ans=0;
  for(char n:N){
    if(n=='2')  ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a,b,c,x=0;
   cin >> a>>b>>c;
   for (int i=a; i<=b; i++)
   {
       if (i%c==0)
       {
           ++x;
       }
   }
   cout << x;
   return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      b.insert(b.begin(), a[i]);
    } else {
      b.push_back(a[i]);
    }
  }
  if (n % 2 == 0) reverse(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    cout << b[i];
    if (i == n - 1)
      cout << endl;
    else
      cout << " ";
  }
}

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


int main(){
    ll n,k; cin>>n>>k;
    vector<ll> snuke(n, 0);
    rep(i,k){
        ll d; cin>>d;
        rep(j,d){
            ll a; cin>>a;
            snuke[a-1]++;
        }
    }
    ll res=0;
    rep(i,n){
        if(snuke[i] == 0) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=',')cout<<a[i];
        else cout<<" ";
    }
    
    
    return 0; 
}

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

using namespace std;

const int INF = 1 << 30;

int N, A[1 << 18];

int dfs(int l, int r) {
  if(l + 1 == r) return A[l];
  auto X = dfs(l, (l + r) >> 1);
  auto Y = dfs((l + r) >> 1, r);
  return abs(X - Y);
}

int main() {
  cin >> N;
  for(int i = 0; i < 1 << N; i++) {
    cin >> A[i];
  }
  cout << dfs(0, 1 << N) << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
LL INF = 1e17;
double EPS=1.0e-9;
double PI=atan2(0,-1);

int main()
{
    string s;
    cin>>s;
    REP(i,4)
    {
        cout<<s[i];
    }
    cout<<" ";
    REP(i,8)
    {
        cout<<s[i+4];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string s;
int K;
vector<string> str(25000, "zzzzzzzzz");

int main()
{
  cin >> s >> K;
  for (int i = 0; i < 5; i++)
  {
    for (int j = 0; j + i < s.size(); j++)
    {
      string temp = "";
      for (int h = 0; h <= i; h++)
      {
        temp += s[j + h];
      }
      str[i * s.size() + j] = temp;
    }
  }
  sort(str.begin(), str.end());
  auto res = unique(str.begin(), str.end());
  str.erase(res, str.end());
  cout << str[K - 1] << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long n;
int main(){
	cin >>n;
	for(register int i=sqrt(n);i>=1;i--){
		if(n%i==0){
			cout<<i-1+n/i-1<<endl;return 0;
		}
	}
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(d<=a)cout<<d;
	else {
		if(d<=b)cout<<a;
		else cout<<a-(d-b-a);
	} 
return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        // educational dp 1

        int n = sc.nextInt();
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }
        long[] dp = new long[n];
        Arrays.fill(dp, -1);
        dp[0] = 0;

        for (int i = 0; i < n - 1; i++) {
            long cost1 = Math.abs(list[i] - list[i + 1]) + dp[i];
            if (dp[i+1] == -1) {
                dp[i+1] = cost1;
            } else {
                dp[i+1] = Math.min(dp[i+1], cost1);
            }

            if (i != n - 2) {
                long cost2 = Math.abs(list[i] - list[i + 2]) + dp[i];
                if (dp[i+2] == -1) {
                    dp[i+2] = cost2;
                } else {
                    dp[i+2] = Math.min(dp[i+2], cost2);
                }
            }
        }
        System.out.println(dp[n - 1]);
    }
}

Measured memory_bytes: 48932
#include <iostream>

using namespace std;


    int main(){
int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12) printf("YYMM\n");
else printf("NA\n");



    return 0;

}
    }


Measured memory_bytes: 3124
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 X              PIC 9(10).
01 dv             PIC 9(10).
01 dv5            PIC 9(10).
01 rm             PIC 9(10).
01 ans            PIC 9(10).
01 zs             PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT X.
  COMPUTE dv = X / 500.
  COMPUTE rm = X - dv * 500.
  COMPUTE dv5 = rm / 5.
  COMPUTE ans = dv * 1000 + dv5 * 5.
  MOVE ans TO zs.
  DISPLAY zs.
  STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=2019;

const int N=200005;

int pw(int a,int p=M-2,int MOD=M){
	int result = 1;
	while (p > 0) {
		if (p & 1)
			result = a * result % MOD;
		a = a * a %MOD;
		p >>= 1;
	}
	return result;
}

int a[N];
int cnt[3000];


void solve(){
	string s;
	cin>>s;
	int n=sz(s);
	rep(i,1,n+1){
		a[i]=(s[i-1]-'0')*pw(10,n-i)%M;
		a[i]=(a[i]+a[i-1])%M;
		// cout<<a[i]<<"\n";
	}
	
	int ans=0;
	cnt[0]=1;
	rep(i,1,n+1){
		ans+=cnt[a[i]];
		cnt[a[i]]++;
	}
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 5328
MOD = 10 **9 + 7
INF = 10 ** 10

def main():
    n = int(input())
    T = list(map(int,input().split()))
    A = list(map(int,input().split()))
    mountainT = [-1] * n
    mountainT[0] = T[0]
    for i in range(1,n):
        if T[i - 1] != T[i]:
            mountainT[i] = T[i]
    
    mountainA = [-1] * n
    mountainA[-1] = A[-1]
    for i in range(n - 1,0,-1):
        if A[i - 1] != A[i]:
            mountainA[i - 1] = A[i - 1]
    
    ans = 1
    for i in range(n):
        if mountainA[i] != -1 and mountainT[i] != -1:
            if mountainT[i] != mountainA[i]:
                ans = 0
                break
        elif mountainA[i] != -1:
            if mountainA[i] > T[i]:
                ans = 0
                break
        elif mountainT[i] != -1:
            if mountainT[i] > A[i]:
                ans = 0
                break
        else:
            ans *= min(T[i],A[i])
            ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18752
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let w = scan.next::<i32>();
    let h = scan.next::<i32>();
    let x = scan.next::<i32>();
    let y = scan.next::<i32>();
    let r = scan.next::<i32>();

    if x - r < 0 || x + r > w || y - r < 0 || y + r > h {
        writeln!(out, "No").ok();
    } else {
        writeln!(out, "Yes").ok();
    }
}



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

card = []
for suit in range(4):
    st = []
    for rank in range(14):
        st.append(False)
    card.append(st)
#print(card)

for i in range(n):
    suit,rank = input().split()
    suit = "SHCD".index(suit)
    rank = int(rank)
    card[suit][rank] = True
    
    
for suit in range(4):
    for rank in range(1,14):
        if card[suit][rank] == False:
            print("SHCD"[suit],rank)


Measured memory_bytes: 5600
n = str(input())
k = int(input())
dp = [[[0] * (k+1) for i in range(2)] for j in range(len(n)+1)]
dp[0][0][0] = 1
for i in range(len(n)):
    for j in range(k+1):
        if n[i] == "0":
            dp[i+1][0][j] = dp[i][0][j]
            dp[i+1][1][j] = dp[i][1][j]
            if j > 0:
                dp[i+1][1][j] += dp[i][1][j-1]*9
        else:
            dp[i+1][1][j] = dp[i][0][j] + dp[i][1][j]
            if j > 0:
                dp[i+1][0][j] = dp[i][0][j-1]
                dp[i+1][1][j] += dp[i][0][j-1] * (int(n[i])-1) + dp[i][1][j-1] * 9
  # print(dp)
print(dp[-1][0][k] + dp[-1][1][k])

Measured memory_bytes: 3064
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int n;
int w[100005][3];
int dp[100005][3];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>w[i][0]>>w[i][1]>>w[i][2];
	}
	dp[1][0]=w[1][0];
	dp[1][1]=w[1][1];
	dp[1][2]=w[1][2];
	for(int i=2;i<=n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+w[i][j]);
			}
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

	return 0;
}


Measured memory_bytes: 2560
N = int(input())
T=[0];X=[0];Y=[0]
for i in range(N):
    t,x,y=map(int,input().split())
    T.append(t);X.append(x);Y.append(y)
def check(t,x,y):
    if t < x+y:
        return False
    elif (x+y-t)%2==0:
        return True
    else:
        return False
for i in range(N):
    if check(T[i+1]-T[i],abs(X[i+1]-X[i]),abs(Y[i+1]-Y[i])):
        pass
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 65880
#include <iostream>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    int values[N];
    for (int i {}; i < N; i++)
        std::cin >> values[i];
    int copy[N];
    for (int i {}; i < N; i++)
        copy[i] = values[i];
    std::sort(values, values + N);
    for (int i {}; i < N; i++)
    {
        if (copy[i] == values[N-1])
            std::cout << values[N-2] << std::endl;
        else
            std::cout << values[N - 1] << std::endl;
    }
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int cnt = 0;
        for (int i = a; i <= n; i++) {
            int x = i;
            int total = x % 10;
            while (x >= 10) {
                x /= 10;
                total += x % 10;
            }
            
            if (total >= a && total <= b)
                cnt += i;
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i,lon,flag=0,j;
	char s[200];
	scanf("%s",s);
	
	lon=strlen(s);
	
	for(i=0;i<lon;i++){
		if(s[i]=='C'){
			for(j=i+1;j<lon;j++){
				if(s[j]=='F'){
					flag++;
				}
			}
		}
	}
	
	if(flag!=0){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}

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

int main()
{
    int n, s[100005], q, t[50005];
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> s[i];
    cin >> q;
    int right, left, mid, count = 0;
    for(int i=0; i<q; i++)
    {
        cin >> t[i];
        right = n;
        left = 0;
        while(left < right)
        {
            mid = (left+right)/2;
            if(s[mid]==t[i])
            {
                count++;
                break;
            }
            else if(s[mid]>t[i])
            {
                right = mid;
            }
            else if(s[mid]<t[i])
            {
                left = mid+1;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3564
#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 N;
    cin >> N;
    vector<pair<int, int>> BA(N);
    rep(i, N) cin >> BA[i].second >> BA[i].first;
    sort(BA.begin(), BA.end());
    //rep(i, N) cout << BA[i].first << " " << BA[i].second << endl;
    ll A = 0, B = 0;
    string ans = "Yes";
    rep(i, N) {
        A += BA[i].second;
        B = BA[i].first;
        //cout << i << " " << A << " " << B << endl;
        if (A > B) ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  if (N<105) {
    ans=0;
  }
  else {
    if (N<135) {
      ans=1;
    }
    else {
      if (N<165) {
        ans=2;
      }
      else {
        if (N<189) {
          ans=3;
        }
        else {
          if (N<195) {
            ans=4;
          }
          else {
            ans=5;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	cin >> n;
	cout << fixed << setprecision(8);
	cout << (double)n*2*M_PI << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n, k;
	cin >> n >> k;

	vector<int> v(n), w(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}

	vector<vector<int>> dp(n + 1, vector<int>(k + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			} else {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}

	cout << dp[n][k] << endl;
	return 0;
}



Measured memory_bytes: 6756
from collections import deque

N,M,K = list(map(int,input().split()))

# N,M,K = [10,random.randint(1,10),random.randint(1,10)]

ad={} #友達関係
block={} #ブロック
for n in range(N):
    n=n+1
    ad[n]=set([])
    block[n]=set([])
    
for m in range(M):
    m1,m2 = list(map(int,input().split()))
    ad[m1].add(m2)
    ad[m2].add(m1)

for k in range(K):
    k1,k2 = list(map(int,input().split()))
    block[k1].add(k2)
    block[k2].add(k1)

visit = deque([])
color={}
tree={}
t=0
for n in range(N):
    n=n+1
    color[n] = -1
    tree[n] = -1
    
start_ = 1
    
while len(visit) < N:
    t += 1
    for c_k in range(start_,N):
        if color[c_k] == -1:
            start = c_k
            start_ = start + 1
            break
    color[start] = 0
    tree[start] = t
    visit_temp=deque([start])

    while len(visit_temp) > 0: #BFS
        start=visit_temp[0]
        for v in ad[start] :
            if color[v] == -1: #未訪問
                visit_temp.append(v)
                color[v] = 0
                
        color[start] = 1
        tree[start] = t
        
        pop_ = visit_temp.popleft()
        visit.append(pop_)
        
tree_={}
for v in set(tree.values()):
    tree_[v]=set()
    
for k in set(tree.keys()):
    tree_[tree[k]].add(k)
    
ans=[]
for n in range(N):
#     print('===')
    n=n+1
    
    tree_len=len(tree_[tree[n]])
    friend_len=len(ad[n])
    
    brock_len=0
    for b in block[n]:
        if tree[n] == tree[b]:
            brock_len += 1
            
#     print(tree_len,friend_len,brock_len)
#     print(tree_len-friend_len-brock_len-1)
    ans.append(tree_len-friend_len-brock_len-1)
            
print(' '.join(map(str,ans)))

Measured memory_bytes: 205832
n = int(input())
lst = [int(i) for i in input().split()]

min_n = min(lst)
max_n = max(lst)
min_count = 1000000000
for i in range(min_n, max_n + 1):
  count = 0
  for j in range(n):
    count += (lst[j] - i) ** 2
  if count < min_count:
    min_count = count
print(min_count)


Measured memory_bytes: 63908
#N = int(input())
L = list(map(int, input()))
L0 = 0
L1 = 0
for i, n in enumerate(L):
    if i % 2 == 0:
        if n == 1:
            L1 += 1
        else:
            L0 += 1
    else:
        if n == 0:
            L1 += 1
        else:
            L0 += 1
print(min(L1, L0))


Measured memory_bytes: 45020
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  ll sum = 0;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  ll s = 0;
  ll ans = INF;
  rep(i, N) {
    if (i == N - 1) {
      continue;
    }
    s += A[i];
    ll b = sum - s;
    ans = min(ans, abs(s - b));
  }
  COUT(ans);
  return 0;
}

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

int N = 200010;
int main(){
    string s;
    cin >> s;
    bool A[N]; for(int i=0; i<N;++i) A[i]=false;
    bool Z[N]; for(int i=0; i<N;++i) Z[i]=false;

    for(int i=0; i<s.size();++i){
        if(s[i] == 'A') A[i] = true;
        if(s[i] == 'Z') Z[i] = true;
    } 
    int start=0, end=0;
    for(int i=0; i<N;++i){
        if(A[i] == true){
            start = i;
            break;
        }
    }
    
    for(int i=N; i>0;--i){
        if(Z[i] == true){
            end = i;
            break;
        }
    }
    
    int n = end - start + 1;
    cout << n << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        int N;
     
        cin >> N;
     
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                if (N == (i * j))
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
     
        cout << "No" << endl;
        return 0;
    }

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

using ll = long long;

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

	ll ans = (n/(a+b))*a + (n%(a+b)>=a ? a : n%(a+b));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {

    int N;
    cin >> N;
    int result =0;

    for(int i=1;i<=N;i++){
        if((to_string(i)).length()%2!=0){
            result++;

        }
    }

    cout << result << endl;


}








Measured memory_bytes: 256