akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
int partition(int*, int, int);
int main(){
  int n,tmp;
  std::cin >> n;
  int A[n];
  for(int i=0; i<n; i++) std::cin >> A[i];
  tmp = partition(A, 0, n-1);
  for(int i=0; i<n; i++){
    if(i == tmp) std::cout << "[";
    std::cout << A[i];
    if(i == tmp) std::cout << "]";
    std::cout << (i != n-1 ? " " : "\n");
  }
  return 0;
}

int partition(int *A, int p, int r){
  int x,i,tmp;
  x = A[r];
  i = p - 1;
  for(int j=p; j<=r-1; j++){
    if(A[j] <= x){
      i = i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

Measured memory_bytes: 3388
import math

a,b,h,m=map(int, input().split())

h_rad = 30*h
h_rad += m*0.5
m_rad = 6*m
diff1 = abs(h_rad-m_rad)

diff2 = 360-diff1

diff = min(diff1,diff2)


cos = math.cos(math.radians(diff))
ans = math.sqrt(a**2+b**2-(2*a*b*cos))
print(ans)

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,m;
    cin>>n>>m;
    if(m==n) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
function split(s, c)
  if string.find(s, c) == nil then
    return { s }
  end

  local cs = {}
  
  local lastPos = 0
  for part, p in string.gmatch(s, "(.-)" .. c .. "()") do
    table.insert(cs, part)
    lastPos = p
  end

  table.insert(cs, string.sub(s, lastPos))

  return cs
end

n=io.read("*n")
ans=0
a={}

print("")

for i=0, n-1 do
  table.insert(a, i, io.read("*n")-1)
end

for i=0, n-1 do
  ans = ans + io.read("*n")
end

c={}
for i=0, n-2 do
  table.insert(c, i, io.read("*n"))
end

for i=0, n-2 do
  if a[i]+1 == a[i+1] then
    ans = ans + c[a[i]]
  end
end

print(ans)

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a<<" "<<b<<" "<<3*c-a-b<<endl;
  cout<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c<<endl;
  cout<<a+b-c<<" "<<2*c-b<<" "<<2*c-a<<endl;
}


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

using namespace std;

typedef long long int ll;

#define mod (int ) (1e9+7)


 
 ll ncr(ll x, ll y){
 	ll ans=1;
 	
 	y=(y > x-y? x-y: y);
 	
 	for(ll i=0; i<y; i++){
 		ans=ans*(x-i);
 		ans=ans/(i+1);
 		ans=ans%mod;
 	}
 
 	
 	return ans;
 }

ll power(ll x, ll y){
    ll ans=1;
    while(y){
        if(y&1){
            ans=ans*x;
            ans=ans%mod;
        }
        
        x=x*x;
        x=x%mod;
        y=y>>1;
    }
    
    return ans;
    
}
 
void solve(){

  ll x,k,d; cin>>x>>k>>d;
  
  if(x<0){
  	ll p=abs(x);
  	p=p/d;
  	p=min(p,k);
  	x=x+p*d;
  	k=k-p;
  	ll ans=min(abs(x+((k%2)*d)),abs((x-((k%2)*d))));
  	
  	cout<<ans<<"\n";
  	
  }else if(x>0){
  	
  	ll p=abs(x);
  	p=p/d;
  	p=min(p,k);
  	x=x-p*d;
  	k=k-p;
  	ll ans=min(abs(x+((k%2)*d)),abs((x-((k%2)*d))));
  	
  	cout<<ans<<"\n";
  	
  	
  }else{
  	cout<<(x+(d*(k%2)))<<"\n";
  }
  
  
  
    return ;
	
}

int main(){
    ios_base::sync_with_stdio(0);
    
    cin.tie(0);
    
    int t=1; //cin>>t; 
    
   
    
    // clock_t begin, end;
    
    // double time_spent;
    
    // begin = clock(); // Time taken till now.
    
    
    while(t--){
    	
	  solve();
        
    }
   
   //end= clock(); // Total  Time taken till now.
   
   //time_spent= (end- begin) / CLOCKS_PER_SEC;
   
   //cout<<time_spent<<"\n";
	
	return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int N =sc.nextInt();
      int R =sc.nextInt();
      
      if(N>=10){
      System.out.println(R);
      }
      else if(10>N){
      System.out.println(R+(100*(10-N)));
      }
    }
}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<typename T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<typename T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<typename T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<typename T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<typename T> T &onth(T &a, const T &b){ return a = ont(a, b); }

template<typename T> T make_v(T val){ return val; }
template<typename... Ts> auto make_v(size_t n, Ts... ts){ return std::vector<decltype(make_v(ts...))>(n, make_v(ts...)); }

int solve(){
	int n, m, t, p;
	scanf("%d%d%d%d", &n, &m, &t, &p);
	if(!n && !m && !t && !p) return 0;
	
	int paper[30][100][100] = {};
	RC(i, n) RC(j, m) paper[0][i][j] = 1;

	RC(i, t){
		int d, c;
		scanf("%d%d", &d, &c);
		if(d == 1){
			RC(j, n) RC(k, m) paper[i + 1][j < c ? c - j - 1 : j - c][k] += paper[i][j][k];
			n = ant(c, n - c);
		}else{
			RC(j, n) RC(k, m) paper[i + 1][j][k < c ? c - k - 1 : k - c] += paper[i][j][k];
			m = ant(c, m - c);
		}
	}

	//RCH(i, m){ RC(j, n) printf("%d ", paper[t&1][j][i]); putchar('\n'); }

	RC(i, p){
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%d\n", paper[t][x][y]);
	}

	return 1;
}

int main(){
	while(solve());
}



Measured memory_bytes: 4376
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
INF=10**9+7
l=[0]*k
ans=0
for i in range(k-1,-1,-1):
    x=i+1
    temp=pow(k//x,n,INF)
    for j in range(2,k//x+1):
        temp=(temp-l[j*x-1])%INF
    l[i]=temp
    ans=(ans+x*temp)%INF
print(ans)











Measured memory_bytes: 73868
#include <stdio.h>

const static int MAX = 100;

void print(int *array, int n){
    for(int i=0;i<n;i++){
        printf("%d", array[i]);
        if(i<n-1) printf(" ");
    }
    printf("\n");
}

int bubble_sort(int *array, int n){
    bool flag = true;
    int k, count=0;
    while(flag){
        flag = false;
        for(int i=n-1;i>0;i--){
            if(array[i] < array[i-1]){
                k = array[i-1];
                array[i-1] = array[i];
                array[i] = k;
                flag = true;
                count++;
            }
        }
    }
    print(array, n);
    return count;
}

int main(){
    int n, array[MAX], c;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &array[i]);
    }
    c = bubble_sort(array, n);
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 2684
package main

import "fmt"

func main() {
	var num1, num2 int
	fmt.Scan(&num1, &num2)
	fmt.Println(gcd(num1, num2))
}


func gcd(a, b int) int {
	if b > a {
		tmp := b
		b = a
		a = tmp
	}
	if remainder := a % b; remainder == 0 {
		return b
	} else {
		return gcd(b, remainder)
	}
}



Measured memory_bytes: 1120
N, K = map(int, input().split())
A = list(map(int, input().split()))

res = 10 ** 15

for bit in range(2 ** N):
    cnt = 0
    for i in range(N):
        if (bit >> i) & 1:
            cnt += 1

    if cnt < K:
        continue

    cost = 0
    height = 0
    for i in range(0, N):
        if (bit >> i) & 1 and height >= A[i]:
            cost += height - A[i] + 1
            height += 1
        elif height < A[i]:
            height = A[i]

    res = min(res, cost)

print(res)


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


int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int tmp;
    tmp = x;
    x = y;
    y = tmp;
    tmp = x;
    x = z;
    z = tmp;
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
from heapq import heappop, heappush
N = int(input())
QL = []
QR = []
for i in range(N):
    L, R = map(int, input().split())
    heappush(QL, (-L, i))
    heappush(QR, (R, i))
QL1 = QL[:]
QR1 = QR[:]

deta = set()
x = 0
ans = 0
for i in range(N):
    if i % 2 == 0:
        for _ in range(N):
            if QL1[0][1] not in deta:
                break
            heappop(QL1)
        L, i = heappop(QL1)
        deta.add(i)
        L = -L
        if x < L:
            ans += L - x
            x = L
    else:
        for _ in range(N):
            if QR1[0][1] not in deta:
                break
            heappop(QR1)
        R, i = heappop(QR1)
        deta.add(i)
        if x > R:
            ans += x - R
            x = R
ans += abs(x)
x = 0
ans1 = 0
deta = set()
for i in range(N):
    if i % 2:
        for _ in range(N):
            if QL[0][1] not in deta:
                break
            heappop(QL)
        L, i = heappop(QL)
        deta.add(i)
        L = -L
        if x < L:
            ans1 += L - x
            x = L
    else:
        for _ in range(N):
            if QR[0][1] not in deta:
                break
            heappop(QR)
        R, i = heappop(QR)
        deta.add(i)
        if x > R:
            ans1 += x - R
            x = R
ans1 += abs(x)

print(max(ans1, ans))

Measured memory_bytes: 129244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());//int型
        int m = Integer.parseInt(sc.next());
        int[] a = new int[m];
        int[] dp = new int[n+1]; // i段目に行く場合の数

        for (int i = 0; i < m; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        boolean[] check = new boolean[n+1];
        for (int i = 0; i < m; i++) {
            check[a[i]] = true;
        }

        // 0段目には1通り
        // 1段目には1通り
        dp[0] = 1;
        if(!check[1]) dp[1] = 1;
        else dp[1] = 0;
        for (int i = 0; i <= n-2; i++) {
            if(!check[i+2]) dp[i+2] = (dp[i+1] + dp[i]) % 1000000007;
            else dp[i+2] = 0;
        }
/*
        for (int i = 0; i < n+1; i++) {
            System.out.println(dp[i]);
        }
*/
        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 47864
// D - Even Relation
#include <bits/stdc++.h>

using namespace std;

void dfs(const vector<vector<pair<int, int> > > &g, int u, int c, vector<int> &a, vector<int> &vi)
{
	if (vi[u]) return;
	vi[u] = 1;
	a[u] = c;
	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i].first;
		if (!vi[v]) dfs(g, v, g[u][i].second ? c ^ 1 : c, a, vi);
	}
}

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<vector<pair<int, int> > > g(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		g[u].push_back(make_pair(v, w % 2));
		g[v].push_back(make_pair(u, w % 2));
	}

	vector<int> a(n), vi(n);
	dfs(g, 0, 0, a, vi);

	for (int i = 0; i < n; i++) cout << a[i] << endl;

	return 0;
}


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

