akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 using namespace std;
 int main(){
 char x;
 cin>>x;
 if(int(x)>=65 && int(x)<=90){
    cout<<"A"<<endl;
 }
 else if(int(x)>=97 && int(x)<=122){
    cout<<"a"<<endl;
 }

 return 0;}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int tc;cin>>tc;
  int ac=0,tle=0,re=0,wa=0;
for(int i=0;i<tc;i++)
{
    string s;
    cin>>s;
    if(s=="AC")ac++;
    else if(s=="TLE")tle++;
    else if(s=="RE")re++;
    else
      wa++;

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



  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define pb 		push_back
#define mp 		make_pair
#define pii 	pair<int,int>
#define vi 		vector<int>
#define vii 	vector<vector<int>>;
#define vpii 	vector<pii>
#define ar 		array
#define SZ(x) 	((int)(x.size()))
#define fi 		first
#define se 		second


#define TRvi(a,it)   for(auto (it)=(a).begin(),it!=(a).end();it++) 	
#define FORV (a,x)   for(auto (x):(a))
#define FOR(i,n)	 for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) 	for(int (i)=1;(i)<=(n);++(i))
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)

#define IN(x,y) 	((y).find((x))!=(y).end())
#define ALL(t) 		t.begin(),t.end()

#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
#define all(x) (x).begin(), (x).end()
#define str(s) to_string(s);

typedef long long ll;

const int INF = 1e9;

const int MINV = 1;
const int MAXV = 10;



void a_m(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}
//type the code here






