akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N]; 
vector <pii> v;
ll cnt[N];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], v.pb ({a[i], i});
   v.pb ({0, 0});
   sort (all (v));
   int will = n + 1;
   for (int i = sz (v) - 1; i > 0; i --) {
      will = min (will, v[i].S);
      cnt[will] += 1ll * (v[i].F - v[i - 1].F) * (sz (v) - i);
   }
   for (int i = 1; i <= n; i ++) cout << cnt[i] << '\n';
}               

 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

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

int main() {
    string s;
    cin >> s;
    bool N = false, S = false, W = false, E = false;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'N') N = true;
        else if (s[i] == 'S') S = true;
        else if (s[i] == 'W') W = true;
        else E = true;
    }

    if (N == S && W == E) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e+9;
int main()
{
	long long S;
	cin >> S;
	int x1,x2,x3,y1,y2,y3;
	x1 = 0 ; y1 = 0 ;
	x2 = inf ; y2 = 1 ;
	y3 = S / inf + 1 ;
	x3 = inf - S % inf;
	if(S % inf == 0)
	{
		y3 -- ;
		x3 = 0 ;
	}
	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3;
	return 0;
	
 } 

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

using namespace std;

int N;
long long a[100000];

#define rep(i, a) for(int i = 0; i < a; i++)
#define reps(i, a, b) for(int i = a; i < b; i++)