int main(void)
{
	char str[1000];
	int i, j, temp, flag;
	int ans = 0;
	
	while (scanf("%s", str) != EOF){
		flag = 1;
		temp = strlen(str);
		temp--;
		j = temp;
		for (i = 0; i < temp; i++){
			if (str[i] != str[j]){
				flag = 0;
//				printf("ツつソツづつェツづつ、\n");
			}
			j--;
		}
		if (flag == 1){
			ans++;
		}
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
    int n;
    int p[21];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int answer=0;
    for(int i=0;i<n-2;i++){
        if(p[i]<p[i+1]&&p[i+1]<p[i+2]){
            answer++;
            continue;
        }
        if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
            answer++;
            continue;
        }
    }
    printf("%d\n",answer);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
struct S{
	double x,y,hen;
	bool operator<(S a){return hen<a.hen;}
};
S s[105];
signed main(){
	cin>>N;
	rep(i,N){
		cin>>s[i].x>>s[i].y;
		s[i].hen=atan2(s[i].y,s[i].x);
	}
	sort(s,s+N);
	double ans=0;
	rep(i,N){
		double nowx=0,nowy=0;
		for(int j=i;j<i+N;j++){
			nowx+=s[j%N].x;nowy+=s[j%N].y;
			chmax(ans,sqrt(nowx*nowx+nowy*nowy));
		}
	}
	printf("%.12lf\n",ans);
}


Measured memory_bytes: 512
import math

A, B, H, M = map(int, input().split())

A_kaku = 360*H/12 + 30*M/60
B_kaku = 360*M/60
sa_kaku = abs(A_kaku - B_kaku)

math.cos(math.radians(sa_kaku))

ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(sa_kaku)))
print(ans)

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

