akhauriyash/Code-Regression huggingface dataset:
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x; }
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline int mul(int x, int y) { return (x * y) % mod; }
inline int powr(int a, int b) {
	int x = 1 % mod;
	while (b) {
		if (b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a) { return powr(a, mod - 2); }

void solve()
{
	cin >> n >> k;
	int ans = 0;
	if (k == 1)
	{
		ans = n + 1;
		k++;
	}
	int mn = 1, mx = n, cnt1 = 2, cnt2 = n - 1;
	for (int i = 2; i <= n + 1; i++)
	{
		// bug(mx, mn);
		mx = add(mx, cnt2);
		if (i >= k)
			ans = add(ans, sub(mx , mn) + 1);

		// bug(ans);
		mn = add(mn, cnt1);
		cnt1++;
		cnt2--;
	}
	cout << ans;

}

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

	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll gcd(ll x,ll y){
  if(x%y==0)return y;
  else return gcd(y,x%y);
}
vector<vector<P>>G(110000);
vector<ll>dist;
void Dij(ll start){
  priority_queue<P,vector<P>,greater<P>> q;
  dist=vector<ll>(110000,INF);
  dist[start]=0;
  q.push(P(start,0ll));
  
  while(!q.empty()){
    ll v=q.top().first;
    ll d=q.top().second;
    q.pop();
    if(dist[v]<d)continue;
    for(auto nv:G[v]){
      if(dist[nv.first]>dist[v]+nv.second){
        dist[nv.first]=dist[v]+nv.second;
        q.push(P(nv.first,dist[nv.first]));
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  rep(i,n-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,c));
  }
  int q,k;
  cin >> q >> k;
  k--;
  Dij(k);
  rep(i,q){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    cout << dist[x]+dist[y] << endl;
  }
}


Measured memory_bytes: 11504
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int q;
    cin >> q;

    unsigned long long a[q], b[q];
    for(int i=0;i<q;i++)cin >> a[i] >> b[i];

    for(int i=0;i<q;i++){
        unsigned long long ans = 0;
        if(a[i]>b[i])swap(a[i],b[i]);
        if(a[i]==b[i])ans = a[i] * 2 - 2;

        else if(a[i]==b[i]-1)ans = a[i] * 2 - 2;

        else{
            ans = sqrt(a[i]*b[i]);
            if(ans*ans==a[i]*b[i])ans -= 1;
            if(ans*(ans+1)<a[i]*b[i])ans = ans * 2 - 1;
            else ans = ans * 2 - 2;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
int ans = 0;
int n;
string s;
cin >> n >> s;
int now = 0;
REP(i,s.size()){
if(s[i] == 'I') now++;
else now--;
ans = max(ans, now);
}
cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())

A = []
B = []

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)

root = [i for i in range(N)]

def find(x):
    if root[x] != x:
        root[x] = find(root[x])
    return root[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    root[y] = x

for i in range(M):
    unite(A[i], B[i])

for x in range(N):
    find(x)

roots = set(root)

print(len(roots) - 1)

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = LINF;
    REP(i, max(x, y) + 1) {
        chmin(ans, c * 2 * i + a * max(0LL, x - i) + b * max(0LL, y - i));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
List1=[1,3,5,7,8,10,12]
List2=[4,6,9,11]
x,y=map(int,input().split())
count1=0
count2=0
if x in List1:
  count1+=1
if y in List1:
  count1+=1
if x in List2:
  count2+=1
if y in List2:
  count2+=1
print('Yes' if count1==2 or count2==2 else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=10000000;
const ll INF=1000000001;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
vector<int> v[100010];
int ma[100010];
int main(){
    int w,h,n;cin>>w>>h>>n;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=w-1;i>=1;i--){
        int maa=0;
        for(auto a:v[i]){
            maa=max(a,maa);
        }
        ma[i-1]=max(ma[i],maa);
    }
    int ans=INF;
    for(int i=0;i<w;i++){
        int s=i+ma[i];
        ans=min(s,ans);
    }
    cout<<ans<<endl;
}


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

int main(){
    int N;cin>>N;
    int info[N][N];
    rep(i,N){
        string S;cin>>S;
        rep(j,N){
            info[i][j]=S[j]-48;
        }
    }
    vector<int> a[N];
    rep(i,N){
        rep(j,N){
            if(info[i][j])a[i].push_back(j);
        }
    }

    //二部グラフ判定
    int color[N];
    rep(i,N)color[i]=-1;
    color[0] = 0;
    bool ok=true;
    deque<int> Q;
    Q.push_back(0);
    while(!Q.empty()) {
        int i = Q.front();
        Q.pop_front();
        for (int j = 0; j < a[i].size(); j++) {
            if (color[a[i][j]] == color[i]) {
                ok = false;
                Q.clear();
                j = a[i].size();
            } else if (color[a[i][j]] == -1) {
                color[a[i][j]] = !color[i];
                Q.push_back(a[i][j]);
            }
        }
    }


    if(ok==false)cout<<-1<<endl;
    else{ //warshall_floyd
        rep(i,N){
            rep(j,N){
                if(i!=j and info[i][j]==0)info[i][j]=INF;
            }
        }
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(info[i][k]==INF or info[k][j]==INF)continue;
                    info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
                }
            }
        }
        int ans=0;
        rep(i,N){
            rep(j,N){
                ans=max(ans,info[i][j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<array>
#include<cmath>
#include <algorithm>

using namespace std;


int main() {
	// 初期処理(iostream軽くする)
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	string n;
	cin >> n;

	if (n.find("7") != string::npos) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

//使い方
int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
	int res=0;
	for(int i=0;i<pf.size();i++){
		for(int j=1;j<1000;j++){
			if(pf[i].second>=j){
				res++;
				pf[i].second-=j;
			}
			else
				break;
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    int a;
    while(cin >> a){
        int ans = 0;
        for(int i = 0; i < 600; i+= a){
            ans += a * i * i;
        }
        OUTL(ans);
    }
RET;}

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  vector<int> W;
  for (int i = 0; 100*A*i <= F; i++) {
    for (int j = 0; 100*B*j <= F; j++) {
      int water = 100*A*i + 100*B*j;
      if (water <= F && water != 0) {
        W.push_back(water);
      }
    }
  }

  vector<int> S;
  for (int i = 0; C*i <= F; i++) {
    for (int j = 0; D*j <= F; j++) {
      int sugar = C*i + D*j;
      if (sugar <= F) {
        S.push_back(sugar);
      }
    }
  }

  double limit_con = 100*(double)E / (100 + (double)E);
  double max_con = -1;
  int ans_as = 0;
  int ans_sugar = 0;
  for (int i = 0; i < W.size(); i++) {
    for (int j = 0; j < S.size(); j++) {
      int w = W.at(i);
      int s = S.at(j);
      int f = w + s;
      double con = 100 * (double)s / (double)f;
      if (con > max_con && con <= limit_con && f <= F) {
        max_con = con;
        ans_as = f;
        ans_sugar = s;
      }
    }
  }
  cout << ans_as << " " << ans_sugar << endl;
}

Measured memory_bytes: 1400
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{s:chars};
    let a:Vec<_> = s.iter().enumerate().filter(|&(i,x)| *x=='A').map(|(i,_x)| i).collect();
    let z:Vec<_> = s.iter().enumerate().filter(|&(i,x)| *x=='Z').map(|(i,_x)| i).collect();
    //debug!(a,z);
    println!("{}", z[z.len()-1]-a[0]+1);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n,m;
	cin >> n >> m;
	bool val[n+1] = {};
	vector<ll> dp(n+1);
	int x;
	while(m--){
		cin >> x;
		val[x] = 1;
	}
	dp[0] = 1;
	dp[1] = val[1] == 0;
	fu(i,2,n){
		if(!val[i]){
			dp[i] = (dp[i-1] + dp[i-2]) % MOD;
		}
	}
	cout << dp[n] << '\n';
}


Measured memory_bytes: 1152
#include<cstdio>  
#include<cstdlib> 
#include<cstring>  
#include<cmath>  
#include<algorithm>  
using namespace std;  
int n,ans = 0;  
struct NOOD {
	int x, y;
}a[105], b[105];
bool line[205][205];
int girl[205];  
bool vis[205];
  
bool find(int x){  
    for(int j = 1; j <= n; j++){  
        if(line[x][j + n] == true && vis[j + n] == false){  
            vis[j + n] = 1;  
            if(girl[j + n] == 0 || find(girl[j + n])){  
                girl[j + n] = x;  
                return true;  
            }  
        }  
    }  
    return false;  
}  
int main(){  
	scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
    for(int i = 1; i <= n; i++) scanf("%d%d", &b[i].x, &b[i].y);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(a[i].x < b[j].x && a[i].y < b[j].y) {
				line[i][j + n] = 1;
				line[j + n][i] = 1;
	}
	for(int i = 1; i <= n; i++){
		memset(vis,0,sizeof(vis));
		if(find(i)) ans++;
	}
	printf("%d\n", ans);
}
  

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B := getInt(), getInt()
	ans := max(A+B, max(A-B, A*B))
	out(ans)
}


Measured memory_bytes: 1772
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
ll can(string s)
{
    ll f=0;
    ll n1 = s.size();
    for(int i=0;i<s.size()/2;i++)
    {
         if(s[i]!=s[n1-i-1])
         {
            f=1;
            break;
         }
    }
    return 1-f;
}
signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
           ll n;
           cin>>n;
           ll a[n];
           map<ll,ll>mp;
           for(int i=0;i<n;i++)
           {
              cin>>a[i];
              mp[a[i]]++;
           }
           ll ans =0;
           for(auto it : mp)
           {
              ll can = (it.se*(it.se-1))/2;
              ans+=can;
           }
           for(int i=0;i<n;i++)
           {
              ll temp = ans;
              ll count = mp[a[i]];
              temp-=((count)*(count-1))/2;
              count--;
              temp+=((count)*(count-1))/2;
              cout<<temp<<endl;
           }

      }
      






}



























Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll mod=1e9+7;
const int maxn=1e5+10;
int a,b,c;
int main(){
    ios::sync_with_stdio(false);
    //cout<<(1ll<<62)<<endl;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(c<=b&&c>=a){
        cout<<"Yes"<<endl;
    }else{
        puts("No");
    }
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
  void Solve()
  {
    var S = Console.ReadLine();

    var n1 = int.Parse(S.Substring(0, 2));
    var n2 = int.Parse(S.Substring(2, 2));

    if (n1>=1&&n1<=12&&n2>=1&&n2<=12)
    {
      Console.WriteLine("AMBIGUOUS");
    }
    else if (n2 >= 1 && n2 <= 12)
    {
      Console.WriteLine("YYMM");
    }
    else if (n1 >= 1 && n1 <= 12)
    {
      Console.WriteLine("MMYY");
    }
    else

    Console.WriteLine("NA");
  }

  static void Main(string[] args)
  {
    new Program().Solve();
  }
}



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

using namespace std;

const int MOD = 1000000007;

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) {
    cin >> A[i];
  }

  vector<vector<int>> dp(H, vector<int>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') continue;
      if (j > 0) dp[i][j] += dp[i][j - 1];
      if (i > 0) dp[i][j] += dp[i - 1][j];
      dp[i][j] %= MOD;
    }
  }

  cout << dp[H - 1][W - 1] << "\n";
  return 0;
}


Measured memory_bytes: 5248
p=998244353
n,k=map(int,input().split())
kukan=[]
for i in range(k):
    l,r=map(int,input().split())
    kukan.append((l,r))
dp=[0]*n
sdp=[0]*(n+1)
dp[0]=1
sdp[1]=1
for i in range(1,n):
    for l,r in kukan:
        left=max(0,i-r)
        right=max(0,i-l+1)
        dp[i]=(dp[i]+sdp[right]-sdp[left])%p
    sdp[i+1]=(sdp[i]+dp[i])%p
print(dp[-1])

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }

    bool yn = false;
    int ans = INT_MAX;
    for (int b = 1; b < (1<<n); b++) {
        int p = 0;
        vector<int> q(m, 0);
        for (int i = 0; i < n; i++) {
            if (b & (1<<i)) {
                p += c[i];
                for (int j = 0; j < m; j++) {
                    q[j] += a[i][j];
                }
            }
        }
        bool f = true;
        for (int i = 0; i < m; i++) {
            if (q[i] < x) f = false;
        }
        if (f) {
            yn = true;
            ans = min (ans, p);
        }
    }
    if (yn) cout << ans << endl;
    else cout << -1 << endl;
}

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

