akhauriyash/Code-Regression huggingface dataset:
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: usize = read();
    let n: usize = read();
    let mut arr: Vec<usize> = (0..n).map(|_| read()).collect();
    arr.push(k + arr[0]);
    let mut ans = 0;
    for i in 0..n {
        ans = max(ans, arr[i + 1] - arr[i]);
    }
    println!("{}", k - ans);
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C){
    vector<long long> v = {A, B, C};
    sort(v.begin(), v.end());
    if (v[0] == 5 and v[1] == 5 and v[2] == 7) {
	cout << YES << endl;
    } else {
	cout << NO << endl;
    }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int const maxN=100001;
int a[maxN],place[maxN];
long long ncr[maxN],mcr[maxN];
long long const p=1e9+7;
long long inv(long long n){
    long long r0=n,r1=p,r2,a0=1,a1=0,a2,b0=0,b1=1,b2,q1;
    while(r1>0){
        q1=r0/r1;
        r2=r0%r1;
        a2=a0-q1*a1;
        b2=b0-q1*b1;
        r0=r1;
        r1=r2;
        a0=a1;
        a1=a2;
        b0=b1;
        b1=b2;
    }
    while(a0<0)a0+=p;
    return a0%p;
}
int main(){
    int n,m;
    scanf("%d",&n);
    for(int i=0;i<=n;i++)place[i]=-1;
    for(int i=0;i<=n;i++){
        scanf("%d",&a[i]);
        if(place[a[i]]>=0){
            m=n-i+place[a[i]];
            break;
        }else{
            place[a[i]]=i;
        }
    }
    ncr[0]=1;
    mcr[0]=1;
    for(int i=1;i<=n+1;i++){
        long long invi=inv(i);
        ncr[i]=(ncr[i-1]*(n+1-i+1)%p)*invi%p;
        mcr[i]=(mcr[i-1]*(m-i+1)%p)*invi%p;
    }
    for(int i=1;i<=n+1;i++){
        printf("%lld\n",(ncr[i]+p-mcr[i-1])%p);
    }
    return 0;
}

Measured memory_bytes: 3456
a=int(input())
while a!=0:
    M=0
    m=1000
    sam=0
    for i in range(a):
        b=int(input())
        sam+=b
        M=max(M,b)
        m=min(m,b)
    print(int((sam-M-m)/(a-2)))
    a=int(input())


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

int main()
{
    int max, total, num = 0;
    cin >> max >> total;

    for (int i = 0; i <= max; i++)
    {
        for (int t = 0; t <= max; t++)
        {
            int sub = total - (i + t);
            if (0 <=sub && sub <= max)
            {
                num++;
            }
        }
    }
    
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static void solve() throws Exception {
		int tests = scanInt();
		for (int test = 0; test < tests; test++) {
			long a = scanLong(), b = scanLong(), c = scanLong(), d = scanLong();
			long g = gcd(b, d), r = a % g;
			out.println(a < b || d < b || (c + g - r) / g * g + r < b ? "No" : "Yes");
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;



int main()
{
    ll n;
    cin>>n;
    ll wa=0,ac=0,tle=0,re=0;

    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="RE")
            re++;
        else if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;

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

    	return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		String result = "Yay!";

		if(Math.abs(a-b)>k) {
			result=":(";
		}
		if(Math.abs(a-c)>k) {
			result=":(";
		}
		if(Math.abs(a-d)>k) {
			result=":(";
		}
		if(Math.abs(a-e)>k) {
			result=":(";
		}
		if(Math.abs(b-c)>k) {
			result=":(";
		}
		if(Math.abs(b-d)>k) {
			result=":(";
		}
		if(Math.abs(b-e)>k) {
			result=":(";
		}
		if(Math.abs(c-d)>k) {
			result=":(";
		}
		if(Math.abs(c-e)>k) {
			result=":(";
		}
		if(Math.abs(d-e)>k) {
			result=":(";
		}

		System.out.print(result);
	}

}

Measured memory_bytes: 24020
#include <iostream>

using namespace std;

int main()
{
    int n,mas[105]={1000000000},in,ans=0;
    cin>>n;
    for(int i=0; i<n-1; i++){
        cin>>in;
        mas[i]=min(mas[i],in);
        ans+=mas[i];
        mas[i+1]=in;
    }
    cout<<ans+mas[n-1];
}


Measured memory_bytes: 256
N = int(input())
c = input()
w = []
r = []
for i, ci in enumerate(c):
    if ci == 'W':
        w.append(i)
    if ci == 'R':
        r.append(i)
# print(w, r)
answer = 0
lenw = len(w)
lenr = len(r)
while answer < min(lenr, lenw) and w[answer] < r[-answer-1]:
    # print(w[answer], r[-answer])
    answer += 1
print(answer)

Measured memory_bytes: 17296
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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


#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

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

	lint a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	YES(a[0] == 5 && a[1] == 5 && a[2] == 7);

	gc();
}

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

using namespace std;

int main(){

int N;
cin >> N;
long long A[N+2];
for(int i=1;i<=N+1;i++){
cin >> A[i];
}
long long B[N+2];
for(int i=1;i<=N;i++){
cin >> B[i];
}
B[0]=0;
B[N+1]=0;
long long ans=0;
for(int i=1;i<=N+1;i++){
    if(A[i]<B[i-1]){
    ans+=A[i];
    A[i]=0;
    }
    else{
    A[i]-=B[i-1];
    ans+=B[i-1];
    }
    if(A[i]<=B[i]){
    B[i]-=A[i];
    ans+=A[i];
    }
    else{
    ans+=B[i];
    B[i]=0;
    }
} 


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

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int>S(n),T(m);
        int sumS=0,sumT=0;
        for(int i=0;i<n;i++){
            cin>>S[i];
            sumS+=S[i];
        }
        for(int i=0;i<m;i++){
            cin>>T[i];
            sumT+=T[i];
        }
        int ans=100000000,ss,tt;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int s=sumS+T[j]-S[i];
                int t=sumT+S[i]-T[j];
                if(s==t&&T[j]+S[i]<ans){
                    ss=S[i];tt=T[j];ans=ss+tt;
                }
            }
        }
        if(ans==100000000)cout<<-1<<endl;
        else cout<<ss<<" "<<tt<<endl;
    }
}

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