int main()
{
  cin >> N;
  long long ma = -1;
  long long mi = 1000000000000;
  int ind = 0;
  rep(i, N) {
    cin >> a[i];
    if (ma < a[i]) {
      ma = a[i];
      ind = i;
    }
    a[i] <<= 1;
  }
  cout << ma << " ";
  long long res;
  rep(i, N) {
    if(mi > abs(a[i]-ma) && ind != i) {
      mi = abs(a[i]-ma);
      res = a[i] >> 1;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int x,i=1;
  while(true){
    cin>>x;
    if(x==0) break;
    else{
      cout<<"Case "<<i<<": "<<x<<'\n';
      i++;
    }
  }
  return(0);
}



Measured memory_bytes: 3140
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = b = None
for i, xs in enumerate(permutations(range(1, N + 1))):
    if xs == P:
        a = i
    if xs == Q:
        b = i
print(abs(a - b))

Measured memory_bytes: 39280
using System;
class atcoder{
    public static void Main(){
        int cnt = 0;
        int n = int.Parse(Console.ReadLine());
        string[] p = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++){
            if (i + 1 == int.Parse(p[i])){
                continue;
            }else{
                cnt ++;
            }
        }
        if (cnt == 0 || cnt == 2){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11092
// AOJ 0251: Magic Square
// 2017.12.16 bal4u@uu

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

#define MAX 100002

/* UNION-FIND library */
int p[MAX], rank[MAX];
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

char f[MAX];
char buf[20], *bp;

int in()
{
	int n = 0;
	while (*bp >= '0') n = 10*n + (*bp++ & 0xf);
	bp++;
	return n;
}

int main()
{
	int n, m, a, b, ans;

	while (fgets(bp=buf, 20, stdin) && *bp != '0') {
		n = in(), m = in();

		memset(rank, 0, sizeof(int)*(n+1));
		for (a = 1; a <= n; a++) p[a] = a;
		memset(f, 0, n+1);

		ans = 1;
		while (m--) {
			fgets(bp=buf, 20, stdin);
			if (ans) {
				a = in(), b = in();
				if (++f[a] > 2) ans = 0;
				if (++f[b] > 2) ans = 0;
				if (find_set(a) == find_set(b)) ans = 0;
				union_set(a, b);
			}
		}
		puts(ans ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 2544
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int n,m,ans;
char f[110][110];

int di[4]={0,0,1,-1};
int dj[4]={1,-1,0,0};

class Info{
public:
	int i,j,walk;
};

void bfs(int i,int j){
	int k,l,w[110][110];
	queue<Info> q;
	Info tmp = {i,j,0};

	if(f[i][j] == 'G'){ans = 0; return;}
	for(k=0;k<110;k++) for(l=0;l<110;l++) w[k][l] = 99999;

	w[i][j] = 0;
	ans = 99999;
	q.push(tmp);

	while(!q.empty()){
		tmp = q.front(); q.pop();

		for(int k=0;k<4;k++){
			int ni = tmp.i + di[k];
			int nj = tmp.j + dj[k];
			int nwalk = tmp.walk;

			if(f[tmp.i][tmp.j] == '.' && f[ni][nj] == '#') nwalk++;

			if(f[ni][nj] == 'G'){
				if(ans > tmp.walk) ans = tmp.walk;
			}
			else if(nwalk < w[ni][nj]){
				Info tmp2 = {ni,nj,nwalk};

				w[ni][nj] = nwalk;
				q.push(tmp2);
			}
		}
	}
}

void dfs(int i,int j){
	f[i][j] = 'G';
	for(int k=0;k<4;k++){
		int ni = i + di[k];
		int nj = j + dj[k];
		if(f[ni][nj] == '.') dfs(ni,nj);
	}
}

int main(void){
	int i,j,si,sj;

	while(cin>>n>>m && (n || m)){
		memset(f,'.',sizeof(f));
		for(i=1;i<=m;i++){
			for(j=1;j<=n;j++){
				cin>>f[i][j];
				if(f[i][j] == '&'){f[i][j]='.'; si=i; sj=j;}
			}
		}

		dfs(0,0);
		bfs(si,sj);

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
while True:
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    if op == '+':
        print("{}".format(a+b))
    elif op == '-':
        print("{}".format(a-b))
    elif op == '*':
        print("{}".format(a*b))
    elif op == '/':
        print("{}".format(a//b))
    elif op == '?':
        break



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000000000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    mseti m;
    for(ll i=n-1;i>=0;i--)
    {
        if(m.ub(a[i])==m.end())
        {
            m.insert(a[i]);
        }
        else
        {
            m.erase(m.ub(a[i]));
            m.insert(a[i]);
        }
    }
    cout<<m.size();
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main()
{
    long long N;
    cin >> N;

    long long sum = 0;
    for (int i = 1; i <= N; i++){
        long long n = N / i;
        sum += i * n * (n + 1) / 2;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.bestbody", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0 ){
			break;
		} // end if
		multimap <double, int> rank;
		int j;

		for (j = 0; j < n; ++j){
			int i, h, w; // index, h[cm], w[kg];  
			getline (cin, str );
			stringstream ss(str);
			ss >> i >> h >> w;
			double bmi = (double)w / ( (h/100.)*(h/100.) );
			double diff = fabs (bmi - 22.0);
			rank.insert (make_pair (diff, i ) );
		} // end for
		multimap <double, int>::iterator it = rank.begin();
		cout << (*it).second << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;


int main(){
  string o,e; cin >> o >> e;
  bool flg = false;
  string ans = "";
  if(o.size() != e.size()) flg = true;
  rep(i,o.size()){
    ans += o[i];
    if(i == o.size()-1 && flg) break;
    ans += e[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
	int n,k,q;
	cin >> n;
	cin >> k;
	cin >> q;

	int t;

	vector<int> a(n),b(n);
	for (int i = 0; i < n; i++) {
		b[i] = 0;
	}
	for (int i = 0; i < q; i++) {
		cin >> t;
		b[t - 1] = b[t - 1] + 1;
		}
	for (int i = 0; i < n; i++) {
		a[i] = k-q+b[i];
	}

	for (int i = 0; i < n-1; i++) {
		if (a[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}

	}
	if (a[n-1] > 0) {
		cout << "Yes" ;
	}
	else {
		cout << "No" ;
	}


	/*vector<vector<double>> a(2, vector<double>(n));
	vector<int> b(n);
	*/

	/*long long kai;
	kai = 1;
	for (long long i = 1; i <= nm; i++) {
		kai = (kai * i) % mod;
	}*/


	//cout << fel(kai,mod-2);

	//vector<long long> sei(nm), gyaku(nm);

}


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

using namespace std;

int n=0;	
int a[100001];
int b[100001];
int res[100001];
vector<pair<int, int> > g[100001];
int Max=0;	
bool used[100001];

void dfs(int v, int c)
{
	used[v] = true;
	int x=0;
	for (int i=0; i<g[v].size(); i++)
	{
		if (!used[g[v][i].first])		
		{
			if (x==c)
				x++;
			res[g[v][i].second] = x;			
			dfs(g[v][i].first, x);
			x++;
		}
	}	
}

int main()
{
	cin >> n;
	for (int i=0; i<n-1; i++)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		g[a[i]].push_back({b[i], i});
		g[b[i]].push_back({a[i], i});
		
	}
 	for (int i=0; i<n; i++)
	{
		Max = max(Max, (int) g[i].size());
	}
	dfs(0, -1);
	cout << Max << endl;
	for (int i=0; i<n-1; i++)
		cout << res[i]+1 << endl;
	return 0;
}


Measured memory_bytes: 8960
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    ll a[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll s[100002] {0};
    for(int i = p - 1; i < n; i++) s[i] = s[i - 1] + a[i];
    int ans = p;
    for(int i = p; i < n; i++){
        if(a[i] + m < a[p - 1]) break;
        if((a[i] + m) * (i - p + 2) - s[i] + m * (n - i - 1) >= m * (v - p + 1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = [list(map(int,list(input().split()))) for _ in range(n)]
mod = 10**9 + 7
dp = [0] * (2**n)

dp[0] = 1

bitcnt = [0] * (2**n)

def who(s):
    ans = []
    i = 0
    while s > 0:
        if s%2:
            ans.append(i)
        i += 1
        s = s >> 1
    return ans

for i in range(1,2**n):
    bitcnt[i] = bitcnt[i >> 1] + i%2
    for l in who(i):
        dp[i] += dp[i - 2**l] * a[bitcnt[i] - 1][l]
        dp[i] %= mod
print(dp[2**n - 1])


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

void move(int direction, int w, int h, pair<int, int>& coord) {
    int k;
    cin >> k;
    switch (direction) {
    case 0:
        coord.second += min(k, h - coord.second);
        break;
    case 1:
        coord.first += min(k, w - coord.first);
        break;
    case 2:
        coord.second -= min(k, coord.second - 1);
        break;
    case 3:
        coord.first -= min(k, coord.first - 1);
        break;
    }
}

int main() {
    while (true) {
        int w, h;
        cin >> w >> h;
        if ((w | h) == 0) {
            break;
        }
        pair<pair<int, int>, int> robot = make_pair(make_pair(1, 1), 0);
        string command = "";
        while (command != "STOP") {
            cin >> command;
            if (command == "FORWARD") {
                move(robot.second, w, h, robot.first);
            } else if (command == "BACKWARD") {
                move((robot.second + 2) % 4, w, h, robot.first);
            } else if (command == "RIGHT") {
                robot.second = (robot.second + 1) % 4;
            } else if (command == "LEFT") {
                robot.second = (robot.second + 3) % 4;
            }
        }
        cout << robot.first.first << " " << robot.first.second << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define ins				insert
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull				unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>
#define usi 			unordered_set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}

void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
bool cmp(Node A,Node B)
{
	return A.a<B.a;
}
const int Max=1e5+1;

int32_t main()
{
	c_p_p();
	int n,x;
	cin>>n>>x;
	int A[1001]={};
	rep(i,0,x)
	{
		int a;
		cin>>a;
		A[a]=1;
	}
	int ans=0;
	repd(i,n,-1)
	{
		int p=n-i;
		if(!A[i])
		{
			ans=i;
			break;
		}
		if(!A[n+p])
		{
			ans=p+n;
			break;
		}
	}
	cout<<ans;

	return 0;
}
	

Measured memory_bytes: 3660
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
# coding: utf-8
# Your code here!
a = input().split()
N = int(a[0])
M = int(a[1])
b = []
k = [int(input()) for i in range(N)]

temp = int(0)

for i in range(300001):
    b.append(0)
    
seg = SegTree(b, segfunc, ide_ele)

for i in range(N):
    temp = seg.query(max(0, k[i]-M), min(300001, k[i]+M+1))
    seg.update(k[i], temp+1)
    temp = 0
    
print(seg.query(0,300001))


Measured memory_bytes: 137560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//1の数
		int cnt =0;
		String S = sc.next();
for(int num =0; S.length()>num; num++) {
	if(S.charAt(num) == '1') {
		cnt++;
	}
}
		System.out.println(cnt);

	}
}

Measured memory_bytes: 21716
// AOJ 2763: Miko Mi String
// 2017.10.9 bal4u@uu

#include <stdio.h>

char s[1000005];
int a[1000005];

int main()
{
	int n, i, j, w;
	char *p;

	scanf("%s", s);
	a[0] = -1, j = -1;
	for (p = s, i = 0; *p; i++, p++) {
		while (j >= 0 && *p != s[j]) j = a[j];
		a[i+1] = ++j;
	}
	n = i;
	
	j = n - a[n];
	w = j * (n / (3 * j) + 1);
	if (w > 0 && w * 2 < n) { s[w] = 0; printf("Love %s!\n", s); }
	else puts("mitomerarenaiWA");
	return 0;
}

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

using namespace std;

// dp[i][j][k]: i番目までのカードをj枚用いて合計がkになるような選び方の数
long long dp[51][51][2501] = {0};

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

    long long max_sum = N * A;

    int x[51];
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
    }

    // i = 1
    dp[1][0][0] = 1;
    dp[1][1][x[1]] = 1;

    for (int i = 2; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= max_sum; k++) {
                if (k - x[i] < 0) {
                    // カードを加えない場合のみ
                    dp[i][j][k] = dp[i - 1][j][k];
                } else {
                    // カードを加えない場合 + 合計が k - x[i] からカードを加える場合
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                }
            }
        }
    }
/*
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= i; j++) {
            ans += dp[i][j][j * A];
            cout << i << "枚目までから" << j << "枚を用いて合計が" << j * A << " = " << dp[i][j][j * A]  << endl;
        }
    }
*/
    long long ans = 0;
    for (int j = 1; j <= N; j++) {
        ans += dp[N][j][j * A];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 49024
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> a >> b;
	ans = a - b;
	if (ans >= 0)cout << "delicious" << rt;
	else if (abs(ans) <= x)cout << "safe" << rt;
	else cout << "dangerous" << rt;
	please AC;
}

Measured memory_bytes: 256
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Measured memory_bytes: 7760
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
#include<ext/rope>
using namespace __gnu_cxx;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll b[105],a[105],n;
int main()
{
  IOS;
    while(cin>>n)
    {
        rep1(i,n-1) cin>>b[i];
        a[0]=b[1];a[n-1]=b[n-1];
        for(int i=1;i<n-1;i++)
        {
            a[i]=min(b[i],b[i+1]);
        }
        ll sum=0;
        rep(i,n)
        {
            sum+=a[i];
        }
        cout<<sum<<'\n';
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var K = input[0];
            var X = input[1];

            Console.WriteLine(K * 500 >= X ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

/** AOJ_No.1172 ICPC_2011_A */
public class Main {
	public static final int DATA_MAX = 123456 * 2 + 1;

	public static void main(String[] args) {
		/* 素数表を作る */
		int[] primeNum = new int[DATA_MAX];/* 素数表(初期値:false) */
		for(int i = 2; i < DATA_MAX; i++) {
			/* 初期値なら素数 */
			if(primeNum[i] == 0) {
				primeNum[i] = 1;

				/* その素数の倍数を埋める */
				for(int j = i * 2; j < DATA_MAX; j += i) {
					primeNum[j] = 2;/* 非素数 */
				}
			}
		}
		
		Scanner sc = new Scanner(System.in);		
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			
			int count = 0, nn = n * 2;
			for(int i = n + 1; i <= nn; i++) {
				if(primeNum[i] == 1) count++;
			}
			System.out.println(count);
		}
	}
}



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

using namespace std;

#define ll long long
#define M 1005000
#define ii pair<ll, ll>
#define fi first
#define se second
#define pb push_back

ll n, a[M], b[M], c[M], sum;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i], sum += b[i];
    for (int i = 1; i < n; i++) cin >> c[i];
    for (int i = 2; i <= n; i++) if (a[i] == a[i - 1] + 1) sum += c[a[i] - 1];
    cout << sum;
    return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[10001];
int main()
{
	int i,j,n,m,lens,joi,ioi;
	while(cin>>s)
	{
		lens=strlen(s);
		if(lens==3&&s[0]=='E'&&s[1]=='O'&&s[2]=='F')break;
		joi=0;
		ioi=0;
		for(i=0;i<lens;i++)
		{
			if(s[i]=='J')
			{
				if(s[i+1]=='O'&&s[i+2]=='I')joi++;
			}
			if(s[i]=='I')
			{
				if(s[i+1]=='O'&&s[i+2]=='I')ioi++;
			}
		}
		cout<<joi<<endl<<ioi<<endl;
	}
	return 0;
}

Measured memory_bytes: 2988
package main
import (
  "fmt"
  "strings"
)
func main() {
  var s,t,ss,ts string
  fmt.Scan(&s,&t)
  n,m := len(s),len(t)
  ss = s+s+s
  if len(ss) < 2*m { ss = strings.Repeat(ss,(2*m+len(ss)-1)/len(ss)) }
  ts = t+ss
  z := z_algorithm(ts)
  ok := make([]bool,n)
  for i:=0;i<n;i++ {
    if z[m+i] >= m { ok[i] = true }
  }
  uf := NewUnionFind(n)
  for i:=0;i<n;i++ {
    if ok[i] && ok[(i+m)%n] {
      if uf.Same(i,(i+m)%n) { fmt.Println(-1);return }
      uf.Unite(i,(i+m)%n)
    }
  }
  ans := 0
  for i:=0;i<n;i++ {
    if !ok[i] { continue }
    tmp := uf.Size(i)
    if ans < tmp { ans = tmp }
  }
  fmt.Println(ans)
}
func z_algorithm(s string) []int {
  n := len(s)
  z := make([]int,n)
  z[0] = n
  for i,j:=1,0;i<n; {
    for i+j < n && s[j:j+1] == s[i+j:i+j+1] { j++ }
    z[i] = j
    if j == 0 { i++;continue }
    k := 1
    for ;i+k<n&&k+z[k]<j;k++ { z[i+k] = z[k] }
    i,j = i+k,j-k
  }
  return z
}
type UnionFind struct { par,rank,size []int }
func NewUnionFind(n int) UnionFind {
  par := make([]int,n)
  rank := make([]int,n)
  size := make([]int,n)
  for i:=0;i<n;i++ { par[i],size[i] = i,1 }
  return UnionFind{par,rank,size}
}
func(u UnionFind) Find(i int) int {
  if u.par[i] == i { return i }
  u.par[i] = u.Find(u.par[i])
  return u.par[i]
}
func(u UnionFind) Same(i,j int) bool { return u.Find(i) == u.Find(j) }
func(u UnionFind) Unite(i,j int) {
  i,j = u.Find(i),u.Find(j)
  if i == j { return }
  if u.rank[i] < u.rank[j] {
    u.par[i] = j
    u.size[j] += u.size[i]
  } else {
    u.par[j] = i
    u.size[i] += u.size[j]
    if u.rank[i] == u.rank[j] { u.rank[i]++ }
  }
}
func(u UnionFind) Size(i int) int { return u.size[u.Find(i)] }

Measured memory_bytes: 35456
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ll n, a, dz = 0, ans = 0;
    scanf("%lld%lld", &n, &a);
    vector<ll> x(n), dp(2501), dn(2501);
    dp.at(0) = (dn.at(0) = 1);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", x.begin() + i);
        x.at(i) -= a;
        if (x.at(i) > 0) {
            for (ll j = 2500; j >= 0; --j) if (dp.at(j)) dp.at(j + x.at(i)) += dp.at(j);
        } else if (x.at(i) < 0) {
            for (ll j = 2500; j >= 0; --j) if (dn.at(j)) dn.at(j - x.at(i)) += dn.at(j);
        } else ++dz;
    }
    for (ll i = 0; i <= 2500; ++i) {
        ans += dp.at(i) * dn.at(i);
    }
    printf("%lld\n", (ans << dz) - 1);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y;
	int cnt;
	int temp;

	scanf("%d %d",&x,&y);
	while(x!=0 && y!=0){
		cnt=0;
		if(x<y){
			temp=x;
			x=y;
			y=temp;
		}
		while(y!=0){
			x=x%y;
			temp=x;
			x=y;
			y=temp;
			cnt++;
		}
	printf("%d %d\n",x,cnt);
	scanf("%d %d",&x,&y);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

int main()
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(r <= x && x <= (W-r) && r <= y && y <= (H-r)) printf("Yes\n");
else printf("No\n");

return 0;

}

Measured memory_bytes: 1012
/*
ID:yaoxinw1
TASK:xxxx
LANG:C++
*/
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	if(n%k)
	cout<<1<<endl;
	else
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split())) # 横入力

x = [0]
aaa = 0
aa = sum(a)
# y = [aa]
for i in range(n):
    aaa += a[i]
    x.append(aaa)
    # aa -= a[i]
    # y.append(aa)

ans = 202020202020
for i in range(n+1):
    ans = min(ans, abs(aa - x[i]*2))

print(ans)

Measured memory_bytes: 26396
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    rep0(i, N-1) cin >> P[i], --P[i];
    rep0(i, N-1) cin >> C[i];
    ll INF = 1e18;
    ll ans = -INF;
    rep0(i, N-1) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;
        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }
        ll path = 0;
        int cnt = 0;
        while (true) {
            cnt++;
            path += C[v];
            if (cnt > K) break;
            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            if (ans < score) ans = score;
            v = P[v];
            if (v == i) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
#include<math.h>
int main(){
	int a,b,c,count;
	while(scanf("%d %d",&a,&b)!=EOF){
		count=0;
		c=a+b;
		//printf("%d %d\n",a,b);
		while(c){
			c=c/10;
			count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 100005
int n,a[N],cnt1,cnt4;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%4==0) cnt4++;
		else if(a[i]&1) cnt1++;
	}
	if(cnt1+cnt4<n)
	{
		if(cnt4>=cnt1) puts("Yes");
		else puts("No");
	}
	else
	{
		if(cnt4>=cnt1-1) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

const int MAXN = 3e5 + 5;

int n, x, y, a, b, c, num_x, num_y, k;
long long int ans;

struct apple {
    long long int delicious;
    int color;

    apple() {
        delicious = color = 0;
    }

    bool operator < (const apple &another) const {
        return delicious > another.delicious;
    }
}arr[MAXN];

int main() {
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    n = x + y;
    for (int i = 1; i <= a; ++i) {
        scanf("%lld", &arr[i].delicious);
        arr[i].color = 1;
    }
    for (int i = a + 1; i <= a + b; ++i) {
        scanf("%lld", &arr[i].delicious);
        arr[i].color = 2;
    }
    for (int i = a + b + 1; i <= a + b + c; ++i) {
        scanf("%lld", &arr[i].delicious);
        arr[i].color = 0;
    }
    std::sort(arr + 1, arr + a + b + c + 1);
    for (int i = 1; i <= n; ++i) {
        ans += arr[i].delicious;
        num_x += (arr[i].color == 1);
        num_y += (arr[i].color == 2);
    }
    if (num_x > x) {
        k = num_x - x;
        for (int i = n, j = 0; i && j < k; --i) {
            if (arr[i].color == 1) {
                ans -= arr[i].delicious;
                ++j;
            }
        }
        for (int i = n + 1; i <= a + b + c && k; ++i) {
            if (arr[i].color == 2 || arr[i].color == 0) {
                ans += arr[i].delicious;
                --k;
            }
        }
    }
    if (num_y > y) {
        k = num_y - y;
        for (int i = n, j = 0; i && j < k; --i) {
            if (arr[i].color == 2) {
                ans -= arr[i].delicious;
                ++j;
            }
        }
        for (int i = n + 1; i <= a + b + c && k; ++i) {
            if (arr[i].color == 1 || arr[i].color == 0) {
                ans += arr[i].delicious;
                --k;
            }
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4864
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
//¿ª O2£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡ 
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef long long LL;
typedef double db;
const int N=100+5,mo=10007;
int a,b,c,d;
ll K;
int main()
{
	scanf("%d %d %d %lld\n",&a,&b,&c,&K);
	K%=2;
	d=a-b;
	if (K) d=-d;
	printf("%d\n",d);
}

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

    const int maxn = 2e5 + 10;
    long long a[maxn], b[maxn];

    int main()
    {
        int n, m, ans = 0;
        long long k;
        cin >> n >> m >> k;
        for (int i = 1; i <= n; i++) cin >> a[i];
        for (int i = 1; i <= m; i++) cin >> b[i];
        for (int i = 1; i <= n; i++) a[i] += a[i - 1];
        for (int i = 1; i <= m; i++) b[i] += b[i - 1];
        // Solution2
        int j = m;
        for (int i = 0; i <= n; i++) {
            if (k < a[i]) break;
            while(b[j] > k - a[i]) j--;
            ans = max(ans, i + j);
        }
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 6728
N = int(input())
X = sorted([list(map(int, input().split())) for _ in range(N)])


front = []
most_left_R = float('inf')
for l, r in X:
    most_left_R = min(r, most_left_R)
    front.append(max(0, most_left_R - l + 1))

back = []
most_left_R = float('inf')
for l, r in X[::-1]:
    most_left_R = min(r, most_left_R)
    back.append(max(0, most_left_R - X[-1][0] + 1))
back = back[::-1]

ans = 0
for i in range(N - 1):
    ans = max(ans, front[i] + back[i + 1])

most_left_R = min([r for l, r in X])
for l, r in X:
    ans = max(ans, (r - l + 1) + max(0, most_left_R - X[-1][0] + 1))
print(ans)


Measured memory_bytes: 35752
import bisect

def ctoi(char):
  return ord(char)-ord('a')

s=input()
l=len(s)
t=input()
if len(set(t)-set(s))!=0:
  print(-1)
  exit()
pos=[[] for _ in range(26)]
for i in range(2*l):
  pos[ctoi(s[i%l])].append(i+1)
index=0
loop=0
for i in range(len(t)):
  tmp=bisect.bisect_right(pos[ctoi(t[i])],index)
  next_index=pos[ctoi(t[i])][tmp]
  if next_index>=l:
    loop+=1
  index=next_index%l
print(l*loop+index)

Measured memory_bytes: 17928
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int N = 200100;
int g[N];

int32_t main(){
	fastio;
   double R;
   cin>>R;
   double PI = acos(-1);
   R = 2.0*PI*R;
   cout<<setprecision(6)<<fixed;
   cout<<R<<endl;
}

Measured memory_bytes: 3800
main :: IO ()
main = do
    a1 <- map toInt . words <$> getLine
    a2 <- map toInt . words <$> getLine
    print $ a1 !! 0 * a1 !! 1 - a2 !! 0 * a1 !! 1 - a2 !! 1 * (a1 !! 0 - a2 !! 0)

toInt :: String -> Int
toInt x = read x :: Int

Measured memory_bytes: 508
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

typedef vector<P> vp;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> B(M), C(M);
  REP(i, M) cin >> B[i] >> C[i];
  priority_queue<P, vp> que;
  // (カードに書かれた数字, カードの枚数)のペアにしておく
  REP(i, N) que.push(P(A[i], 1));
  REP(i, M) que.push(P(C[i], B[i]));
  ll ans = 0;
  int cnt = N;
  while (que.size()) {
    int t = min(cnt, que.top().second);
    ans += 1ll * t * que.top().first;
    cnt -= t;
    que.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3700
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long a1 = a*c;
		long res =a1;
		long a2 = a*d;
		if(a2>res)
			res=a2;
		long a3 = b*c;
		if(a3>res)
			res=a3;
		long a4 = b*d;
		if(a4>res)
			res=a4;
		System.out.println(res);
	}
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {
	long long N, tmp, ans = 0;
	vector<long long> vec;

	cin >> N;

	for (long long i = 0; i < N; i++) {
		cin >> tmp;
		vec.push_back(tmp);
	}

	sort(vec.begin(), vec.end(), greater<long long>());

	tmp = 0;
	for (long long i = 1; i <= N ; i++) {
		if (i == 1) {
			ans = ans + 0;
			continue;
		}

		ans = ans + vec[tmp];

		if (i % 2 == 0) {
			tmp++;
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;

using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

using vi=vector<int>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
template<class T>bool is_prime(T IN){
    if(IN<=1)return false;
    for(long long i=2;i*i<=IN;i++){
        if(IN%i==0){
            return false;
        }
    }
    return true;
}
vpllll primefact(ll x){
    vpllll ret;
    for(ll i=1;i*i<=x;i++){;
        //i=√xのときの処理改善の余地あり.
        if(x%i==0){
            vll alt={i,x/i};
            if(alt[0]==alt[1])alt[1]=1;
            rep(j,0,alt.size()){
                if(is_prime(alt[j])){
                   pllll t=make_pair(alt[j],0);
                   while(x%alt[j]==0){
                       x/=alt[j];
                       t.second++;
                   }
                   ret.push_back(t);
                }
            }
       }
    }
    return ret;
}
vll yakusuu(ll x){
    vll ret;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            ll a=i,b=x/i;
            ret.push_back(a);
            if(a!=b)ret.push_back(b);
        }
    }
    return ret;
}
long long INF = 1LL<<60;
int main( ){
    ll n,m; cin>>n>>m;
    vll pf=yakusuu(m);
    sort(pf.begin(),pf.end());
    for(ll i=pf.size()-1;i>=0;i--){
        if(pf[i]*n<=m){
            cout<<pf[i]<<endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			if (a == 0) {
				sc.close();
				break;
			}

			int b = sc.nextInt();
			int d = sc.nextInt();

			int[] ans = new int[2];
			int x = 0;
			int y = 0;
			int minNum = Integer.MAX_VALUE;
			int minWeight = Integer.MAX_VALUE;
			for (int i = 0; i < 50000; i++) {
				x = i;
				if (d - a * i > 0 && (d - a * i) % b == 0) {
					y = (d - a * i) / b;
					if (minNum >= x + y && minWeight >= a * x + b * y) {
						minNum = x + y;
						minWeight = a * x + b * y;
						ans[0] = x;
						ans[1] = y;
					}
				} else if (a * i - d >= 0 && (a * i - d) % b == 0) {
					y = (a * i - d) / b;
					if (minNum >= x + y && minWeight >= a * x + b * y) {
						minNum = x + y;
						minWeight = a * x + b * y;
						ans[0] = x;
						ans[1] = y;
					}

				} else if ((d + a * i) % b == 0) {
					y = (d + a * i) / b;
					if (minNum >= x + y && minWeight >= a * x + b * y) {
						minNum = x + y;
						minWeight = a * x + b * y;
						ans[0] = x;
						ans[1] = y;
					}
				}
			}

			System.out.println(ans[0] + " " + ans[1]);
		}
	}
}

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

using namespace std;

int main()
{
	int h;
	int w;
	cin >> h >> w;

	vector<string> s;
	for (int i = 0; i < h; i++)
	{
		string str;
		cin >> str;
		s.push_back(str);
	}

	int ans = 0;

	// (a,b)→(c,d)
	for (int a = 0; a < w; a++)
	{
		for (int b = 0; b < h; b++)
		{
			if (s[b][a] == '.')
			{
				// (a,b)からの全点探索
				int step[21][21];
				// C++はいちいち初期化せなならんのか？？
				for (int i = 0; i < 21; i++)
				{
					for (int j = 0; j < 21; j++)
					{
						step[i][j] = 0;
					}
				}
				queue<pair<int, int>> que;
				que.push(pair<int, int>{a, b});
				step[a][b] = 1;
				int vx[] = { 0, 1, 0, -1 };
				int vy[] = { 1, 0, -1, 0 };
				while (!que.empty())
				{
					// キューをpに取り出す
					pair<int, int> p = que.front();
					que.pop();
					// 現在の手数を記録しておく
					int now_step = step[p.first][p.second];
					// キューに入ってたとこから4方向に移動
					for (int i = 0; i < 4; i++)
					{
						// 移動先をnpに入力
						pair<int, int> np;
						np.first = p.first + vx[i];
						np.second = p.second + vy[i];

						// 移動先が範囲内なの確認
						if ((0 <= np.first && np.first < w) && (0 <= np.second && np.second < h))
						{
							// 移動先が移動可能だった場合&移動先が未訪問だった場合
							if (s[np.second][np.first] == '.' && step[np.first][np.second] == 0)
							{
								// そこに移動する＝キューに追加
								que.push(pair<int, int>{np.first, np.second});
								// 移動先は現在の手数＋１
								step[np.first][np.second] = now_step + 1;
							}
						}
					}
				}
				for (int c = 0; c < w; c++)
				{
					for (int d = 0; d < h; d++)
					{
						if (s[d][c] == '.' && 1 < step[c][d]) ans = max(ans, step[c][d] - 1);
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll h, w, n;
  cin >> h >> w >> n;
  ll large = max(h, w);
  ll ans = (n - 1) / large + 1;
  print(ans);
}

Measured memory_bytes: 256