typedef long long ll;

const int MN = 305, P = 998244353;

typedef std::bitset<MN> bst;

bst val[MN], vec[MN];

int n, m, cnt;

inline int fpw(int x, int k) {
	int res = 1;
	for (; k; k >>= 1, x = (ll) x * x % P)
		if (k & 1) res = (ll) res * x % P;
	return res;
}

inline int read() {
	int x; bool f; char c;
	for (f = 0; (c = getchar()) < '0' || c > '9'; f = c == '-');
	for (x = c ^ '0'; (c = getchar()) >= '0' && c <= '9'; x = (x << 1) + (x << 3) + (c ^ '0'));
	return f ? -x : x;
}

int main() {
	n = read(), m = read();
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			val[i][j] = read();

	for (int i = 0; i < n; ++i)
		for (int j = m; j--; )
			if (val[i][j]) {
				if (vec[j].count()) val[i] ^= vec[j];
				else {
					++cnt;
					vec[j] = val[i];
				/*	for (int k = j; k--; )
						if (vec[j][k]) vec[j] ^= vec[k];
					for (int k = j; ++k < m; )
						if (vec[k][j]) vec[k] ^= vec[j];*/
					break;
				}
			}

	printf("%lld\n", (ll)fpw(2, m - 1) * (fpw(2, n) - fpw(2, n - cnt) + P) % P);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount


int32_t main(){
	int n;
	cin>>n;
	int ans = 0;
	ans += (n/500)*1000;
	n%=500;
	ans += (n/5)*5;
	cout<<ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
 ll a;cin>>a;
 cout<<pow(a,3)+pow(a,2)+a<<endl;
}



Measured memory_bytes: 4156
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)
t=1
# t=int(input())
for _ in range(t):
    n,m,k=l()
    A=[0]+l()
    B=[0]+l()
    for i in range(1,m+1):
        B[i]+=B[i-1]
    curr=0
    ma=0
    for i in range(n+1):
        curr+=A[i]
        if curr>k:
            break
        low=0
        high=m
        mab=0
        while(low<=high):
            mid=(low+high)//2
            if B[mid]+curr<=k:
                mab=mid
                low=mid+1
            else:
                high=mid-1
        ma=max(ma,mab+i)
    print(ma)