int main() {
  string ans;
  int Q;
  cin >> ans >> Q;
  bool rev = false;
  int cnt = 0;
  int L = ans.length();

  for (int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
      cnt++;
      continue;
    }

    if (t == 2) {
      if (ans.length() == L && rev == 1) {
        reverse(ans.begin(), ans.end());
        rev = 0;
      }
      int f;
      string c;
      cin >> f >> c;

      if (f == 1) {
        if (rev == false) {
          ans.insert(0, c);
        } else {
          ans += c;
        }
      } else if (f == 2) {
        if (rev == false) {
          ans += c;
        } else {
          ans.insert(0, c);
        }
      }
    }
  }

  if (ans.length() == L && rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
  }

  if (!rev) {
    cout << ans << endl;
  } else if (rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}
ll lpow(ll a,ll b){
  ll i,res=1;
  rep(i,b){
    res*=a;
  }
  return res;
}

struct unionfind{
  vector<ll> par,treesize;
  unionfind(ll N){
    par.resize(N);
    for(ll i=0;i<N;i++)par[i]=i;
    treesize.resize(N);
    for(ll i=0;i<N;i++)treesize[i]=1;
  }
  ll root(ll x){
    ll r;
    if(par[x]==x)return x;
    r=root(par[x]);
    if(par[x]!=r){
      treesize[r]+=treesize[x];
      treesize[x]=0;
      par[x]=r;
    }
    return r;
  }
  void unite(ll x,ll y){
    ll px=root(x);
    ll py=root(y);
    if(px!=py){
      par[px]=py;
      treesize[py]+=treesize[px];
      treesize[px]=0;
    }
  }
  bool parcheck(ll x,ll y){
    ll px=root(x);
    ll py=root(y);
    return px==py;
  }
  ll size(ll x){
    ll px=root(x);
    return treesize[px];
  }
};

int main(){
  ll i,j=0,N,M,cnt=0;
  cin>>N;
  vec v(N+1,1);
  if(N<2){cout<<1<<endl;return 0;}
  For(i,2,N+1){
    v[i]=v[i-1]+v[i-2];
  }
  cout<<v[N]<<endl;
}


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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	cin>>n;
	ll S; cin>>S;
	ll x[n], p[n];
	f(i,0,n) cin>>x[i]>>p[i];
	ll ans = 0;
	function<int(int,int)> dfs = [&](int i, int j) {
		if (x[i]>S) {ans += x[j]-S; return j;}
		else if (x[j]<S) {  ans += S-x[i]; return i; }
		else {
			if (p[i]>=p[j]) {
				p[i] += p[j];
				ans += x[j]-x[dfs(i,j-1)];
				return j;
			} else {
				p[j] += p[i];
				ans += x[dfs(i+1,j)]-x[i];
				return i;
			}
		}
	};
	dfs(0,n-1);
	cout << ans << endl;
		

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 6912
n = int(input())
s = []
for _ in range(n):
    s.append(sorted(input())) 
