akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		boolean[] v = new boolean[31];
		for (int i = 0; i < 28; ++i) {
			v[sc.nextInt()] = true;
		}
		for (int i = 1; i <= 30; ++i) {
			if (!v[i]) System.out.println(i);
		}
	}

}

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

int main()
{
  int n, k;
  cin >> n >> k;
  
  int a[n];
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(a, a + n);
  
  long ans = 0;
  for (int i = 0; i < max(0, n - k); ++i)
    ans += a[i];
  
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(void){
    
    int N;
    cin >> N;
    int d[N];
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    
    int ans = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int top[] = new int[3];

		for (int i = 0; i < 10; i++)
		{
			int n = sc.nextInt();
			for (int j = 0; j < 3; j++)
			{
				if (Math.max(top[j], n) == n)
				{
					for (int k = 2; k > j; k--)
						top[k] = top[k-1];
					top[j] = n;
					break;
				}
			}
		}
		for (int i = 0; i < 3; i++)
		{
			System.out.println(Integer.toString(top[i]));
		}
	}
}

Measured memory_bytes: 11000
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int f[][] = new int[n][10];
		int p[][] = new int[n][11];

		for(int i=0; i<n; i++) {
			for(int j=0; j<10; j++) {
				f[i][j]=sc.nextInt();
			}
		}
		for(int i=0; i<n; i++) {
			for(int j=0; j<=10; j++) {
				p[i][j]=sc.nextInt();
			}
		}

		long ans = -Long.MAX_VALUE;
		for(int i=1; i<(1<<10); i++) {
			int cnt[] = new int[n];
			for(int j=0; j<10; j++) {
				if(((i>>j)&1)==1) {
					for(int k=0; k<n; k++) {
						if(f[k][j]==1) {
							cnt[k]++;
						}
					}
				}
			}
			long sum = 0;
			for(int j=0; j<n; j++) {
				sum += p[j][cnt[j]];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 40148
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int h,n,sum=0;cin>>h>>n;
    vi a(n); cin_pl(n,a);
    rep(i,n)
    {
        sum+=a[i];
    }
    sum-h>=0?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 640
n, m = map(int, input().split())
h = list(map(int, input().split()))
a, b = [], []
for i in range(m):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
glaph_h = [[]for i in range(n)]

for i in range(len(a)):
    glaph_h[a[i]-1].append(b[i]-1)
    glaph_h[b[i]-1].append(a[i]-1)
counter = 0
for i in range(len(glaph_h)):
    if len(glaph_h[i]) == 0:
        counter += 1
        continue
    flag = False
    for j in range(len(glaph_h[i])):
        if h[i] <= h[glaph_h[i][j]]:
            flag = True
            break
    if not flag:
        counter += 1
print(counter)
# group_h = [-1]*n
# save_pair = 0
# counter = 0
# for i in range(m):
#     aa = a[i]
#     bb = b[i]
#     if group_h[aa-1] == -1 and group_h[bb - 1] == -1:
#         counter += 1
#         group_h[aa-1] = counter
#         group_h[bb-1] = counter
#     elif group_h[aa-1] != -1 and group_h[bb - 1] == -1:
#         group_h[bb-1] = group_h[aa-1]
#     elif group_h[aa-1] == -1 and group_h[bb - 1] != -1:
#         group_h[aa-1] = group_h[bb-1]
#     elif group_h[aa-1] == group_h[bb-1]:
#         continue
#     else:
#         save_pair += 1
# for i in group_h:
#     if group_h == -1:
#         counter += 1
# print(counter-save_pair)
# print(counter, save_pair)


Measured memory_bytes: 104424
//WrittenBiDP
//frog

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

#define MAXN 1000050000

using namespace std;

typedef vector <int> vi;

vi h;
vi ans;

int main() {
	//ifstream In("input.txt");
	//ofstream Out("output.txt");

	int n, k;
	//In >> n;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		int t;
		//In >> t;
		cin >> t;
		h.push_back(t);
	}

	ans.assign(n, MAXN);
	ans[0] = 0;
	ans[1] = abs(h[0] - h[1]);

	for (int i = 2; i < n; i++) {
		for (int e = 1; e <= min(k, i); e++) {
			ans[i] = min(ans[i], abs(h[i] - h[i - e]) + ans[i - e]);
		}
	}

	//Out << ans[n - 1];
	cout << ans[n - 1];
	//cin >> n;
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	string a, b, c; CI a >> b >> c;
	if (a[a.length() - 1] == b[0] and b[b.length() - 1] == c[0]) {
		CO "YES" EN;
	}
	else CO "NO" EN;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str,x;
        int i,j,ok;
        ok = 0;
        str = scan.nextLine();
        x = scan.nextLine();
        //StringBuilder sb = new StringBuilder();
        for ( i=0; i<str.length(); i++) {
             str.charAt(i);
             for(j=0; j<x.length();j++){
                 if(str.charAt((i+j)%str.length())!=x.charAt(j)){
                     ok = 0;
                     break;
                 }
                 ok++;
             }
             if(ok == x.length()){
                 System.out.println("Yes");
                 scan.close();
                 return;
             }

        }
        

        scan.close();
        System.out.println("No");
        return;
    }

}



