akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
long gcd(long a,long b){
    if(b==0) return a;
    return gcd(b,a%b);
}
long lcm(long a,long b){
    long g=gcd(a,b);
    return a/g*b;
}
int main(void){
   long N;
   cin>>N;
   long t[N];
   for(int i=0;i<N;i++){
       cin>>t[i];
   }
   long ans=t[0];
   for(int i=1;i<N;i++){
      ans=lcm(ans,t[i]) ;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;


signed main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> s[i][j];
    vector<vector<int>> dp(H, vector<int>(W, INF));
    dp[0][0] = (s[0][0] == '#');
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bool check = (s[i][j] == '.');
            if (check) {
                if (i + 1 <= H - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i + 1][j] == '#'));
                if (j + 1 <= W - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j + 1] == '#'));
            } else {
                if (i + 1 <= H - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                if (j + 1 <= W - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            }
        }
    }
    int ans = dp[H - 1][W - 1];
    dp = vector<vector<int>>(H, vector<int>(W, INF));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) s[i][j] = (s[i][j] == '.' ? '#' : '.');
    dp[0][0] = (s[0][0] == '#');
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bool check = (s[i][j] == '.');
            if (check) {
                if (i + 1 <= H - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i + 1][j] == '#'));
                if (j + 1 <= W - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j + 1] == '#'));
            } else {
                if (i + 1 <= H - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                if (j + 1 <= W - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            }
        }
    }
    cout << min(ans, dp[H - 1][W - 1] + 1);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f , mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
 

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
  string s , t;
  cin >> s >> t;
  t.pop_back();
  if(s == t)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}

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

const int N = 1e5 + 10;
int h[N], c[N], n, m, ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> m;
	c[0] = 1;
	for (int i = 0; i < n; i++)
		h[i] = 1;
	for (int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		x--;y--;
		c[y] |= c[x];
		h[x]--;
		h[y]++;
		if(h[x] == 0)
			c[x] = 0;
	}	
	for (int i = 0; i < n; i++)
		ans += c[i];
	cout << ans;
	
}



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

using LL = int64_t;
using VL = vector<LL>;

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}

int main(int argc, char *argv[])
{
	int n,m,q;
	cin >> n >> m >> q;
	VL a(q), b(q), c(q), d(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i]>> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	VL A(n,1);
	LL ans = 0;
	auto dfs = [&](auto&& dfs, int v) -> void{
		while (A[v] <= m) {
			if (v == n-1) {
				int tmp = 0;
				for (int i = 0; i < q; i++) {
					tmp += A[b[i]] - A[a[i]] == c[i] ? d[i] : 0;
				}
				chmax(ans,tmp);
			}
			else {
				if (A[v+1] < A[v]) {
					A[v+1] = A[v];
				}
				dfs(dfs, v+1);
			}
			A[v]++;
		}
		A[v] = 1;
		return;
	};
	dfs(dfs, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int n,a[200003],maxx=1e9,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<maxx)
			ans++;
		maxx=min(maxx,a[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	set<int>ans;
	if(n==3){
		ans = {2,5,63};
	}else if(n==4){
		ans={2,5,20,63};
	}else if(n==5){
		ans={2,5,20,30,63};
	}else{
		ans={2,3,4};
		n -= 3;
		for (int x = 6; x <= 30000; x++){
			if(x%6==1||x%6==5) continue;
			ans.insert(x);
			n--;
			if(n==0)break;
		}
		int sum = accumulate(all(ans),0);
		if(sum%6==2){
			ans.erase(8);
			ans.insert(30000);
		}else if(sum%6==3){
			ans.erase(9);
			ans.insert(30000);
		}else if(sum%6==5){
			ans.erase(9);
			ans.insert(30000-2);
		}
	}

	for(auto x:ans)cout<<x<<" ";
	cout<<endl;
	return 0;
}

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

int N, p[4], t[4];

int main(){
    cin >> N;
    for(int i=0;i<4;i++)    cin >> p[i];
    for(int i=0;i<4;i++)    cin >> t[i];

    int ans = 1000000000;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                int a = N - t[0]*i - t[1]*j - t[2]*k;
                if(a < 0){
                    ans = min(ans, p[0] * i + p[1] * j + p[2] * k);
                    continue;
                }
                if(p[0] * i + p[1] * j + p[2] * k + (a + (t[3] - 1)) / t[3] * p[3] < ans)
                    ans = p[0] * i + p[1] * j + p[2] * k + (a + (t[3] - 1)) / t[3] * p[3];
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3100
import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        Scanner obj = new Scanner(System.in);
        int n = obj.nextInt(),k = obj.nextInt();
        String s =  Integer.toUnsignedString(n,k);
        System.out.println(s.length());
    }
}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main (){
  int N,S,x[1000];
  int A=0,sum=0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin>>x[i];
    sum+=x[i];
  }
  if(sum%N<=N/2){
    S=sum/N;
  }else{
    S=sum/N+1;
  }
  for(int i=0; i<N; i++){
    A=A+(x[i]-S)*(x[i]-S);
  }
  if(N==1){
    cout << 0 << endl;
  }else{
  cout << A << endl;
  }
}


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

