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

using namespace std;

const int N_CONTEST = 26;

struct Contest {
    int day;
    vector<int> complain;
    vector<vector<int>> satisfy;

    Contest() {
        cin >> day;

        complain.resize(N_CONTEST+1);
        for ( int c = 1; c <= N_CONTEST; c++ )
            cin >> complain.at(c);

        satisfy.resize(day+1);
        for ( int d = 1; d <= day; d++ ) {
            satisfy.at(d).resize(N_CONTEST+1);
            for ( int c = 1; c <= N_CONTEST; c++ )
                cin >> satisfy.at(d).at(c);
        }
    }

    void dump() {
        printf("----- Dump contents of struct Contest -----\n"
               "%d\n", day);
        for ( int c = 1; c <= N_CONTEST; c++ )
            printf("%d ", complain.at(c));
        printf("\n");
        for ( int d = 1; d <= day; d++ ) {
            for ( int c = 1; c <= N_CONTEST; c++ )
                printf("%d ", satisfy.at(d).at(c));
            printf("\n");
        }
        printf("----- Dump done -----\n");
    }
};

static int calc_greedy_ans (Contest contests, int day, vector<int> &last) {
    int max_score = INT_MIN;
    int ans_c = 1;

    for ( int c = 1; c <= N_CONTEST; c++ ) {
        int score = contests.satisfy.at(day).at(c);
        for ( int c_ = 1; c_ <= N_CONTEST; c_++ ) {
            if ( c_ == c ) {
                continue;
            }
            score -= contests.complain.at(c_) * (day - last.at(c_));
        }
        /* 13 日後までコンテストを開催しない場合のスコアで比較する */
        for ( int d = day; d <= min(day+13, contests.day); d++ ) {
            for ( int c_ = 1; c_ <= N_CONTEST; c_++ ) {
                score -= contests.complain.at(c_) * (d - last.at(c_));
            }
        }
        if ( score > max_score ) {
            max_score = score;
            ans_c = c;
        }
    }
    last.at(ans_c) = day;

    return ans_c;
}

static void dump_ans (Contest contests) {
    vector<int> last(N_CONTEST+1, 0);

    for ( int d = 1; d <= contests.day; d++ ) {
        int c = calc_greedy_ans(contests, d, last);
        cout << c << endl;
    }
}

int main (void) {
    Contest contests;

    dump_ans(contests);

    return 0;
}



Measured memory_bytes: 3804
while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    for i in range(a):
        for j in range(b):
            if (j == 0 or j == b - 1) or (i == 0 or i == a - 1):
                print("#", end="")
            else:
                print(".", end="")

        print("")

    print("")



Measured memory_bytes: 7012
#include <cstdio>

int main() {
    int co = 0;
    bool cur[3] = { true, false, false };
    int tr[100] = { 0 };
    int wt[100] = { 0 };

    {
        char intr;
        char inwt;
        while (scanf(" %c , %c", &intr, &inwt) != EOF) {
            tr[co] = intr - 'A';
            wt[co] = inwt - 'A';
            co++;
        }
    }

    for (int i = 0; i < co; ++i) {
        int ttr = tr[i];
        int twt = wt[i];
        bool t = cur[ttr];
        cur[ttr] = cur[twt];
        cur[twt] = t;
    }

    char re = 0;
    for (int i = 0; i < 3; ++i) {
        if (cur[i]) {
            re = i;
            break;
        }
    }
    printf("%c\n", re + 'A');

    return 0;
}

Measured memory_bytes: 972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();

        int N = int.Parse(s.Split(' ')[0]);
        int L = int.Parse(s.Split(' ')[1]);

        //味の中で、両端のもの
        int tasteL = L;
        int tasteR = L + N - 1;

        //回答となる数値
        int ans = 0;

        //全部の味の和
        int sum = N * (2 * L + N - 1) / 2;

        if (tasteL < 0 && tasteR < 0) {
            ans = sum - (L + N - 1);
        } else if (tasteR > 0 && tasteL > 0) {
            ans = sum - L;
        } else {
            ans = sum;
        }

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n,d,cnt;

