akhauriyash/Code-Regression huggingface dataset:
///   ***   ---   In the name of ALLAH    ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef pair<ll, ll> PLL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef double DL;
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print cout
#define sz(x) (int)x.size()
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define fori(a,n) for (ll i = a; i < n; ++i)
#define forj(a,n) for (ll j = a; j < n; ++j)
#define fri(a,n) for (ll i = a; i <=n; ++i)
#define frj(a,n) for (ll j = a; j < =n; ++j)
#define forv(v) for(auto i : v)
#define minimum(a)  *min_element(a.begin(), a.end())
#define maximum(a)  *max_element(a.begin(), a.end())
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
int main()
{
    optimize();
    string s;cin>>s;
    fori(0,sz(s))if(s[i]=='7'){print<<"Yes\n";return 0;}
    print<<"No\n";
    return 0;
}
/*
*****Comment Section**********



*/


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n,h,w;
    cin >> n >> h >> w;
    ll a,b;
    ll ans = 0;
    rep(i,n){
        cin >> a >> b;
        ans += min(a/h,b/w);

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define m 1000000007
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;

int main()
{
	string s,t;
	cin>>s>>t;
	ll ans=0;
	for (int i = 0; i <= 2; ++i)
	{
		if(s[i]==t[i])
			ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    ll ans = 0;
    map<int,int>data;
    rep(i,n){
        int sa = i - a[i];
        ans += data[sa];
        int wa = i+a[i];
        data[wa]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21416
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a.at(i);
    rep(i,m) cin >> b.at(i);
    // 部分文字列を持つか比較して、そこからさらに細かくみていけば良い？
    string res = "No";
    for(int i=0; i<n-m+1; i++){
        int64_t index = -1;
        for(int k=0; k<51; k++){
            index=a.at(i).find(b.at(0), index+1);
            if(index==-1) break;
            for(int j=0;j<m; j++){
                if(index != a.at(i+j).find(b.at(j), index)) break;
                if(j==m-1) res ="Yes";
            }
        }
    }
    cout << res << endl;}


Measured memory_bytes: 256
def main():
    n = input()

    l = len(n)

    nines = "0" + "9" * (l - 1)
    nines = int(nines)

    num = nines
    for i in range(1, 10):
        tmp = i * 10 ** (l - 1) + nines
        if tmp <= int(n):
            num = tmp

    ans = sum(map(int, str(num)))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 20;
ll n, m, x, y, q, d,z, w = 0, sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	string s, t; cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i])ans++;
	}cout << ans << endl;
}

Measured memory_bytes: 3860
n = int(input())
a = list(int(input()) for _ in range(n))

c = 0
for i in range(n):
    if a[i] > 0:
        if i > 0 and a[i - 1] > 0:
            c += 1
            a[i] -= 1

        c += a[i] // 2
        a[i] %= 2

print(c)

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

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

    int fav[M];
    for (int i=0; i<M; i++) fav[i]=0;

    for (int i=0; i<N; i++){
        int K;
        cin >> K;
        for (int j=0; j<K; j++){
            int A;
            cin >> A;
            A--;
            fav[A]++;
        }
    }

    int ans = 0;
    for (int i=0; i<M; i++){
        if (fav[i]==N){
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i=0;i<n;i++){
        ll j;
        cin >> j;
        v.push_back(j);
    }
    for(ll i=0;i<n;i++) {
        if(i == 0) {
            cout <<v[n-i-1];
        }else {
            cout <<" "<<v[n-i-1];
        }
    }
    cout << endl;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int l,r;
	cin>>l>>r;
	int ans;
	for(int i=1;i<m;i++)
	{
		int g,h;
		cin>>g>>h;
		l=max(l,g);
		r=min(r,h);
		if(l>r)
        {ans=0;
        break;}
		else
		ans=r-l+1;
	}
  if(m==1)
  ans=r-l+1;
	cout<<ans;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(lambda x: int(x) - 1, input().split()))

now = 0
seen = []
while True:
    seen.append(now)
    teleporter = A[now]
    A[now] = 'used'
    if teleporter == 'used':
        break
    else:
        now = teleporter  

loop_s = seen.index(now)
size = len(seen) - loop_s - 1

