akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
	ll n; cin >> n;
	cout << 8 - (n - 400)/200 << endl;;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define Int long long
#define pb push_back
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

Int N,M,K;

const int MOD=(int)(1e9+7);
const int MAXN=500005;
vector<Int> adj[MAXN];
vector<Int> degree;
bool VIS[MAXN];     

int main()
{
        string S;cin>>S;
        Int ans=0;Int cons=0;
        for(int i=0;i<S.length();++i){
            if(S[i]=='R') ++cons,ans=max(ans,cons);
            else{
                cons=0;
            }
        }
        cout<<ans<<"\n";
}

Measured memory_bytes: 15308
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())
    // 数列中のAiを除くN - 1個の要素のうち最大の値を求めよ
    // Aのうち、もっとも大きい値以外では、常にAのうちもっとも大きい値が最大値
    // 最大値ではない
    val (max, maxidx) = A.zipWithIndex.maxBy(_._1)
    var max2 = 0
    var i = 1
    while (i < N) {
      if (i != maxidx) {
        max2 = max2 max A(i)
      }
      i += 1
    }

    println((0 until N). map { i =>
      if (i == maxidx) max2
      else max
    }. mkString("\n"))
  }

}

Measured memory_bytes: 90160
n,k = map(int,input().split())

prob = []

for i in range(1,n+1):
	for j in range(10000):
		#print(i,j)
		if k <= i*2**j:
			#print("1/{}*(1/2)**{}".format(n,j))
			p = (1/n)*(1/2)**j
			prob.append(p)
			break

print(sum(prob))


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    ll a[100000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a + n);

    int imx = -1;
    for (int i = 0; i < n - 1; i++)
    {
        if (imx < min(a[i], a[n - 1] - a[i]))
            imx = a[i];
    }
    cout << a[n - 1] << " " << imx << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int beki(int K){
  if(K==0) return 1;
  else return 2*beki(K-1);
}

int main(){
  	int A, B, C, K;
    cin >> A >> B >> C >> K;

    int sum = A + B + C;
    cout << sum + max(max(A,B),C)*(beki(K)-1) <<endl;




  return 0;
}

Measured memory_bytes: 384
#include<bitset>
#include<cstdio>
#include<algorithm>

int a[3000];
std::bitset<4000000> dp;

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);

    if(n==1) {
        printf("%d\n", a[0]);
        return 0;
    }

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

    dp[0] = 1;
    for(int i=0; i<n; i++) {
        dp |= dp << a[i];
    }

    int r = 0;
    for(int i=0; 2*i<=sum; i++)
        if(dp[i]) r = sum-i;

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


Measured memory_bytes: 1664
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<numeric>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> L(N);
	for(int i=0; i<N; i++)
		cin >> L[i];

	sort(L.begin(), L.end());
	int n = accumulate(L.begin(), L.begin()+N-1, 0);
	if(n > L.back())
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int n;
	vector<int> mountain;
	while( cin >> n )
		mountain.push_back(n);
	sort( mountain.begin(), mountain.end(), greater<int>() );
	for(n=0; n<3; n++)
		cout << mountain[n] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;