int main() {
    ll n;
    cin >> n;
    string ans = "";
    while (n > 0) {
        n--;
        ans = char('a' + n % 26) + ans;
        n /= 26;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
/*input
red blue
5 5
blue
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005

int main() 
{
    string s,t,k;
    map<string,ll>m;
    cin>>s>>t;
    cin>>m[s]>>m[t];
    cin>>k;
    m[k]-=1;
    cout<<m[s]<<" "<<m[t];
    return 0;
}

Measured memory_bytes: 256
s = input()

ans = float("inf")
for i in range (26):
    a = chr(ord("a")+i)
    if  s.count(a) == 0 :
        pass
    else:
        tmp = s
        c = 0
        while set(tmp) != {a}:
            t = ""
            for j in range(len(tmp)-1):
                if tmp[j] == a or tmp[j+1] == a:
                    t += a
                else:
                    t += tmp[j]
            c += 1
            tmp = t
        ans = min(c, ans)

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
map<int,int> check;
int cou[200001]={0},pos=0,pos1=0;
int main()
{
    int n,k,tmp,ans=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&tmp);
        if(check.count(tmp)==0)
        {
            check[tmp]=pos;
            cou[pos++]++;
        }
        else
            cou[check[tmp]]++;
    }
    sort(cou, cou+pos);
    for(int i=0;i<pos-k;i++)
    {
        ans+=cou[pos1++];
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 10368
N, X, M = map(int, input().split())
tmp = X
seq = []
ans = 0
for i in range(N):
  if X in seq:
    break
  seq.append(X)
  X = (X ** 2) % M

ans = sum(seq[:min(N, len(seq))])
N -= len(seq)
if N < 1:
    print(ans)
    exit()
i = seq.index(X)
l = len(seq) - i
ans += sum(seq[i:]) * (N//l)
N %= l
ans += sum(seq[i:i+N])
print(ans)


Measured memory_bytes: 67820
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

vector<int> dfs(vector2<int>& graph, int s){
    int n = graph.size();
    vector<int> depth(n, -1);

    stack<P> st;
    st.emplace(s, 0);
    while(not st.empty()){
        int v = st.top().first;
        int d = st.top().second;
        st.pop();

        if(depth[v] != -1){
            continue;
        }
        depth[v] = d;
        for(int u : graph[v]){
            st.emplace(u, d + 1);
        }
    }

    return depth;
}

int doubleSweep(vector2<int>& graph){
    int n = graph.size();
    vector<int> d1 = dfs(graph, 1);
    int f1 = 0;
    rep(i, n){
        if(d1[f1] < d1[i]){
            f1 = i;
        }
    }
    vector<int> d2 = dfs(graph, f1);
    int f2 = 0;
    rep(i, n){
        if(d2[f2] < d2[i]){
            f2 = i;
        }
    }
    vector<int> d3 = dfs(graph, f2);

    int dia = d2[f2];

    vector<int> len(n);
    for(int v = 1; v < n; v++){
        len[max(d2[v], d3[v])]++;
    }
    return dia;
}

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

    int n;
    cin >> n;
    auto edge = initVec2<int>(n + 1, 0);
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    int dia = doubleSweep(edge);

    if(dia % 3 == 1){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }

    return 0;
}


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

# 辞書に入れたほうがやりやすそう
dic = {}
for i in range(len(a)):
      dic.update([(i,a[i])]) #辞書に 要素，その番号を入れていく
      #print(d)
new_dic = sorted(dic.items(),key=lambda x:x[1])

li = []
for i in range(len(a)):
      li.append(new_dic[i][0] +1) #0から始めるからプラスしとく
print(' '.join(map(str, li))) #リストpの数値を文字列に変換する，そして''空白刻みで表示させる


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

int main()
{
    int N;
    unsigned long f0 = 2, f1 = 1;

    cin >> N;
    if (N == 0)
    {
        cout << "2" << endl;
    }
    else 
    {
        for (int i = 1; i < N; i++)
        {

            unsigned long f2 = f0 + f1;

            f0 = f1;
            f1 = f2;
        }
        cout << f1 << endl;
    }
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W, N;
    scan(H, W, N);
    long SR, SC;
    scan(SR, SC);
    auto S = sread();
    auto T = sread();
    long l = SC;
    long r = W - SC + 1;
    long u = SR;
    long d = H - SR + 1;
    foreach (i; 0 .. N)
    {
        switch (S[i])
        {
        case 'L':
            l--;
            break;
        case 'R':
            r--;
            break;
        case 'U':
            u--;
            break;
        case 'D':
            d--;
            break;
        default:
            assert(0);
        }
        // writefln("%s %s %s %s", l, r, u, d);
        if (l <= 0 || r <= 0 || u <= 0 || d <= 0)
        {
            writeln("NO");
            return;
        }
        switch (T[i])
        {
        case 'L':
            if (r < W)
                r++;
            break;
        case 'R':
            if (l < W)
                l++;
            break;
        case 'U':
            if (d < H)
                d++;
            break;
        case 'D':
            if (u < H)
                u++;
            break;
        default:
            assert(0);
        }
    }
    writeln("YES");
}


Measured memory_bytes: 2556
def dist(x,y,p):
    d = 0
    for i in range(len(x)):
        d += abs(x[i]-y[i])**p
    d = d**(1/p)
    return d

n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
print('{0:.6f}'.format(dist(x,y,1)))
print('{0:.6f}'.format(dist(x,y,2)))
print('{0:.6f}'.format(dist(x,y,3)))
print('{}'.format(max([abs(x[i]-y[i])for i in range(n)])))


Measured memory_bytes: 5652
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;

	int n, s[200] = {}, num[200000] = {}, result = 0, lamp = 1, in, ax, h, w, m, a, b, c, d, r, tmp = 1;
	string str, str2;
	long long int point;
	char memo;
	cin >>a>>b>>c;
	if ((c - b) % 2 == 1) {
		cout << "Borys";
	}
	else { cout << "Alice"; }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))
flag = [0] * 2000
for i in range(2 ** len(a)):
         tmp = 0
         for j in range(len(a)):
                  if ((i >> j) & 1) == 1:
                           tmp += a[j]
         flag[tmp] = 1

for k in m:
         if flag[k] == 1:
                  print("yes")
         else:
                  print("no")
                                    




Measured memory_bytes: 5632
#include<iostream>
#define dump(a) cout << (#a) << "=" << a << endl
using namespace std;

int main() {
	int N;
	string num;

	cin >> N;

	for(int t=0;t<N;t++) {
		cin >> num;

		int cnt=0;
		int back_size=0;
		bool is_infre=false;
		while(true) {
			if (num.size() == 1) {
				is_infre=false;
				break;
			}
			else {
				if (num.size() == back_size) { //?????????????????´???????????¨???
					if (cnt > 1000000) { 
						//??±??????
						is_infre=true;
						break; 
					}
				}

				int max_num=0;
				for(int i=1;i<num.size();i++) {
					string left = num.substr(0,i);
					string right = num.substr(i,num.size()-i);
					max_num = max(max_num, stoi(left)*stoi(right));
				}
				num = to_string(max_num);
			}
			cnt++;
			back_size = num.size();
		}

		cout <<  (is_infre ? "-1" : to_string(cnt)) << endl;
	}
	
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S;
  cin>>S;
  if((S/100 >12)||(S/100==0)){
    if((S-(S/100)*100>12)||(S-(S/100)*100==0)){
      cout<<"NA"<<endl;
    }else{
      cout<<"YYMM"<<endl;
    }
  }else{
    if((S-(S/100)*100>12)||(S-(S/100)*100==0)){
      cout<<"MMYY"<<endl;
    }else{
      cout<<"AMBIGUOUS"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,a[200005]={},cnt=0,p;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> p;
    a[p]=a[p-1]+1;
    cnt=max(cnt,a[p]);
  }
  cout << n-cnt << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
d = [0]*60
for i in range(n):
    for j in range(60):
        if a[i] >> j & 1 == 1:
            d[j] += 1

ans = 0
for j in range(60):
    ans += 2**j * d[j] * (n - d[j]) % mod

print(ans % mod)

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

struct Ca{
  char mark,va;
};

void BubbleSort(struct Ca A[],int N){
  int i,j;
  for( i=0;i<N;i++){
    for(j=N-1;j>=i;j--){
      if(A[j].va<A[j-1].va){
      Ca b = A[j];
      A[j] = A[j-1];
      A[j-1] = b;
    }
  }
}
}

void SelectionSort(struct Ca A[],int N){
  int i,j;
  for( i=0;i<N;i++){
    int mi = i;
    for(j = i; j< N; j++){
      if(A[j].va < A[mi].va) mi = j;
    }
    Ca t = A[i];
    A[i] = A[mi];
    A[mi] = t;
  }
}

void express(struct Ca A[],int N){
  int i;
  for( i=0;i<N;i++){
    if(i>0) cout << " ";
    cout << A[i].mark << A[i].va;
  }

  cout << endl;
}

bool re(struct Ca A1[], struct Ca A2[],int N){
  int i;
  for( i =0;i<N;i++){
    if(A1[i].mark != A2[i].mark) return false;
  }
  return true;
}

int main(){
  Ca A1[100],A2[100];
  int N;
  char ch;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A1[i].mark >> A1[i].va;
  }

  for(int i=0;i<N;i++){
    A2[i]=A1[i];
  }

  BubbleSort(A1,N);
  SelectionSort(A2,N);

  express(A1,N);
  cout << "Stable" << endl;
  express(A2,N);
  if( re(A1,A2,N)){
    cout << "Stable" << endl;
  }
  else{
    cout << "Not stable" << endl;
  }
  return 0;
}



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

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

  long long n;
  cin >> n;
  long long a[n];
  double sum=0.0, ans;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=(double)(1.0/a[i]);
  }
  ans=(double)(1.00/sum);
  printf("%.10f\n", ans);
  return 0;
}


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

int main() {
  int N, m = 0, a = 0, b = 0, c = 0, d = 0;
  
  cin >> N;
  string x;

  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    if(s == "P" && a == 0){
      a++, m++;
    }
    if(s == "W" && b == 0){
      b++, m++;
    }
    if(s == "G" && c == 0){
      c++, m++;
    }
    if(s == "Y" && d == 0){
      d++, m++;
    }
  }
  if(m == 3){
    cout << "Three";
  }
  if(m == 4){
    cout << "Four";
  }
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,x;cin>>n>>x;
    ll g=0;
    for(ll i=0,p;i<n;i++)cin>>p,g=__gcd(g,abs(x-p));
    cout<<g;
}

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

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
        if((n+m)%3==0||n%3==0||m%3==0)
            printf("Possible\n");
        else
            printf("Impossible\n");
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let p: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 0;
    for i in 0..n {
        if i == 0 || i == n - 1 {
            continue;
        }
        if p[i] > p[i - 1] && p[i] < p[i + 1] || p[i] < p[i - 1] && p[i] > p[i + 1] {
            ans += 1;
        }
    }

    return ans.to_string();
}


Measured memory_bytes: 2104
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll x;
    ll ans = 0;
    cin >> x;
    // サイコロの5と6の目を交互に出し続けるのが明らかに最大
    ll p = x / 11;
    int r = x % 11;
    // 11 をにするためには操作が2回必要
    if (r == 0) {
    	ans = 2 * p;
    }
    else if (r <= 6) {
    	ans = 2 * p + 1;
    }
    else {
    	ans = 2 * p + 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
xyh = sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[2])[::-1]
flag = 0
for x in range(101):
    for y in range(101):
        H = abs(xyh[0][0]-x) + abs(xyh[0][1]-y)+xyh[0][2]
        for i in range(n):
            if not((xyh[i][2] == 0 and H - abs(xyh[i][0]-x) - abs(xyh[i][1]-y) <= 0) or H - abs(xyh[i][0]-x) - abs(xyh[i][1]-y) == xyh[i][2]):
                break
            if i == n-1:
                flag = 1
        if flag == 1:
            ans = [x,y,H]
            break
    if flag == 1:
        break
print(str(ans[0])+" "+str(ans[1])+" "+str(ans[2]))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<string> 
#include<vector>
#include<stack>
#include<queue> 
#define PI 3.1415926

typedef long long ll;
using namespace std;
const ll Mod=1e9+7;
ll gcd(ll a, ll b) 
{
    if (b == 0) return a;
    else gcd(b, a % b);
}
long long quick_mod(long long a,long long b)//a的b次方对Mod取余 
{
    long long ans = 1;
    a %= Mod; //对刚进来的a进行取模运算，避免后面第一次求平方运算溢出
    while(b)
    {
        if(b&1) //对二进制下的 b 进行按位与1运算，求二进制下 b 的最低位是否为1
            ans = ans * a % Mod; //对结果进行保存
        b>>=1; //二进制下的 b 右移一位，相当于十进制下的 b 除以2
        a = a * a % Mod; 
    }
    return ans % Mod;
}
const int inf=0x3f3f3f3f;
int main()
{
	char a;
	cin>>a;
	printf("%c",a+1);
	return 0;
} 

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

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

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

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

	for (int i = 0;i < N;i++){
		int tmp; cin >> tmp;
		tmp--;
		ans += tmp;
	}
	
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

uint64_t my_sqrt(uint64_t X){ // Y^2 <= X なる最大のY
    uint64_t ret=0;

    for(uint64_t i=(1ull << 31); i; i>>=1){
        if((ret+i)*(ret+i) <= X)
            ret += i;
    }
    return ret;
}

int main(){
    uint64_t X,Y;
    
    scanf("%llu",&X);

    // 2X <= Y(Y+1)なる最小のYを求める
    // つまりfloor(sqrt(2X))-1 <=  Y <= floor(sqrt(2X)) + 1
    Y=my_sqrt(2*X)-1;
    if(Y*(Y+1) < 2*X)
        Y++;
    if(Y*(Y+1) < 2*X)
        Y++;
    printf("%llu\n",Y);

    return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split(" "))


h = (math.pi/6*H%360) + (math.pi/360*M)
m = math.pi/30*M
#print(math.degrees(h))
#print(math.degrees(m))

#print(math.degrees(h-m))
ans = math.sqrt(A**2 + B**2 -(2*A*B*math.cos((math.pi/6*H%360) + (math.pi/360*M)-math.pi/30*M)))

print("{:.20f}".format(ans))


Measured memory_bytes: 9448
from collections import Counter

n = int(raw_input())
l = map(int, raw_input().split())
c = Counter(l)
ls = sorted(c.keys(), reverse=True)
h = 0
w = 0
for k in ls:
    if c[k] >= 4 and h == 0 and w == 0:
        h = k
        w = k
        break
    elif c[k] >= 2:
        if h == 0:
            h = k
        else:
            w = k
            break
print h*k


Measured memory_bytes: 16428
#include<stdio.h>
int main(void)
{
  int a, b, c, z;

  scanf("%d %d %d", &a, &b, &c);

  if (a > b) {
    z = a;
    a = b;
    b = z;
  }

  if (b > c) {
    z = b;
    b = c;
    c = z;
  }

  if (a > b) {
    z = a;
    a = b;
    b = z;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;

}

Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	cin>>n>>m;
	int MAX=-1;
	int MIN=INT_MAX;
	int a,b;
	
	for(int i=0;i<n;i++){
			cin>>a>>b;
			m=m+a-b;
			MAX=max(MAX,m);
			MIN=min(MIN,m);
	}
	if(MIN<0){
		cout<<"0"<<endl;
	}
	else{
		cout<<MAX<<endl;
	}
	return 0;
}


Measured memory_bytes: 3108
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N, A, B;
        {int[] a = r.ii(); N = a[0]; A = a[1]; B = a[2];}
        int base ;
        int ans = 0;
        for(int i = 1; i <= N; i++){
            int x = 0;
            int temp = i;
            while(temp > 0){
                x += temp%10;
                temp /= 10;
            }
            if(B < x)
                i += -i%10+9;
            else if(A <= x)
                ans += i;
        }
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  map<int, int> zip;
  map<int, int> unzip;
  map<int, int> tmp;
  vector<int> A(N), B(N);
  for ( int i = 0; i < N; i++ ) {
    int a, b;
    cin >> a >> b;
    A[i] = a;
    B[i] = b;    
    tmp[a] = tmp[b] = 1; 
  }  

  int cnt = 0;
  for ( auto i : tmp ) {
    zip[i.first] = cnt++;    
    unzip[cnt-1] = i.first;    
  }

  vector<int> cum(400000, 0);  
  for ( int i = 0; i < N; i++ ) {
    cum[zip[A[i]]]++;
    cum[zip[B[i]]+1]--;    
  }

  for ( int i = 0; i < 300000-1; i++ ) {
    cum[i+1] += cum[i];    
  }

  int ma = 0;
  for ( int i = 0; i < 300000-1; i++ ) {
    ma = max(cum[i], ma);    
  }

  cout << ma << endl;  
  
  return 0;
}



Measured memory_bytes: 45084
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int a[101010];
int b[101010], c[101010];

int main(){
    cin >> n >> m;
    REP(i, n)cin >> a[i];
    sort(a, a + n);
    vector<pair<int, int>> v;
    REP(i, m){
        cin >> b[i] >> c[i];
        v.emplace_back(make_pair(c[i], b[i]));
    }
    sort(ALL(v));
    reverse(ALL(v));
    int idx = 0;
    REP(i, n){
        if(idx == (int)v.size())break;
        if(a[i] < v[idx].first){
            a[i] = v[idx].first;
            v[idx].second--;
            if(v[idx].second == 0)idx++;
        }
    }
    LL sum = 0;
    REP(i, n)sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int modpow(int n, int k, int MOD);

/**************** code starts here ****************/

void poppingfever() {
	int n; string a, b, c; cin >> n >> a >> b >> c;
	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] && a[i] == c[i]) {
			continue;
		} else if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) {
			ans += 2;
		} else {
			ans++;
		}
	} 
	cout << ans;
} 

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);

	int t = 1;
	while(t--) {
		poppingfever();
	}

	return 0;
}