int32_t main()
{
	//type your code here
	a_m();
	string  T;
	cin>>T;
    if(T=="0"){
        cout<<"Yes"<<endl;
        return 0;
    }
	long long int sum=0;
    for(auto &x:T){

        sum += x-'0';
    }
    // cout<<sum<<endl;
    if(sum%9!=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
    
}



Measured memory_bytes: 3700
X = list(int(i) for i in input().split())
cnt = 0

for i in range(X[0], X[1]+1):
    a = int(i / 10000 % 10)
    b = int(i / 1000 % 10)
    c = int(i / 100 % 10)
    d = int(i / 10 % 10)
    e = int(i % 10)
    if a == e and b == d:
        cnt += 1

print("%d" % cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
class lca {
  public:
    using Graph = vector<vector<int>>;
    const int n = 0;
    const int log2_n = 0;
    std::vector<std::vector<int>> parent;
    std::vector<int> depth;

    lca() {}

    lca(const Graph &g, int root)
        : n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) {
        dfs(g, root, -1, 0);
        for (int k = 0; k + 1 < log2_n; k++) {
            for (int v = 0; v < (int)g.size(); v++) {
                if (parent[k][v] < 0)
                    parent[k + 1][v] = -1;
                else
                    parent[k + 1][v] = parent[k][parent[k][v]];
            }
        }
    }

    void dfs(const Graph &g, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        REP(j,g[v].size()) {
            if (g[v][j] != p) dfs(g, g[v][j], v, d + 1);
        }
    }

    int get(int u, int v) {
        if (depth[u] > depth[v]) std::swap(u, v);
        for (int k = 0; k < log2_n; k++) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if (u == v) return u;
        for (int k = log2_n - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};
int main(){
    int N;cin>>N;
    vector<vector<pair<int,int>>> graph(N);
    REP(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        graph[a].push_back({b,i});
        graph[b].push_back({a,i});
    }
    int M;cin>>M;
    vector<pair<int,int>> Q(M);
    REP(i,M){
        cin>>Q[i].first>>Q[i].second;
        Q[i].first--;Q[i].second--;
    }
    function<bool(int,int,int,vector<int>&)> dfs=[&](int now,int pre,int v,vector<int> &D){
        if(now==v) return true;
        for(auto e:graph[now]){
            if(e.first==pre) continue;
            if(dfs(e.first,now,v,D)){
                D.push_back(e.second);
                return true;
            }
        }
        return false;
    };
    ll ans=0;
    vector<vector<int>> E(M);
    REP(i,M){
        dfs(Q[i].first,-1,Q[i].second,E[i]);
    }
    vector<bool> app;
    rep(bit,1,1<<M){
        app.assign(N-1,true);
        REP(i,M) if(bit>>i&1){
            
            for(auto v:E[i]) app[v]=false;
        }
        int n=0;
        REP(i,N-1) if(app[i]) n++;
        if(__builtin_popcount(bit)%2==1) ans+=1LL<<(n);
        else ans-=1LL<<(n);
    }
    ans=(1LL<<(N-1))-ans;
    cout<<ans<<endl;
}

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

#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
#define debu(x, y) cout << "( " << #x << ", " << #y << " ) = ( " << x << ", " << y << " )" << endl
#define int long long

typedef long long ll;
ll mod=1000000007;

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;

    ans = b*d;
    //if( d < 0) {
        ans = max(ans, d*a);
        ans = max(ans, b*c);
    //}
    ans = max(ans, c*a);
    ans = max(ans, (min(c+1, d)*a) );
    ans = max(ans, (min(a+1, b)*c) );
    ans = max(ans, (min(c+1, d)*min(a+1, b)) );

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> t;
  int A;
  for (int i = 0; i < N; i++){
    cin >> A;
    t.push_back(make_pair(A,i+1));
  }
  sort(t.begin(),t.end());
  for (int i = 0; i < N; i++){
    cout << t.at(i).second;
    if (i < N - 1) cout << ' ';
  }
}

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

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int> after_max(N);
  for(int i=N-2; i>=0; i--){
    after_max.at(i) = max(after_max.at(i+1), vec.at(i+1));
  }
  int margin = 0;
  int ans = 0;
  for(int i=0; i<N; i++){
    int x = after_max.at(i) - vec.at(i);
    if(x <= 0){
      continue;
    }
    else if(x == margin){
      ans++;
    }
    else if(x > margin){
      margin = x;
      ans = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes"<<endl;
    else if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b;
  int i;

  scanf("%d %d",&a,&b);

  if(a <= 5){
    i = 0;
  } else if(a >= 6 && a <= 12){
    i = b/2;
  } else {
    i = b;
  }

  printf("%d",i);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char a[201],b[101],c[101];
    scanf("%s %s", a, c);
    strcpy(b,a);
    strcat(a,b);
    if(strstr(a,c) == NULL)printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 3168
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(b-a)<=d&&abs(c-b)<=d)
	cout<<"Yes"<<endl;
	else if(abs(c-a)<=d)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int r; cin >> r;
  cout << r * r << endl;
  return 0;
}


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

const int MAX = 100;
const int INF = 1 << 29;

int n;
int grid[MAX][MAX];

void solve()
{
	int ans[MAX];
	bool visited[MAX];

	for (int i = 0; i < n; i++) {
		ans[i] = INF;
		visited[i] = false;
	}

	ans[0] = 0;

	while (true) {
		int min = INF;
		int min_index;

		for (int i = 0; i < n; i++) {
			if (min > ans[i] && visited[i] == false) {
				min = ans[i];
				min_index = i;
			}
		}

		if (min == INF) {
			break;
		}


		visited[min_index] = true;

		for (int i = 0; i < n; i++) {
			if (grid[min_index][i] != INF&&ans[i] > ans[min_index] + grid[min_index][i]) {
				ans[i] = ans[min_index] + grid[min_index][i];
			}
		}
	}
	

	for (int i = 0; i < n; i++) {
		cout << i << " " << ans[i] << endl;
	}
}

int main()
{
	for (int i = 0; i < MAX; i++) {
		for (int j = 0; j < MAX; j++) {
			grid[i][j] = INF;
		}
	}

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num >> num;

		for (int j = 0; j < num; j++) {
			int k;
			cin >> k;
			cin >> grid[i][k];
		}
	}

	solve();

	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll H, W;
	cin >> H >> W;
	
	ll ans;
	if (H & 1 && W & 1) ans = (H * W + 1) / 2;
	else ans = H * W / 2;
	if (H == 1 || W == 1) ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, X) = (input[0], input[1])
var m = [Int]()
for _ in 0..<N {
    m += [readInt()!]
}
print(N + (X-m.reduce(0){$0+$1})/m.min())


Measured memory_bytes: 7524
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j=0;
    char a[100000],b[100000];
    scanf("%s",a);
    for (i=0;i<strlen(a);i=i+2)
    {
        b[j]=a[i];
        j++;
    }
    b[j]='\0';
    printf("%s\n",b);
    return 0;
}


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int MOD = 1000000009;