int main()
{
    scanf("%lld %lld",&n,&d);
    for(int i=0;i<n;i++)
    {
        ll x,y;
        scanf("%lld %lld",&x,&y);
        if(d*d>=x*x+y*y)cnt++;
    }
    printf("%lld\n",cnt);
    return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

int BFS();
void debug();


int H, W,dst[50][50];
char  grid[50][50];
int BFS();
int sx = 0;
int sy = 0;
int gx, gy;
int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++)scanf("%s", grid[i]);

	gy = H - 1;
	gx = W - 1;


	int need = BFS();
	int def = 0;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (grid[i][j] == '#')def++;

	if(need!=c_YET)printf("%d", W*H -2 - def - need+1);
	else printf("-1");




}


int BFS() {
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)dst[i][j] = c_YET;
	dst[sy][sx] = 0;

	queue<P> que;
	que.push(P(sy,sx));

	while (que.size()) {
		P p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx)break;
	
		for (int i = 0; i < 4; i++) {
			int ny = p.first + c_Dy[i];
			int nx = p.second + c_Dx[i];
			if (ny >= 0 && ny < H&&nx >= 0 && nx < W&&grid[ny][nx] != '#'&&dst[ny][nx] == c_YET) {
				que.push(P(ny, nx));
				dst[ny][nx] = dst[p.first][p.second] + 1;
				//debug();
			}

		}
	
	}

	return dst[gy][gx];

}

void debug() {
	printf("\n");
	for (int i = 0; i < H; i++) {
		printf("\n");
		for (int j = 0; j < W; j++)
			printf("%d  ", dst[i][j]);
	}

}


/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

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

using namespace std;

const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector a(n,0LL);
  for (int i=0; i<n; i++) cin >> a[i];
  
  vector bits(2, vector(60,0LL));
  for (int i=0; i<n; i++) {
    for (int j=0; j<60; j++) {
      bits[(a[i]>>j)&1][j]++;
      bits[(a[i]>>j)&1][j] %= MOD;
    }
  }
  
  long long ans = 0;
  long long d =  1;
  for (int i=0; i<60; i++) {
    ans += (((bits[0][i] * bits[1][i]) % MOD) * d) % MOD;
    d *= 2;
    d %= MOD;
    ans %= MOD;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5156
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  int A, B, C; cin >> A >> B >> C;
  if (A < B && B < C){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] A = new int[N];
    long ans = 1;
    int count = 0;
    for (int i = 0; i < N; i++){
      A[i] = scanner.nextInt();
    }
    Arrays.sort(A);
    for (int i = N - 1; i > 0; i--){
      if (A[i] == A[i - 1]){
        ans *= A[i];
        i--;
        count++;
      }
      if (count >= 2){
      System.out.println(ans);
      return;
      }
    }
    System.out.println(0);
  }
}


Measured memory_bytes: 50724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	string name;
	cin>>name;
	cout<<name[0];
	cout<<name.length()-2;
	cout<<name[name.length()-1];
	return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll cnt=0;
    for(int i=0;i<n-k;i++)
    {
        cnt+=v[i];
    }
    cout<<cnt<<'\n';
}