int modpow(int n, int k, int MOD) {
	int ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans;
}

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

int main(){
  int n, T; cin >> n >> T;
  int ans = 1e7;
  for(int i = 0; i < n; i++){
    int c, t; cin >> c >> t;
    if(t <= T) ans = min(ans, c);
  }
  if(ans < 1e7) cout << ans << endl;
  else cout << "TLE" << endl;
}

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

int N;
int ans = 0;

int main() {
    cin >> N;
    for (int n = 1; n <= N; n+=2){
        int div = 0;
        for (int i = 1; i <= n; i++){
            if (n % i == 0){
                div += 1;
            }
        }
        if (div == 8){
            ans += 1;
        }
    }
    cout << ans << endl;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL
//	O(1e7) O(1e8)

void Main()
{
	ll K;
	cin>>K;

	ll ans=0;
	ll N=0;
	for(ll i= 0; i<=1e7;i++){
		N=(N*10+7)%K;
		//dout<<i<<':'<<N<<_n;
		if(N%K==0){cout<<i+1;return;}
	}
	cout<<-1<<_n;
}


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


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

int main()
{
    int a, b, c, d;
    int sum = 0;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;

    if (a > b){
        sum += b;
    } else {
        sum += a;
    }
    
    if (c > d){
        sum += d;
    } else {
        sum += c;
    }
    
    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n>>s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if(s.at(i) == 'R') cnt++;
	}
	if (cnt*2 > n) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

const int MAX_LIMIT = 100005;

int nodes, edges;
std::vector<int> adj[MAX_LIMIT];
int dist[MAX_LIMIT], vis[MAX_LIMIT];
queue<int> q;

set<int> done, allDone;

int C[MAX_LIMIT], memo[MAX_LIMIT][15];

std::vector<pair<int, pair<int, int> > > Q;

void bfs(int node, int distLimit, int thisColor)
{
	q.push(node);
	vis[node] = 1;
	dist[node] = distLimit;
	while(!q.empty())
	{
		node = q.front();
		q.pop();

		if(allDone.find(node) == allDone.end())
			C[node] = thisColor;
		done.insert(node);
		allDone.insert(node);
		// cerr << node << " " << thisColor << "\n";
		if(dist[node] == 0)
		{
			// cerr << node + 1 << "\n";
			continue;
		}



		int i, limit = adj[node].size();
		fl(i,0,limit)
		{
			int v = adj[node][i];
			if(vis[v])
				continue;
			
			dist[v] = dist[node] - 1;
			bool flag = 0;
			for(int j = dist[v]; j <= 10; j++)
			{
				if(memo[v][j])
					flag = 1;
			}
			if(flag)
			{
				// cerr << node + 1 << " " << v + 1 << "\n";
				continue;
			}

			vis[v] = 1;
			memo[v][dist[v]] = 1;
			// cout << v + 1 << " " << dist[v] << "\n";
			q.push(v);
		}
	}
	return;
}

int main()
{
	int i, j;

	scanf("%d %d", &nodes, &edges);

	for(int i = 0; i < edges; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);

		x--;	y--;
		adj[x].PB(y);
		adj[y].PB(x);
	}

	int qws;
	scanf("%d", &qws);

	for(int i = 0; i < qws; i++)
	{
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		x--;

		Q.PB(MP(x, MP(y, c)));
	}

	for(int i = qws - 1; i >= 0; i--)
	{
		if(allDone.size() == nodes)
			break;
		int x = Q[i].first;
		int y = Q[i].second.first;
		int c = Q[i].second.second;

		bool f = 0;

		for(int j = y; j <= 10; j++)
		{
			if(memo[x][j])
				f = 1;
		}

		if(f)
			continue;

		// cout << x << " " << y << "\n";

		memo[x][y] = 1;

		bfs(x, y, c);

		while(!done.empty())
		{
			int v = *done.begin();
			done.erase(v);
			vis[v] = 0;
		}
	}

	for(int i = 0; i < nodes; i++)
		printf("%d\n", C[i]);


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 24048
#C問題
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]

