akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main() {
   int n; cin>>n;
   vector<char> s(n);
   rep(i,0,n) cin>>s[i];
   sort(s.begin(),s.end());
   int ans=1;
   rep(i,0,n-1){
      if(s[i]!=s[i+1]) ans++;
   }
   if(ans==3) cout<<"Three"<<endl;
   else cout<<"Four"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    int min=0;
    for(int i=0; i<K; i++)
    {
        min+=A.at(i);
    }
    cout << min << endl;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**7)

n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    tree[u].append((v, w))
    tree[v].append((u, w))

ans = [0 for _ in range(n)]

def journey(u, p, bit):
    ans[u] = bit
    for v, w in tree[u]:
        if v == p: continue
        if w % 2 == 0: journey(v, u, bit)
        else: journey(v, u, 1-bit)
    
journey(0, -1, 0)
[print(x) for x in ans]

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;


int main(){
    int n,q;
    string s;
    cin >> n >> s >> q;
    // set<char> C;
    vector<set<int>> is(26);
    rep(i,n){
        is[s[i]-'a'].insert(i);
    }
    rep(i,q){
        int ty;cin>>ty;
        if(ty==1){
            int ac;char x;
            cin >> ac>>x;
            --ac;
            is[s[ac]-'a'].erase(ac);
            s[ac]=x;
            is[s[ac]-'a'].insert(ac);
        }else{
            int l,r;cin>>l>>r;
            --l;
            // cout << endl;
            int ans = 0;
            rep(i,26){
                auto it = is[i].lower_bound(l);
                if(it!=is[i].end()&&*it<r)++ans;
            }
            // cout << endl;
            cout << ans << endl;
        }
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<double> vec(N);
  double ans = 0;
  rep(i, N){
    cin >> vec[i];
    ans +=  1.0 / vec[i];
  } 
  cout << 1.0 / ans << endl;
  
}

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

int main()
{
    int n; 
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 0, 3*n)
        cin >> a[i];

    priority_queue<int, vector<int>, greater<int>> left;
    priority_queue<int, vector<int>, less<int>> right;

    vector<ll> ans(3 * n, 0);
    ll sum = 0;
    rep(pos, 0, 2 * n)
    {
        ll new_a = a[pos];
        left.push(new_a);
        sum += new_a;
        if (pos >= n)
        {
            ll old_a = left.top();
            left.pop();
            sum -= old_a;
            // cout << pos << ' ' << old_a << ' ' << new_a << ' ' << sum << endl;
        }
        ans[pos] += sum;
    }
    sum = 0;
    rrep(pos, 3 * n, n - 1)
    {
        ll new_a = a[pos];
        right.push(new_a);
        sum += new_a;

        if (pos < 2 * n)
        {
            ll old_a = right.top();
            right.pop();
            sum -= old_a;
            // cout << pos << '*' << old_a << ' ' << new_a << ' ' << sum << endl;
        }
        if (pos - 1 >= 0) ans[pos - 1] -= sum;
    }

    // cout << "******" << endl;
    ll max_ans = ans[n-1];
    rep(pos, n - 1, 2 * n)
        // cout << pos << ' ' << ans[pos] << endl;
        max_ans = max(max_ans, ans[pos]);
    cout << max_ans << endl;
    return 0;
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
int N, a, nicnt = 0, cnt = 0;;
  cin >> N;
bool ans = false;  
  
  for(int i = 0;i < N;i++){
  cin >> a;
    if(a % 4 == 0) cnt++;
    else if((a % 2 == 0) && (a % 4 != 0)) nicnt++;  
  }
 
  if((nicnt > 0) && ((N - nicnt) % 2 == 0)){
    N -= nicnt;
    if(cnt >= N / 2) ans = true;
  }
  
  else if((nicnt > 0) && ((N - nicnt) % 2 == 1)){
    N -= nicnt;
    if(cnt >= N / 2 + 1) ans = true;
  }
    
  else if(nicnt == 0){
    if(cnt >= N / 2) ans = true;
  }
 
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
ll a[N];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    scanf("%lld",&a[i]);
    if(k>=n)printf("0");
    else
    {
        ll ans=0;
        int c=n-k;
        sort(a+1,a+1+n);
        for(int i=1;i<=c;i++)
            ans+=a[i];
        printf("%lld",ans);
    }
    return 0;
}