int main()
{
    
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
N = gets.to_i
arr = gets.chomp.split
nums = []
ops = []
first = arr.shift.to_i
(N-1).times do
    ops << arr.shift
    nums << arr.shift.to_i
end
ops << '-'
nums << 0
sum = first + nums.inject(0, :+)

BIG = 10**20
loss = BIG
minus = 0
plus = 0
N.times do |i|
    if ops[i] == '+'
        if minus > 0
            plus += nums[i]
        end
    else
        if minus > 0
            result = minus + plus
            loss = result if loss > result
            plus = 0
        end
        minus += nums[i]
    end
end
puts loss == BIG ? sum : sum - 2 * loss

Measured memory_bytes: 23036
#include <stdio.h>
int fibonacci(int);

int b[44];

int main()
{
  int n,a,i;

  scanf("%d",&n);

  for(i=0;i<44;i++){
    b[i] = 0;
  }
  a = fibonacci(n);
  printf("%d\n",a);
  return 0;
}
int fibonacci(int n)
{  

  if(n == 0 || n ==1){
    b[n] = 1;
    return b[n];
  }
  else if(b[n] != 0 )return b[n];
  
  else {
    b[n] = fibonacci(n-2) + fibonacci(n-1);
    return b[n];
  }
}

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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;
	vector < string > S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		sort(S[i].begin(), S[i].end());
	}

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

	ll ans = 0;

	ll index = 0;

	while (index < N) {
		string head = S[index];
		ll move = 1;
		while (index + move < N && S[index + move] == head) {
			move++;
		}
		ans += move * (move - 1) / 2;
		index += move;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7296
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

int n;
string base;
bool quest(int from) { //True:base
	printf("?");
	REP(i, n) {
		printf(" %d", (from+ i) % (2*n) + 1);
	}
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

bool quest(int from, int ad) { //True:base
	printf("?");
	REP(i, n - 1) {
		printf(" %d", (from + i) % (2 * n) + 1);
	}
	printf(" %d", ad + 1);
	
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

signed main() {
	string str[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	string a;
	cin >> a;
	int num = 0;
	REP(i, 7) {
		if (a == str[i])
			num = i;
	}

	cout << (7 - num) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a[4],b[4],b1=0,b2=0,hit=0,boro=0;
    while(scanf("%d",&a[0])!=EOF){
        for(int i=1;i<4;i++){
            cin>>a[i];
        }
        for(int i=0;i<4;i++){
            cin>>b[i];
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i==j&&a[i]==b[j]){
                    b1=0;b2=1;
                    break;
                }
                if(a[i]==b[j])b1=1;
            }
            hit+=b2;boro+=b1;
            b1=0;b2=0;
        }
        cout<<hit<<" "<<boro<<endl;
        hit=0;boro=0;
    }
}

Measured memory_bytes: 1244
<?php
  
$in = fgets(STDIN);
$num = explode(" ", $in);

$num1 = (int)$num[0];
$num2 = (int)$num[1];

if($num1 < 10 && $num2 < 10){
  echo $num1 * $num2;
}else{
  echo "-1";
}

Measured memory_bytes: 4856
import java.util.*;

public class Main {
    private static boolean[][] fld;

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int w = 0;
            int h = 0;
            int y = 0;
            int x = 0;
            while((w = scn.nextInt()) > 0 | (h = scn.nextInt()) > 0) {
                fld = new boolean[h][w];
                for(int i = 0; i < h; i++) {
                    char[] ary = scn.next().toCharArray();
                    for(int j = 0; j < w; j++) {
                        switch(ary[j]) {
                            case '@':
                                y = i;
                                x = j;
                            case '.':
                                fld[i][j] = true;
                                break;
                            case '#':
                                fld[i][j] = false;
                                break;
                            default:
                                assert false;
                        }
                    }
                }
                System.out.println(count(y, x));
            }
        }
    }

    public static int count(int y, int x) {
        int rslt = 0;
        try {
            if(fld[y][x]) {
                fld[y][x] = false;
                rslt += count(~-y, x);
                rslt += count(y, ~-x);
                rslt += count(y, -~x);
                rslt += count(-~y, x);
                rslt++;
            }
        } catch(ArrayIndexOutOfBoundsException ignore) {}
        return rslt;
    }
}

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