B = [0 for i in range(N)]
for a in A:
    B[a-1]+=1

for b in B:
    if K-(Q-b) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8628
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n=int(input())
if n==1:
    ans=0
else:
    a=prime_factorize(n)
    if a==[]:
        ans=1
    else:
        ans=0
        xzen=a[0]
        count=1
        ans+=1
        for x in range(1,len(a)):
            if xzen==a[x]:
                count+=1
                if count==3 or count==6 or count==10 or count==15 or count==21 or count==28 or count==36:
                    ans+=1
            else:
                xzen=a[x]
                count=1
                ans+=1
print(ans)

Measured memory_bytes: 9244
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int n, i;
int ord(int n, int a[]){
	int j, cnt=0;
	lop(i, n-1){
		for(j=i; j<n; j++){
			if(a[i]>a[j]) cnt++;
		}
		cnt*=n-i-1;
	}
	return cnt;
}

int main()
{
	scanf("%d", &n);
	int p[8], q[8];
	lop(i, n){ scanf("%d", &p[i]); }
	lop(i, n){ scanf("%d", &q[i]); }
	
	int P=ord(n, p), Q=ord(n, q);
	
	printf("%d", abs(P-Q));
	
return 0;
}

Measured memory_bytes: 128
s = str(input())
t = str(input())
L = []
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] == '?' or s[i+j] == t[j]:
            continue
        else:
            break
    else:
        ns = s[:i] + t + s[i+len(t):]
        ns = ns.replace('?', 'a')
        L.append(ns)