Measured memory_bytes: 1792
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next();
    let a_line = lines.next().unwrap().unwrap();
    let splited = a_line.trim().split_whitespace();
    let mut vs: Vec<f64> = splited.map(|s| s.parse().unwrap()).collect();

    let mut vs = &mut vs[..];
    while vs.len() > 1 {
        vs.sort_by(|a, b| a.partial_cmp(b).unwrap());
        vs[1] = (vs[0] + vs[1]) / 2.0;
        vs = &mut { vs }[1..];
    }

    writeln!(&mut writer, "{}", vs[0]).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"2
3 4", br"3.5
",
        ),
        (
            br"3
500 300 200",
            br"375
",
        ),
        (
            br"5
138 138 138 138 138",
            br"138
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    a[n - 1] /= 2;
    int sum = 0;
    rep(i, n) sum+=a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a,a);
}

int lcm(int x, int y){
	if(x == 0 || y==0) return 0;
	return x/gcd(x, y) *y;
}

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

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

  int cnt = 0;
  int B = A[0];
  while( B%2 == 0 ){
    B /= 2;
    cnt++;
  }
  for( int i = 1; i < N; i++ ){
    B = A[i];
    int now = 0;
    while( B%2 == 0 ){
      B /= 2;
      now++;
    }
    //2で割れる回数が異なったら
    if( cnt != now ){
      cout << 0 << endl;
      return 0;
    }
  }

  int LCM;
  if( N >= 2 ) LCM = lcm(A[0], A[1]);
  else LCM = A[0];
  
  for( int i = 2; i < N; i++ ){
    LCM = lcm(LCM, A[i]);
    if( LCM > M ){
      cout << 0 << endl;
      return 0;
    }
  }

  cout << (M/LCM+1)/2 << endl;
}


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

int main(){
  long long X,K,D; cin >> X >> K >> D;
  X = abs(X);
  long long k;
  k = K - (X - X%D)/D;
  if (k <= 0) cout << abs(X-D*K) << endl;
  else {
    if (k%2 == 0) cout << X%D << endl;
    else cout << abs(X%D - D) << endl;
  }
}

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