int main(){
    int q; cin >> q;
    string x[q],y[q];
    rep(i,q){
        cin >> x[i] >> y[i];
    }
    int ans[q];
    rep(i,q){
        int dp[1010][1010] = {};
        int xlen = x[i].size();
        int ylen = y[i].size();
        // cout << x[i] << ' ' << xlen << ' ' << y[i] << ' ' << ylen << endl;
        dp[0][0] = 0;
        rep(j,xlen+1){
            if(!j)continue;
            rep(k,ylen+1){
                if(!k)continue;
                if(x[i][j-1] == y[i][k-1]) {
                    dp[j][k] = dp[j-1][k-1] + 1;
                    // cout << i  << ' ' << j  << ' ' << k << ' ' <<  dp[j][k] << endl;
                }
                else{
                    dp[j][k] = max(dp[j-1][k],max(dp[j][k-1],dp[j-1][k-1]));
                }
            }
        }
        ans[i] = dp[xlen][ylen];
    }

    rep(i,q) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll n,a[N],b[N],c[N];
long long summ;
ll judge(ll m)
{
    long long sum=m;
    b[1]=m;
    for(ll i=2;i<=n;i++)
        b[i]=2*(a[i-1]-b[i-1]/2),sum+=b[i];
    if(sum<summ) return 1;
    if(sum>summ) return 2;
    return 0;
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&a[i]),summ+=a[i];
    ll l=0,r=2e9,ans;
    while(l<=r)
    {
        ll m=l+r>>1,t=judge(m*2);
        if(t==2) r=m-1;
        else if(t==1) l=m+1;
        else {ans=m;break;}
    }
    b[1]=ans*2;
    for(ll i=2;i<=n;i++)
        b[i]=2*(a[i-1]-b[i-1]/2);
    for(ll i=1;i<=n;i++)
        printf(i==n?"%lld\n":"%lld ",b[i]);
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main(){
  string s; cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i, n) {
    ans += s[i]-'0';
    ans %= 9;
  }
  if(ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[12345678][2], aa[1234][1234], bb[1234][1234];
signed main() {
	int n, m = 0, k, z = 0, cnt = 1, ans = 0;
	cin >> n >> k;
	if (k > (n - 1)* (n - 2) / 2) { cout << -1 << endl; return 0; }
	for (int h = 2; h <= n; h++) {
		test[m][0] = 1; test[m][1] = h; m++;
	}
	cnt = (n - 1) * (n - 2) / 2 - k;
	for (int h = 2; h <= n; h++) {
		for (int i = h + 1; i <= n; i++) {
			if (cnt == 0) { z++; break; }
			test[m][0] = h; test[m][1] = i; m++; cnt--;
		}
		if (z == 1) { break; }
	}
	cout << m << endl;
	for (int h = 0; h < m; h++) {
		cout << test[h][0] << ' ' << test[h][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#if 0
date +%Y.%m.%d

将数从大到小排序，排在一起。
每次删除操作可以看作删掉最左边一列，减一操作可以看作删掉底下一列。
那么问题转换在二维平面上有一条折线，从 (0, 0) 开始，每次可以 x + 1 或 y + 1 。
所有折线上的点都是必败态，求 (0, 0) 是必败态还是必胜态。
有一个性质就是，若 (x, y) 和 (x + 1, y + 1) 都不在折线上，它们胜负态相同。
那么从 (0, 0) 直接走到的最大的 (k, k) ，然后问题从折线转换为矩形，简单判断即可。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 100005;
int a[maxn];

int main() {
	int n = read;
	for(int i = 1; i <= n; i ++)
		a[i] = read;

	std::sort(a + 1, a + n + 1);
	std::reverse(a + 1, a + n + 1);

	int x = 0, y = 0;
	while(y < a[x + 1])
		++ x, ++ y;
	-- x, -- y;

	int dy = a[x + 1] - y;

	while(y < a[x + 1])
		++ x;

	int dx = x - y;

	if(dx & 1 and dy & 1) puts("Second");
	else puts("First");
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  if(B % A == 0)
    cout << A + B << endl;
  else
    cout << B - A << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll N;
  cin>>N;
  vector<pair<string, vector<ll> > > SP;
  FORi(N){
    string s;
    ll p;
    ll n=i+1;
    cin>>s>>p;
    SP.push_back(make_pair(s,vector<ll>{p,n}));
  }
  sort(SP.rbegin(),SP.rend(),[](auto a,auto b){
    if(a.first!=b.first){
      return a.first.compare(b.first)>0;
    }else{
      return (bool)(a.second[0]<b.second[0]);
    }
  });
  for(auto a:SP){
    cout<<a.second[1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 888
n = int(input())
a_list = list(map(int,input().split()))
import collections
c = collections.Counter(a_list)
result = 0
for key in c:
  if c[key] > key:
    result += c[key] - key
  elif c[key] < key:
    result += c[key]
    
print(result)

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

int main() {
    string S;
    cin >> S;

    int flag = 1;
    for (int i = 0; i < S.size(); ++i) {
        if(i % 2 == 0){
            if(S[i] == 'L') flag = 0;
        } else{
            if(S[i] == 'R') flag = 0;
        }
    }
    if(flag){
        cout << "Yes" << "\n";
    } else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
// Problem: C - Be Together
// Contest: AtCoder - AtCoder Regular Contest 059
// URL: https://atcoder.jp/contests/arc059/tasks/arc059_a
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;

int n;
int a[N];

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int ans = INT_MAX;
  for (int x = -100; x <= 100; x++) {
    int cur = 0;
    for (int i = 1; i <= n; i++) {
      cur += (a[i] - x) * (a[i] - x);
    }
    ans = min(ans, cur);
  }
  cout << ans;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int k=max(n,m);
    if(k+k-1>n+m)
        cout<<k+k-1<<endl;
    else
        cout<<m+n<<endl;
        return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	double d = 1 - (n / 2) / (double)n;
	cout << setprecision(10) <<  d << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, a, b; cin>>n>>a>>b;
	cout<<min(a, b)<<" "<<max(0, a+b-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

   int x = 0, y = 0, ans = 0;
   cin >> x >> y;
   
   if(x >= y){
      ans += x;
      x--;
   }else{
       ans += y;
       y--;
   }
   
   if(x >= y){
      ans += x;
      x--;
   }else{
       ans += y;
       y--;
   }
   cout << ans << "\n";
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll heapN,heap[1<<20];
int PQhikaku(int i,int j){return heap[i]<heap[j];}//jの方が優先度が高いときtrueを
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heap[1]=heap[heapN--];
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heap_dtou(heapN);
}


ll a[300010];
ll l[300010],r[300010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,3*n)scanf("%d",a+i);
	
	ll s=0;
	rep(i,0,n){
		s+=a[i];
		PQpush(-a[i]);
	}
	l[n]=s;
	rep(i,n,2*n){
		s+=a[i];
		PQpush(-a[i]);
		s+=PQpop();
		l[i+1]=s;
	}
	rep(i,0,n)PQpop();
	
	s=0;
	for(int i=3*n-1;i>=2*n;i--){
		s+=a[i];
		PQpush(a[i]);
	}
	r[2*n]=s;
	for(int i=2*n-1;i>=n;i--){
		s+=a[i];
		PQpush(a[i]);
		s-=PQpop();
		r[i]=s;
	}
	
	ll ans=-INF;
	rep(i,n,2*n+1)ans=max(ans,l[i]-r[i]);
	printf("%lld\n",ans);
	return 0;
}

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

totalrain = sum(A)//2
for i in range(0, N, 2):
    totalrain -= A[i]

ans = [-totalrain*2]
for i in range(N-1):
    ans.append((A[i]-ans[i]//2)*2)

print(" ".join(map(str, ans)))


Measured memory_bytes: 19096
#include <iostream>
#include <limits>
#include <algorithm>

typedef long long Int;

int main() {
	Int N;
	Int W;
	std::cin >> N >> W;
	Int w[N];
	Int v[N];
	for (Int i = 0; i < N; ++i) {
		std::cin >> w[i] >> v[i];
	}
	
	long long dp[N][W + 1];
	for (Int i = 0; i < N; ++i) {
		for (Int j = 0; j <= W; ++j) {
			if (i == 0) {
				if (w[0] <= j) {
					dp[i][j] = v[0];
				}
				else
				{
					dp[i][j] = 0;
				}
				
			} else {
				dp[i][j] = 0;
			}
		}
	}
	// for (Int i = 0; i < N; ++i) {
	// 	for (Int j = 0; j <= W; ++j) {
	// 		std::cout << dp[i][j] << " ";
	// 	}
	// 	std::cout << std::endl;
	// }
	for (Int i = 1; i < N; ++i) {
		for (Int j = 0; j <= W; ++j) {
			if (j - w[i] >= 0) {
				dp[i][j] = std::max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]); 
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	// for (Int i = 0; i < N; ++i) {
	// 	for (Int j = 0; j <= W; ++j) {
	// 		std::cout << dp[i][j] << " ";
	// 	}
	// 	std::cout << std::endl;
	// }
	std::cout << dp[N-1][W] << std::endl;
	
	return 0;	
}


Measured memory_bytes: 81224
#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 kaijoMOD(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 ={'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(){
 string O,E;cin>>O>>E;
  if(O.size()-E.size()==0){
    rep(i,O.size()){
  
       cout<<O[i]<<E[i];
    
    }
    cout<<endl;
  }
  else{
     rep(i,E.size()){
  
       cout<<O[i]<<E[i];
    
    }
    
    cout<<O[O.size()-1]<<endl;

  }

}




Measured memory_bytes: 256
s = list(input())
t = list(input())
a = len(s)
b = len(t)
dp = [[0]*(b+1) for _ in range(a+1)]
ans = ""
#dp[i][j]はi文字目までのsとtのj文字目までの共通部分
for i in range(a):
  for j in range(b):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
i = a
j = b
while(i>=0 and j>=0):
  if dp[i][j] == dp[i-1][j]:
    i -= 1
  elif dp[i][j] == dp[i][j-1]:
    j -= 1
  else:
    ans = t[j-1]+ans
    i -= 1
    j -= 1
print(ans)


Measured memory_bytes: 112476
n = int(input())
h = list(map(int,input().split()))
a = 0
b = 0
x = [0]*n

if n==1:
    print("Yes")
else:
    for i in range(n-1):
        if h[i]>h[i+1]:
            h[i]=h[i]-1
            x[i]=1

    for k in range(n-1):
        if h[n-k-1]<h[n-k-2] and x[n-k-2]==0:
            h[n-k-2]=h[n-k-2]-1


    for j in range(n-1):
        if h[j]>h[j+1]:
            print("No")
            break
        a = a+1
    if a==n-1:
        print("Yes")



Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
int h,w;
vector<vector<char>> board;

bool fine(int x, int y){
    if(x<0 or y<0 or x>=h or y>=w or board[x][y] == '#') return false;
    return true;
}

int main(){
   
    fast;
    
    int n;
    cin>>n;
    string s;
    cin>>s;

    int st = 0, en = n-1;
    int ans = 0;
    while(st<en){
        if(s[st] == 'W' and s[en] == 'R'){
            st++, en--, ans++;
        }
        if(s[st] == 'R') st++;
        if(s[en] == 'W') en--;
    }

    cout<<ans<<endl;

}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  int ans = INF;
  vector<int> pr(N);
  function<void(int)> dfs = [&](int d) {
    if (d == N) {
      int mp = 0;
      int a = 0, b = 0, c = 0;
      for (int i = 0; i < N; i++) {
        if (pr[i] == 1) {
          if (0 < a)
            mp += 10;
          a += l[i];
        } else if (pr[i] == 2) {
          if (0 < b)
            mp += 10;
          b += l[i];
        } else if (pr[i] == 3) {
          if (0 < c)
            mp += 10;
          c += l[i];
        }
      }
      if (0 < a && 0 < b && 0 < c) {
        mp += abs(A - a);
        mp += abs(B - b);
        mp += abs(C - c);
        dump(pr, a, b, c, mp);
        ans = min(ans, mp);
      }
      return;
    }
    for (int i = 0; i < 4; i++) {
      pr[d] = i;
      dfs(d + 1);
    }
  };
  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: qq.cpp
	> Author: ralph
	> Mail: 1694487365@qq.com
	> Created Time: 2018年12月21日 星期五 21时08分50秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;
int s[12];
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int ans=0,now=a+b;
        while(now)
        {
            now/=10;
            ans++;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 2988
package main

import (
        "fmt"
        "sort"
)

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        x := make([]int64, n)
        y := make([]int64, n)
        z := make([]int64, n)
        for i := 0; i < n; i++ {
                fmt.Scan(&x[i], &y[i], &z[i])
        }
        xm := []int64{-1, 1}
        ym := []int64{-1, 1}
        zm := []int64{-1, 1}

        var maxscore int64
        for _, xm := range xm {
                for _, ym := range ym {
                        for _, zm := range zm {
                                score := make([]int64, n)
                                for i := range score {
                                        score[i] = xm*x[i] + ym*y[i] + zm*z[i]
                                }
                                sort.Sort(sort.Reverse(Int64Slice(score)))

                                var sumscore int64
                                for i := 0; i < m; i++ {
                                        sumscore += score[i]
                                }
                                if maxscore < sumscore {
                                        maxscore = sumscore
                                }
                        }
                }
        }
        fmt.Println(maxscore)
}

func abs(x int64) int64 {
        if x < 0 {
                return -x
        }
        return x
}

type Int64Slice []int64

func (p Int64Slice) Len() int           { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
long long dp[4][1000005]={0};
int main()
{
    long long n;
    cin>>n;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        dp[0][i]=(dp[0][i-1]*8)%mod;
        dp[1][i]=(dp[0][i-1]+dp[1][i-1]*9)%mod;
        dp[2][i]=(dp[0][i-1]+dp[2][i-1]*9)%mod;
        dp[3][i]=(dp[3][i-1]*10+dp[1][i-1]+dp[2][i-1])%mod;
    }
    cout << dp[3][n] << endl;
    return 0;
}


Measured memory_bytes: 34688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string s,t;
    cin >> s >> t;
    int a,b; cin >> a >> b;
    string u;
    cin >> u;
    if(u == s){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }

}

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

int main() {
    string S,T;
    ll count=0;
    cin>>S;
    cin>>T;
    rep(i,S.length()){if(S[i]!=T[i])count++;}
    //int result=S.compare(T);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3916
N, M = map(int, input().split())
import sys
sys.setrecursionlimit(10000000)

mod = 1000000007

memo = [-1] * (N+1)

for _ in range(M):
    broken_step = int(input())
    memo[broken_step] = 0
    
memo[0] = 1
if memo[1] == -1:
    memo[1] = 1

def step_memo(N):
    
    if memo[N] != -1:
        return memo[N]
    
    memo[N] =  (step_memo(N-1) + step_memo(N-2)) % mod
    return (step_memo(N-1) + step_memo(N-2)) % mod
  
print(step_memo(N))

Measured memory_bytes: 111084
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, m, a[500005] = {}, f[1000006] = {1}, g[1000006] = {}, z = 0;
    g[1000000] = 397802501;
    for (int i = 1; i <= 1000000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    cin >> n >> m;
    for (int i = 0; i <= n; i++) a[i] = f[m - i] * g[m - n] % mod;
    for (int i = 0; i <= n; i++) a[i] = a[i] * f[n] % mod * g[i] % mod * g[n - i] % mod;
    for (int i = (int)n; i; i--) a[i - 1] = (a[i - 1] - a[i] + mod) % mod;
    cout << a[0] * f[m] % mod * g[m - n] % mod;
}


Measured memory_bytes: 23184
#!/mnt/c/Users/moiki/bash/env/bin/python
N,K = map(int, input().split())
x = list(map(int, input().split()))

x_minus = filter(lambda x: x<0, x)
x_plus  = filter(lambda x: x>=0, x)

x_minus = sorted(x_minus, reverse=True)
x_plus  = sorted(x_plus , reverse=False)

n_minus = len(x_minus)
n_plus = len(x_plus)


ans = 10**9

# go left only
if n_minus >= K:
    # ans = min(ans, sum( map(lambda x: abs(x)m x_minus[K])))
    ans = min(ans, abs(x_minus[K-1]))

# go right only
if n_plus  >= K:
    # ans = min(ans, sum(x_plus[K-1]))
    ans = min(ans, x_plus[K-1])

# left   and  right
for i in range( min(K-1, n_minus) ):
    remain = K - i - 1
    try:
        ans = min(ans, 2*abs(x_minus[i]) + x_plus[K-i-1-1])
    except IndexError:
        continue
    
# right  and  left
for i in range( min(K-1, n_plus) ):
    remain = K - i - 1
    try: 
        ans = min(ans, 2*x_plus[i] + abs(x_minus[K-i-1-1]))
    except IndexError:
        continue

print(ans)
    




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

#define int long long

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

    int a[100010];
    int b[100010];

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

    int ans = 0;
    for(int i = 0;i <= 30;i++){
        int bit = k;
        if((k & (1 << i)) > 0){
            bit ^= (1 << i);
            for(int j = 0;j < i;j++){
                bit |= (1 << j);
            }
        }

        int tmp = 0;

        for(int j = 0;j < n;j++){
            if(((~bit)&(a[j])) == 0){
                tmp += b[j];
            }
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), cost[] = new int[n];
            cost[0] = 0;
            cost[1] = Math.abs(a[1] - a[0]);
            for (int i = 2; i < n; ++i)
                cost[i] = Math.min(cost[i - 1] + Math.abs(a[i] - a[i - 1]), cost[i - 2] + Math.abs(a[i] - a[i - 2]));
            out.println(cost[n - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

void trace(int a[],int N){            
	int i=0;
	for(i=0;i<N-1;i++)
	   cout<<a[i]<<" ";	
	   cout<<a[i]<<endl;
}

void insertionsort(int a[],int N){
	trace(a,N);
	int i,j,v;
	for(i=1;i<N;i++){
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
	    a[j+1]=v;
		trace(a,N);
	}
	
}

int main()
{
	int N;
	cin>>N;
    int a[110];
    for(int i=0;i<N;i++)
    cin>>a[i];
    insertionsort(a,N);  
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  int n;
  cin>>n;
  vvi in(3,vi(n));
  rep(i,3)rep(j,n)cin>>in[i][j];
  rep(i,3)sort(all(in[i]));
  ll out=0;
  rep(i,n){
    int t=in[1][i];
    ll r=lower_bound(all(in[0]),t)-in[0].begin();
    ll l=in[2].end()-upper_bound(all(in[2]),t);
    out+=r*l;
  }
  cout<<out<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
   int H,W;
   char t[101][101];

   while(cin >> H >> W,(H!=0&&W!=0)){
   for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
		cin >> t[j][i];
	}
   }

   int X=0,Y=0;
   for(int k=0;k<10000;k++){
	if(t[X][Y] == '>'){
		X++;
	}else if(t[X][Y] == '<'){
		X--;
	}else if(t[X][Y] == 'v'){
		Y++;
	}else if(t[X][Y] == '^'){
		Y--;
	}else if(t[X][Y] == '.'){
		break;
	}

   }

   if(t[X][Y] == '.'){
	cout << X << " " << Y << endl;
   }else{
	cout << "LOOP" << endl;
   }

   }
   return 0;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N = 100, W = 1e5+1;
int w[N],v[N];
ll t[N][W];

ll dp(int i, int c){
   if(t[i][c]) return t[i][c];
   if(i == 0) t[i][c] = c >= w[i] ? v[i] : 0;
   else {
       ll x = dp(i-1,c);
       t[i][c] = max(x,(c >= w[i] ? dp(i-1,c-w[i])+v[i] : x));
   }
   return t[i][c];
} 

int main() {
	fastio;
	
    int n,m; cin >> n >> m;
    forn(i,n){
        int x,y; cin >> x >> y;
        w[i] = x, v[i] = y;
    }
	cout << dp(n-1,m) << endl;
	return 0;
}


Measured memory_bytes: 78080
#include<cmath>
#include <iostream>
#include <vector>

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

int main(){
  int N;
  std::cin >> N;

  std::vector<int> A_arr(N), g_l(N), g_r(N);
  for(int i = 0; i < N; i++) std::cin >> A_arr[i];

  g_l[0] = A_arr[0];
  g_r[N-1] = A_arr[N-1];
  for(int i = 1; i < N; i++){
    g_l[i] = gcd(g_l[i-1], A_arr[i]);
    g_r[N-1-i] = gcd(g_r[N-i], A_arr[N-1-i]);
  }
  int ans = std::max(g_l[N-2], g_r[1]);
  for(int i = 1; i < N-1; i++){
    ans = std::max(ans, gcd(g_l[i-1], g_r[i+1]));
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 1408
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

char s[MAX_N + 4];
int cs[2];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  for (char *cpt = s; *cpt; cpt++)
    cs[*cpt - '0']++;

  printf("%d\n", min(cs[0], cs[1]) * 2);
  return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, a, b;
  cin >> n >> a >> b;
  
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  
  sort(v.rbegin(), v.rend());
  
  double sum = 0;
  vector<ll> w;
  for (int i = 0; i < a; i++) {
    sum += v.at(i);
    w.emplace_back(v.at(i));
  }
  
  cout << fixed << setprecision(10) << sum / a << '\n';
  
  ll key = w.back();
  int count1 = 0, count2 = 0;
  for (ll i : w) {
    if (i == key) count1++;
  }
  for (ll i : v) {
    if (i == key) count2++;
  }
  
  vector<vector<ll>> c(52, vector<ll>(52));
  c[0][0] = c[1][0] = c[1][1] = 1;
  for (int i = 0; i <= 50; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0) c[i][j] = 1;
      else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
  
  ll ans = 0;
  if (w.front() != w.back()) ans = c[count2][count1];
  else {
    for (int i = a; i <= b; i++) {
      ans += c[count2][i];
    }
  }
  
  cout << ans << '\n';
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	cin >> N;
	
	vector< int > imos(100010, 0);
	for_(i,0,N) {
		int a, b;
		cin >> a >> b;
		imos[a-1]++;
		--imos[b];
	}
	
	for_(i,0,100010) imos[i+1] += imos[i];
		
	int ans = 0;
	for_(i,0,100010) if (i <= imos[i]) ans = i;
	cout << ans << endl;
}

Measured memory_bytes: 3096
import sys
n=int(input())
l=list(map(int,input().split()))
#a,b,c = map(int,input().split())
for i in l:
    if i%2==0:
        if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            sys.exit()
print("APPROVED")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M, K;
  cin >> N >> M >> K;

  bool f = false;
  REP(i, 0, N + 1) {
    REP(j, 0, M + 1) {
      ll k = i * M + j * N - i * j * 2;
      if(k == K) f = true;
    }
  }

  cout << (f ? "Yes" : "No") << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string s[2];

inline bool check() {
    if (s[0][0] != s[1][2])return false;
    if (s[0][1] != s[1][1])return false;
    if (s[0][2] != s[1][0])return false;
    return true;
}

int main() {
    rep(i, 2)cin >> s[i];
    cout << (check() ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
int main(){
	char S[101],T[101];
	scanf("%s %s",S,T);
	char initial=S[0];
	int flag;
	rep(j,strlen(S)){
		flag=1;
		rep(i,strlen(S)){
			if(S[i]!=T[(i+j)%strlen(S)]){
				flag=0;
				break;
			}
		}
		if(flag) break;
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

seen = {}


def luka(n):
    if n == 0:
        return 2
    if n == 1:
        return 1

    if n in seen.keys():
        return seen[n]
    else:
        seen[n] = luka(n-1) + luka(n-2)
        return seen[n]


N = int(input())
print(luka(N))



Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;string s;cin>>n>>s;
  int ans=0;
  for(int i=1;i<n-1;i++){
    int cnt=0;
    vector<int> l(26),r(26);
    for(int j=0;j<i;j++)l[s[j]-'a']=1;
      for(int k=i;k<n;k++)r[s[k]-'a']=1;
        rep(i,26){
          if(l[i]==1&&r[i]==1)cnt++;
        }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
int main()
{
	char a[5];
	while(gets(a))
	{
	int i,j,d=1;
	for(i=0,j=2;i<j;i++,j--)
	if(a[i]!=a[j])
	{
	d=0;
	break;
		}
	if(d==1)
	printf("Yes\n");
	else			
	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		int c = (a + b);
		int d = (a - b);
		int e = (a * b);

		if (c < d) {
			if (d < e) {
				System.out.println(e);
			} else {
				System.out.println(d);
			}
		} else if(c<e) {
			System.out.println(e);
		}
		else {
			System.out.println(c);
		}
	}
}


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

int main(){
  int n,a,b; cin >> n >> a >> b;
  if(n*a<=b){
    cout << n*a << endl;
  }
  else{
    cout << b << endl;
  }
}

Measured memory_bytes: 256