L.sort()
if L:
    print(L[0])
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
using System;
class Program
{
	static void Main()
	{
	long n = long.Parse(Console.ReadLine());//long.Parseは文字列を整数に変換。
  long digit = whatDigit(n);
  long answer = 0;

  long multypleNum = 1;//+がないとき左の数は10倍

  for(long i = 0; i < (Math.Pow(2,digit-1)); i++)//２進数で全通り試す
  {
    long ii = i;
    long nn = n;
    for(long j = 0; j < digit; j++)
    {
      answer += (nn % 10) * multypleNum;
      nn /= 10;
      if(ii % 2 == 1) multypleNum *= 10;
      else multypleNum = 1;
      ii /= 2;
    }
  }
	
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}

  static long whatDigit (long n)//nは何桁か
  {
    for(long i = 1; i < 20; i++)
    {
      n /= 10;
      if(n == 0)
      {
        return i;
        break;
      }
    }
    return 0;
  }
}

Measured memory_bytes: 11092
while gets
a=$_.split.map(&:to_i)
b=gets.split.map(&:to_i)
c,d=0,0;
4.times{|i|
c+=1 if a[i]==b[i]
d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i]
}
puts "#{c} #{d}"
end

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

int main() {
    int N; cin >> N;
    vector<int> a(N);
    vector<int> copy(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        copy.at(i) = a.at(i);
    }
    sort(copy.begin(), copy.end());
    int mx = copy.at(N-1), mx2 = copy.at(N-2);
    for (int i = 0; i < N; i++) {
        if (a.at(i) == mx) cout << mx2 << endl;
        else cout << mx << endl;
    }
}

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