typedef long long ll;
using namespace std;


int main()
{
    char c;
    cin >> c;

    if(c == 'a' || c == 'e'|| c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// C++11
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <sstream>
#include <fstream>
#include <random>
#include <bitset>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 2.8e9;
}

int a[200000] = {};
int b[200000] = {};

void solve(){
  double starttime = GetSeconds();
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
  int r = 0;
  for(int i=30;i>0; i--){
    int ii = pow(2,i);
    int ti = pow(2,i-1);
    for(int j=0; j<n; j++){
      b[j] %= ii;
      a[j] %= ii;
    }
    sort(&b[0], &b[n]);
    int c = 0;
    for(int j=0; j<n; j++){
      int i1 = lower_bound(&b[0], &b[n], ti - a[j]) - b;
      int i2 = lower_bound(&b[0], &b[n], ti*2 - a[j]) - b;
      int i3 = lower_bound(&b[0], &b[n], ti*3 - a[j]) - b;
      c += i2-i1 + n-i3;
    }
    if(c%2) r += ti;
  }
  cout << r << endl;

  return;
}

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



Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));

sort($a);
if ($n % 2) {
	if ($a[0] != 0) exit("0");
	if ($n == 1) exit("1");
	$st = 1;
	$c = 2;
} else {
	$st = 0;
	$c = 1;
}
for ($i = $st; $i < $n; $i += 2) {
	if ($a[$i] != $c || $a[$i+1] != $c) exit("0");
	$c += 2;
}
$p = ($n - $n % 2) / 2;
$mod = 10 ** 9 + 7;
$x = 2;
for ($i = 0; $i < $p; $i += 30) {
	if ($p - $i > 30) {
		$x = $x * 2 ** 30 % $mod;
	} else {
		$x = $x * 2 ** ($p - $i - 1) % $mod;
	}
}
echo $x;

