akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
const int N = 1e5+150;
int n,v[N],a[N],poz,i,j,k,st,dr,mij;
int main()
{
    cin>>n;
    for (i=1; i<=n; ++i)
        cin>>v[i];
    a[1]=v[1];
    k=1;
    for (i=2;i<=n;++i)
    {
        poz=0;
        st=1;dr=k;
        while (st<=dr)
        {
            mij=(st+dr)/2;
            if (v[i]>a[mij])
            {
                poz=mij;
                dr=mij-1;
            }
            else st=mij+1;
        }
        if (poz) a[poz]=v[i];
        else a[++k]=v[i];

    }
    cout<<k<<"\n";
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n>> k;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
	}
	int ans[n];
	ans[0]= 0;
	ans[1]= abs(a[1]-a[0]);
	for(int i=2; i<n; i++)
	{int min =1000000007;
     for(int j=i-1; j>=max(i-k,0); j--)
     { int p=ans[j]+abs(a[j]-a[i]);
       if(p<min)
         min=p;
     }ans[i]=min;
     min=1000000007;
		
	}
	
	cout << ans[n-1];
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (ll i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (ll i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (ll i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (ll i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (ll i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (ll i = (x), a = 0; a < (N);   \
                              i = (i + 1) % (N), ++a)
#define int long long
typedef long long ll;


template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

ll constexpr inf = std::numeric_limits<ll>::max();

using namespace std;

typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    vector<vll> a(3, vll(3, 0));

    for0(i, 3){
        for0(j, 3)
            cin >> a[i][j];
    }
    int n;
    cin >> n;

    vector<vector<bool >> q(3, vector<bool>(3, false));

    for0(t, n){
        int b;
        cin >> b;

        for0(i, 3)for0(j, 3){
            if(a[i][j] == b){
                q[i][j] = true;
                goto out;
            }
        out:
            continue;
        }
    }

    // tate
    for0(i, 3){
        bool good = true;
        for0(j, 3){
            good = good && q[i][j];
        }
        if (good) {
            cout << "Yes";
            return 0;
        }
    }

    // yoko
    for0(i, 3){
        bool good = true;
        for0(j, 3){
            good = good && q[j][i];
        }
        if (good) {
            cout << "Yes";
            return 0;
        }
    }

    // naname
    if ((q[0][0] && q[1][1] && q[2][2]) || (q[0][2] && q[1][1] && q[2][0])) {
        cout << "Yes";
        return 0;
    }

    cout << "No";

    return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7

s = input()
k = int(input())
n = len(s)
ans = []
for c in s[:n-1]:
    if c == 'a':
        ans.append('a')
        continue
    if ord('z')-ord(c)+1 <= k:
        k-=(ord('z')-ord(c)+1)
        ans.append('a')
    else:
        ans.append(c)
ans.append(chr(ord('a')+(ord(s[n-1])-ord('a')+k)%26))
print(*ans, sep='')

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

int main()
{
  int  n, i;
  long  a[200000], x, y, min;

  scanf("%d", &n);

  x = 0L;
  y = 0L;
  for(i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    y += a[i];
  }
  min = 1000000000000000L;
  for(i = 0; i < n-1; i++) {
    x += a[i]; 
    y -= a[i];
    if(labs(x - y) < min) {
      min = labs(x - y);
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int v[20000];
int main(){
  int n; scanf("%d", &n);
  for(int i = 1; i < 105; i++){
    for(int j = 1; j < 105; j++){
      for(int k = 1; k < 105; k++){
        int t = i*i+j*j+k*k+i*j+j*k+k*i;
        if(t <10050) v[t]++;
      }
    }
  }
  for(int i = 1; i <= n; i++){
    printf("%d\n", v[i]);
  }
  return 0;
}


Measured memory_bytes: 3740
#include<cstdio>
#include<iostream>
using namespace std;
bool chain();

int main()
{
	while(chain()){}
	return 0;
}
bool chain()
{
	int N,cnt = 0,totalIN = 0,in[2],max = 0;
	pair<int,int> IN[10000],now;
	bool change;

	scanf("%d",&N);
	
	if(N == 0)
		return false;
	
	for(int i = 0; i < N; i++){
		scanf("%d",&in[i%2]);
		if(i == 0 || in[i%2] == in[(i+1)%2]){
			cnt++;
		}
		else{
			IN[totalIN].first = in[(i+1)%2];
			IN[totalIN].second = cnt;
			totalIN++;
			cnt = 1;
		}
	}
	if(cnt != 0){
		IN[totalIN].first = in[(N+1)%2];
		IN[totalIN].second = cnt;
	}
	else{
		totalIN--;
	}

	for(int i = 0; i < totalIN; i++){
		cnt = IN[i].second + 1;
		if(IN[i+1].second == 1){
			if((i+1) != totalIN){
				if(IN[i].first == IN[i+2].first){
					cnt += IN[i+2].second;
					now.first = i-1;
					now.second = i+3;
				}
				else{
					now.first = i-1;
					now.second = i+2;
				}
			}
			else{
				now.first = i-1;
				now.second = i+1;
			}
		}
		else{
			now.first = i-1;
			now.second = i+1;
		}
		IN[i+1].second--;

		if(cnt >= 4){
			while(now.first >= 0 && now.second <= totalIN){
				if(IN[now.first].first == IN[now.second].first){
					if((IN[now.first].second + IN[now.second].second) >= 4){
						cnt += (IN[now.first].second + IN[now.second].second);
						now.first--;
						now.second++;
					}
					else
						break;
				}
				else
					break;
			}
			if(max < cnt){
				max = cnt;
			}
		}

		IN[i+1].second++;
	}

	printf("%d\n",N-max);

	return true;
}

Measured memory_bytes: 1264
N=int(input())
*A,=map(int,input().split())
A.sort()
M=A[-1]
A=[-10**9]+A+[10**11]
from bisect import*
P=bisect_right(A,M/2)
if abs(A[P-1]-M/2)>abs(A[P]-M/2):
    m=A[P]
else:
    m=A[P-1]
print(M,m)

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    LL n,m,s,g1,g2;
    cin >> n >> m >> s >> g1 >> g2;
    if(n==0) return 0;
    s--,g1--,g2--;
    vector<vector<LL>> dist(n,vector<LL>(n,INF));
    for(LL i=0;i<n;i++) dist[i][i]=0;
    LL u,v,c;
    for(LL i=0;i<m;i++){
      cin >> u >> v >> c;
      dist[u-1][v-1]=c;
    }
    for(LL k=0;k<n;k++){
      for(LL i=0;i<n;i++){
        for(LL j=0;j<n;j++){
          dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
        }
      }
    }
    // for(LL i=0;i<n;i++){
    //   for(LL j=0;j<n;j++){
    //     cout << dist[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    LL ans=INF;
    for(LL i=0;i<n;i++){
      ans=min(ans,dist[s][i]+dist[i][g1]+dist[i][g2]);
    }
    cout << ans << endl;
  }
  return 0;
}



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

const int INF = 1001001001;

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  vector<char> rel(26,'0');
  for(int i = 0;i<n;i++){
    int from = s.at(i) - 'a';
    if(rel.at(from) == '0'){
      rel.at(from) = t.at(i);
    }else{
      if(rel.at(from) != t.at(i)){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  for(int i=0;i<26;i++){
    char val = rel.at(i);
    int count = 0;
    while((val != ('a' + i) && (val != '0'))){
      val = rel.at(val - 'a');
      count++;
      if(count == 27){
        cout << "No" << endl;
        return 0;
      }      
    }
    for(int j=0;j<26;j++){
      if(rel.at(i) != '0' && rel.at(i) == rel.at(j) && i!=j){
        cout << "No" << endl;
        return 0;
      }
    }
  }    
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
p=*0..gets.to_i
s=0
f=->a{a!=p[a]?p[a]=f[p[a]]:a}
a,b=$<.map(&:split).transpose.map{|a|i=0
a.map{[_1.to_i,i+=1]}.sort.each_cons(2).map{[_2[0]-_1[0],_1[1],_2[1]]}}
(a+b).sort.map{|c,*a|a,b=a.map &f
a!=b&&(s+=c
p[b]=a)}
p s

Measured memory_bytes: 52140
#include <iostream>

using namespace std;

int main () {
    int x=0, n, max=0;
    string s;

    cin >> n >> s;

    for (int i=0; i<n; ++i) {
        if (s.at(i) == 'I') {
            ++x;
        } else {
            --x;
        }
        max = ((x > max) ? x : max);
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  char a;
  set<char> s;
  rep(i,3){
    cin>>a;
    s.insert(a);
  }
  if(s.size()==1){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, H; cin >> N >> H;
  int a[N], b[N];
  rep(i,N){
    cin >> a[i] >> b[i];
  }

  sort(a,a+N);
  sort(b,b+N);

  int max_a = a[N-1];
  int cnt_b = N - (lower_bound(b,b+N,max_a) - b);
  
  ll retval = 0;
  for (int i=0;i<cnt_b;i++){
    H -= b[N-1-i];
    if (H<=0) {
      retval = i+1;
      break;
    }
  }
  if (H>0) retval = cnt_b + (H+(max_a-1ll))/max_a;
  cout << retval << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 4384
#include <iostream>
#include <vector>


using namespace std;

//変数デバッグ
#define DEB(variable) cout <<#variable <<"="<<variable<<endl
//for簡易表記(引数ミス防止) a<bにすること！
#define FOR(inc,a,b) for(int inc =(a);(inc)<(b);(inc)++) //incをaにし、b-a回(iがb未満 の間)処理を行う
#define DEFOR(de,a,b) for(int de =(a);(de)>(b);(de)--)

int sesort(vector<int> &V, int N) {
	
	int trade=0, min=0, space;

	FOR(i,0,N){
		
		min = i;
		FOR(j, i, N) {
			if (V[min]>V[j]) {
				min = j;
			}

		}
	
		
		if (i != min) {
			space = V[min];
			V[min] = V[i];
			V[i] = space;
			trade++;
		}
	}	
	return trade;
}

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

	vector<int> v(n, 0);

	FOR(i, 0, n) {
		cin >> v[i];
	}

	int trade = sesort(v,n);

	FOR(k, 0, n - 1) {
		cout << v[k] << " ";
	}


	cout << v[n - 1] << "\n"<<trade<<endl;
	return 0;
}


Measured memory_bytes: 3116
n = int(input())
s = list(input() for _ in range(n))
s.sort()
now = s[0]
ans = [s[0],]
cnt = 0
m_cnt = 0

for i in range(n):
    word = s[i]
    if word == now:
        cnt +=1
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)
    else:
        cnt = 1
        now = word
        if cnt > m_cnt:
            ans = [word,]
            m_cnt = cnt
        elif cnt == m_cnt:
            ans.append(word)

for k in sorted(ans):
    print(k)


Measured memory_bytes: 26932
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    long long H, W;
    cin >> H >> W;

    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }


    if(H % 2 == 0){
        cout << W*H/2 << endl;
    }else{
        cout << W*(H-1)/2 + (W+1)/2 << endl;
    }
    // cout << W*(H-1)/2 << " " <<(W+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define inf LLONG_MAX
#define bp __builtin_popcountll
#define pb push_back
#define ff first
#define ss second
#define P pair<ll,ll>
#define N 100001
#define all(a) a.begin(),a.end()
#define LG 20
#define int ll
#define nl '\n'
#define vi vector<int>
#define f(n) for(int i=0;i<n;i++)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ps(x,y) fixed<<setprecision(y)<<x



signed main() {
    int n;
    cin>>n;
    vector<double> vec(n);
    f(n) cin>>vec[i];
    vector<vector<double >> ans(n+1,vector<double> (n+1));
    ans[0][0]=1;
    for(int i=1;i<n+1;i++) ans[0][i]=ans[0][i-1]*(1-vec[i-1]);
    for(int i=1;i<n+1;i++){
        for(int j=i;j<n+1;j++){
            ans[i][j]=ans[i-1][j-1]*vec[j-1] + ans[i][j-1]*(1-vec[j-1]);
        }
    }
//    for(int i=0;i<n+1;i++){
//        for(int j=0;j<n+1;j++)
//            cout<<ans[i][j]<<" ";
//        cout<<nl;
//    }
    double res=0;
    for(int i=(n/2)+1;i<=n;i++) res+=ans[i][n];
    cout<<ps(res,10);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
const int64_t BIG_PRIME = 1000000007;

int main()
{
    int64_t n, a, b;
    cin >> n >> a >> b;

    int64_t amari = n % (a + b);
    int64_t div = n / (a + b);

    int64_t ans = div * a;
    if (amari <= a)
    {
        ans += amari;
    }
    else
    {
        ans += a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		sc.close();

		for (int i = A; i <= B; i++) {
			if (i < A + K || i > B - K) {
				out.println(i);
			}
		}
	}

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


Measured memory_bytes: 21844
Scanf.scanf "%d %d %d" (fun n k l ->
    let rec root arr x =
        if x = arr.(x) then x else (
            let r = root arr arr.(x) in
            arr.(x) <- r;
            r
        )
    in

    let merge arr count x y =
        if root arr x <> root arr y then (
            count.(arr.(x)) <- count.(arr.(x)) + count.(arr.(y));
            arr.(arr.(y)) <- arr.(x);
        )
    in

    let road        = Array.init n (fun i -> i) in
    let train       = Array.init n (fun i -> i) in
    let road_count  = Array.make n 1 in
    let train_count = Array.make n 1 in
            
    for i = 1 to k do
        Scanf.scanf " %d %d" (fun p q ->
            let p = p - 1 in
            let q = q - 1 in
            merge road road_count p q
        )
    done;
    for i = 1 to l do
        Scanf.scanf " %d %d" (fun p q ->
            let p = p - 1 in
            let q = q - 1 in
            merge train train_count p q
        )
    done;
    let module M = Map.Make (struct type t = int let compare = compare end) in
    let rec loop i map =
        if i = n then map else
            let r = root road  i in
            let t = root train i in
            let key = r * n + t in
            let map = M.add key (1 + try M.find key map with _ -> 0) map in
            loop (i + 1) map
    in
    let map = loop 0 M.empty in

    for i = 0 to n - 1 do
        let r = root road  i in
        let t = root train i in
        let key = r * n + t in
        Printf.printf "%d " @@ M.find key map
    done;
    print_newline ()
)

Measured memory_bytes: 18104
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
    a = list(map(int, input().split()))
    temp = c
    for j in range(m):
        temp += a[j] * b[j]
    if temp > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
# https://atcoder.jp/contests/abc107/tasks/abc107_b

def main():
    H, W = map(int, input().split())
    a = [list(input()) for _ in range(H)]

    a = [ai for ai in a if any(ais == '#' for ais in ai)]

    i = 0
    while i < len(a[0]):
        if all(ai[i] == '.' for ai in a):
            for ai in a:
                del ai[i]
        else:
            i += 1
            continue

    for ai in a:
        print(''.join(ai))


if __name__ == '__main__':
    main()





Measured memory_bytes: 3064
from collections import defaultdict
from heapq import heappop, heappush

def getlist():
    return list(map(int, input().split()))

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b, w):
        self.graph[a].append((b, w))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    def __init__(self, graph, s):
        self.g = graph.graph
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[s] = 0
        self.prev = defaultdict(lambda: None)

        self.Q = []
        heappush(self.Q, (self.dist[s], s))

        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, w in self.g[u]:
                alt = dist_u + w
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def s_d(self, goal):
        return self.dist[goal]

    def s_p(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

H, W = getlist()
c = []
for i in range(10):
    cl = getlist()
    c.append(cl)
A = []
for i in range(H):
    Al = getlist()
    A.append(Al)

g_a = Graph()
for i in range(10):
    for j in range(10):
        a, b, w = i, j, c[i][j]
        if a != b:
            g_a.add_edge(b, a, w)

d_a = Dijkstra(g_a, 1)

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            pass
        else:
            ans += d_a.dist[A[i][j]]

print(ans)

Measured memory_bytes: 3696
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Bits as Bits

main :: IO ()
main = do
    input <- B.getLine
    if solve input then
        putStrLn "YES"
    else
        putStrLn "NO"

solve :: B.ByteString -> Bool
solve input =
    solveReversed (B.reverse input)

solveReversed :: B.ByteString -> Bool
solveReversed goal
    | "remaerd" `B.isPrefixOf` goal = solveReversed (B.drop 7 goal)
    | "resare"  `B.isPrefixOf` goal = solveReversed (B.drop 6 goal)
    | "maerd"   `B.isPrefixOf` goal = solveReversed (B.drop 5 goal)
    | "esare"   `B.isPrefixOf` goal = solveReversed (B.drop 5 goal)
    | B.null goal                   = True
    | otherwise                     = False


Measured memory_bytes: 764
// #include "vacation.h"
#include <algorithm>
#include <iostream>
#include <vector>

using ActivityData = std::vector<int>;
using Activities = std::vector<ActivityData>;

namespace {

constexpr size_t num_activities{3};

} // namespace

int max_happiness(const Activities& activities)
{
    std::vector<std::vector<int>> dp(activities.size(),
                                     std::vector<int>(num_activities, 0));
    ActivityData prev_day_activities = activities.front();
    std::vector<int> cumulative_happiness = prev_day_activities;

    for (size_t day = 1; day < activities.size(); ++day) {
        for (size_t activity = 0; activity < num_activities; ++activity) {
            for (size_t prev_activity = 0; prev_activity < num_activities;
                 ++prev_activity) {
                if (activity == prev_activity)
                    continue;
                auto& happiness = activities[day][activity];
                cumulative_happiness[activity] =
                    std::max(cumulative_happiness[activity],
                             happiness + prev_day_activities[prev_activity]);
            }
        }
        std::swap(cumulative_happiness, prev_day_activities);
    }

    return *std::max_element(prev_day_activities.cbegin(),
                             prev_day_activities.cend());
}

int main(int argc, char* argv[])
{
    size_t n;
    std::cin >> n;
    Activities activities(n, std::vector<int>(num_activities));
    for (size_t i = 0; i < n; ++i) {
        size_t a, b, c;
        std::cin >> a >> b >> c;
        activities[i][0] = a;
        activities[i][1] = b;
        activities[i][2] = c;
    }
    std::cout << max_happiness(activities) << std::endl;
    return 0;
}


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

ll mod = 998244353;

const int N = 2e5;
ll dp[N][2][3][3][3];

int solve2(string s) {
  if(s[0] == s[1]) return 1;
  return 2;
}

int solve3(string s) {
  if(s[0] == s[1] && s[1] == s[2]) return 1;
  if(s[0] == s[1] || s[1] == s[2]) return 6;
  if(s[0] == s[2]) return 7;
  return 3;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s; cin >> s;
  int n = s.size();
  int sum = 0;
  if(n == 2) return (cout << solve2(s) << endl, 0);
  if(n == 3) {
    cout << solve3(s) << endl;
    return 0;
  }
  int f = 1;
  int same = 1;
  for(int i = 0; i < n; i++) {
    sum += s[i] - 'a';
    if(i && s[i] == s[i - 1]) f = 0;
    if(i && s[i] != s[i - 1]) same = 0;
  }
  if(same) return (cout << 1 << endl, 0);
  sum %= 3;
  for(int i = 0; i < 3; i++) dp[0][0][0][i][i] = 1;
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++) {
      for(int l = 0; l < 2; l++) for(int m = 0; m < 3; m++)
        for(int o = 0; o < 3; o++) {
          (dp[i][l || (j == k)][j][k][(o + k) % 3] +=
           dp[i - 1][l][m][j][o]) %= mod;
        }
    }
  }
  ll ans = 0;
  for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
    ans += dp[n - 1][1][i][j][sum % 3];
  }
  ans += f;
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 85012
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back
#define EPS 1e-9

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);


int a,b;



signed main(){
    cin >> a >> b;

    if((a%3 == 0 ||b%3 == 0 )|| (a+b)%3 == 0){
        cout<< "Possible\n";
    }else{
        cout<< "Impossible\n";
    }

    return 0;
}

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 100000
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back

using namespace std;
typedef long long ll;

int tc;


void solve(){

    string s; cin>>s; if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl; else cout<<"No"<<endl;

}

int main()
{

    _fastIO;


    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    best_jump = 10**10
    
    for j in range(1, k+1):
        if i-j < 0:
            break
        else:
            jump = dp[i-j] + abs(h[i]-h[i-j])      
            if jump < best_jump:
                best_jump = jump            
    dp[i] = best_jump
    
print(dp[-1])

Measured memory_bytes: 52448
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
  string xyz ="";
int x=0,y=0,z=0,w=0,i=0,j=0,n=0;
std::cin >> xyz;

for(i=xyz.size()-1;i>=0;i--){
  std::cout << xyz[i];
}
std::cout  << '\n';

}



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

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n+1), b(n);
	for(int &e : a) cin >> e;
	for(int &e : b) cin >> e;
	
	long long ans = 0;
	for(int i = 0;i < n;++i){
		for(int j = 0;j <= 1;++j){
			ans += min(a[i+j], b[i]);
			int temp = a[i+j];
			a[i+j] -= min(a[i+j], b[i]);
			b[i] -= min(temp,b[i]);
		}
	}

	cout << ans;
}


Measured memory_bytes: 4052
n = gets.to_i
hs = gets.strip.split.map(&:to_i)

inf = 1 << 60
dp = Array.new(n, inf)
dp[0] = 0

n.times do |i|
    dp[i] = [dp[i], dp[i - 1] + (hs[i] - hs[i - 1]).abs].min

    if i >= 2
        dp[i] = [dp[i], dp[i - 2] + (hs[i] - hs[i - 2]).abs].min
    end
end

puts dp[n - 1]


Measured memory_bytes: 11780
#include<stdio.h>
#define LEN 100000

typedef struct{
  char name[10];
  int time;
}P;
  
int head=0;
int tail=0;
P Q[LEN];

void enqueue(P);
P dequeue(void);

int main(){
  int q,i,n,sum=0;
  P u;
  scanf("%d%d",&n,&q);
  
  for (i=0;i<n;i++){
    scanf("%s%d",Q[i].name,&Q[i].time);
    enqueue(Q[i]);
  }
  i=0;
  while(i!=n){
    u=dequeue();
    if(u.time<=q){
      sum+=u.time;
      u.time=sum;
      Q[i]=u;
      printf("%s %d\n",Q[i].name,Q[i].time);
      i++;
    }
    else{
      sum+=q;
      u.time=u.time-q;
      enqueue(u);


    }
  }


  
  return 0;
}


void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN)
    tail = 0;
  else
    tail++;
}

P dequeue(){
  P x;
  x = Q[head];
  if(head + 1 == LEN)
    head = 0;
  else
    head++;
  return x;
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr ll MOD = 1000000007;
int main(void){
  int n;
  scanf("%d\n",&n);
  vector<ll> a(n);
  RPT(i,0,n) scanf("%ld ",&a[i]);
  ll ans = 0;
  ll tmp = 1;
  RPT(i,0,62){
    ll tmp_ = 0;
    FOR(j,0,n){
      if( ( (a[j]>>i)&1LL)==1 ) tmp_++;
    }
    tmp_ = tmp_*((ll)n-tmp_) % MOD;
    tmp_ *= tmp;
    tmp_ %= MOD;
    ans += tmp_;
    ans %= MOD;
    tmp *= 2;
    tmp %= MOD;
  }
  /*
  FOR(i,0,n){FOR(j,i+1,n){
    ll tmp = (a[i]^a[j]) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  }
  */
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        cout << "x";
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll f[n+1];
	f[0]=2LL;f[1]=1LL;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+f[i-2];
	}
	cout<<f[n];

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;



int main(){
  ll r,c,k;
  cin >> r >> c >> k;
  vector<vector<ll>> arr(r,vector<ll>(c));
  vector<vector<vector<ll>>> dp(r+1,vector<vector<ll>>(c+1,vector<ll>(4,0)));
  rep(i,k){
    cin >> t1 >> t2 >> t3;
    t1--,t2--;
    arr[t1][t2] = t3;
  }
  rep(i,r){
    rep(j,c){
      rep(p,4){
        chmax(dp[i+1][j+1][0],dp[i][j+1][p]);
        chmax(dp[i+1][j+1][p],dp[i+1][j][p]);
        if(p < 3){
          chmax(dp[i+1][j+1][p+1],dp[i+1][j][p] + arr[i][j]);
        }
        chmax(dp[i+1][j+1][1],dp[i][j+1][p] + arr[i][j]);
      }
    }
  }
  ll ans = 0;
  rep(p,4){
    chmax(ans,dp[r][c][p]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 706432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

int main(void){
  ios_base::sync_with_stdio(0);
  int N;  cin >> N;
  while(N--){
    string a, b;  cin >> a >> b;
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < a.size(); i++){
      for(int j = 0; j < b.size(); j++){
        if(a[i] == b[j]) dp[i+1][j+1] = dp[i][j] + 1;
        else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
    cout << dp[a.size()][b.size()] << endl;
  }
  return 0; 
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n,m; cin >> n >> m;
        vll s(m);
        vector<char>c(m);
        rep(i,m){
            cin >> s[i] >> c[i];
        }

        repA(i,0,999){
            bool ok = true;
            string str = to_string(i);
            if(str.size()!=n){
                ok = false;
                continue;
            }
            rep(j,m){
                if(str[s[j]-1]!=c[j]){
                    ok = false;
                }
            }
            if(ok){
                cout << i << endl;
                return 0;
            }
        }
         cout << -1 << endl;

    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  cout << (s[5] == '1' || s[6] - '0' >= 5 ? "TBD\n" : "Heisei\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
	for (i++; i <= n; i += i&-i) {
	  d[i] += x;
	}
  }
  T sum(int i) {//sum of [0,i]
	T x = 0;
	for (i++; i; i -= i&-i) {
	  x += d[i];
	}
	return x;
  }
  T sum(int l, int r) {// sum of [l,r)
	return sum(r-1) - sum(l-1);
  }
};
const int INF = 1001001001;
signed main(){
	int n,d,a;cin >> n >> d >> a;
	vector<P> res(n);
	rep(i,n)cin >> res[i].first >> res[i].second;
	sort(res.begin(),res.end());
	BIT<int> bit(n+1);
	int ret = 0;
	rep(i,n){
		//trace(i,res[i],ret,bit.sum(i));
		if(bit.sum(i) < res[i].second){
			int rest = res[i].second - bit.sum(i);
			int num = (rest + a-1)/a;
			int damage = num*a;
			bit.add(i,damage);
			int idx = upper_bound(res.begin(),res.end(),P(res[i].first + 2*d,INF))- res.begin();
			bit.add(idx,-damage);
			ret += num;
		}
	}
	cout << ret << endl;
	

	return 0;
}

Measured memory_bytes: 7844
N, M = [int(nm) for nm in input().split()]
L, R = [int(lr) for lr in input().split()]
LR = [L, R]
for m in range(M-1):
  L_2, R_2 = [int(lr) for lr in input().split()]
  if L_2 < LR[0]:
    if R_2 < LR[0]:
      print(0)
      break
    elif LR[0] <= R_2 <= LR[1]:
      LR = [LR[0], R_2]
    else: # LR[1] < R_2:
      continue
  elif LR[0] <= L_2 <= LR[1]:
    if LR[0] <= R_2 <= LR[1]:
      LR = [L_2, R_2]
    else: # LR[1] < R_2:
      LR = [L_2, LR[1]]
  elif LR[1] < L_2:
    print(0)
    break
else:
  card = LR[1] - LR[0] + 1
  print(card)

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    if (1 <= n) {
        ans += min(n, 9);
    }
    if (100 <= n) {
        ans += min(n, 999) - 100 + 1;
    }
    if (10000 <= n) {
        ans += min(n, 99999) - 10000 + 1;
    }
    cout << ans << endl;
    return 0;
}

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

signed main() {
    int a,b;
    cin >> a >> b;

    int x = 0, y = 0; // x = F(0,A-1) y = F(0,B);


    int acnt = a;
    int bcnt = b + 1;

    if(acnt % 2 == 0) {
        if((acnt / 2) % 2 == 0) x = 0;
        else x = 1;
    }
    else {
        if((acnt / 2) % 2 == 0) x = a - 1;
        else {
            x = 1 ^ (a - 1);
        }
    }

    if(bcnt % 2 == 0){
        if((bcnt / 2) % 2 == 0) y = 0;
        else y = 1;
    } else {
        if((bcnt / 2) % 2 == 0) y = b;
        else {
            y = 1 ^ b;
        }
    }

    int ans = x ^ y;
    cout << ans << endl;

}

Measured memory_bytes: 256
(let ((k (read))
    (ans 0))
    (setq ans 
        (loop for i from 1 to k sum
            (loop for j from 1 to k sum
                (loop for l from 1 to k sum
                    (gcd i j l)
                )
            )
        )
    )
    (format t "~A~%" ans)
)

Measured memory_bytes: 24440
import java.util.HashMap;
import java.util.Scanner;
 
/**
 * Created by zzt on 17-1-29.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        int a;
        for (int i = 0; i < n; i++) {
            a = scanner.nextInt();
            map.computeIfPresent(a,(key, oldValue) -> oldValue+1);
            map.computeIfAbsent(a, key -> 1);
        }
        int ret = map.size();
        if (ret % 2 == 0)
            ret--;
        System.out.println(ret);
    }
}

Measured memory_bytes: 52644
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Hashtable;
//https://vjudge.net/contest/159423#problem/B
public class Main {
	public static void main(String [] argv) throws Exception{

		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		int number = a* 100 + b * 10 + c;
		if (number % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		// R G B
	} 
	


}




Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static char[] strs;
    static final char VISITED = 'v';

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            strs = sc.next().toCharArray();
            for (int i = 0; i < n; i++) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < strs.length; j++) {
                    if (strs[j] != VISITED) {
                        char tmp = strs[j];
                        sb.append(ope(strs[j], j) + "" + tmp);
                    }
                }
                strs = sb.toString().toCharArray();
            }
            System.out.println(strs);
        }
    }

    public static int ope(char c, int it) {
        int ct = 0;
        while (it < strs.length && strs[it] == c) {
            ct++;
            strs[it] = VISITED;
            it++;
        }
        return ct;
    }
}

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

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

	int b1, b2, b3;
	cin >> b1 >> b2 >> b3;
	cout << (b1 + b2 + b3 * 2 == 2 ? "Open" : "Close") << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
    string s;
    char c;
    int f = 0;
    cin >> s;
    c = s[0];
    if (c == 'R')
    {
        c = s[1];
        f++;
        if (c == 'R')
        {
            c = s[2];
            f++;
            if (c == 'R')
            {
                f++;
            }
        }
    }else{
        c = s[1];
        if(c=='R'){
            f++;
            c = s[2];
            if(c=='R'){
                f++;
            }
        }else{
            c = s[2];
            if(c=='R'){
                f++;
            }
        }
    }
    cout << f;

    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	
	while (1){
		scanf("%d", &n);
		
		if (!n){
			break;
		}
		
		i = 0;
		while (n - 1){
			if (n % 2 == 1){
				n = n * 3 + 1;
			}
			else {
				n /= 2;
			}
			i++;
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 0
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    count = [0] * (N+1)
    for val in A:
        count[val] += 1
    base_sum = 0
    for val in count:
        if val <= 1:continue
        base_sum += val * (val-1) // 2
    for i in range(N):
        if count[A[i]] == 1:
            print(base_sum)
        else:
            print(base_sum - count[A[i]] + 1)
if __name__ == "__main__":
    run()


Measured memory_bytes: 20396
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N; 
	cin >> N; 
	int A[110] = {}; 
	int S = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		S += A[i]; 
	}
	int ans = 0, D = abs(S - N * A[0]); 
	for(int i = 1; i < N; i++){
		if(abs(S - N * A[i]) < D)
		ans = i, D = abs(S - N * A[i]);
	}
	cout << ans << endl; 
}

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

template <class T, class U>
inline bool chmax(T& t, const U& f) { return t < f ? t = f, true : false; }

int main() {
    int n, d, x; cin >> n >> d >> x;
    vector<int> p(n), q(n);
    for (int i = 0; i < d; ++i, p.swap(q)) {
        for (int& e : p) cin >> e;
        if (i == 0) continue;
        vector<int> dp(x + 1, -1); dp[0] = 0;
        rep(j, n) {
            vector<int> nxt = dp;
            rep(k, x + 1) {
                if (dp[k] == -1 or k + q[j] > x) continue;
                chmax(dp[k + q[j]], dp[k] + p[j] - q[j]);
                chmax(nxt[k + q[j]], dp[k + q[j]]);
            }
            dp.swap(nxt);
        }
        x += *max_element(all(dp));
    }
    cout << x << endl;
}

Measured memory_bytes: 3184
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        while (true) {
            String W = stdIn.next();
            if(W.equals("-")) {
                break;
            }
            int m = stdIn.nextInt();
            for(int i = 0; i < m; i++) {
                int h = stdIn.nextInt();
                String s1 = W.substring(0, h);
                String s2 = W.substring(h);
                W = s2 + s1;
            }
            System.out.println(W);
        }
    }
}


Measured memory_bytes: 26548
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  double a = sc.nextDouble();
  double b = sc.nextDouble();
  if(a > b)System.out.println("GREATER");
  else if(a < b)System.out.println("LESS");
  else System.out.println("EQUAL");
}}

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

int n,k,a[4010],cnt;
long long ans,fac[2010],dp[4010][2010][2];
const long long mod=924844033;
int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;++i)
	fac[i]=fac[i-1]*i%mod;
	for(int i=1;i<=k;++i)
	{
		for(int l=1;l<=2;++l)//有对称的两条链，举个例子，一个是1->3'->5，一个是1'->3->5' 
		{
			for(int j=i;j<=n;j+=k)
			{
				++cnt;
				if(j!=i)//链头不与前面一个连 
				a[cnt]=1;
			}
		}			
	}
	dp[0][0][0]=1;
	for(int i=0;i<2*n;++i)
	{
		for(int j=0;j<=n;++j)
		{
			dp[i+1][j][0]=(dp[i][j][0]+dp[i][j][1])%mod;
			if(a[i+1])
			dp[i+1][j+1][1]=dp[i][j][0];
		}
	}
	for(int i=0;i<=n;++i)
	{
		if(i&1)
		ans=(ans-(dp[2*n][i][0]+dp[2*n][i][1])*fac[n-i]%mod+mod)%mod;
		else
		ans=(ans+(dp[2*n][i][0]+dp[2*n][i][1])*fac[n-i])%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 125952