akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

const double PI = acos(-1.0);
const int N = 200005;
const int MOD = 1e9 + 7;
const int inf = 1<<28;
typedef long long ll;

double a[55];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
   	cin>>n;

   	for(int i = 0; i < n; i++)
   		cin>>a[i];

   	sort(a, a + n);

   	double x = (a[0] + a[1]) / 2;
   	for(int i = 2; i < n; i++)
   		x = (x + a[i]) / 2;
   	
   	cout<<fixed<<setprecision(8)<<x;

   	
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
using namespace std;

int main()
{
    char a[3]={0};
    cin >> a;
    
    if(a[0]=='9' || a[1]=='9')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 10" ].parse.expand.solve == "0.145833333" );
	assert( [ "100000 5" ].parse.expand.solve == "0.999973750" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	real ans = 0F;
	foreach( i; 1L .. n + 1 )
	{
		real r = 1F;
		for( auto s = i; s < k; s *= 2 ) r /= 2;
		ans += r / n;
	}
	return format( "%0.9f", ans );
}


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int n, t;
    cin >> n >> t;
    vector< P > ab(n);
    rep (i, n)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(), ab.end());

    int dp[n + 1][t + 1];
    rep (i, n + 1) rep (j, t + 1) dp[i][j] = 0;

    rep (i, n)
    {
        rep (j, t + 1)
        {
            if (j == t)
            {
                dp[i + 1][j] = MAX(dp[i][j], dp[i][j - 1] + ab[i].second);
            }
            else if (j < ab[i].first)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = MAX(dp[i][j], dp[i][j - ab[i].first] + ab[i].second);
            }
        }
    }

    cout << dp[n][t] << "\n";
    return 0;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int arr[N], L[N], R[N];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); 
	cout.tie(0);
	int n;
	cin >> n;
	multiset<int> st;
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		st.insert(num);
	}
	int ans = 0;
	while(!st.empty()){
		int x = *st.rbegin();
		st.erase(st.find(x));
		int num = 1;
		while(num <= x){
			num *= 2;
		}
		if(st.find(num - x) == st.end()){
			continue;
		}
		st.erase(st.find(num - x));
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 9600
N=int(input())
a_n=[int(x) for x in input().split()]
import sys

r=[]
r.append([i for i in a_n if 1<=i<=399])
r.append([i for i in a_n if 400<=i<=799])
r.append([i for i in a_n if 800<=i<=1199])
r.append([i for i in a_n if 1200<=i<=1599])
r.append([i for i in a_n if 1600<=i<=1999])
r.append([i for i in a_n if 2000<=i<=2399])
r.append([i for i in a_n if 2400<=i<=2799])
r.append([i for i in a_n if 2800<=i<=3199])
R=[i for i in a_n if 3200<=i]

count=0
for i in range(len(r)):
    if r[i]:
        count+=1
if count==0:
    count+=1
    print(str(count), str((count-1) + len(R)))
    sys.exit()

print(str(count), str(count+len(R)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a=0,b=0; cin>>n;
  vector<int> s(n); for(int i=0;i<n;i++) cin>>s[i];
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
    int e=s.size()-1;
    if(i%2==0) a+=s[e];
    else b+=s[e];
    s.pop_back();
  }
  cout<<a-b;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Graph {
	private int totalVertex;
	Queue<Integer> q1,q2;
	int[] distance;
	boolean[] visited;
	boolean[][] connected;
	
	Graph() {
		totalVertex = 0;
	}
	
	int getTotalVertex() {
		return totalVertex;
	}
	
	public void loadAdjList() {
		Scanner sc = new Scanner(System.in);
		totalVertex = sc.nextInt();
		distance=new int[totalVertex];
		visited=new boolean[totalVertex];
		connected=new boolean[totalVertex][totalVertex];
		q1=new LinkedList<Integer>();
		q2=new LinkedList<Integer>();
		
		q1.add(0);
		for(int i = 0; i < totalVertex; i++) {
			int u = sc.nextInt() - 1;
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int v=sc.nextInt() - 1;
				connected[u][v]=true;
			}
			distance[i] = -1;
		}
		sc.close();
	}
	
	public void BFS() {
		for(int i = 0; i < totalVertex; i++) {
			while(!q1.isEmpty()) {
				int node = q1.poll();
				if(visited[node] == true) {
					continue;
				}
				else {
					visited[node] = true;
					distance[node] = i;
				}
				for(int j = 0; j < totalVertex; j++) {
					if(connected[node][j] == true) {
						q2.add(j);
					}
				}
			}
			q1 = q2;
			q2 = new LinkedList<Integer>();
		}
	}
	
	public void print() {
		for(int i = 1; i <= totalVertex; i++) {
			System.out.println(i + " " + distance[i-1]);
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS();
		g.print();
	}
}


Measured memory_bytes: 28300
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using ll = long long;
using namespace std;


int main() {
    stack<int> c1;
    stack<pair<int, int>> c2;
    char c;
    int j;
    int sum = 0;
    for (int i = 0; cin >> c; i++){
        if (c == '\\') c1.push(i);
        else if (c == '/' && !c1.empty()) {
            j = c1.top(); c1.pop();
            sum += i - j;
            int a = i - j;
            while (!c2.empty() && c2.top().first > j){
                a += c2.top().second; c2.pop();
            }
            c2.push(make_pair(j, a));
        }
    }
    vector<int> ans;
    while (!c2.empty()) { ans.push_back(c2.top().second); c2.pop();}
    reverse(ans.begin(), ans.end());
    cout << sum << "\n";
    cout << ans.size();
    for (int an : ans) {
        cout << " ";
        cout << an;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int n;
    cin>>n;
    vector<string> s;
    rep(i,n){
        string t;
        cin>>t;
        s.push_back(t);
    }
    int ac=0,wa=0,tle=0,re=0;
    rep(i,n){
        if(s[i]=="AC"){
            ac++;
        }else if(s[i]=="WA"){
            wa++;
        }else if(s[i]=="TLE"){
            tle++;
        }else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

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

#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    int a;
    cin>> a;
    cout << a + a * a + a * a * a << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    //cin >> t;
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  vi x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  
  vi a(n);
  rep(i,n) a[i]=i;

  double sum=0;

  do{
    rep(i,n-1){
      sum+=sqrt(((x[a[i+1]])-x[a[i]])*(x[a[i+1]]-x[a[i]])+(y[a[i+1]]-y[a[i]])*(y[a[i+1]]-y[a[i]]));
    }
  }while(next_permutation(all(a)));
  FOR(i,1,n) sum/=i;
  cout<<setprecision(10)<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    while (1) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        string ans;
        int sum = m + f;
        if (m == -1 || f == -1) ans = 'F';
        else if (80 <= sum) ans = 'A';
        else if (65 <= sum) ans = 'B';
        else if (50 <= sum) ans = 'C';
        else if (30 <= sum) {
            if (50 <= r) ans = 'C';
            else ans = 'D';
        }
        else ans = 'F';
        cout << ans << endl;
    }
    return 0;
}



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

const int N = 2e5 + 10;

int n, a[N], m1, m2;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", a+i);
        if(i == 1){
            m1 = a[i];
        } else if(i == 2){
            m2 = a[i];
        } else {
            m2 = max(m2, a[i]);
        }
        if(m2 > m1) swap(m1, m2);
    }
    for(int i=1; i<=n; i++){
        printf("%d\n", a[i] == m1 ? m2 : m1);
    }
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
 
char s[555333];
long long br[555];
 
int main() {
   scanf("%s", s);
   int n = strlen(s);
   for(int i=0; i<n; i++) br[s[i]]++;
   long long res = 0;
   for(int i='a'; i<='z'; i++) res += br[i] * (n-br[i]);
   printf("%lld\n", res/2 + 1);
   return 0;
}

Measured memory_bytes: 384
function gcd(a,b)
    if b == 0 then
        return a
    else
        return gcd(b, a % b)
    end
end

function gcdmany(tbl)
    local ans = tbl[1]
    for i=2,#tbl do
        ans = gcd(ans, tbl[i])
    end
    return ans
end

local N, X = io.read("n", "n")
local x = {}
for i=1,N do
    x[i] = io.read("n")
end
table.insert(x, X)
table.sort(x)
local diffs = {}
for i=2,#x do
    table.insert(diffs, x[i] - x[i - 1])
end
local ans = gcdmany(diffs)
print(ans)


Measured memory_bytes: 4472
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]+a[2]*10;
}

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

