akhauriyash/Code-Regression huggingface dataset:
local s=io.read("n")
t={}
t[1]=s
k={}
k[s]=true
i=1
while true do
  i=i+1
  if t[i-1]%2==0 then
    t[i]=t[i-1]/2
    else
    t[i]=t[i-1]*3+1
    end
  if not k[t[i]] then
    k[t[i]]=true
    else print(i)
    break
    end
  end


Measured memory_bytes: 376
#include <stdio.h>
long long MOD = 998244353;
int big_n = 1;
long long Delta[524288];

void upd(int l_query, int r_query, long long delta,
         int l_node = 1, int r_node = big_n, int i_node = 0) {
    // printf("  upd(%i, %i, %lli, %i, %i, %i)\n", l_query, r_query, delta, l_node, r_node, i_node);
    /// Query segment doesn't contain the node at all
    if (r_query < l_node || r_node < l_query) {
        return;
    }

    /// Query segment contains the hole node
    if (l_query <= l_node && r_node <= r_query) {

        // printf("  [%i:%i] += %lli\n", l_node, r_node, delta);

        Delta[i_node] = (Delta[i_node] + delta) % MOD;
        return;
    }

    /// Query segment contains a part of the node
    int mid = (l_node + r_node) >> 1;
    upd(l_query, r_query, delta, l_node, mid, (i_node * 2) + 1);
    upd(l_query, r_query, delta, mid + 1, r_node, (i_node * 2) + 2);
}

long long get(int i_query, int l_node = 1, int r_node = big_n, int i_node = 0) {

    // printf("  [%i:%i]=%lli <- get\n", l_node, r_node, Delta[i_node]);

    /// Last row
    if (big_n - 1 <= i_node) {
        return Delta[i_node];
    }

    int mid = (l_node + r_node) >> 1;
    if (i_query <= mid) {
        return (Delta[i_node] + get(i_query, l_node, mid, (i_node * 2) + 1)) % MOD;
    }
    else {
        return (Delta[i_node] + get(i_query, mid + 1, r_node, (i_node * 2) + 2)) % MOD;
    }
}

int main() {
    int n, k;
    int Segment[10][2];
    scanf("%i%i", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%i%i", &Segment[i][0], &Segment[i][1]);
    }

    while (big_n < n) big_n <<= 1;

    Delta[big_n - 1] = 1;

    for (int i = 1; i <= n; i++) {

        // printf("cell #%i:\n", i);

        long long delta = get(i);
        for (int j = 0; j < k; j++) {
            int l = i + Segment[j][0];
            int r = i + Segment[j][1];
            // printf(" segm = [%i:%i]\n", l, r);
            if (r <= n)
                upd(l, r, delta);
            else if (l <= n) {
                upd(l, n, delta);
            }
        }
    }

    printf("%lli", get(n));
}


Measured memory_bytes: 4864
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	int AL = 0;
	int AR = 0;
	int BL = 0;
	int BR = 0;
	int CL = 0;
	int CR = 0;
	int DL = 0;
	int DR = 0;

	while(true){
		double L;
		cin >> L;

		if(cin.eof())
			break;

		double R;
		cin >> R;

		if(L>=1.1){
			AL++;
		}
		else if(L>=0.6){
			BL++;
		}
		else if(L>=0.2){
			CL++;
		}
		else{
			DL++;
		}

		if(R>=1.1){
			AR++;
		}
		else if(R>=0.6){
			BR++;
		}
		else if(R>=0.2){
			CR++;
		}
		else{
			DR++;
		}
	}

	cout << AL << ' ' << AR << '\n';
	cout << BL << ' ' << BR << '\n';
	cout << CL << ' ' << CR << '\n';
	cout << DL << ' ' << DR << '\n';

	return 0;
}

Measured memory_bytes: 0
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))

dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

sum = 0

for key, value in dic.items():
    sum += value * (value - 1) // 2

for a in A:
    val = dic[a]
    pre_sum = sum - val * (val - 1) // 2
    ans = pre_sum + (val - 1) * (val - 2) //2
    print(ans)