int n;
ll c;
pll sus[100010];
ll l[100010] = {}, r[100010] = {};
ll l2[100010] = {}, r2[100010] = {};

int main(){
	cin >> n >> c;
	sus[0] = make_pair(0LL, 0LL);
	sus[n+1] = make_pair(c, 0LL);
	for (int i = 1; i <= n;i++) {
		ll x, v;
		cin >> x >> v;
		sus[i] = make_pair(x, v);
	}
	ll lans = 0LL, lans2 = 0LL;
	int li = 0;
	sort(sus, sus + n);
	for (int i = 1; i <= n;i++) {
		l[i] = l[i - 1] + sus[i].second - sus[i].first + sus[i - 1].first;
		l2[i] = max(l2[i-1], l[i] - sus[i].first);
//		if (lans < l[i]) {
//			lans = l[i];
//			li = i;
//		}
	}
	ll rans = 0LL, rans2 = 0LL;
	int ri = n+1;
	for (int i = n; i >= 1; i--) {
		r[i] = r[i + 1] + sus[i].second + sus[i].first - sus[i + 1].first;
		r2[i] = max(r2[i+1], r[i] - c + sus[i].first);
//		if (rans < r[i]) {
//			rans = r[i];
//			ri = i;
//		}
	}
	ll ans;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, l[i] + r2[i+1]);
		ans = max(ans, r[i] + l2[i-1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector <int> p(a), q(b), r(c);
    for (auto &i : p) cin >> i;
    for (auto &i : q) cin >> i;
    for (auto &i : r) cin >> i;
    ll ans = 0;
    sort(all(p));
    sort(all(q));
    sort(all(r));
    reverse(all(p));
    reverse(all(q));
    reverse(all(r));
    multiset <int> have;
    for (int i = 0; i < x; i++) {
        ans += p[i];
        have.insert(p[i]);
    }
    for (int i = 0; i < y; i++) {
        ans += q[i];
        have.insert(q[i]);
    }
    for (int i = 0; i < c; i++) {
        if (*have.begin() < r[i]) {
            ans -= *have.begin();
            have.erase(have.begin());
            ans += r[i];
            have.insert(r[i]);
        }
        else break;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12964
#include<stdio.h>
#include<math.h>
 
struct Point{ double x,y; };
 

 
void koch(int n, Point a, Point b){
   if(n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;
 
  
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x -s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x -s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
 
  koch(n-1, a, s);
  printf("%8f %8f\n",s.x,s.y);
  koch(n-1, s, u);
  printf("%8f %8f\n",u.x,u.y);
  koch(n-1, u, t);
  printf("%8f %8f\n",t.x,t.y);
  koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;
 
  scanf("%d", &n);
 
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
 
  printf("%8f %8f\n",a.x, a.y);
  koch(n, a, b);
  printf("%8f %8f\n",b.x, b.y);
  
  return 0;
}

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

typedef long long ll;

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];

  map<int,int> even,odd;
  for(int i=0; i<n; i+=2){
    even[v[i]]++;
  }
  for(int i=1; i<n; i+=2){
    odd[v[i]]++;
  }

  int cnt1_e,cnt2_e,cnt1_o,cnt2_o;
  cnt1_e=cnt2_e=cnt1_o=cnt2_o=0;

  int evenM1=0,evenM2=0,oddM1=0,oddM2=0;
  vector<pair<int,int> > evenv,oddv;
  for(auto itr=even.begin(); itr!=even.end(); itr++){
    evenv.push_back(make_pair(itr->second,itr->first));
    //cout << itr->first <<" "<< itr->second << endl;
  }
  for(auto itr=odd.begin(); itr!=odd.end(); itr++){
    oddv.push_back(make_pair(itr->second,itr->first));
    //cout << itr->first <<" "<< itr->second << endl;
  }

  sort(evenv.begin(),evenv.end());
  reverse(evenv.begin(),evenv.end());
  sort(oddv.begin(),oddv.end());
  reverse(oddv.begin(),oddv.end());

  if(evenv.size()>1){
    for(int i=1; i<evenv.size(); i++){
      cnt1_e += evenv[i].first;
    }
    cnt2_e = evenv[0].first;
    for(int i=2; i<evenv.size(); i++){
      cnt2_e += evenv[i].first;
    }
  }
  if(oddv.size()>1){
    for(int i=1; i<oddv.size(); i++){
      cnt1_o += oddv[i].first;
    }
    cnt2_o = oddv[0].first;
    for(int i=2; i<oddv.size(); i++){
      cnt2_o += oddv[i].first;
    }
  }


  if(evenv[0].second == oddv[0].second){
    if(evenv.size()==1) cnt2_e = evenv[0].first;
    if(oddv.size()==1) cnt2_o = oddv[0].first;
    ans = min(cnt1_e+cnt2_o,cnt2_e+cnt1_o);
  }
  else {
    ans = cnt1_e+cnt1_o;
  }

  cout << ans << endl;


  for(int i=0; i<evenv.size(); i++){
    //cout << evenv[i].first <<" "<< evenv[i].second << endl;
  }
  

}

Measured memory_bytes: 6520
#include"cstdio"
int main(){
	int n,i=0,t=1;
scanf("%d",&n);
	while(1){
	if(n!=1)
	{
n=n/2;
t=t*2;
	}
	else{
	break;
	}
	}
printf("%d\n",t);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int w, h;
  scanf("%d %d", &w, &h);
  vi p(w+h);
  deque<vi> c(w+h, vi(2));
  rep (i, w+h) {
    scanf("%d", &p[i]);
    c[i][0] = p[i];
    c[i][1] = i;
  }
  sort(all(c));
  ll cost = 0;
  int cw = 0;
  int ch = 0;
  rep (i, w+h) {
    vi edge = c[i];
    ll num_edge;
    if (edge[1] < w) {
      num_edge = h + 1 - ch;
      cw += 1;
    } else {
      num_edge = w + 1 - cw;
      ch += 1;
    }
    cost += num_edge * edge[0];
  }
  printf("%lld\n", cost);
  return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int k;
	scanf("%d", &k);
	while (k --) printf("ACL");
	return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int len = str.length();
		char[] rl = str.toCharArray();
		int[] count_r = new int[len], count_l=new int[len], count = new int[len];
		int num=0;
		for(int i=len-1;i>=0;i--) {
			if(rl[i]=='L') num=0;
			else {
				num++;
				count_r[i]=num;
			}
		}
		for(int i=0;i<len;i++) {
			if(rl[i]=='R') num=0;
			else {
				num++;
				count_l[i]=num;
			}
		}
		for(int i=0;i<len;i++) {
			if(count_r[i]!=0) {
				if(count_r[i]%2==0) count[i+count_r[i]]++;
				else count[i+count_r[i]-1]++;
			}else {
				if(count_l[i]%2==0) count[i-count_l[i]]++;
				else count[i-count_l[i]+1]++;
			}
		}
		for(int i=0;i<len;i++) System.out.print(count[i]+" ");
		System.out.println();
	}
}

Measured memory_bytes: 44280
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  int count=0;
  string s;

  cin>>s;

  for(int i=1;i<s.size();i++){
    if(s[i-1]=='0'){
      if(s[i]=='0'){
	count++;
	s[i]='1';
      }
    }else{
      if(s[i]=='1'){
	count++;
	s[i]='0';
      }
    }
  }

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


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
vvel solve(int n) {
	if (n == 1) { return { {1} }; }
	int m = n / 2;
	vvel a(n, vel(n));
	rep(i, m) {
		rep(j, n-m) {
			a[i][j+m] = 1;
			a[j + m][i] = 1;
		}
	}
	vvel a1 = solve(m);
	rep(i, m) {
		rep(j, m) {
			a[i][j] = a1[i][j] + 1;
		}
	}
	vvel a2 = solve(n-m);
	rep(i, n-m) {
		rep(j, n-m) {
			a[i+m][j+m] = a2[i][j] + 1;
		}
	}
	return a;
}
signed main(){
	int n; cin >> n;
	vvel a = solve(n);
	rep(i, n-1) {
		for (int j = i + 1; j < n - 1; j++) { cout << a[i][j] << " "; }
		cout << a[i][n - 1] << endl;
	}
}

Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {
	public static void main(String[] a){
		Scanner scn = new Scanner(System.in);
		try{
			while(true){
				long alpha = scn.nextInt();
				long beta = scn.nextInt();
				long gcd = gcd(alpha,beta);
				long lcm = alpha /gcd * beta;
				System.out.println(gcd + " " + lcm);
			}
		}catch(Exception e){

		}

	}
	public static long gcd(long alpha,long beta){
		long x = Math.max(alpha,beta);
		long y = Math.min(alpha,beta);
		long z;
		while(y != 0){
			z = y;
			y = x % y;
			x = z;
		}
		return x;
	}
}

Measured memory_bytes: 26112
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let a: Vec<usize> = (0..n).map(|_| rd.get()).collect();

    let m = 1_000_000 + 5;
    let mut min_facs = (0..m).map(|i| i).collect::<Vec<usize>>();
    for i in 2..m {
        // prime
        if min_facs[i] == i {
            let mut j = i * 2;
            while j < m {
                if min_facs[j] == j {
                    min_facs[j] = i;
                }
                j += i;
            }
        }
    }
    // dbg!(min_facs);

    let mut pairwise_coprime = true;
    let mut seen = std::collections::HashSet::new();
    for &x in &a {
        if !pairwise_coprime {
            break;
        }
        let mut facs = std::collections::HashSet::new();
        let mut y = x;
        while y > 1 {
            facs.insert(min_facs[y]);
            y = y / min_facs[y];
        }
        for f in facs {
            let exist = !seen.insert(f);
            if exist {
                pairwise_coprime = false;
                break;
            }
        }
    }
    if pairwise_coprime {
        println!("pairwise coprime");
        return;
    }

    let mut g = a[0];
    for i in 1..n {
        g = gcd(g, a[i]);
    }
    if g == 1 {
        println!("setwise coprime");
        return;
    }

    println!("not coprime");
}

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

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