Measured memory_bytes: 26324
#include<iostream>

using namespace std;

long fl(long a, long b, long x)
{
	if (x < 0) return 0;
	return (a*x)/b - a * (x/b);
}

int main(void)
{
	
	long a, b, n;
	cin >> a >> b >> n;

	cout << fl(a, b, min(n, b - 1)) << endl;
	
	return 0;
	
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll K; cin >> K;
  ll res = 7; int ans = 0; bool flag = false;
  REP(i, 1000000) {
    ans++;
    if(res % K == 0) {
      flag = true;
      break;
    }
    res = ((res % K) * 10) % K + (7 % K);
  }
  if(flag == true) cout << ans << endl;
  else cout << -1 << endl;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++) ans += p[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int WA[100010];
bool AC[100010];
int ans[2];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int p;
		string S;
		cin >> p >> S;
		if (S == "WA") {
			WA[p]++;
		}
		else {
			if (!AC[p]) {
				ans[0]++;
				ans[1] += WA[p];
				AC[p] = true;
			}
		}
	}
	cout << ans[0] << " " << ans[1] << endl;
}

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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORE(it,v) for(__typeof((v).begin() it=(v).begin();it!=(v).end();i++)
#define IN(v) cerr<<v<<endl
#define SET(a,x) memset((a),(x),sizeof(a))
#define mod 1000000000

#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;

typedef pair<int,int> ii;

typedef pair<ll,int> lii;


const int N=1000005;

string st[3];
int q;
int u,v,x,y;
int sa[3][N],sb[3][N];

int tinha(int bit,int u,int v)
{
    return sa[bit][v]-sa[bit][u-1];
}
int tinhb(int bit,int u,int v)
{
    return sb[bit][v]-sb[bit][u-1];
}

int main()
{


   if (fopen("text.inp","r"))
   {
      freopen("text.inp","r",stdin);
      freopen("text.out","w",stdout);
   }
   else
   {
    //freopen("FENCE1.INP","r",stdin);
    //freopen("FENCE1.OUT","w",stdout);
   }

   getline(cin,st[1]);
   getline(cin,st[2]);
   int len[3];
   len[1]=st[1].length();
   len[2]=st[2].length();
   int len1=st[1].length(),len2=st[2].length();
   st[1]=" "+st[1];
   st[2]=" "+st[2];
   FOR(h,1,2)
    FOR(i,1,len[h])
    {
       sa[h][i]=sa[h][i-1]+(st[h][i]=='A');
       sb[h][i]=sb[h][i-1]+(st[h][i]=='B');

    }
   cin>>q;

   FOR(i,1,q)
   {
       cin>>u>>v>>x>>y;
       int dema=tinha(1,u,v)+tinhb(1,u,v)*2-tinhb(2,x,y)*2;
       dema-=tinha(2,x,y);
       dema=dema+30000000;
      // cerr<<tinha(1,u,v)<<" "<<tinhb(1,u,v)<<" "<<tinhb(2,x,y)<<endl;
       if(dema>=0 && dema%3==0)  cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
   }


}















Measured memory_bytes: 13156
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back
#define inf (1<<29)

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        int a,b,c;
        cin >> a>> b >> c;
        cout<<c<<" "<<a<<" "<<b<<endl;

return 0;
}








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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll> p(a),q(b),r(c);
  cin>>p>>q>>r;
  
  sort(p.begin(),p.end(),greater<>());
  sort(q.begin(),q.end(),greater<>());
  sort(r.begin(),r.end(),greater<>());

  int i,j,k;
  i = j = k = 0;
  ll ans = 0;
  ll cnt = 0;
  ll acnt,bcnt,ccnt;
  acnt = bcnt = ccnt = 0;
  priority_queue<pll> que;
  que.emplace(p[i],1);
  que.emplace(q[j],2);
  que.emplace(r[k],3);
  while(!que.empty()){
    ll v,t;
    tie(v,t) = que.top();
    que.pop();
    cnt++;
    if(cnt>x+y)break;
    dump(v,t);
    dump(acnt,bcnt,ccnt,cnt);
    if(t==1){
      i++;
      if(i!=a&&acnt+1<x&&acnt+bcnt+ccnt<x+y){
        que.emplace(p[i],1);
        acnt++;
      }
    }
    if(t==2){
      j++;
      if(j!=b&&bcnt+1<y&&acnt+bcnt+ccnt<x+y){
        que.emplace(q[j],2);
        bcnt++;
      }
    }
    if(t==3){
      k++;
      if(k!=c&&acnt+bcnt+ccnt<x+y){
        que.emplace(r[k],3);
        ccnt++;
      }
    }
    ans += v;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 2560
def read_line():
    return input().rstrip()

def read_ints():
    return [int(x) for x in read_line().split()]

def read_int():
    return int(read_line())


s = read_line()
l = len(s)

u = len(set(s))

if l == u:
    print('yes')
else:
    print('no')


Measured memory_bytes: 2940
/* Author - Ankur Kumar Singh 
	IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
	/* variable type :- */
	# define ll  long long int
	# define ld long double
	# define I int
	# define mod 1000000007
/* map */
	# define abc  pair<long long int,long long int>
	map < pair < abc,abc > , long long int > pqr;
	map <  pair < long long int,long long int > ,long long int > xyz;	
/* vector */
	# define pb push_back
	# define pp pop_back
	# define ff first
	# define ss second
	# define mp make_pair
	# define ac accumulate
	vector<pair<ll,string>>a1;
	vector<pair<ll,string>>a2;
	vector<pair<ll,string>>a3;
	vector<pair<ll,string>>a4;
	vector<pair<ll,string>>a5;
	vector<pair<ll,string>>a6;
	vector<pair<ll,string>>a7;
	vector<pair<pair<ll,ll>,ll>>b;
bool compare( const pair<long long int,long long int>&x , const pair<long long int,long long int>&y )
{
	return x.ff>y.ff;
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
        return (a.ss < b.ss);
}
bool isPowerOfTwo(ll n) 
{ 
   return (ceil(log2(n)) == floor(log2(n))); 
} 
int main()
{
	
	ios_base::sync_with_stdio(false); 
    	cin.tie(NULL);   
	ll arr[4];
	for(ll i=0;i<3;i++)cin>>arr[i];
	sort(arr,arr+3);
	cout<<arr[2]*10+arr[1]+arr[0];
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int A, B;
    cin >> A >> B;
    vector<int> tax_8;
    vector<int> tax_10;
    vector<int> ans_8;
    vector<int> ans_10;
    int i;
    int flag_8, flag_10;

    for(i=1;i<=1250;i++){
        tax_8.push_back(i * 0.08);
        tax_10.push_back(i * 0.1);
    }

    for(i=0;i<=1249;i++){
        flag_8  = 0;
        flag_10 = 0;
        if(tax_8.at(i)  == A){flag_8  = 1;}
        if(tax_10.at(i) == B){flag_10 = 1;}
        if(flag_8 == 1 and flag_10 == 1){cout << i+1 << endl; return 0;}
    }
    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>

int main(void)
{
    int H=0,W=0,i,j;
    for (; ; )
    {
        scanf("%d %d",&H,&W);
        if (H==0&&W==0)
            break;
        for (i=0; i<H; i++)
        {
            for (j=0; j<W; j++)
            {
                if (i==0)
                    printf("#");
                else if (j==0)
                    printf("#");
                else if(i==(H-1))
                    printf("#");
                else if (j==(W-1))
                    printf("#");
                else
                    printf(".");
            }printf("\n");
        }printf("\n");
    }
    return 0;
} 

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    int ans[10] = { 1, 1, 0, 2, 0, 0, 1, 0, 1, 0 };
    const char *S[] = {"hon", "pon", "bon"};
    cout << S[ans[N % 10]] << endl;
    return 0;
}


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



int main() {

int A, B, C, K;
int sum=0;
cin >> A >> B >> C >> K;

if(A>=K){
    sum += K;
    K -= K;
}
else{
    sum += A;
    K -= A;
}

if(B>=K){
    K -= K;
}
else{
    K -= B;
}

if(C>=K){
    sum -= K;
    K -= K;
}
else{
    sum -= C;
}
cout << sum << endl;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sm = sum(B)
for i in range(N):
    if A[i] > B[i]:
        A[i] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i]
        A[i] = 0

    if A[i+1] > B[i]:
        A[i+1] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i+1]
        A[i+1] = 0

