akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a#dp-%E5%AE%9F%E8%A3%85%E3%81%AE%E9%A0%86%E5%BA%8F
    
    
    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく
    
    N = int(input())
    L=[list(map(int,input().split())) for i in range(N+1)]
    # dpテーブル dp[i][j]:=i日目にjを行なって得られる幸福度のmax
    W=3
    dp = [[-1]*3 for _ in range(N+1)]
    """
    初期化の値は，
        最小化問題：INF, 
        最大化問題：-INF（0以上の値しか取らないなら-1, あるいは0でもいいかも)
        数え上げ問題：0
        確率問題：0
        Yes/No判定問題:False
    """
    
    # 初期条件
    for j in range(W):
        dp[0][j] = 0
    
    # ループ
    for i in range(1,N+1):
        for j in range(W):
    
            """
            dp[from] の値の更新が完了していればノード from からノード to への緩和を行っていい．貰うdpであれ配るdpであれ．
            両者の違いを意識すべきケースはcf. 
            https://qiita.com/drken/items/ace3142967c4f01d42e9#%E8%B2%B0%E3%81%86-dp-%E3%81%A8%E9%85%8D%E3%82%8B-dp-%E3%81%AE%E6%AF%94%E8%BC%83
    
            # 遷移式がたくさんある場合この中でさらにforループを回したりする cf. https://atcoder.jp/contests/dp/tasks/dp_b
            """
            for k in range(W):
                if j!=k:
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+L[i-1][k])
    
    # 出力
    print(max(dp[N]))
    
    
    
resolve()

Measured memory_bytes: 72156
#include <stdio.h>
int max(int x, int y){
  if(x >= y) return x;
  else return y;
}
int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int ans = max(a*10 + b + c, max(b*10 + a + c, c*10 + a + b));
  printf("%d\n", ans);
}

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