const int INF = 1000000007;

int main(){
	int n; cin>>n;
	int a[2][110]={{0}, {0}};
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}

	int cost=0;
	for(int i=0;i<n;i++){
		cost += a[0][i];
	}
	cost += a[1][n-1];

	//cout<< cost <<endl;

	int ans=cost;
	for(int i=0;i<n-1;i++){
		cost -= a[0][n-1-i];
		cost += a[1][n-1-i-1];
		ans = max(cost, ans);
	}
	
	

	cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,t_sum=0,h_sum=0;
  cin>>n;
  string t_card,h_card;
  for(int i=0;i<n;i++){
    cin>>t_card>>h_card;
    int result=t_card.compare(h_card);
    if(result>0)t_sum+=3;
    else if(result<0)h_sum+=3;
    else{
      t_sum++;h_sum++;
    }
    }
    cout<<t_sum<<" "<<h_sum<<endl;
}


Measured memory_bytes: 3192
#!/bin/sh
read S
S1=${S:0:1}
S2=${S:1:1}
S3=${S:2:1}
S4=${S:3:1}
if [ $S1 == $S2 -a $S3 == $S4 -a $S1 != $S3 ];then
	echo Yes
elif [ $S1 == $S3 -a $S2 == $S4 -a $S1 != $S2 ];then
	echo Yes