print(sm - sum(B))


Measured memory_bytes: 18624
from math import ceil
from decimal import Decimal, getcontext
getcontext().prec = 100
N = int(input())
TA = [tuple(map(int, input().split())) for _ in range(N)]

T = 1
A = 1
for i in range(N):
    x, y = TA[i]
    n = max(ceil(Decimal(T)/Decimal(x)), ceil(Decimal(A)/Decimal(y)))
    T = n*x
    A = n*y
print(T+A)

Measured memory_bytes: 82872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define MAX_V 100000
#define INF 100000000
using namespace std;

int V, M;               //頂点，辺の数
vector<int> G[MAX_V];   //グラフの隣接リスト表現
int match[MAX_V];       //マッチングのペア
bool used[MAX_V];       //DFSですでに調べたかのフラグ

//uとvを結ぶ辺をグラフに追加する
void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

//増加パスをDFSで探す
bool dfs(int v){
    for (int i=0; i<G[v].size(); i++){
        if (used[G[v][i]] == false){
            used[G[v][i]] = true;
            if (match[G[v][i]] < 0 || dfs(match[G[v][i]])){
                match[G[v][i]] = v;
                match[v] = G[v][i];
                return true;
            }
        }
    }
    return false;
}

//二部グラフの最大マッチングを求める
int bipartite_matching(){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v=0;v<V;v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v)){
                   res++;
            }
        }
    }
    return res;
}

