akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    //入力
    int n;
    cin >> n;
    vector<int>yama(n);
    for(int i=0;i<n;i++)
    {
        cin >> yama[i];
    }

    //処理
    int ans=1;
    int max_=yama[0];
    for(int i=1;i<n;i++)
    {
        if(max_<=yama[i])
        {
            ans++;
            max_=yama[i];
        }
    }

    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long long t,i,j,n,a,b,c,d,ans,A,B,x,y,k,one,q,l,r;
	string s,s1,s2,s3;
	cin>>n;
	int arr[125]={0},brr[125]={0};
	cin>>s;
	    for(j=0;j<s.length();j++)
	        arr[s[j]]++;
	
	for(i=1;i<n;i++)
	{
	    cin>>s;
	    for(j=0;j<s.length();j++)
	        brr[s[j]]++;
	    for(k=0;k<125;k++)
	    {
	        arr[k]=min(arr[k],brr[k]);
	    }
	    for(k=0;k<125;k++)
	    {
	        brr[k]=0;
	    }

	}
	for(i=0;i<124;i++)
	{
	    cout<<string(arr[i],char(i));
	   //cout<<arr[i];
	}
	
	
    }

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long sumNone = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sumNone += i;
        }
    }
    cout << sumNone << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
const int N=1e5+10;
const long long int INF=1e16+10;
int max(int a,int b){return a>b?a:b;}
long long int min(long long int a,long long int b){return a>b?b:a;}
int main(){
  int n,w,p,v,ans=0;
  long long int a[N];
  scanf("%d%d",&n,&w);
  for(int i=1;i<N;i++)a[i]=INF;
  a[0]=0;
  for(int i=0;i<n;i++){
    scanf("%d%d",&p,&v);
    for(int j=N-1;j>=v;j--)a[j]=min(a[j],a[j-v]+p);
  }
  for(int i=N-1;i>=0;i--)if(a[i]<=w){
  	ans=i;
    break;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 896
/*
    Take me to church
    I'll worship like a dog at the shrine of your lies
    I'll tell you my sins and you can sharpen your knife
    Offer me that deathless death
    Good God, let me give you my life
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, L, R, A[N];
long long dp[N];
int main()
{
    scanf("%d%d%d", &n, &R, &L);
    for (int i = 1; i <= n; i ++)
        scanf("%d", &A[i]);
    n ++; A[n] = n;
    for (int i = 1; i <= n; i ++)
    {
        int cnt = 0;
        dp[i] = LLONG_MAX;
        for (int j = i - 1; ~ j; j --)
            if (A[j] < A[i])
                dp[i] = min(dp[i], dp[j] + cnt * 1LL * L + (i - j - 1 - cnt) * 1LL * R), cnt ++;
    }
    return !printf("%lld\n", dp[n]);
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 3e3 + 3;

int dp[maxn][maxn];
string kata1, kata2;

void trace(int r, int c) {
	char ans[3001];
	int rawal = r, cawal = c;
	int idx = dp[r][c];
	while(r > 0 && c > 0){
		if(kata1[r-1] == kata2[c-1]){
			// printf("r: %d c: %d %c\n",r,c,kata1[r-1]);
			ans[idx] = kata1[r-1];

			r--; c--; idx--;
		}else if(dp[r-1][c] > dp[r][c-1]){
			r--;
		}else{
			c--;
		}
	}
	for(int i=1;i<=dp[rawal][cawal];i++){
		printf("%c",ans[i]);
	}
	printf("\n");
}

int main(){
	int i,j;
	cin>>kata1>>kata2;
	int pjg1 = kata1.length(), pjg2 = kata2.length();
	for(i=1;i<=pjg1;i++){
		for(j=1;j<=pjg2;j++){
			if(kata1[i-1] == kata2[j-1]){
				dp[i][j] = max(1 + dp[i-1][j-1], max(dp[i-1][j], dp[i][j-1]));
			}else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	// for(i=1;i<=pjg1;i++){
	// 	for(j=1;j<=pjg2;j++){
	// 		printf("%d ",dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	// printf("%d\n",dp[pjg1][pjg2]);
	trace(pjg1, pjg2);
	// for(i=ans.length()-1;i>=0;i--){
	// 	printf("%c",ans[i]);
	// }
	// printf("\n");
	return 0;
};

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

int main(void)
{
  std::string S, T;
  std::cin >> S >> T;

  int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      cnt++;
    }
  }
  std::cout << cnt << std::endl;
}

Measured memory_bytes: 3912
MOD = 10 ** 9 + 7
def mod_fact(n):
  ret = 1
  for i in range(1, n + 1):
    ret = (ret * i) % MOD
  return ret

n = int(input())
AB = []
for i in range(2 * n):
  AB.append((int(input()), i//n)) # i//n: 0=a, 1=b

AB.sort()

a, b = 0, 0
ans = 1
for i, j in AB:
  if j == 0:
    if b == 0:
      a += 1
    else:
      ans = (ans * b) % MOD
      b -= 1
  else:
    if a == 0:
      b += 1
    else:
      ans = (ans * a) % MOD 
      a -= 1
print(ans % MOD)

Measured memory_bytes: 24476
H, W = map(int, input().split())
gridgraph = [input() for _ in range(H)]

dp = [[10000]*W for _ in range(H)]

if gridgraph[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

adjacent = [[1, 0], [0, 1]]

for i in range(H):
    for j in range(W):
        for dy, dx in adjacent:
            ny = i+dy
            nx = j+dx
            if ny == H or nx == W:
                continue
            # 壁の中に移動する時
            if gridgraph[i][j] == "." and gridgraph[ny][nx] == "#":
                dp[ny][nx] = min(dp[i][j]+1, dp[ny][nx])
            else:
                dp[ny][nx] = min(dp[i][j], dp[ny][nx])
print(dp[H-1][W-1])


Measured memory_bytes: 9212
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    vector<int> vec(n);
    for (int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        vec.at(a-1)++;
        vec.at(b-1)++;
    }
    for(int i=0;i<n;i++){
        cout<<vec.at(i)<<endl;
    }
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
if a>b :
  if b>c :
    print(c,b,a)
  elif a>c :
    print(b,c,a)
  else :
    print(b,a,c)
elif a>c :
  print(c,a,b)
elif c>b :
  print(a,b,c)
else :
  print(a,c,b)


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

int m,n;
int w[222222];
int t[222222];
int c[222222];
int b[222222];

int dp[1<<16];

vector<int>A,B;

main(){

  A.push_back(0);
  B.push_back(0);

  
  cin>>m>>n;
  r(i,m) cin>>w[i]>>t[i] , A.push_back(w[i]) , B.push_back(t[i]);
  r(i,n) cin>>c[i]>>b[i];

  r(i,m){
    A[i+1] += A[i];
    B[i+1] += B[i];
  }

  A.push_back(4e18);
  B.push_back(4e18);

  dp[0]=0;

  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      if(i&(1<<j))continue;
      
      int ai = upper_bound(A.begin(),A.end(),A[dp[i]]+c[j]) - A.begin(); ai--;
      int bi = upper_bound(B.begin(),B.end(),B[dp[i]]+b[j]) - B.begin(); bi--;
      int x = min( ai , bi );
      //cout<<x<<endl;
      dp[i|(1<<j)] = max(dp[i|(1<<j)],x);
    }
  }

  cout<< dp[(1<<n)-1] <<endl;
  
}



Measured memory_bytes: 9644
local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local function getdivisorparts(x, primes)
  local prime_num = #primes
  local tmp = {}
  local lim = mce(msq(x))
  local primepos = 1
  local dv = primes[primepos]
  while primepos <= prime_num and dv <= lim do
    if x % dv == 0 then
      local t = {}
      t.p = dv
      t.cnt = 1
      x = mfl(x / dv)
      while x % dv == 0 do
        x = mfl(x / dv)
        t.cnt = t.cnt + 1
      end
      table.insert(tmp, t)
      lim = mce(msq(x))
    end
    if primepos == prime_num then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if x ~= 1 then
    local t = {}
    t.p, t.cnt = x, 1
    table.insert(tmp, t)
  end
  return tmp
end

local function getdivisorCore(divisorparts)
  local t = {}
  local pat = 1
  local len = #divisorparts
  local allpat = 1
  for i = 1, len do
    allpat = allpat * (1 + divisorparts[i].cnt)
  end
  for t_i_pat = 0, allpat - 1 do
    local div = allpat
    local i_pat = t_i_pat
    local ret = 1
    for i = 1, len do
      div = mfl(div / (divisorparts[i].cnt + 1))
      local mul = mfl(i_pat / div)
      i_pat = i_pat % div
      for j = 1, mul do
        ret = ret * divisorparts[i].p
      end
    end
    table.insert(t, ret)
  end
  -- table.sort(t)
  return t
end

local function getdivisor(x, primes)
  local dvp = getdivisorparts(x, primes)
  return getdivisorCore(dvp)
end

local n = io.read("*n")
local primes = getprimes(mce(msq(n)))
local divs = getdivisor(n, primes)
local ret = 0
for i = 1, #divs do
  local mp1 = divs[i]
  local k = n // mp1
  if k < mp1 - 1 then
    ret = ret + mp1 - 1
  end
end
print(ret)

Measured memory_bytes: 18808
#include<iostream>
using namespace std;
int main(){
    int count[4][3][10] = {};
    int n;
    cin >> n;
    int ren, kai, bangou, ninzu;
    
    for(int x = 1; x <= n; x++){
        cin >> ren >> kai >> bangou >> ninzu;
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 10; k++){
                    if((i + 1 == ren) && (j + 1 == kai) && (k + 1 ==bangou)){
                        count[i][j][k] += ninzu;
                    }
                }
                
            }
        }  
        
    }
    

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                    
            cout << " " << count[i][j][k];
                    
                
            } 
            cout << endl;
        }
        if(i != 3){
            cout << "####################" << endl;
        }
        
    }  
        
    
  
   
    return 0;

}


Measured memory_bytes: 3080
#include<stdio.h>

int main(){
	int a[3], i, tmp, j;
	for(i = 0; i < 3; i++) scanf("%d", &a[i]);
	for(i = 0; i < 2; i++){
		for(j = i + 1; j < 3; j++){
			if(a[i] > a[j]){
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main() {
   int x, h, m, s;

   scanf("%d\n", &x);

   s = x % 60;
   x = (x - s) / 60;
   m = x % 60;
   x = (x - m) / 60;
   h = x;

   printf("%d:%d:%d\n", h, m, s);

}

Measured memory_bytes: 1848
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const [H, W, K] = lines[0].split(" ").map(Number)
    lines.shift()

    const createMap = () => {
        const map = Array(H).fill([])
        for (let h = 0; h < H; h++) {
            map[h] = lines[h].split("")
        }
        return map
    }

    const c = (map) => {
        let count = 0
        for (let i = 0; i < H; i++) {
            for (let j = 0; j < W; j++) {
                if (map[i][j] === '#') {
                    count++
                }
            }
        }
        return count
    }
    const OH = (map, h) => {
        if (!h) {
            return map
        }
        for (let i = 0; i < W; i++) {
            map[h - 1][i] = '*'
        }
        return map
    }
    const OW = (map, w) => {
        if (!w) {
            return map
        }
        for (let i = 0; i < H; i++) {
            map[i][w - 1] = '*'
        }
        return map
    }

    let count = 0
    const P = Math.pow(2, H + W)
    for (let i = 0; i < P; i++) {
        const map = createMap()
        for (let j = 0; j < H; j++) {
            const h = i & Math.pow(2, j) ? j + 1 : 0
            OH(map, h)
        }
        for (let j = 0; j < W; j++) {
            const w = i & Math.pow(2, H + j) ? j + 1 : 0
            OW(map, w)
        }
        if (c(map) === K) {
            count++
        }
    }

    console.log(count)

})(input)


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

int main() {
    int x;
    cin >> x ;
    bool primeFlag = true;
    if(x<= 3 || x == 5 || x == 7){
        // ルートにして3より小さくなる素数はそのまま出力
    }else{
        while(primeFlag){
            //2の倍数であればスキップ(多いので)
            if(x % 2 == 0){
                x++;
                continue;
            }
            // 素数を見つける試し割法
            int sqrtNum = sqrt(x);
            for(int i = 3; i <= sqrtNum; i+=2){
                if(x % i == 0){
                    x++;
                    primeFlag = true;
                    break;
                }
                primeFlag = false;
            }
        }
    }
    cout << x << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const ll MOD = 1000000007;

int binsearch_lower_bound(vector<int> &vec, int val)
{
    int low = 0;           // ???????????????
    int high = vec.size(); // ???????????????????§£???????????° [low, high] ??????????????¨??????
    while (low < high)
    {
        int mid = (low + high) / 2; // ??????????????????????£???§????????????????????????????????????
                                    // ??????????????? mid=low+(high-low)/2 ??¨????????????
        int midval = vec[mid];      // ????????§??????

        // ?§£?????????????????????
        if (midval < val)
            low = mid + 1;
        else
            high = mid;
    }
    return low;
}

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

    int n, t;
    cin >> n >> t;
    std::vector<int> v;
    for (int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        v.push_back(d);
    }
    sort(v.begin(), v.end());
    ll res = 1;
    for (int i = 1; i < n; i++)
    {
        if (v[i - 1] >= v[i] - t)
        {
            int idx = binsearch_lower_bound(v, v[i] - t);
            res = (res * (i - idx + 1)) % MOD;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c;
    else if(b==c)
        cout<<a;
    else
        cout<<b;
    cout<<nl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M = map(int,(input().split()))
c = []
bridge = []
nax = 0
for i in range(M):
    a,b = map(int,(input().split()))
    c.append((a,b))
c.sort(key=lambda x:x[1])

for i in range(M):
    if c[i][0] > nax:
        bridge.append(c[i][1]-1)
        nax = c[i][1]-1

print(len(bridge))

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

int main() {	

	ll n; cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 1;
	ll zeroCnt = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] == 0) {
			zeroCnt++;
			continue;
		}
		if (ans > 1000000000000000000LL / a[i]) {
			ans = -1;
			break;
		}
		else {
			ans *= a[i];
		}	
	}
	if (zeroCnt > 0) cout << 0 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3960
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;
#include <cassert>
#include <vector>

template <class T = int> static bool is_prime(T x) {
    if (x <= 1)
        return false;

    if (x % 2 == 0 || x % 3 == 0 || x % 5 == 0 || x % 7 == 0)
        return false;

    for (T d = 11; d * d <= x; d += 6) {
        if (x % d == 0)
            return false;
        if ((d + 2) * (d + 2) <= x && x % (d + 2) == 0)
            return false;
    }

    return true;
}

template <class T = int> static std::vector<T> gen_prime(T maxval) {
    assert(maxval >= 10);

    auto p = std::vector<T>();
    p.reserve(maxval / 7 + 5);
    p.push_back(2);
    p.push_back(3);
    p.push_back(5);
    p.push_back(7);

    for (T x = 11; x <= maxval; x += 6) {
        if (is_prime(x))
            p.push_back(x);
        if (x + 2 <= maxval && is_prime(x + 2))
            p.push_back(x + 2);
    }

    return p;
}

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

    const auto factors = gen_prime(1'001'000);
    auto fcount = 1LL; // divisor of 1

    for (const auto d : factors) {
        if (!(d <= a && d <= b))
            break;

        auto acnt = 0;
        auto bcnt = 0;
        while (a % d == 0) {
            a /= d;
            acnt++;
        }
        while (b % d == 0) {
            b /= d;
            bcnt++;
        }
        if (acnt && bcnt) {
            cerr << "D " << d << "\n";
            fcount++;
        }
    }
    if (a > 1 && a == b) {
        fcount++;
    }

    cout << fcount << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

ll n;
ll a[3001];

// dp[i][j] :
//  ai+1からajでゲームをするときのX-Yの最大値
//  ただし、手番は「元のゲームを行ってその局面になった時の手番」とする
int main(){
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }
    ll dp[n+1][n+1];
    rep(i, n+1) rep(j, n+1) dp[i][j] = 0;
    for(int len = 1; len <= n; len++){
        for(int l = 0; l < n - len + 1; l++){
            int r = l + len;
            dp[l][r] = max(a[l]-dp[l+1][r], a[r-1] - dp[l][r-1] );
        }
    }


    cout << dp[0][n] << endl;

}

Measured memory_bytes: 70656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define inf 0x7fffffff
using namespace std;
long long l=2,r=2;
int main()
{  int n;
	cin>>n;
	int a[n+1];
	for(int i=n;i>=1;i--)cin>>a[i];
	for(int i=1;i<=n;i++){
		l=a[i]*((l+a[i]-1)/a[i]);
		r=a[i]*((r+a[i])/a[i])-1;
		if(r<l){cout<<"-1";return 0;}
	}
	cout<<l<<" "<<r;
	return 0;
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e6;

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

  int W; cin >> W;
  VI xs(W); REP(i,W) cin >> xs[i];
  
  VI num(W,-1);
  int tmp = -1;
  REP(x,W){
	if(xs[x] == 0) tmp = INF;
	else if(xs[x] > 0){
	  if(0 <= tmp && tmp < INF) --tmp;
	  num[x] = max(num[x], tmp);
	}
	else{
	  if(0 <= tmp && tmp < INF) --tmp;
	  tmp = min(tmp, abs(xs[x]) - 1);
	}
  }

  tmp = -1;
  for(int x=W-1;x>=0;--x){
	if(xs[x] == 0) tmp = INF;
	else if(xs[x] > 0){
	  if(0 <= tmp && tmp < INF) --tmp;
	  num[x] = max(num[x], tmp);
	}
	else{
	  if(0 <= tmp && tmp < INF) --tmp;
	  tmp = min(tmp, abs(xs[x]) - 1);
	}
  }

  int ans = 0;
  REP(x,W){
	if(xs[x] > 0) ans += min(num[x]+1, xs[x]);
  }
  cout << ans << endl;
  
  return 0;
}

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

const int nm = 1e3;
int n, k, p[nm];
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	sort(p,p+n);
	int m=0;
	for (int i = 0; i < k; ++i)
	m+=p[i];
	cout<<m<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    string s;
    int time[24 * 3600] = {};
    rep(i, n) {
      cin >> s;
      time[stoi(s.substr(0, 2)) * 3600 + stoi(s.substr(3, 2)) * 60 + stoi(s.substr(6, 2))]++;
      cin >> s;
      time[stoi(s.substr(0, 2)) * 3600 + stoi(s.substr(3, 2)) * 60 + stoi(s.substr(6, 2))]--;
    }
    int maxi = 0, tmp = 0;
    rep(i, 24 * 3600) {
      tmp += time[i];
      maxch(maxi, tmp);
    }
    cout << maxi << endl;
  }

  return 0;
}

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

int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a * b < c * d) { cout << c * d; }
	else { cout << a * b; }
	return 0;
}

Measured memory_bytes: 256
def isPalindrome(n):
    s = str(n); l = len(s);
    for i in xrange(l/2):
        if s[i]!=s[-1-i]:
            return False
    return True
n = input()
p = q = n
while isPalindrome(p)==False:
    p += 1
while isPalindrome(q)==False:
    q -= 1
print q if abs(n-q)<=abs(p-n) else p

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,m;cin>>n>>m;
  if(m/2<=n){
    res=m/2;
  }
  else{
    res=n+(m/2-n)/2;
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int N,K,C;
string S;

int L[200010];
int R[200010];

int main ()
{
    cin >> N >> K >> C >> S;

    int pre = 0;
    int tmp = -1e9;
    for (int i = 1; i <= K; i++) {
        while (S[pre] == 'x' || abs(tmp - pre) <= C) pre++;
        L[i] = pre;
        tmp = pre;
        pre++;
    }

    pre = N - 1;
    tmp = 1e9;
    for (int i = K; i >= 1; i--) {
        while (S[pre] == 'x' || abs(tmp - pre) <= C) pre--;
        R[i] = pre;
        tmp = pre;
        pre--;
    }

    for (int i = 1; i <= K; i++) {
        cerr << L[i]<< " ";
    }
    cerr << endl;
    for (int i = 1; i <= K; i++) {
        cerr << R[i] << " ";
    }
    cerr << endl;

    for (int i = 1; i <= K; i++) {
        if (L[i] == R[i]) {
            cout << L[i] + 1 << endl;
        }
    }

//    cout << cnt << endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n, s;
int inp[N];

int m = 998244353;

int dp[3234][3234];

int go(int pos, int rem){
  if(rem < 0) return 0;
  if(pos > n){
    return (rem == 0);
  }
  if(dp[pos][rem] != -1){
    return dp[pos][rem];
  }
  int ret = 0;
  ret = (ret + 1ll * go(pos + 1, rem) * 2 % m) % m;
  ret = (ret + 1ll * go(pos + 1, rem - inp[pos]) % m) % m;
  return dp[pos][rem] = ret;
}

int main(){
  fastScan(n);
  fastScan(s);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", go(1, s));
}


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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define ull unsigned long long
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define pl(x) cout << #x << "= " << x << endl;
const int inf = 0x3f3f3f3f;
const int N = 1e5+5;



int  main(){
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll m = sqrt(n+0.5);
    for(ll i=m; i>=1; i--){
        if(n%i == 0){
            int ans = 0;
            ll tmp = n/i;
            while(tmp>0){
                ans++;
                tmp /= 10;
            }
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int k,x;
  cin>>k>>x;
  if(500*k>=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List (sort)
import Control.Monad (replicateM)

main :: IO ()
main = do
    n <- readLn
    xs <- replicateM n readLn
    print $ length $ solve $ sort (xs :: [Integer])

solve :: Ord a => [a] -> [a]
solve [] = []
solve [x] = [x]
solve (x : y : xys) | x == y = solve xys
                    | otherwise = x : solve (y : xys)

Measured memory_bytes: 49532
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

int n;
int a[100005];


int main() {
  
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", &a[i]);
  
  sort(a, a+n);
  
  int x = a[n-1];
  int t = x/2;
  int mind = 1000000009;
  int y = -1;
  
  rep(i, 0, n-1) {
    int d = abs(t-a[i]);
    if (d <= mind) {
      y = a[i];
      mind = d;
    }
  }
  
  printf("%d %d\n", x, y);
  
  return 0;
}
 


Measured memory_bytes: 640
#4問目
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))

#すでに移動したことのある場所
already = [False] * N
step = 0
now = 1
count = 0
while(already[now-1] != True):
    already[now - 1] = True
    now = A[now - 1]
    count += 1
    if count == K:
      print(now)
      exit(0)
# count はstartから2度現れる点までの移動数

#ループに入るまで何回ステップがあったか調べる
# loop := ループに含まれる辺の個数
loop = 0
cycle = 0
if(now == 1):
    step = 0
    cycle = count
    loop = K % cycle
else:
    step = 0
    temp = 1
    while(temp != now):
        temp = A[temp - 1]
        step += 1
    cycle = count - step
    loop= (K - step) % cycle

temp = 1
for i in range(step + loop):
    temp = A[temp - 1]
print(temp)


Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n; cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    sort(a,a+n,greater<>());
    ll ans=0;
    ans+=a[0];
    for(ll i=1;i<n/2;i++) ans+=2*a[i];
    if(n%2) ans+=a[n/2];
    cout<<ans;
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}

Measured memory_bytes: 5224
Program KnapSack1;
uses math;
var V,W:Array[1..105] of longint;
    F:array[0..105,0..100005] of int64;
    n,i,j,maxx,k :longint;
    fi,fo:text;
//--------------------------------
begin
//assign(fi,'KnapSack1.inp');reset(fi);
readln(n,k);
for i:=1 to n do begin
                 Readln(W[i],V[i]);
                 end;
for j:=1 to k do begin
                 for i:=1 to n do begin
                                       if j-W[i]>=0 then F[i,j]:=max(F[i-1,j],V[i]+F[i-1,j-W[i]])
                                      else F[i,j]:=F[i-1,j];
                                      end;
                 end;
Writeln(F[n,k]);
//readln;
end.



Measured memory_bytes: 78848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long h = sc.nextLong(), n = sc.nextLong();
		long all =0;
		for(;n > 0; n--) {
			all += sc.nextLong();
		}
		if(all >= h) pw.print("Yes");
		else pw.print("No");
		pw.close();
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 31708
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
#define Mod(x) (((x) % mod + mod) % mod)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (998244353);
char str[maxn];
int main(){
    int n;scanf("%d",&n);
    int a = 0,w = 0,t = 0,r = 0;
    for(int i = 1;i <= n;i++){
        scanf("%s",str + 1);
        if(str[1] == 'A'){
            a++;
        }
        else if(str[1] == 'W'){
            w++;
        }
        else if(str[1] == 'T'){
            t++;
        }
        else{
            r++;
        }
    }
    printf("AC x %d\n"
           "WA x %d\n"
           "TLE x %d\n"
           "RE x %d\n",a,w,t,r);
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

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

  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  mint ans = 3;
  int start = 1, flg = 0;
  if (s1[0] != s2[0]) {
    ans = 6;
    start = 2;
    flg = 1;
  }
  rep(i, start, n) {
    int mul = 2;

    if (s1[i] != s2[i]) {
      flg++;
      i++;
    } else {
      if (flg > 0) {
        flg = 0;
        continue;
      }

      flg = 0;
    }

    if (flg >= 2)
      mul = 3;
    ans *= mul;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c,x,y=gets.split.map(&:to_i)
c*=2
N=[x,y].max
ans=Float::INFINITY
(N+1).times do |i|
    p1 = c*i
    p2 = [0,x-i].max * a
    p3 = [0,y-i].max * b
    jd = p1 + p2 + p3
    ans = jd < ans ? jd : ans
end
puts ans



Measured memory_bytes: 1788
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var h = o.a();
  var ans = 0, cnt = 1;
  while(h){
    ans += cnt;
    cnt *= 2;
    h = Math.floor(h/2);
  }
  return ans;
}

Measured memory_bytes: 21064
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int j = 0; j <= 7; j++){
        if(s.substr(0, j) + s.substr(s.size() - 7 + j) == "keyence"){
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    set<int>seta;
    cin>>n;
    while(n--)
    {
        cin>>a;
        seta.insert(a);
    }
    cout<<seta.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;

int main() {
    fastIO;
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        sum += x;
    }
    if (n >= sum) {
        cout << n - sum;
    }
    else {
        cout << -1;
    }
}

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

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

int main()
{
    int n, a; cin >> n >> a;
    
    if ((n % 500) > a) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
S = input()
lenS = len(S)
rui = [0] * 2019
rui[0] = 1
tmp = 1
m = 0
for i in range(lenS):
    m += int(S[-i - 1]) * tmp
    m %= 2019
    tmp *= 10
    tmp %= 2019
    rui[m] += 1

ans = 0
for i in rui:
    if i >= 2:
        ans += (i * (i - 1) // 2)

print(ans)


Measured memory_bytes: 9356
#include <iostream>

using namespace std;

using ll = long long;

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

  for (int i = 0; i < (int)s.size() - 1; ++i) {
    if (s[i] != 'a' && k >= (ll)'z' - s[i] + 1LL) {
      k -= (ll)'z' - s[i] + 1LL;
      s[i] = 'a';
    }
  }

  s[(int)s.size() - 1] = (s[(int)s.size() - 1] - (ll)'a' + k) % 26LL + 'a';

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
                for(int i=0;i<H;i++){
                    for(int j=0;j<W;j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
        } 
          sc.close();
    }

}


Measured memory_bytes: 62276
import static java.lang.Math.acos;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        double r=in.nextDouble();
        double pi=acos(-1.0);
        Double are=2*pi*r;
        Double toBeTruncated = new Double(are);

Double truncatedDouble = BigDecimal.valueOf(toBeTruncated)
    .setScale(3, RoundingMode.HALF_UP)
    .doubleValue();
        System.out.println(toBeTruncated);
    }
}

Measured memory_bytes: 37620
m, d = map(int, input().split())
d1 = d%10
d10 = int(d/10)
cnt  =0
for i in range(1, m+1):
    for j in range(1, d+1):
        m1 = i
        d1 = j%10
        d10 = int(j/10)
        if d1 >= 2 and d10 >= 2 and d1*d10 == m1:
            cnt += 1
print(cnt)

Measured memory_bytes: 39152
n = int(input())
a = list(map(int, input().split()))

dic = dict()
for i in a:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

cnt = 0
dic_v = list(dic.values())
for i in range(len(dic_v)):
    x = dic_v[i]
    cnt += int(x*(x-1)/2)
    
for k in range(n):
    print(cnt - (dic[a[k]]-1))

Measured memory_bytes: 87628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
int sum = 0;
vector<int> A;
vector<int> B;
vector<int> C;



int main() {
	int tmp;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> tmp;
		A.push_back(tmp);
	}
	for (int i = 0;i < N;i++) {
		cin >> tmp;
		B.push_back(tmp);
	}
	for (int i = 0;i < N - 1;i++) {
		cin >> tmp;
		C.push_back(tmp);
	}

	for (int i = 0;i < N;i++) {
		sum += B[A[i] - 1];
		if (i != N - 1) {
			if (A[i + 1] - A[i] == 1) {
				sum += C[A[i] - 1];
			}
		}
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int c[3][3];
    for(int i = 0; i < 3; i++){
        scanf("%d %d %d", &c[i][0], &c[i][1], &c[i][2]);

    }
    if (c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][1] - c[0][1] == c[1][2] - c[0][2] && c[2][0] - c[0][0] == c[2][1] - c[0][1] && c[2][1] - c[0][1] == c[2][2] - c[0][2]){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 128
N=int(input())
NT=N
cnt=0
ans=0
while NT//10:
  cnt+=1
  NT//=10
if cnt==0:
  ans=N
if cnt==1:
  ans=9
if cnt==2:
  ans=N-90
if cnt==3:
  ans=909
if cnt==4:
  ans=909+(N-9999)
if cnt==5:
  ans=90909
print(ans)

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

int main() {
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        int x;
        cin >> x;
        ans += x;
    }
    if(ans > 21)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}

Measured memory_bytes: 256
def check(x,j=1):
    if sum(x)==0: return True
    for i in range(j,10):
        if x[i]>0:break
    y = x[:]
    if y[i]>=3:
        y[i] -= 3
        if check(y,i): return True
    y = x[:]
    if i<8 and y[i]>0 and y[i+1]>0 and y[i+2]>0:
        y[i] -= 1
        y[i+1] -= 1
        y[i+2] -= 1
        if check(y,i): return True
    return False

while True:
    c = [0]*10
    try:
        for e in map(int,raw_input()):
            c[e] += 1
    except:
        break

    f = False
    for i in range(1,10):
        c1=c[:]
        if c1[i]>=4: continue
        else: c1[i]+=1
        atama = [j for j,e in enumerate(c1) if e>=2]
        for e in atama:
            c1[e]-=2
            if check(c1):
                f = True
                print i,
                break
            c1[e]+=2
    if f: print
    else: print 0

Measured memory_bytes: 4284
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
  char s[20],t[20];
  scanf("%s%s",s,t); 
  int i;
   for(i=0;i<strlen(s);i++)
   {
     if(s[i]!=t[i])
       break;
     }
     if(i==strlen(s))
       printf("Yes");
     else
       printf("No");
      return 0;
  }

Measured memory_bytes: 1696
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B float64
	fmt.Scanf("%f", &A)
	fmt.Scanf("%f", &B)

	if int(math.Abs(A - B)) % 2 == 0 {
		fmt.Println(int(math.Abs(A - B) / 2 + math.Min(A, B)))
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 512
import math
import copy

def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l

arr=nCast(input().split())
ss=set()
for n in arr:
    ss.add(n)
if 1 in ss and 9 in ss and 7 in ss and 4 in ss:
    print("YES")
else:
    print("NO")















Measured memory_bytes: 3700
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    if (n%2) {
        cout << 0 << '\n';
        return 0;
    }
    n /= 2;
    ll ans = 0;
    ll cnt = 5;
    while (n/cnt>0) {
        ans += (n/cnt);
        cnt *= 5;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dob;
typedef pair<int,int> par;
const LL N=1000010,lim=N-10,P=998244353;
LL inv[N],s1[N],s2[N],ans;
LL C(int n,int m){
	if (m<0) return 0;
	return s1[n]*s2[m]%P*s2[n-m]%P;
}
int n,k;
LL ask(int r,int b){
	if (r<=b) return 0;
	if (r<n) return 0;
	int b0=r-n+1;
	return C(r+b,b)-C(r+b,b-b0);
}
int main(){
	inv[1]=1;
	rep(i,2,lim) inv[i]=inv[P%i]*(P-P/i)%P;
	s1[0]=s2[0]=1;
	rep(i,1,lim){
		s1[i]=s1[i-1]*i%P;
		s2[i]=s2[i-1]*inv[i]%P;
	}
	scanf("%d%d",&n,&k);
	rep(i,1,k) ans=(ans+ask(i,k-i))%P;
	if (k%2==0&&k/2>=n) ans=(ans+C(k-1,k/2)-C(k-1,n-2))%P;
	ans=(ans%P+P)%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 23552
#include <stdio.h>
int main (void){
    char t[17] = "CODEFESTIVAL2016";
    char s[17] = {'\0'};
    int ans = 0;
    scanf("%s",s);
    for(int i = 0; i < 17; i++){
        if(t[i] == s[i]){
            continue;
        } else {
            ans++;
        }   
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128