elif [ $S1 == $S4 -a $S2 == $S3 -a $S1 != $S2 ];then
	echo Yes
else
	echo No
fi


Measured memory_bytes: 376
def lscan; gets.split.map(&:to_i); end
n = gets.to_i
pp = lscan
qq = lscan

i = 0
pi = nil
qi = nil
(1..n).to_a.permutation(n) do |perm|
  pi = i if perm == pp
  qi = i if perm == qq
  i += 1
end

p (pi-qi).abs

Measured memory_bytes: 2172
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

map < string, ll > mp;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
		string s;

		cin >> s;

		mp[s]++;
    }

    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';


}





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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e7 + 5;

int arr[maxr];

void precompute() {
	arr[0] = 0;
	arr[1] = 1;
	for (int i = 2; i < maxr; i++)
		arr[i] = 2;
	for (int i = 2; i < maxr; i++) {
		for (int j = i + i; j < maxr; j += i) {
			arr[j]++;
		}
	}

	for (int i = 0; i < maxr; i++)
		arr[i] *= i;
	for (int i = 1; i < maxr; i++)
		arr[i] += arr[i - 1];
}

int32_t main()
{
	GO;
	int n;
	cin >> n;
	precompute();
	cout << arr[n] << endl;
	return 0;
}

//!