using namespace std;

    string S;
    bool bad = false;

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

    cin >> S;

    for (int i = 1; i < 4; i++)
    {
        if (S[i] == S[i-1])
        {
            bad = true;
        }
        
    }
    
    if(bad){
        cout << "Bad\n";
    }else{
        cout << "Good\n";
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    string str;
    string seven = "7";
    cin >> str;
    for(int i=0;i<str.length();i++){
        if(str.compare(i,1,seven)==0){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

int play(int x, int y) {
    if (x == y) {
        return false;
    }
    if (y == 0 && x == 2) {
        return true;
    }
    if (y == 2 && x == 0) {
        return false;
    }
    if (y > x) {
        return true;
    }
    return false;
}

int conv(char c) {
    if (c == 'r') {
        return 0;
    }
    if (c == 'p') {
        return 1;
    }
    return 2;
}

const int K = 1e5 + 7;

ll dp[K][3];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int r, p, s;
    cin >> r >> p >> s;
    vector <int> pts(3);
    pts[0] = r;
    pts[1] = s;
    pts[2] = p;
    vector <int> a(n);
    vector <int> g[k];
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        g[i % k].push_back(conv(c));
    }
    for (int i = 0; i < k; i++) {
        int sz = (int) g[i].size();
        if (sz == 0) {
            continue;
        }
        vector <ll> cur_dp(3, 0);
        for (int t = 0; t < 3; t++) {
            if (play(g[i][0], t) == 1) {
                cur_dp[t] = pts[t];
            }
        }
        for (int j = 1; j < sz; j++) {
            vector <ll> go(3, 0);
            for (int t = 0; t < 3; t++) {
                for (int pt = 0; pt < 3; pt++) {
                    if (t == pt) {
                        continue;
                    }
                    ll cur = 0;
                    if (play(g[i][j], t) == 1) {
                        cur = pts[t];
                    }
                    go[t] = max(go[t], cur_dp[pt] + cur);
                }
            }
            cur_dp = go;
        }
        for (int t = 0; t < 3; t++) {
            dp[i][t] = cur_dp[t];
        }
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        ll cur = 0;
        for (int j = 0; j < 3; j++) {
            cur = max(cur, dp[i][j]);
        }
        ans += cur;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7552
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  ll T;
  cin >> N >> T;
  VL t(N + 1);
  REP(i, N) {
    cin >> t[i];
  }

  t[N] = INF;
  ll X = 0;

  REP(i, N) {
    X += min(t[i + 1] - t[i], T);
  }

  cout << X << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll i,j,n,a=0,w=0,t=0,r=0;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
        {a++;}
        if(s=="WA")
        {w++;}
        if(s=="TLE")
        {t++;}
        if(s=="RE")
        {r++;}
    }
    cout<<"AC"<<" "<<"x "<<a<<endl;
    cout<<"WA"<<" "<<"x "<<w<<endl;
    cout<<"TLE"<<" "<<"x "<<t<<endl;
    cout<<"RE"<<" "<<"x "<<r<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  if(n<2)
    cout << 1 << endl;
  else if(n<4)
    cout << 2 << endl;
  else if(n<8)
    cout << 4 << endl;
  else if(n<16)
    cout << 8 << endl;
  else if(n<32)
    cout << 16 << endl;
  else if(n<64)
    cout << 32 << endl;
  else if(n<128)
    cout << 64 << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(Math.abs(m - n) > 1) {
			System.out.println("0");
		}
		else {
			long permutation = 1;
			if(Math.abs(m - n) == 0) permutation *= 2;
			for(int i = 2; i <= n; i++) permutation = permutation * i % 1000000007;
			for(int i = 2; i <= m; i++) permutation = permutation * i % 1000000007;
			System.out.println(permutation);
		}
	}
}

Measured memory_bytes: 22100
def gmax(a,b):
  if a<b:
  	a,b=b,a
  while a%b!=0:
    tmp=a
    a=b
    b=tmp%b
  return b
 
n=int(input())
x=[]
for i in range(n):
  x.append(int(input()))

if len(x)!=1:
  g=gmax(x[0],x[1])
  l=x[0]*x[1]//g

  for i in range(2,len(x)):
    g=gmax(x[i],l)
    l=(x[i]*l)//g
else:
  l=x[0]
print(l)

Measured memory_bytes: 3064
#!/usr/bin/env python3
s = input()
pre = []
post = []
rev_it = 0#反転の回数
q = int(input())
for i in range(q):
    query = input()
    if query[0] == "1": rev_it += 1
    elif query[2] == "1":
        if rev_it % 2 == 0:
            pre.append(query[4])
        else:
            post.append(query[4])
    else:
        if rev_it % 2 == 0:
            post.append(query[4])
        else:
            pre.append(query[4])
ans = "".join(pre)[::-1]+s+"".join(post)
if rev_it % 2 == 0:
    print(ans)
else:
    print(ans[::-1])



Measured memory_bytes: 72024