akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Diagnostics;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        //ソートで必要な数を計算+もしN-1だったらswap可能な場所を探す
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var mergedSorted = a.OrderBy(x => x).Zip(b.OrderBy(x => x), (x, y) => new Tuple<int, int>(x, y)).ToArray();
        if (mergedSorted.Any(x => x.Item1 > x.Item2))
        {
            Console.WriteLine("No");
            return;
        }
        if (mergedSorted.Zip(mergedSorted.Skip(1), (x, y) =>
        {
            var fa = x.Item1;
            var fb = x.Item2;
            var sa = y.Item1;
            var sb = y.Item2;
            //swap可能
            return fa <= sb && sa <= fb;
        }).Any(x => x))
        {
            Console.WriteLine("Yes");
            return;
        }
        Dictionary<int, int> adic = a.OrderBy(x => x).Select((x, y) => new Tuple<int, int>(x, y)).ToDictionary(x => x.Item1, x => x.Item2);
        var inita = a.Zip(b, (x, y) => new Tuple<int, int>(x, y)).OrderBy(x => x.Item2).Select(x => adic[x.Item1]).ToArray();
        int pos = 0;
        int count = 0;
        do
        {
            pos = inita[pos];
            count++;
        }
        while (pos != 0) ;
        Console.WriteLine(count == n ? "No" : "Yes");
    }
}


Measured memory_bytes: 50280
using System;
class walkmultable{
  public static void Main(){
    ulong n = ulong.Parse(Console.ReadLine());
    ulong ret=0;
    for(ulong i=(ulong)Math.Sqrt(n)+1; i>0; i--){
      if(n%i == 0){
        ret = i+(n/i)-2;
        break;
      }
    }
    Console.WriteLine(ret);
  }
}


Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  int sum=0;
  int sum2=0;
  vector<int> p(n);
  rep(i,n){
  cin>>p[i];
  sum+=p[i];
  sum2+=p[i]*p[i];
  }
  
  int ans = 1000000000;
  repo(i,101){
    ans=min(ans,sum2-2*i*sum+i*i*n);
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"

using namespace std;

const long long int MOD = 1000000007;

long long int N;

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

	cin >> N;
	map<char, int>m;
	for (char a = 'a'; a <= 'z'; a++)m[a] = 0;
	vector<int>dp(N + 1, MOD);
	string s;
	dp[1] = 1;
	for (int i = 1; i <= N; i++) {
		cin >> s;
		char box = s[0];
		if (i > 1) {
			int bef = m[box];
			dp[i] = min(dp[i - 1] + 1, dp[bef]);
		}
		m[box] = i;
	}
	cout << dp.back() << endl;
	return 0;
}


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

char map[100][100];
char now;
int h, w;
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

void dfs(int a, int b){
	map[a][b] = '0';
	for(int i = 0; i < 4; i++){
		int na = a + dh[i], nb = b + dw[i];
		if(na >= 0 && na < h && nb >= 0 && nb < w && map[na][nb] == now){
			dfs(na, nb);
		}
	}
	return;
}

int main(void){
	int cnt;
	while(true){
		cnt = 0;
		cin >> h >> w;
		if(!h && !w)	break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(map[i][j] == '#' || map[i][j] == '*' || map[i][j] == '@'){
					now = map[i][j];
					dfs(i, j);
					cnt++;
				}
			}
		}

		printf("%d\n", cnt);
	}
  return 0;
}

Measured memory_bytes: 1464
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

long compare(const void *a,const void *b){
  return *(long*)b - *(long*)a;
}

