akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

void split(const string& str, char delim, vector<int>& ret)
{
	size_t index = 0;
	while (index < str.size()) {
		size_t next = str.find(delim, index);
		if (next == string::npos) break;
		string tmp = str.substr(index, next - index);
		ret.push_back(atoi(tmp.c_str()));
		index = next + 1;
	}
	string tmp = str.substr(index, str.size() - index);
	ret.push_back(atoi(tmp.c_str()));
}

int main()
{
	string str = "1 , 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
	size_t s;
	cin >> s;
	vector<int> list;

	split(str, ',', list);
	//std::sort(list.begin(), list.end(), less<int>());


	if (s <= list.size()) cout << list[s - 1] << endl;

	return 0;
}

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

int main(){
    int n;
    int a[100];
    cin >> n;
    
    for (int i = 0; i < n; i++)  cin >> a[i];
    for (int j = n - 1; j >= 0; j--) {
        if ( j != n - 1) cout << " ";
        cout << a[j];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3076
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=6005;
int n,m,add,ans,a[N],b[N],f[N][N],nxt[N],last[N];
int check(int x,int y,int z){
	return b[x]==b[y]&&b[y]==b[z];
}
void update(int x,int y,int a,int b,int c){
	f[x][a]=max(f[x][a],f[x][y]+check(y,b,c));
	f[x][b]=max(f[x][b],f[x][y]+check(y,a,c));
	f[x][c]=max(f[x][c],f[x][y]+check(y,a,b));
	f[y][a]=max(f[y][a],f[x][y]+check(x,b,c));
	f[y][b]=max(f[y][b],f[x][y]+check(x,a,c));
	f[y][c]=max(f[y][c],f[x][y]+check(x,a,b));
	f[a][b]=max(f[a][b],f[x][y]+check(x,y,c));
	f[a][c]=max(f[a][c],f[x][y]+check(x,y,b));
	f[b][c]=max(f[b][c],f[x][y]+check(x,y,a));
}
void dp(int x,int y){
	if(y+3>=n){
		return;
	}
	int sy=y/3*3;
	update(x,y,sy+3,sy+4,sy+5);
	int tx=x;
	while(tx&&tx<sy+3){
		tx=nxt[tx];
	}
	if(tx){
		int t=tx/3*3;
		update(x,y,t,t+1,t+2);
	}
	int ty=y;
	while(ty&&ty<sy+3){
		ty=nxt[ty];
	}
	if(ty){
		int t=ty/3*3;
		update(x,y,t,t+1,t+2);
	}
}
int main(){
	memset(f,-1,sizeof(f));
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++){
		scanf("%d",&a[i]);
	}
	b[++m]=a[1];
	b[++m]=a[2];
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i+1]==a[i+2]){
			add++;
		}else{
			b[++m]=a[i];
			b[++m]=a[i+1];
			b[++m]=a[i+2];
		}
	}
	b[++m]=a[3*n];
	n=m;
	for(int i=n-1;i>=1;i--){
		nxt[i]=last[b[i]];
		last[b[i]]=i;
	}
	f[1][2]=0;
	for(int j=2;j<n;j++){
		for(int i=1;i<j;i++){
			if(f[i][j]!=-1){
				ans=max(ans,f[i][j]+check(i,j,n));
				dp(i,j);
			}
		}
	}
	printf("%d\n",add+ans);
	return 0;
}

Measured memory_bytes: 142644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String input = br.readLine();

			String[] tmpArray = input.split(" ");
			int t = Integer.parseInt(tmpArray[0]);
			int d = Integer.parseInt(tmpArray[1]);
			int l = Integer.parseInt(tmpArray[2]);

			if(t == 0 && d == 0 && l == 0){
				break;
			}

			int tide[] = new int[t];

			for(int i = 0; i < t; i++){
				tide[i] = Integer.parseInt(br.readLine());
			}

			int result = 0;