int main()
{
	int n, m, sn, sm, sub;
	bool flag;
	while (cin >> n >> m, n || m) {
		vector<int> taro(n), hanako(m);
		sn = sm = 0;
		for (int i = 0; i < n; i++) {
			cin >> taro[i];
			sn += taro[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> hanako[i];
			sm += hanako[i];
		}
		sort(taro.begin(), taro.end());
		sort(hanako.begin(), hanako.end());
		if ((sn - sm) % 2) {
			cout << -1 << endl;
			continue;
		}
		sub = (sn - sm) / 2;
		flag = true;
		for (int i = 0; i < n; i++) {
			if (binary_search(hanako.begin(), hanako.end(), (taro[i] - sub))) {
				cout << taro[i] << " " << taro[i] - sub << endl;
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

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

vector<P> opt(n);
rep(i,n) {
  int a,b;cin >> a >> b;
  opt[i] = make_pair(a,b);
}
sort(opt.begin(),opt.end());

multiset<int> s;
int ind = 0;
int ans = 0;
for(int i = m-1;i >= 0;i--){
  while(opt[ind].first<=m-i && ind < opt.size()) {
    s.insert(opt[ind].second);
    ind++;
  }
  if(s.size()){
    ans += *(--s.end());
    //cout << ans << endl;
    s.erase(--s.end());
  }
}

cout << ans << endl;




}

Measured memory_bytes: 8712
import sys
n = int(input())
w = [input() for i in range(n)]
s = set(w)
if n != len(s):
    print("No")
    sys.exit()
else:
    for i in range(n-1):
        if w[i][-1] == w[i+1][0]:
            continue
        else:
            print("No")
            sys.exit()
    print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,n,p,r[100],b[100][100],c[100]={0};
  char s[40],d[100][40];
  while(scanf("%s %d",s,&p)!=EOF){
    for(i=0;i<n;i++){
      if(strcmp(d[i],s)==0)break;
    }
    j=0;
    if(i==n)strcpy(d[n++],s);
    else{
      for(j=c[i];j;j--){
	if(b[i][j-1]>p)b[i][j]=b[i][j-1];
	else break;
      }
    }
    b[i][j]=p;
    c[i]++;
  }
  for(i=0;i<n;i++){
    r[i]=i;
    for(j=i;j;j--){
      if(strcmp(d[r[j]],d[r[j-1]])<0){
	p=r[j];
	r[j]=r[j-1];
	r[j-1]=p;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%s\n",d[r[i]]);
    for(j=0;j<c[r[i]];j++){
      if(j)printf(" ");
      printf("%d",b[r[i]][j]);
    }
    printf("\n");
  }
  return 0;
}
	

Measured memory_bytes: 660
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int L;
		cin >> L;

		if(L==0)
			break;

		int M[12], N[12];
		for(int i=0; i<12; i++){
			cin >> M[i] >> N[i];
		}

		int sum = 0;
		int ans = -1;
		for(int i=0; i<12; i++){
			sum += (M[i]-N[i]);

			if(sum>=L){
				ans = i+1;
				break;
			}
		}

		if(ans!=-1){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long Int;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  Int n, k; cin >> n >> k;
  vector<Int> x(n); for(Int i = 0; i < n; i++) cin >> x[i];
  Int l, r;
  Int ansL, ansR;
  Int ans = 1000000000000000;
  for(int i = 0; i < n - k + 1; i++) {
    l = x[i], r = x[i+k-1];
    ansL = abs(l) + abs(r-l);
    ansR = abs(r) + abs(r-l);
    if(min(ansL, ansR) <= ans) {
      ans = min(ansL, ansR);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n];
	for (ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll l[n];
	ll r[n];
	l[0]=a[0];
	r[n-1]=a[n-1];
	for (ll i=1;i<n;i++)
		l[i]=__gcd(l[i-1],a[i]);
	for (ll i=n-2;i>=0;i--)
		r[i]=__gcd(r[i+1],a[i]);
	ll ma=1;
	for (ll i=0;i<n;i++)
	{
		if (i==0)
		{
			ma=max(ma,r[i+1]);
		}
		else if (i==n-1)
		{
			ma=max(ma,l[i-1]);
		}
		else
		{
			ma=max(ma,__gcd(l[i-1],r[i+1]));
		}
	}
	cout<<ma;


}



Measured memory_bytes: 2560
{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Control.Applicative ((<$>))
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS


main :: IO ()
main = do
  n <- read <$> getLine
  s <- VU.unfoldrN n BS.uncons <$> BS.getLine
  print $ VU.maximum
    $ VU.map (\ !gap -> min gap $ test s $ VU.drop gap s)
    $ VU.tail $ VU.generate n id

test :: VU.Vector Char -> VU.Vector Char -> Int
test v1 v2
 = VU.maximum
   $ VU.scanl' (\ !l !b -> if b then l+1 else 0) (0::Int)
   $ VU.zipWith (==) v1 v2


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int N;
int main(){
    cin>>N;int a[N];for(int i=0;i<N;i++)cin>>a[i];
    double sum;
    for(int i=0;i<N;i++){sum+=(1/(double(a[i])));}
    cout<<1/sum<<endl;
}


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

#define s second
#define f first

const long long maxn = 1e5 + 10;

long long n;
long long ans;
long long chiz[maxn];
long long f[2 * maxn];
pair<long long, long long> a[maxn];

void in();
void solve();
void out();
long long check(long long x);
void witex();
void add(long long x, long long v);
long long get(long long x);
long long getinv();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(long long i = 0; i < n; i++){
        cin >> a[i].f;
        a[i].s = i;
    }
}

void solve(){
    sort(a, a + n);
    long long r = n;
    long long l = 0;
    while(r - l > 1){
        long long mid = (l + r) >> 1;
        if(check(mid) <= (n * (n - 1) / 2 + n) / 2)
            l = mid;
        else
            r = mid;
    }
    ans = a[l].f;
}

void out(){
    cout << ans;
}

long long check(long long x){
    witex();
    long long sum = 0;
    for(long long i = 0; i < n; i++)
        chiz[i] = -1;
    for(long long i = 0; i < x; i++)
        chiz[a[i].s] = 1;
    sum += getinv();
    return sum;
}

void witex(){
    for(long long i = 1; i < 2 * maxn; i++)
        f[i] = 0;
}

void add(long long x, long long v){
    for(; x <= 2 * maxn; x += x & -x)
        f[x] += v;
}

long long get(long long x){
    long long ans = 0;
    for(; x > 0; x -= x & -x)
        ans += f[x];
    return ans;
}

long long getinv(){
    long long parsum = 0;
    add(maxn, 1);
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        parsum += chiz[i];
        ans += get(parsum + maxn - 1);
        add(parsum + maxn, 1);
    }
    return ans;
}


Measured memory_bytes: 4224
(let ((n (read))
      (city (make-array 0 :element-type 'integer
                          :adjustable t
                          :fill-pointer 0))
      (ans 0)
      temp temp2)
     (dotimes (i (1+ n))
       (vector-push-extend (read) city))
     (dotimes (i n)
       (setf temp (read))
       (setf temp2 (min temp (aref city i)))
       (incf ans temp2)
       (decf temp temp2)
       (setf temp2 (min temp (aref city (1+ i))))
       (incf ans temp2)
       (setf (aref city (1+ i)) (- (aref city (1+ i)) temp2)))
     (princ ans))

Measured memory_bytes: 59752
import sys
sys.setrecursionlimit(10**6)

def f(j):
  a[j]=1
  n=len(dic[j])
  for k in range(n):
    if a[dic[j][k]]==0:
      f(dic[j][k])

N, M=map(int, input().split())
dic={}
for i in range(1, N+1):
  dic[i]=[]

for i in range(M):
  x, y, z=map(int, input().split())
  dic[x].append(y)
  dic[y].append(x)
  
a=[0]*(N+1)
out=0
i=1
while i<N+1:
  if a[i]==0:
    a[i]=1
    out+=1
    n=len(dic[i])
    for j in range(n):
      if a[dic[i][j]]==0:
        f(dic[i][j])
  i+=1
print(out)

Measured memory_bytes: 117920
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 1e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    int n, w;
    cin >> n >> w;
    // int a[N];
    // for (int i=1; i <= n; i++) { 
    //     cin >> a[i];
    // }

    vector<ll> dp(N, 0);
    for (int i=1; i <= n; i++) {
        int weight, value;
        cin >> weight >> value;
        
        for (int j=w - weight; j >= 0; j--) {
            dp[j + weight] = max(dp[j+weight], dp[j] + value);
        }
    }
    
    cout << dp[w] << '\n';
}


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

int main(){
    int K,S,ans=0;
    cin>>K>>S;
    for(int i=0;i<=K;i++){
        for (int j=0;j<=K;j++){
            int Z=S-i-j;
            if(Z>=0&&Z<=K){
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io;
use std::collections::BTreeMap;


/// https://beta.atcoder.jp/contests/arc086/tasks/arc086_a
fn main() {
    let (_, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let an = read::<usize>();
    let mut bm = BTreeMap::new();
    for a in an {
        *bm.entry(a).or_insert(0) += 1;
    }

    let mut ans = 0;
    let mut cnt = 0;
    let mut bm = bm.iter().collect::<Vec<_>>();
    bm.sort_by_key(|&(_, v)| -v);
    for v in bm.iter().rev() {
        if bm.len() - cnt <= k { break; }
        cnt += 1;
        ans += *v.1;
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 14572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }
 
  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }
 
  mint ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	auto judge = [&](string t) {
		if ((int)t.size() % 2 != 0) return false;
		bool ok = true;
		for (int i = 0; i < (int)t.size() / 2; ++i) {
			if (t[i] != t[i + (int)t.size() / 2]) ok = false;
		}
		return ok;
	};
	for (int i = n - 2; i >= 1; --i) {
		if (judge(s.substr(0, i))) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
	auto _n = readln;
	string[] n = [];
	foreach (string l; lines(stdin)) n ~= l.chomp;
	foreach (_s; ["S", "H", "C", "D"])
		foreach (_i; 1..14) {
			auto t = "%s %d".format(_s, _i);
			if (!n.canFind(t)) t.writeln;
		}
}

Measured memory_bytes: 2440
#include <stdio.h>

int main(){
   int h, w;
   int i, j;
   while(1){
       scanf("%d %d ", &h, &w);
       if(h==0&&w==0)break;
       for(i=0;i<h;i++){
           for(j=0;j<w;j++){
               printf("#");
           }
           printf("\n");
       }
       printf("\n");
   }

   return 0;
}


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

int main(){
  string st, ans;
  ans = "";
  cin >> st;
  rep(i, st.size()){
    if(st.at(i) == 'A') ans += 'T';
    if(st.at(i) == 'T') ans += 'A';
    if(st.at(i) == 'C') ans += 'G';
    if(st.at(i) == 'G') ans += 'C';
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys


def solve_even(n, aaa, bbb):
    li = n // 2 - 1
    ri = n // 2
    aaa.sort()
    bbb.sort()
    ll = aaa[li]
    lr = aaa[ri]
    rl = bbb[li]
    rr = bbb[ri]
    return (rl + rr) - (lr + ll) + 1


def solve_odd(n, aaa, bbb):
    k = n // 2
    aaa.sort()
    bbb.sort()
    return bbb[k] - aaa[k] + 1


n, *ab = map(int, sys.stdin.buffer.read().split())
if n % 2 == 0:
    ans = solve_even(n, ab[0::2], ab[1::2])
else:
    ans = solve_odd(n, ab[0::2], ab[1::2])
print(ans)


Measured memory_bytes: 46828
def segfunc(x, y):
    return (x | y)


ide_ele = 0


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

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

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

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


n = int(input())
s = input()
q = int(input())

ls = []

for ch in s:
    ls.append(1 << (ord(ch) - 97))

seg = SegTree(ls, segfunc, ide_ele)

for i in range(q):
    que = input().split()
    if que[0] == '1':
        iq = int(que[1])
        cq = que[2]
        seg.update(iq-1, 1 << (ord(cq) - 97))
    else:
        lq = int(que[1])
        rq = int(que[2])
        ret = seg.query(lq-1, rq)
        print(str(bin(ret)).count('1'))


Measured memory_bytes: 48464
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  cout<<fixed<<setprecision(10);
  int sum=0;
  int N;
  cin >> N;
  vector<int> B(N-1);
  cin >> B[0];
  sum += 2*B[0];
  for(int i=1; i<N-1; ++i){
    cin >> B[i];
  	if(B[i-1] <= B[i]) sum += B[i];
    else {
      sum -= B[i-1];
      sum+= 2*B[i];
    }
  }
  cout << sum << endl;
}

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

using namespace std;

typedef struct {
	int c, s, f;
}Train;

const int N = 1000;
Train trains[N];

int main (){
	int n;

	scanf("%d", &n);
	
	for(int i = 0 ; i < n - 1 ; i++){
		scanf("%d%d%d", &trains[i].c, &trains[i].s, &trains[i].f);
	}

	for(int i = 0 ; i < n - 1 ; i++){
		int ac = trains[i].s + trains[i].c;

		for(int j = i + 1 ; j < n - 1 ; j++){
			ac = max(ac, trains[j].s);

			while(ac % trains[j].f != 0){
				ac++;
			}

			ac = ac + trains[j].c;
		}

		printf("%d\n", ac);
	}

	printf("0\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int n;cin>>n;
    vector<int> v(n);
    int sum=0;
    rep(i,n){
        cin>>v[i];
        sum+=v[i];
    }
    sum/=n;
    int ans=0;
    rep(i,n){
        ans+=(sum-v[i])*(sum-v[i]);
    }
    int ans1=0;
    sum++;
    rep(i,n){
        ans1+=(sum-v[i])*(sum-v[i]);
    }
    cout<<min(ans,ans1)<<endl;
    return 0;
}

Measured memory_bytes: 256
//arc092_c.cpp
//Fri Jul 26 21:28:51 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

struct edge {int to, cap, rev;};

vector<edge> G[300];
int level[300];
int iter[300];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
}

void bfs (int s){
	fill(level,level+300,-1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()){
		int v= que.front(); que.pop();
		for (int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to]<0){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if (v==t){
		return f;
	}
	for (int &i = iter[v]; i< G[v].size(); i++){
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to,t,min(f,e.cap));
			if (d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for (;;){
		bfs(s);
		if (level[t]<0){
			return flow;
		}
		fill(iter,iter+300,0);
		int f;
		while ((f=dfs(s,t,INTINF))>0){
			flow += f;
		}
	}
}

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

	vector<P> a;
	vector<P> b;

	for (int i=0;i<n;i++){
		int tempa,tempb;
		cin >> tempa >> tempb;
		a.push_back(make_pair(tempa,tempb));
	}

	for (int i=0;i<n;i++){
		int tempc,tempd;
		cin >> tempc >> tempd;
		b.push_back(make_pair(tempc,tempd));
	}

//	sort(a.begin(),a.end());
//	sort(b.begin(),b.end());

	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (a[i].first < b[j].first &&
				a[i].second < b[j].second){
				add_edge(i,j+n,1);
			}
		}
	}

	for (int i=0;i<n;i++){
		add_edge(2*n,i,1);
		add_edge(i+n,2*n+1,1);
	}


	cout << max_flow(2*n,2*n+1) << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 764
#coding: UTF-8
import math

def PR(a):
    for k in range(len(a)):
        area = ""
        H = int(a[k].split(" ")[0])
        W = int(a[k].split(" ")[1])
        if H == 0 and W == 0:
            break
        for j in range(H):
            for i in range(W):
                area += "#"
            print(area)
            area = ""
        print("")

if __name__=="__main__":
    a = []
    for i in range(300):
        a.append(input())
        if a[i] == "0 0":
            break
    PR(a)  

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

int main() {
    int N;
    cin >> N;
    int a[1000];
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    cout << a[0] - a[N-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

void dfs(int keta, stack<int> s){

}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int k, n;
    cin >> n >> k;
    int d[10] = {};
    for(int i = 0;i < k;i++){
        int x;
        cin >> x;
        d[x] = 1;
    }
    string str;
    int flag = 0;
    cout << endl;
    for(int i = n;i <= 10 * n; i++){
        flag = 0;
        str = to_string(i);
        for(int j = 0; j < str.length(); j++){
            if(d[str[j] - 48] == 1)flag = 1;
        }
        if(flag);
        else{
            cout << str << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int a, b, c, d;
  cin >>a >> b >> c >> d;
  if (a != c) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
ll data[3][3];
  rep(i,3) {
    rep(j,3) {
      cin >>data[i][j];
    }
  }
  
  ll N;
    cin >>N;
  vl b(N);
  rep(i,N) {
cin >>b.at(i);
  }
rep(i,N) {
  ll a=b.at(i);
  rep(k,3) {
    rep(m,3) {
      if(data[k][m]==a) {
        data[k][m]=0;
        break;
      }
    }
  }
  
}
  
  
 if( ((data[0][0]==0) &&(data[0][1]==0) &&(data[0][2]==0))
   ||   ((data[1][0]==0) &&(data[1][1]==0) &&(data[1][2]==0))
   ||   ((data[2][0]==0) &&(data[2][1]==0) &&(data[2][2]==0))
   || ((data[0][0]==0) &&(data[1][0]==0) &&(data[2][0]==0))
   ||  ((data[0][1]==0) &&(data[1][1]==0) &&(data[2][1]==0))
   ||    ((data[0][2]==0) &&(data[1][2]==0) &&(data[2][2]==0))
   ||  ((data[0][0]==0) &&(data[1][1]==0) &&(data[2][2]==0))
   ||    ((data[0][2]==0) &&(data[1][1]==0) &&(data[2][0]==0))  ) {
cout<<"Yes"<<endl;
 }
else {
cout<<"No"<<endl;
}
}
                      
                        


Measured memory_bytes: 256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

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

int main(){
    int N;
    cin>>N;
    vector<int> A(N),GCD_LEFT(N),GCD_RIGHT(N);
    REP(i,N){
        cin>>A[i];
    }
    //条件
    GCD_LEFT[0]=A[0];
    REPi(i,1,N){
        GCD_LEFT[i]=gcd(GCD_LEFT[i-1],A[i]);
    }
    GCD_RIGHT[N-1]=A[N-1];
    REPRi(i,N-2,-1){
        GCD_RIGHT[i]=gcd(GCD_RIGHT[i+1],A[i]);
    }
    int ans=1;
    REPi(i,1,N-1){
        int hoge=gcd(GCD_RIGHT[i+1],GCD_LEFT[i-1]);
        ans=max(ans,hoge);
    }
    ans=max(ans,max(GCD_RIGHT[1],GCD_LEFT[N-2]));
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
 
int main(void){
  char temp, str[1001], re[1001], p[101];
  int i, j, a, b, q;
 
  scanf("%s", str);
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf(" %s%d%d", p, &a, &b);
    if(strcmp(p, "print") == 0){
      for(j = a; j <= b; j++){
    printf("%c", str[j]);
      }
      printf("\n");
    }else if(strcmp(p, "reverse") == 0){
      for(j = 0; a+j < b-j; j++){
    temp = str[a+j];
    str[a+j] = str[b-j];
    str[b-j] = temp;
      }
    }else if(strcmp(p, "replace") == 0){
      scanf(" %s", re);
      for(j = 0; a+j <= b; j++){
    str[a+j] = re[j];
      }
    }
  }
  return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long

using namespace std;

int main()
{
    int x,t;
    while(scanf("%d%d",&x,&t)==2)
    {
        if(t>=x)
        {
            printf("%d\n",0);
        }
        else
        {
            printf("%d\n",x-t);
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
ans = 10 ** 7

for i in range(1, 101):#1から100で開催
  ans1 = 0
  for j in range(N):
    ans1 += (X[j] - i) ** 2
  ans = min(ans, ans1)
  
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i]; 
	} 
	int ans=0;
	for(int i=1;i<n-1;i++){
        if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1])){
        	ans++;
        }
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,dp[100010],num[100010];
vector <int> g[100010],dg[100010],topo;
bool vis[100010];

void dfs(int pos)
{
	if(vis[pos]) return;
	vis[pos]=true;
	rep(i,g[pos].size()) dfs(g[pos][i]);
	topo.pb(pos);
}

int main()
{
	rep(i,100005) dp[i]=1;
	cin>>n>>m;
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		dg[y].pb(x);
	}
	repn(i,n) if(!vis[i]) dfs(i);
	reverse(topo.begin(),topo.end());
	rep(i,topo.size()) num[topo[i]]=i;
	rep(i,topo.size())
	{
		rep(j,dg[topo[i]].size()) dp[i]=max(dp[i],dp[num[dg[topo[i]][j]]]+1);
	}
	int ans=0;
	rep(i,n) ans=max(ans,dp[i]);
	cout<<ans-1<<endl;
	rt0;
}

Measured memory_bytes: 13948
#include<cstdio>
#define MAXN 500000
struct node
{
	int key;
	node *fa;
	node *ch[2];
};
node tree[MAXN+5];
node *ncnt,*Root,*NIL;
void Init()
{
	NIL=&tree[0];
	ncnt=&tree[1];
	NIL->ch[0]=NIL->ch[1]=NIL->fa=NIL;
	Root=NIL;
}
inline node *NewNode(int val)
{
	node *p=++ncnt;
	p->ch[0]=NIL;
	p->ch[1]=NIL;
	p->key=val;
	return p;
}
void Insert(node *&rt,node *fa,int val)
{
	if(rt==NIL)
	{
		node *p=NewNode(val);
		p->fa=fa;
		rt=p;
		return;
	}
	int d=(val>=rt->key);
	Insert(rt->ch[d],rt,val);
}
void InOrder(node *rt)
{
	if(rt==NIL)
		return;
	printf(" %d",rt->key);
	InOrder(rt->ch[0]);
	InOrder(rt->ch[1]);
}
void PreOrder(node *rt)
{
	if(rt==NIL)
		return;
	PreOrder(rt->ch[0]);
	printf(" %d",rt->key);
	PreOrder(rt->ch[1]);
}
node *Find(node *rt,int val)
{
	if(rt==NIL)
		return NIL;
	if(rt->key==val)
		return rt;
	int d=(val>=rt->key);
	return Find(rt->ch[d],val);
}
node *FindNext(node *rt)
{
	node *y=rt->ch[1];
	while(y->ch[0]!=NIL)
		y=y->ch[0];
	return y;
}
void Delete(node *rt,int val)
{
	if(rt==NIL)
		return;
	node *x,*y,*z=Find(Root,val);
	if(z->ch[0]==NIL||z->ch[1]==NIL)
		y=z;
	else
		y=FindNext(z);
	
	if(y->ch[0]!=NIL)
		x=y->ch[0];
	else
		x=y->ch[1];
	
	if(x!=NIL)
		x->fa=y->fa;
	
	if(y==y->fa->ch[0])
		y->fa->ch[0]=x;
	else if(y==y->fa->ch[1])
		y->fa->ch[1]=x;
	
	if(y!=z)
		z->key=y->key;
}
int main()
{
	Init();
	int n,x;
	char a[15];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",a);
		if(a[0]=='i')
		{
			scanf("%d",&x);
			Insert(Root,NIL,x);
		}
		else if(a[0]=='p')
		{
			PreOrder(Root);
			printf("\n");
			InOrder(Root);
			printf("\n");
		}
		else if(a[0]=='f')
		{
			scanf("%d",&x);
			if(Find(Root,x)!=NIL)
				printf("yes\n");
			else
				printf("no\n");
		}
		else if(a[0]=='d')
		{
			scanf("%d",&x);
			Delete(Root,x);
		}
	}
	return 0;
}

Measured memory_bytes: 15092
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 3002;

int n;
long long f[maxn][maxn], sum[maxn];

int main() {

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

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int d;
        cin >> d;
        sum[i] = sum[i-1] + d;
    }

    for (int j = 1; j <= n; ++j) {
        f[j][j] = sum[j] - sum[j-1];

        for (int i = j-1; i > 0; --i)
            f[i][j] = sum[j] - sum[i-1] - min(f[i+1][j], f[i][j-1]);
    }
	
    cout << 2 * f[1][n] - sum[n] << endl;

	return 0;
}

Measured memory_bytes: 70016