int main(){
  long n = 0;
  long h = 0;
  long a[100000] = {};
  long b[100000] = {};
  long ac[100000] = {};
  long bc[100000] = {};
  long amax = 0;
  long i = 0;
  long atk = 0;
  scanf("%ld %ld",&n,&h);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&a[i],&b[i]);
  }
  memcpy(ac,a,n*sizeof(long));
  memcpy(bc,b,n*sizeof(long));

  qsort(ac,n,sizeof(long),compare);
  qsort(bc,n,sizeof(long),compare);
  
  /*for(i=0;i<n;i++){
    printf("%ld %ld\n",ac[i],bc[i]);
  }*/
  
  amax = ac[0];
  for(i=0;i<n;i++){
    if(amax <= bc[i]){
      h -= bc[i];
      atk++;
      if(h <= 0){
        break;
      }
    }
  }
  if(h > 0){
    if(h % amax == 0){
      atk += h / amax;
    }else{
      atk += h / amax + 1;
    }
  }
  printf("%ld",atk);
  return 0;
}
  
      

Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	string p;
	rep(i, w+2)
		p.push_back('#');
	rep(i, h)
		cin >> s.at(i);
	cout << p << endl;
	rep(i, h)
		cout << "#" << s.at(i) << "#" << endl;
	cout << p << endl;
	return (0);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  vector<int>h(n);
  rep(i,n) cin>>h[i];
 reverse(h.begin(),h.end());
  int ans=0;
  int val=0;
  for(int i=1;i<n;i++){
    if(h[i-1]<=h[i]) val++;
    else val=0;
    ans=max(val,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
	public static void main(String[] args){
	Scanner in = new Scanner(System.in);
int i = 1;
		while(true){
			
			int x = in.nextInt();
			if(x == 0){
				break;
			}
			System.out.println("Case " + i + ": " + x);
                        i++;
		}
	}
}


Measured memory_bytes: 41676
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


struct dinic_flow{
	struct edge{
		int to,cap,p;
	};
	vector<edge> vs[105];
	
	void adde(int fr,int to,int cap){
		vs[fr].push_back((edge){to,cap,vs[to].size()});
		vs[to].push_back((edge){fr,0,vs[fr].size()-1});
	}
	
	int dep[105];
	int ite[105];
	
	int bfs(int st){
		queue<mp> que;
		memset(dep,-1,sizeof(dep));
		dep[0]=0;
		que.push(mp(0,st));
		while(!que.empty()){
			mp pa=que.front();
			que.pop();
			int no=pa.sec,
				d=pa.fir;
			rep(i,vs[no].size()){
				edge e=vs[no][i];
				if(e.cap<=0 || dep[e.to]>=0)continue;
				dep[e.to]=d+1;
				que.push(mp(d+1,e.to));
			}
		}
	}
	
	int dfs(int no,int gl,int f){
		if(no==gl)return f;
		for(int &i=ite[no];i<vs[no].size();i++){
			edge& e=vs[no][i];
			if(e.cap<=0 || dep[no]>=dep[e.to])continue;
			int tf=dfs(e.to,gl,min(f,e.cap));
			if(tf>0){
				e.cap -= tf;
				vs[e.to][e.p].cap += tf;
				return tf;
			}
		}
		return 0;
	}
	
	int inf;
	dinic_flow(){ inf = IINF; }
	int dinic(int st,int gl){
		int res=0;
		for(;;){
			bfs(st);
			/*
			rep(i,4){
				printf("dep[%d] .. %d\n",i,dep[i]);
				rep(j,vs[i].size()){
					edge e = vs[i][j];
					printf("%d : %d %d\n",i,e.to,e.cap);
				}
			}*/
			if(dep[gl]<0)break;
			memset(ite,0,sizeof(ite));
			for(;;){
				int f=dfs(st,gl,inf);
				if(f==0)break;
				res+=f;
			}
		}
		return res;
	}
			
} flow;


int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		flow.adde(a,b,c);
	}
	printf("%d\n",flow.dinic(0,n-1));
	return 0;
}

Measured memory_bytes: 3328
N=int(input())
L=list(map(int,input().split()))
dic=[0]*1005
izyo=[0]*1005#index以上の長さを持つ総計
for x in L:
	dic[x]+=1
ruike = 0
for x in range(1000,0,-1):
	ruike += dic[x]
	izyo[x] = ruike