Measured memory_bytes: 41504
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll l,n=0;
  cin >> l;
  vector<TP> ans;
  ll r=1,c=0,rc=1;
  while(r<=l){
    r*=2;
    c++;
  }
  r/=2;
  c--;
  for(int i=0;i<c;i++){
    n++;
    ans.push_back(TP(n,n+1,0));
    ans.push_back(TP(n,n+1,rc));
    rc*=2;
  }
  ll v = r;
  n++;
  rc/=2;
  for(int i=n-2;i>=0;i--){
    //cout << l<<"de "<<r<<" "<<rc<<endl;
    if(l-r>=rc){
      ans.push_back(TP(i+1,n,v));
      v+=rc;
      l-=rc;
    }
    rc/=2;
  }
  cout << n <<" "<<ans.size()<<endl;
  for(auto tp:ans){
    cout << get<0>(tp)<<" "<<get<1>(tp)<<" "<<get<2>(tp)<<endl;
  }
}


Measured memory_bytes: 256
input()
nums  = list(map(int, input().split()))

def low(lis, n):
    return [
        l for l in lis if l <= n
    ]

def rev_idx(lis, n):
    return [
        i for i, e in enumerate(lis[::-1]) if e == n
    ]


try:
    sort = sorted(list(set(nums)))[1:]
    order = low(nums, 1)
    order[0]
    for i, n in enumerate(sort):
        lows = low(nums, n)
        for index in rev_idx(lows, n):
            if (n + index - 1) > len(order):
                raise Exception
            order.insert(n + index - 1, n)
    for o in order:
        print(o)
except:
    print(-1)

Measured memory_bytes: 3064
N, W = map(int, input().split())
Items = [list(map(int, input().split())) for i in range(N)]

# dp[i] := 価値[i]に対する最低の重さ
dp = [float('inf')] * (N * 10 ** 3 + 1)
dp[0] = 0

for w, v in Items:
    for i in range(len(dp))[::-1]:
        if i - v < 0:
            continue
        dp[i] = min(dp[i], dp[i - v] + w)

for v, res in zip(range(len(dp))[::-1], dp[::-1]):
    if res <= W:
        print(v)
        exit()


Measured memory_bytes: 95692
#include <cstdio>
int n, m, a, b;
char c[1005][1005];
void f(int p, int q) {c[p][q]='^'; c[p+1][q]='v'; b--;}
void g(int p, int q) {c[p][q]='<'; c[p][q+1]='>'; a--;}

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	int i, j;
	for(i=1; i<=n; i++) for(j=1; j<=m; j++) c[i][j] = '.';
	if(m&1) for(i=1; i<n && b; i+=2) f(i, m);
	if(n>1 && m>2 && n&1 && b&1) f(n-1, m-2);
	for(i=1; i<n; i++) for(j=1; j<=m-(m&1) && b; j++)
		if(c[i][j]=='.' && c[i+1][j]=='.') f(i, j);
	for(i=1; i<=n; i++) for(j=1; j<m && a; j++)
		if(c[i][j]=='.' && c[i][j+1]=='.') g(i, j);
	if(a+b==0) {
		puts("YES");
		for(i=1; i<=n; i++) puts(c[i]+1);
	} else puts("NO");
	return 0;
}

Measured memory_bytes: 2176
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
max_A = max(A)
bit = bin(K)
if max_A > K:
    bit = bin(max_A)