Measured memory_bytes: 81760
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

struct MaxFlow{
private:
    struct edge{ int to, cap, rev, num; bool isrev; };

    int V;
    vector<vector<edge>> G;
    vector<bool> used;

public:
    vector<int> edges;

    MaxFlow(int _V=0){
        V = _V;
        G.resize(V);
        used.resize(V);
    }

    void add(int from, int to, int cap){
        G[from].push_back({ to, cap, (int)G[to].size(),(int)edges.size(),false });
        G[to].push_back({ from, 0, (int)G[from].size()-1,(int)edges.size(),true });
        edges.push_back(0);
    }

    int dfs(int v, int t, int f){
        if(v == t) return f;
        used[v] = true;
        for(int i=0; i<G[v].size(); i++){
            edge& e = G[v][i];
            if(!used[e.to] && e.cap > 0){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    if(!e.isrev) edges[e.num] += d;
                    else edges[e.num] -= d;
                    return d;
                }
            }
        }
        return 0;
    }

    int calculate(int s, int t){
        int ret = 0;
        while(true){
            used.assign(V, false);
            int f = dfs(s, t, INT_MAX);
            if(f == 0) break;
            ret += f;
        }
        return ret;
    }
};

int H, W;
string S[100];
int si, sj, ti, tj;
MaxFlow flow(100*100*2);

signed main(){
    cin >> H >> W;
    rep(i, H) cin >> S[i];

    rep(i, H){
        rep(j, W){
            if(S[i][j] == 'S'){
                si = i;
                sj = j;
            }
            if(S[i][j] == 'T'){
                ti = i;
                tj = j;
            }
        }
    }

    if(si == ti || sj == tj){
        cout << -1 << endl;
        return 0;
    }

    rep(i, H){
        rep(j, W){
            if(S[i][j] == '.') continue;
            flow.add((100*i+j)*2, (100*i+j)*2+1, 1);
        }
    }
    rep(i, H){
        rep(j, W){
            if(S[i][j] == '.') continue;
            rep(k, W){
                if(j == k) continue;
                if(S[i][k] == '.') continue;
                flow.add((100*i+j)*2+1, (100*i+k)*2, 1);
            }
        }
    }
    rep(i, W){
        rep(j, H){
            if(S[j][i] == '.') continue;
            rep(k, H){
                if(j == k) continue;
                if(S[k][i] == '.') continue;
                flow.add((100*j+i)*2+1, (100*k+i)*2, 1);
            }
        }
    }
    cout << flow.calculate((100*si+sj)*2+1, (100*ti+tj)*2) << endl;
}