ans=0
for a in range(1000,0,-1):#a>=b>=c
	#a=bを考える
	#  a=b=cを考える
	ans+=dic[a]*(dic[a]-1)*(dic[a]-2)//6
	#if ans>0:print("~a:",a,"ans",ans)
	#  a=b>cを考える
	ans+=dic[a]*(dic[a]-1)//2*(izyo[1]-izyo[a])
	#if ans>0:print("-a:",a,"ans",ans)
	
	#a>bを考える
	for b in range(a-1,a//2,-1):
		#b=cを考える
		ans+=dic[a]*dic[b]*(dic[b]-1)//2
		#if ans>0:print("^a:",a,"ans",ans)
		#b>cを考える
		ans+=dic[a]*dic[b]*(izyo[a-b+1]-izyo[b])
		#if ans>0:print("#a:",a,"ans",ans)
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main() {
  char c;
  
  scanf("%c\n", &c);
  
  if (c == 'A')
    printf("T");
  else if (c == 'T')
    printf("A");
  else if (c == 'C')
    printf("G");
  else if (c == 'G')
    printf("C");
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1005;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char lol[4] = {'R', 'L', 'U', 'D'};
int x[N], y[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> x[i] >> y[i];
	}
	bool par = ((x[1] + y[1]) % 2 + 2) & 1;
	fr(i, 1, n){
		bool par1 = ((x[i] + y[i]) % 2 + 2) & 1;
		if(par1 != par){
			cout << -1;
			return;
		}
	}
	int k = 33;
	int kk = k;
	if(!(par & 1)){
		kk++;
	}
	cout << kk << endl;
	if(!(par & 1)){
		cout << 1 << " ";
	}
	fr(i, 0, k - 1){
		cout << (1LL << i) << " ";
	}
	cout << endl;
	fr(i, 1, n){
		pii p = {x[i], y[i]};
		if(!(par & 1)){
			p.fi++;
			cout << 'L';
		}
		vector<char> v(k, 'a');
		for(int j = k - 1; j >= 0; j--){
			int val = (1LL << j);
			fr(z, 0, 3){
				pii q = p;
				q.fi -= dx[z] * val;
				q.se -= dy[z] * val;
				if(abs(q.fi) + abs(q.se) <= val - 1){
					v[j] = lol[z];
					p = q;
					break;
				}
			}
		}
		for(char ch : v){
			cout << ch;
		}
		cout << endl;
	}
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int a, b;
	while(~scanf(" %d %d", &a, &b)) {
		printf("%d %d\n", __gcd(a, b), a / __gcd(a, b) * b);
	}
	return 0;
}

Measured memory_bytes: 0
use proconio::{fastout, input};

pub trait LexicalPermutation {
    /// Return  if the slice was permuted,  if it is already
    /// at the last ordered permutation.
    fn next_permutation(&mut self) -> bool;
    /// Return  if the slice was permuted,  if it is already
    /// at the first ordered permutation.
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    /// Original author in Rust: Thomas Backman <serenity@exscape.org>
    fn next_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the last-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Find the rightmost element larger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }

        // Step 3: Swap that element with the pivot
        self.swap(j, i - 1);

        // Step 4: Reverse the (previously) weakly decreasing part
        self[i..].reverse();

        true
    }

    fn prev_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly increasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the first-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Reverse the weakly increasing part
        self[i..].reverse();

        // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }

        // Step 4: Swap that element with the pivot
        self.swap(i - 1, j);

        true
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n],
        q: [usize; n]
    }

    let find_prm = |v: Vec<usize>| -> isize {
        // let mut prm = (1..=n).collect::<Vec<usize>>();
        let mut prm = (1..=n).collect::<Vec<usize>>();
        let mut prm_index = 0;
        loop {
            prm_index += 1;
            if v == prm {
                return prm_index;
            }

            if !prm.next_permutation() {
                panic!();
            }
        }
    };

    println!("{:?}", (find_prm(p) - find_prm(q)).abs());
}


Measured memory_bytes: 2188
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int x,a,b;

int main(){
	cin>>x>>a>>b;
	if(a>=b){
		cout<<"delicious"<<endl;
	}else if(x+a>=b){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    int n,d; cin >> n >> d;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x,y; cin >> x >> y;
        if(x*(ll)x + y*(ll)y <= d*(ll)d){
            cnt++;
        }
    }

    cout << cnt << endl;


}

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

