akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	ll ans=0;
	cin >>n>>m;
	ans=(100*(n-m)+1900*m)<<m;
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
/*input
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;
vector < int > v[N];
int dp[N];

int dfs(int s)
{
  if(dp[s] > -1) {
    return dp[s];
  }
  for(auto x: v[s]) {
    dfs(x);
    dp[s] = max(dp[s], dp[x] + 1); 
  }
  return dp[s];
}
int main()
{
  ifalse;
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= m; i ++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
  }

  memset(dp, -1, sizeof(dp));
  int res = 0;
  for(int i = 1; i <= n; i ++) {
    res = max(res, dfs(i));
  }
  cout << res + 1,nl;
  return 0;
}

Measured memory_bytes: 8192
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

print(s0%(10**9+7))


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

int main() {
	int n, r, A[200][200];
	cin >> n >> r;
	for(int i=0; i<n; i++){
		for(int j=0; j<r; j++){
		cin >> A[i][j];
		A[i][r] += A[i][j];
		}
	}
	for(int k=0; k<=r; k++){
		for(int l=0; l<n; l++){
			A[n][k] += A[l][k];
		}
	}

	for(int a=0; a<=n; a++){
		for(int b=0; b<r; b++){
			cout << A[a][b] << " ";
		}
		cout << A[a][r] << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<map>
#include<set>
#include<vector>
using namespace std;

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

  map<int, int> num_cnt;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    num_cnt[x]++;
  }

  long long ans = 0;
  vector<multiset<int>> res_cnt(M);
  vector<int> res_cnt_sum(M);
  for(auto pair: num_cnt){
    res_cnt[pair.first % M].insert(2 * (pair.second / 2));
    if(pair.second % 2){
      res_cnt[pair.first % M].insert(1);
    }
    res_cnt_sum[pair.first % M] += pair.second;
  }

  for(int i = 0; i * 2 <= M; i++){
    if((i == 0) || (i * 2 == M)){
      ans += res_cnt_sum[i] / 2;
      res_cnt_sum[i] %= 2;
    }else{
      int si, li;
      if(res_cnt_sum[i] <= res_cnt_sum[M - i]){
        si = i;
        li = M - i;
      }else{
        si = M - i;
        li = i;
      }
      for(auto x: res_cnt[li]){
        if(res_cnt_sum[si] > 0){
          int diff = min(res_cnt_sum[si], x);
          res_cnt_sum[si] -= diff;
          x -= diff;
          ans += diff;
        }
        ans += x / 2;
      }
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 17024
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    s = list(input())
    black_count = [0 for _ in range(n + 1)]
    ans = float('inf')

    for i, si in enumerate(s):
        if si == '#':
            black_count[i + 1] = black_count[i] + 1
        else:
            black_count[i + 1] = black_count[i]

    for j in range(n + 1):
        ans = min(ans, black_count[j] + (n - j) - black_count[n] + black_count[j])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12740
#include<cstdio>
#define mod 1000000007
#define maxn 2005
int n,k,fact[maxn*maxn],inv[maxn*maxn],dp[maxn][maxn];
void init()
{
	fact[0]=1;
	for(int i=1;i<=n*k;i++) fact[i]=1ll*fact[i-1]*i%mod;
	inv[1]=1;
	for(int i=2;i<=n*k;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	inv[0]=1;
	for(int i=1;i<=n*k;i++) inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	if(k==1) { printf("1\n"); return 0; }
	init();
	dp[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			if(i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			if(j)
			{
				int x=n*k-i-(j-1)*(k-1)-1;
				dp[i][j]=(dp[i][j]+1ll*dp[i][j-1]*fact[x]%mod*inv[k-2]%mod*inv[x-k+2]%mod)%mod;
			}
		}
	int ans=1ll*dp[n][n]*fact[n]%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 46336
#include<stdio.h>

int main(void)
{
	int i;
	int N;
	int data[200000];
	int max,min,now;
	scanf("%d",&N);

	for(i=0;i<N;i++)
	{
		scanf("%d",&data[i]);
	}
	max=data[1]-data[0];
	min=data[0];
	for(i=1;i<N;i++)
	{
		now=data[i]-min;
		if(max<now)
		{
			max=now;
		}
		if(min>data[i])
		{
			min=data[i];
		}
	}
	printf("%d\n",max);

	return 0;
}



Measured memory_bytes: 2556
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//エラトステネスの篩
void sieve(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	while (1) {
		int n, p;
		cin >> n >> p;
		if (n == 0 && p == 0)break;
		int box = p;
		vi u(n, 0);
		int i = 0;
		while (1) {
			if (box == 1 && u[i] == p - 1) {
				cout << i << endl;
				break;

			}
			if (box != 0) {
				u[i]++;
				box--;
			}
			else {
				box += u[i];
				u[i] = 0;
			}
			i++;
			i %= n;
		}
	}
	return 0;
}


Measured memory_bytes: 3020
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n;
  cin>>n;
  if(n==2){
    cout<<1;
  }else{
  ll m=n;
  int ans=2;
  for(int i=2;i<=sqrt(n-1);i++){
    if((n-1)%i==0){
      if(i!=sqrt(n-1)){
        ans++;
      }
    }
  }
  for(int i=2;i<=sqrt(m);i++){
    n=m;
    while(1){
      if(n%i!=0){
        if(n%i==1){
          ans++;
        }
        break;
      }
      n/=i;
    }
  }
  cout<<ans;
}
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

exist = False
for i in range(N-M+1):
    for j in range(N-M+1):
        match = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    match = False
        if match:
            exist = True

if exist:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 40432
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; string s; cin >> n >> s;
    map<int, int> mp;
    rep(i, n) {
        mp[s[i] - 'a'] ++;
    }
    int ans = 1;
    rep(i, 26) {
        ans *= (mp[i] + 1);
        ans %= mod;
    }
    cout << (ans + mod - 1) % mod << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli k, a, b, c, h, n, w, ans = 1, count = 1, coin = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> k >> a >> b;

  if (b - a <= 2 || k < a - 1)
  {
    ans += k;
    cout << ans << endl;
    return 0;
  }
  else
  {
    ans = a;
    k -= a - 1;
    if (k % 2 == 1)
    {
      ans++;
      k--;
    }
    ans += (b - a) * (k / 2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3644
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  if i>=K:
    ans += 1/N
  else:
    X = math.ceil(math.log2(K)-math.log2(i))
    ans += 1/N*((1/2)**X)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int i, abc[4] = { 1, 1, 1 };
	char s[4];

	scanf("%s", &s);

	for (i = 0; i < 3; i++) {
		if (s[i] == 'a') abc[0] = 0;
		if (s[i] == 'b') abc[1] = 0;
		if (s[i] == 'c') abc[2] = 0;
	}

	printf(abc[0] + abc[1] + abc[2] == 0 ? "Yes\n" : "No\n");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	long long N,Y;
	int x=0,y=0,z=0;
	cin>>N>>Y;
	//9 张钞票共Y元有没有可能
	if(Y%1000!=0){//没可能 
		cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;
	}else{//有可能 
		Y=Y/1000;
		Y=Y-N;
		//就相当于求9*x+4*y==Y-N 的全部整数解
		//从0开始   X 的最大值为  A\9
		for(int i=0;i<=Y*1.0/9;i++){
			double rr=(Y-9*i)*1.0/4;
			int tt=int(rr);
			if(tt==rr){//rr为整数  即  x=i j=rr 皆为整数 
				x=i;
				y=rr;
				if(N-x-y>=0){
					z=N-x-y;
					cout<<x<<" "<<y<<" "<<z<<endl;
					return 0; 
				}
			}
		} 
	}
	cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
#define db double
#define ll long long 
#define int long long 
int read(){
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0') f= c=='-' ? -1:1,c=getchar();
	while(c<='9'&&c>='0') x=10*x+c-'0',c=getchar();
	return x*f;
}
int a[N],n,psum[N];
int f1[N],f2[N],tf[N];
int A[N],S[N],frm[N];
db getfl(int i,int j){return 1.0*(A[i]-A[j])/(1.0*i-j);}
void getit(int f[]){
	int top=0;
	S[++top]=0;
	for(int i=1;i<=n;i++){
		while(top>1 &&getfl(S[top-1],S[top])<=i) top--;
		f[i]= A[S[top]]-i*S[top]+(i*i+i)/2-psum[i] ;
		frm[i]=S[top];
		f[i]=max(f[i],f[i-1]);
		A[i]=f[i]+(i*i-i)/2+psum[i];
		while(top>1 && getfl(i,S[top]) > getfl(S[top],S[top-1]) ) top--;
		S[++top]=i;
	}
}
void readit(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),psum[i]=a[i]+psum[i-1];
	getit(f1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++) psum[i]=a[i]+psum[i-1];
	getit(f2);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++) psum[i]=a[i]+psum[i-1];
	reverse(f2+1,f2+n+1);
}
int tmx[N];
void find(int *tf1,int *tf2,int l,int r){
	if(l==r){
		tf[l]=max(tf[l],tf1[l-1]+tf2[l+1]-a[l]+1);
		return;
	}
	int mid=(l+r)>>1,top=0;
	for(int i=l-1;i<mid;i++){//鎵斿埌鍗曡皟鏍堥噷闈㈠幓
		A[i]=i*(i-1)/2 +tf1[i]+psum[i];
		while(top>1&& getfl(S[top],S[top-1])<=getfl(i,S[top-1]) ) top--;
		S[++top]=i;
	}
	for(int i=mid;i<=r;i++){ // 鍦ㄥ崟璋冩爤閲岄潰鏌ユ壘
		while(top>1&&getfl(S[top],S[top-1])<=i) top--;
		int pos=S[top];
		tmx[i]= tf1[pos]+tf2[i+1] + (i-pos)*(i-pos+1)/2 -(psum[i]-psum[pos]);
	}
	for(int i=r-1;i>=mid;i--) tmx[i]=max(tmx[i],tmx[i+1]);
	for(int i=mid;i<=r;i++) tf[i]=max(tf[i],tmx[i]);
	find(tf1,tf2,l,mid);
	find(tf1,tf2,mid+1,r);
}
void CDQ(){
	find(f1,f2,1,n);
	//for(int i=1;i<=n;i++) printf("%d ",f1[i]); cout<<endl;
	//for(int i=1;i<=n;i++) printf("%d ",f2[i]); cout<<endl;
	reverse(a+1,a+n+1);
	reverse(f1+1,f1+1+n),reverse(f2+1,f2+1+n),reverse(tf+1,tf+1+n);
	for(int i=1;i<=n;i++) psum[i]=psum[i-1]+a[i];
	find(f2,f1,1,n);
	reverse(a+1,a+n+1);
	reverse(f1+1,f1+1+n),reverse(f2+1,f2+1+n),reverse(tf+1,tf+1+n);
}
signed main()
{
	
	readit();
	for(int i=1;i<=n;i++) tf[i]=1-a[i];
	CDQ();
	int m=read();
//	for(int i=1;i<=n;i++) printf("%d ",f1[i]);cout<<endl;
//	for(int i=1;i<=n;i++) printf("%d ",f2[i]);cout<<endl;
//	for(int i=1;i<=n;i++) printf("%d ",tf[i]);cout<<endl;
	while(m--){
		int p=read(),v=read(),t;
		int ans=f1[p-1]+f2[p+1];
		ans=max(ans,tf[p]+a[p]-v);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = 507;

ll a[MAX_N], k, r[MAX_N];
int n;

inline bool check(ll div)
{
	ll ops = k, bal = 0;

	for(int i = 0; i < n; ++i)
		r[i] = a[i] % div;

	sort(r, r + n);

	for(int i = 0; i < n; ++i)
	{
		ll take = min(ops, r[i]);

		bal += take;
		ops -= take;
		r[i] -= take;
	}

	for(int i = 0; i < n; ++i)
	{
		ll take = (div - r[i]) % div;

		if(take > bal)
			return false;

		r[i] = (r[i] + take) % div;
		bal -= take;
	}

	return bal % div == 0;
}

void solve()
{
	cin >> n >> k;
	ll sum = 0;

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

	ll answ = 0;

	for(ll div = 1; div * div <= sum; ++div)
	{
		if(sum % div == 0)
		{
			if(check(div))
				answ = max(answ, div);

			if(check(sum / div))
				answ = max(answ, sum / div);
		}
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

typedef long long       ll;
const int MAX=2e5+9;
int n, a[MAX];
ll freq[MAX], sum;

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

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

    for (int i=1; i<=200000; ++i) {
        sum+=freq[i]*(freq[i]-1)/2;
    }

    for (int i=1; i<=n; ++i) {
        sum-=freq[a[i]]*(freq[a[i]]-1)/2;
        --freq[a[i]];
        sum+=freq[a[i]]*(freq[a[i]]-1)/2;
        cout << sum << "\n";

        sum-=freq[a[i]]*(freq[a[i]]-1)/2;
        ++freq[a[i]];
        sum+=freq[a[i]]*(freq[a[i]]-1)/2;
    }

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    ll t = min(N,M/2);

    N-=t;
    M-=2*t;

    if (M>=4) {
        t+=M/4;
    }
    cout << t << endl;
}

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

using namespace std;
 
set<int> m1[201][201];
bool m2[201][201];
 
int stoi(string s) {
	stringstream ss; ss << s;
	int ret; ss >> ret;
	return ret;
}
 
string str;
set<int> dp(int l, int r) {
	if (m2[l][r]) return m1[l][r];

	set<int> ret;
	bool f = true;
	for (int i = l; i < r; ++i) {
		if (!isdigit(str[i])) f = false;
	}
	if (f) {
		ret.insert( stoi(str.substr(l, r-l)) );
	}
	else {
		int depth = 0;
		for (int i = l; i < r; ++i) {
			switch (str[i]) {
				case '(':
					++depth;
					break;

				case ')':
					--depth;
					break;

				case '+':
				case '-':
				case '*':
				case '/':
				if (depth == 0) {
					set<int> L = dp(l, i), R = dp(i+1, r);
					for (set<int>::iterator j = L.begin(); j != L.end(); ++j) {
						for (set<int>::iterator k = R.begin(); k != R.end(); ++k) {
							switch (str[i]) {
								case '+': ret.insert(*j+*k); break;
								case '-': ret.insert(*j-*k); break;
								case '*': ret.insert((*j)*(*k)); break;
								case '/': if (*k) ret.insert((*j)/(*k)); break;
							}
						}
					}
				}
				break;
			}
		}
		if (!ret.size() && str[l] == '(' && str[r-1] == ')') ret = dp(l+1, r-1);
	}
	return m2[l][r] = true, m1[l][r] = ret;
}
 
int main() {
	while (cin >> str, str != "#") {
		fill(&m2[0][0], &m2[0][0]+201*201, false);
		cout << dp(0, str.size()).size() << endl;
	}
}

Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#define INFi LLONG_MAX;
int main()
{
   ll n,m;
   cin >> n >> m;
   string s[n];
   for(ll i=0;i<n;i++)    cin >> s[i];
   ll dp[n][m];
   memset(dp,0,sizeof(dp));
   dp[0][0] = 1;
   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j<m;j++)
       {
           if(s[i][j]=='.'){
           if(i-1>=0)     dp[i][j] += dp[i-1][j];
           dp[i][j] %= MOD;
           if(j-1>=0)     dp[i][j] += dp[i][j-1];
           dp[i][j] %= MOD;}
       }
   }
   cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
S = list(input())
n = len(S)
for j in range(n):
	S[j] = int(S[j])
cnt = 0
for i in range(n-1):
	if S[i] == S[i+1]:
		S[i+1] = abs(S[i]-1)
		cnt += 1
print(cnt)

Measured memory_bytes: 81432
N,*A = `dd`.split.map &:to_i
Mod = 10**9 + 7
dp = Array.new(N+1,0)
dp[0] = 1
h = {}
(1..N).each{ |i|
  a = A[i-1]
  dp[i] = dp[i-1]
  if h[a] && h[a] < i-1
    dp[i] += dp[h[a]]
  end
  dp[i] %= Mod
  h[a] = i
}
p dp[-1]


Measured memory_bytes: 31496
let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let vs = Array.make n 0 in
  let cs = Array.make n 0 in
  let res = ref 0 in
  for i = 0 to n - 1 do
    Scanf.scanf (if i <> n - 1 then "%d " else "%d\n") (fun v -> vs.(i) <- v);
  done;
  for i = 0 to n - 1 do
    Scanf.scanf (if i <> n - 1 then "%d " else "%d\n") (fun c -> cs.(i) <- c);
  done;
  for i = 0 to n - 1 do
    let r = vs.(i) - cs.(i) in
    if r > 0 then res := !res + r;
  done;
  print_int !res

Measured memory_bytes: 384
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  a := make([]int, n)
  for i := 0; i < n ; i++ {
      a[i] = nextInt()
  }

  for i, e := range a{
    fmt.Print(e)
    if i != n - 1 { 
     fmt.Print(" ")
    } else {
     fmt.Println()
    }   
  }   

  for i := 1; i <= n - 1; i++ {
      v := a[i]
      j := i - 1 
      for j >= 0 && a[j] > v { 
          a[j+1] = a[j]
          j-- 
          a[j+1] = v 
      }

      for i, e := range a{
        fmt.Print(e)
        if i != n - 1 {
         fmt.Print(" ")
        } else {
         fmt.Println()
        }
      }
  }
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}



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

using namespace std;

int main()
{
	int D, x, y, p;
	char s[10];
	vector<int> xs, ys;

	scanf("%d", &D);

	scanf("%d", &x);
	for (int i = 0; i < x; i++){
		scanf("%s", s); scanf("%d", &p);
		if (s[0] == 'D') xs.push_back(p);
	}

	scanf("%d", &y);
	for (int i = 0; i < y; i++){
		scanf("%s", s); scanf("%d", &p);
		if (s[0] == 'D' && s[1] == 'D') ys.push_back(p);
	}

	sort(xs.rbegin(), xs.rend()); sort(ys.rbegin(), ys.rend());
	int tmp = 0, ans = 0;
	for (int i = 0; i <= xs.size(); i++){
		if (i) tmp += xs[i - 1];
		int tmp2 = 0;
		for (int j = 0; j <= ys.size(); j++){
			if (j) tmp2 += ys[j - 1];
			if (i + 2 * j <= D) ans = max(ans, tmp + tmp2);
		}
	}
	
	printf("%d\n", ans);

	return (0);
}

Measured memory_bytes: 1216
# coding: utf-8
# Your code here!

a,b,c=input().split()

#print(a)
#print(b)
#print(c)

i=0
num=int(a)
count=0

while(i!=int(b)-int(a)+1): 
    #print("1")
    if (num%int(c)==0):
        count+=1
    num+=1
    i+=1
print(count)


Measured memory_bytes: 9092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

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

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


    int N, t;
    cin >> N;

    vi C(N), V(N);

    REP(i,N) {
        cin >> t;
        V[i] = t;
    }

    REP(i,N) {
        cin >> t;
        C[i] = t;
    }

    int ans = 0;
    REP(i,N) {
        if (V[i]-C[i] > 0) ans += (V[i]-C[i]);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    long long int A, B, N;
    cin>>A>>B>>N;

    long long int m = min(B-1, N);
    cout<< (A*m)/B - A*(m/B);

    return 0;
}



Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>

int main() {
  int N = 1299709;
  std::vector<int> s(N+1);
  for (int i=2; i*i<=N; ++i) {
    if (s[i]) continue;
    for (int j=i*i; j<=N; j+=i) {
      s[j] = i;
    }
  }

  std::set<int> p;
  for (int i=2; i<=N; ++i)
    if (s[i] == 0) p.insert(i);

  while (true) {
    int n;
    scanf("%d", &n);
    if (n == 0) break;

    if (p.count(n)) {
      puts("0");
      continue;
    }

    auto it = p.lower_bound(n);
    int ub = *it;
    int lb = *--it;
    printf("%d\n", ub-lb);
  }
}



Measured memory_bytes: 11932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] pointInfo = new int[n][d];
		for(int i =0;i <n;i++) {
			for(int j =0;j <d;j++) {
				pointInfo[i][j] = sc.nextInt();
			}
		}
		int answer =0;
		for(int i = 0; i < n-1;i++) {
			for(int j = i +1; j < n;j++) {
				int kyori = 0;
				for(int k =0;k <d;k++) {
					kyori += (pointInfo[j][k]- pointInfo[i][k]) * (pointInfo[j][k]- pointInfo[i][k]);
				}
				int l =1;
				while(l <=16000) {
					if(l * l == kyori) {
						answer++;
						break;
					}
					l++;
				}
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23508
from sys import stdin
[N, M] = [int(x) for x in stdin.readline().rstrip().split()]

H =  [int(x) for x in stdin.readline().rstrip().split()]

highest_neighbor = [-1 for _ in range(N)]
for i in range(M):
    [a, b] = [int(x) for x in stdin.readline().rstrip().split()]
    a-=1
    b-=1
    if H[b]>highest_neighbor[a]:
        highest_neighbor[a] = H[b]
    if H[a]>highest_neighbor[b]:
        highest_neighbor[b] = H[a]

tot = 0
for i in range(N):
    if H[i] > highest_neighbor[i]:
        tot+=1
print(tot)



Measured memory_bytes: 85056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

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

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    cout << (double)((n + 1) / 2) / (double)n << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] b = new int[n][3][2];
        ;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 3; j++)
                for (int k = 0, h, m; k < 2; k++)
                    b[i][j][k] = sc.nextInt() * 60 + sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++) {
                    int res = 0;
                    for (int p = 0; p < n; p++) {
                        if (b[p][0][0] <= b[i][0][1] && b[i][0][1] <= b[p][0][1] &&
                                b[p][1][0] <= b[j][1][1] && b[j][1][1] <= b[p][1][1] &&
                                b[p][2][0] <= b[k][2][1] && b[k][2][1] <= b[p][2][1])
                            res++;
                    }
                    ans = Math.max(ans, res);
                }
        System.out.println(ans);
    }
}



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

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(int i=K;i<N;i++){
    if(vec.at(i-K)>=vec.at(i)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
    
  
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define file freopen("in.txt", "r", stdin);
#define pii pair<int, int>
#define pll pair<ll, ll>

struct DATA{
	int a, b, c;
};
const int maxn = 1e5 + 5;
DATA arr[maxn];
int n;
ll dp[maxn][4], inf = 1e15;

ll call(int i, int last){
	if(i >= n+1)return 0;
	if(dp[i][last] != -1)return dp[i][last];
	ll ret = 0;
	if(last == 1){
		ret = max(ret, arr[i].b + call(i+1, 2));
		ret = max(ret, arr[i].c + call(i+1, 3));
	}	
	if(last == 2){
		ret = max(ret, arr[i].a + call(i+1, 1));
		ret = max(ret, arr[i].c + call(i+1, 3));
	}
	if(last == 3){
		ret = max(ret, arr[i].a + call(i+1, 1));
		ret = max(ret, arr[i].b + call(i+1, 2));
	}
	return dp[i][last] = ret;
}

int main(){
	//file
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		arr[i] = {x, y, z};
	}
	ll ans = 0;
	memset(dp, -1, sizeof dp);
	ans = max(ans, call(1, 1)+arr[0].a);
	memset(dp, -1, sizeof dp);
	ans = max(ans, call(1, 2)+arr[0].b);
	memset(dp, -1, sizeof dp);
	ans = max(ans, call(1, 3)+arr[0].c);
	cout<<ans<<endl;
}

Measured memory_bytes: 9216
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

cnt1 = Counter(v[::2]).most_common()
cnt2 = Counter(v[1::2]).most_common()
cnt1 += [(-1,0)]
cnt2 += [(-1,0)]
if cnt1[0][0] != cnt2[0][0]:
    print(n - (cnt1[0][1] + cnt2[0][1]))
else:
    print(n - max(cnt1[1][1] + cnt2[0][1], cnt1[0][1] + cnt2[1][1]))

Measured memory_bytes: 20572
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll get_cnt(ll n) {
    ll cnt = 0;
    while (n % 2 == 0) cnt++, n /= 2;
    return cnt;
}

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    while (b) {
        ll x = a, y = b;
        a = y, b = x % y;
    }

    return a;
}

int main()
{
    ll N, M; cin >> N >> M;
    vll a(N); rep(i, N) {
        ll num; cin >> num; a[i] = num / 2;
    }

    ll d = get_cnt(a[0]);
    rep(i, N) if (get_cnt(a[i]) != d) {cout << 0 << endl; return 0;}

    ll lcm = 1;
    rep(i, N) {
        lcm = lcm * a[i] / gcd(lcm, a[i]);
    }
    //cout << lcm << endl;

    cout << (M / lcm + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
def solution():
    user_input = input()
    animals, legs = [int(x) for x in user_input.split()]

    turtles = (4*animals - legs) / 2
    condition = turtles >= 0 and turtles <= animals and turtles % 1 == 0 
    if condition:
        print("Yes")
    else:
        print("No")

solution()

Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

long long S(long long n) {
	long long ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll mypow(ll b, ll n) {
	return n == 0 ? 1 : b * mypow(b, n - 1);
}

long long snuke(long long n) {
	//priority_queue<pair<double, ll>, vector<pair<double, ll>>, greater<pair<double, ll>>>val;
	GPQ<pair<double, ll>> val;
	long long dig = 0;
	while (mypow(10,dig)<=n) {
		for (long long i = 1;i<=9;++i) {//★★
			long long v = n - n % (mypow(10, dig + 1)) + i * mypow(10, dig) - 1;
			if (v >= n) {
				val.push(make_pair(v * 1.0 / S(v), v));
			}
		}
		++dig;
	}
	--dig;    
	
	// 1桁もnと一致しないものを列挙
	for (ll i = 1; i <= 100; ++i) {
		ll v = i * mypow(10, dig) - 1;
		if (v >= n) {
			val.push(make_pair(v * 1.0 / S(v), v));
		}
	}

	auto ret = val.top();
	// g(m)とmが最小となる(g(m), m)の組

	return ret.second;
}


int main() {
	long long K;
	cin >> K;
	long long pre = 1;
	for (long long i = 0;i<K;++i) {
		cout << pre <<endl;
		pre = snuke(pre+1);
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int x[n+2];
    for(int i = 0; i < n; i++){
            cin >> x[i];
    }
    for(int i =0;  i <n; i++){
        int y;
        cin >> y;
        if(x[i] > y) ans += (x[i] - y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<int> l(n), r(n);
    l[0] = a[0];
    r[n - 1] = a[n - 1];
    for(int i = 1; i < n; i++) l[i] = gcd(l[i - 1], a[i]);
    for(int i = n - 2; i >= 0; i--) r[i] = gcd(r[i + 1], a[i]);
    int ans = 0;
    rep(i, 0, n){
        int tmp;
        if(i == 0) tmp = r[1];
        else if(i == n - 1) tmp = l[n - 2];
        else tmp = gcd(l[i - 1], r[i + 1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	BigInteger a = sc.nextBigInteger();
	BigInteger b = sc.nextBigInteger();
	
	if(a.compareTo(b)==1){
		System.out.println("GREATER");
	}else if (a.compareTo(b)==-1) {
		System.out.println("LESS");
	}else {
		System.out.println("EQUAL");
	}
	}
}


Measured memory_bytes: 21840
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	double n;
	cin >> n;
	cout << ceil(n / 2) << endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;



public class Main
{
    public static void main(String [] args)
    {
        Scanner key = new Scanner(System.in);
        int num = key.nextInt();
        key.nextLine();
        String s = key.nextLine();
        long ca =0;
        long cb = 0;
        long cc = 0;
        
        for(int i = 0; i<num ; i++)
        {
            char c = s.charAt(i);
            if(c == 'R')
                ca ++;
            else if(c == 'G')
                cb ++;
            else
                cc++;

        }
        long total = ca * cb * cc;

        for(int j = 0; j<num; j++)
        {
            for(int k = 0; k<num; k++)
            {
                int a = j + k;
                int b = a + k;
                if(b>=num) 
                    break;
                else
                {
                    if(s.charAt(j) != s.charAt(a) && s.charAt(j) != s.charAt(b) && s.charAt(a) != s.charAt(b))
                        total = total - 1;
                }
                
            }
        }

        System.out.println(total);
        
    }
}

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

typedef long long ll;

ll memo[1000000]={0};
const ll MOD = 1000000000+7;

ll factorial(ll n){
    ll res = 1;
  	for(ll i = 2; i <= n; i++){
      res = (res * i) % MOD;
    }
  	return res;
}

ll power(ll a, ll n){
 	ll x = 1;
  	while(n > 0){
     	if (n & 1){
         	x = (a *x) % MOD; 
        }
      	a = (a * a) % MOD;
      	n >>= 1;
    }
  	return x;
}

ll comb(ll n, ll k){
 	ll a = factorial(n) % MOD;
  	ll b = factorial(n-k) % MOD;
  	ll c = factorial(k) % MOD;
  	return (((a * power(b, MOD-2)) % MOD) * power(c, MOD-2)) % MOD;
}

int main(void){

    ll X, Y;
    cin >> X >> Y;
    
    if((X+Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }else{
        ll n = (2*Y - X) / 3;
        ll m = (2*X - Y) / 3;
        if (n < 0 || m < 0){
            cout << 0 << endl;
            return 0;
        }else{
            cout << comb(m+n, m) << endl;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
   	int n;
    
    long long number, perPrice, amount;
    
    bool isUsed;
    //long long valueCheck[4000];
    vector<long long> valueCheck(4001, 0);
    queue<int> que;
    
    while(true)
    {
        isUsed = false;
        
        cin>>n;
        
        if (n == 0)
        {
            break;
        }
        
        while(n--)
        {
            cin>>number>>perPrice>>amount;
            
            valueCheck[number] += perPrice * amount;
            que.push(number);
        }
        
        while (!que.empty()) //if empty return true
        {
            if (valueCheck[que.front()] >= 1000000) //check the first element
            {
                cout<<que.front()<<endl;
                
                isUsed = true;
            }
            
            valueCheck[que.front()] = 0;
            
            que.pop(); //delete the beginning element, do the next judgement
        }
        
        if (!isUsed)
        {
            cout<<"NA"<<endl;
        }
        
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1256
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
close = 300

for i in range(-105,105):
    if i not in p:
        if abs(x-i) < abs(close-x):
            close = i
        elif abs(x-i) == abs(close-x):
            close = min(close, i)

# print(i)
print(close)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}

const int nn=50;
ll x[nn][nn],n,kk,gg=0;
void multi(ll a[nn][nn], ll b[nn][nn], ll temp[nn][nn]){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            temp[i][j] = 0;
            for(int k=0;k<n;k++){
                temp[i][j] =( temp[i][j] +(a[i][k] * b[k][j])  % mod) % mod;
            }
        }
    }
}
void power(ll a[nn][nn] ,ll req[nn][nn], ll k){
    if(k==0){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)
                    req[i][j] = 1;
                else
                    req[i][j] = 0;
            }
        }
        return;
    }   
    ll temp[nn][nn];
    power(a,temp,k/2);
    multi(temp,temp,req);
    if(k%2){
        multi(x,req ,temp);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                req[i][j] = temp[i][j];
            }
        }
    }
}
int main(){
    cin>>n>>kk;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cin>>x[i][j];
    }
    ll temp[nn][nn];
    power(x, temp, kk);
    // power(x, temp, 1);
     for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            // cout<<temp[i][j]<<" ";
            gg += temp[i][j];
        }
        // cout<<endl;
    }
    cout<<gg%mod;
}

Measured memory_bytes: 1536
package main

import (
	"fmt"
	"math"
)

func main() {
	n := Int1()
	n100 := n * 100
	ans := int(math.Ceil(float64(n100) / float64(108)))
	tax := 1.08

	if int(float64(ans)*tax) == n {
		fmt.Println(ans)
	} else {
		fmt.Println(":(")
	}
}

func Str1() string {
	var s string
	fmt.Scan(&s)
	return s
}

func Int1() int {
	var x int
	fmt.Scan(&x)
	return x
}

func Int2() (int, int) {
	var x, y int
	fmt.Scan(&x, &y)
	return x, y
}

func Int3() (int, int, int) {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	return x, y, z
}

func IntSlice(n int) []int {
	slice := make([]int, n)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	return slice
}

func SumSlice(slice []int) int {
	total := 0
	for i := range slice {
		total += slice[i]
	}
	return total
}

func Min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func IntPow(x, pow int) int {
	return int(math.Pow(float64(x), float64(pow)))
}


Measured memory_bytes: 1776