max_f = 0
for d in range(1,len(bit))[::-1]:
   #d-bit目まではKと同じ
   #XがKより大きくならないように、上位ビットをKに合わせる。
    d=d-2
    if (d != -1 and not (K & 1 << d)):
        continue
    f=0
    for e in range(2,len(bit))[::-1]:
        e=e-2
        mask = 1<<e
        num=0
        for a in A:#e-bit目が立っているA[i]を数える
            if a&mask:
                num+=1
        n_num = N - num
        #A[i]のe-bit目が立っていれば、XORの計算上0になるので、e-bit目が立っていないA[i]が加算
        if e>d:#dビット目より上はKに合わせる
            #以下、e-bit目だけ計算したf(x)
            if K&mask:
                f += mask*n_num
            else:
                f += mask*num
        elif e==d:
            f += mask*num
        else:#どうせ後から計算するからなんでもよい？
            f += mask*max(n_num,num)
    max_f = max(f,max_f)
print(max_f)

Measured memory_bytes: 69920
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7, MOD = 1e9 + 7;

int deg[N] = { 1 };

void solve() {
    loop1(i, N - 1)
        deg[i] = (deg[i - 1] << 1) % MOD;
    int n, sum = 0; cin >> n;
    vector <int> a(n);
    loop(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    if (n == 1) {
        cout << a[0] * 2 % MOD; return;
    }
    sort(all(a), greater<int>());
    int ans = 0;
    sum %= MOD;
    loop(i, n) {
        sum = (sum - a[i] + MOD) % MOD;
        ans = (ans + deg[n - 1] * a[i] + deg[n - 2] * sum) % MOD;
    }
    cout << ans * deg[n] % MOD;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 6328
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,c,t[100000],tt,p,cc,ans,k;
    scanf("%d %d %d",&n,&c,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&t[i]);
    }
    sort(t,t+n);
    p=n-2;
    tt=t[n-1];
    cc=1;
    ans=1;
    while(p>=0){
        if(cc==c||t[p]+k<tt){
            cc=1;
            ans++;
            tt=t[p];
        }
        else{
            cc++;
        }
        p--;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> mp;
    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }
    ll ans = 0;
    for (auto p: mp) {
        if (p.second < 2) continue;
        ll tmp = p.second * (p.second - 1);
        tmp /= 2;
        ans += tmp;
    }
    rep(i, N) {
        if (mp[A[i]] < 2) {
            cout << ans << endl;
            continue;
        }
        ll sub = mp[A[i]]*(mp[A[i]]-1) / 2 - (mp[A[i]]-1)*(mp[A[i]]-2) / 2;
        cout << ans - sub << endl;
    }
    return 0;
}

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

const int N = 2e5+5 , INF = 20000;

int n  , m , p;
long long d[N] , d2[N];
vector<pair<int,int> > adj[N] , adj2[N];
vector<pair<pair<int,int> , int> > e;
map<pair<int,int> , bool > bad;

bool vis[N];

bool cango(int A , int B)
{
    vis[A] = 1;
    if(A==B)
        return 1;
    bool ret = 0;
    for(auto u : adj[A])
    {
        if(vis[u.first])
            continue;
        ret|=cango( u.first ,B  );
    }
    return ret;
}

int main() {
    for(int i = 0;i<N;i++)
    {
        d[i] = -1e12;
        d2[i] = 1e12;
    }
    cin>>n>>m>>p;
    d[1] = d2[1] = 0;
    for(int i = 0;i<m;i++)
    {
        int a ,b , c;
        cin>>a>>b>>c;
        adj[a].push_back({b ,  c - p});
        e.push_back({{a , b} , p-c });
    }

    for(int i = 0;i<n-1;i++)
    {
        for(int j = 0;j<m;j++)
        {
            if( d2[e[j].first.first] <1e12 )
            {
                d2[ e[j].first.second ] = min(d2[ e[j].first.second ] ,d2[ e[j].first.first ] + e[j].second  );
            }
        }
    }
    for(int j = 0;j<m;j++)
    {
        if( d2[e[j].first.first] <1e12 && d2[ e[j].first.first ] + e[j].second < d2[ e[j].first.second ] )
        {
            int st = e[j].first.first , en = e[j].first.second;
            memset(vis , 0 , sizeof vis);
            if(cango(1 , st))
            {
                memset(vis , 0 , sizeof vis);
                if(cango(en  , n))
                {
                    return cout<<-1,0;
                }
                else
                {
                    bad[{st , en}] = 1;
                }
            }
            else
            {
                bad[{st , en}] = 1;
            }
        }
    }


    priority_queue< pair<long long  , int > > Q;
    memset(vis , 0 , sizeof vis);
    Q.push({0 , 1});
    while(Q.size())
    {
        long long dst = Q.top().first;
        int node= Q.top().second;
        Q.pop();
        for(auto u : adj[node] )
        {
            if( bad[{node,u.first}] || node==u.first)
                continue;
            if( d[node] + u.second > d[u.first] )
            {
                d[u.first] =d[node] + u.second;
                Q.push({ d[u.first] , u.first});
            }
        }
    }
    cout<<max(0LL , d[n]);
    return 0;
}


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