int main(void){
  int h,w;
  while(cin>>h>>w,h||w){
    for(int i=0;i<h;++i){
      for(int j=0;j<w;++j){
      	if(!i||!j||i==h-1||j==w-1)printf("#");
      	else printf(".");
      }
      puts("");
    }
    puts("");
  }
}

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int nums[3];
    for(int i = 0; i < 3; i++){
        cin >> nums[i];
    }
    int K;
    cin >> K;
    for(int i = 0; i < K; i++){
        sort(nums, nums + 3);
        nums[2] *= 2;
    }
    cout << nums[0] + nums[1] + nums[2] << endl;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val num = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val dice = Dice(num[0],num[1],num[2],num[3],num[4],num[5])
    val order = readLine() ?: return
    order.forEach {
        when(it){
            'N'  -> dice.toN()
            'E'  -> dice.toE()
            'S'  -> dice.toS()
            else -> dice.toW()
        }

    }
    println(dice.getTop())
}

class Dice (var one:Int,
            var two:Int,
            var three:Int,
            var four:Int,
            var five:Int,
            var six:Int){

    fun toN(){
        val temp = one
        one  = two
        two  = six
        six  = five
        five = temp
    }

    fun toS(){
        val temp = one
        one  = five
        five = six
        six  = two
        two  = temp
    }

    fun toE(){
        val temp = one
        one   = four
        four  = six
        six   = three
        three = temp
    }

    fun toW(){
        val temp = one
        one   = three
        three = six
        six   = four
        four  = temp
    }

    fun getTop() : Int {
        return one
    }
}