//			int begin = Integer.MIN_VALUE;
			int end = Integer.MIN_VALUE;
			boolean dry[] = new boolean[t];
			for(int i = 1; i < t; i++){
				//明らかに洪水が到達している場合
				if(tide[i - 1] >= l){
					//beginの更新が必要
					if(i == 0 || dry[i - 1]){
//						begin = i;
					}

					end = i - 1;
				}
				//洪水は到達していないが濡れている場合
				else if(i <= end + d){

				}
				//それ以外
				else {
					dry[i] = true;
				}

//				System.out.println("i = "+i+" end "+end);
			}

			for(int i = 1; i < t; i++){
				if(!dry[i]){
					result++;
				}
			}

			System.out.println(result);
		}
	}

}



Measured memory_bytes: 62464
#include <bits/stdc++.h>
#include <vector>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(ALL(l));
    int sum = 0;
    REP(i, n-1){
        sum += l[i];
    }

    if(sum <= l[n-1])
        cout << "No";
    else
        cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
vector<int> v(26,0);
string s;cin>>s;
for(char x:s){
    v[x-'a']++;
}
for(int i=0;i<26;i++){
    if(v[i]==0){cout<<char(i+'a');return 0;}
}
cout<<"None";return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int s;
	vector <int> vec;
	while(cin>>s)
	{
		vec.push_back(s);
		while(1)
		{
			int answer=0;
			if(s%2==0)
			{
				s=s/2;
				vec.push_back(s);
			}
			else
			{
				s=(3*s)+1;
				vec.push_back(s);
			}
			for(int i=0;i<vec.size();i++)
			{
				for(int j=i+1;j<vec.size();j++)
				{
					if(vec.at(i)==vec.at(j))
					{
						answer=j+1;
						cout<<answer;
					}
				}
			}
			if(answer!=0)
			{
				break;
			}
		}
	}
	
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int a[200000];
int cnt[1000001] = {0};
int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	if (n == 1) {
		printf("1\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		bool ok = true;
		int x = a[i];
		if (x == 1) {
			if (cnt[1] >= 2) {
				ok = false;
			}
		} else {
			for (int j = 1; j * j <= x; j++) {
				if (x % j == 0) {
					if (cnt[j] >= 1) {
						ok = false;
						break;
					}
					if (j == 1) {
						if (cnt[x / j] >= 2) {
							ok = false;
							break;
						}
					} else {
						if (cnt[x / j] >= 1) {
							ok = false;
							break;
						}
					}
				}
			}
		}
		if (ok) {
			// printf("%d\n", x);
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6412
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_f)

sum = 0
k.times do |i|
  sum += (q[i] + 1)/2
end

ans = sum
(n-k).times do |i|
  sum -= (q[i] + 1)/2
  sum += (q[i+k] + 1)/2
  ans = sum if ans < sum
end

puts ans



Measured memory_bytes: 16196
n = int(input())
k = int(input())
num = 2**n
list = [format((i),"b").zfill(n) for i in range(num)]
result = []
for i in list:
    a = 1
    for j in range(n):
        if i[j] == "0":
            a *= 2
        else:
            a += k
    result.append(a)
print(min(result))

Measured memory_bytes: 3064
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;


ll arr[100005];

int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<ll>vec;

    for(int i=0;i<n;i++){
        cin>>arr[i];vec.pb(arr[i]);
    }
    sort(vec.begin(),vec.end());

    unordered_map<ll,int>pos;

    for(int i=0;i<n;i++){
        pos[vec[i]]=i;
    }
    int ans =0;
    for(int i=0;i<n;i++){
        if(i%2!=pos[arr[i]]%2)ans++;
    }
    cout<<ans/2<<"\n";
}


Measured memory_bytes: 6004
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for(int i = 60; i >= 0; i--){
        int cnt = 0;
        rep(j,n){
            if(a[j]>>i&1) cnt++;
        }
        if(cnt&1){
            rep(j,n){
                if(a[j]>>i&1) a[j] -= 1ll<<i;
            }
            ans += 1ll<<i;
        }
    }
    

    int rank = 0;
    for(int i = 60; i >= 0; i--){
        int j = rank;
        for(; j < n; j++){
            if(a[j]>>i&1){
                swap(a[rank],a[j]);
                break;
            }
        }
        if(j == n) continue;
        rep(k,n){
            if(k == rank) continue;
            if(a[k]>>i&1){
                a[k] ^= a[rank];
            }
        }
        rank++;
    }
    ll ans2 = 0;
    rep(i,rank) ans2 ^= a[i];
    ans2 *= 2;
    cout << ans+ans2 << endl;
}



Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