namespace c
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            long[] a = new long[n];
            for (long i = 0; i < n; i++)
            {
                a[i] = long.Parse(Console.ReadLine());
            }

            //可能判定
            for (long i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    if (a[0] != 0)
                    {
                        Console.WriteLine(-1);
                        return;
                    }

                    continue;
                }
                if (a[i] - a[i - 1] > 1)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            long count = 0;
            for (long i = 1; i < n; i++)
            {
                if (a[i] - a[i - 1] == 1)
                {
                    ++count;
                }
                else
                {
                    count += a[i];
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 17332
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int N, K; cin >> N >> K;
    int M = 1, digit = 0;
    while (M <= N) {
        M *= K;
        digit += 1;
    }
    cout << digit << endl;
    return 0;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

import sys
N = n()

cords = []
for i in range(N):
    x, y = nl()
    cords.append([x, y])

if N == 1:
    print(1)
    sys.exit()

from collections import defaultdict

pats = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        c1 = cords[i]
        c2 = cords[j]
        pats[(c1[0] - c2[0], c1[1] - c2[1])] += 1
        pats[(c2[0] - c1[0], c2[1] - c1[1])] += 1

print(N - sorted(list(pats.values()), reverse=True)[0])


Measured memory_bytes: 3772
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

struct data_t
{
    int i;
    string s;
    int p;

    // 最後のconstを忘れると"instantiated from here"というエラーが出てコンパイルできないので注意
    bool operator<(const data_t &right) const
    {
        return s != right.s ? s < right.s : p > right.p;
    }
};

int main()
{
    int N;
    cin >> N;
    data_t sp[N];
    REP(i, N)
    {
        string s;
        int p;
        cin >> s >> p;
        sp[i].i = i + 1;
        sp[i].s = s;
        sp[i].p = p;
    }

    sort(sp, sp + N);

    REP(i, N)
    {
        cout << sp[i].i << endl;
    }
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
Q = deque()
for i in range(n):
    cmd = input()
    if cmd == "deleteFirst":
        Q.popleft()
    elif cmd == "deleteLast":
        Q.pop()
    else:
        com,num = cmd.split()
        if com == "insert":
            Q.appendleft(num)
        elif com == "delete":
            try:
                Q.remove(num)
            except:
                pass
print(' '.join(Q))


Measured memory_bytes: 69732
program B
    implicit none
    integer::i
    character(len=200)::S
    read(*,*) S
    i = (len_trim(S)-1)/2 *2

    do while(i >= 2)
        if(S(1:i/2) .eq. S(i/2+1:i)) then
            write(*,*) i
            stop
        end if
        i = i-2
    end do
end program B

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

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

  ll n, k;
  cin >> n >> k;
  vector < ll > h(n + 1), dp(n + 1, LLONG_MAX);
  for(int i = 1; i <= n; i++) cin >> h[i];

  dp[1] = 0;
  for(int i = 2; i <= n; i++){
    for(int j = i - 1; j >= i - k && j >= 1; j--){
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }

  cout << dp[n] << '\n';
}


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

template<class T>
int part(const T& s,int l, int r){return s[r] - s[l];};

vector<bool> is_prime(int n){
  vector<bool> isP(n,true);
  isP[0] = isP[1] = false;
  for(int i=2;i<n;i++){
    if(isP[i]){
      for(int j=2*i;j<n;j+=i)
        isP[j] = false;
    }
  }
  return isP;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int Q; cin>>Q;
  vector<bool> isP = is_prime(100005);
  vector<int> like(100005);
  for(int i=3;i<isP.size();i++){
    if(isP[i]){
      int a = (i + 1) / 2;
      if(isP[a]) like[i] = 1;
    }
  }
  vector<int> sum(100006);
  for(int i=0;i<like.size();i++)
    sum[i+1] = sum[i] + like[i];
  for(int i=0;i<Q;i++){
    int l,r;
    cin>>l>>r;
    cout<<part(sum,l,r+1)<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextLong()

  val cnt = Stream.from(0)
    .map(i => Integer.toString(i, 4))
    .filter(s => s.contains('1') && s.contains('2') && s.contains('3') && !s.contains('0'))
    .map(s => s
      .replaceAll("3", "7")
      .replaceAll("1", "3")
      .replaceAll("2", "5"))
    .map(s => s.toLong)
    .takeWhile(n >= _)

  println(cnt.size)
}


Measured memory_bytes: 115912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    int nx,ny,nt;
    nx = 0; ny = 0; nt = 0;
    bool ok = 1;
    REP(i,N)
    {
        int t,x,y;
        cin >> t >> x >> y;
        int dist = abs(x-nx) + abs(y-ny);
        if(dist <= t - nt && (dist - (t-nt)) % 2 == 0)
        {

        }
        else
        {
            ok = 0;
        }

    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
from math import factorial

n, m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
else:
    n_per = factorial(n) // factorial(n - n)
    m_per = factorial(m) // factorial(m - m)
    if n != m:
        print((n_per * m_per) % (10**9 + 7))
    else:
        print((n_per * m_per *2) % (10**9 + 7))

Measured memory_bytes: 5080
import sys
S = input()
T = input()

sys.exit() if not (S.islower() or T.islower()) else ''
sys.exit() if not (2 <= len(S) <= 100) else ''

array_S = list(S)
array_T = list(T)

for I in range(len(array_S)):
    array_S.insert(0,array_S.pop(-1))
    if array_S == array_T:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 8844
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long int)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

int p[20000];ll dp[200005];


int main(){
	fastio();
	//input();

	ll N;
	ll W;
	cin>>N>>W;
	ll w[N+1];
	ll v[N+1];
	ll total_val=0;
	for(ll i=1;i<=N;i++){
		cin>>w[i]>>v[i];
		total_val+=v[i];
	}
	ll dp[N+1][total_val+1];
	for(ll i=0;i<=N;i++){
		for(ll j=0;j<=total_val;j++){
			if(j==0){
				dp[i][j] = (ll)0;
			}
			else{
				dp[i][j] = INF64;
			}
		}
	}
/*	for(int i=0;i<=N;i++){
		for(int j=0;j<=total_val;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=total_val;j++){
			if(v[i]<=j)
				dp[i][j] = min(w[i]+dp[i-1][j-v[i]],dp[i-1][j]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	ll ans =0;
	for(ll i=1;i<=total_val;i++){
		if(dp[N][i]<=W){
			ans = i;
		}
	}
	cout<<ans<<endl;
	return 0;
}
     

Measured memory_bytes: 79232
#include <iostream>
#include <iomanip> // setprecision など
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;
double pi2 = acos(-1.0) * 2.0;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15);

    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double xh = a * cos((60.0 * h + m) * pi2 / 720.0);
    double xm = b * cos(m * pi2 / 60.0);
    double yh = a * sin((60.0 * h + m) * pi2 / 720.0);
    double ym = b * sin(m * pi2 / 60.0);
    debug(xh, xm, yh, ym, (xh - xm), (yh - ym));
    cout << sqrt((xh - xm) * (xh - xm) + (yh - ym) * (yh - ym)) << endl;

    return 0;
}


Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  int count=0;
  int count2=0;
  if(y%2!=0){
    cout<<"No"<<'\n';
    return(0);
  }
  if(x*2>y){
    cout<<"No"<<'\n';
    return(0);
  }
  while(y>=4){
    y-=4;
    count++;
  }
  while(y>=2){
    y-=2;
    count2++;
  }
  if(count+count2<=x){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

    vector<vector<int>> G(n + 1);
    while (m--) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<int> ans(n + 1);
    vector<int> visited(n + 1);

    // parent, node
    queue<pair<int, int>> Q;

    Q.emplace(1, 1);
    visited[1] = true;

    while (!Q.empty()) {
        int size = Q.size();

        while (size--) {
            pair<int, int> p = Q.front();
            Q.pop();

            if (p.second != 1) {
                ans[p.second] = p.first;
            }

            for (const auto& child : G[p.second]) {
                if (!visited[child]) {
                    Q.emplace(p.second, child);
                    visited[child] = true;
                }
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        if (!visited[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 10504
import sys
def main():
    x, n = map(int, input().split())
    p = list(map(int,input().split()))

    if (n == 0):
        print(x)
    else:
        for i in range(100):
            low = x - i
            if (low not in p):
                print(low)
                sys.exit()
            up = x + i
            if (up not in p):
                print(up)
                sys.exit()
                
main()


Measured memory_bytes: 9192
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var Y = int.Parse(Console.ReadLine());

            var result = Math.Min(N, K) * X + Math.Max((N - K), 0) * Y;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

LL N;
LL ans;

void check(LL x) {
  if (x == 1) return;
  --x;
  if (N%x == N/x) ans += x;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  for (LL i=1; i*i <= N; i++) {
    if (N%i == 0) {
      check(i);
      if (i*i != N) check(N/i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define debd(x) pf("%s = %d\n", #x, x)
#define debs(x) pf("%s = %s\n", #x, s)
#define debll(x) pf("%s = %lld\n", #x, x)
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

struct P {
	int x,y;
};

int main() {
//    freopen("input.in", "r", stdin);
	int n, m;
	sf("%d %d", &n, &m);
	P s[55], c[55];
	fr(i, 0, n)
		sf("%d %d", &s[i].x, &s[i].y);
	fr(i, 0, m)
		sf("%d %d", &c[i].x, &c[i].y);
	fr(i, 0, n) {
		int cur = INF, res;
		fr(j, 0, m) {
			int dist = abs(c[j].x - s[i].x) + abs(c[j].y - s[i].y);
			if(dist < cur) {
				res = j+1;
				cur = dist;
			}
		}
		pf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 384
class Tree:
    def __init__(self, n):
        self.nodes = {node: {'parent': None, 'children': [], 'depth': None} for node in range(n)}

    def add_node_with_child(self, node, children):
        for c in children:
            self.nodes[node]['children'].append(c)
            self.nodes[c]['parent'] = node
    
    def get_parent(self, node):
        return self.nodes[node]['parent']

    def get_children(self, node):
        return self.nodes[node]['children']
    
    def get_depth(self, node):
        if self.nodes[node]['depth'] != None:
            return self.nodes[node]['depth']
        elif self.nodes[node]['parent'] == None:
            self.nodes[node]['depth'] = 0
            return 0
        else:
            depth = self.get_depth(self.nodes[node]['parent']) + 1
            self.nodes[node]['depth'] = depth
            return depth


n = int(input())
T = []
for _ in range(n):
    t = list(map(int, input().split()))
    T.append(t)

RootedTree = Tree(n)
for t in T:
    if t[1] == 0:
        continue

    node = t[0]
    children = t[2:]
    RootedTree.add_node_with_child(node, children)

for node in range(n):
    parent = RootedTree.get_parent(node)
    if parent == None:
        parent = -1
    depth = RootedTree.get_depth(node)
    children = RootedTree.get_children(node)
    children = ', '.join(list(map(str, children)))

    if parent == -1:
        node_type = 'root'
    elif children == '':
        node_type = 'leaf'
    else:
        node_type = 'internal node'

    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(node, parent, depth, node_type, children))


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll uni[100005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll x,y;
    for(int i=0;i<m;i++){
    	cin>>x>>y;
    	connect(x,y);
    }
    if(n-1==m){
    	cout << 0 <<endl;
    	return 0;
    }
    if(2*(n-1-m)>n){
    	cout << "Impossible"<<endl;
    	return 0;
    }
    ll b[n];
    for(int i=0;i<n;i++){
    	b[i]=root(i);
    }
    map<ll,ll> mp;
    vector<pair<ll,ll> > ve;
    for(int i=0;i<n;i++){
    	ve.push_back({a[i],b[i]});
    }
    sort(be(ve));
    for(int i=0;i<n;i++){
    	if(mp.find(ve[i].second)==mp.end()){
    		mp[ve[i].second]=ve[i].first;
    	}else{
    		mp[ve[i].second]=min(mp[ve[i].second],ve[i].first);
    	}
    }
    multiset<pair<ll,ll> > ms;
    ll num=2*(n-1-m)-mp.size();
    for(int i=0;i<n;i++){
    	ms.insert(ve[i]);
    }
    ll ans=0;
    for(auto& i:mp){
    	ans+=i.second;
    	ms.erase(ms.find({i.second,i.first}));
    }//////
    auto itr=ms.begin();
    for(int i=0;i<num;i++){
    	ans+=itr->first;
    	itr++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 13552
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}


using pii=pair<int,int>;
using ll=long long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

pair<pii,pii> cut(const pii& cake, int si){


  auto w=cake.first;
  auto d=cake.second;
  auto r=w*2+d*2;
  si%=r;
  //cout << w << " " << d << endl;
  if(si<=w){
    return pair<pii,pii>(
            pii(min(si,w-si),d),
            pii(max(si,w-si),d)
          );
  }else if(si<=w+d){
    return pair<pii,pii>(
          pii(w,min(si-w,d-(si-w))),
          pii(w,max(si-w,d-(si-w)))
        );
  }else if(si<=w*2+d){
    return pair<pii,pii>(
          pii(min(si-d-w,w-(si-d-w)),d),
          pii(max(si-d-w,w-(si-d-w)),d)
        );
  }
  return pair<pii,pii>(
          pii(w,min(si-w-w-d,d-(si-w-w-d))),
          pii(w,max(si-w-w-d,d-(si-w-w-d)))
        );
}

void solve(int n, int w, int d){
  vector<pii> box;
  box.push_back(pii(w,d));

  rep(i,n){
    int pi,si;
    cin >> pi>>si;
    auto res = cut(box[pi-1],si);
    box.push_back(res.first);
    box.push_back(res.second);
    removeAt(box,pi-1);
    //cout << "end step" << endl;
    //for(auto item : box) {
      //cout << item.first << " " << item.second << endl;
    //}
  }
  
  vector<ll> ans;
  for(auto item : box){
    ans.push_back(item.first*item.second);
  }
  sort(ans.begin(),ans.end());

  auto len=ans.size();
  for(int i=0;i<len-1;i++){
    cout << ans[i] << " ";
  }
  cout << ans[len-1] << endl;
}

int main()
{
  int n,w,d;
  cin >> n>>w>>d;
  while(n||w||d){
    solve(n,w,d);
    cin >> n>>w>>d;
  }
  return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll K, A, B; cin >> K >> A >> B;
	if (B-A <= 2 || K-1 < A) {
		cout << K+1 << endl;
	} else {
		ll nokori = K - (A-1);
		ll num = A;
		if (nokori&1) num++, nokori--;
		nokori >>= 1;
		cout << num + nokori * (B-A) << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3644
//ABC163 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;
lint a[300000];


int main() {
  cin >> n;

/*   rep(i,n){
    scanf("%lld",&a[i]);
  } */
  double PI=3.14159265358979323846;
  
  printf("%lf\n",2*n*PI);
}


Measured memory_bytes: 3752
//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>

#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
using namespace std;
// using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

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

    int ans = 2 * 5000 * pow(10, 5);
    int z = max(x, y);
    for (int i = 0; i <= z; i++) {
        int yen = 2 * c * i + a * max(0, x - i) + b * max(0, y - i);
        ans = min(ans, yen);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;


void solve()
{
int n;	
cin>>n;
n%=1000;
if(n!=0)
cout<<abs(1000-n);
else
cout<<"0";
}


int32_t main()
{
FAST
l T=1;
//cin>>T;
while(T--)
{
solve();
}
}










Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int INF = INT_MAX / 4;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( ui i = (ui)( m ); i < (ui)( n ); i++ )
#define EACH( v, c ) for ( __typeof( c.front() ) &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
		{
		int n;
		cin >> n;
		
		if ( n == 0 )
		{
			break;
		}

		vector< set<int> > knows( n );

		for ( auto &per : knows )
		{
			int	m;
			cin >> m;

			REP( i, 0, m )
			{
				int p;
				cin >> p;
				per.insert( p );
			}
		}

		int k;
		cin >> k;

		vector<int> ls( k );

		for ( auto &l : ls )
		{
			cin >> l;
		}

		VI res;

		REP( i, 0, n )
		{
			bool flag = true;

			REP( j, 0, k )
			{
				if ( !EXIST( knows[i], ls[j] ) )
				{
					flag = false;
				}
			}

			if ( flag )
			{
				res.PB( i + 1 );
			}
		}

		if ( res.size() == 1 )
		{
			cout << res[0] << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}

	return 0;
}

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

ll read(){
	ll s=0,w=1; char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') w=-1; ch=getchar();}
	while (ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^'0'), ch=getchar();
	return s*w;
}

void write(ll s){
	if (s<0) s=-s,putchar('-');
	if (s>9) write(s/10);
	putchar(s%10+'0');
}

void writeln(ll s){
	write(s); puts("");
}

void writeln(){
	puts("");
}

int n;
char s[10001];

int check(int x){
	int l = x, r = x; 
	while (s[l]==s[x]) l--; while (s[r]==s[x]) r++;
	if (s[x]=='W'&&s[l]=='B'&&s[r]=='B') return r-l-1;
	if (s[x]=='B'&&s[l]=='W'&&s[r]=='W') return r-l-1;
	return 0;
}
	

signed main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	int ans = 0;
	for (int i=1;i<=n;i++){
		if (s[i]!='.') continue;		
		s[i] = 'W';
		if (!check(i)) for (int j=1;j<=n;j++) if (s[j]=='B') ans = max(ans,check(j));
		s[i] = '.';
	}
	writeln(ans);
int qwq;
	return 0;
}


Measured memory_bytes: 3164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    bool enter = true;
    for(int i = 0; i < s.length(); i++){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
                enter = true;
            }
            else{
                cout << "No";
                return 0;
            }
        }
        if(i%2==1){
            if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
                enter = true;
            }
            else{
                cout << "No";
                return 0;
            }
        }
    }
    if(enter == true){
        cout << "Yes";
    }
}

Measured memory_bytes: 256