Measured memory_bytes: 33864
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, W;
  cin >> N >> W;
  vector<int64_t> weight(N + 1);
  vector<int64_t> value(N + 1);
  int64_t total_value = 0;
  for (int64_t i = 1; i <= N; ++i) {
    cin >> weight[i] >> value[i];
    total_value += value[i];
  }
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t result = 0;
  vector<int64_t> minimum_weight(total_value + 1, kInf);
  minimum_weight[0] = 0;
  for (int64_t i = 1; i <= N; ++i) {
    for (int64_t v = total_value; v >= 0; --v) {
      const int64_t prev_value = v - value[i];
      if (prev_value >= 0) {
        minimum_weight[v] = min(minimum_weight[v], minimum_weight[prev_value] + weight[i]);
      }
      if (minimum_weight[v] <= W) {
        result = max(v, result);
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3968
import sys
import numpy as np

input = sys.stdin.readline

N, K = map(int, input().split())
h = np.array(list(map(int, (input().split()))))

dp = np.full(N,sys.maxsize,dtype=int)

dp[0] = 0

for i in range(1, N):
    s = max(0, i - K)
    dp[i] = min(dp[s:i] + abs(h[i] - h[s:i]))

print(dp[N - 1])


Measured memory_bytes: 22816
// AOJ 1313 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1313)
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()

const int MAX_M = 100, MAX_N = 100;

int m, n;
int x1[MAX_M], yo[MAX_M];
int x2[MAX_N], z2[MAX_N];
std::vector<int> xs;

double slice( int *X, int *Y, int sz, double x )
{
	double lb = 101, ub = -101;

	rep( i, sz )
	{
		int xi = X[i], yi = Y[i], nx = X[(i+1)%sz], ny = Y[(i+1)%sz];

		if( (xi-x)*(nx-x) <= 0 && xi != nx )
		{
			double y = yi+(ny-yi)*(x-xi)/(nx-xi);

			lb = std::min( lb, y );
			ub = std::max( ub, y );
		}
	}

	return std::max( 0.0, ub-lb );
}

int main()
{
	while( scanf( "%d%d", &m, &n ), m|n )
	{
		xs.clear();

		int mi1 = 101, ma1 = -101, mi2 = 101, ma2 = -101;

		rep( i, m )
		{
			scanf( "%d%d", x1+i, yo+i );
			xs.push_back(x1[i]);
			mi1 = std::min( mi1, x1[i] );
			ma1 = std::max( ma1, x1[i] );
		}
		rep( i, n )
		{
			scanf( "%d%d", x2+i, z2+i );
			xs.push_back(x2[i]);
			mi2 = std::min( mi2, x2[i] );
			ma2 = std::max( ma2, x2[i] );
		}

		std::sort( all(xs) );

		double ans = 0.0;

		rep( i, xs.size()-1 )
		{
			double a = xs[i], b = xs[(i+1)], c = (a+b)/2;

			if( mi1 <= c && c <= ma1 && mi2 <= c && c <= ma2 )
			{
				double fa = slice(x1,yo,m,a)*slice(x2,z2,n,a),
					   fb = slice(x1,yo,m,b)*slice(x2,z2,n,b),
					   fc = slice(x1,yo,m,c)*slice(x2,z2,n,c);

				ans += (b-a)/6*(fa+4*fc+fb);
			}
		}

		printf( "%.12f\n", ans );
	}

	return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
 
const int INF=250000;
int main(){
  int N,C;
  cin>>N>>C;
  vector<int> s(N),t(N),c(N);
  for(int i=0;i<N;++i){
    cin>>s[i]>>t[i]>>c[i];
    s[i] *= 2;
    t[i] *= 2;
  }
 
  vector<vector<int>> sum(C+1,vector<int>(INF));
  for(int i=0;i<N;++i){
    ++sum[c[i]][s[i]-1];
    --sum[c[i]][t[i]+1];
  }
 
  for(int i=1;i<=C;++i){
    for(int j=1;j<INF;++j){
      sum[i][j] += sum[i][j-1];
    }
  }
 
  int cnt=0;
  for(int i=0;i<INF;++i){
    int subcnt=0;
    for(int j=1;j<=C;++j){
      if(sum[j][i]>0) ++subcnt;
    }
    cnt=max(cnt,subcnt);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 32768
#include <iostream>
#include <set>


using namespace std;


int main()
{
    set<int> a;
    for( int i = 0; i < 3; ++i ){
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    
    
    cout << a.size() << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
// abc179_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int zoro = 0;
    bool ok = false;
    REP(i, N){
        int a, b;
        cin >> a >> b;

        if (a == b){
            zoro++;
            if (zoro == 3){
                ok = true;
            }
        } else {
            zoro = 0;
        }
    }

    if (ok){
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 3636
m = int(input())
for _ in range(m):
  fund = int(input())
  year = int(input())
  n = int(input())
  ans = fund
  for i in range(n):
    t, rate, fee = map(float, input().split())
    if t:
      a = fund
      b = 0
      for j in range(year):
        b = int(a*rate)
        a = a+b-fee
      ans = max(ans, a)
    else:
      a = fund
      b = 0
      for j in range(year):
        b+= int(a*rate)
        a = a-fee
      ans = max(ans, a+b)
  print(int(ans))


Measured memory_bytes: 5624
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_; std::vector<std::vector<Type> > dat;
	inline int query_(int a, int b, Type x, int k, int l, int r) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r)
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
		int lc = query_(a, b, x, k << 1, l, (l + r) >> 1);
		int rc = query_(a, b, x, k << 1 | 1, (l + r) >> 1, r);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::vector<Type>());
		for (int i = 0; i < n; i++) dat[i + size_] = std::vector<Type>({ *(begin_ + i) });
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[i << 1 | 1].size());
			int cl = 0;
			for (int j = 0; j < dat[i].size(); j++) {
				if (j - cl == dat[i << 1 | 1].size() || (cl != dat[i << 1].size() && dat[i << 1][cl] < dat[i << 1 | 1][j - cl])) {
					dat[i][j] = dat[i << 1][cl++];
				}
				else {
					dat[i][j] = dat[i << 1 | 1][j - cl];
				}
			}
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		return query_(l, r, x, 1, 0, size_);
	}
};

#endif

#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, xl, yl, xr, yr;
int main() {
	scanf("%d%d", &N, &Q);
	vector<pair<int, int> > p(N);
	for (int i = 0; i < N; i++) scanf("%d%d", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	vector<int> z1(N), z2(N);
	for (int i = 0; i < N; i++) {
		z1[i] = p[i].first;
		z2[i] = p[i].second;
	}
	RangeTree<int> seg(z2.begin(), z2.end());
	while (Q--) {
		scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
		int ptr1 = lower_bound(z1.begin(), z1.end(), xl) - z1.begin();
		int ptr2 = lower_bound(z1.begin(), z1.end(), xr + 1) - z1.begin();
		int res1 = seg.query(ptr1, ptr2, yl);
		int res2 = seg.query(ptr1, ptr2, yr + 1);
		printf("%d\n", res2 - res1);
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'
const int N = 1000;
LL x[N];

int main() {
  fast_io;
  LL n, k;
  cin >> n >> k;
  for (LL i = 0; i < n; i++) {
    cin >> x[i];
  }
  LL msum = 0;
  for (LL i = 0; i <= n; i++) {
    for (LL j = 0; j <= n; j++) {
      if (i + j <= k && i + j <= n) {
        LL sum = 0;
        std::vector<LL> y;
        for (LL l = 0; l < i; l++) {
          sum += x[l];
          y.PB(x[l]);
        }
        for (LL l = n - j; l < n; l++) {
          sum += x[l];
          y.PB(x[l]);
        }
        sort(ALL(y));
        LL rem = k - i - j;
        rem = min(rem, 1LL * SZ(y));
        for (LL l = 0; l < rem; l++)
          if (y[l] < 0)
            sum -= y[l];
        msum = max(msum, sum);
      }
    }
  }
  cout << msum << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "math"
)

func main() {
        var n int
        fmt.Scan(&n)
        l := int(math.Sqrt(float64(n)))
        min := math.MaxInt32
        for i := 1; i <= l; i++ {
                if n%i == 0 {
                        var cmin int
                        if di, dni := digits(i), digits(n/i); di < dni {
                                cmin = dni
                        } else {
                                cmin = di
                        }
                        if cmin < min {
                                min = cmin
                        }
                }
        }
        fmt.Printf("%d\n", min)
}

func digits(n int) (d int) {
        tmp := n
        for tmp > 0 {
                d++
                tmp /= 10
        }
        return d
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
int num;

ll number(string& s, ll& i);
ll term(string& s, ll& i);
ll factor(string& s, ll& i);
ll expr(string& s, ll& i);

ll number(string& s, ll& i) {
	ll n = s[i++] - '0';
	while (isdigit(s[i])) n = n * 10 + s[i++] - '0';
	return n;
}

ll factor(string& s, ll& i) {
	if (isdigit(s[i])) return number(s, i);
	i++;
	ll ret = expr(s, i);
	i++;
	return ret;
}

ll term(string& s, ll& i) {
	ll val = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		int val2 = factor(s, i);
		if (op == '*') val *= val2;
		else val /= val2;
	}
	return val;
}

ll expr(string& s, ll& i) {
	ll val = term(s, i);
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i];
		i++;
		int val2 = term(s, i);
		if (op == '+') val += val2;
		else val -= val2;
	}
	return val;
}

int main() {
	cin >> s >> num;
	ll pos = 0;
	ll m = expr(s, pos);
	ll l = s[0] - '0';
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == '+')l += s[i + 1] - '0';
		else l *= s[i + 1] - '0';
	}
	if (m == num) {
		if (l == num)cout << "U" << endl;
		else cout << "M" << endl;
	}
	else if (l == num)cout << "L" << endl;
	else cout << "I" << endl;
}

Measured memory_bytes: 3184
loop do
	n = $<.gets.to_i
	break if n.zero?

	m = n.times.map do
		$<.gets.split.map(&:to_i).tap{|a| a << a.inject(&:+)}
	end
	m << m.inject {|r1, r2| r1.zip(r2).map {|a, b| a + b}}

	m.each do |row|
		puts row.map{|i| "%5d" % i}.join
	end
end

Measured memory_bytes: 6132
#include<cstdio>
#include<iostream>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-8;i++){
		cout<<s[i];
	}
	return 0;
}

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

num_list = list(map(int, input().split()))

hats = [0, 0, 0]


ans = 1

for i in range(N):
    same_color = num_list[i]
    if same_color not in hats:
        print(0)
        break
    cand_num = hats.count(same_color)
    ans *= cand_num
    ans = ans % 1000000007
    hats[hats.index(same_color)] += 1
else:
    print(ans)


Measured memory_bytes: 14056
n = int(input())
a = list(map(int, input().split()))
s = 0
d = {}
for i in a:
    s += i
    d[s] = d.get(s, 0) + 1
ans = 0
for key, value in d.items():
    ans += value*(value-1)//2
    if key == 0:
        ans += value
print(ans)

Measured memory_bytes: 38676
#include <cstdio>
#include <queue>

using namespace std;

const int maxn=810;

int vis[maxn][maxn],walkx[]={0,0,-1,1},walky[]={1,-1,0,0};
char str[maxn][maxn];

struct node
{
	int x,y,t;
};

queue <node> q;

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",&str[i][1]);
		for(int j=1;j<=m;j++)
		{
			if(str[i][j]=='S')
			{
				q.push((node){i,j,0});
				vis[i][j]=1;
			}
		}
	}
	int ans=2e9;
	while(!q.empty())
	{
		node t=q.front();q.pop();
		int tt=min(t.x,t.y);
		ans=min(ans,(tt-1)/k+((tt-1)%k!=0));
		ans=min(ans,(n-t.x)/k+((n-t.x)%k!=0));
		ans=min(ans,(m-t.y)/k+((m-t.y)%k!=0));
		if(t.t==k)continue;
		for(int i=0;i<4;i++)
		{
			int newx=t.x+walkx[i],newy=t.y+walky[i];
			if(newx>0&&newx<=n&&newy>0&&newy<=m&&!vis[newx][newy]&&str[newx][newy]!='#')
			{
				q.push((node){newx,newy,t.t+1});
				vis[newx][newy]=1;
			}
		}
	}
	ans++;
	printf("%d\n",ans);
	return 0;
} 

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