string P="ACL";

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

  int K;
  cin>>K;

  string ans="";
  rep(i,K) ans+=P;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;
typedef pair<Pa, ll> info;

vector<info> infos;
int main()
{
	cin >> N;
	rep(i, N - 1) {
		cin >> A >> B >> C;
		infos.push_back(info(Pa(B, C), A));
	}
	rep(i, N) {
		int curr_pos = i;
		int curr_time = 0;
		while (curr_pos != N - 1) {
			Pa p = infos[curr_pos].first;
			if (curr_time > p.first) {
				curr_time = ((curr_time - 1) / p.second + 1) * p.second;
			}
			else {
				curr_time = p.first;
			}
			curr_time += infos[curr_pos].second;
			curr_pos++;
		}
		cout << curr_time << endl;
	}
}


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

int func(int n, int d){
	int ret = 0;
	int eat = 1, num = 0;
	while(eat <= d) {
		ret++;
		num++;
		eat = num * n + 1;
	}
	return ret;
}

int main(){
	int n, d, x;
	scanf("%d%d%d", &n, &d, &x);
	int ans = x;
	for(int i = 0; i < n; i++) {
		scanf("%d", &x);
		ans += func(x, d);
	}
	printf("%d\n", ans);
}


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

ans = 0
if (K % 2 != 0):
  ans = (N // K) ** 3
else:
  for i in range(1,N+1):
    if (i % K == int(K / 2)):
      ans += 1
  ans = ans ** 3 + (N // K) ** 3
print(ans)

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


signed main(){
    int N;
    int A[114514]={};
    int sum=0;
    int sum2;
    cin >> N;
    REP(i,N){cin >> A[i+1];sum+=abs(A[i+1]-A[i]);}
    sum+=abs(A[N]-A[0]);
    REP(i,N){
        sum2=sum;
        if(i==0){
            sum2-=abs(A[1]-A[0]);
            sum2-=abs(A[2]-A[1]);
            sum2+=abs(A[2]-A[0]);
        }else if(i==N-1){
            sum2-=abs(A[N]-A[N-1]);
            sum2-=abs(A[0]-A[N]);
            sum2+=abs(A[0]-A[N-1]);
        }else{
            sum2-=abs(A[i+2]-A[i+1]);
            sum2-=abs(A[i+1]-A[i]);
            sum2+=abs(A[i+2]-A[i]);
        }
        cout << sum2 << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(){
    int i,j,n[21],s[100],t,a,b,r[100];
    
    i=0;
    while (1) {
        scanf("%d",&n[i]);
        if (n[i]==0) break;
        t=0;
        a=0;
        b=1000;
        for (j=0;j<n[i];j++) {
            scanf("%d",&s[j]);
            t+=s[j];
            if (a<s[j]) {a=s[j];}
            if (b>s[j]) {b=s[j];}
        }
        r[i]=t-a-b;
        i++;
        
    }
    for (j=0;j<i;j++) {
        printf("%d\n",(r[j]/(n[j]-2)));
    }
    
    return 0;
    
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
map<int,int> mp;
void solve(){
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(mp[a[i]] == 0) mp[a[i]] = 1;
		else mp[a[i]] *= -1;
		cnt += mp[a[i]];
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 1e5 + 1;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

int n;

int a[MAX_N];
int cnt1[MAX_N];
int cnt2[MAX_N];

vector<pii> vec1;
vector<pii> vec2;

int solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i += 2)
    {
        cnt1[a[i]]++;
    }
    for (int i = 2; i <= n; i += 2)
    {
        cnt2[a[i]]++;
    }
    for (int i = 1; i < MAX_N; ++i)
    {
        if (cnt1[i] > 0)
        {
            vec1.pb(mp(cnt1[i], i));
        }
        if (cnt2[i] > 0)
        {
            vec2.pb(mp(cnt2[i], i));
        }
    }
    sort(vec1.begin(), vec1.end());
    sort(vec2.begin(), vec2.end());
    reverse(vec1.begin(), vec1.end());
    reverse(vec2.begin(), vec2.end());
    int ans = 1e9;
    for (int i = 0; i < min(3, (int)vec1.size()); ++i)
    {
        for (int j = 0; j < min(3, (int)vec2.size()); ++j)
        {
            int x = vec1[i].Y;
            int y = vec2[j].Y;
            if (x != y)
            {
                int res = 0;
                for (int v = 1; v <= n; v += 2)
                {
                    if (a[v] != x)
                    {
                        res++;
                    }
                }
                for (int v = 2; v <= n; v += 2)
                {
                    if (a[v] != y)
                    {
                        res++;
                    }
                }
                ans = min(ans, res);
            }
        }
    }
    if (ans == 1e9)
    {
        cout << n / 2 << endl;
    }
    else
    {
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 2428
/*
 * ID:  ITP1_5_D 
 * Program: Structure Program
 */

#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int i;
    for (i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) 
            printf(" %d", i);
        else {
            for (; x; x /= 10) 
                if ( x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
        }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> triple;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// GaussJordan by BitMatrix
const int MAX_ROW = 100010; // To be set appropriately.
const int MAX_COL = 60; // To be set appropriately.

class BitMatrix {
public:
  BitMatrix(int h = 1, int w = 1) : H(h), W(w) {}
  inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }

  int H, W;

private:
  bitset<MAX_COL> val[MAX_ROW];
};

ostream& operator << (ostream& s, BitMatrix A) {
  s << endl;
  rep(i, A.H) {
    rep(j, A.W) {
      s << A[i][j] << ", ";
    }
    s << endl;
  }
  return s;
}

int GaussJordan(BitMatrix &A, bool is_extended = false) {
  int rank = 0;
  rep(col, A.W) {
    if (is_extended && col == A.W - 1) { break; }
    int pivot = -1;
    for (int row = rank; row < A.H; ++row) {
      if (A[row][col]) {
        pivot = row;
        break;
      }
    }
    if (pivot == -1) continue;
    swap(A[pivot], A[rank]);
    rep(row, A.H) {
      if (row != rank && A[row][col]) {
        A[row] ^= A[rank];
      }
    }
    ++rank;
  }
  return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
  int m = A.H, n = A.W;
  BitMatrix M(m, n + 1);
  rep(i, m) {
    rep(j, n) {
      M[i][j] = A[i][j];
    }
    M[i][n] = b[i];
  }
  int rank = GaussJordan(M, true);

  // check if it has no solution
  for (int row = rank; row < m; ++row) {
    if (M[row][n]) { return -1; }
  }

  // answer
  res.assign(n, 0);
  rep(i, rank) {
    res[i] = M[i][n];
  }
  return rank;
}


int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<ull> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  ull allxor = 0;
  rep(i, N) {
    allxor ^= A[i];
  }
  // NOTE: leave only significant bits.
  rep(i, N) {
    A[i] &= ~allxor;
  }

  BitMatrix matrix(N, 60);
  rep(i, N) {
    for (int j = 59; j >= 0; --j) { // j represents the bit of A[i]. e.g. The j of 1 in 100 is 2.
      matrix[i][59 - j] = (A[i] >> j) & 1LL;
    }
  }
  int rank = GaussJordan(matrix, false); // rank is not used.

  vector<ull> B(N); // The result of GaussJordan transformation.
  rep(i, N) {
    ull x = 0;
    for (int j = 59; j >= 0; --j) {
      if (matrix[i][59 - j] > 0) {
        x += 1LL << j;
      }
    }
    B[i] = x;
  }

  ull x = 0;
  rep(i, N) {
    x = max(x, x ^ B[i]);
  }

  cout << (x * 2) + allxor << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a,c=0,d=0;

int main(){
	cin >> n;
	REP(i,0,n) cin >> a,c+=a%2,d+=1-a%2;
	
	cout << (c%2?"NO":"YES") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b;
  // 整数の入力
  scanf("%d %d", &a, &b);
  // 出力
  if ((a * b) % 2 == 0) {
    printf("Even\n");
  }else{
    printf("Odd\n");
  }
  return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int a[m];
  int sum1=0;
  int sum2=0;
  for(int i = 0; i < m; i++){
    cin>>a[i];
    if(a[i]>x)sum1++;
    else sum2++;
  }
  cout<<min(sum1,sum2)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}
//aとｂの最大公約数を求めるよ！
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
//2のn乗を求めるよ！(二分累乗法)
int tow(ll n) {
	if (n == 0)return 1;
	ll x = tow( n / 2);
	x *= x;
	if (n % 2 == 1)x =x * 2;
	return x;
} 
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long 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;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

int main() {
	llint n, a, b;
	cin >> n >> a >> b;
	llint ans = modpow(2,n,mod);
	ans -= 1;
	ans -= c(n, a,mod);
	ans -= c(n, b,mod);
	while (ans < 0)ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def insert(tree,k):
    y = None
    x = tree
    z = {'key':k, 'parent':None, 'left':None, 'right':None}
    while x != None:
        y = x
        if x['key'] > k:
            x = x['left']
        else:
            x = x['right']
    z['parent'] = y
    if y == None:
        tree = z
    elif y['key'] > k:
        y['left'] = z
    else:
        y['right'] = z
    return tree

def delete_leaf(p,x):
    if left(p,x):
        p['left'] = None
    else:
        p['right'] = None
    return p

def delete_half_leaf(p,x,y):
    if left(p,x):
        p['left'] = y
    else:
        p['right'] = y
    y['parent'] = p
    return p


def left(p,x):
    if p['left'] != None and p['left']['key'] == x['key']:
        return True
    else:
        return False

def delete_internal(p,x):
    y = x['right']
    while y['left'] != None:
        y = y['left']
    x['key'] = y['key']
    if y['right'] == None:
        y['parent'] = delete_leaf(y['parent'],y)
    else:
        y['parent'] = delete_half_leaf(y['parent'],y,y['left'])
    return p

def delete(tree,k):
    x = find(tree,k)
    if x == None: return
    p = x['parent']
    if p == None:
        pass
    else:
        if x['left'] == x['right'] == None:
            p = delete_leaf(p,x)
        elif x['right'] == None:
            p = delete_half_leaf(p,x,x['left'])
        elif x['left'] == None:
            p = delete_half_leaf(p,x,x['right'])
        else:
            p = delete_internal(p,x)
    return tree

def find(tree,k):
    x = tree
    while x != None:
        if x['key'] == k:
            return x
        elif x['key'] > k:
            x = x['left']
        else:
            x = x['right']
    return None

def middleorder(x):
    if x != None:
        middleorder(x['left'])
        print x['key'],
        middleorder(x['right'])

def preorder(x):
    if x != None:
        print x['key'],
        preorder(x['left'])
        preorder(x['right'])



tree = None
m = int(raw_input())
for i in range(m):
    c = raw_input().strip()
    if c[0] == 'i':
        tree = insert(tree, int(c[7:]))
    elif c[0] == 'f':
        x = find(tree, int(c[5:]))
        if x == None:
            print "no"
        else:
            print "yes"
    elif c[0] == 'd':
        tree = delete(tree, int(c[7:]))
    elif c[0] == 'p':
        print '',
        middleorder(tree)
        print
        print '',
        preorder(tree)
        print

Measured memory_bytes: 145956
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int maxn = 2000005;
const int mod = 998244353;
const int inf = 1<<30;

void solve(){
	lli x,k,d;
	cin >> x >> k >> d;
	lli veces = abs(x)/d;
	if(x < 0) x+= min(veces,k) * d;
	else x-= min(veces,k) * d;
	k-= min(veces,k);
	lli ans = 1e18;
	//terminar aqui
	if(k%2 == 0){
		ans= min(ans, abs(x));
	}
	else{
		lli aux = 0ll;
		if(x < 0) aux = x+d;
		else aux = x-d;
		ans = min(ans,abs(aux));
	}
	// del otro lado
	if(k){
		if(x < 0) x+=d;
		else x-=d;
		k--;
		if(k%2 == 0) ans = min(ans,abs(x));
		else{
			if(x < 0)x+=d;
			else x-=d;
			ans = min(ans,abs(x));
		}
	}
	cout << ans << endl;
}

int main(){__
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#include<iostream>
using namespace std;
int main() {
  int a, b, n;
  a = 0;
  cin >> n;
  rep(i,n)
  {
    cin >> b;
    if (a + 1 == b) {
      a++;
    }
  }
  if (a == 0) {
    cout << -1;
  } else {
    cout << (n - a);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647

int main() {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	string s; cin >> s;

	int count = 1; 
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) {
			count += 1; 
		}
	}
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 512
n = int(input())
flag =True

import math

while True:
  
    if n == 2:
      print(n)
      break

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
          flag = False
    
    if flag==False:
      n+=1
      flag = True
    else:
      print(n)
      break


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define sec second
#define f first
#define pb push_back
#define pf push_front
#define po pop_back
const ll mod=1000000007;
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define pii pair< pair<ll,ll> ,ll >
#define set set<ll>
#define map map<ll,ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
ll maxm(ll a,ll b){return a>b?a:b;}
ll minm(ll a,ll b){return a>b?b:a;}
#define max maxm
#define min minm
const ll inf=1e18;


int main()
{
    fast;

  ll s,w;cin>>s>>w;
  if(w>=s)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))

c0 = c1 = c2 = 0

for i in a:
    if i % 4 == 0:
        c0 += 1
    elif i % 2:
        c1 += 1
    else:
        c2 += 1

if c2:
    if c1 <= c0:
        print('Yes')
    else:
        print('No')
else:
    if c1 <= c0 + 1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15020
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    let mut counter = HashMap::new();
    for i in -1..2 {
        for x in &a {
            let count = counter.entry(x + i).or_insert(0);
            *count += 1;
        }
    }
    println!("{}", counter.values().max().unwrap());
}


Measured memory_bytes: 10492
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 1e5 + 20;

int n, k, q;
long long a[MAXN];

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n >> k >> q;
    for(int i = 1; i <= n; i++)
    	a[i] = k;
    int tmp;
    for(int i = 0; i < q; i++) {
    	cin >> tmp;
    	a[tmp]++;
    }
    for(int i = 1; i <= n; i++) {
    	if(a[i] > q)
    		cout << "Yes" << endl;
    	else
    		cout << "No" << endl;
    }

    return 0;
}






















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

int main() {
    int n, count=0;
    cin >> n;

    vector<int> p(n);
    for(int i=0; i<n; i++) {
        cin >> p[i];
    }

    for(int i=1; i<n-1; i++) {
        if(p[i] > p[i-1] && p[i] < p[i+1]) count++;
        else if(p[i] < p[i-1] && p[i] > p[i+1]) count++;
    }
    cout << count << endl;
}

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

int main()
{
    int N, count = 0;
    cin >> N;
    vector<int> data(N);

    for (int i = 0; i < N; i++)
    {
        cin >> data.at(i);
    }

    sort(data.rbegin(), data.rend());
    data.erase(unique(data.begin(), data.end()), data.end());

    cout << data.size() << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	ll n;
	cin >> n;
	ld a[n];
	ll b[n];
	p64 arr[n];
	ld fact = pow(10,10);
	ll dp[19][19];
	ll ans = 0;
	forn(i,19) forn(j,19) dp[i][j]=0;
	forn(i,n) {
		cin >> a[i];
		b[i]=(a[i]*fact);
		if(b[i]%10==1) b[i]--;
		else if(b[i]%10==9) b[i]++;
		b[i]/=10;
		arr[i]=mp(0,0);
		while(b[i]%2==0){
			arr[i].fi++;
			b[i]/=2;
		}
		while(b[i]%5==0){
			arr[i].se++;
			b[i]/=5;
		}
		arr[i].fi=min(arr[i].fi,(ll)18);
		arr[i].se=min(arr[i].se,(ll)18);
		ll v1 = 18-arr[i].fi, v2 = 18-arr[i].se;
		ans += dp[v1][v2];
		forn(j,arr[i].fi+1){
			forn(k,arr[i].se+1){
				dp[j][k]++;
			}
		}
	}
	cout << ans << ln;
}
 
int main()
{
	fast_cin();
	ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 11548
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int nums[] = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = input.nextInt();
        }
        Arrays.sort(nums);
        if(nums[n/2] > nums[n/2-1])
            System.out.println(nums[n/2] - nums[n/2-1]);
        else
            System.out.println(0);

    }
}


Measured memory_bytes: 50248
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout<<"node " <<u<<": ";
    cout<<"parent = " <<T[u].p<<", ";
    cout<<"depth = " <<D[u]<<", ";
    if(T[u].p==NIL)cout<<"root, ";
    else if(T[u].l==NIL)cout<<"leaf, ";
    else cout<<"internal node, ";

    cout <<"[";
    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i)cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

int rec(int u, int p){
    D[u]=p;
    if(T[u].r!=NIL)rec(T[u].r,p);
    if(T[u].l!=NIL)rec(T[u].l,p+1);
}
int main(){
    int i,j,d,v,c,l,r;
    cin>>n;
    for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

    for(i=0;i<n;i++){
        cin>>v>>d;
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0)T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL)r=i;
    }
    rec(r,0);
    for(i=0;i<n;i++)print(i);
    return 0;
}


Measured memory_bytes: 7780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n, r;
    cin >> n >> r;
    if(n > 9) {
        print(r);
    } else {
        print(r + 100*(10-n));
    }
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 200005;
LL dp[N];
LL call(LL val)
{
    if(val == 0)return 0;
    if(dp[val] != -1)return dp[val];
    LL ret = 1 + call(val % __builtin_popcount(val));
    return dp[val] = ret;
}
LL n;
string str;
LL mod1 , mod2;
LL pw1[N],pw2[N];

int32_t main()
{
    MEM(dp,-1);
    cin >> n;
    cin >> str;
    LL one = count(str.begin(),str.end(),'1');
    if(one == 1){
        for(LL i = 0;i < str.size();i++){
            if(str[i] == '1')cout << 0 << "\n";
            else {
                if(str[i] == '0')str[i] = '1';
                else str[i] = '0';

                if(str.back() == '1')cout << 2 << "\n";
                else cout << 1 << "\n";
            }
        }
        return 0;
    }
    mod1 = one - 1;
    mod2 = one + 1;
    pw1[0] = pw2[0] = 1;
    for(LL i = 0;i < str.size();i++){
        pw1[i + 1] = (pw1[i] * 2) % mod1;
        pw2[i + 1] = (pw2[i] * 2) % mod2;
    }
    REV(str);

    LL hash1 = 0 , hash2 = 0;
    for(LL i = 0;i < str.size();i++){
        hash1 = (hash1 + pw1[i] * (str[i] - '0')) % mod1;
        hash2 = (hash2 + pw2[i] * (str[i] - '0')) % mod2;
    }
//    cout << hash1 << " " << hash2 << "\n";
    for(LL i = str.size() - 1;i >= 0;i--){
        if(str[i] == '1'){
            //mod1 here
            LL newhash = (hash1 - pw1[i] + mod1) % mod1;
            cout << 1 + call(newhash) << "\n";
        }else{
            LL newhash = (hash2 + pw2[i] + mod2) % mod2;
            cout << 1 + call(newhash) << "\n";
        }
    }
}


Measured memory_bytes: 8408
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 100100;


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

int dp[maxn]; //dp[i] = maior caminho começando de i
int n,m,ans;
vector<int> filho[maxn];

void dfs(int x)
{
	int best = 0;

	for(int i=0;i<filho[x].size();++i)
	{
		int y = filho[x][i];
		if(dp[y] == 0)
			dfs(y);		
		best = max(best,dp[y]);
	}

	dp[x] = best + 1;
}

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

	for(int i=1;i<=n;++i) dp[i] = 0;

	for(int i=1;i<=m;++i)
	{
		int a,b;
		cin>>a>>b;
		filho[a].pb(b);
	}
	
	for(int i=1;i<=n;++i)
		if(dp[i] == 0) dfs(i);

	int best = 0;
	for(int i=1;i<=n;++i)
		best = max(best,dp[i]);
	cout<<best-1<<"\n";

}