int main(void){
	// cin >> V >> M;
	// int a,b;
	// for(int i=0;i<M;i++){
	// 	cin >> a >> b;
	// 	add_edge(a,b);
	// }
    int X, Y;
    cin >> X >> Y >> M;
    V = X + Y;
    for (int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        add_edge(x, X+y);
    }

	std::cout << bipartite_matching() << std::endl;

}


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

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll INF = INT_MAX;
ll dp[1010][10100];

int main() {
  ll h, n;
  cin >> h >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, 1010) rep(j, 10100) dp[i][j] = INF;

  dp[0][0] = 0;
  rep(i, n) rep(j, h + 1) {
    dp[i + 1][j] = dp[i][j];
    dp[i + 1][j] = min(dp[i + 1][max(j - a[i], 0LL)] + b[i], dp[i + 1][j]);
  }
  cout << dp[n][h] << endl;
}


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

using namespace std;
int n;
int b[10005];
pair <double,double> a[10005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("C.inp","r",stdin);
    //freopen("C.out","w",stdout);
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i].first>>a[i].second;
        b[i]=i;
    }
    double ans=0;
    do
    {
        double res=0;
        for (int i=2;i<=n;i++)
            res+=sqrt((a[b[i]].first-a[b[i-1]].first)*(a[b[i]].first-a[b[i-1]].first)+(a[b[i]].second-a[b[i-1]].second)*(a[b[i]].second-a[b[i-1]].second));
        ans+=res;
    }
    while (next_permutation(b+1,b+1+n));
    for (int i=1;i<=n;i++)
        ans/=i;
    cout<<setprecision(10)<<fixed<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    long double n,m,d; cin>>n>>m>>d;
    long double al = n*n;
    long double beutiful = (n-d)*2;
    long double per = beutiful/al;
    if(d == 0) printf("%.10llf\n", per * (m-1)/2);
    else printf("%.10llf\n", per * (m-1));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<string, int> psi;