using namespace std;

int sum_digits(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n = n / 10;
    }
    return sum;
}

int main() {

    int n;
    cin >> n;

    int minimum = sum_digits(n - 1) + 1;

    for (int i = 1; i <= n - 1; i++) {
        int sum = sum_digits(i) + sum_digits(n - i);
        minimum = min(minimum, sum);
    }

    cout << minimum << endl;

    return 0;
}


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

namespace Volume0007
{
    class Program
    {
        const long _principal = 100000;
        const double _interestRate = 1.05;

        static void Main(string[] args)
        {
            int weeks = int.Parse(Console.ReadLine());
            double repayment = Money.CalcRepayment(_principal, _interestRate, weeks);
            Console.WriteLine(repayment);
        }
    }
    class Money
    {
        internal static double CalcRepayment(double Princepal, double InterestRate, int Weeks)
        {
            double Repayment = Princepal;
            for (int n = 0; n < Weeks; ++n)
            {
                Repayment = Repayment * InterestRate;
                if (0 < Repayment % 1000 && Repayment % 1000 <= 499)
                {
                    Repayment = double.Parse((Repayment / 1000).ToString("F0")) * 1000 + 1000;
                }
                else if (500 <= Repayment % 1000)
                    Repayment = double.Parse((Repayment / 1000).ToString("F0")) * 1000;
            }

            return Repayment;
        }

    }
}



Measured memory_bytes: 15908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rep2(i,a,b) for (ll i = (a); i < (b); ++i)
#define INF (1<<18)




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

    bool ans = false;
    rep(i,30)rep(j,20){
        if(4*i+j*7 ==n) ans=true;
    }

    cout<< (ans ? "Yes" : "No") <<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
t=[]
s_sum=0
for i in range(n):
    s=int(input())
    s_sum+=s
    if s%10!=0:
        t.append(s)
if s_sum%10!=0:
    print(s_sum)
elif len(t)==0:
    print(0)
else:
    print(s_sum-min(t))

Measured memory_bytes: 3064
N = int(input())

D = 26
lst = []
while N > 0:
    # c = N%26
    # if c == 0:
    #     ans += 'z'
    # else:
    #     ans += chr(ord('a') + (N%26) - 1)

    lst.append(N%D)
    N //= D

# print(lst)
ans = ""
z = False
for i in range(len(lst)):
    # print(i)
    if i == len(lst)-1 and lst[i] == 0:
        break

    if lst[i] == 0:
        ans += 'z'
        while lst[i+1] == 0:
            lst[i+1] = 25
            i+=1
        lst[i+1] -= 1
    else:
        ans += chr(ord('a') - 1 + lst[i])


# for c in enulst:
#     if c == 0:
#         z=True
#     else:
#         if z:
#             ans += chr(ord('z') + 1 - c)
#         else:
#             ans += chr(ord('a') - 1 + c)

# print(lst)
# print("rev:", list(reversed(lst)))
# print(ans)
print("".join(list(reversed(ans))))

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

int main() {
    int A, B, C, K;
    cin>>A>>B>>C>>K;
    if(K<=A+B)
    	if(K<A)
      		cout<<K<<endl;
  		else
        	cout<<A<<endl;
    else{
        cout<<A-K+A+B<<endl;
    }
}


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

if n==1:
  print(1)
  
else:
  min1=a[0]
  ans=1
  for x in range(1,n):
    if min1>=a[x]:
      ans+=1
    min1=min(min1,a[x])
    
  print(ans)

Measured memory_bytes: 32360
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)

odd = 0
even = 0
for i in range(N) :
	if i % 2 == 0 :
		even += a[i]
	else :
		odd += a[i]

print( "{}".format( abs( even-odd ) ) )

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long int N, K;
  long long int MIN;
 
  cin >> N >> K;
  
  if(N == K){
    cout << 0 << endl;
    return 0;
  }else if(N > K){
    MIN = N % K;
    cout << min(MIN, abs(MIN - K)) << endl;
    return 0;
  }else{
    cout << min(N, abs(N - K)) << endl;
    return 0;
  }
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.next().toList.map(_.asDigit)
  val opType = List((x:Int, y:Int) => x + y, (x:Int, y:Int) => x - y)
  val opChar = List('+', '-')
  val ops = for (i <- opType; j <- opType; k <- opType) yield List(i, j, k)
  val opChars = for (i <- opChar; j <- opChar; k <- opChar) yield List(i, j, k)
  val index = ops.indexWhere(op => op(2)(op(1)(op(0)(n(0), n(1)), n(2)), n(3)) == 7)
  val ansOps = opChars(index)
  println(s"${n(0)}${ansOps(0)}${n(1)}${ansOps(1)}${n(2)}${ansOps(2)}${n(3)}=7")
}


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

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