Measured memory_bytes: 12104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll a, b;

    cin >> a >> b;

    cout << a*b;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W, N;
  cin >> H >> W >> N;
  vec< int > a(N), b(N);
  map< pair< int, int >, int > mpB;
  map< pair< int, int >, int > mp;
  REP(i, N) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--; //注意
    pair< int, int > p(a[i], b[i]);
    mpB[p]++;
  }
  vec< int > count(10, 0);
  REP(k, N) {
    FORS(i, a[k] - 2, a[k]) { //注意
      FORS(j, b[k] - 2, b[k]) {
        if (0 <= i && i + 2 < H && 0 <= j && j + 2 < W) { //注意
          int val = 0;
          FOR(l, i, i + 3) {

            FOR(m, j, j + 3) {
              pair< int, int > p(l, m);
              val += mpB[p];
            }
          }
          pair< int, int > p(i, j);
          mp[p] = val;
          // continue;
        }
      }
    }
  }
  FORA(e, mp) { count[e.second]++; }
  int ans = (H - 2) * (W - 2);
  REP(i, 9) { ans -= count[1 + i]; }
  count[0] = ans;
  REP(i, 10) { print(count[i]); }
}

Measured memory_bytes: 214272
from bisect import bisect
from itertools import accumulate
from functools import reduce
from sys import setrecursionlimit