int main(){

    string s;
    cin>>s;

    int w; cin>>w;
    string ans ="";
    for(int i =0;i<s.length();i+=w){
        ans+=s[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp
 
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

#define ll long long int
#define sortasc(v, T) sort(v.begin(), v.end(), less<T>())
#define sortdesc(v, T) sort(v.begin(), v.end(), greater<T>())

//------

int K;
vector<int> A(2);

int main(){
    cin >> A[0] >> A[1] >> K;

    for(int i = 0; i < K; i++){
        if(A[i % 2] % 2 == 1){
            A[i % 2] -= 1;
        }
        A[i % 2] /= 2;
        A[(i ^ 1) % 2] += A[i % 2];
    }

    cout << A[0] << " " << A[1] << endl;

    return 0;
}


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

s = [True] * n  
c = [1]  
now = 0  
while s[now]:
    s[now] = False  
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1]) 
loop = c[start_cycle:-1]  
cycle = len(loop)

if k < start_cycle:  
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    int ans = -1;
    for(int i = 0;i < 50000;i++){
        int temp = i*1.08;
        if(temp == n){
            ans = i;
            break;
        }
    }
        
    if(ans == -1){
        cout << ":(" << endl;
        return 0;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n < 2*m){
            System.out.print("0");
        }else{
            System.out.print(n-2*m);
        }
        
    }
}

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

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

  string S[101];
  for (int i = 0; i < N; ++i) cin >> S[i];

  sort(S, S + N);
  for (int i = 0; i < N; ++i) cout << S[i];
  cout << endl;
}


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

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  long int H[N],high[N],A[M],B[M];
  for(int i=0;i<N;i++){
    cin >> H[i];
    high[i]=1;
  }
  
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
  }
  
  for(int i=0;i<M;i++){
    if(H[A[i]-1]<H[B[i]-1]){
      high[A[i]-1]=0;
    }
    else if(H[A[i]-1]>H[B[i]-1]){
      high[B[i]-1]=0;
    }
    else{
      high[A[i]-1]=0;
      high[B[i]-1]=0;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=high[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6700
#pragma comment(linker,"/STACK:10240000")
#include<iostream>
#include<stack>
#include<cstdlib>
#include<cstdio>
#include<set>
#define N 250
#define INT_MAX		0x3fffffff
using namespace std;
int dp[N][N];
int result=INT_MAX;

void swap(int *a, int *b)
{
    int m;
    m = *a;
    *a = *b;
    *b = m;
}
void perm(int list[], int k, int m)
{
    int i;
    if(k > m)
    {
       int tempresult=0;
       for(int i=0;i<m;i++){
            if(dp[list[i]][list[i+1]]!=INT_MAX){
                 tempresult+=dp[list[i]][list[i+1]];
            }
            else{
                tempresult = INT_MAX;
                break;
            }
       }
       if(tempresult<result){
        result = tempresult;
       }
       //return;
    }
    else
    {
        for(i = k; i <= m; i++)
        {
            swap(&list[k], &list[i]);
            perm(list, k + 1, m);
            swap(&list[k], &list[i]);
        }
    }
}
int main()
{
    int n,e,r;     //表示输入的顶点数和边数
    int a[8];
    //set<int> st;
    while(cin>>n>>e>>r&&e!=0)
    {   for(int i=0;i<r;i++){
         cin>>a[i];
        }
        int i,j;
        int s,t,w;      //表示存在一条边s->t,权值为w
        for(i=0;i<N;i++){
            for(j=0;j<N;j++){
                dp[i][j]=INT_MAX;
            }
        }
        for(i=0;i<e;i++)
        {
            cin>>s>>t>>w;
            dp[s][t]=w;
            dp[t][s]=w;
        }
      for(int k=1;k<=n;k++){
         for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++) {
                if(dp[i][k]+dp[k][j]<dp[i][j]) {
                    dp[i][j]=dp[i][k]+dp[k][j];
                    //path[i][j]=path[i][k];
                }
            }
         }
      }
      perm(a,0,r-1);



        cout<<result<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
const int mod = 1e9;

int main(void){
	int a, b;
	cin >> a >> b;
	if(a < 0 && 0 < b) printf("Zero\n");
	else if(a == 0 || b == 0) printf("Zero\n");
	else if(0 < a) printf("Positive\n");
	else{
		long long c = b - a;
		if(c % 2 == 0) printf("Negative\n");
		else printf("Positive\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		char c = 0;


		ArrayList<String> al = new ArrayList<String>();
//		try {
//			tes = br.readLine();
//		} catch (IOException e) {
//			// TODO 自動生成された catch ブロック
//			e.printStackTrace();
//		}
//		int eee3 = 0;
//		String[] fruit3 = tes.split(" ", 0);
//		for(int k=0;k<26;k++){
//			StringBuffer t = new StringBuffer();
//			for(int i=0;i<fruit3.length;i++){
//				for(int j=0;j<fruit3[i].length();j++){
//					c = fruit3[i].charAt(j);
//					if(String.valueOf(fruit3[i].charAt(j)).matches("[a-z]")){
//						c = (char) (fruit3[i].charAt(j) + k);
//						if(c > 122){
//							c = (char) (96 + c -122);
//						}
//					}
//					t.append(c);
//				}
//				t.append(' ');
//			}
//			String sss = new String(t);
//			String[] fruit2 = sss.split(" ", 0);
//			for(int i=0;i<fruit2.length;i++){
//				if(fruit2[i].equals("the") || fruit2[i].equals("this") || fruit2[i].equals("that") ){
//					eee3 = 1;
//					break;
//				}
//			}
//			if(eee3 == 1){
//				tes = sss;
//				break;
//			}
//		}
//		System.out.println(tes);
//		//double a = Double.parseDouble(tes);
//		//al.add(a);

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			if(tes.equals("")){
				break;
			}
			al.add(tes);

			
			//al.add(a);
		}
		for(int u=0;u<al.size();u++){
			tes = al.get(u);
			int eee = 0;
			String[] fruit = tes.split(" ", 0);
			for(int k=0;k<26;k++){
				StringBuffer t = new StringBuffer();
				for(int i=0;i<fruit.length;i++){
					for(int j=0;j<fruit[i].length();j++){
						c = fruit[i].charAt(j);
						if(String.valueOf(fruit[i].charAt(j)).matches("[a-z]")){
							c = (char) (fruit[i].charAt(j) + k);
							if(c > 122){
								c = (char) (96 + c -122);
							}
						}
						t.append(c);
					}
					t.append(' ');
				}

				String sss = new String(t.substring(0, t.length()-1));
				String[] fruit2 = sss.split(" ", 0);
				for(int i=0;i<fruit2.length;i++){
					if(fruit2[i].equals("the") || fruit2[i].equals("this") || fruit2[i].equals("that") ){
						eee = 1;
						break;
					}
				}
				if(eee == 1){
					tes = sss;
					break;
				}
			}
			System.out.println(tes);
		}
		
	}

}

Measured memory_bytes: 24812
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")

for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if N-1<k:
      break

    if S[j]!=S[i] and S[j]!=S[k] and S[k]!=S[i]:
        ans-=1
        
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,m;cin>>a>>b>>m;
  vector<int> A(a);
  rep(i,a){
    cin>>A[i];
  }
  vector<int> B(b);
  rep(i,b){
    cin>>B[i];
  }
  map<P,int> M;
  rep(i,m){
    int x,y,c;cin>>x>>y>>c;
    P p(x-1,y-1);
    if(M.find(p)!=M.end()){
      M[p]=max(M[p],c);    
    }else{
      M[p]=c;
    }
  }
  int ans=INT_MAX;
  for(auto it=M.begin();it!=M.end();++it){
    int ai=it->first.first;
    int bi=it->first.second;
    int ci=it->second;
    ans=min(ans,A[ai]+B[bi]-ci);
  }
  sort(all(A));
  sort(all(B));
  ans=min(ans,A[0]+B[0]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long N;
        static string[] c = { "7", "5", "3" };

        public static void Input()
        {
            var cin = new Solve();

            N = long.Parse(Console.ReadLine());
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            Console.WriteLine(Dfs("0"));
            


            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public static int Dfs(string s)
        {
            if (long.Parse(s) > N)  { return 0; }
            int x = 0;
            if (s.Contains("7") && s.Contains("5") && s.Contains("3"))
            {
                x++;
            }
            foreach(var z in c)
            {
                x += Dfs(s+z);
            }
           
            return x;
        }

    }
}

    



Measured memory_bytes: 15184
n,y = map(int, input().split())

a = -1
b = -1
c = -1
n1 = min(y // 10000, n)
n2 = min(y // 5000, n)
for i in range(n1+1):
    for j in range(n2+1-i):
        money = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if y == money:
            a = i
            b = j
            c = n - i - j
            break;


print(str(a)+" ",str(b)+" ",str(c))

Measured memory_bytes: 3064
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
o = {}
max = 0
for (i=0; i<N; i++) {
    if (!o[inp[i]]) {
        o[inp[i]] = 1
    } else {
        o[inp[i]] += 1
    }
    if (max < o[inp[i]]) {
        max = o[inp[i]]
    }
}
k = Object.keys(o)
k = k.filter((k) => o[k] == max)
console.log(k.sort().join("\n"))


Measured memory_bytes: 114072
#include <iostream>
#include <cmath>

using namespace std;

int D, G, p[11], c[11];

int main() {
    cin >> D >> G;
    for(int i = 0; i < D; ++i) cin >> p[i] >> c[i];

    long long int ans = 1000000000;
    bool use[11] = {false};
    for(int j = 0; j < D; j++) use[j] = false;

    for(int i = 0; i < pow(2, D); ++i) {
        long long int sum = 0, count = 0;
        for(int j = 0; j < D; j++) {
            if(i & (1<<j)) {
                use[j] = true;
                sum += 100 * (j + 1) * p[j] + c[j];
                count += p[j];
            }
        }

        if(sum >= G) ans = min(ans, count);
        else {
            for(int j = D - 1; j >= 0; --j) {
                if(!use[j]) {
                    for(int k = 0; k < p[j]; ++k) {
                        if(sum >= G) break;
                        sum += 100 * (j + 1);
                        ++count;
                    }
                }
            }
            ans = min(ans, count);
        }
        for(int j = 0; j < D; j++) use[j] = false;
    }

    cout << ans << endl;
}

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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    
    struct S{
        int x1, y1, x2, y2;
    };
    
    vector<S> ans;
    int cnt = 0;
    for(int i = 0; i < H - 1; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j] % 2 == 0)        continue;
            
            a[i][j]--;
            a[i + 1][j]++;
            S temp;
            temp.x1 = i + 1;
            temp.y1 = j + 1;
            temp.x2 = i + 2;
            temp.y2 = j + 1;
            
            ans.push_back(temp);
            cnt++;
        }
    }
    
    for(int j = 0; j < W - 1; j++){
        if(a[H - 1][j] % 2 == 0)        continue;
        
        a[H - 1][j]--;
        a[H - 1][j + 1]++;
        S temp;
        temp.x1 = H;
        temp.y1 = j + 1;
        temp.x2 = H;
        temp.y2 = j + 2;
        
        ans.push_back(temp);
        cnt++;
    }
    
    cout << cnt << endl;
    for(int i = 0; i < ans.size(); i++){
        S temp = ans[i];
        cout << temp.x1 << " " << temp.y1 << " " << temp.x2 << " " << temp.y2 << endl;
    }
}

Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a;
  cin >>a;
  sort(a.begin(),a.end());
  if(a=="abc"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    w = [0] * (10 ** 6 + 1)
    for a in A:
        w[a] += 1
    f = [False] * (10 ** 6 + 1)
    for a in A:
        if f[a]:
            w[a] = 0
            continue
        for b in range(a * 2, 10 ** 6 + 1, a):
            w[b] = 0
        f[a] = True
    print(sum(w))

if __name__ == '__main__':
    main()


Measured memory_bytes: 108980
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

def LIS(A):
    """
    returns Longest Increasing Subsequence of list A.
    """
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B

def LDS(A):
    """
    returns Longest Decreasing Subsequence of list A.
    """
    A = A[::-1]
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_right(B, A[i+1])
            B[index] = A[i+1]
    return B[::-1]


print(len(LDS(A)))

Measured memory_bytes: 57560
//f[i]=f[j]+h[i]^2+h[j]^2-2h[i]h[j]
//f[i]=h[i]^2+(f[j]+h[j]^2)-2*h[i]*h[j]
//g[i]=f[i]+h[i]^2
//f[i]=h[i]^2+g[j]-2*h[i]*h[j]
//g[j]-2*h[i]*h[j]>g[k]-2*h[i]*h[k](j<k)后一个更优 
//g[j]-g[k]>2*h[i]*(h[j]-h[k])
//(g[j]-g[k])/(h[j]-h[k])<2*h[i]
//满足小于时，后一个比前一个优
//因为h递增，后一个永远比前一个优，可以直接舍去
//cale(x,y)>cale(y,z)时(x<y<z)
//cale(y,z)<cale(x,y)<2*h[i]时z最优
//cale(x,y)>cale(y,z)>2*h[i]时x最优
//cale(x,y)>2*h[i]>cale(y,z)时 x或z优 
//总之和y无关
//所以保持斜率递增 
#include<cstdio>
long long g[200005],f[200005],c;
int n,q[200005],h[200005],l,r;
double cale(int j,int k)
{return(g[j]-g[k])*1.0/(h[j]-h[k]);}
long long sqr(int x){return 1ll*x*x;}
int main()
{
	scanf("%d%lld",&n,&c);q[l=r=1]=1;
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);g[1]=sqr(h[1]);
	for(int i=2;i<=n;i++)
	{
		while(l<r&&cale(q[l],q[l+1])<=2*h[i])l++;
		f[i]=g[q[l]]+sqr(h[i])-2*1ll*h[i]*h[q[l]]+c;
		g[i]=f[i]+sqr(h[i]);
		while(l<r&&cale(q[r-1],q[r])>=cale(q[r],i))r--;
		q[++r]=i;
	}printf("%lld\n",f[n]);
}

Measured memory_bytes: 4864
#include<iostream>

using namespace std;

int main()
{
    const long N=1000000;
    long n;          //入力数
    int A[4][3][10]={0};        //[棟][階][部屋]
    int b[N],f[N],r[N],v[N];
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>b[i]>>f[i]>>r[i]>>v[i];
    }
    for(int i=0;i<n;i++){
        A[b[i]-1][f[i]-1][r[i]-1] += v[i];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<' '<<A[0][i][j];
        }
        cout<<'\n';
    }
    cout<<"####################\n";

    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<' '<<A[1][i][j];
        }
        cout<<'\n';
    }
    cout<<"####################\n";

    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<' '<<A[2][i][j];
        }
        cout<<'\n';
    }
    cout<<"####################\n";

    for(int i=0;i<3;i++){
        for(int j=0;j<10;j++){
            cout<<' '<<A[3][i][j];
        }
        cout<<'\n';
    }

}


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