Measured memory_bytes: 21744
s1 = int(input())
s2 = int(input())
s3 = int(input())
s4 = int(input())
s5 = int(input())
s6 = int(input())
s7 = int(input())
s8 = int(input())
s9 = int(input())
s10 = int(input())
print(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))


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

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

Measured memory_bytes: 3608
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;


#define MOD (1000000000+7)


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(n+1), b(m+1);
		vi c(n*m);
		ll ans=1LL;

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

		sort(a.rbegin(), a.rend());
		sort(b.rbegin(), b.rend());

		for(int i=1;i<n;i++) if(a[i]==a[i-1]) ans=0;
		for(int i=1;i<m;i++) if(b[i]==b[i-1]) ans=0;

		int ap=0, bp=0;

		for(int i=m*n;i>0;i--)
		{
			for(;i<a[ap] && ap<n;ap++);
			for(;i<b[bp] && bp<m;bp++);

			if(i==a[ap])
			{
				if(i!=b[bp])
				{
					ans=(ans*bp)%MOD;
//					printf("*%d", bp);
				}
				else
				{
//					printf("*1");
				}
			}
			else if(i==b[bp])
			{
				ans=(ans*ap)%MOD;
//				printf("*%d", ap);
			}
			else
			{
				ans=(ans*((ap*bp)-(m*n-i)))%MOD;
//				printf("*(%d-%d)", (ap*bp), (m*n-i));
			}
			if(ans<=0)
			{
				ans=0;
				break;
			}
		}
		printf("%lld\n", ans);
	}

	return 0;
}