int main(void){
    int n, m;
    std::cin >> n >> m;
    int a;
    for(int i = 0; i < m; i++){
        std::cin >> a;
        n = n - a;
    }
    if(n < 0){
        std::cout << "-1" << std::endl;
    }else{
        std::cout << n << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
  cin>>n>>k;
  long sm=0;
  long arr[n+1];
  for(int i=0;i<n;i++){
  cin>>arr[i];

  }
  long long ans[n+1];
  ans[0]=0;
  //ans[1]=arr[1];
  ans[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<n;i++){
    long long mn=1000000000;
  for(int j=1;j<=k;j++){
        if(i-j<0)break;
    mn=min(mn,abs(arr[i]-arr[i-j])+ans[i-j]);
  }
    ans[i]=mn;
  }
cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int ans=1;
   int ans1=1;
   int ans2=1;
   for(int i=0;i<(n);i++)
   {
       ans*=10;
       ans1*=8;
       ans2*=9;
       ans%=M;
       ans1%=M;
       ans2%=M;
   }
   ans2=(ans2-ans1+M)%M;
   ans2*=2;
   ans2%=M;
   ans2+=ans1;
   ans2%=M;
   cout<<(ans-ans2+M)%M<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する

vector<int>to[200005];
vector<int>ans;

void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) {
			continue;
		}
		ans[u] += ans[v];
		dfs(u, v);
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; cin >> n >> q;
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	rep(i, q) {
		int p, x; cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

string divide[4] ={"dream","dreamer","erase","eraser"};

int main(){
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i=0;i<4;++i) reverse(divide[i].begin(),divide[i].end());
	bool can = true; 
	for(int i=0;i<s.size();){
		bool can2 = false;
		for(int j=0;j<4;++j){
			string d = divide[j];
			if(s.substr(i,d.size()) == d){
					can2 = true;
					i += d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	}
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){
	//Code here bby
  int n;
  cin>>n;
  string s;
  cin>>s;
  int wTotal, rTotal;
  wTotal = rTotal = 0;
  for(char idx : s){
    if(idx == 'W'){
      wTotal++;
    } else {
      rTotal++;
    }
  }
  if(rTotal == 0 || wTotal == 0){
    cout<<0<<endl;
    return 0;
  }
  int wCurr, rCurr;
  wCurr = rCurr = 0;
  if(s[0] == 'W'){
    wCurr++;
  } else {
    rCurr++;
  }
  int res = -1;
  for(int idx = 1; idx < n; idx++){
    int swap = min((rTotal - rCurr), wCurr);
    int ops = wCurr + (rTotal - rCurr) - swap;
    if(res == -1){
      res = ops;
    } else {
      res = min(res, ops);
    }
    if(s[idx] == 'W'){
      wCurr++;
    } else {
      rCurr++;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


int cntC(string s1, string s2){
	set<char> sa, sb;
	for(auto c : s1) sa.insert(c);
	for(auto c : s2) sb.insert(c);
	int cnt = 0;
	for(auto e : sa){
		cnt += sb.count(e);
	}
	return cnt;
}


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

	int ans = 0;
	rep(i, 1, N){
		string s1, s2;
		rep(j, 0, i) s1.push_back(S[j]);
		rep(j, i, N) s2.push_back(S[j]);
		ans = max(ans, cntC(s1, s2));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define E(n,e)else if(!(k&n))for(x=0;x<5;x++)puts(k&1<<(e+x)?"1":"2");
#define K(n)||(k&n)==n
#define M 1015808
i,k;main(x){for(;;i++){scanf("%d",&x);if(!x)return 0;k+=1<<(5*x+i);if(i==4){if((k&992&&k&31744&&k&M)K(992)K(31744)K(M))for(x=5;x--;)puts("3");E(992,10)E(31744,15)E(M,5)k=0,i=-1;}}}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

lint Count(vector<int> r, vector<int> g, vector<int> b, string jun)
{
    vector<int> t1 = (jun[0] == 'R') ? r : (jun[0] == 'G') ? g : b;
    vector<int> t2 = (jun[1] == 'R') ? r : (jun[1] == 'G') ? g : b;
    vector<int> t3 = (jun[2] == 'R') ? r : (jun[2] == 'G') ? g : b;

    lint count = 0;
    for (auto it1 = t1.begin(); it1 != t1.end(); it1++) {
        auto it2 = lower_bound(t2.begin(), t2.end(), *it1);
        for (auto idx2 = distance(t2.begin(), it2); idx2 < t2.size(); idx2++) {
            auto it3 = lower_bound(ALL(t3), t2[idx2]);
            size_t d = distance(it3, t3.end());
            if (binary_search(ALL(t3), 2 * t2[idx2] - (*it1))) d--;
            count += d;
        }
    }

    return count;
}

void resolve()
{
    int N;
    string S;
    cin >> N >> S;

    vector<int> posR, posG, posB;
    RPT0(i, N)
    {
        if (S[i] == 'R') posR.push_back(i);
        if (S[i] == 'G') posG.push_back(i);
        if (S[i] == 'B') posB.push_back(i);
    }

    lint ans = 0;
    ans += Count(posR, posG, posB, "RGB");
    ans += Count(posR, posG, posB, "RBG");
    ans += Count(posR, posG, posB, "GRB");
    ans += Count(posR, posG, posB, "GBR");
    ans += Count(posR, posG, posB, "BRG");
    ans += Count(posR, posG, posB, "BGR");
    cout << ans << endl;
}

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


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

const int INF = 1000000000;

int main() {
	long long Q, H, S, D, N;
	long long ans = 0;
	long long M = INF;
	
	cin >> Q >> H >> S >> D;
	cin >> N;

	M = M > Q * 8 ? Q * 8 : M;
	M = M > H * 4 ? H * 4 : M;
	M = M > S * 2 ? S * 2 : M;

	if (M > D) {
		ans += (int)(N / 2) * D;
		N %= 2;
	}

	ans += N * (int)(M / 2);

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

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

int main() {
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break;
        }
        char grade;
        if (m == -1 || f == -1) {
            grade = 'F';
        } else if (m + f >= 80) {
            grade = 'A';
        } else if (m + f >= 65) {
            grade = 'B';
        } else if (m + f >= 50) {
            grade = 'C';
        } else if (m + f >= 30) {
            if (r >= 50) {
                grade = 'C';
            } else {
                grade = 'D';
            }
        } else {
            grade = 'F';
        }
        cout << grade << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  int *A = (int *)a;
  int *B = (int*)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main()
{
    int n,a[100000],pair[100000],i,j = 0,k;

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

    long long cnt = 1;
    for (i = 0; i < n - 1; i++)
    {
        if(a[i] == a[i + 1])cnt++;
        else {
            if(2 <= cnt && cnt < 4){
                pair[j] = a[i];
                cnt = 1;
                j++;
            }
            else if(4 <= cnt)
            {
                pair[j] = a[i];
                j++;
                pair[j] = a[i];
                j++;
                cnt = 1;
            }
            
        }
    }
    if(2 <= cnt && cnt < 4){pair[j] = a[i];cnt = 1;j++;}else if(4 <= cnt){pair[j] = a[i];j++;pair[j] = a[i];j++;cnt = 1;}
    if(j < 2)
    {
        printf("0");
    }
    else
    {
        printf("%lld",(long long)pair[j - 1] * (long long)pair[j - 2]);
    }
}

Measured memory_bytes: 892
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <utility>
#include <iostream>
#include <algorithm>
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=(n)-1;i>=a;--i)
#define foredge(u,i) for(int i=head[u];~i;i=l[i].nxt)
#define mem(a,x) memset(a,x,sizeof(a))
#define LOG(a) cout<<'#'<<a<<endl
void print_array(int *a,int n){printf("#");for(int i=0;i<n;i++) printf("%d%c",a[i],i==n-1?'\n':' ');}
typedef long long ll;
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> pii;
const double EPS=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;

const int sz=100005;


ll a[sz],b[sz];
ll c[sz],pre[sz];
ll num[sz],tmp[sz];
ll n;

ll ans=0;
void merge(int l,int r){
	if(r-l<=1) return;
	int mid=(l+r)/2;
	merge(l,mid), merge(mid,r);//递归子问题
	int a=l, b=mid, p=a;
	while(a<mid || b<r){
		if(b>=r || (a<mid&&num[a]<num[b])){
			tmp[p++]=num[a++];
		}else{
			tmp[p++]=num[b++];
			ans+=mid-a;
		}
	}
	rep(i,l,r){
		num[i]=tmp[i];
	}
}

bool check(int x){
	rep(i,0,n){
		c[i]=(a[i]>=x);
		// c[i]=(a[i]>=x?1:-1);
	}
	// puts("c ");
	// rep(i,0,n) printf("%d ",c[i]);
	// puts("");
	rep(i,1,n+1){
		pre[i]=pre[i-1]+c[i-1];
	}

	rep(i,0,n+1){
		// num[i-1]=(pre[i]);
		num[i]=(i-2*pre[i]);
	}
	// puts("num ");
	// rep(i,0,n) printf("%d ",num[i]);
	// puts("");
	ans=0;
	merge(0,n+1);
	// LOG("check "<<x<<' '<<(ans>=(n*(n-1))/4?"true":"false"));
	// LOG(ans);
	return ans>=(ll(n)*(n+1))/4;
}

int main(){
	scanf("%lld",&n);
	rep(i,0,n){
		scanf("%lld",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	// puts("b ");
	// rep(i,0,n) printf("%d ",b[i]);
	// puts("");
	int l=0,r=n;//l satisfy
	// check(40);
	while(r-l>1){
		int mid=(l+r)/2;
		if(check(b[mid])) l=mid;
		else r=mid;
	}
	// LOG(l);
	printf("%lld\n",b[l]);

	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

namespace beet{
  
  template<typename T>
  void swap(T &a,T &b){
    T x=a;
    a=b;
    b=x;
  }

  const int MAX = 1e5+10;
  struct UnionFind{
    int r[MAX],p[MAX],w[MAX];
    UnionFind(int n){
      for(int i=0;i<n;i++){
        r[i]=1;
        p[i]=i;
        w[i]=0;
      }    
    }
    int find(int x){
      if(p[x]==x){
        return x;
      }
      int t=find(p[x]);
      w[x]+=w[p[x]];
      return p[x]=t;
    }
    int same(int x,int y){
      return find(x)==find(y);
    }
    int weight(int x){
      find(x);
      return w[x];
    }
    void unite(int x,int y,int d){
      d+=weight(x);
      d-=weight(y);
      x=find(x);y=find(y);
      if(x==y) return;
      if(r[x]<r[y]) swap(x,y),d=-d;
      r[x]+=r[y];
      p[y]=x;
      w[y]=d;
    }
    int diff(int x,int y){
      return weight(y)-weight(x);
    }
  };
}
using namespace beet;

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  UnionFind uf(n);
  while(q--){
    int t,x,y;
    scanf("%d %d %d",&t,&x,&y);
    if(t==0){
      int z;
      scanf("%d",&z);
      uf.unite(x,y,z);
    }    
    if(t==1){
      if(uf.same(x,y)){
        printf("%d\n",uf.diff(x,y));
      }else{
        puts("?");
      }
    }
  }  
  return 0;
}



Measured memory_bytes: 3844
n,m = list(map(int, input().split()))
box = sorted(list(map(int, input().split())))

li = []

for i in range(len(box) - 1 ):
    li.append(box[i + 1] - box[i])

lis = sorted(li, reverse = True)

for i in range(n - 1):
    if lis == []:
        break
    else:
        del lis[0]

print(sum(lis))

Measured memory_bytes: 13960
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] h = new int[n];
		int count = 0;
		int max = 1;

		for (int i = 0;i<n ;i++ ) {
			h[i] = sc.nextInt();
		}

		for (int i = 0;i<n ;i++ ) {
			if (max<=h[i]) {
				count++;
				max = Math.max(h[i],max);
			}
		}

		System.out.println(count);


	}
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int current = 100;
  int x = in();
  int counter = 0;
  while(current < x) {
    current *= 1.01;
    ++counter;
  }
  cout << counter;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  S.erase(S.end()-8, S.end());
  cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
X = input()

cnt = [0]*(200001)
for i in range(1,200001):
    pc = bin(i).count('1')
    cnt[i] = cnt[i%pc] + 1
    
plus = X.count("1")+1
minus = X.count("1")-1

defp = int(X, 2)%plus
if minus:
    defm = int(X, 2)%minus
else:
    defm = None

pl = 1
mi = 1
ans = []
for i, x in enumerate(X[::-1]):
    if x == "0":
        ans.append(cnt[(defp+pl)%plus]+1)
    else:
        if minus:
            ans.append(cnt[(defm-mi)%minus]+1)
        else:
            ans.append(0)
    pl = 2*pl%plus
    if minus:
        mi = 2*mi%minus

print(*ans[::-1], sep="\n")

Measured memory_bytes: 87516
#sizeありversion
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}
        self._size = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0
        self._size[x] = 1

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if x == y:
            return
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
            self._size[x] += self._size[y]
        else:
            self.p[x] = y
            self._size[y] += self._size[x]
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    #頂点xが属するグループと同じグループに属する頂点数を得る
    def size(self, x):
        return self._size[self.findSet(x)]

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]


N, M = map(int, input().split())
l = [[int(i) for i in input().split()] for i in range(M)]

ds = DisjointSet()
for i in range(N):
    ds.makeSet(i+1)

ans = [0] * M
ans[M-1] = N * (N - 1) // 2

for i in range(M-1, 0, -1):
    a, b = l[i]
    if ds.same(a, b):
        ans[i-1] = ans[i]
    else:
        x = ds.size(a)
        y = ds.size(b)
        ans[i-1] = ans[i] - x * y
    ds.unite(a, b)

for a in ans:
    print(a)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll seica[111111];
ll ans[111111];

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

    REP(i, 111111){
        seica[i] = 1;
    }

    for(int i = 2;i < 111111;i++){
        for(int j = 2 * i;j < 111111;j += i){
            seica[j] *= i;
            if(seica[j] >= 2 * j){
                ans[j]++;
                seica[j] = 0;
            }
        }
    }

    REP(i, 111111 - 1){
        ans[i+1] += ans[i];
    }


    int q;cin >> q;
    REP(i, q){
        int now;cin >> now;
        cout << ans[now] << endl;
    }

	return 0;
}



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

#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;
using pii = pair<int,int>;

bool comp(const pii &a,const pii &b){
    if(a.second > b.second)return true;
    return false;
}

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int,vector<int>,less<int> > pq;
    vector<pii> vec;

    int tmp;
    rep(i,n){ 
        cin >> tmp;
        pq.push(tmp);
    }

    int tmp2;
    rep(i,m){
        cin >> tmp >> tmp2;
        vec.push_back(make_pair(tmp,tmp2));
    }
    //先頭からN個を取る
    sort(vec.begin(),vec.end(),comp);
    int cnt = 0;
    int cnt2 = 0;
    while(cnt2 < n){
        rep(j,vec[cnt].first){
            pq.push(vec[cnt].second);
            cnt2++;
            if(cnt2 > n)break;
        }
        cnt++;
        if(cnt >= m)break;
    }

    ll ans = 0;
    rep(i,n){
        ans += pq.top();
        pq.pop();
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;

int f[2000006];

int main(void) {

	cin >> N;

	for (int x= 1;x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
				f[tmp]++;
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		cout << f[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 3824
N = input()
if N[-1] =="1":
    print("pon")
elif N[-1] == "2":
    print("hon")
elif N[-1] == "3":
    print("bon")
elif N[-1] == "4":
    print("hon")
elif N[-1] == "5":
    print("hon")
elif N[-1] == "6":
    print("pon")
elif N[-1] == "7":
    print("hon")
elif N[-1] == "8":
    print("pon")
elif N[-1] == "9":
    print("hon")
elif N[-1] == "0":
    print("pon")

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int mod=1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}

int main() {
  int x,y,z;cin>>x>>y>>z;
  int ans=0;
  cout<<z<<" "<<x<<" "<<y<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int imax = INT_MAX;
int imin = INT_MIN;
ll llmax = LLONG_MAX;
ll llmin = LLONG_MIN;


int main()
{
	ll a, b;
	cin >> a >> b;
	a = a - b;
	if (a < 0)
		a = 0;
	cout << a << endl;
	return 0;
}

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

int main()
{
  int n, k ;
  cin >> n >> k  ;
  int l[n];
 for(int i=0; i<n; i++)
   cin >> l[i] ;
  
  sort(l,l+n,greater<int>());
  int ans = 0;
  for(int i=0;i<k;++i)
    ans+=l[i] ;

  cout << ans << endl;
}


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

int main(){
  vector<map<char, int>> v;
  
  int n;
  cin >> n;
  
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    
    map<char, int> mp;
    
    for(char c: s){
      mp[c]++;
    }
    
    v.push_back(mp);
    
  }
  
  map<char, int> tmp = v[0];
  
  for(auto p: v){
    for(auto itr = tmp.begin(); itr != tmp.end(); itr++){
      if(itr->second > 0){
        tmp[itr->first] = min(tmp[itr->first], p[itr->first]);
      }
    }
  }
  
  for(auto itr = tmp.begin(); itr != tmp.end(); itr++){
    for(int i=0; i< itr-> second; i++){
      cout << itr -> first;
    }
  }
  cout << endl;
}

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

using namespace std;

int main() {
    int i,j,n,p,q,temp;
    int t=0;
    int flag=0;
    string s;
    cin>>s;
    if(s[0]=='A')cout<<"T";
    if(s[0]=='T')cout<<"A";
    if(s[0]=='C')cout<<"G";
    if(s[0]=='G')cout<<"C";
    return 0;
}

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

int main() {
	int N, D;
	cin >> N >> D;
	int x[N][D];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> x[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N-1; i++) {
		for (int j = i + 1; j < N; j++) {
			double d = 0;

			for (int k = 0; k < D; k++) {
				d += pow(x[i][k] - x[j][k],2);
			}
			d = sqrt(d);

			if (ceil(d) == floor(d)) {
				ans++;
			}

		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product

INF = 1000000007

def mat2_mul(X, Y):
        z = [[0, 0], [0, 0]]
        for (i, j, k) in product(range(2), range(2), range(2)):
                z[i][j] += X[i][k] * Y[k][j]
        return z

def mat2_pow(X, n):
        if n == 0:
                return [[1, 0], [0, 1]]
        elif n % 2:
                return mat2_mul(X, mat2_pow(X, n - 1))
        else:
                half_pow = mat2_pow(X, n / 2)
                return mat2_mul(half_pow, half_pow)

def fib(n):
        if n == 0:
                return 0
        else:
                f = [[0, 1], [1, 1]]
        return mat2_pow(f, n - 1)[1][1]


N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
ans, start = 1, 0

for k in a:
        ans *= fib(k - start)
        ans %= INF
        start = k + 1

ans *= fib(N - start + 1)
print(ans % INF)

Measured memory_bytes: 7096
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            WriteLine(A + B >= C ? "Yes" : "No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main(){
long i,j,a[25],r;
while(cin>>i){
if(i==0)break;
for(j=0;j<i;j++)cin>>a[j];
r=31;
cout<<r<<endl;
for(j=0;;j++){
if(j==i)j=0;
r-=a[j];
cout<<r<<endl;
r=(r-1)/5*5+1;
cout<<r<<endl;
if(r==1)break;
}
cout<<'0'<<endl;
}
return 0;
}

Measured memory_bytes: 1164
s = input()

count = 0
Len = len(s)
half = Len//2
if Len%2 == 0:
    left = s[:half]
    right = s[half:]
    reverse_right = s[::-1]
    #print(left +" "+ right)
    for i in range(half):
        if left[i] != reverse_right[i]:
            count += 1

else:
    left = s[:half]
    right = s[(half+1):]
    reverse_right = s[::-1]
    #print(left +" "+ right)
    for i in range(half):
        if left[i] != reverse_right[i]:
            count += 1

print(count)

Measured memory_bytes: 38384
n, m = map(int, input().split())
MOD = 10 ** 9 + 7

a = [int(input()) for _ in range(m)]

dp = [0] * (n+3)

for x in a:
    dp[x] = -1

dp[0] = 1

for i in range(n):
    if dp[i] == -1:
        continue
    if dp[i+1] != -1:
        dp[i+1] = ( dp[i+1] + dp[i] ) % MOD
    if dp[i+2] != -1:
        dp[i+2] = ( dp[i+2] + dp[i] ) % MOD

#print(dp)

print(dp[n])

Measured memory_bytes: 7848
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 998244353
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, s;
    int a[3000];
    cin >> n >> s;
    rep(i, n) cin >> a[i];
    int dp[3005][3005];
    rep(i, n + 1) {
        rep(j, s + 1) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, s + 1) {
            dp[i + 1][j] += dp[i][j] * 2;
            dp[i + 1][j] %= MOD;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= MOD;
            }
        }
    }
    cout << dp[n][s] << endl;

    return 0;
}


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

int main() {
	
	int n;
	cin >> n;
	
	vector<pair<int,int> > ar;
	for (int i=0; i<n; i++) {
		int a;
		cin >> a;
		ar.push_back(make_pair(a, i));
	}
	
	sort(ar.begin(), ar.end());
	
	int f[n];
	for (int i=0; i<n; i++) {
		f[ar[i].first] = ar[i].second;
	}
	
	for (int i=0; i<n; i++) {
		cout << ar[i].second + 1 << ' ';
	}
	cout << endl;
	
	
}


Measured memory_bytes: 2164
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		char[] c = w.toCharArray();
		char[] moji = new char[26];
		char a = 'a';
		int count = 0;

		 for (int i = 0; i < moji.length; i++){
		        moji[i] = a++;
		    }

		for (int j = 0; j < moji.length; j++) {
			for (int i = 0; i < c.length; i++) {
				if(c[i] == moji[j]) {
					count++;
				}
			}

			if(count % 2 != 0) {
				System.out.print("No");
				System.exit(0);
			}
		}

		System.out.print("Yes");
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

# define max_n 50

struct points {
    int sx,sy,tx,ty;
};

void print(points p){
    cout << p.sx << " " << p.sy << " " << p.tx << " " << p.ty << endl;
}

int main(void) {
    int i,j;
    int h,w;
    while(cin >> w >> h, h){
        vs s(h),t(h);
        rep(i,h) cin >> s[i] >> t[i];

        points p;
        rep(i,h)rep(j,w){
            if(s[i][j] == 'L'){
                p.sx = i;
                p.sy = j;
            }
            if(t[i][j] == 'R'){
                p.tx = i;
                p.ty = j;
            }
        }

        queue<points> q;
        q.push(p);

        bool used[50][50][50][50]={};
        used[p.sx][p.sy][p.tx][p.ty] = true;

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

        bool ans = false;

        while(q.size()){
            points p = q.front();
            q.pop();

            if(s[p.sx][p.sy] == '%' && t[p.tx][p.ty] == '%'){
                ans = true;
                break;
            }
            if(s[p.sx][p.sy] == '%' || t[p.tx][p.ty] == '%') continue;

            rep(i,4){
                points pp;

                pp.sx = p.sx + dx[i];
                pp.sy = p.sy + dy[i];
                if(pp.sx < 0 || pp.sx >= h || pp.sy < 0 || pp.sy >= w || s[pp.sx][pp.sy] == '#'){
                    pp.sx = p.sx;
                    pp.sy = p.sy;
                }

                pp.tx = p.tx + dx[i];
                pp.ty = p.ty + dy[(i+2)%4];
                if(pp.tx < 0 || pp.tx >= h || pp.ty < 0 || pp.ty >= w || t[pp.tx][pp.ty] == '#'){
                    pp.tx = p.tx;
                    pp.ty = p.ty;
                }

                if(used[pp.sx][pp.sy][pp.tx][pp.ty])continue;

                used[pp.sx][pp.sy][pp.tx][pp.ty] = true;
                q.push(pp);

            }
        }

        if(ans){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 10020
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
long long arr[3] ; 
int main () 
{
	for ( int i = 0 ; i < 3; i++ ) 
		cin >> arr[i] ;	
	sort ( arr , arr+3 ) ;
	if ( arr[0]%2 == 1  && arr[1]%2 == 1 && arr[2]%2==1  ) 
		cout << arr[0]*arr[1] << endl;
	else
		cout << 0 << endl;
}

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

using namespace std;

set<string> s;

int main(){
	
	int n;
	cin >> n;
	
	for(int i=0;i<n;i++){
		string a;
		cin >> a;
		s.clear();
		
		for(int i=1;i<(int)a.size();i++){
			string b,c,d,e;
			b=a.substr(0,i);
			c=a.substr(i);
			d=b;
			reverse(d.begin(),d.end());
			e=c;
			reverse(e.begin(),e.end());
			
			s.insert(b+c);
			s.insert(c+b);
			s.insert(b+e);
			s.insert(e+b);
			s.insert(d+c);
			s.insert(c+d);
			s.insert(d+e);
			s.insert(e+d);
		}
		cout << s.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    string s;
    cin>>s;
    int f=(s[0]-'0')*10+ s[1]-'0';
    int d=(s[2]-'0')*10+ s[3]-'0';
    if((f>=1 and f<=12) and (d>=1 and d<=12)){
        cout<<"AMBIGUOUS";
        return 0;
    }
    else if(f>=1 and f<=12){
        cout<<"MMYY";
    }
    else if(d<=12 and d>=1) 
        cout<<"YYMM";
    else 
        cout<<"NA";
    return 0;
}


Measured memory_bytes: 256