int main() {
	int x, k;

	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> x;
	
	k = 2;
	if(360%x == 0)
		cout << 360/x << endl;
	else {
		while(1) {
			int tmp = 360*k;
			if(tmp%x == 0) {
				cout << tmp/x << endl;
				break;
			}
			else
				k++;
		}
	}

	return 0;
}


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

ll a[1000];

int main() {
	vector<ll>so;
	so.push_back(2);
	ll n=3;
	while(n<=1000){
		bool flag=true;
		for(int i=0;i<so.size();i++){
			if(n%so[i]==0){
				flag=false;
			}
		}
		if(flag){
			so.push_back(n);
		}
		n+=2;
	}
	cin>>n;
	for(int i=1;i<=n;i++){
		ll now=i;
		for(int j=0;j<so.size();j++){
			while(now%so[j]==0){
				a[j]++;
				now=now/so[j];
			}
			if(now==1){
				break;
			}
		}
	}
	ll ans=1;
	for(int i=0;i<1000;i++){
		ans*=(a[i]+1);
		ans%=inf;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>h(N), H(N, 0);
	vector<bool>v(N, false);
	rep(i, N)
	{
		cin >> h[i];
		if (!h[i])v[i] = true;
	}
	int ans = 0;
	while (1)
	{
		int cnt = 0;
		rep(i, N)
		{
			if (v[i] == false)
			{
				H[i]++;
				cnt++;
				if (i == N - 1)ans++;
			}
			else
			{
				if (cnt)ans++;
				cnt = 0;
				continue;
			}
		}
		rep(i, N)
		{
			if (h[i] == H[i] && v[i] == false)v[i] = true;
		}
		int sum = 0;
		rep(i, N)if (v[i] == true)sum++;
		if (sum == N)break;
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().B();
	}

	void A() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ma = -1, mi = 101;
		for (int i = 0; i <= Math.min(A, B); ++i) {// A,B両方
			int j = A - i;
			int k = B - i;
			if (i + j + k > N || j < 0 || k < 0)
				continue;
			ma = Math.max(i, ma);
			mi = Math.min(i, mi);
		}
		System.out.println(ma + " " + mi);

	}

	void B() {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (a.charAt(i) == b.charAt(i) && b.charAt(i) == c.charAt(i)) {
				continue;
			} else if (a.charAt(i) == b.charAt(i) || b.charAt(i) == c.charAt(i) || c.charAt(i) == a.charAt(i)) {
				ans += 1;
			} else {
				ans += 2;
			}
		}
		System.out.println(ans);
	}


	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