Measured memory_bytes: 4096
from sys import stdin
from collections import deque
N=list(map(int,stdin.readline().strip().split()))[0]

t=0
data = [list(map(int,stdin.readline().rstrip().split())) for _ in range(N)]

data=sorted(data,key=lambda x:(x[1]))
d=deque(data)
while(len(d)!=0):
    A,B=d.popleft()
    if B>=t+A:
        t+=A
    else:
        print("No")
        exit()
print("Yes")


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    string s;
    cin >> s;

    int front = stoi(s.substr(0, 2));
    int back = stoi(s.substr(2, 2));

    string ans = "NA";
    if (1 <= front && front <= 12 && 1 <= back && back <= 12) {
        ans = "AMBIGUOUS";
    } else if (1 <= front && front <= 12) {
        ans = "MMYY";
    } else if (1 <= back && back <= 12) {
        ans = "YYMM";
    }

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


Measured memory_bytes: 256
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> a = inp(n);
    UNIQUE(a);
    cout << YES(a.size() == n) << endl;
    
}

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

int main() {

    char c[2][3];

    for(int i=0; i<2; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }

    string ans = "NO";

    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
        ans = "YES";
    }

    cout << ans << endl;

    return 0;
}

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


int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int cnt = 0, mx = 0;
  for (int i = 0; i < n-1; i++) {
    if (h[i] >= h[i+1]) {
      cnt++;
    } else {
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  mx = max(mx, cnt);
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int count = 0;
  for (auto i : mp) {
    if (i.second % 2 == 1) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  
  int a,b,m;
  cin >> a>>b>>m;
  
  int ans = 500000;
  
  int am = 500000;
  int bm = 500000;
  
  vector<int> A(a);
  rep(i,a) {
  cin >> A[i];
  am = min(am,A[i]);
  }
  
  vector<int> B(b);
  rep(i,b) {
  cin >> B[i];
  bm = min(bm,B[i]);
  }
  
  rep(i,m) {
  int x,y,c;
  cin >>x>>y>>c;
  ans=min(ans, A[x-1]+B[y-1]-c);    
  }
  
  
  cout << min(ans,am+bm) << endl;
  
}


Measured memory_bytes: 1024
L, R = map(int, input().split())

if(R - L >= 2019):
  print(0)
  exit()
  
result = 2019

for i in range(L, R + 1):
  for j in range(i + 1, R + 1):
    tmp = ((i % 2019) * (j % 2019)) % 2019
    if(tmp < result):
      result = tmp

print(result)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long d = sc.nextLong();
        double ans = (m - 1) * (n - d) * 2;
        if (d == 0) {
            ans = (m - 1) * (n - d);
        }
        System.out.println(ans / Math.pow(n, 2));
    }
}

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

