akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

int main(void){
	string a;
	cin >> a;
	int n=a.size();
	int ans=0;
	int mid=n/2;
	if(n%2)
		if(!islower(a[mid]))
			ans++;
	rep(i,mid){
		if(islower(a[i])){
			if(a[i]==a[n-1-i])
				continue;
			ans++;
		}else{
			if(a[i]=='('&&a[n-1-i]==')')
				continue;
			if(a[i]==')'&&a[n-1-i]=='(')
				continue;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>

int main(void) {

	int W, a, b;
	std::cin >> W >> a >> b;

	if (b < a) {
		std::swap(a, b);
	}

	int result = b - (a + W);
	if (result < 0) {
		result = 0;
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>


using namespace std;


#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS) //?????????????????????????????????


//??????????????????????????????
class Point {

public:

	double x, y;//??§?¨????????????????x,y??????

	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}

	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}

	Point operator * (double r) {
		return Point(x * r, y * r);
	}

	Point operator / (double r) {
		return Point(x / r, y / r);
	}

	double norm() {
		return x*x + y*y;
	}

	//?????????????????§???????????????
	double abs() {
		return sqrt(norm());
	}

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS &&  fabs(y - p.y) < EPS;
	}

};

typedef Point Vector;

//??????????????????????????????
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

//??????????????????????????????
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

//?????????????????´?????????
bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

class Segment {
public:
	Point p1, p2;

	Segment(){}

	//?????¨????°???±?????????
	Point projection(Point p) {
		Vector base = p2 - p1;

		double r = dot(p - p1, base) / base.norm();
		return p1 + base * r;
	}

};

//??????????§??????¨?????????????????´?????????
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

//???????????´?????????
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//???????????????????????????
bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

//??????????§??????¨???????????????????????????
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

//?????????????????????
bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//?°???±?????????
Point projection(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base * r;
}

typedef Segment Line;

typedef vector<Point> Polygon;



//???
class Circle {
public:
	Point c;//??????
	double r;//??????
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};


int main(void)
{
	int n;

	Segment s;
	Point p;
	Point proj;

	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> p.x >> p.y;
		proj = projection(s, p);
		printf("%.9lf %.9lf\n",proj.x,proj.y);
	}

	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, ans = 0;
	while (cin >> N) {
		REP(a, 10) REP(b, 10) REP(c, 10) REP(d, 10) if (a + b + c + d == N) ans++;
		cout << ans << "\n";
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long n;
    long long count_mul_4 = 0;
    long long count_odd = 0;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        count_odd += temp % 2;
        if(temp % 4 == 0)
            count_mul_4++;
    }
    
    if(n == 1 || count_odd == 0)
        cout << "Yes" << endl;
    else if(n == count_odd + count_mul_4 && count_odd - count_mul_4 <= 1)
        cout << "Yes" << endl;
    else if(count_mul_4 >= count_odd)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect
import functools

MOD = 998244353


def factorial(n, mod=None, memo=False):
    if memo:
        factorial.memo = [1] * (n + 1)
        #print('factorial.memo') # debug
        #print(factorial.memo) # debug
        for i in range(1, n + 1):
            #print('i') # debug
            #print(i) # debug
            if mod is None:
                factorial.memo[i] = i * factorial.memo[i - 1]
            else:
                factorial.memo[i] = i * factorial.memo[i - 1] % mod
            #print('factorial.memo[i]') # debug
            #print(factorial.memo[i]) # debug
    return factorial.memo[n]

def choose(n, r, mod=None):
    a = factorial(n)
    b = factorial(r)
    c = factorial(n - r)
    if mod is None:
        res = a // b // c
    else:
        # fermat's little theorem
        res = a * pow(b, mod - 2, mod) * pow(c, mod - 2, mod) % mod
    return res

def calc(n, m, k):
    res = choose(n - 1, k, MOD) * m * pow(m - 1, n - 1 - k, MOD) % MOD
    #print('res') # debug
    #print(res) # debug
    return res

# in the case k pair is same, pattern is (n-1)Choose(k) * m (m - 1) ** (n - 1 - k)
if __name__ == '__main__':
    n, m, k = list(map(int, input().split()))
    ans = 0
    factorial(n, MOD, True)
    for kk in range(k + 1):
        ans += calc(n, m, kk)
    #print('ans') # debug
    print(ans % MOD)

    #print('\33[32m' + 'end' + '\033[0m') # debug



Measured memory_bytes: 79768
def solve():
  n, l = map(int,input().split())
  ans = 0
  pre = 0
  prepre = 0
  acc = 0
  for i in range(n):
    length = int(input())
    time = l - length
    if length > pre and pre >= prepre:
      acc += time
    elif length < pre and pre <= prepre:
      acc += time
    else:
      if ans < acc:
        ans = acc
      acc = time + (l - pre)
    prepre = pre
    pre = length
  else:
    ans = max(ans, acc)
  print(ans)
solve()


Measured memory_bytes: 5620
# import sys
# input = sys.stdin.readline
# import re
import collections

def main():
    n = int(input())
    s = input()
    sc = collections.Counter(s)
    # 半分ずつの場合
    if sc['W'] == sc['R']:
        # 右側のRをカウント
        print(s[n//2:].count('R'))
        exit()
    print(s[:sc['R']].count('W'))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == '__main__':
    main()



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

using namespace std;

const int N = 105, K = 1e5 + 5, MOD = 1e9 + 7;
int n, p, dp[N][K], prefix[N][K], a[N];

inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}

inline int sub(int a, int b){
	a -= b;
	if(a < 0)a += MOD;
	return a;
}

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

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

	for(int i=0;i<=n;++i)dp[i][0] = prefix[i][0] = 1;
	for(int j=0;j<=p;++j)prefix[0][j] = 1;

	for(int i=1;i<=n;++i)
		for(int j=1;j<=p;++j){
			// coefficient of x^j is prefix[i - 1][j - a[i] : j];

			int first = (j - a[i] - 1 >= 0)? prefix[i - 1][j - a[i] - 1] : 0;
			int last = prefix[i - 1][j];
			dp[i][j] = add(dp[i][j], sub(last, first));
			prefix[i][j] = add(prefix[i][j - 1], dp[i][j]);
		}

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

Measured memory_bytes: 82176
using System;
using System.Text.RegularExpressions;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal num = Convert.ToDecimal(Console.ReadLine());
            num -= 1;
            Console.WriteLine(num  * (num + 1) / 2);
        }
    }
}