Measured memory_bytes: 114396
#include<iostream>

using namespace std;

long long attack(long long H, long long enemy) {
    if(H > 1) {
        return enemy + attack(H / 2, enemy * 2);
    } else {
        return enemy;
    }
}

int main() {
    long long H;

    cin >> H;

    long long ans = attack(H, 1);

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       h1: usize,
       m1:usize,
       h2:usize,
       m2:usize,
       k:usize,
    }

    let mut ans: usize = 0;
    let a = h1 * 60 + m1;
    let a2 = h2 * 60 + m2;
    if a2 - a < k {
        echo!(0);
        return;
    }
    ans = a2 - a - k;

    echo!(ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

template <typename T>
class Compress{
public:
  vector<T> X;
  bool ok;
  Compress(){};
  
  int size(){return X.size();}
  void add(T a){ok = false; X.push_back(a); X.push_back(a-1); X.push_back(a+1);}
  void add(const vector<T> a){for(T x:a) add(x);}
  //void add(const vector<T> &a){for(T x:a) add(x);}
  
  void build(){
    ok = true;
    sort(X.begin(),X.end());
    X.erase(unique(X.begin(),X.end()),X.end());
  }
  
  T getL(T x){assert(ok); return lower_bound(X.begin(),X.end(),x) - X.begin();}
  T getU(T x){assert(ok); return upper_bound(X.begin(),X.end(),x) - X.begin();}
};

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  Compress <int> cmp;
  cmp.add(A);
  cmp.add(B);
  cmp.build();

  int ans = 0;
  int i = 0, j = 0, cnt = 0;
  for(auto x:cmp.X){
    while(j < N && B[j] < x) j++, cnt--;
    while(i < N && A[i] <= x)i++, cnt++;
    Max(ans, cnt);
  }
  cout<<ans<<endl;   
  return 0;
}



Measured memory_bytes: 8292
using System.Collections.Generic;
using System.Linq;
using System;

public class TT
{
    public int hh { get; set; }
    public int mm { get; set; }
}