using namespace std;

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

Measured memory_bytes: 640
#include <iostream>
#include <string>

int main(){

    std::string s;

    std::cin >> s;

    bool flag = false;
    for(int i=0; i<3; i++){
        if( s[i] == s[i+1] ){
            flag = true;
            break;
        }
    }

    if(flag == true){
        std::cout << "Bad" << std::endl;
    }else{
        std::cout << "Good" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

previous = H[0]

if N == 1:
    print(0)
    exit()

counter = 0
max_counter = 0

for i in range(1,N):
    if H[i] <= H[i-1]:
        counter += 1
        max_counter = max(max_counter,counter)
    else:
        counter = 0

print(max_counter)

Measured memory_bytes: 14228
package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"sort"
)

func main() {
	body, _ := ioutil.ReadAll(os.Stdin)
	v := make([]int, 3)
	fmt.Sscanf(string(body), "%d %d %d", &v[0], &v[1], &v[2])
	// fmt.Printf("%+v\n", v)
	sort.Ints(v)

	diff := 2*v[2] - v[1] - v[0]
	if diff%2 == 0 {
		fmt.Printf("%d\n", diff/2)
	} else {
		fmt.Printf("%d\n", diff/2+2)
	}
}


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

map<int, int> store;
vector<int> nxt;

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

    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        store[tmp]++;
    }

    for (auto x : store) {
        nxt.push_back(x.second);
    }

    if (K >= (int)nxt.size()) {
        cout << "0\n";
        return 0;
    }

    sort(nxt.begin(), nxt.end());

    int cnt = 0;
    for (int i = 0; i < (int)nxt.size(); i++) {
        cnt += nxt[i];
        if ((int)nxt.size() - (i+1) == K) break;
    }

    cout << cnt << "\n";
}


Measured memory_bytes: 10748
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from time import time
from random import randint
from copy import deepcopy

start_time = time()

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

def update(socre, day, t, q):
    p = t[day]
    t[day] = q
    scores[p] = 0
    scores[q] = 0
    lasts = [0]*26
    for i in range(1, len(t)):
        if t[i] == p or t[i] == q:
            scores[t[i]] += s[i][t[i]]
            dif = i - lasts[t[i]]
            scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
            lasts[t[i]] = i
    for i in [p, q]:
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores, t

def greedy(c, s):
    day_lim = len(s)
    socres = [0]*26
    t = [0]*day_lim
    lasts = [0]*26
    for i in range(1, day_lim):
        pls = [v for v in socres]
        mns = [v for v in socres]
        for j in range(26):
            pls[j] += s[i][j]
            mns[j] -= c[j] * (i - lasts[j])
        sum_mns = sum(mns)
        pt = sum_mns - mns[0] + pls[0]
        idx = 0
        for j in range(1, 26):
            tmp = sum_mns - mns[j] + pls[j]
            if pt < tmp:
                pt = tmp
                idx = j
        t[i] = idx
        lasts[idx] = i
        for j in range(26):
            if j == idx:
                socres[j] = pls[j]
            else:
                socres[j] = mns[j]
    return socres, t

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))

scores, t = greedy(c, s)
sum_score = sum(scores)

while time() - start_time < 1.75:
    day = randint(1, D)
    q = randint(0, 25)
    if q == t[day]:
        continue
    tmp_t = deepcopy(t)
    tmp_scores = deepcopy(scores)
    tmp_scores, tmp_t = update(tmp_scores, day, tmp_t, q)
    sum_tmp_score = sum(tmp_scores)
    if sum_score < sum_tmp_score:
        sum_score = sum_tmp_score
        t = tmp_t
        scores = tmp_scores