if K <= loop_s:
    print(seen[K] + 1)
else:
    print(seen[loop_s +(K - loop_s) % size] + 1)

Measured memory_bytes: 96948
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, ans = 0;
    cin >> n;
    for (ll i = 1; i <= n; ++i) {
        ll t = n / i;
        ans += t * (t + 1) / 2 * i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;
 
 
int N;
vector<P> G[MAX];
int col[MAX];
 
void dfs(int v, int c){
	col[v]=c;
	int l=sz(G[v]);
	rep(i,l){
		P p=G[v][i];
		int nv=p.first;
		int d=p.second;
		if(col[nv]!=-1)continue;
		int nc=(c+d)%2;
		dfs(nv,nc);
	}
}
 
 
int main(){
	cin>>N;
	rep(i,N-1){
		int u,v,w;
		cin>>u>>v>>w;
		u--;
		v--;
		w=w%2;
		G[u].push_back(make_pair(v,w));
		G[v].push_back(make_pair(u,w));
	}
	
	rep(i,N)col[i]=-1;
	dfs(0,0);
	
	rep(i,N)cout<<col[i]<<endl;
	
}

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

using namespace std;

typedef long long ll;

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

int main(int, char**) {
	int n, k; cin >> n >> k;
	int upr = (n - 2) * (n - 1) / 2;
	if (k > upr) {
		cout << -1 << endl;
		return 0;
	}
	int m = n - 1 + (upr - k);
	cout << m << endl;
	for (int i=0; i< n - 1; i++) {
		cout << 1 << " " << i+2 << endl;
	}
	if (upr - k == 0) return 0;
	int cnt = 0;
	for (int j=2; j < n; j++) {
		for (int i=j+1; i < n+1; i++) {
			cout << j << " " << i << endl;
			cnt++;
			if (cnt==(upr - k)) break;
		}
		if (cnt==(upr - k)) break;
	}
	return 0;
}

Measured memory_bytes: 3576
import sys
def input(): return sys.stdin.readline().strip()

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R.sort()

idx_p = X
idx_q = Y
eatR = 0

for i in range(1, C + 1):
    r = R[-i]
    if idx_p <= 0 and idx_q <= 0:
        break

    elif idx_p <= 0:
        if Q[-idx_q] >= r:
            break
        else:
            eatR += r
            idx_q -= 1

    elif idx_q <= 0:
        if P[-idx_p] >= r:
            break
        else:
            eatR += r
            idx_p -= 1

    elif P[-idx_p] >= r and Q[-idx_q] >= r:
        break

    elif P[-idx_p] >= r:
        eatR += r
        idx_q -= 1
    
    elif Q[-idx_q] >= r:
        eatR += r
        idx_p -= 1
    
    else:
        diff_p = r - P[-idx_p]
        diff_q = r - Q[-idx_q]
        if diff_p >= diff_q:
            eatR += r
            idx_p -= 1
        else:
            eatR += r
            idx_q -= 1

ans = eatR + sum(P[(A - idx_p):]) + sum(Q[(B - idx_q):])
print(ans)

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

int main(){
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    rep(i,s.size()){
        if(s[i]!=t[i]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long a,br,b;
    double g;
    cin >> a;
    cin >> g;
    b=g*100+0.1;
    br=(a*b)/100;
    cout << br;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Poor(void) {

	int num[3];
	int counter = 0;

	cin >> num[0] >> num[1] >> num[2];

	for (int loop1 = 0; loop1 < 3; loop1++) {
		for (int loop2 = loop1 + 1; loop2 < 3; loop2++) {
			
			if (num[loop1] == num[loop2]) counter++;
		}
	}

	if (counter == 1) cout << "Yes" << flush;
	else cout << "No" << flush;

	return;
}

void B_Papers_Please(void) {

	int N;
	cin >> N;

	int A;
	for (int loop = 0; loop < N; loop++) {
		cin >> A;
		if (A % 2 == 0 && A % 3 > 0 && A % 5 > 0) {
			cout << "DENIED";
			return;
		}
	}

	cout << "APPROVED";
	return;
}

void C_Poll(void) {

	int N;
	cin >> N;

	vector<string> S(N);
	for (int loop = 0; loop < N; loop++) {
		cin >> S[loop];
	}
	sort(S.begin(), S.end());

	int maxNum = 0;
	int counter = 0;
	for (int loop = 0; loop < N; loop++) {

		if (loop == 0 || S[loop].compare(S[loop - 1]) == 0) {

			counter++;
		}
		else {

			counter = 1;
		}

		maxNum = max(counter, maxNum);
	}

	counter = 0;
	for (int loop = 0; loop < N; loop++) {

		if (loop == 0 || S[loop].compare(S[loop - 1]) == 0) {

			counter++;
		}
		else {

			counter = 1;
		}

		if (counter == maxNum) cout << S[loop] << endl;
	}

	return;
}

int main(void) {

	//A_Poor();
	//B_Papers_Please();
	C_Poll();
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v) cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

int fast_mod(int x, int m = MOD) {
	while(x <= m) x -= m;
	if(x < 0) x += m;
	return x;
}

int mod_add(int x, int y) {
	return fast_mod(x + y);
}

int n;
string s, t;

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

	
	cin >> n;
	cin >> s >> t;

	for(int i = 0 ; i < sz(s) ; ++i) {
		cout << s[i] << t[i];
	}	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int cnt=0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        if((i+1)%2==1 && a%2==1){
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int a,b;
    cin  >> a >> b;
    if((a*b)%2==0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
	
	return 0;
}


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



int main()
{
  long long h, w;
  long long ans = 0;
  cin >> h >> w;
  if ((h * w) % 2 == 0)
  {
    if (h == 1 || w == 1)ans = 1;
    else ans = h * w / 2;
  }
  else
  {
    if (h == 1 || w == 1)ans = 1;
    else ans = h * w / 2 + 1;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
 
int main() {
  long long  a,b,c,d;
  cin>>a>>b>>c>>d;
  long long  max=-1e30;

  if(a*c>max){max=a*c;}
 if(a*d>max){max=a*d;}
 if(b*c>max){max=b*c;}
 if(b*d>max){max=b*d;}

 cout<<max;

}

Measured memory_bytes: 3628
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read_vec::<i64>();
    let ans =  n[0] + n[1] / 2;
    println!("{}",ans);
}

Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val L = sc.asSequence().take(n).map { it.toInt() }.toList()
    var r = 0
    var p = 0

    while (r < n) {
        p += L[r]
        if (p <= x) {
            r++
        } else {
            break
        }
    }
    r++
    println(r)
}


Measured memory_bytes: 31524
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max

local n, k = io.read("*n", "*n")
local a = {}
local sum = 0
for i = 1, n do
  a[i] = io.read("*n")
  sum = sum + a[i]
end


local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if(allnums[i]) then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local function getdivisorparts(x, primes)
  local prime_num = #primes
  local tmp = {}
  local lim = mce(msq(x))
  local primepos = 1
  local dv = primes[primepos]
  while(primepos <= prime_num and dv <= lim) do
    if(x % dv == 0) then
      local asdf = {}
      asdf.p = dv
      asdf.cnt = 1
      x = x / dv
      while(x % dv == 0) do
        x = x / dv
        asdf.cnt = asdf.cnt + 1
      end
      table.insert(tmp, asdf)
      lim = mce(msq(x))
    end
    if(primepos == prime_num) then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if(x ~= 1) then
    local asdf = {}
    asdf.p, asdf.cnt = x, 1
    table.insert(tmp, asdf)
  end
  return tmp
end

local function getdivisor(divisorparts)
  local t = {}
  local pat = 1
  local len = #divisorparts
  local allpat = 1
  for i = 1, len do
    allpat = allpat * (1 + divisorparts[i].cnt)
  end
  for t_i_pat = 0, allpat - 1 do
    local div = allpat
    local i_pat = t_i_pat
    local ret = 1
    for i = 1, len do
      div = mfl(div / (divisorparts[i].cnt + 1))
      local mul = mfl(i_pat / div)
      i_pat = i_pat % div
      for j = 1, mul do
        ret = ret * divisorparts[i].p
      end
    end
    table.insert(t, ret)
  end
  table.sort(t, function(a, b) return a > b end)
  return t
end

local primes = getprimes(mce(msq(sum)))
local divparts = getdivisorparts(sum, primes)
local divs = getdivisor(divparts)
for i = 1, #divs do
  local div = divs[i]
  local front = {}
  local sum, minussum = 0, 0
  for j = 1, n do
    tmp = a[j] % div
    sum = sum + tmp
    table.insert(front, tmp)
  end
  table.sort(front)
  local cnt = sum
  for j = n, 1, -1 do
    sum, minussum = sum - front[j], minussum + div - front[j]
    cnt = mmi(cnt, mma(sum, minussum))
  end
  -- print(div, cnt)
  if cnt <= k then
    print(div)
    break
  end
end


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, D, X;
    cin >> N >> D >> X;

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

    int sum = X;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= D; j+=A[i]){
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
parseint(x) = parse(Int, x)
readint() = readline() |> parseint
readstr() = readline() |> chomp
readstrlist(n) = [readstr() for _ = 1:n]

function strsort(s::String)
    cs = [c for c in s]
    sort!(cs)
    s = String(cs)
end

c2(n) = (n*(n-1))>>1

function main()
    n = readint()
    s = readstrlist(n)
    s = strsort.(s)
    sort!(s)
    append!(s, [""])
    ans = 0
    num = 1
    for i = 1:n
        if s[i] == s[i+1]
            num += 1
        else
            ans += c2(num)
            num = 1
        end
    end
    println(ans)
end

main()


Measured memory_bytes: 164488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int mod = 9;

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

    string s; cin >> s;
    int ans = 0;
    for (auto i: s) {
        ans += i - '0';
        ans %= mod;
    }
    if (ans) cout << "No";
    else cout << "Yes";


    return 0;
}



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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> topbot(w+2,"#");
  vector<string> data(h);
  rep(i,h) cin >> data.at(i);
  rep(i,w+2) cout << topbot.at(i);
  cout << endl;
  rep(i,h) cout << "#" << data.at(i) << "#" << endl;
  rep(i,w+2) cout << topbot.at(i);
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    ll a,b;
    cin >> a >> b;
    ll c = __gcd(a,b);
    ll ans = 1;
    for (ll i = 2; i * i <= c; i++) {
        if (c % i == 0) {
            ans++;
            while (c % i == 0) c /= i;
        }
    }
    if (c > 1) {
        ans++;
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int sum = 0, num = 0, i = 0;

	int s, n;
	char k;
	while(cin >> s >> k >> n)
	{
		sum += s * n;
		num += n;
		i++;
	}

	cout << sum << endl << int((float)num / i + 0.5) << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	int ans[200005];
	init(ans);
	cin >> n;
	for(int i =1;i<n;i++){
		cin >> x;
		ans[x-1]++;
	}	
	for(int i =0;i<n;i++){
		cout << ans[i]<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 4364
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9+7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;

void die(string s) {
	cout << s << endl;
	exit(0);
}

struct edge {
	int to, cost, index;
};
vector<edge>G[100010];
int D[100010];
int col[100010];
bool vis[100010];
bool use[200020];
void dfs(int n, int pre, int c) {
	vis[n] = true;
	col[n] = c % 2;
	for (auto e : G[n]) {
		int nxt = e.to;
		if (vis[nxt])continue;
		if (!use[e.index])continue;
		vis[nxt] = true;
		dfs(nxt, n, c + 1);
	}
}

void solve() {
	int N, M; cin >> N >> M;
	REP(i, N) {
		cin >> D[i];
	}
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back({ v,(int)1e9,i });
		G[v].push_back({ u,(int)1e9,i });
	}
	vector<int>ans(M, 1e9);
	REP(i, N) {
		bool ok = false;
		for (auto e : G[i]) {
			int nxt = e.to;
			if (D[nxt] <= D[i])ok = true;
		}
		if (!ok)die("-1");
	}
	REP(i, N) {
		P p = { D[i],1e9};
		for (auto &e : G[i]) {
			P nxt = { D[e.to],e.to };
			if (nxt < p)p = nxt;
		}
		for (auto &e : G[i]) {
			if (e.to == p.second) {
				e.cost = D[i];
				use[e.index] = true;
				ans[e.index] = D[i];
				break;
			}
		}
	}
	
	REP(i, N) {
		if (!vis[i])dfs(i, i, 0);
	}
	REP(i, N) {
		if (col[i] & 1)cout << "B";
		else cout << "W";
	}cout << endl;

	//REP(i, N) {
	//	for (auto &e : G[i]) {
	//		ans[e.index] = min(ans[e.index],e.cost);
	//	}
	//}
	REP(i, M) {
		print(ans[i]);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 21760
n=int(input())
t,s=0,0
a=[]
for i in range(n):
    _a=int(input())
    a.append(_a)
    if _a>t:
        t=_a
    elif _a==t or _a>s:
        s=_a
for _a in a:
    if _a==t:
        print(s)
    else:
        print(t)


Measured memory_bytes: 12632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
 
int main() {
	string n; cin >> n;
	string ans;
	if (n == "Sunny") ans = "Cloudy";
	else if(n == "Cloudy") ans = "Rainy";
	else ans = "Sunny";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll A,B,C; cin >> A >> B >> C;
  bool f = false;
  ll cnt = 0;
  while(1) {
    if ( A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ) f = true;
    if(f) {
      cout << cnt << endl;
      return 0;
    }
    
    if ( A == B && B == C ) {
      cout << -1 << endl;
      return 0;
    }

    ll tmpA = A/2,tmpB = B/2,tmpC = C/2;
    ll sumA = tmpB+tmpC,sumB = tmpA+tmpC,sumC = tmpA+tmpB;
    A = sumA,B = sumB,C = sumC;
    cnt++;
    
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll> A(N);
    ll mx=0;
    vector<ll> BT(50);
    rep(i,N){
        ll a;
        cin>>a;
        A[i] = a;
        rep(j,50){
            if(((ll(1)<<(j))&a) != 0){
                //cout<<j<<endl;
                BT[j]++;
            }
        }

    }
    /*rep(i,50){
        cout<<BT[i]<<endl;
    }*/
    ll X=0;
   
    vector<bool> BK;
    ll B=0;
    ll flag = 0;
    rep(i,50){
        if((ll(1)<<(49-i)) & K){
            flag = 1;
        }
        if(flag == 1){
            if((ll(1)<<(49-i)) & K){
                BK.pb(1);
            }else{
                BK.pb(0);
            }
            
        }else{
            //cout << bitset<50>(B)<<endl;
            B += (ll(1)<<(49-i));
        }
    }
    
    ll M = BK.size();
    //reverse(all(BK));
    vector<vector<ll>> dp(M+1,vector<ll>(2));
    rep(i,M){
        ll a,b,c,d;
        a = dp[i][0]+BT[M-1-i]*(ll(1)<<(M-1-i));
        b = dp[i][0]+(N-BT[M-1-i])*(ll(1)<<(M-1-i));
        c = dp[i][1]+BT[M-1-i]*(ll(1)<<(M-1-i));
        d = dp[i][1]+(N-BT[M-1-i])*(ll(1)<<(M-1-i));
        if(i==0){

            dp[i+1][0] = a;
            dp[i+1][1] = max(a,b);
     
        }else{
            if(BK[i]==1){
                dp[i+1][0] = max({a,b,c});
                dp[i+1][1] = d;
            }else{
                dp[i+1][0] = max({a,b});
                dp[i+1][1] = c;
            }
        }
        
        //cout<<dp[i+1][0]<<" "<<dp[i+1][1]<<endl;
    }
    
    ll ans = max(dp[M][0],dp[M][1]);
    //cout<<ans<<endl;
    //cout << bitset<50>(B)<<" "<<bitset<50>(A[0]);
    rep(i,N){
        ans += (B&A[i]);
        //cout<<(B&A[i])<<endl;
    }

    cout << ans << endl;


    return 0;
    

}

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

#include<numeric>

int main(){
    
    size_t n, max = 0;
    std::string s;

    std::cin >> n >> s;

    for(size_t i = 1; i < n; i++){
        size_t cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            bool flag1 = false, flag2 = false;
            for(size_t j = 0; j < i; j++){
                if(s[j] == c) flag1 = true;
            }

            for(size_t j = i; j < n; j++){
                if(s[j] == c) flag2 = true;
            }

            if(flag1 && flag2) cnt++;
        }

        if(max < cnt) max = cnt;
    }

    std::cout << max << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


int* sortArray(int* nums) {
  int length = sizeof(nums) / sizeof(nums[0]);
  length += 1;
  int temp; 
  for (int i = 0; i < length - 1; i ++) { 
    for (int j = i + 1; j < length; j ++) {
      if (nums[i] > nums[j]) {
        temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
      }
    }
  }
  return nums;
} 


int main() {
  int inputs[3], *sorted;
  for (int i = 0; i < 3; i ++) std::cin >> inputs[i];
  sorted = sortArray(inputs);

  std::cout << sorted[0] << " " << sorted[1] << " " << sorted[2] << std::endl;
  return 0;
}

Measured memory_bytes: 1168
def actual(K, S):
    count = 0

    for x in range(K + 1):
        for y in range(K + 1):
            z = S - (x + y)

            cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
            cond2 = (x + y + z) == S

            if cond1 and cond2:
                count += 1

    return count

K, S = map(int, input().split())
print(actual(K, S))

Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int k;
  cin >> k;
  cout << (k/2) * ((k+1)/2) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
 
N = int(input())
E = [tuple(map(int,input().split())) for _ in range(N-1)]
#print(E)
V = [set() for _ in range(N+1)]
for a,b in E:
    V[a].add(b)
    V[b].add(a)
#print(V)
maxc = 0
for v in V:
    maxc = max(maxc,len(v))
#print(maxc)
CE = {}
for e in E:
    CE[e] = 0
#print(CE)
 
def dfs(u,t,c):
    if t > 0:
        CE[(min(u,t),max(u,t))] = c
    cc = c+1
    if cc > maxc:
        cc = 1
    for v in V[u]:
        if CE[(min(u,v),max(u,v))] == 0:
            dfs(v,u,cc)
            cc += 1
            if cc > maxc:
                cc = 1
dfs(1,0,1)
print(maxc)
for e in E:
    print(CE[e])

Measured memory_bytes: 79876
#include <stdio.h>
#include <string.h>

int main(void){
    int i, n; 
    char x[10];

    scanf("%d", &n);
    sprintf(x, "%d", n);

    for(i = 0; i < 3; i++){
    if(x[i] == '0' + 9){
        x[i] = 1;
    }else if(x[i] == '0' + 1) {
        x[i] = 9;
    }
    }
    for(i = 0; i < 3; i++){
    printf("%d",x[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAXN 100005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define KONJ 42-42
using namespace std;

ll n, h[MAXN], sol, pad;

void print(int arr[MAXN][MAXN], int r, int s) {
	cout << "\nTEST:\n";
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; j++) {
			cout << arr[i][j] << " ";
		}
		cout << "\n";
	}
	cout << "\n";
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
		if (i) {
			if (h[i] > h[i - 1]) {
				sol = max(sol, pad);
				pad = 0;
			}
			else pad++;
		}
	}
	
	cout << max(sol, pad);
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    i64 ans = 0;
    vector<pair<i64, i64>> Range(N);
    for(int i = 0; i < N; i++) {
        cin >> Range[i].first >> Range[i].second;
    }

    sort(WHOLE(Range));
    vector<pair<i64, i64>> L(N), R(N);
    i64 l = -1, r = 1e10;
    for(int i = 0; i < N; i++) {
        l = max(l, Range[i].first);
        r = min(r, Range[i].second);
        L[i] = {l, r};
    }
    l = -1, r = 1e10;
    for (int i = N - 1; i >= 0; i--) {
        l = max(l, Range[i].first);
        r = min(r, Range[i].second);
        R[i] = {l, r};
    }

    for(int i = 0; i < N - 1; i++) {
        ans = max(ans,
            max<i64>(0, L[i].second - L[i].first + 1) +
            max<i64>(0, R[i + 1].second - R[i + 1].first + 1));
    }

    for(int i = 0; i < N; i++) {
        ans = max(ans,
            Range[i].second - Range[i].first + 1 + 
            max<i64>(0, 
                min(i >= 0 ? L[i - 1].second : 1e10, i < N - 1 ? R[i + 1].second : 1e10) -
                max(i >= 0 ? L[i - 1].first : 0, i < N - 1 ? R[i + 1].first : 0) + 1)
        );
    }

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

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

int main()
{
    int a;cin>>a;int f=0,g=0;
    if(a<=9) cout<<"Yes"<<endl,f=100;
    else if(f!=100)
    {
        for(int i=1;i<=9;i++)
        {
            int sum=a/i;
            if(a%i==0 && sum<=9)
            {
                cout<<"Yes"<<endl;
                f=100;
                break;
            }
        }
    }
    if(f!=100) cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> a,b,c;
    int n,in;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>in;
        a.push_back(in);
    }
    for(int i=0;i<n;i++){
        cin>>in;
        b.push_back(in);
    }
    for(int i=0;i<n;i++){
        int t=0;
        for(int j=0;j<=i;j++){
            t+=a[j];
        }
        for(int k=i;k<n;k++){
            t+=b[k];
        }
        c.push_back(t);
    }
    cout<<*max_element(c.begin(),c.end())<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool is_natural(const string& score, char cur) {
    char prev = score[0];
    for (int i = 1; i < score.size(); i++) {
        if (prev == score[i]) {
            return false;
        }
        prev = score[i];
    }

    char l = 'm';
    char r = 'm';
    for (int i = 0; i < score.size(); i++) {
        if (cur == 'l') {
            l = score[i];
            cur = 'r';
        } else {
            r = score[i];
            cur = 'l';
        }

        if (l == 'U') {
            if (r == 'L') {
                return false;
            }
        } else if (l == 'R') {
            return false;
        } else {
            if (r == 'L') {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string score; cin >> score;
        cout << ((is_natural(score, 'l') || is_natural(score, 'r')) ? "Yes" : "No") << endl;
    }
    return 0;
}

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

#define ll long long int
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

int main() {_
    ll n;
    cin >> n;
    ll a[n+1] = {};
    ll dp[n+1] = {};

    for(ll i = 1; i<=n; i++) {
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(ll i = 3; i<=n; i++) {
        dp[i] = min(dp[i], dp[i-1] + abs(a[i-1] - a[i]));
        dp[i] = min(dp[i], dp[i-2] + abs(a[i-2] - a[i]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		int[] D = new int[2 * N];

		for (int i = 0; i < 2 * N; i += 2) {
			D[i] = scan.nextInt();
			D[i + 1] = scan.nextInt();
		}
		String ans = "No";

		for (int i = 0; i < 2 * (N - 2); i += 2) {
			if (D[i] == D[i + 1] && D[i + 2] == D[i + 3] && D[i + 4] == D[i + 5]) {
				ans = "Yes";
			}
		}

		//結果出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 36068
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
     
int main(){
  int n,id=1,nv,ch,index,syuryo=1;
       
  scanf("%d\n",&n);
   
  int *A = new int[100040];
  bool *B = new bool[100040];
  int *C = new int[100040];
  string *D = new string[100040];
  int st,ed;
  for(int i=0;i<=100040;i++){
    A[i]=0; // hukasa
    C[i]=-1; // oya
    B[i]=false; //false nara ko wo motte inai
  }
  for(int i=0;i<n;i++){
    scanf("%d",&id);
      
    getline(cin,D[id]);
   
    syuryo=1;
    for(int r=1;r<=D[id].length();r++){
      if(D[id][r] == ' '){
    syuryo = r-1; // String no iti gime
    break;
      }
    }
     
    index = atoi(D[id].substr(1,syuryo).c_str()); 
  
    if(index != 0)B[id]=true;
         
  
    if(index != 0){
      st = syuryo+2;   
      for(int d = syuryo+2;d<=D[id].length();d++){
    if(D[id][d] == ' ' || d == D[id].length()){
      A[atoi(D[id].substr(st,d-st).c_str())]=A[id]+1;
      C[atoi(D[id].substr(st,d-st).c_str())]=id;
      if(B[atoi(D[id].substr(st,d-st).c_str())]){
        int st2=3;
          
        for(int j = syuryo+2;j<=D[atoi(D[id].substr(st,d-st).c_str())].length();j++){
            
          if(D[atoi(D[id].substr(st,d-st).c_str())][j] == ' ' || j == D[atoi(D[id].substr(st,d-st).c_str())].length()){
        A[atoi(D[atoi(D[id].substr(st,d-st).c_str())].substr(st2,j-st2).c_str())]=A[atoi(D[id].substr(st,d-st).c_str())]+1;
        st2=j+1;
          }
        }
      }
      st = d+1;
    }
      }
        
    }
      
  }
       
   
       
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,C[i],A[i]);
    int cou=0;
    if(C[i] == -1){printf("root, [");}
    else if(!B[i])printf("leaf, [");
    else printf("internal node, [");
      
  
    syuryo=1;
    for(int r=1;r<=D[i].length();r++){
      if(D[i][r] == ' '){
    syuryo = r-1;
    break;
      }
    }
    index = atoi(D[i].substr(1,syuryo).c_str());
      
    st=syuryo+2;
    if(index != 0){     
      for(int j=syuryo+2;j<=D[i].length();j++){
    if(D[i][j] == ' ' || D[i].length() == j ){
      printf("%d",atoi(D[i].substr(st,j-st).c_str()));
      if(j != D[i].length())printf(", ");
      st=j+1;
    }
      }
    }
    printf("]\n");
  }
       
  delete [] A;
  delete [] B;
  delete [] C;
  delete [] D;
  return 0;
}


Measured memory_bytes: 9812
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;

bool equal(int n[], int m[], int k){
    for (int i = 0; i<k ; i++){
        if(n[i] != m[i]){
            return false;
        }
    }
    return true;
}

int main(){
    int n, a = 0, b = 0, count = 0;
    cin >> n;
    int p[n], q[n], temp[n];
    
    for(int i = 0; i<n; i++){
        cin >> p[i];
        temp[i] = p[i];
    }
    
    for(int i = 0; i<n; i++){
        cin >> q[i];
    }
    
    sort(temp, temp+n);

    do{
        count++;
        if(a != 0 && b != 0){
            break;
        }
        if (equal(temp, p, n) && a == 0){
            a = count;
        }
        if(equal(temp, q, n) && b == 0){
            b = count;
        }
    }while(next_permutation(temp, temp+n));
    
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

int main() {

	int n, m;

	cin >> n >> m;
	vector<int> vecl(m), vecr(m);
	rep0(i, m) {
		cin >> vecl[i] >> vecr[i];
	}
	sort(all(vecr));
	sort(rall(vecl));
	cout << max(vecr[0] - vecl[0]+1, 0);

}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			char c[]=in.next().toCharArray();
			boolean judge=true;
			char now=c[0];
			int cnt=1;
			for(int i=0;i<c.length;i++)//left start
			{
				if(cnt%2!=0&&c[i]=='R')
					judge=false;
				if(cnt%2==0&&c[i]=='L')
					judge=false;
				if(i+1<c.length&&now==c[i+1])
					judge=false;
				if(i+1<c.length)
					now=c[i+1];
				cnt++;
			}
			cnt=1;
			if(judge)
				System.out.println("Yes");
			else
			{
				judge=true;
				now=c[0];
				for(int i=0;i<c.length;i++)//right start
				{
					if(cnt%2!=0&&c[i]=='L')
						judge=false;
					if(cnt%2==0&&c[i]=='R')
						judge=false;
					if(i+1<c.length&&now==c[i+1])
						judge=false;
					if(i+1<c.length)
						now=c[i+1];
					cnt++;
				}
				System.out.println(judge ? "Yes":"No");
			}
		}
	}
}

Measured memory_bytes: 25204
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp3
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			string ans = ((ab[0] * ab[1]) % 2 == 0) ? "Even" : "Odd";

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(){
	int A, B;
	scanf("%d%d",&A,&B);
	if (A+B>16){
		if (A > 8 && B<=7||B>8&&A<=7){
			printf(":(");

		}
		else{
			printf("Yay!");
		}
	}
	else if (A > 8 && B <= 7 || B>8 && A <= 7){
		printf(":(");
	}
	else{
		printf("Yay!");
	}
	return 0;
}

Measured memory_bytes: 128