public class hello
{
    public static void Main()
    {
        var tts = new List<TT>();
        for (int i = 0; i < 2; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(s[0]);
            for (int j = 1; j <= 2 * n - 1; j += 2)
                tts.Add(new TT { hh = int.Parse(s[j]), mm = int.Parse(s[j + 1]) });
        }
        var ans = tts.OrderBy(x => x.hh).ThenBy(x => x.mm).ToList();
        var hhprev = 99;   var mmprev = 99;
        for (int i = 0; i < ans.Count(); i++)
        {
            if (ans[i].hh == hhprev && ans[i].mm == mmprev) continue;
            else
            {
                if (i == 0) Console.Write("{0}:{1:00}", ans[i].hh, ans[i].mm);
                else Console.Write(" {0}:{1:00}", ans[i].hh, ans[i].mm);
                hhprev = ans[i].hh;
                mmprev = ans[i].mm;
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 10324
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a; cin >> n >> a;
	if (n <= 9 && a <= 9) {
		cout << n * a << endl;
	}
	else {
		cout << -1 << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    n = int(input())
    P = [int(c) for c in input().split()]
    num = 0
    for i in range(1, n - 1):
        lists = [P[i - 1], P[i], P[i + 1]]
        max_ = max(lists)
        min_ = min(lists)
        if (P[i] != max_ and P[i] != min_):
            num += 1
    print(num)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

void print( vector<int> &vs ) {
  bool first = true;
  for ( const int val : vs ) {
    if ( not first ) {
      cout << " ";
    }
    cout << val;
    first = false;
  }
  cout << endl;
}

void dfs( vector<int> &vs, int rest ) {
  if ( rest == 0 ) {
    print( vs );
  } else {
    int m = vs.empty() ? rest : min( vs[ vs.size() - 1 ], rest );
    for ( int i = m; i >= 1; i-- ) {
      vs.push_back( i );
      dfs( vs, rest - i );
      vs.pop_back();
    }
  }
}

int main() {
  while( true ) {
    int n;
    cin >> n;
    if ( n == 0 ) break;
    vector<int> vs;
    dfs( vs, n );
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  llong finalans = -1e9;
	llong N;
  llong K;
  cin >> N >> K;
  vector<llong> P(N);
  vector<llong> C(N);
  for(llong i=0; i<N; ++i){
    cin >> P[i];
    --P[i];
  }
  for(llong i=0; i<N; ++i) cin >> C[i];
  for(llong i=0; i<N; ++i){
    llong ans = -1e9;
    vector<llong> visited(N, 0);
    vector<llong> score(N, -1e9);
    llong count = -1;
    llong now_place = i;
    llong now_score = 0;
    visited[now_place] = 1;
    while(1){
      ++count;
      now_place = P[now_place];
      now_score += C[now_place];
      score[count] = now_score;
      if(visited[now_place]==1){
        break;
      }
      visited[now_place] = 1;
    }
    if(count+1 >= K){
      for(llong i=0; i<=min(K-1, N-1); ++i){
        ans = max(ans, score[i]);
      }
    }else{
      llong max_under = -1e9;
      for(llong i=0; i<count; ++i){
        max_under = max(max_under, score[i]);
      }
      if(score[count]>0){
        llong max_remain = -1e9;
        for(llong i=0; i<K%(count+1); ++i){
          max_remain = max(max_remain, score[i]);
        }
        if(K%(count+1)==0) max_remain = 0;
        ans = max(score[count] * (K/(count+1)) + max_remain, score[count] * (K/(count+1) -1) + max_under);
      }else ans = max_under;
    }
    finalans = max(finalans, ans);
  }
  cout << finalans << endl;
}

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


def main():
    s = input()
    n = len(s)

    for i in range(n):
        for k in range(i, n):
            if (s[:i] + s[k:]) == 'keyence':
                print('YES')
                exit()

    print('NO')


if __name__ == '__main__':
    main()


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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & -(x))
#define BIT(a,b) ((ll)((a)&(1<<(b)))==0 ? false : true)

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

    ll res=100000;

    string s;
    cin>>s;

    for(ll i=0;i<26;i++)
    {
        ll u=0,e=0;

        for(ll j=0;j<s.size();j++)
        {
            if (s[j]==char(i+'a'))
            {
                e=max(e , u);
                u=0;
            }
            else
            {
                u++;
            }
        }

        e=max(e , u);

        res=min(res , e);
    }

    cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int GetDigitsSum(int N) {
	int digitsSum = 0;
	while (N > 0) {
		digitsSum += N % 10;
		N /= 10;
	}
	return digitsSum;
}

int main()
{
	int N;
	int B;
	int A_B_DigitsSum;
	int answer = 2147483647;

	cin >> N;

	for (int A = 1 ; A <= ( N + 1 ) / 2  ; A++) {

		B = N - A;
		A_B_DigitsSum = 0;
		A_B_DigitsSum += GetDigitsSum(A);
		A_B_DigitsSum += GetDigitsSum(B);
	
		if ( A_B_DigitsSum < answer )
			answer = A_B_DigitsSum;		
	}

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

k, q = map(int, (input().split()))
d = list(map(int, (input().split())))

for qi in range(q):
    n, x, m = map(int, input().split())
    last = x
    eq = 0
    for i in range(k):
        num = ((n-1-i)+(k-1))//k
        last += (d[i]%m) * num
        if d[i]%m == 0: eq += num
    ans = (n-1) - (last//m - x//m) - eq
    print(ans)

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

int main() {
  int N;
  cin >> N;
  
  vector <int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  sort (a.begin(),a.end());
  reverse (a.begin(),a.end());
  
  int A=0;
  int B=0;
  
  for (int i=0; i<N; i++) {
    if (i%2 == 0) {
      A += a.at(i);
    }
    else {
      B += a.at(i);
    }
  }
  
  cout << A-B << endl;
}


Measured memory_bytes: 256