setrecursionlimit(10000000)

MOD = 998244353

def solve(robots):
    N = len(robots)
    robots.sort()

    parent = [None]*(N+1)

    stack = [(float('inf'),0)]
    for i,(x,d) in enumerate(robots,start=1):
        d += x
        while stack[-1][0] <= x:
            stack.pop()
        parent[i] = stack[-1][1]
        while stack[-1][0] <= d:
            stack.pop()
        stack.append((d,i))

    dp = [1]*(N+1)
    for i in reversed(range(1,N+1)):
        p = parent[i]
        dp[p] *= dp[i]+1
        dp[p] %= MOD
    return dp[0]

if __name__ == '__main__':
    N = int(input())
    robots = [tuple(map(int,input().split())) for _ in range(N)]
    print(solve(robots))

Measured memory_bytes: 46628
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      class Pair{
        int x, y;
        Pair(int a, int b)
        {
          x=a;
          y=b;
        }
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j;
          int n = io.nextInt();
          int m = io.nextInt();
          
          ArrayList<Pair> ar = new ArrayList<>();
          for(i=0 ; i<=n ; i++)
            	ar.add(new Pair(0,0));
          for(i=0 ; i<m ; i++)
          {
            int tmp=io.nextInt();
            String str = io.next();
            if(ar.get(tmp).x==0)
            {
              if(str.equals("WA"))
                ar.get(tmp).y++;
              else
                ar.get(tmp).x++;
            }
          }
          int pen=0, correct=0;
          for(Pair p : ar)
          {
            if(p.x!=0)
            {
              correct++;
              pen+=p.y;
            }
          }
            out.print(correct+" "+pen);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

Measured memory_bytes: 44576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int M = sc.nextInt();
        long[] A = new long[M];
        long ans = N;
        for(int i=0;i<M;i++){
            A[i] = sc.nextInt();
            ans -= A[i];
        }
        System.out.println(ans >= 0 ? ans : -1);
    }
}


Measured memory_bytes: 39048
N = int(input())
S = [input() for i in range(N)]
count = 0
con = []
Alis = []
Blis = []
for s in S:
    count += s.count('AB')
for i in range(N):
    if S[i][-1:] == 'A' and S[i][0] == 'B':
        con.append(S[i])
    elif S[i][-1:] == 'A':
        Alis.append(S[i])
    elif S[i][0] == 'B':
        Blis.append(S[i])
if len(Alis)== 0 and len(Blis) == 0 and len(con) > 0:
    count += len(con)-1
else:
    count += min(len(con)+len(Alis),len(con)+len(Blis))
print(count)


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();j++)
				if(s[j]=='F'){
					cout<<"Yes\n";
					return 0; 
				}
		}
	}
    cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256