Measured memory_bytes: 256
N = int(input())
X = list()
Y = list()
H = list()
i = 0
for n in range(0,N):
    S = list(map(int,input().split()))
    X.append(S[0])
    Y.append(S[1])
    H.append(S[2])
for x in range(0,101):
    for y in range(0,101):
        while H[i] == 0:
            i = i+1 
            if i == N-1:
                break
        else:
            sub = abs(x - X[i]) + abs(y - Y[i]) + H[i]
        for n in range(0,N):
            h = sub - abs(x-X[n]) - abs(y-Y[n])
            if not H[n] == max(h,0):
                break
            else:
                if n == N-1:
                    print(x, y, sub)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    s64 ans = 0;
    cin >> N;

    vs64 a(N), b(N);
    rep (i, N) cin >> a[i];
    rep (i, N) cin >> b[i];

    rep (i, N)
    {
        ans += (b[i] - a[i] >= 0) ? (b[i] - a[i]) / 2 : b[i] - a[i];
    }

    cout << (ans >= 0 ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main () {

    int i, j, k, n, v, A[100];

    cin >> n;

    for (i = 0; i < n; i++) {

        cin >> A[i];

    }

    for (i = 0; i < n; i++) {

        cout << A[i];

        if (i < n - 1) {

            cout << " ";

        }

    }

    cout << endl;

    for (i = 1; i < n; i++) {

        v = A[i];
        j = i - 1;

        while (j >= 0 && A[j] > v) {

            A[j + 1] = A[j];

            j--;

        }

        A[j + 1] = v;

        for (k = 0; k < n; k++) {

            cout << A[k];

            if (k < n - 1) {

                cout << " ";

            }

        }

        cout << endl;

    }

    return 0;

}

        

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    cout << ((A - 1) * (B - 1)) << endl;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut max = 0;
    let mut sum = 0;
    for _ in 0..n {
    	let x = get!();
        if x > max {
        	max = x;
        }
        sum += x;
    }
    sum -= max;
    if max < sum {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(){
	int N,a;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a);
		if(a%2==1){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

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

    const int favorite_sum = 753;
    const int max_char = 11;
    int min_diff = 10000;
    for (int i = 0; i < max_char - 3; ++i) {
        if (s[i + 2] == '\0')
            break;
        int tmp = stoi(s.substr(i, 3));
        int diff = abs(favorite_sum - tmp);
        if (min_diff > diff)
            min_diff = diff;
    }
    cout << min_diff << '\n';
}


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

#define ff first
#define ss second
#define endl '\n'

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

	ll n;
	cin >> n;

	if (n & 1) {
		cout << 0 << endl;
		return 0;
	}

	n /= 2;
	ll ans = 0;
	for (n /= 5; n > 0; n /= 5) {
		ans += n;
	}

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


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>
using namespace std;
// example of listing permuations
void list_permutation()
{
    int n;
    cin >> n;
    vector<int> one_case;
    for (int i = 0; i < n; i++)
        one_case.push_back(i);

    do
    {
        for (auto num : one_case)
        {
            cout << num << " ";
        }
        cout << endl;

    } while (next_permutation(one_case.begin(), one_case.end()));
}
using pii = pair<double, double>;
int main()
{
    int n;
    int pattern = 1;
    cin >> n;
    vector<int> one_case;
    vector<pii> pairs;
    for (int i = 1; i <= n; i++)
    {
        pattern *= i;
        double x, y;
        cin >> x >> y;
        pairs.push_back(pii(x, y));
        one_case.push_back(i - 1);
    }
    long double sum = 0;
    do
    {
        for (int i = 0; i < one_case.size() - 1; i++)
        {
            sum += sqrt(pow(pairs[one_case[i]].first - pairs[one_case[i + 1]].first, 2.0) + pow(pairs[one_case[i]].second - pairs[one_case[i + 1]].second, 2.0));
        }

    } while (next_permutation(one_case.begin(), one_case.end()));
    cout << fixed << setprecision(10) << (sum / pattern);
}

Measured memory_bytes: 3856
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
long long value[100] = {};
long long geko = 0;
long long dfs(long long n_l, long long n_r, long long l_rate, long long r_rate) {
	if (n_l >= n_r) return 0;
	long long ans = geko;
	for (int q = n_l; q < n_r; ++q) {
		long long next_value = (l_rate + r_rate) * value[q];
		if (geko > next_value||1) {
			long long gogo = dfs(n_l, q, l_rate, (l_rate + r_rate)) + dfs(q + 1, n_r, (l_rate + r_rate), r_rate);
			ans = min(ans, next_value + gogo);
		}
	}
	return ans;
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}
int main() {
	while (true) {
		int n = 0;
		cin >> n;
		long long final_ans = 0;
		cin >> final_ans;
		REP(i, n - 2) {
			cin >> value[i];
		}
		long long tmp = 0;
		cin >> tmp;
		final_ans += tmp;
		n -= 2;
		for (long long q = 0; q < n; ++q) {
			geko += value[q] * (q + 2LL);
		}
		cout << dfs(0, n, 1, 1) + final_ans << endl;
		return 0;
	}
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i * 500 + j * 100 + k * 50 == X:
        count += 1
print(count)

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


using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;


//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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


int A, B;
int a[10010][10010], b[1000];
int dp[10010][3];
 
int main()
{
    ll N, K; cin >> N >> K;
    ll sum = 0;
    
    ll upperSum;
    ll lowerSum;

    for(ll k = K; k <= N+1; k++){
        
        upperSum = (N+1)*N/2 -(N-k+1)*(N-k)/2;
        lowerSum = (k)*(k-1)/2;
        PRINT(upperSum)
        PRINT(lowerSum)
        sum += upperSum - lowerSum + 1;
        
        sum = sum % mod;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない

/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	string alpha="abcdefghijklmnopqrstuvwxyz";
	rep(i,int(alpha.length())){
		if(s.find(alpha[i])!=-1){
			alpha[i]='{';
		}
	}
	sort(all(alpha));
	bool flag =(alpha[0]=='{');
	cout<<(flag?"None":alpha.substr(0,1))<<endl;



//	int m,n;
//	cin>>n>>m;
//	vector<string> a(n);
//	vector<string> b(m);
//
//	rep(i,n)cin>>a[i];
//	rep(i,m)cin>>b[i];
//
//	rep(i,n-m+1)rep(j,n-m+1){
//		rep(k,m)rep(l,m)if(a[i+k][j+l]!=b[k][l])goto BB;
//		cout<<"Yes"<<endl;
//		return 0;
//BB:
//		continue;
//	}
//	cout<<"No"<<endl;
//
//
	return 0;
}


Measured memory_bytes: 512
$ans = 0
def solve(v,n)
    li = Array.new(n){0}
    route(0,v,0,n,li)
    puts $ans
end

def route(nid,v,cnt,n,li)
    if cnt == n-1
        $ans += 1
    else
        n.times do |i|
            if v[nid][i] == 1 && li[i] == 0
                li[nid] = 1
                route(i,v,cnt+1,n,li)
                li[nid] = 0
            end
        end
    end
end

n,m=gets.split.map(&:to_i)
v = Array.new(n){Array.new(n){0}}

m.times do
    a,b=gets.split.map(&:to_i)
    v[a-1][b-1] = 1
    v[b-1][a-1] = 1
end

solve(v,n)

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
u=[]
alphasm=[chr(i) for i in range(97, 97+26)]
s=input().rstrip()
for i in range(n):
    s1=list(s[0:i])
    s2=list(s[i:n])
    count=0
    for x in alphasm:
        if (x in s1) and (x in s2):
            count+=1
    u.append(count)
print(max(u))

Measured memory_bytes: 3316
#include <stdio.h>
int main(){
  int i,j,k,sum;
  scanf("%d",&j);

 
  while(j){
    sum=0;
    for(i=0;i<j*(j-1)/2;i++){
      scanf("%d",&k);
      sum+=k;
    }
    printf("%d\n",sum/(j-1));
    scanf("%d",&j); 
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        int a = -1;
        int b = -1;
        int c = -1;

        for(int i=0; i<=n; i++){
        	for(int j=0; j<=n-i; j++){
                if(10000*i+5000*j+1000*(n-i-j) == y){
                    a = i;
                    b = j;
                    c = n-i-j;
                    break;
                }
            }
        }
        System.out.print(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 23764
import bisect
point=0
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
for i in range(N):
  m=bisect.bisect_left(A,B[i])
  n=bisect.bisect_right(C,B[i])
  point+=m*(N-n)
print(point)

Measured memory_bytes: 105572