Measured memory_bytes: 13268
N=int(input())
S=input()
RS=S[::-1]

west=[0]
east=[0]

for i in range(N):
  if S[i]=="W":
    west.append(west[-1]+1)
  else:
    west.append(west[-1])
west.append(0)

for i in range(N):
  if RS[i]=="E":
    east.append(east[-1]+1)
  else:
    east.append(east[-1])
east.append(0)
east=east[::-1]

ans=10**9
for i in range(1,N+1):
  ans=min(ans,west[i-1]+east[i+1])

print(ans)


Measured memory_bytes: 116112
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'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'};
//cout<<""<<endl;
int main(){
  int X,t;cin>>X>>t;cout<<max(X-t,0)<<endl;
  
}







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

int main() {
	int N; cin >> N;
	int a[100010], p[100010];
	for(int i=1; i<=N; ++i){
	    cin >> a[i];
	    p[i]=1;
	}
	int light=1, ans=0;
	while(light!=2 && p[light]){
	    --p[light];
	    light=a[light];
	    ++ans;
	}
	if(light==2) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    ll n,z,w;
    cin>>n>>z>>w;
    ll a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    ll ans = abs(w - a[n-1]);
    for(int i=0;i<n;i++){
        a[i] = abs(a[i] - a[n-1]);
    }
    ll now = ans;
    ll cnt = 0;
    ll p = 0;
    for(int i=0;i<n-1;){
        p = -1;
        for(int j=i;j<n-1;j++){
            if(cnt%2 == 0){
                if(chmax(now,a[j])){
                    p = j;
                }
            }
            else{
                if(chmin(now,a[j])){
                    p = j;
                }
            }
        }
        if(p == -1) break;
        i = p;
        cnt++;
    }
    chmax(ans,now);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    ll n,i,ans=0,m,a,b,c,j;
    cin>>n>>m;
    vector<vector<ll>> v(8,vector<ll> (n,0));
    ll maxans=0;
    rep(i,n){
        cin>>a>>b>>c;
        v[0][i]=a+b+c;
        v[1][i]=a+b-c;
        v[2][i]=a-b+c;
        v[3][i]=a-b-c;
        v[4][i]=-1*a+b+c;
        v[5][i]=-1*a+b-c;
        v[6][i]=-1*a-b+c;
        v[7][i]=-1*a-b-c;
    }
    for(j=0;j<8;j++){
        ans=0;
        sort(v[j].rbegin(),v[j].rend());
        
        rep(i,m){
            ans+=v[j][i];
        }
        maxans=max(ans,maxans);
    }
    
    cout<<maxans<<endl;
    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  if ( D == 25 ) cout << "Christmas" << endl;
   else if ( D == 24 ) cout << "Christmas Eve" << endl;
    else if ( D == 23 ) cout << "Christmas Eve Eve" << endl;
     else if ( D == 22 ) cout << "Christmas Eve Eve Eve" << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
  {
   for( int i=2;i<=sqrt(n);++i)
   {
     if(n%i==0)
       return false;
   }
  return true;
  }

int main(){
 int x;
  cin>>x;
  while(!isPrime(x)) x++;
  cout<<x<<endl;
  
 return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    N, M = map(int, input().split())

    G = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    dist = [-1] * N
    que = deque([0])
    dist[0] = 0
    parent = [-1] * N
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            parent[w] = v
            que.append(w)

    ans = [x + 1 for x in parent[1:]]

    print('Yes')
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 40092
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int h[]=new int[N];
		boolean done[]=new boolean[N];
		
		
		h[0]=sc.nextInt();
		done[0]=false;
		boolean x=true;
		for(int i=1;i<N;i++) {
			int t=i;
			h[i]=sc.nextInt();
			done[i]=false;
			while(t>=1&&h[t-1]>h[t]) {
				if(!done[t-1])h[t-1]--;
				done[t-1]=true;
				if(h[t-1]>h[t]) {
				x=false;
				break;
				}
				t--;
			}
			
			
			
		}
		if(x)p("Yes");
		else p("No");
		//System.out.println(cc);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 50312
#include <stdio.h>

int main(void) {
	int w, n, i, ex;
	int L, R;
	int ary[30];
	scanf("%d", &w);
	scanf("%d", &n);
	
	for(i=0;i<=w;i++){
	ary[i] = i+1;
	}
	
	for(i=0;i<n;i++){
		scanf("%d,%d", &L, &R);
		ex = ary[L-1];
		ary[L-1] = ary[R-1];
		ary[R-1] = ex;
		
	}
	
	for(i=0;i<w;i++){
		printf("%d\n",ary[i]);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
using namespace std;
const int N=110000;
char str[N];
int n;
int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	int ans=0;
	rep(i,1,n-1)if(str[i]!=str[i+1])ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using UL=unsigned int;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

int main(){
 UL X[2][4]; rep(i,2)rep(j,4) cin>>X[i][j];
 UL ans=0;
 rep(i,2) ans+=(X[i][2]*X[i][3]);
 rep(i,2)rep(j,2) X[i][j+2]+=X[i][j];
 UL W,H; W=H=0;
 if(min(X[0][2],X[1][2])>max(X[0][0],X[1][0]))
  W=min(X[0][2],X[1][2])-max(X[0][0],X[1][0]);
 if(min(X[0][3],X[1][3])>max(X[0][1],X[1][1]))
  H=min(X[0][3],X[1][3])-max(X[0][1],X[1][1]);
 ans-=W*H*2;
 cout<<ans<<endl;
 return 0;
}



Measured memory_bytes: 3084
let n, m, x = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let a_s = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let l, r = ref 0, ref 0
let _ =
  for i = 0 to m - 1 do if a_s.(i) < x then incr l else incr r done;
  min !l !r |> Printf.printf "%d\n"

Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        Array.Sort(A, (a, b) => b - a);
        int L = Enu.Range(0, N).First(i => i + 1 == N || A[i + 1] <= i + 1);
        int R = Enu.Range(L + 1, N).First(i => i == N || A[i] <= L);
        bool win = (A[L] - L) % 2 == 0 || (R - L) % 2 == 0;
        Console.WriteLine(win ? "First" : "Second");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 17616
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
// #if LOCAL == 1
//     std::ifstream in("input.txt");
//     std::cin.rdbuf(in.rdbuf());
// #endif
  ll N = input();
  ll M = input();

  debug(M);
 
  string reslt = N<=M ? "Yes" : "No";
  output(reslt);
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int ara[100000];
int main()
{
    int i,j;
    int n,k,s;
    cin>>n>>k>>s;
    if(k==n){
        for(i=0;i<n;i++)
            ara[i]=s;
    }
    else if(k==0){
        for(i=0;i<n;i++)
            ara[i]=232313243;
    }
    else if(s==1){
        for(i=0;i<k;i++)
            ara[i]=1;
        while(i<n)
            ara[i++]=1e9;
    }
    else if(s<1e9){
        ara[0]=1;
        for(i=1;i<=k;i++){
            if(i&1)
                ara[i]=s-1;
            else
                ara[i]=1;
        }
        while(i<n)
            ara[i++]=1e9;
    }
    else {
        ara[0]=1;
        for(i=1;i<=k;i++){
            if(i&1)
                ara[i]=s-1;
            else
                ara[i]=1;
        }
        while(i<n)
            ara[i++]=2;
    }
    for(i=0;i<n;i++)
        cout<<ara[i]<<" ";
}


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

const string YES = "Yes";
const string NO = "No";

int main()
{
  int N;
  vector<pair<int, int>> D;

  cin >> N;
  D.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> D[i].first >> D[i].second;
  }

  int continuous_number = 0;
  int max_continuous_number = 0;
  for (auto &&i : D) {
    if (i.first == i.second) {
      continuous_number++;
    }
    else {
      continuous_number = 0;
    }
    max_continuous_number = max(max_continuous_number, continuous_number);
  }

  if (max_continuous_number >= 3) {
    cout << YES << endl;
  }
  else {
    cout << NO << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ld long double

int main () {
  int n;
  cin >> n;
  ld p[n + 1], dp[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    for (int j = 0; j <= n; j++) {
      dp[i][j] = 0.0;
      dp[0][j] = 0.0;
    } 
    dp[0][0] = 1.0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      // j回数出る
      dp[i][j] = dp[i - 1][j] * (1 - p[i]);
      if (j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
    }
  }
  ld ans = 0;
  int j = n / 2 + 1;
  for (int i = 0; i <= n; i++) {
    if (i >= j) ans += dp[n][i];  
  }
  cout << setprecision(12) << fixed << ans << endl;
}


Measured memory_bytes: 140928
#pragma GCC optimize("Ofast")

#include<cstdio>

int main(){
  int N;
  scanf("%d", &N);
  int in;
  int m_in = 200000;
  int cn = 0;
  for(;N-->0;){
    scanf("%d", &in);
    if(m_in >= in){
      cn++;
      m_in = in;
    }
  }
  
  printf("%d\n", cn);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

pair<int, int> p[N];
pair<ll, int> pos_pos[N], pos_neg[N], neg_pos[N], neg_neg[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
        pos_pos[i] = {x + y, i};
        pos_neg[i] = {x - y, i};
        neg_pos[i] = {-x + y, i};
        neg_neg[i] = {-x -y, i};
    }
    sort(pos_pos, pos_pos + n);
    sort(pos_neg, pos_neg + n);
    sort(neg_pos, neg_pos + n);
    sort(neg_neg, neg_neg + n);

    int i = n - 1;

    if(neg_neg[n - 1].second == pos_pos[i].second) {
        ans = max(ans, neg_neg[n - 2].first + pos_pos[i].first);
    }
    else ans = max(ans, neg_neg[n - 1].first + pos_pos[i].first);

    if(neg_pos[n - 1].second == pos_neg[i].second) {
        ans = max(ans, neg_pos[n - 2].first + pos_neg[i].first);
    }
    else ans = max(ans, neg_pos[n - 1].first + pos_neg[i].first);

    if(pos_pos[n - 1].second == neg_neg[i].first)
        ans = max(ans, pos_pos[n- 2].first + neg_neg[i].first);

    else ans = max(ans, pos_pos[n - 1].first + neg_neg[i].first);

    if(pos_neg[n - 1].second == neg_pos[i].second) {
        ans = max(ans, pos_neg[n - 2].first + neg_pos[i].first);
    }
    else ans = max(ans, pos_neg[n - 1].first + neg_pos[i].first);
    cout << ans;

    return 0;
}


Measured memory_bytes: 17660
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
int main(){
    int n,m,sum,cnt;
    for(;;){
        cnt=0;
        cin>>n;
        if(n==0)
            return 0;
        for(int i=1; i<=n/2; i++){
            for(m=i+1,sum=i;sum<n; sum+=m++);
            if(sum==n)
                cnt++;
            }
            cout<<cnt<<endl;
       }
    return 0;
}


Measured memory_bytes: 2984
import copy
n = int(input())
a_list = [ int(input()) for _ in range(n)]
max_val = max(a_list)
index = [a_list.index(max_val)]
tmp_list = copy.copy(a_list)
for i, a in enumerate(a_list):
  if 2 <= len(index):
    print(max_val)
  elif i in index:
    tmp_list.pop(i)
    print(max(tmp_list))
    tmp_list = copy.copy(a_list)
  else:
    print(max_val)
    
  

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

char num[200001];

signed main(){

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

    int sum=0;

    cin>>num;
    for(int i=0;num[i]!='\0';i++){
        sum+=num[i]-'0';
    }

    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3844
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceSP(const L &s, const P &p) {
    if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
    if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
    return distanceLP(s, p);
}

int main(){
    int n,m,sx,sy;
    cin >> n >> m >> sx >> sy;
    VP p(n+1);
    p[0] = P(sx, sy);
    for(int i=1; i<n+1; i++){
        int x,y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    vector<double> dist(n+1, INF);
    for(int i=1; i<=n; i++){
        dist[i] = abs(p[i] -p[0]);
    }
    double ans = 0;
    for(int rep=0; rep<m; rep++){
        double minval = INF;
        int newidx = -1;
        for(int i=0; i<n+1; i++){
            if(dist[i] +EPS < minval){
                minval = dist[i];
                newidx = i;
            }
        }
        int nearidx = -1;
        minval = INF;
        for(int i=0; i<n+1; i++){
            if(dist[i] == INF and abs(p[newidx]-p[i]) +EPS < minval){
                nearidx = i;
                minval = abs(p[newidx]-p[i]);
            }
        }
        ans += abs(p[newidx] -p[nearidx]);
        dist[newidx] = INF;
        for(int i=0; i<n+1; i++){
            if(dist[i] == INF) continue;
            dist[i] = min(dist[i], distanceSP(L(p[newidx], p[nearidx]), p[i]));
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H, W;
        cin >> H >> W;
        vector<vector<char> > a(H+2, vector<char>(W+2, '#'));
        rep(i, 1, H+1) rep(j, 1, W+1) cin >> a[i][j];
        rep(i, 0, H+2) {
                rep(j, 0, W+2) {
                        if (j != W+1) cout << a[i][j];
                        else cout << a[i][j] << endl;
                }
        }
}

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

using namespace std;

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

class state{
public :
	char t;
	int w,l,id;
	bool operator<(const state & a)const{
		if (w!=a.w) return w > a.w;
		if (l!=a.l) return l < a.l;
		return id<a.id;
	}	
};

main(){
	int n;
	while(cin>>n,n){
		state data[n];
		rep(i,n){
			cin>>data[i].t;
			data[i].id=i;
			data[i].w =0;
			data[i].l =0;
			rep(j,n-1){
				int tmp;
				cin>>tmp;
				if(tmp==0)data[i].w++;
				else if(tmp==1)data[i].l++;
			}
		}
		sort(data,data+n);
		rep(i,n)cout<<data[i].t<<endl;
	}
}

Measured memory_bytes: 1172
#include <vector>
#include <iostream>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <limits>
#include <queue>

using namespace std;

// usage:
// MaxFlowDinic::Init(n);
// MaxFlowDinic::AddEdge(0, 1, 100, 100); // for bidirectional edge
// MaxFlowDinic::AddEdge(1, 2, 100); // directional edge
// result = MaxFlowDinic::Solve(0, 2); // source -> sink
// graph[i][edgeIndex].res -> residual
//
// in order to find out the minimum cut, use `l'.
// if l[i] == 0, i is unrechable.

struct MaxFlowDinic
{
	typedef int flow_t;

	struct Edge
	{
		int next;
		int inv; /* inverse edge index */
		flow_t res; /* residual */
		Edge(int q, int w, flow_t e) {
			next = q;
			inv = w;
			res = e;
		}
	};

	int n;
	vector<vector<Edge>> graph;

	vector<int> q, l, start;

	void Init(int _n) {
		n = _n;
		graph.resize(n);
		for (int i = 0; i < n; i++) graph[i].clear();
	}
	void AddNodes(int count) {
		n += count;
		graph.resize(n);
	}
	void AddEdge(int s, int e, flow_t cap, flow_t caprev = 0) {
		Edge forward = Edge(e, graph[e].size() + ((s == e) ? 1 : 0), cap);
		Edge reverse = Edge(s, graph[s].size(), caprev);
		graph[s].push_back(forward);
		graph[e].push_back(reverse);
	}

	bool AssignLevel(int source, int sink) {
		int t = 0;
		memset(&l[0], 0, sizeof(l[0]) * l.size());
		l[source] = 1;
		q[t++] = source;
		for (int h = 0; h < t && !l[sink]; h++) {
			int cur = q[h];
			for (int i = 0; i < graph[cur].size(); i++) {
				int next = graph[cur][i].next;
				if (l[next]) continue;
				if (graph[cur][i].res > 0) {
					l[next] = l[cur] + 1;
					q[t++] = next;
				}
			}
		}
		return l[sink] != 0;
	}

	flow_t BlockFlow(int cur, int sink, flow_t currentFlow) {
		if (cur == sink) return currentFlow;
		for (int &i = start[cur]; i < graph[cur].size(); i++) {
			int next = graph[cur][i].next;
			if (graph[cur][i].res == 0 || l[next] != l[cur] + 1)
				continue;
			if (flow_t res = BlockFlow(next, sink, min(graph[cur][i].res, currentFlow))) {
				int inv = graph[cur][i].inv;
				graph[cur][i].res -= res;
				graph[next][inv].res += res;
				return res;
			}
		}
		return 0;
	}

	flow_t Solve(int source, int sink)
	{
		q.resize(n);
		l.resize(n);
		start.resize(n);
		flow_t ans = 0;
		while (AssignLevel(source, sink)) {
			memset(&start[0], 0, sizeof(start[0])*n);
			while (flow_t flow = BlockFlow(source, sink, numeric_limits<flow_t>::max())) {
				ans += flow;
			}
		}
		return ans;
	}
};

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

	for (;;) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) break;
		MaxFlowDinic mf;
		mf.Init(n + m + 2);
		for (int i = 1; i <= m; i++) {
			int x, y; cin >> x >> y;
			mf.AddEdge(x, i + n, 1);
			mf.AddEdge(y, i + n, 1);
			mf.AddEdge(i + n, n + m + 1, 1);
		}

		int mn = 0, mx = 0;
		int fin = 0;
		bool flag = true;

		for (int i = 1; i < n; i++) {
			for (int j = 1; j <= n; j++)
				mf.AddEdge(0, j, 1);
			int ret = mf.Solve(0, n + m + 1);
			fin += ret;
			if (ret == n && flag) mn = i;
			else flag = false;
			if (fin == m) {
				mx = i;
				break;
			}
		}

		cout << mn << " " << mx << "\n";
	}
	return 0;
}


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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long N, long long L, std::vector<std::string> S){
    sort(S.begin(), S.end());
    rep(i, N) {
        cout << S[i];
    }
    cout << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

// お借りしました
// keita-matsushita.hatenablog.com/entry/2016/12/30/235259
class SegmentTree {
    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

	int N;
	int[] originalData;
	int[] tree;

	int INT_MAX = Integer.MAX_VALUE / 2;

	SegmentTree(int[] original) {
		this.originalData = Arrays.copyOf(original, original.length);
		int n = originalData.length;
		this.N = 1;
		while (N < n) N *= 2;
		this.tree = new int[N*2];
		for (int i = 0; i < N*2; i++) {
			tree[i] = INT_MAX;
		}
		build();
	}

	// O(N)
	void build() {
		for (int i = 0; i < originalData.length; i++) {
			update(i, originalData[i]);
		}
	}

	//i番目の値をxに更新 O(log N)
	void update(int i, int x) {
		i = N + i - 1;
		tree[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			tree[i] = marge(tree[i * 2 + 1], tree[i * 2 + 2]);
		}
	}

	//O(log N);
	int query(int start, int end) {
		return query(start, end, 0, 0, N);
	}

	//[a, b)の最小値、l, rにはノードkに対応する区間を与える
	private int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)
			return INT_MAX;

		if (a <= l && r <= b) {
            return tree[k];
		} else {
			int lv = query(a, b, 2*k+1, l, (l+r)/2);
			int rb = query(a, b, 2*k+2, (l+r)/2, r);
			return marge(lv, rb);
		}
	}

	private int marge(int l, int r) {
        if(l==INT_MAX||r==INT_MAX) return Math.min(l,r);
		return gcd(l, r);
	}

}

public class Main {
	static Scanner sc = new Scanner(System.in);
    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	public static void main(String[] args) {

		int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        SegmentTree st = new SegmentTree(a);
        int ans=-1;
        for(int i=0;i<n;i++){
            int gcd1=-1;
            int gcd2=-1;
            // gcd1=st.query(1,2);
            // out.println(gcd1);
            if(0<i) gcd1=st.query(0,i);
            if(i<n-1) gcd2=st.query(i+1,n);
            // out.println(gcd1);
            // out.println(gcd2);
            if(gcd1>0&&gcd2>0){
                ans=Math.max(ans,gcd(gcd1,gcd2));
            }else{
                ans=Math.max(ans,Math.max(gcd1,gcd2));
            }
        }
		out.println(ans);
	}
}

// int n = sc.nextInt();
// int[] array = new int[n];
// String s = sc.next();
// s.charAt(i)
// out.println();
// Math.min()


Measured memory_bytes: 49788
import bisect

N = int(input())
tops = sorted(tuple(map(int, input().split(' '))))
middles = sorted(tuple(map(int, input().split(' '))))
bottoms = sorted(tuple(map(int, input().split(' '))))

s = 0

for middle in middles:
    n_tops = bisect.bisect_left(tops, middle)
    n_bottoms = len(bottoms) - bisect.bisect_right(bottoms, middle)
    s += n_tops * n_bottoms

print(s)


Measured memory_bytes: 23220
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


vector<int> solve(vector<int> s_t, vector<int> s_h, int sum_t, int sum_h, int m, int n) {
    for (int i=0; i<m; i++) {
      for (int j=0; j<n; j++) {
        if (2 * (s_t[i] - s_h[j]) == sum_t - sum_h) {
          vector<int> res = {s_t[i], s_h[j]};
          return res;
        }
      }
    }
  return {0, 0};
}


void show_vector(vector<int> v) {
  for (int i=0; i<v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}


int main() {
  int n, m;

  while (cin >> m >> n && m && n) {
    int sum_t = 0;
    int sum_h = 0;
    int next_t_i = n;
    int next_h_i = m;

    vector<int> s_t(m);
    vector<int> s_h(n);

    for (int i=0; i<m; i++) {
      cin >> s_t[i];
      sum_t += s_t[i];
    }

    for (int i=0; i<n; i++) {
      cin >> s_h[i];
      sum_h += s_h[i];
    }

    // show_vector(s_t);
    // show_vector(s_h);

    vector<int> res = solve(s_t, s_h, sum_t, sum_h, m, n);
    if (res[0] && res[1]) {
      cout << res[0] << " " << res[1] << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 3120
n,d=map(int,input().split())
x=[]
for _ in range(n):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(x[i][k]-x[j][k])**2
    dist=dist**0.5
    if dist.is_integer():
      ans+=1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }

    for(int i = 1;i < n - 1;i++){
        if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])){
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
class UnionFind
  attr :parent

  def initialize(nodes)
    @parent = {}
    nodes.each do |node|
      parent[node] = -1
    end
  end

  def root(x)
    if parent[x] < 0
      x
    else
      parent[x] = root(parent[x])
    end
  end

  def size(x)
    return -parent[root(x)]
  end

  def unite(x, y)
    rx = root(x)
    ry = root(y)
    if rx == ry
      return false
    else
      if size(rx) < size(ry)
        rx, ry = ry, rx
      end

      parent[rx] += parent[ry]
      parent[ry] = rx

      return true
    end
  end
end

n,m = gets.split.map(&:to_i)
uf = UnionFind.new((1..n).to_a)

m.times do
  a, b = gets.split.map(&:to_i)
  uf.unite(a, b)
end

ans = -1
(1..n).each do |i|
  ans = [ans, uf.size(i)].max
end

puts ans

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int res1,res2,res3;
    res1 = a*x+b*y;
    int mi = min(x,y);
    res2 = c*2*mi+(x-mi)*a+(y-mi)*b;
    int ma = max(x,y);
    res3 = c*2*ma;
    cout << min(res1,min(res2,res3)) << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

d = []

bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append([b,c])

bc = sorted(bc,key=lambda x:x[1],reverse=True)

for elm in bc:
    for i in range(elm[0]):
        d.append(elm[1])
        if len(d) >= n:
            break
    if len(d) >= n:
        break

d.sort()
d.reverse()

#print(a)
#print(d)

sum = 0
ln = len(d)
for i in range(n):
    if i < ln:
        if a[i] < d[i]:
            sum += d[i]
        else:
            sum += a[i]
    else:
        sum += a[i]

print(sum)

Measured memory_bytes: 26432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, -1); dp[0] = 0;
  vector<vll> check(100001, vll(n));
  for (ll i = 1; i <= ww; i++) {
    if (dp[i] == -1) dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      check[i] = check[i - w[memo]];
      check[i][memo] = 1;
    }
    else check[i] = check[i-1];
  }
  cout << dp[ww] << endl;
}


Measured memory_bytes: 83072
S = input()

flag = 'Yes'
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break
    if i%2 == 1:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            pass
        else:
            flag = 'No'
            break

print(flag)


Measured memory_bytes: 2940
N, Q = map(int, input().split())
S = input()
QS = []

l = [0, 0]
last = S[0]
for i in range(1, len(S)):
    if last == 'A' and S[i] == 'C':
        l.append(l[-1] + 1)
    else:
        l.append(l[-1])
    last = S[i]

for _ in range(Q):
    left, right = map(int, input().split())
    QS.append((left, right))

# print(l)
for left, right in QS:
    ans = l[right] - l[left]
    print(ans)


Measured memory_bytes: 19812
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
 
ll n, p, ans=1;
int main() {
	ll i, j, t;
	cin >> n >> p;
	if(n==1) {return printf("%lld", p)*0;}
	for(i=2; ; i++) {
		t = 1;
		for(j=0; j<n; j++) {
			t *= i;
			if(t<0 || t>p) {cout << ans; return 0;}
		}
		if(p%t==0) ans = i;
	}
	return 0;
}

Measured memory_bytes: 256