Measured memory_bytes: 25184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            if (x == 3 || x == 5 || x == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 60;

/* typedef */

typedef long long ll;

/* global variables */

int n;
ll m;
ll combs[MAX_N + 1][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  memset(combs, 0, sizeof(combs));
  combs[0][0] = 1;
  for (int i = 1; i <= MAX_N; i++) {
    combs[i][0] = 1;
    for (int j = 1; j <= MAX_N; j++)
      combs[i][j] = combs[i - 1][j] + combs[i - 1][j - 1];
  }

  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    m--;
    
    int k;
    for (k = 0; m >= combs[n][k]; k++)
      m -= combs[n][k];
    //printf("k=%d, m=%lld\n", k, m);

    string bits;

    while (n > 0) {
      if (m < combs[n - 1][k]) {
	bits += '0';
      }
      else {
	bits += '1';
	m -= combs[n - 1][k];
	k--;
      }
      n--;
    }

    cout << bits << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1240
from collections import defaultdict

def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]

    ans = 0

    for i in range(edge_num):
        dic_graph = defaultdict(set)
        for j in range(edge_num):
            if i == j:
                continue
            dic_graph[data[j][0]].add(data[j][1])
            dic_graph[data[j][1]].add(data[j][0])
        if check(dic_graph, node_num):
            ans += 1

        # print(dic_graph)

    print(ans)

def check(dic_graph, node_num):
    visit_data = [0 for i in range(node_num + 1)]
    visit_data[0] = 1
    visit_data[1] = 1

    now_point = set()
    next_point = set()
    now_point.add(1)

    while len(now_point) > 0:
        for ele in now_point:
            next_data = dic_graph[ele]
            for next_ele in next_data:
                if visit_data[next_ele]:
                    continue
                next_point.add(next_ele)
                visit_data[next_ele] = 1
        now_point = next_point
        next_point = set()

    # print(visit_data)


    if 0 in visit_data:
        return 1
    else:
        return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 41840
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	string s,t;
	while(cin>>s>>t){
		int n = s.size(), m = t.size();
		int ans = 0;
		REP(i,n){
			int cnt = 0;
			for(int j = 0; j < m && i + j < n; j++){
				if(s[i+j] == t[j])cnt++;
				else cnt=0;
				ans = max(ans,cnt);
			}
		}
		swap(s,t); n = s.size(); m = t.size();
		REP(i,n){
			int cnt = 0;
			for(int j = 0; j < m && i + j < n; j++){
				if(s[i+j] == t[j])cnt++;
				else cnt=0;
				ans = max(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using 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 (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
ll keta(ll n){
    string s = to_string(n);
    ll res = 0;
    rep(i,s.size()){
        res += s[i]-'0';
    }
    return res;
}
ll next(ll n){
    string s = to_string(n);
    vector<pair<double,ll>> a;
    ll l = s.size();
    a.push_back(make_pair((double)n/(double)keta(n),n));
    rep(i,l){
        n += (9-(s[l-i-1]-'0'))*pow(10,i);
        a.push_back(make_pair((double)n/(double)keta(n),n));
    }
    SORT(a);
    return a[0].second;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    ll n = 0;
    rep(i,k){
        PRINT(next(n+1));
        n = next(n+1);
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>

int main() {

  int a;
  int b;
  int c;
  int d;

  std::cin >> a >> b >> c >> d;

  if ((std::abs(a - b) <= d && std::abs(b - c) <= d) || std::abs(a - c) <= d) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    string s;
    cin >> s;
    if((int)s.size() == 2) cout << s << endl;
    else cout << s[2] << s[1] << s[0] << endl;
    return 0;
}


Measured memory_bytes: 3624
from itertools import accumulate

n, m = map(int, input().split())
cards = [0] * (n+2)
for i in range(m):
  s, e = map(int, input().split())
  cards[s] += 1
  cards[e+1] -= 1
valids = list(accumulate(cards))
print(valids.count(m))


Measured memory_bytes: 8124
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　＿,,...　 ...,,_ 　 　 　 　 ,r‐､ 
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　　,. -''" : : : : : : : : : :`丶､ 　 ,ｲ: : :| 
//　　, '´￣`丶､　 　 　 　 　 　 　 　 　 　 　 　 　f: : : : : : :_,,..　--――--::;,.ｲ: : :/_,,.　_ 
//　 / 　 　 　 　 `　ー　--――-　､　 　 　 　 　 ゝ __,.r''"　 　 　 　_,,. -―‐‐ﾒｿ´: :_ : :.） 
//　 !　 　 　 　 　 　 　 　 　 　 　 　'´￣´ ´ 丶､　 　｜　 　 　,. -'"　 　 　.／: |ヽ‐''"´ 
//　丶.　 　 　 　 　 　 　 　,r''　 　 　 　 　 　 　 　丶、丶 ..,r'"　 　 　 　.／: : :/　| i 
//　 　 丶 .　 　 　 　 　_,./　 　 ,;;;;,　 　 　 　 　 　 　 ヽ. _ ｛　 　 　 　／: : : :/ 　 !　l 
//　 　 　 　 ￣ ´´ ￣　 { .....　 :;;;;:　 　 　 　 　 　 　 　 丶`ゝ .＿ ／: : : : :.,.'　 　!　 l 
//　 　 　 　 　 　 　 　 　l :::::::::　 　 　 　 　 　 　 　 　 　 　 ／／{: : : : : :／　 　/　｜ 
//　 　 　 　 　 　 　 　 　丶.　 　 　 　(__ 　 ,　 　 ,;;;;;, 　 ／／　 丶､__.／　 　 /　 　i 
//　 　 　 　 　 　 　,. -- ..　 ＞, -‐-, 　 `'''ﾞ 　 　:;;;;;: ／／!　 　 　 　{ 　 　 ／　 　/ 
//　 　 　 　 　 　,.'´ 　 _　ﾞ／ 　 　 /‐- ..,__ 　 　 .／／　｜　 　 　 　ゝ ._／　 　 ./ 
//　 　 　 　 　 　{ 　 f´　/　 　 　 'ﾞ 　 ,f´,-'γ⌒ヽ '::::: ノ丶　 　 　 　 　 {.　 　.／、 
//　 　 　 　 　 　ゝ　丶./ 　 　 　 　 　 {. '‐'"ゝ- ノ´￣　 　 ヽ. 　 　 　 　 ` ー'ﾞ 　 ! 
//　 　 　 　 　 　 　`ー 〉　 　 　 　 　 　￣´ 　イ 　 　 　 　 　 丶､　 　 　 　 　 　ﾉ 
//　 　 　 　 　 　 　 　　{ 　 ､　 　 　 　 　 　 　 | 　 　 　 　 　 　 　 ` ‐-　..... 　‐'" 
//　 　 　 　 　 　 　 　 　`ー'ﾞ` ‐-　...＿＿. 　 / ,.'´´,`!Ｏ ,-v-､,-v-､, - ､,-v-v-､., -, ,-v-、, -, ｲ´lｲ´l 
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　（__ノ´　{　 ｛-i|´.l1　i　l1 .i　|>┘.l1 i　i　 |　t `! .r-ｲ t `;|　{|　{. 
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　ゝ ＿人_]ー'--'ｰ'--'ｰ゜-'-┴┴‐ゝ- ｲ._）　ゝ- ﾍ.._人__） 
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　warm　heart，　wagging　tall， 
//　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　　and　ａ　smile　just　for　you！


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int w,h,n;
  cin >> w >> h >> n;
  
  int xx = 0, yy = 0;
  REP(_,n){
    int x,y,a;
    cin >> x >> y >> a;
    switch(a){
      case 1:
        xx = max(xx,x);
        break;
      case 2:
        w = min(w,x);
        break;
      case 3:
        yy = max(yy,y);
        break;
      case 4:
        h = min(h,y);
        break;
    }
  }
  
  cout << (w-xx<=0||h-yy<=0?0:(w-xx)*(h-yy)) << endl;
        
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int n;
char m[14][14];
int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int dfs(int x, int y){
	if(m[x][y]!='1') return 0;
	m[x][y] = 0;
	for(int i=0;i<4;i++) dfs(x+d[i][0], y+d[i][1]);
	return 1;
}


main(){
	int i,j;
	while(1){
		memset(m, 0, sizeof(m));
		int ans=0;
		for(i=1;i<=12;i++) if(!(cin>>&m[i][1]))return 0;
		for(i=1;i<=12;i++){
			for(j=1;j<=12;j++){
				ans += dfs(i,j);
			}
		}
		
		cout << ans << endl;
	}
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << "\n";
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

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

void solve1() {
    string s; cin >> s;

    int len = (int)s.size();

    int ans = 0;
    for(int i = 0; i < len - 1; i++) {
        if(s[i] != s[i+1]) {
            ans ++;
        }
    }

    cout << ans << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),bits(61);
    REP(i,61)bits[i] = 0;
    REP(i,n)cin >> a[i];
    REP(i,n){
        REP(j,61){
            if(a[i] & (1ll<<j)){
                bits[j]++;
            }
        }
    }
    ll answer = 0;
    REP(i,61){
        answer=(answer+((1ll<<i)%MOD*(bits[i]*(n-bits[i])%MOD))%MOD)%MOD;
        cerr << answer << endl;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 5584
import sys

if __name__ == '__main__':
    data = []
    count = 0
    for line in sys.stdin:
        data.append(line.split())
    s = list(map(int, data[1]))
    n = int(data[0][0])
    q = int(data[2][0])
    t = list(map(int, data[3]))
    for i in range(0, q):
        head = 0
        tail = n - 1
        while True:
            if head > tail :
                break
            center = (head + tail)//2
            if s[center] == t[i] :
                count = count + 1
                break
            elif s[center] < t[i]:
                head = center + 1
            else :
                tail = center - 1
    print(count)


Measured memory_bytes: 21416
#include<iostream>
#include<fstream>

using namespace std;

	ifstream fin;
	ofstream fout;

	//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1160&lang=jp

	int gomi = 0;

	int a[52][52] = {};
	void check(int, int);

	int main(){

		fin.open("input.txt");
		fout.open("output.txt");

		int width = 0, height = 0;
		int count = 0;

		while (true){

			cin >> width >> height;
			if (width == 0 && height == 0)break;

			//初期化
			count = 0;
			for (int i = 0; i < 50; i++)
				for (int j = 0; j < 50; j++)
					a[i + 1][j + 1] = 0;

			for (int i = 0; i < height; i++)
				for (int j = 0; j < width; j++)
					cin >> a[i + 1][j + 1];

			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					if (a[i + 1][j + 1] == 1){
						check(i + 1, j + 1);
						count++;
					}
				}
			}
			cout << count << endl;
			fout << count << endl;
		}
	}

	void check(int y, int x){
		for (int i = -1; i <= 1; i++)
			for (int j = -1; j <= 1; j++)
				if (i + j != 0 || i - j != 0)
					if (a[y + i][x + j] == 1){
			a[y + i][x + j] = 0;
			check(y + i, x + j);
					}
	}
//------------------------------------------------------------↑↓どちらでもいい------------------------------------------------------------
/*	void check(int y, int x){
		if (a[y + 1][x] == 1){
			a[y + 1][x] = 0;
			check(y + 1, x);
		}
		//-----------------------------
		if (a[y][x + 1] == 1){
			a[y][x + 1] = 0;
			check(y, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x] == 1){
			a[y - 1][x] = 0;
			check(y - 1, x);
		}
		//-----------------------------
		if (a[y][x - 1] == 1){
			a[y][x - 1] = 0;
			check(y, x - 1);
		}
		//-----------------------------
		if (a[y + 1][x + 1] == 1){
			a[y + 1][x + 1] = 0;
			check(y + 1, x + 1);
		}
		//-----------------------------
		if (a[y + 1][x - 1] == 1){
			a[y + 1][x - 1] = 0;
			check(y + 1, x - 1);
		}
		//-----------------------------
		if (a[y - 1][x + 1] == 1){
			a[y - 1][x + 1] = 0;
			check(y - 1, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x - 1] == 1){
			a[y - 1][x - 1] = 0;
			check(y - 1, x - 1);
		}
		//-----------------------------
	}*/

Measured memory_bytes: 1428
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <list>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n, ans, u_max, v_max, u_itr, v_itr;
    bool flag, flag2;
    flag2 = true;
    u_max = 0;
    v_max = 0;
    cin >> n;
    ans = 0;
    vector<int> u(n/2, 0);
    vector<int> v(n/2, 0);
    vector<int> u_map(100001, 0);
    vector<int> v_map(100001, 0);
    
    for (int i=0; i<n; ++i){
        if(i % 2 == 0){
            cin >> u[i/2];
            u_map[u[i/2]]++;
        }
        else {
            cin >> v[(i-1)/2];
            v_map[v[(i-1)/2]]++;
        }
    }
    
    for (int i=0; i<100001; ++i){
        if(u_max <= u_map[i]){
            u_max = u_map[i];
            u_itr = i;
        }
        if(v_max <= v_map[i]){
            v_max = v_map[i];
            v_itr = i;
        }
    }
    /*
    cout << "u info: " << u_max << ":" << u_itr << endl;
    cout << "v info: " << v_max << ":" << v_itr << endl;
    */
    sort(u_map.begin(), u_map.end(), std::greater<int>() );
    sort(v_map.begin(), v_map.end(), std::greater<int>() );
    //cout << u_map[0] << ";" << v_map[0] << endl;
    if(u_itr == v_itr){
        for (int i=0; i<=100000; ++i){
            if(i == 0){
                ans += min(u_map[i], v_map[i]);
                if(u_map[i] > v_map[i]){
                    flag = true;
                }
                else if(u_map[i] < v_map[i]){
                    flag = false;
                }
                else if(u_map[i] == v_map[i]){
                    flag2 = false;
                    if(u_map[i+1] >= v_map[i+1]){
                        ans += v_map[i+1];
                    }
                    else {
                        ans += u_map[i+1];
                    }
                }
            }
            else if(i == 1){
                if(flag && flag2){
                    ans += u_map[i];
                }
                else if(!flag && flag2){
                    ans += v_map[i];
                }
            }
            else {
                ans += (u_map[i] + v_map[i]);
            }
        }
    }
    else {
        for (int i=1; i<=100000; ++i){
            ans += (u_map[i] + v_map[i]);
        }
    }
    /*
    for (int i=0; i<n/2; ++i){
        cout << u[i] << " " << v[i] << endl;
    }
    */
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
 using namespace std;
 const long long MOD = 1e9+7;
 #define rep(i,n) for(int i=0;i<n;++i)
 typedef long long int ll;
 typedef unsigned long long ull;
 template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
 template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
 typedef pair<ll,ll> P;
int main(){

    long n;
    cin >> n;

    vector<ll> a(n+1);

    a[0] = 2;
    a[1] = 1;

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

    cout << a[n] << endl;

}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
template<class T> bool chmax(T &a, const T b) {if (a<b) {a=b; return true;} return false;}
#define myfill(a, val, type) fill((type *)a, (type *)a+sizeof(a)/sizeof(type), val)
const long long INF = 1e18;

int main() {
	int R, C, K;
	cin >> R >> C >> K;
	int V[3005][3005] = {};
	for (int i = 0; i < K; i++) {
		int r, c, v;
		cin >> r >> c >> v;
		V[r][c] = v;
	}
	long long dp[3005][4]; myfill(dp, -INF, long long);
	dp[0][0] = 0;
	for (int i = 0; i <= R; i++) {
		for (int j = 0; j <= C; j++) {
			for (int k = 0; k < 4; k++) {
				long long x = dp[j][k];
				if (k < 3) chmax(dp[j+1][k+1], x + V[i][j]);
				chmax(dp[j+1][k], x);

				chmax(dp[j][0], x);
				if (k < 3) chmax(dp[j][0], x + V[i][j]);
			}
		}
	}
	long long ans = dp[C][0];
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

void output(int AC, int WA, int TLE, int RE) {
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  // main procedure
  array<int, 4> counts_array;
  for (auto &&x : counts_array) {
    x = 0;
  }

  for (size_t i = 0; i < N; i++) {
    string input_line;
    cin >> input_line;
    if (input_line == "AC") {
      counts_array[0]++;
    }
    if (input_line == "WA") {
      counts_array[1]++;
    }
    if (input_line == "TLE") {
      counts_array[2]++;
    }
    if (input_line == "RE") {
      counts_array[3]++;
    }
  }

  // output
  output(counts_array[0], counts_array[1], counts_array[2], counts_array[3]);

  return 0;
}

Measured memory_bytes: 3620
import sys

S =  input()
l = len(S)
ans = [0] * l
cot = [0,0]
for i  in range(l):
    if S[i] == "R":
        cot[i%2] += 1
    else:
        ans[i] += cot[i %2 ]
        ans[i - 1 ] += cot[(i + 1)%2]
        cot[0] = cot[1] = 0

cot[0] = cot[1] = 0
for i  in range(l-1,-1,-1):
    if S[i] == "L":
        cot[i%2] += 1
    else:
        ans[i] += cot[i %2 ]
        ans[i + 1 ]  += cot[(i + 1)%2]
        cot[0] = cot[1] = 0
print(" ".join(list(map(str,ans))))




Measured memory_bytes: 48752
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	ll n, d;
	cin >> n >> d;
	pll* xy = new pll[n];
	rep(i, n) cin >> xy[i].first >> xy[i].second;

	int ans = 0;
	rep(i, n) {
		if (d*d >= xy[i].first*xy[i].first + xy[i].second*xy[i].second) ++ans;
	}

	cout << ans << "\n";

	return 0;
}


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

int main(){
    long long n, m;
    cin >> n >> m;
    
    vector<long long> dp(n + 1, 2 * n);
    dp[0] = 0;
    
    long long c;
    for(int i = 0; i < m; ++i){
        cin >> c;
        for(int j = c; j <= n; ++j){
            dp[j] = min(dp[j], dp[j - c] + 1);
        }
    }
    
    cout << dp[n] << endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int n,i,tot,res,kd,one,two,a[N],cnt[N];
int main()
{
//	freopen("hats.in","r",stdin);
//	freopen("hats.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) { scanf("%d",&a[i]); cnt[a[i]]++; }
	rep(i,1,n) if (cnt[i]) kd++,tot=i;
	if (kd>2) {
		printf("No\n"); return 0;
	}
	if (kd==2) {
		rep(i,1,n)
			if (a[i]==tot) two++;
			else if (a[i]==tot-1) one++;
			else {printf("No\n"); return 0;}
		if (one+two/2<tot || one+1>tot) printf("No\n");
		else printf("Yes\n");
	}
	else {
		if (tot==n-1 || tot<=n/2) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

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


int main () {
    int n;
    string s;
    cin >> n >> s ;
    vector<char> vec ;
    rep(i, 26){
        vec.push_back('A' + i) ;
    }
    rep(i, 26){
        vec.push_back('A' + i) ;
    }
    int k = s.size();
    string t;
    rep(i, k){
        rep(j, 26){
            if(s.at(i) == vec.at(j)){
                t.push_back(vec.at(j + n));
            }
        }
    }
    cout << t << endl;
    
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    rep(i, X + 1){
        i64 j = X - i;
        if(i * 2 + j * 4 == Y){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3680
x, y = map(int, input().split())

A = {1, 3, 5, 7, 8, 10, 12}
B = {4, 6, 9, 11}

if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
S=input()
T=input()

sd={}
td={}
cond=True
for i in range(len(S)):
    if S[i] not in sd:
        sd[S[i]]=T[i]
    else:
        if sd[S[i]]!=T[i]:
            cond=False
            break
    if T[i] not in td:
        td[T[i]]=S[i]
    else:
        if td[T[i]]!=S[i]:
            cond=False
            break

if cond:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> d;
  tools::read(d, N);

  i64 answer = 0;
  for (i64 i = 0; i < N; ++i) {
    for (i64 j = i + 1; j < N; ++j) {
      answer += d[i] * d[j];
    }
  }

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

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m;
	cin >> n >> m;
	vll v(n),w(n);
	rep(i,n) cin >> v[i] >> w[i];
	vvll dp(n+1,vll(m+1));
	rep(i,n+1){
		rep(j,m+1){
			if(i==0 || j==0) dp[i][j]=0;
			else if(w[i-1]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 10712
S = input()
if S[0] != "A":
    print("WA")
    exit()
if S[2:-1].count("C") != 1:
    print("WA")
    exit()
if (S[1:S.index("C",2)] + S[S.index("C",2)+1:]).islower():
    print("AC")
else:
    print("WA")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

vector<pair<double,int>> belog(double with,vector<pair<double,int>> &ices,int del_size = 0) {
    vector<pair<double,int>> ret(ices.size()-del_size);
    REP(i, ices.size()-del_size) {
        double mul = with / ices[i].first;
        ret[i] = make_pair(with, ices[i].second * mul);
    }
    return ret;
}

int fnd_best(vector<pair<double,int>> &mx) {
    int mini = INF;
    REP(i,mx.size()) {
        chmin(mini,mx[i].second);
    }

    return mini;
}

int main() {
    // litter,value
    vector<pair<double,int>> ices(4);
    int Q,H,S,D;
    cin >> Q >> H >> S >>D;

    ices[0] = make_pair(0.25,Q);
    ices[1] = make_pair(0.5,H);
    ices[2] = make_pair(1.0,S);
    ices[3] = make_pair(2.0,D);

    ll N;
    cin >> N;

    ll ans = 0;

    while( N != 0) {
        if ( N >= 2) {
            // 2L まではすべて買える
            auto tag = belog(2.0,ices);
            auto bst = fnd_best(tag);
            auto buy_amount = N/2;
            N -= buy_amount * 2;
            ans += bst * buy_amount;
        }

        if (N == 1) {
            // 1L までは2L以外買える
            auto tag = belog(1.0,ices,1);
            auto bst = fnd_best(tag);
            auto buy_amount = 1;
            N -= buy_amount;
            ans += bst * buy_amount;
        }
    }

    cout << ans << endl;



    return 0;
}


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

void solve()
{
	double n,d;
	cin >> n >> d;
	double cnt=0;
	for(double i=0;i<n;++i)
	{
		double t1,t2;
		cin >> t1 >> t2;
		double temp=((t1*t1)+(t2*t2));
		double temp1=sqrt(temp);
		if(temp1<=d)
		cnt++;
	}
cout << cnt << endl;	
}

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

Measured memory_bytes: 3708
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

const int MX=1e6+10;
int cnt[MX];

int32_t main(){
   boost;
   memset(cnt,0,sizeof(cnt));
   int N; cin>>N;
   for(int i=1; i*i<=N; i++) for(int j=1; j*j<=N; j++) for(int k=1; k*k<=N; k++){
      int x=i*i+j*j+k*k+i*j+i*k+j*k;
      if(x<MX) cnt[x]++;
   }
	for(int i=1; i<=N; i++) cout << cnt[i] << endl;

   return 0;
}



Measured memory_bytes: 11428
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

bool field[5005][5];

int block(int d, int p, int q){
	int x, y;
	if(d == 1) { x = p; y = 1;}
	else {y = p; x = 1;}
	for(int i = 5000; i >= 1; i--){
		bool f = false;
		rep(j, x){
			if(field[i-1][q+j]) f = true;
		}
		if(f){
			rep(j, y){
				rep(k, x){
					field[i+j][q+k] = true;
				}
			}
			return i;
		}
	}
	rep(i, y)rep(j, x) field[i][q+j] = true;
	return 0;
}

void mov(int pos){
	rep(i, 5) field[pos][i] = false;
	rep2(i, pos, 5000)rep(j, 5) swap(field[i+1][j], field[i][j]);
}

void update(int pos){
	int cnt = 0;
	for(int i = 4; i >= 0; i--){
		bool f = true;
		rep(j, 5){
			if(!field[pos+i][j]) f = false;
		}
		if(f) mov(pos + i);
	}
}

void drop(){
	int d, p, q;
	cin >> d >> p >> q;
	int pos = block(d, p, --q);
	update(pos);
}

int cnt(){
	int res = 0;
	rep(i, 5000)rep(j, 5) if(field[i][j]) res++;
	return res;
}

int main(){
	int n;
	while(cin >> n && n){
		memset(field, false, sizeof(field));
		rep(i, n){
			drop();
	//		cout << i << " " << cnt() << endl;
		}
		cout << cnt() << endl;
	}
	return 0;
}

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

//Compiler version g++ 6.3.0

int main()
{
  int cnt=0;
   string s,t;
   cin>>s>>t;
   for(int i=0;i<s.size();i++)
   {
     if(s[i]!=t[i])
     cnt++;
   }
   cout<<cnt;
}

Measured memory_bytes: 3916
min_cost = [850, 1100, 1230, 1400, 1610, 1520, 1950, 1870, 2070, 2250, 2244, 2620,
	2624, 2794, 3004, 3040, 3344, 3390, 3590, 3740, 3764, 4120, 4114, 4314, 4494,
	4488, 4864, 4868, 5038, 5248, 5284, 5588, 5634, 5834, 5984, 6008, 6364, 6358,
	6558, 6738, 6732, 7108, 7112, 7282, 7492, 7528]

$<.each_line do |line|
	n = line.to_i
	break if n.zero?

	p min_cost[n / 100 - 5]
end

Measured memory_bytes: 6092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int W,N;
int v[1005],w[1005];
int dp[1005][1005];

void DEBUG(){
  rep(i,W+1)cout<<i<<": "<<dp[N][i]<<endl;
}

void init(){
  rep(i,1005){
    rep(j,1005){
      dp[i][j]=-INF;
    }
  }
}

void DP(){
  for(int i=0;i<1005;i++)dp[0][i]=0;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j>=w[i])dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
}

int main(){
  int cnt=1;
  while(cin>>W){
    init();
    if(W==0)break;
    cin>>N;
    rep(i,N)scanf("%d,%d",&v[i],&w[i]);
    
    DP();

    //DEBUG();
    int ans_value=0,ans_weight=0;
    rep(i,W+1){
      if(dp[N][i]>ans_value){
	ans_value=dp[N][i];
	ans_weight=i;
      }
    }
    cout<<"Case "<<cnt<<":"<<endl;
    cout<<ans_value<<endl;
    cout<<ans_weight<<endl;
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <map>

static const int INF = 1 << 20;

using namespace std;

struct state
{
	int ticket, id, cost;
};

struct comparator : public binary_function<state, state, bool>
{
	bool operator() (const state &x, const state &y) const { return x.cost > y.cost; }
};

static bool det[11][101];
static int edges[101][101];

int main()
{
	int C,N,M,S,D;
	while(cin>>C>>N>>M>>S>>D,C|N|S|M|D)
	{
		for (int c = 0; c <= C; c++)
			for (int i = 1; i <= N; i++)
				det[c][i] = false;

		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= N; j++)
				edges[i][j] = INF;

		for (int i = 0; i < M; i++)
		{
			int a,b,f;
			cin>>a>>b>>f;
			edges[a][b] = edges[b][a] = f;
		}

		state init = { C, S, 0 };

		// Dijkstra
		priority_queue<state, vector<state>, comparator> Q;
		Q.push(init);

		int min_cost = INF;
		while (!Q.empty())
		{
			state s = Q.top();
			Q.pop();
			if (det[s.ticket][s.id]) continue;
			det[s.ticket][s.id] = true;

			if (s.id == D) min_cost = min(min_cost, s.cost);

			for (int i = 1; i <= N; i++)
			{
				if (edges[s.id][i] == INF) continue;

				int cost = s.cost + edges[s.id][i];
				state s2 = { s.ticket, i, cost };

				if (!det[s2.ticket][s2.id]) Q.push(s2);

				if (s.ticket > 0)
				{
					cost = s.cost + edges[s.id][i] / 2;
					state s3 = { s.ticket - 1, i, cost };
					if (!det[s3.ticket][s3.id]) Q.push(s3);
				}
			}
		}
		cout << min_cost << endl;
	}
	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  map<int,int> smp,tmp;
  rep(i,sz(s)) {
    smp[s[i]- 'a']++;
  }
  rep(i,sz(t)) {
    tmp[t[i]- 'a']++;
  }
  vi svi,tvi;
  for(auto x:smp) {
    svi.push_back(x.second);
  }
  for(auto x:tmp) {
    tvi.push_back(x.second);
  }
  sort(rng(svi));
  sort(rng(tvi));
  if(svi == tvi) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main()
{
	int n[3];
	cin >> n[0] >> n[1] >> n[2];

	int five = 0, seven = 0;
	for (int i : n) {
		if (i == 5) five++;
		if (i == 7) seven++;
	}

	if (five == 2 && seven == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 1000000007
ll dp[1000000 + 1][4];
int main()
{
    int n;
    cin >> n;

    for (int i = 0; i < 4; i++)
    {
        dp[0][i] = 0;
    }

    dp[1][0] = 8;
    dp[1][1] = 1;
    dp[1][2] = 1;
    dp[1][3] = 0;

    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = (8 * (dp[i - 1][0] % M)) % M;                                        //containing none of 0 or 9
        dp[i][1] = (dp[i - 1][0] % M + (dp[i - 1][1] % M) * 9) % M;                     //containing 0 only
        dp[i][2] = (dp[i - 1][0] % M + (dp[i - 1][1] % M) * 9) % M;                     //containing 9 only
        dp[i][3] = (dp[i - 1][1] % M + dp[i - 1][2] % M + (dp[i - 1][3] % M) * 10) % M; //containing 0 as well as 9
    }
    cout << dp[n][3] << endl;
}

Measured memory_bytes: 34824
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

a, b, c = map(int, input().split())
print(a*b//2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(ll x, ll y)
{
	return (x|y)&(~x|~y);	
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
	ll t,n,m,i,j,k,l,x,y,z,a,b,c,d,e,p,nl,np,q,r,s,h;
	string str,str1;
	cin>>n;
	ll res;
	if(n<500)
	{
		a=n/5;
		res = 5*a;
	}
	else
	{
		a = n/500;
		res = 1000*a;
		n = n%500;
		a = n/5;
		res+=5*a;
	}
	cout<<res;
}

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

int main(void){
    
    string s;
    cin >> s;
    if(s[5] == '0' && (int)(s[6]-48) <= 4){
        cout << "Heisei" <<endl;
    }
    else{
        cout << "TBD" <<endl;
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
 
using namespace std;
 
string solve() {
  string S;
  cin >> S;
  
  if (S[0] != 'A') return "WA";
  if (S[1] == 'C') return "WA";
  
  int cnt = 0;
  for (int i = 2; i < S.size() - 1; i++) {
    cnt += S[i] == 'C';
  }
  if (cnt != 1) return "WA";
  
  for (int i = 1; i < S.size(); i++) {
    if (S[i] != 'C' && S[i] <= 'Z') return "WA";
  }
  
  return "AC";
}
 
int main() {
  cout << solve() << endl;
}

Measured memory_bytes: 256