int main(){
	vector<psi> words;
	while(!cin.eof()){
		psi entry;
		cin >> entry.first >> entry.second;
		words.push_back(entry);
	}
	sort(words.begin(), words.end());
	string word = "";
	for(int i = 1; i < words.size(); ++i){
		if(words[i].first != word){
			word = words[i].first;
			cout << word << endl;
		}
		cout << words[i].second;
		if(i == words.size() - 1 || words[i + 1].first != word){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    ll X;
    cin >> N >> X;
    int x;
    cin >> x;
    ll ans = abs(x - X);
    for(int i = 1; i < N; i++) {
        cin >> x;
        ans = gcd(ans, abs(x - X));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long n, k, cur = 0;
    cin >> n >> k;
    for (int i = 31; i >= 0; i--) {
        (k >> i & 1);
    }
    vector<int> as(n);
    vector<vector<int>> to(n, vector<int>(64));
    REP(i, n) {
        cin >> as[i];
        as[i]--;
        to[i][0] = as[i];
    }
    for (int j = 1; j < 64; j++) {
        REP(i, n) { to[i][j] = to[to[i][j - 1]][j - 1]; }
    }
    for (int j = 0; j < 64; j++) {
        if ((k >> j) & 1) {
            cur = to[cur][j];
        }
    }
    cout << cur + 1 << endl;
}

Measured memory_bytes: 61808
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			cout << "No" << endl;
			cin >> n; return 0;
		}
		if (i % 2 == 1 && s[i] == 'R') {
			cout << "No" << endl;
			cin >> n; return 0;
		}
	}
	cout << "Yes" << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <ctype.h>
using namespace std;
int main()
{
  string S;
  
  // 標準入力から文字列を受け取る
  cin >> S;
  
  // 文字列の長さチェック
  if(S.size() == 4)
  {
    // 大文字チェック
    for(int i = 0 ; i < S.size() ; i++)
    {
      if(!isupper((unsigned char)S[i]))
      {
      	return 0;
      }
    }
    
    // 文字列チェック
    int a = (int)S.find(S[0], 1);
    if(a == 1)
    {
      int b = (int)S.find(S[2], 3);
      int c = (int)S.find(S[0], 2);
      if((b == 3) && (c == -1))
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else if(a == 2)
    {
      int b = (int)S.find(S[1], 3);
      int c = (int)S.find(S[0], 3);
      if((b == 3) && (c == -1))
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else if(a == 3)
    {
      int b = (int)S.find(S[1], 2);
      if(b == 2)
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else
    {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
vii vec1;
vector<vii > vec(100);
int main(){
    std::ios::sync_with_stdio(false);
    int n,c;
    cin>>n>>c;
    int i,s,t,ct;
    rep(i,n){
    	cin>>s>>t>>ct;
    	ct--;
    	//cout<<ct<<endl;
    	vec[ct].pb(mp(s,t));
    }
    int j;
    rep(i,c){
    	sort(vec[i].begin(),vec[i].end());
    	if(vec[i].empty())
    		continue;
    	//cout<<i<<vec[i].size()<<endl;
    	vec1.pb(mp(vec[i][0].ff,0));
    	rep(j,vec[i].size()-1){
    		if(vec[i][j].ss!=vec[i][j+1].ff){
    			vec1.pb(mp(vec[i][j].ss,1));
    			vec1.pb(mp(vec[i][j+1].ff,0));
    		}
    	}
    	vec1.pb(mp(vec[i][j].ss,1));
    }
    //cout<<vec1.size()<<endl;
    int ans=0,maxi=0;
    sort(vec1.begin(),vec1.end());
    rep(i,vec1.size()){
    	//cout<<vec1[i].ff<<" "<<vec1[i].ss<<endl;
    	if(vec1[i].ss){
    		ans--;
    	}
    	else{
    		ans++;
    	}
    	maxi=max(ans,maxi);
    }
    cout<<maxi<<endl;
    return 0;  
    
}



Measured memory_bytes: 3572
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A -= np.arange(1,N+1)

def sad(b):
    return int(np.sum(np.abs(A - b)))

l = -1e10
r =  5e10
m = 2e30
tmp = 5e30
tmp2 = 1e30
while tmp2 != sad(m):
    if tmp > sad(m):
        tmp = sad(m)
    tmp2 = sad(m)
    m = (l + r) // 2
    if sad(m) - sad(m+1) >= 0:
        l = m
    else:
        r = m

print(tmp)


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

int n;
int A,B;
int pieC;
int C[100];

int main() {

    cin >> n;
    cin >> A >> B;
    cin >> pieC;
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }
 
    // テゥツ卍催ゥツ??10,9,8,...)テ」ツ?ォテ」ツつステ」ツδシテ」ツδ暗」ツ?凖」ツつ?
    sort(C, C+n);
    reverse(C, C+n);

 	int calorie = pieC;
	int doll = A;
	int ans = calorie / doll;
	for (int i = 0; i < n; i++) {
		doll += B;
		calorie += C[i];
		
		if (calorie / doll >= ans) {
			ans = calorie / doll;
		} else {
			break;
		}
	}

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

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll asum =0;
    rep(i,n){
        scanf("%lld",&a[i]);
        asum+=a[i];
    }
    ll b[n] = {};
    ll c[n] = {};
    ll bsum=0;
    ll d = 0;
    int count = 0;
    rep(i,n){
        scanf("%lld",&b[i]);
        c[i] = a[i]-b[i];
        if(c[i]<0){
            count++;
            d+=c[i];
        }
        bsum+=b[i];
    }
    if(asum-bsum<0){
        puts("-1"); return 0;
    }
    sort(c,c+n);
    int num = n-1;
    while(d<0){
        d+=c[num];
        count++;
        num--;
    }

    




    ll ans = 0;
    
    cout << count << endl;
    return 0;
}
 
 


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, 100001)
	l := 100000
	r := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		a[x]++
		l = min(l, x)
		r = max(r, x)
	}
	ans := a[l] + a[l+1]
	for i := l + 1; i < r; i++ {
		ans = max(ans, a[i-1]+a[i]+a[i+1])
	}
	if l != r || r > 0 {
		ans = max(ans, a[r-1]+a[r])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#17:21
from collections import deque
import bisect
n = int(input())
now = deque()
for _ in range(n):
  tmp = int(input())
  b = bisect.bisect_left(now,tmp)
  if b != 0:
    now[b-1] = tmp
  else:
    now.appendleft(tmp)
print(len(now))

Measured memory_bytes: 47960
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int X=sc.nextInt();
		int Y=sc.nextInt();
		int Z=sc.nextInt();
		{
			X^=Y;Y^=X;X^=Y;
			X^=Z;Z^=X;X^=Z;
		}
		System.out.println(X+" "+Y+" "+Z);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	int card[4][13];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			card[i][j] = 1;
		}
	}
	int x;
	char c;
	for (int i = 0; i < N; i++) {
		cin >> c >> x;
		if (c == 'S') {
			card[0][x - 1] = 0;
		}
		else if (c == 'H') {
			card[1][x - 1] = 0;
		}
		else if (c == 'C') {
			card[2][x - 1] = 0;
		}
		else {
			card[3][x - 1] = 0;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (card[i][j]) {
				if (i == 0) {
					cout << "S " << j + 1 << endl;
				}
				else if (i == 1) {
					cout << "H " << j + i << endl;
				}
				else if (i == 2) {
					cout << "C " << j + 1 << endl;
				}
				else {
					cout << "D " << j + 1 << endl;
				}

			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>

#define ll long long
#define nums vector<int>
#define words vector<string>

using namespace std;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s == "ABC") {cout << "ARC" << endl;}
    else {cout << "ABC" << endl;}
    return 0;
}


Measured memory_bytes: 3600
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var ret = Math.Max(A + B, (Math.Max(A - B, A * B)));
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;


char str[200050];

int main(){
	int n=0,l=0,i=0,j=0;
	long long sum=0,itr=0;
	scanf("%s",str+1);
	l=strlen(str+1);
	i=l;
	while(i>=1){
		if(str[i]=='A') sum+=itr,i--;
		else if(str[i]=='C'&&str[i-1]=='B') itr++,i-=2;
		else itr=0,i--;
	}
	printf("%lld\n",sum);
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin >> arr[i];
    int c=0;
    int check=1;
    for(int i=0; i<n; i++)
    {
        if(arr[i]!=check)
        {
            c++;
        }
        else
        {
            check++;
        }
    }
    if(n==c)
        c=-1;
    cout<<c;
    return 0;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<int> lgcd(N), rgcd(N);
  lgcd[0] = A[0];
  REP(i, N-1){
    lgcd[i+1] = gcd(lgcd[i], A[i+1]);
  }
  rgcd[N-1] = A[N-1];
  for(int i = N-1; i > 0; i--){
    rgcd[i-1] = gcd(rgcd[i], A[i-1]);
  }
  int ans = max(lgcd[N-2], rgcd[1]);
  FOR(i, 1, N-1){
    ans = max(ans, gcd(lgcd[i-1], rgcd[i+1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

bool isPrime(int n) {
    if (n < 2) return false;
    for (int i = 2; i * i <= n; ++i) if (n % i == 0) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int L = 1000;
    int p = 2;
    while (!isPrime(p) || p * p + p + 1 < L) ++p;
    int n = p * p + p + 1;
    cout << n << ' ' << p + 1 << '\n';
    forn(a, p) forn(b, p) {
        forn(j, p) {
            int x = (a * j + b) % p;
            cout << 1 + j * p + x << ' ';
        }
        cout << 1 + p * p + a << '\n';
    }
    forn(b, p) {
        forn(j, p) cout << 1 + b * p + j << ' ';
        cout << 1 + p * (p + 1) << '\n';
    }
    forn(j, p) cout << 1 + p * p + j << ' ';
    cout << 1 + p * (p + 1) << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MOD = 1000000007;

int main() {
	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	ll up = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2;
	ll dw = k * (k - 1) / 2;
	ans += up - dw + 1;
	ans %= MOD;
	//cout << ans << endl;
	for (ll i = k + 1; i <= n + 1; i++) {
		dw += i - 1;
		up += n - (i - 1);
		ans += up - dw + 1;
		ans %= MOD;
		//cout << ans << endl;
	}

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


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    S = input()
    if 'L' not in S[::2] and 'R' not in S[1::2]:
        print('Yes')
    else:
        print('No')

main()


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(k >= e - a)
  cout << "Yay!" << endl;
  else
    cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import dijkstra

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])

def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]
N, M = map(int,input().split())
g = [[np.inf]*(2*N) for _ in range(2*N)]
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a][b] = 1
    g[a][b+N] = 1
    g[a+N][b] = 1

ans = np.inf
j = -1
d = dijkstra(g,return_predecessors=True)

for i in range(N):
    if d[0][i][i+N] < ans:
        ans = int(d[0][i][i+N])
        j = i

if ans != np.inf:
    path = get_path(j,j+N,d[1])[::-1][:-1]
    path = [node%N for node in path]
    print(ans)
    for node in path:
        print(node+1)
else:
    print(-1)

Measured memory_bytes: 138972
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
using pr  = pair<ll, ll>;

const ll MOD = 998244353;

int main()
{
	int N, K;
	cin >> N >> K;

	vec cnt(N, 0);

	for (int k = 0; k < K; ++k)
	{
		int d;
		cin >> d;

		for (int i = 0; i < d; ++i)
		{
			int A; cin >> A; --A;
			
			cnt[A]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) { ans += (cnt[i] == 0); }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	Scanner sc = new Scanner(System.in);

    	int N = sc.nextInt();

    	if(N%2==0) {
        	System.out.println(N/2);
    	} else {
        	System.out.println(N/2+1);
    	}

    }
}

Measured memory_bytes: 23764
N,M=map(int,input().split())
S=[]
T=[]
for i in range(N):
  S.append(list(map(int,input().split())))
for i in range(M):
  T.append(list(map(int,input().split())))
for i in range(N):
  min=abs(S[i][0]-T[0][0])+abs(S[i][1]-T[0][1])
  num=1
  for j in range(1,M):
    if abs(S[i][0]-T[j][0])+abs(S[i][1]-T[j][1])<min:
      min=abs(S[i][0]-T[j][0])+abs(S[i][1]-T[j][1])
      num=j+1
  print(num)

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

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

    vector<vector<string>> lunlun(12);
    for(int i=1; i<=9; i++){
        string s = " ";
        s[0] = '0' + i;
        lunlun[0].push_back(s);
        //cout << s << endl;
    }
    for(int i=1; i<12; i++){
        for(string l : lunlun[i-1]){
            string s = " ", t = " ", u = " ";
            s[0] = l[i-1] - 1;
            t[0] = l[i-1];
            u[0] = l[i-1] + 1;
            if(l[i-1] != '0') lunlun[i].push_back(l+s);
            lunlun[i].push_back(l+t);
            if(l[i-1] != '9') lunlun[i].push_back(l+u);
        }
    }
    vector<string> ans;
    for(int i=0; i<12; i++){
        for(string l : lunlun[i]){
            ans.push_back(l);
            //if(i <= 1) cout << l << " ";
        }
    }
    cout << ans[k-1] << endl;
    return 0;
}

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

int N,A[200010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",&A[i]);
    for(int i = 0; i < N; i+=2)
    {
        printf("%d ",A[N - i - 1]);
    }
    for(int i = 1; i < N / 2 + 1; i++)
    {
        printf("%d",A[i*2 - 1 - (N%2 == 0)]);
        if(i == N / 2)continue;
        printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2944