int main() {
    string s;
    int i;
	cin>>s;
	for(i=0;i<3;i++)
	{
	    if(s[i]=='1')
	    cout<<9;
	    else
	    cout<<1;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int *insertionSort(int *, int);

void printArray(int *, int );
int main() {
  
  int n,a[1000],*b;
  int i;

  for (i = 0; i < 1000; i++ ) {
        a[i] = 0;
    }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  b = insertionSort(a,n);
  
  printArray(b,n);
  printf("\n");
  return 0;
}

int *insertionSort (int *A, int N) {
  int i,j;
  int v;
  
  for(i = 1 ; i < N ; i++ ) { 
    printArray(A,N);
    printf("\n");

    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

  }
  return A;
}

void printArray(int *A, int N) {
  int i;
  
  for(i=0;i<N-1;i++) {
    printf("%d ",A[i]);
  }
  printf("%d",A[N-1]);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
     
using namespace std;
     
int main() {
  int n, mx = 0, ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (mx <= x) {
      ++ans;
    }
    mx = max(mx, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
class Program
 {
   	static void Main(string[] args)
        {
    　　	string a = Console.ReadLine(); //標準入力
		string[] aa = a.Split(' ');
		

	       	int N = int.Parse(aa[0]);
	       	int M = int.Parse(aa[1]);
      
		bool test = N==M;

		if(test){
			Console.WriteLine("{0}", "Yes");
		}else{
			Console.WriteLine("{0}", "No");
		}
		
        }
 
 }

Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;

bool isP[10000001];
std::vector<ll> px;

void siever(void)
{
	memset(isP, 1, sizeof(isP));
	isP[0] = 0;
	isP[1] = 0;
	for(ll p=2;p*p<10000001;p++)
	{
		if(isP[p])
		{	
			for(ll i=p*p;i<10000001;i+=p)
			isP[i] = 0;
		}		
	}
	for(ll i=2;i<10000001;i++)
	{
		if(isP[i])
		px.pb(i);	
	}
	return;
}

ll fexp(ll a, ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
		res *= a;
		a *= a;
		n >>= 1;	
	}
	return res;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	siever();
	ll n,p;
	std::cin>>n>>p;
	ll ag = 1;
	for(int i=0,j=(int)px.size();i<j;i++)
	{
		ll xd = px[i], ct = 0;
		while(!(p % xd))
		{
			p /= xd;
			ct++;
		}
		if(ct/n)
		ag *= fexp(xd, (ct/n));
	}
	if(p > 1)
	{
		if(n == 1)
		ag *= p;	
	}
	std::cout<<ag<<"\n";
	return 0;
}

Measured memory_bytes: 20332
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  string s,t;
  cin >> s >> t;
  if(s.size()+1 != t.size()){
    NO;
    return 0;
  }
  rep(i,s.size()){
    if(s.at(i) != t.at(i)) {
      NO;
      return 0;
    }
  }
  YES;
}

Measured memory_bytes: 3596
"""
python3 main.py < input.txt
"""
import math
import itertools as it
import heapq

def gcd(a, b):
        return a if b == 0 else gcd(b, a%b)
N=int(input())
A=list(map(int, input().split()))

L=[A[0]]
for i in range(1, N):
        L.append(gcd(L[-1], A[i]))
R=[A[-1]]
for i in reversed(range(N-1)):
        R.append(gcd(R[-1], A[i]))
R.reverse()

m=max(R[1], L[-2])
for i in range(1, N-1):
        m=max(m, gcd(L[i-1], R[i+1]))
print(m)

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

const int inf = 1000003;

string S;
int dp[100005], tree[400005];

void update(int left, int right, int x, int val, int root)
{
    if(left > x || right < x)
        return;
    
    if(left == right)
    {
        tree[root] = val;
        return;
    }

    int mid = (left + right) / 2;

    update(left, mid, x, val, root*2);
    update(mid+1, right, x, val, root*2+1);

    tree[root] = min(tree[root*2], tree[root*2+1]);
}

int query(int left, int right, int L, int R, int root)
{
    if(left > R || right < L)
        return inf;
    
    if(left >= L && right <= R)
        return tree[root];
    
    int mid = (left + right) / 2;

    return min(query(left, mid, L, R, root*2), query(mid+1, right, L, R, root*2+1));
}

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

    int N, M;
    cin >> N >> M >> S;

    for(int i=N-1; i>=0; i--)
    {
        if(S[i] == '1')
        {
            dp[i] = inf;
            update(0, N, i, dp[i], 1);
            continue;
        }

        int L = i+1, R = min(N, i+M);
        dp[i] = min(inf, 1 + query(0, N, L, R, 1));
        update(0, N, i, dp[i], 1);
    }

    if(dp[0] == inf)
    {
        cout << -1 << "\n";
        return 0;
    }

    int ptr = 0;

    while(ptr != N)
    {
        int target = dp[ptr] - 1, ans = 0;

        while(dp[ptr] != target)
            ans++, ptr++;
        
        cout << ans << " ";
    }

    return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<pair<long long int, long long int> > st(N);
    vector<pair<long long int, long long int> > cp(M);
    for(int n=0; n<N; n++) {
        cin >> st[n].first >> st[n].second;
    }
    for(int m=0; m<M; m++) {
        cin >> cp[m].first >> cp[m].second;
    }
    for(int n=0; n<N; n++) {
        long long int ans=abs(st[n].first-cp[0].first)+abs(st[n].second-cp[0].second);
        int idx=1;
        for(int m=1; m<M; m++) {
            if(ans>abs(st[n].first-cp[m].first)+abs(st[n].second-cp[m].second)) {
                ans = abs(st[n].first-cp[m].first)+abs(st[n].second-cp[m].second);
                idx = m+1;
            }
        }
        cout << idx << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let mut a: Vec<f64> = read_vec();
    for i in 0..n {
        a[i] /= a[i] * a[i];
    }
    let mut ans = 0.0;
    for i in a {
        ans += i;
    }
    println!("{}", 1.0 / ans);
}





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

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,a[200010];
L p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  {
	   scanf("%d",&a[i]);
	   if(a[i]>a[i-1]+1)
	     break;
      }
	if(a[1] || i<=n)
	  {
       printf("-1\n");
       return 0;
      }
	for(i=2;i<=n;i++)
	  if(a[i]==a[i-1]+1)
	    p++;
	  else
	    p+=a[i];
	printf("%lld\n",p);
	return 0;
}


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

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(A < 10 && B < 10 ? A * B: -1);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    int bill = 700;
    
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'o') bill += 100;
    }
    
    cout << bill << endl;
}



Measured memory_bytes: 3560
// to be build tomorrow
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()
{
    ll t = 1;
    while (t--)
    {
        ll X, Y;
        cin >> X >> Y;
        ll p = 4*X - Y;
        ll ok = 1;
        if (p < 0 || p%2)
        {
            ok = 0;
        }
        ll e = p/2;
        if (X < e)
        {
            ok = 0;
        }
        if (ok)
        cout << "Yes";
        else 
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

int main(void) {
    cin >> n;
    vector<ll> aa(n, 0);
    rep (i, 0, n) cin >> aa[i];
    rep (i, 0, n) {
        if (aa[i] % 2 == 0) {
            if (aa[i] % 3 && aa[i] % 5) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}



Measured memory_bytes: 256