long cnt(long k) {
    if (k % 2 == 1) return 0;
    return 1 + cnt(k / 2);
}

int main() {
    long n;
    cin >> n;
    long ans = 0;
    REP(i,n) {
        long a;
        cin >> a;
        ans += cnt(a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;

int main() {
  ll X,K,D,ans;
  cin>>X>>K>>D;
  X=abs(X);
  if (X/D>=K) ans = X-K*D;
  else if ((K-X/D)%2 == 0) ans = X%D;
  else ans = D-X%D;
  cout<<ans<<endl;
  return 0;
}


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

const static ll MOD = (1e+9)+7;

int main(){
    int n;cin>>n;
    vector<string> S(n);rep(i,n)cin>>S[i];
    int B_A = 0,B=0,A=0;
    ll ans = 0;
    rep(i,n){
        rep(j,S[i].size()-1){
            if(S[i][j] == 'A'){
                if(S[i][j+1] == 'B')ans++;
            }
        }
    }
    rep(i,n){
        if(S[i][0] == 'B' && S[i][S[i].size()-1] == 'A'){
            B_A++;
        }else if(S[i][0] == 'B'){
            B++;
        }else if(S[i][S[i].size()-1] == 'A'){
            A++;
        }
    }
    if(B_A == 0){
        ans += min(A,B);
    }else{
        if(B>=2 && A>= 2){
            ans += 2+min(A-1,B-1);
        }else if(B>=1 && A>= 1){
            ans += 2;
        }else if(A == 0 && B == 0){
            ans += 0;
        }else{
            ans += 1;
        }
        if(B_A >= 2){
            ans += B_A -1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int solve(int x) {
    if (x >= 400 && x < 600)
        return 8;
    if (x >= 600 && x < 800)
        return 7;
    if (x >= 800 && x < 1000)
        return 6;
    if (x >= 1000 && x < 1200)
        return 5;
    if (x >= 1200 && x < 1400)
        return 4;
    if (x >= 1200 && x < 1400)
        return 4;
    if (x >= 1400 && x < 1600)
        return 3;
    if (x >= 1600 && x < 1800)
        return 2;
    if (x >= 1800 && x < 2000)
        return 1;
}

int main() {
    int x;
    cin >> x;
    cout << solve(x) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int a[100010];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0, ans2 = 0;
	int sum = 0;
	rep(i, n) {
		sum += a[i];
		if (i % 2 == 0) {
			if (sum <= 0) {
				ans += 1 - sum; sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				ans += sum + 1; sum = -1;
			}
		}
	}
	sum = 0;
	rep(i, n) {
		sum += a[i];
		if (i % 2 != 0) {
			if (sum <= 0) {
				ans2 += 1 - sum; sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				ans2 += sum + 1; sum = -1;
			}
		}
	}
	cout << min(ans,ans2) << endl;
}


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

using namespace std;

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

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

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

struct UniTree {
    int *par, *rank, *sz;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        sz = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
            sz[x] += sz[y];
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int siz(int x) {
        return sz[root(x)];
    }
};

bool check(double mid) {
    return true;
}

double bin(double left, double right) {
    while(right - left > 1e-4) {
        double mid = (left + right) / 2;
        if(check(mid)) left = mid;
        else right = mid;
    }
    return left;
}

int main() {
    int n, a;
    cin >> n >> a;
    map<int, ll> *mp = new map<int, ll>[n + 1];
    mp[0][0] = 1;
    rep(i, n) {
        int x;
        cin >> x;
        for(pair<int, ll> p : mp[i]) {
            mp[i + 1][p.first] = mp[i + 1][p.first] + p.second;
            mp[i + 1][p.first + x - a] = mp[i + 1][p.first + x - a] + p.second;
        }
    }
    cout << mp[n][0] - 1 << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++)
        cin >> D[i];

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

    int res = 0;
    for (int i = 1; i <= 100000; i++) {
        int t = lower_bound(D.begin(), D.end(), i) - D.begin();
        if (t == N / 2) res++;
    }
    cout << res << endl;
    return 0;
}

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

int n, W;
vector<long long int> w, v;// weight, value
vector<vector<long long int>> dp;// memo

long long int DFS(int i, int j){// try to pack j with items i ~ n
    // terminal case
    if(i == n) return 0;// dp[n][j] = 0
    
    // already visited
    if(dp[i][j] != 0) return dp[i][j];

    // none of the above
    // i + (i+1 ~ n)
    if(j < w[i]) return dp[i][j] = DFS(i+1, j);
    else return dp[i][j] = max(DFS(i+1, j-w[i]) + v[i], DFS(i+1, j));// add or not
}

int main(){
    cin >> n >> W;
    w.resize(n);
    v.resize(n);
    dp.resize(n+1, vector<long long int>(W+1));
    
    for(int i=0; i<n; i++){
        cin >> w[i] >> v[i];
    }

    cout << DFS(0, W) << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > P(N), position(N);
  for (int i=0; i<N; i++){
    scanf("%d", &P[i]);
    position[P[i]-1]=i;
  }
  int increase_max = 1;
  int temp=1;
  int index_old=N+4;
  for (int i=0; i<N; i++){
    int index=position[i];
    if (index_old>index){
      temp=1;
    } else{
      temp++;
      increase_max=std::max(increase_max, temp);
    }
    index_old=index;
  }
  std::cout << N-increase_max <<std::endl;
  return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define ll long long int    
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const ll MOD = 1e9 + 7, N = 1e5 + 3;

int main(){
    ll n, a;
    cin >> n >> a;
    ll ans = n*2;
    ll ans1 = n*4;
    if(a == ans || a == ans1)
        cout << "Yes";
    else{
        int d = 0;
        while(n--){
            ans -= 2;
            ans += 4;
            if(ans == a){
                ++d;
                cout << "Yes";  
                break;
            }
        }
        if(d == 0)
            cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn main() {
    input!{
        s: chars
    }
    let mut ans: usize = 0;
    let mut na = 0;
    let mut i = 0;
    while i < s.len() - 1 {
        if s[i] == 'A' {
            na += 1;
            i += 1;
        } else if s[i] =='B' && s[i + 1] == 'C' {
            ans += na;
            i += 2;
        } else {
            na = 0;
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//
//  main.cpp
//  Atcoder176
//
//  Created by Keita on 2020/08/22.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

void doProblemA(){
    int N, X, T;
    cin >> N >> X >> T;
    if(N % X == 0){
    cout << (N / X) * T << endl;
    }else{
        cout << (N / X + 1) * T << endl;
    }
}

int main(int argc, const char * argv[]){
    // insert code here...
    doProblemA();
    return 0;
}


Measured memory_bytes: 3160
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    
    center_left = N//2 - 1
    center_right = N//2
    ans = d[center_right] - d[center_left]
    print(ans)
main()

Measured memory_bytes: 14300
#include<bits/stdc++.h>
using namespace std;
//using p=pair<int,int>;
typedef long long ll;

 int main(){

 int n;
 cin>>n;

 for(int i=0;i<=20;i++)
 {
    if(n < (1<<(i+1)) ){
        cout<<(1<<i)<<endl;
         break ;
      }
 }

 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    double x1, y1, x2, y2, ans;
    cin >> x1 >> y1 >> x2 >> y2;
    ans = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    cout << fixed << setprecision(8) << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <string>
#include <set>

struct Pos {
	int x;
	int y;

	Pos(): x(-1), y(-1){}
	Pos(int _x, int _y): x(_x), y(_y){}
	Pos(const Pos& rh): x(rh.x), y(rh.y){}

	bool operator<(
		const Pos& lh
	) const {
		if(lh.y > y){
			return true;
		}else if(lh.y < y){
			return false;
		}else{
			return lh.x > x;
		}
	}
};

int main(){
	int H, W, N;
	std::cin >> H >> W >> N;

	std::vector<std::string> Map(H);

	for(int i = 0; i < H; i++){
		std::cin >> Map[i];
	}

	Pos start;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(Map[i][j] == 'S'){
				start.x = j;
				start.y = i;
				break;
			}
		}
		if(start.x != -1 && start.y != -1){
			break;
		}
	}

	int ans = 0;
	std::vector<Pos> diffs(4);
	diffs[0] = Pos(0, -1);
	diffs[1] = Pos(1, 0);
	diffs[2] = Pos(0, 1);
	diffs[3] = Pos(-1, 0);

	for(int i = 1; i <= N; i++){
		//std::cout << "i: " << i << std::endl;
		bool flg = false;
		std::vector<Pos> positions(1);
		positions[0] = start;
		std::set<Pos> known_pos;
		known_pos.insert(start);
		int count = 0;

		while(flg == false){
			std::vector<Pos> new_pos;
			for(int ii = 0; ii < positions.size(); ii++){
				Pos pos = positions[ii];
				//std::cout << "pos : (" << pos.x << ", " << pos.y << ")" << std::endl;

				for(int j = 0; j < 4; j++){
					Pos d = diffs[j];
					int y = pos.y + d.y;
					int x = pos.x + d.x; 
					if(	y >= 0 && y < H &&
						x >= 0 && x < W &&
						Map[y][x] != 'X'){
						if(Map[y][x] - 48 == i){
							start.x = x;
							start.y = y;
							flg = true;
							break;
						}else{
							Pos p(x, y);
							if(known_pos.find(p) == known_pos.end()){
								new_pos.push_back(p);
							}
						}
					}
				}
				for(int k = 0; k < new_pos.size(); k++){
					known_pos.insert(new_pos[k]);
				}
			}
			count += 1;
			positions = new_pos;
		}
		ans += count;
	}

	std::cout << ans << std::endl;
}



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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
#define REV(i, a, b) for (int i = a; i > (b); --i)
#define debug(a) cerr << #a << " " << a << endl
#define debug2(a, b) cerr << #a << " " << a << ", " << #b << " " << b << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  double pi = 6.28318530717958623200;
  double r; cin >> r;
  cout << r*pi << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	long long ans = 0;
	bool rest = false;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (rest && A > 0) {
			ans++;
			A--;
		}
		ans += (long long)A / 2;
		rest = A % 2 == 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
ll dp[1001][1001];
int a[1000];
int b[1000];
ll c[1001];
int main()
{
	while(1)
	{
		int n,m;
		cin>>n>>m;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
			cin>>a[i];
		for(int i=0;i<n;i++)
			cin>>b[i];
		c[0]=0;
		for(int i=0;i<n;i++)
		{
			if(b[i]<a[i])
				c[i+1]=b[i]-a[i]+m;
			else
				c[i+1]=b[i]-a[i];
		}
		fill(dp[0],dp[1001],1e14-1);
		dp[0][0]=0;
		for(int i=1;i<n+1;i++)
		{
			//cerr<<c[i]<<endl;
			for(int j=0;j<1001;j++)
			{
				if(i==1)
					dp[i][j]=c[i]+j*m;
				else{
					int k=(c[i]+j*m-c[i-1])/m;
					dp[i][j]=min(dp[i-1][k]+max(0LL,c[i]+j*m-c[i-1]-k*m),dp[i-1][k+1]+max(0LL,c[i]+j*m-c[i-1]-(k+1)*m));
				}
			}
		}
		ll ans=1e14-1;
		for(int i=0;i<100;i++)
			ans=min(ans,dp[n][i]);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 10972
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n,k;

    cin >> n >> k;

    int a = 1;

    for(int i = 0;i < n;i++)
    {
        a = min(a*2,a+k);
    }

    cout << a;
}



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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	map<int, int> s;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		if(s.find(x) == s.end()) s[x] = 0;
		++s[x];
	}
	int ans = 0;
	for (int z = 1 << 30; z; z >>= 1) {
		for (auto it = s.begin(); it != s.end(); ++it) {
			int x = it->first, y = z - x;
			if(x == y) {
				ans += it->second / 2;
				it->second %= 2;
			}
			else if(s.find(y) != s.end()) {
				int t = min(s[x], s[y]);
				s[x] -= t;
				s[y] -= t;
				ans += t;
			}
		}
#ifdef DEBUG
		cout << "z = " << z << endl;
		for (auto foo: s) cout << foo.first << ' ' << foo.second << endl;
#endif
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9600
n=int(input())
line= list(map(int,input().split()))
cnt=0
for x in range(n):
    if line[x]!=x+1:
        cnt+=1
if cnt==0 or cnt==2: #cnt==0 or 2だと　２４３５１でYES（ｃnｔ＝４）になる
    print('YES')
else:
    print('NO')

    


Measured memory_bytes: 2940
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def nCr(self, n, r):
        r = min(n - r, r)
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def nHr(self, n, r):
        return self.nCr(n - 1 + r, r)


def main():
    MOD = 10 ** 9 + 7

    r1, c1, r2, c2 = map(int, input().split())

    cl = Calc(max_value=r2 + c2 + 1, mod=MOD)
    nCr = cl.nCr

    ans = 0
    for r in range(r1, r2 + 1):
        ans = (ans + nCr(r + c2 + 1, r + 1) - nCr(r + c1 - 1 + 1, r + 1)) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=1e6+5;

bool fnc(string s)
{
    int l = s.size();
    for(int i=0; i<l; i++) {
        if(s[i] != s[l-1-i]) return 0;
    }
    return 1;
}

int main()
{
    string s;
    cin >> s;
    bool yes = 1;

    int n = s.size();
    if(n % 2 == 0) yes = 0;

    if(!fnc(s.substr(0, n/2))) yes = 0;
    if(!fnc(s.substr(n/2+1, n/2))) yes = 0;
    if(!fnc(s)) yes = 0;

    if(yes) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,q;
long s[1<<17],t[1<<17];
long cs[1<<17],ct[1<<17];
main()
{
	cin>>a>>b>>q;
	for(int i=0;i<a;i++)cin>>s[i+1];
	s[0]=-5e10;s[a+1]=5e10;
	for(int i=0;i<b;i++)cin>>t[i+1];
	t[0]=-5e10;t[b+1]=5e10;
	for(int i=1;i<=a;i++)
	{
		long*p=lower_bound(t,t+b+2,s[i]);
		cs[i]=min(s[i]-p[-1],p[0]-s[i]);
	}
	for(int i=1;i<=b;i++)
	{
		long*p=lower_bound(s,s+a+2,t[i]);
		ct[i]=min(t[i]-p[-1],p[0]-t[i]);
	}
	cs[0]=cs[a+1]=ct[0]=ct[b+1]=6e15;
	for(;q--;)
	{
		long x;cin>>x;
		long ans=9e18;
		long*P=lower_bound(s,s+a+2,x),*Q=lower_bound(t,t+b+2,x);
		ans=min(ans,P[0]-x+cs[P-s]);
		ans=min(ans,x-P[-1]+cs[P-s-1]);
		ans=min(ans,Q[0]-x+ct[Q-t]);
		ans=min(ans,x-Q[-1]+ct[Q-t-1]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4992
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    if(line[0].charAt(line[0].length-1)===line[1].charAt(0)&&line[1].charAt(line[1].length-1)===line[2].charAt(0)){
        console.log("YES");
    } else {
        console.log("NO")
    }
//    console.log(line[0].charAt(line[0].length));
//    console.log(line[1].charAt(line[1].length));
//    console.log(line[2].charAt(line[2].length));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
n=int(input())
b=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
f=sum(a)
for i in range(n):
    a1=a[i]
    a[i]=max(0,a[i]-b[i])
    b[i]=max(0,b[i]-a1)
    a2=a[i]
    a[i]=max(0,a[i]-b[i+1])
    b[i+1]=max(0,b[i+1]-a2)
print(f-sum(a))
    

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

int main()
{
    int N, H, W;
    cin >> N >> H >> W;

    int A[N];
    int B[N];
    REP(i, N) cin >> A[i] >> B[i];

    int ret = 0;
    REP(i, N)
    {
        if (A[i] >= H && B[i] >= W) ++ret;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int main(){
  int a,b;
  cin >> a >> b;
  cout << (b-a)*(b-a-1)/2-a << endl;
  return 0;
}

Measured memory_bytes: 256