s = sorted(s)

 
a = []
x = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
else:
    a.append(x)

 
y = 0
for j in a:
    y += j*(j-1)/2
 
print(int(y))

Measured memory_bytes: 25420
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     ll s,w;
     cin>>s>>w;
     if(w>=s) cout<<"unsafe";
     else cout<<"safe";     
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3804
s=str(input())[:-1]
if len(s)%2!=0:
    s=s[:-1]
a=len(s)//2
for i in range(len(s)):
    if s[0:a]==s[a:]:
        print(a*2)
        break
    else:
        a-=1
        s=s[:-2]

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a,f[5]={0};
	for(int i=0;i<6;i++){
	    cin>>a;
	    f[a-1]++;
	}
	sort(f,f+4);
	if(f[0]==1 && f[1]==1 && f[2]==2 && f[3]==2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	
}

Measured memory_bytes: 256
function main()
	lines=readlines()
	H,W=map(x->parse(Int,x),split(shift!(lines)))
	S=Array{Int,2}(H,W)
	for i in 1:H
		s=shift!(lines)
		for j in 1:W
			S[i,j]=s[j]=='.'
		end
	end
	dp1=copy(S)
	dp2=copy(S)
	dp3=copy(S)
	dp4=copy(S)
	for i=1:H,j=1:W
		if i>1
			dp1[i,j]=S[i,j]*(dp1[i-1,j]+1)
			dp2[H-i+1,j]=S[H-i+1,j]*(dp2[H-i+2,j]+1)
		end
		if j>1
			dp3[i,j]=S[i,j]*(dp3[i,j-1]+1)
			dp4[i,W-j+1]=S[i,W-j+1]*(dp4[i,W-j+2]+1)
		end
	end
	println(maximum(dp1+dp2+dp3+dp4)-3)
end
main()


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

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

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

#define MOD 2019

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

  ll l, r;
  cin >> l >> r;

  ll L = l % MOD;
  ll R = r % MOD;
  if(r - l >= 2019)
    cout << 0 << endl;
  else if(R < L)
    cout << 0 << endl;
  else{
    ll minx = 2019;
    for(int i = L; i <= R; i++){
      for(int j = i+1; j <= R; j++){
        ll tmp = i * j % MOD;
        if(minx > tmp)
          minx = tmp;
      }
    }

    cout << minx << endl; 
  }



}




Measured memory_bytes: 256
n = int(input())
s = input()
t = input()

if (n == len(s) and (s == t)):
    print(n)