for v in t[1:]:
    print(v+1)

Measured memory_bytes: 93112
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

struct edge {
  ll to, cap, rev;
};

vector<vector<edge>> to;
vector<bool> used;
void addE(ll u, ll v, ll w) {
  to[u].push_back({v, w, (ll)to[v].size()});
  to[v].push_back({u, 0, (ll)to[u].size() - 1});
}

ll dfs(ll u, ll t, ll f) {
  assert(f > 0);
  if (u == t) return f;
  used[u] = true;
  for (edge& e : to[u]) {
    if (used[e.to] || e.cap <= 0) continue;
    ll d = dfs(e.to, t, min(f, e.cap));
    if (d == 0) continue;
    e.cap -= d;
    to[e.to][e.rev].cap += d;
    return d;
  }
  return 0;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll nx, ny, ne;
  cin >> nx >> ny >> ne;

  to.resize(nx + ny + 2);
  rep(i, nx) { addE(nx + ny, i, 1); }
  rep(i, ny) { addE(nx + i, nx + ny + 1, 1); }

  rep(i, ne) {
    ll x, y;
    cin >> x >> y;
    addE(x, nx + y, 1);
  }

  ll ans = 0;
  while (true) {
    used.assign(nx + ny + 2, false);
    ll add = dfs(nx + ny, nx + ny + 1, INF);
    if (add == 0) {
      cout << ans << endl;
      return 0;
    } else
      ans += add;
  }

  cout << ans << endl;

  return 0;
}



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

int main(){
    int N;
    string L;
    int P, A, B, C, D, E, F, S, M;

    while(true){
        cin >> N;
        if(N == 0) break;
        vector<pair<double, string>> plant;
        for(int i=0;i<N;i++){
            cin >> L;
            cin >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            double reward = ((double)(F*S*M) - (double)P) / ((double)(A + B + C + (D + E)*M));
            plant.push_back(pair<double, string>(-reward, L));
        }
        sort(plant.begin(), plant.end());
        for(auto p: plant){
            cout << p.second << "\n";
        }
        cout << "#\n";
    }
    return 0;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int p,q,r,ans=0;
    cin >> p >> q >> r;
    ans=p+q+r;
    ans-=max({p,q,r});

    cout << ans << endl;
 }    


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    let k: usize = read();
    let n = s.len();
    let mut f = true;
    for i in 1..n{
        if s[i - 1] != s[i]{
            f = false;
            break;
        }
    }
    let mut ans = 0;
    if f{
        ans = n * k / 2;
    }else{
        let f2 = if s[0] == *s.last().unwrap() {true} else {false};
        if f2{
            let mut a: usize = 1;
            let mut b: usize = 1;
            while s[a - 1] == s[a] { a += 1; }
            while s[n - b] == s[n - b - 1] { b += 1; }
            let mut i = a + 1;
            while i < n-b{
                if s[i - 1] == s[i]{
                    ans += 1;
                    i += 1;
                }
                i += 1;
            }
            ans = ans * k + a / 2 + b / 2 + ((a + b) / 2) * (k - 1);
        }else{
            let mut i = 1;
            while i < n{
                if s[i - 1] == s[i]{
                    ans += 1;
                    i += 1;
                }
                i += 1;
            }
            ans = ans * k;
        }
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;
const ull in = 1000000000000000000ull;

std::ostream &operator<<(std::ostream &dest, __uint128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    __uint128_t ret = 1;
    vector<ull> a(n);
    for(auto &b : a) cin>>b;
    sort(a.begin(),a.end());
    if(a[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<n;++i){
        ret *= a[i];
        if(ret > in or a[i] > in){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ret > in){
        cout << -1 << endl;
    }else cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200005]={0};
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >>a[i];
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k])
            cout << "Yes\n";
        else
            cout <<"No\n";
    }
    return 0;
}


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

using namespace std;

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

	vector<char> c(N);
	int count = 0;

	for(int i = 0; i < N; i++) {
		cin >> c[i];
	}

	int i = 0, j = N-1;

	while(i <= j) {
		if(c[i] == 'W') {
			if(c[j] == 'R') {
				
				swap(c[i], c[j]);
				
				count++;
				i++;
				j--;
			} else {
				j--;
			}
		} else {
			i++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3552