else:
    ind = [0]
    for i in range(1, len(s)):
        if s[-i:] == t[:i]:
            ind.append(i)

    ind.reverse()
    for i in ind:
        if i == 0:
            print(2*n)
        else:
            res = s[0:-i] + t
            if len(res) >= n:
                print(len(res))
                break

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(2*c < a+b){
    int ans = 0;
    if(x < y){
      if(b < 2*c){
        cout << (2*c*x + (y-x)*b) << endl;
        return 0;
      }else{
        cout << 2*c*y << endl;
        return 0;
      }
    }else{
      if(a < 2*c){
        cout << (2*c*y + (x-y)*a) << endl;
        return 0;
      }else{
        cout << 2*c*x << endl;
        return 0;
      }
    }
  }else{
    cout << (a*x + b*y) << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    string S;
    cin >> S;
    string S2(3, 'a');
    for (uint i=0; i<=2; i++) {
        S2[i] = S[i];
    }
    cout << S2 << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <typeinfo>
#include <math.h>
#include <stdio.h>

#define PI 3.141592653589793238462643383279

using namespace std;

double degree (double h, double m){
    double ans;
    double M = 6 * m;
    double H = h * 30 + m / 2;
    if (H < M){
        double a = M - H;
        double b = H + 360 - M;
        if (a < b){
            ans = a;
        }
        else{
            ans = b;
        }
    }
    else {
        double a = H - M;
        double b = M + 360 - H;
        if (a < b){
            ans = a;
        }
        else{
            ans = b;
        }
    }
    return ans;
}

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double d = degree(H, M);
    double r = d * PI / 180;
    double y = cos(r);
    double c = A * A + B * B - 2 * A * B * y;
    double ans = sqrt(c);
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4212
# 1 "127_abc_f.cpp"
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;

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

#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i,s,e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i,s,e) for (int(i) = (s); (i) > (e); (i)--)

#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);


template<typename type>
struct BIT0 {
 int N;
 int nn;
 vector<type> data;

 BIT0(int n) {
  N = n + 1;
  data = vector<type>(n + 1, 0);
  nn = 1;
  while (nn * 2 <= N)nn *= 2;
 }
 void add(int i, type w) {
  i++;
  for (int x = i; x < N; x += x & -x) {
   data[x] += w;
  }
 }
 type sum(int i) {
  type ret = 0;
  for (int x = i; x > 0; x -= x & -x) {
   ret += data[x];
  }
  return ret;
 }

 type sum(int l, int r) {
  return sum(r) - sum(l);
 }







 int lower_bound(type w) {
  if (w <= 0) return 0;
  int x = 0;
  for (int k = nn; k > 0; k /= 2) {
   if (x + k < N && data[x + k] < w) {
    w -= data[x + k];
    x += k;
   }
  }
  return x;
 }
};

void test(VI a) {
 int r = 20;
 VL b(r);
 int geta = r / 2;
 for (auto it : a) {
  FOR(i, 0, r) {
   int re = i - geta;
   b[i] += abs(re - it);
  }
  DD(De(b));
 }
}



int main() {



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


 int Q; cin >> Q;
 using tp = tuple<int, int, int>;
 vector<tp>a(Q);
 vector<LL>u;
 FOR(i, 0, Q) {
  int b; cin >> b;
  if (b == 1) {
   LL c, d; cin >> c >> d;
   a[i] = tp(b, c, d);
   u.push_back(c);
  }
  else {
   a[i] = tp(b, 0, 0);
  }
 }
 SORT(u);
 UNIQ(u);
 BIT0<LL>bit1(SZ(u));
 BIT0<LL>bit2(SZ(u));
 FOR(i, 0, Q) {
  int b, c, d;
  tie(b, c, d) = a[i];
  if (b == 1) {
   c = lower_bound(ALL(u), c) - u.begin();
   a[i] = tp(b, c, d);
  }
 }

 LL dsum = 0;
 int addcnt = 0;
 FOR(i, 0, Q) {
  LL b, c, d;
  tie(b, c, d) = a[i];
  if (b == 1) {
   bit1.add(c, 1);
   bit2.add(c, u[c]);
   dsum += d;
   addcnt++;
  }
  else {
   int mid = bit1.lower_bound((addcnt + 1) / 2);
   cout << u[mid] << " ";
   LL val = 0;
   LL Lsum = bit1.sum(0, mid + 1)* u[mid] - bit2.sum(0, mid + 1);
   LL Rsum = bit2.sum(mid + 1, SZ(u)) - bit1.sum(mid + 1, SZ(u))*u[mid];






   val += Lsum + Rsum + dsum;
   cout << val << endl;
   DD(de(addcnt, mid, u[mid], val));
  }

 }


 return 0;
}


Measured memory_bytes: 7412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string> s(n+1);
    string ans;
    int suc=1,tmp=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    s[n]="|||";
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            suc++;
        }
        else{
            if(suc>tmp){
                ans=s[i];
                tmp=suc;
            }
            else if(suc==tmp){
                ans+="/"+s[i];
            }
            suc=1;
        }
        //cout<<suc<<tmp<<endl;
    }
    for(int i=0;i<ans.length();i++){
        if(ans[i]=='/'){
            cout<<endl;
        }
        else{
            cout<<ans[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 16132
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int N; cin >>N;
  int ans=0;
  for (int i=1;i<=N;i+=2) {
    int count=0;
    for (int j=1;j<=i;j++) {
      if (!(i%j)) count++;
    }
    if (8==count) ans++;
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=100005;
int n,K,i,p[N],q[N],invp[N],invq[N],a[N],b[N],c[N],x[10][N],ans[N],m;
void Mult(int a[N],int b[N],int rtn[N])
{
	for(int i=1;i<=n;++i)
		rtn[i]=a[b[i]];
}
void Inv(int a[N],int rtn[N])
{
	for(int i=1;i<=n;++i)
		rtn[a[i]]=i;
}
int main()
{
	scanf("%d%d",&n,&K);
	for(i=1;i<=n;++i)
		scanf("%d",p+i);
	for(i=1;i<=n;++i)
		scanf("%d",q+i);
	Inv(p,invp);
	Inv(q,invq);
	for(i=1;i<=n;++i)
		x[1][i]=p[i],x[2][i]=q[i];
	Mult(q,invp,x[3]);
	Mult(x[3],invq,x[4]);
	Mult(x[4],p,a);
	Mult(a,invq,x[5]);
	Mult(a,p,b);
	Mult(b,invq,x[0]);
	Inv(a,b);
	m=(K-1)/6;
	for(i=1;i<=n;++i)
		ans[i]=i;
	while(m)
	{
		if(m&1)
		{
			Mult(ans,a,c);
			for(i=1;i<=n;++i)
				ans[i]=c[i];
		}
		Mult(a,a,c);
		for(i=1;i<=n;++i)
			a[i]=c[i];
		m>>=1;
	}
	Mult(ans,x[K%6],c);
	for(i=1;i<=n;++i)
		ans[i]=c[i];
	m=(K-1)/6;
	while(m)
	{
		if(m&1)
		{
			Mult(ans,b,c);
			for(i=1;i<=n;++i)
				ans[i]=c[i];
		}
		Mult(b,b,c);
		for(i=1;i<=n;++i)
			b[i]=c[i];
		m>>=1;
	}
	for(i=1;i<=n;++i)
		printf("%d ", ans[i]);
	return 0;
}


Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main() {
	int a, b;
	char op;
	cin>> a >> op >> b;
	while( op != '?'){	
		if( op == '+'){
			cout<< a + b <<endl;
		}else if( op == '-'){
			cout<< a - b <<endl;
		}else if( op == '*'){
			cout<< a * b <<endl;
		}else{
			cout<< a / b <<endl;
		}
		cin>> a >> op >> b;
	}
}


Measured memory_bytes: 3052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				for (int c = 0; c <= k; c++) {
					if (a + b + c == k) {
						int rr = (int) Math.pow(2, a) * R;
						int gg = (int) Math.pow(2, b) * G;
						int bb = (int) Math.pow(2, c) * B;
						if (gg > rr && bb > gg) {
							System.out.println("Yes");
							return;
						}
					}
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 35760
# keyence2019C - Exam and Wizard
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    ans, shortage, pos = 0, 0, []
    for i, j in zip(A, B):
        x = i - j
        if x >= 0:
            pos += [x]
        else:
            ans += 1
            shortage += x
    for i in sorted(pos, reverse=1):
        if shortage >= 0:
            break
        ans += 1
        shortage += i
    print(ans if shortage >= 0 else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18408
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>

using namespace std;

static const int W = 5;
static const int H_MAX =  11;

int n;
int map[H_MAX][W];

int main(int argc, const char * argv[]) {
    // input from txt
    /////////
    //write//
    /////////
    
    while(1){
        cin >> n;
        if(n==0) break;
        for(int i=0; i<n+1; i++){
            for(int j=0; j<W; j++){
                if(i==0)map[i][j] = -1;
                else cin >> map[i][j];
            }
        }
        
        bool erase_stone = true;
        int ans = 0;
        
        while(erase_stone){
            erase_stone = false;
            for(int i=1; i<n+1; i++){
                int cnt = 0;
                int now_stone = 0;
                for(int j=0; j<W; j++){
                    if(now_stone == -1 )cnt = 0;
                    if(!cnt){
                        now_stone = map[i][j];
                        cnt++;
                    }
                    else{
                        if(map[i][j] == now_stone){
                            cnt++;
                        }
                        else {
                            if(cnt>=3){
                                for(int itr=0; itr<cnt; itr++){
                                    ans += now_stone;
                                    for(int itr2 = i; itr2>0; itr2--){
                                        map[itr2][j-itr-1] = map[itr2-1][j-itr-1];
                                    }
                                    erase_stone = true;
                                }
                            }
                            cnt = 0;
                            now_stone = map[i][j];
                            cnt++;
                        }
                    }
                }
                if(cnt>=3){
                    for(int j=0; j<cnt; j++){
                        ans += now_stone;
                        for(int itr2 = i; itr2>0; itr2--){
                            map[itr2][W-j-1] = map[itr2-1][W-j-1];
                        }
                    }
                    erase_stone = true;
                }
            }
        }
        
        cout << ans << endl;
    }
    
    return 0;
}




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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            cout << 0 << endl;
        else
            cout << -1 << endl;
    }
    else {
        for (int i = 0;; i++) {
            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
                cout << i << endl;
                break;
            }
            int x = (a + b) / 2, y = (b + c) / 2, z = (c + a) / 2;
            a = x, b = y, c = z;
        }
    }
}


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

int main(){

    ll l,r;
    cin >> l >> r;

    if(r-l+1>2050){
        cout << 0 << endl;
    }else{
        ll mi=2019*2019;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                mi=min(mi,((i%2019)*(j%2019))%2019);
            }
        }
        cout << mi << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	n := nextInt()
	for {
		if n == 0 {
			fmt.Println("No")
			return
		}
		a := n % 10
		n = n / 10
		if a == 9 {
			fmt.Println("Yes")
			return
		}
	}
}


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

int main(){
  int x,n, aux1, aux2;
  cin>>x; cin>>n;
  int p[n], a=x, b=x;
  for(int i=0; i<n; i++){
    cin>>p[i];
  }
  while(true){
    aux1=0; aux2=0;
    for(int i=0; i<n; i++){
      if(a==p[i]){aux1=1;};
      if(b==p[i]){aux2=1;};
    }
    if(aux1==0&&aux2==0){cout<<b; break;}
    if(aux1==0){cout<<a;break;}
    if(aux2==0){cout<<b;break;}
    else{a+=1;b-=1;}
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=1;
  ll c;
  cin>>c;
  for(ll i=0;i<a-1;i++){
    ll d;
    cin>>d;
    if(d>=c){
      b+=1;
      c=d;
    }
  }
  cout<<b<<endl;
  
  return 0;
  
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

const int Maxn = 100010;
const int mod = (int) 1e9 + 7;

ll a[Maxn], t[Maxn];
bool b[Maxn], c[Maxn];

int n;

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

    cin >> n;
    t[0] = a[n + 1] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i];
        if (t[i - 1] < t[i]) b[i] = true;
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; --i) {
        if (a[i] > a[i + 1]) c[i] = true;
    }

    ll ans = 1;
    for (int i = 1; i <= n; ++i) {
        if (b[i] && c[i]) {
            if (t[i] != a[i]) ans = 0;
        } else if (b[i]) {
            if (t[i] > a[i]) ans = 0;
        } else if (c[i]) {
            if (a[i] > t[i]) ans = 0;
        } else {
            (ans *= min(t[i], a[i])) %= mod;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    if(A + B < 10){
        cout << A + B << endl;
    }else{
        cout << "error" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  vector<int> B(N);
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  
  int64_t plus = 0;
  int64_t minus = 0;
  int cnt = 0;
  
  for(int i=0; i<N; i++){
    if(A.at(i) %2 != B.at(i) %2){
      B.at(i)++;
      cnt++;
    }
    if(A.at(i) < B.at(i)){
      plus += (B.at(i) - A.at(i)) / 2;
    }
    if(A.at(i) > B.at(i)){
      minus += A.at(i) - B.at(i);
    }
  }
  
  plus -= cnt;
  
  if(minus > plus){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 384
def gcd(a, b):
    if a < b:
        temp = a
        a = b
        b = temp
    if b == 0:
        return a
    else:
        r = a % b
        if r == 0:
            return b
        else:
            return gcd(b, r)


N = int(input())
A = list(map(int,input().split()))
L = [] #[A[0], gcd(A[0], A[1]), gcd(A[0], A[1], A[2]), ...,gcd(A[0], ..., A[N-2]) -> N-1個の要素
R = [] #[A[N-1], gcd(A[N-1], A[N-2]), gcd(A[N-1], A[N-2], A[N-3]), ... ,gcd(A[N-1], A[N-2], A[N-3], ..., A[1])]

L.append(A[0])
R.append(A[-1])
for i in range(1, N-1):
    L.append(gcd(L[i-1], A[i]))
    R.append(gcd(R[i-1], A[N-1-i]))
ans = max(R[-1], L[-1])
for i in range(N-2):
    val = gcd(L[i], R[N-i-3])
    if val > ans:
        ans = val
print(str(ans))

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

using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair

int main(){

int n;
cin>>n;
int a[n];
int i;
for(i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
int l=a[n-1];
int m=(a[n-1])/2+(a[n-1])%2;
int b[l+1];
for(i=0;i<=l;i++)
    b[i]=0;
    int fl=0;

for(i=0;i<n;i++){

    b[a[i]]++;
}

if(a[n-1]%2==0){
        int c=0;
        int cou=0;
    if(b[m]!=1){
       fl=1;
    }
    else
    {c+=b[m];
        for(i=m+1;i<=l;i++){
        if(b[i]<2)
            {
                fl=1;
                break;
            }
            else{
                c+=b[i];

            }

    }

    }
    for(i=1;i<m;i++)
        if(b[i])
        fl=1;
    if(fl)
        cout<<"Impossible"<<endl;
    else
        cout<<"Possible"<<endl;



}
else
{
    int c=0;


    {
        for(i=m;i<=l;i++){
                if(i==m)
                {
                    if(b[i]!=2)
                    {
                        fl=1;
                        break;
                    }
                    continue;
                }
        if(b[i]<2)
            {
                fl=1;
                break;
            }
            else{
                c+=b[i];

            }

    }

    }
    for(i=1;i<m;i++)
        if(b[i])
        fl=1;
    if(fl)
        cout<<"Impossible"<<endl;
    else
        cout<<"Possible"<<endl;





}






return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    bitset<64> bs;
    for(int i = 0; i < q; i++)
    {
        ll x, y;
        cin >> x;
        if(x == 0)
        {
            cin >> y;
            cout << (bs.test(y) ? 1 : 0) << endl;
        }
        if(x == 1)
        {
            cin >> y;
            bs.set(y);
        }
        if(x == 2)
        {
            cin >> y;
            bs.reset(y);
        }
        if(x == 3)
        {
            cin >> y;
            bs.flip(y);
        }
        if(x == 4)
        {
            cout << (bs.all() ? 1 : 0) << endl;
        }
        if(x == 5)
        {
            cout << (bs.any() ? 1 : 0) << endl;
        }
        if(x == 6)
        {
            cout << (bs.none() ? 1 : 0) << endl;
        }
        if(x == 7)
        {
            cout << bs.count() << endl;
        }
        if(x == 8)
        {
            cout << bs.to_ullong() << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

bool check(int num) {
    bool dec = true;
    int rem = num % 10;
    while (num / 10 != 0) {
        num /= 10;
        if (num % 10 != rem - 1) {
            dec = false; 
            break;
        }
        rem--;
    }
    return dec;
}

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i= 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int max = 0;
    for (int i = 0; i< n; i++) {
        for (int j = i + 1; j< n; j++) {
            int prod = a[i] * a[j]; 
            if (check(prod) == true && max < prod) {
                max = prod;
            }
        }
    }
    if (max == 0) {
        cout << -1 << endl;
    } else {
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mr make_pair
using namespace std;
int n,k;
int main(){
	cin>>k>>n;
	if (n+k/2<=k){
		for (int i=0;i<k;i++){
			if (i%2==0)cout<<n+(i/2)<<' '<<n+k+k/2+(i/2)<<' '<<n+k+k+i<<'\n';
			else cout<<n+(i/2)+(k+1)/2<<' '<<n+k+(i/2)<<' '<<n+k+k+i<<'\n';
		}
	}else{
		puts("-1");
	}
	return 0;
}

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

// #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

const int MAX = 200000 + 1;
vector<vector <ll> > tree(MAX);
vector<ll> value(MAX, 0);
vector<bool> flag(MAX, true);

void dfs(ll j){
  flag[j] = false;
  if (tree[j].size() == 0) return;
  for(ll k: tree[j]){
    if (flag[k]){
      value[k] += value[j];
      dfs(k);
    }
  }
  return;
}

int main() {
  int N, Q;
  cin >> N >> Q;
  
  ll a, b;
  rep(i, N - 1){
    cin >> a >> b;
    a--; b--;
    if (a == 0) {
      tree[a].push_back(b);
    } else if (b == 0){
      tree[b].push_back(a);
    } else {
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
  }

  ll p, x;
  rep(i, Q){
    cin >> p >> x;
    value[p - 1] += x;
  }

  // 最後にたすのはDFSで行う必要があるらしい
  // 根の向きが逆の可能性もある
  dfs(0);

  // 出力
  rep(i, N){
    cout << value[i] << endl;
  }

}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(i == n - 1)
        {
            ans += p[n-1] / 2;
        }
        else
        {
            ans += p[i];
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, a, b, c, d;
  cin  >> N;
  a = N/1000, b = (N-1000*a)/100,
  c = (N-1000*a-100*b)/10, d = (N-1000*a-100*b-10*c);
 
  if ( b != c || ( a != b && c != d)) {
      cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
}

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

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
int main() {
	ll a;
	while (scanf("%lld", &a), a) {
		vector<ll>v;
		for (ll i = 1; i*i <= a; i++) {
			if (a%i == 0) {
				v.push_back(i);
				if (i != a / i)v.push_back(a / i);
			}
		}
		if (v.size() > 10000)abort();
		sort(v.begin(), v.end());
		int cnt = 0;
		rep(i, v.size())for (int j = i; j < v.size(); j++) {
			if (lcm(v[i], v[j]) == a)cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3188
#include<stdio.h>
int main(void)
{ 
	int n,k,x,y,i,sum;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	sum=0;
	for(i=1;i<=n;i++){
		if(k<i){
			sum+=y;
		}
		else{
			sum+=x;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, cnt[26]{}, ans = 1;
    string s;
    cin >> n >> s;
    for(auto c : s){
        cnt[c-'a']++;
    }
    REP(i,26){
        ans *= cnt[i]+1;
        ans %= MOD;
    }
    ans = (ans-1+MOD)%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FO(x) {freopen(#x".in","r",stdin);\
				freopen(#x".out","w",stdout);}
#define fir first
#define sec second
using namespace std;
typedef long long ll;
template<typename T>inline bool cmin(T &a,const T &b){ return a>b?a=b,1:0;}
template<typename T>inline bool cmax(T &a,const T &b){ return a<b?a=b,1:0;}
#define p 1000000007
int exp(int a,int n){
	int res=1;
	for(;n;n>>=1,a=(ll)a*a%p)
		if(n&1)res=(ll)res*a%p;
	return res;
}
#define N 101234
int n,a[N],b[N],fac[N],rv[N];
int c(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return (ll)fac[n]*rv[m]%p*rv[n-m]%p;
}
int main(){
	int i,j,k=0;
	scanf("%d",&n);++n;
	for(i=1;i<=n;i++)scanf("%d",a+i),++b[a[i]];
	for(i=fac[0]=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%p;
	for(rv[n]=exp(fac[n],p-2),i=n;i;i--)rv[i-1]=(ll)rv[i]*i%p;
	for(i=1;i<=n;i++){
		j=a[i];
		if(!~b[j])k+=n-i-1;
		if(b[j]==2)k+=i,b[j]=-1;
	}
	for(i=1;i<=n;i++){
		j=c(n,i);
		if(i-1<=k)j=(j-c(k,i-1)+p)%p;
		printf("%d\n",j);
	}
	return 0;
}


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

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(); cout.tie();
    long long y = 1e5 + 2;
    long long v[y] = {0}, n, s=0, s2=0, x;
    long long q, b, c;
    cin >> n;

    for(int i = 1; i<=n; i++ )
    {
        cin>>x;
        v[x]++;
        s += x;
    }

    cin>>q;
    for(int i = 1; i<=q; i++)
    {
        cin>>b>>c;
        v[c] += v[b];
        s2 = s - b*v[b] + c*v[b];
        s = s2;
        v[b] = 0;
        cout<<s2<<"\n";
    }

    return 0;
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 3;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;


int walk (int u, vector<int> & dist, vector<vector<int>> & adj) {
	if (adj[u].empty()) {
		return 0;
	}
	auto & d = dist[u];

	if(d == -1) {
		d = 0;
		for (auto v : adj[u]) {
			d = max(d, walk(v, dist, adj) + 1);
		}
	}

	return d;
}

void solve () {
	int n, m; cin >> n >> m;
	vector<vector<int>> adj(n + 2);

	for (auto i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
	}

	vector<int> dist(n + 2, -1);
	for (auto i = 1; i <= n; ++i) {
		if(dist[i] == -1) {
			dist[i] = walk(i, dist, adj);
		}
	}

	int ret = 0;
	for (auto it : dist) {
		ret = max(ret, it);
	}
	cout << ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}



Measured memory_bytes: 8192
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, x;

	cin >> n >> x;

	vector<ll> v(2 * n - 1, 0);

	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		if (n == 2) {
			REP(i, 3) {
				v[i] = i + 1;
			}
		}
		else if (x == 2) {
			v[n - 1] = x;
			v[n - 2] = x + 1;
			v[n] = x - 1;
			v[n + 1] = x + 2;
			ll now = 1;
			REP(i, v.size()) {
				while (now == x || now == x + 1 || now == x - 1 || now == x + 2) {
					now++;
				}
				if (v[i] == 0) {
					v[i] = now;
					now++;
				}
			}
		}
		else {
			v[n - 1] = x;
			v[n - 2] = x - 1;
			v[n] = x + 1;
			v[n + 1] = x - 2;
			ll now = 1;
			REP(i, v.size()) {
				while (now == x || now == x - 1 || now == x + 1 || now == x - 2) {
					now++;
				}
				if (v[i] == 0) {
					v[i] = now;
					now++;
				}
			}
		}
		REP(i, v.size()) {
			cout << v[i] << endl;
		}
	}
}

Measured memory_bytes: 3072