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

class Jewely
{
public:
	int mValue;
	int mCost;
	Jewely(int cValue) : mValue(cValue), mCost(0) {}
};

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

	vector<Jewely> v;
	for (int i = 0; i < n; ++i)
	{
		int value;
		cin >> value;
		v.push_back(value);
	}

	for (int i = 0; i < n; ++i)
	{
		int cost;
		cin >> cost;
		v[i].mCost = cost;
	}

	int X = 0;
	int Y = 0;

	for (int i = 0; i < n; ++i)
	{
		if (v[i].mValue > v[i].mCost)
		{
			X += v[i].mValue;
			Y += v[i].mCost;
		}
	}

	cout << X - Y;
	return 0;
}

Measured memory_bytes: 256
num = input().split()
amount = int(num[0])
aji_list = [int(num[1])+i for i in range(amount)]

original_aji = sum(aji_list)
smallest = abs(aji_list[0])

for i in aji_list:
  if abs(i)<abs(smallest): smallest = i
    
print(original_aji-smallest)

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

int main(){
  long N,A,B;cin>>N>>A>>B;
  long count=0;
  long X=N/(A+B);
  count+=X*A;
  N-=X*(A+B);
  if(N<=A) count+=N;
  else count+=A;
  cout<<count<<endl;
}
  


Measured memory_bytes: 3600
def main():
    N = int(input().strip())
    res = int(input().strip())
    if N == 1:
        print(res)
        return
    for _ in range(1, N):
        t = int(input().strip())
        res = lcm(res, t)
    print(res)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def gcd(a, b):
    if b == 0:
        return a
    if b == 1:
        return 1
    if b > a:
        return gcd(b, a)
    else:
        return gcd(b, a % b)

if __name__ == '__main__':
    main()


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

int main() {
  string text;
  cin >> text;
    if (text.at(2)==text.at(3) && text.at(4)==text.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
  string A;
  cin >> A;
  
  if ( A == "ABC" ) {
    
    cout << "ARC" << endl;
    
  }
  
  else if ( A == "ARC" ) {
    
    cout << "ABC" << endl;
    
  }
  
  else {
    
    cout << "error" << endl;

  }

}


Measured memory_bytes: 3584
def main():
  s=input()
  a=[]
  for i in range(len(s)):
    if s[i]=='0':
      a.append('0')
    elif s[i]=='1':
      a.append('1')
    elif s[i]=='B':
      if a==[]:
          continue
      else:
          a.pop(-1)
  print(''.join(a))
  
  
if __name__=='__main__':
  main()

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;

ll cnt(ll n)
{
  switch (n & 3)
  {
  case 0:
    return n;
  case 1:
    return 1;
  case 2:
    return n + 1;
  case 3:
    return 0;
  }
}

void solve()
{
  ll a, b;
  cin >> a >> b;
  cout << (cnt(b) ^ cnt(a - 1));
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  //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 <iostream>
#include <cmath>
#include <string>
using namespace std;

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

    int s[m][2];

    for(int i=0; i<m; i++){
        cin >> s[i][0] >> s[i][1];
    }

    int i;
    for(i=0; i<pow(10, n); i++){
        if(n>1 && i<pow(10,n-1)){ i = (int)pow(10,n-1); }

        string str = to_string(i);

        bool suc = true;
        for(int j=0; j<m; j++){
            if(str[ s[j][0] -1 ] - 48 != s[j][1]){
                suc = false;
                break;
            }
        }

        if(suc){
            cout << i << endl;
            break;
        }
    }
    
    if(i >= pow(10,n)){
        cout << -1 << endl;
    }

    return 0;
}

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

int a[5000];
bool flg[5000];
vector<int> vec;

int sum(int i, int j);

int main()
{
	int n, i, j, k, l, s, max;

	while (cin >> n)
	{
		if (n == 0) break;

		for (i = 0; i < n; i++)
			cin >> a[i];

		max = -2147483647;
		for (i = 0; i < n; i++)
		{
			for (j = i; j < n; j++)
				if ((s = sum(i, j)) > max)
					max = s;
			vec.clear();
			flg[i] = false;
		}
		cout << max << endl;
	}
	return 0;
}

int sum(int a, int b)
{
	int tmp;
	if (!flg[a])
	{
		vec.push_back(::a[a]);
		flg[a] = true;
	}
	if (b-a-1 >= 0)
	{
		vec.push_back(vec[b-a-1]+::a[b]);
	}
		return vec.back();
}

Measured memory_bytes: 968
#include <iostream>
#include <algorithm>

int main () {
    int n;
    std::cin >> n;
    int l[n];
    for(int i = 0; i < n; ++i) {
        std::cin >> l[i];
    }
    std::sort(l, l + n);
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int id = i;
        for(int j = i + 1; j < n; ++j) {
            while(id < n && l[id] < l[i] + l[j]) ++id;
            ans += id - j - 1;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include <iostream>
 #include <deque>
  using namespace std; 
  int main()
   {
        deque < char > d;
         string s,t;
          int flag;
           cin >> s >> t;
            for (int k=0;k<s.size();k++){
                    d.push_back(s[k]);
            } for (int k=0;k<s.size();k++){
                 d.push_front(d[s.size()-1]);
                  d.pop_back();
                   for (int j=0;j<t.size();j++){
                            if (d[j]==t[j]){
                                 flag=1;
                   }else{
                        flag=0; break; }
                         } 
                         if (flag==1){
                                break; }
                         } 
                         if (flag==1){
                                cout << "Yes"; }
                         else{
                                cout << "No"; } return 0; }

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int sx = Integer.parseInt(S[0]);
    int sy = Integer.parseInt(S[1]);
    int tx = Integer.parseInt(S[2]);
    int ty = Integer.parseInt(S[3]);
    
    int a = tx-sx;
    int b = ty-sy;
    
    String ans = "", ans1 = "", ans2 = "", ans3 = "", ans4 = "";
    for(int i = 0; i < a; i++){
      ans1 += "R";
      ans3 += "L";
    }
    for(int i = 0; i < b; i++){
      ans2 += "U";
      ans4 += "D";
    }
    ans += ans1 + ans2 + ans3 + ans4;
    ans1 = "";
    ans2 = "";
    ans3 = "";
    ans4 = "";
    for(int i = 0; i < a+1; i++){
      ans1 += "R";
      ans3 += "L";
    }
    for(int i = 0; i < b+1; i++){
      ans2 += "U";
      ans4 += "D";
    }
    ans += "D" + ans1 + ans2 + "L" + "U" + ans3 + ans4 + "R";
    System.out.println(ans);
  }
}

Measured memory_bytes: 62032
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int addm(int a, int b)
{
	return ((long long)a + b) % MOD;
}

int subm(int a, int b)
{
	return addm(a, MOD - b);
}

int mulm(int a, int b)
{
	return ((long long)a * b) % MOD;
}

int powm(int a, int n)
{
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return mulm(a, powm(a, n - 1));
	}
	else {
		return powm(mulm(a, a), n / 2);
	}
}

vector<int> fact;
vector<int> ifact;

void make_fact(int n)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fact[i] = mulm(i, fact[i - 1]);
	}

	ifact.resize(n + 1);
	ifact[n] = powm(fact[n], MOD - 2);
	for (int i = n - 1; i >= 0; --i) {
		ifact[i] = mulm(i + 1, ifact[i + 1]);
	}
}

int combm(int n, int k)
{
	return mulm(mulm(fact[n], ifact[n - k]), ifact[k]);
}

int f(int r, int c)
{
	return combm(r + c, r);
}

int g(int r, int c)
{
	return subm(f(r + 1, c + 1), f(r, 0));
}

int main()
{
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	make_fact(1000 * 1000 * 3);

	int ans = g(r2, c2);
	ans = subm(ans, g(r2, c1 - 1));
	ans = subm(ans, g(r1 - 1, c2));
	ans = addm(ans, g(r1 - 1, c1 - 1));
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int N;
int F[200][10];
int P[200][15];

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

	cin >> N;

	for (int i = 0;i < N;i++){
		for (int j = 0;j < 10;j++){
			cin >> F[i][j];
		}
	}

	for (int i = 0;i < N;i++){
		for (int j = 0;j <= 10;j++){
			cin >> P[i][j];
		}
	}

	int ans = INT_MIN;

	for (int state = 1;state < (1<<10);state++){
		int cnt[200]; memset(cnt,0,sizeof(cnt));
		for (int i = 0;i < 10;i++){
			if(state & (1<<i)){
				for (int j = 0;j < N;j++){
					if(F[j][i] == 1) cnt[j]++;
				}
			}
		}
		int sum = 0;
		for (int i = 0;i < N;i++){
			sum += P[i][cnt[i]];
		}
		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
	int N;
	string s;
	int ans = 1;
	cin>>N;
	getchar();
	getline(cin, s);
	char f = s[0];
	for(int i =1;i<s.length();i++)
	{
		if(f==s[i])
			continue;
		else
		{
			ans++;
			f=s[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int k,n,a[200000];

    scanf("%d %d",&k,&n);

    int i,j;

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

    long long ans = 0,max = 0;
    for (i = 0; i < n - 1; i++)
    {
        if(a[i + 1] - a[i] > max)max = a[i + 1] - a[i];
    }
    if(k - a[n - 1] + a[0] > max)max = k - a[n - 1] + a[0] ;

    printf("%lld",k - max);
}


Measured memory_bytes: 1276
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    ans = 0
    for key, value in d.items():
        ans += value * (value - 1) // 2
    for i in range(n):
        print(ans - d[a[i]] * (d[a[i]] - 1) // 2 + (d[a[i]] - 2) * (d[a[i]] - 1) // 2)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 83148
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s; cin >> s;
	string t;
	t.resize(s.size());
	FOR_LT(i, 0, s.size()) {
		t[i] = s[s.size() - i - 1];
	}

	int64_t ans = 0;
	bool has_c = false;
	FOR_LT(i, 0, t.size()) {
		int n = t[i] - '0';
		if (has_c) n++;
		if (n == 10) {
			has_c = true;
			continue;
		}
		if (n < 5) {
			ans += n;
			has_c = false;
		}
		else if (n == 5) {
			if (i < t.size() - 1 && '5' <= t[i + 1]) {
				has_c = true;
			}
			else {
				has_c = false;
			}
			ans += n;
		}
		else {
			ans += (10 - n);
			has_c = true;
		}
	}
	if (has_c) ans++;
	cout << ans << endl;

	return 0;
}

/*
int solve(string t) {
	int64_t ans = 0;
	bool has_c = false;
	FOR_LT(i, 0, t.size()) {
		int n = t[i] - '0';
		if (has_c) n++;
		if (n == 10) {
			has_c = true;
			continue;
		}
		if (n < 5) {
			ans += n;
			has_c = false;
		}
		else if (n == 5) {
			if (i < t.size() - 1 && '5' <= t[i + 1]) {
				has_c = true;
			}
			else {
				has_c = false;
			}
			ans += n;
		}
		else {
			ans += (10 - n);
			has_c = true;
		}
	}
	if (has_c) ans++;

	return ans;
}

int solve2(int n) {
	auto count = [](int i) {
		int c = 0;
		while (i != 0) {
			c += (i % 10);
			i /= 10;
		}
		return c;
	};

	int ans = INT_MAX;
	FOR_LT(i, n, 10 * n) {
		int ca = (count(i) + count(i - n));
		ans = min(ans, ca);
	}
	return ans;
}

int main()
{
	FOR_LE(i, 1, 10000) {
		string s = to_string(i);

		string t;
		t.resize(s.size());
		FOR_LT(i, 0, s.size()) {
			t[i] = s[s.size() - i - 1];
		}

		cout << s << " " << solve(t) << " " << solve2(i) << endl;
		if (solve(t) != solve2(i)) {
			cout << "!!!" << endl;
			return -1;
		}
	}
	return 0;
}
*/

Measured memory_bytes: 2332
import sys
from collections import deque
H,W=map(int,input().split())
map = [[i for i in map(str,sys.stdin.readline().rstrip())] for _ in range(H)]
count_dot = 0
dist = [[0]*W for _ in range(H)]
for i in range(H):
  for j in range(W):
    if map[i][j] == '.':
      count_dot +=1
def bfs():
  while q:
    x,y = q.popleft()
    if x == H-1 and y ==W-1:
      break
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    for i in range(4):
      nx = x + dx[i]
      ny = y + dy[i]
      if 0 <= nx < H and 0 <= ny < W and map[nx][ny]=='.' and dist[nx][ny] == 0:
        q.append((nx,ny))
        dist[nx][ny] = dist[x][y] + 1
q = deque()
q.append((0,0))
bfs()
dist_min = dist[H-1][W-1]
if dist_min ==0:
  print(-1)
else:
  print(count_dot-dist_min-1)

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

int main() {
	int a[3];
	int b;
	cin >> b;
	while (cin >> a[0] >> a[1] >> a[2]) {
		sort(a, a + 3);
		if (a[2] * a[2] == a[1] * a[1] + a[0] * a[0]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007


#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int T1,T2;
  T1 = H1*60 +M1;
  T2 = H2*60 +M2;
  int res = 0;
  chmax(res,T2 - T1 - K);
  cout<<res<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define int long long
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e4+5;

int32_t main() {
	int a, b;
	cin >> a >> b;
	string s1 = "", s2 = "";
	for(int i = 0; i < b; i++)
		s1.pb(a+'0');
	for(int i = 0; i < a; i++)
		s2.pb(b+'0');
	cout << (s1 <= s2 ? s1 : s2) << endl;
}


Measured memory_bytes: 256
MAX_V = 100100
MAX_N = 101
INF = pow(2, 40)

N, W = map(int, input().split())
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])

ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])

print(ans)


Measured memory_bytes: 171372
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int h, w, k;
vector<vector<char>> choco;
vector<vector<int>> sums;

#define INF 1000000;

int solve(int hori){
  int ret = 0;
  int c = 0;
  int t = hori;
  vector<int> sh_h;
  while(t){
    c++;
    if(t&1){
      ret++;
      sh_h.push_back(c);
    }
    t /= 2;
  }
  sh_h.push_back(h);
  // for(int i = 0; i < sh_h.size(); i++) cout << sh_h[i] << ' ';
  // cout << endl;
  int last_v = 0;
  for(int j = 1; j <= w; j++){
    int last_h = 0;
    for(int i = 0; i < sh_h.size(); i++){
      int s = sums[sh_h[i]][j] - sums[sh_h[i]][last_v] - sums[last_h][j] + sums[last_h][last_v];
      if(s > k){
        if(j - last_v == 1){
          return INF;
        }
        last_v = j-1;
        ret++;
        break;
      }
      last_h = sh_h[i];
    }
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  cin >> h >> w >> k;
  int ans = INF;
  choco = vector<vector<char>>(h, vector<char>(w));
  sums = vector<vector<int>>(h+1, vector<int>(w+1, 0));
  for(int i = 0; i < h; i++){
    string s; cin >> s;
    for(int j = 0; j < w; j++){
      choco[i][j] = s[j];
      sums[i+1][j+1] = sums[i+1][j];
      if(s[j] == '1') sums[i+1][j+1]++;
    }
  }
  for(int j = 0; j < w; j++){
    for(int i = 0; i < h; i++){
      sums[i+1][j+1] += sums[i][j+1];
    }
  }
  // for(int i = 0; i <= h ; i++){
  //   for(int j = 0; j <= w; j++){
  //     cout << sums[i][j] << ' ';
  //   }
  //   cout << endl;
  // }

  for(int i = 0; i < pow(2, h-1); i++){
    ans = min(ans, solve(i));
    // cout << endl;
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

namespace ABC133D
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var n = int.Parse(input);
            var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            var total = a.Sum();

            var result = new long[n];

            result[0] = total - 2 * (a.Select((x, i) => new { x, i }).Where(x => x.i % 2 == 1).Select(x => x.x).Sum());
            for (int i = 1; i < n; i++)
            {
                result[i] = 2 * a[i - 1] - result[i - 1];
            }

            Console.WriteLine(string.Join(" ", result));
        }
    }
}


Measured memory_bytes: 34272
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

from heapq import heappop,heappush
from collections import defaultdict
f=defaultdict(int)
pq=[]

def push(a,b,c):
    if f[(a,b,c)]==0 and a<X and b<Y and c<Z:
        heappush(pq,(-(A[a]+B[b]+C[c]),a,b,c))
        f[(a,b,c)]=1

push(0,0,0)

for i in range(K):
    d,a,b,c=heappop(pq)
    print(-d)
    push(a+1,b,c)
    push(a,b+1,c)
    push(a,b,c+1)



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

int main(){
  string s;
  int K;
  cin>>s;
  cin>>K;
  set<string> d;
  int len = s.length();

  for(int i=1;i<=K;i++){
    for(int j=0; j<len - i + 1; j++){
      d.insert(s.substr(j, i));
    }
  }

  int cnt=0;
  for(auto a: d){
    cnt++;
    if(cnt==K){
      cout<<a<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1664
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	string a, b;
	s.pop_back();
	s.pop_back();
	while (1) {
		a.clear();
		b.clear();
		a = s.substr(0, (s.size()) / 2);
		b = s.substr((s.size()) / 2);
		if (a == b) break;
		s.pop_back();
		s.pop_back();
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = 1e9;
    FOR(i,1,101){
        int tmp = 0;
        rep(j,n){
            tmp += (x[j] - i)*(x[j] - i);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//2019.8.24 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=5e5+10;
const int kcz=1e9+7;
namespace MAIN{
    int n,H,W;
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    int a[N],R[N],C[N];
    map<Pair,int> M;
    vector<int> A[N];
    int fa[N];
    inline int find(res x){
        while(x!=fa[x])x=fa[x]=fa[fa[x]];
        return x;
    }
    struct E{
        int u,v,w;
        E() {}
        E(res u,res v,res w):u(u),v(v),w(w) {}
        inline bool operator < (const E &b) const {
            return w>b.w;
        }
    }edge[N];
    bool vis[N];
    LL ans;
    int cnt;
    inline void MAIN(){
        n=read(),H=read(),W=read();
        for(res i=1;i<=n;i++)R[i]=read(),C[i]=read(),a[i]=read(),edge[++cnt]=E(R[i],C[i]+H,a[i]);
        sort(edge+1,edge+cnt+1);
        for(res i=1;i<=H+W;i++)fa[i]=i;
        for(res i=1;i<=cnt;i++){
            res u=edge[i].u,v=edge[i].v,w=edge[i].w,fu=find(u),fv=find(v);
            if(fu==fv){if(!vis[fv])ans+=w,vis[fv]=1;}
            else if(!vis[fu]||!vis[fv])ans+=w,vis[fu]|=vis[fv],fa[fv]=fu;
        }
        printf("%lld\n",ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  int res = 0;
  for (int i = 0; i < k; i++)
    res += a[i];
  cout << res << '\n';   
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    get = input()
    if get == "AC":
        ac += 1
    if get == "WA":
        wa += 1
    if get == "TLE":
        tle +=1
    if get =="RE":
        re +=1
print("AC x",ac) 
print("WA x",wa) 
print("TLE x",tle) 
print("RE x",re) 

Measured memory_bytes: 9208
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
using namespace std;
char map[200][200];
#define SIZE 1000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for(int i=0;i<SIZE;i++)
		{
			par[i]=i;
			ran[i]=0;
			ren[i]=1;
		}
	}
	int find(int a)
	{
		if(a==par[a])return a;
		else return par[a]=find(par[a]);
	}
	void unite(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a==b)return;
		if(ran[a]>ran[b])
		{
			par[b]=a;
			ren[a]+=ren[b];
		}
		else
		{
			par[a]=b;
			ren[b]+=ren[a];
		}
		if(ran[a]==ran[b])ran[b]++;
	}
};
unionfind uf;
typedef long long ll;
ll mod=1000000007;
int main()
{
	int mx,my;
	scanf("%d%d",&mx,&my);
	for(int i=0;i<mx;i++)
	{
		for(int j=0;j<my;j++)
		{
			scanf(" %c",&map[i][j]);
		}
	}
	ll ret=1;
	if(mx%2==1)
	{
		for(int i=0;i<my;i++)
		{
			if(map[mx/2][i]!=map[mx/2][my-1-i])
			{
				ret*=2;
				break;
			}
		}
	}
	if(my%2==1)
	{
		for(int i=0;i<mx;i++)
		{
			if(map[i][my/2]!=map[mx-1-i][my/2])
			{
				ret*=2;
				break;
			}
		}
	}
	uf.init();
	for(int i=0;i<mx/2;i++)
	{
		for(int j=0;j<my/2;j++)
		{
			vector<char>v;
			v.push_back(map[i][j]);
			v.push_back(map[mx-1-i][j]);
			v.push_back(map[i][my-1-j]);
			v.push_back(map[mx-1-i][my-1-j]);
			sort(v.begin(),v.end());
			int r=0;
			for(;;)
			{
				r++;
				if(!next_permutation(v.begin(),v.end()))break;
			}
			if(r==24)
			{
				if(uf.find(i)!=uf.find(j+200))
				{
					uf.unite(i,j+200);
				}
				else r/=2;
			}
			ret*=r;
			ret%=mod;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    n,*a=map(int,open(0).read().split())
    print(min(a),max(a),sum(a))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 7868
N,K = map(int,input().split())
A = map(int,input().split())
MOD = 10**9 + 7

dp = [0]*(1+K)
dp[0] = 1

for a in A:
  t,dp[K] = dp[K], sum(dp[j] for j in range(K-a,K+1)) % MOD

  for i in reversed(range(K)):
    t,dp[i] = dp[i], (dp[i+1]-t+(dp[i-a] if i >= a else 0)) % MOD

print(dp[K])

Measured memory_bytes: 43372
function dfs(N, A, x, y, cost) {
    if (x > N - 1 || y > 2 - 1) return 0;
    var value = cost + A[y][x];
    if (x === N - 1 && y === 2 - 1) {
        return value;
    }
    return Math.max(dfs(N, A, x + 1, y, value), dfs(N, A, x, y + 1, value));
}

function Main(inp) {
    var input = inp.split('\n');
    var N = Number(input[0]);
    var A = [];
    for (var i = 0 + 1; i < 2 + 1; i++) {
        A.push(input[i].split(' ').map(function(n) {
            return Number(n);
        }));
    }
    console.log(dfs(N, A, 0, 0, 0));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef struct {
    int x;
    int y;
    int z;
} triple;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int N_MAX = 2000;
int N, Y;


void solve()
{
    for (int x = 0; 10 * x <= Y && x <= N; x++) {
        int N_res1 = N - x;
        int Y_res1 = Y - 10 * x;
        for (int y = 0; 5 * y <= Y_res1 && y <= N_res1; y++) {
            int N_res2 = N_res1 - y;
            int Y_res2 = Y_res1 - 5 * y;
            if (N_res2 == Y_res2) {
                int z = N_res2;
                printf("%d %d %d\n", x, y, z);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
    return;
}

int main(void)
{
    cin >> N >> Y;
    Y /= 1000;
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string str = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int[][] card = new int[3][];
			for (int i = 0; i < 3; i++) {
				card[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
			}
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++) {
				int m = int.Parse(Console.ReadLine());
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (card[j][k] == m) {
							card[j][k] = 0;
						}
					}
				}
			}
			if ((card[0][0] == 0 && card[0][1] == 0 && card[0][2] == 0) ||
				(card[1][0] == 0 && card[1][1] == 0 && card[1][2] == 0) ||
				(card[2][0] == 0 && card[2][1] == 0 && card[2][2] == 0) ||
				(card[0][0] == 0 && card[1][0] == 0 && card[2][0] == 0) ||
				(card[0][1] == 0 && card[1][1] == 0 && card[2][1] == 0) ||
				(card[0][2] == 0 && card[1][2] == 0 && card[2][2] == 0) ||
				(card[0][0] == 0 && card[1][1] == 0 && card[2][2] == 0) ||
				(card[0][2] == 0 && card[1][1] == 0 && card[2][0] == 0)) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
			

			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false);
   ll S;
   cin >> S;
   ll x = sqrt(S);
   // x1 * y2 - x2 * y1
   cout << "0 0 ";
   if (x * (x + 1) < S) {
      ll rm = (x + 1) * (x + 1) - S;
      cout << x + 1 << " " << 1 << " ";
      cout << rm << " " << x + 1 << "\n";
   } else if (x * x < S){
      ll rm = x * (x + 1) - S;
      cout << x << " " << 1 << " ";
      cout << rm << " " << x + 1 << "\n";
   } else {
      cout << x << " 0 0 " << x << "\n";
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

class BIT
{
    private:
        vi node;
        int n;
    public:
        BIT(int n_) {
            n = n_;
            node.resize(n + 1);
        }

        void add(int i, int x) {
            while (i <= n) {
                node[i] += x;
                i += (i & (-i));
            }
        }

        int sum(int i) {
            int sum = 0;
            while (i > 0) {
                sum += node[i];
                i -= (i & (-i));
            }
            return sum;
        }

        int sum(int a, int b) {
            return sum(b) - sum(a - 1);
        }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    BIT bit(N);
    rep(i, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;
        if (C == 0) {
            bit.add(X, Y);
        } else {
            cout << bit.sum(X, Y) << endl;
        }
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI acos(-1.0)
#define test() int t; cin>>t; while(t--)
#define ll long long int
const int INF = 1e9 + 5;
int main()
{
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j : {i + 1, i + 2}) {
			if (j < n)
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 3964
import java.util.*;
import java.io.*;

public class Main {
	static int[] f = new int[101];
	static int n;
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int t = ni();
		int a = ni();
		int[] h = na(n);
		int result = 0;
		double dif = Double.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			double tmp = (double)t - h[i] * 0.006;
			double tmpdif = Math.abs(tmp - (double)a);
			if(tmpdif < dif) {
				result = i + 1;
				dif = tmpdif;
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<char> v(n);
  int r_cnt = 0, w_cnt = 0;
  for(int i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] == 'R') r_cnt++;
  }
  for(int i = 0; i < r_cnt; i++) {
    if(v[i] == 'W') w_cnt++;
  }
  cout << w_cnt;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define _ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
using namespace std;

int main() { _
    string a, b; cin >> a >> b;
    int ans = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] != b[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3832
<?php
error_reporting(0);
//$N = explode(" ",trim(fgets(STDIN)));
//list($D,$X) = explode(" ",trim(fgets(STDIN)));
$N=trim(fgets(STDIN));

$A = str_split($N,1);
sort($A);
if (implode("",$A)=="abc") {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 3700
w = input()
G = []
q = 0
for x in w:
    if not ([x, True] in G or [x, False] in G):
        G.append([x, True])
    else:
        if [x, True] in G:
            G[G.index([x, True])][1] = False
        else:
            G[G.index([x, False])][1] = True
for h in range(len(G)):
    q += G[h][1]
#print(G)
if q == 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;

ll nck(ll n, ll k){
    ll ans = 1;
    for(ll i=1; i<=k; i++)
        ans = ans*(n-i+1)/i;
    return ans;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << nck(n, 2) + nck(m, 2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#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 eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#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))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------

int main(int argc,char** argv){ fastio; myio;
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  int ans = 0;
  rep(i,n){
    ans +=a[i] - 1 ;
  }
  cout<<ans;
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 100005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
ll mod = 998244353;
string s;
bool vis[N];

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> a >> b;
        cout << a * b << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


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

using namespace std;

int main(){
  int n, a[3];
  cin >> n;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++)
      cin >> a[j];
    sort(a, a + 3);
    cout << (a[2] * a[2] == a[0] * a[0] + a[1] * a[1] ? "YES\n" : "NO\n");
  }
}

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

	vector<int> num(26);
	for (int i = 0; i < s.size(); i++) {
		num.at((int)s.at(i) - 97)++;
	}

	for (int i = 0; i < 26; i++) {
		if (num.at(i) == 0) {
			cout << (char)(i + 97) << endl;
			return 0;
		}
	}

	cout << "None" << endl;

 	return 0;
 }

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>

// Definitions
#define MAXN 200010
#define elif else if
typedef long long int64;
typedef long double num128;
typedef unsigned long long uint64;

// Variables
int n;
char c[MAXN];
int ans;

// Improve the speed of read-in.
inline bool IsNum(char x) { return ('0' <= x) && (x <= '9'); }
inline int64 ReadNum() {
  int64 sign = 1, val = 0; char tmp = getchar();
  while (!IsNum(tmp)) { if (tmp == '-') {sign = -sign;} tmp = getchar(); }
  while (IsNum(tmp)) { val = val * 10 + tmp - 48; tmp = getchar(); }
  return val * sign;
}
inline bool IsLetter(char x) {
  return ('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z');
}
inline char GetLetter() {
  char tmp = getchar();
  while (!IsLetter(tmp)) { tmp = getchar(); }
  return tmp;
}

// Functions
inline void Process() {
  int l = 1, r = n;
  while (l <= r) {
    while (c[l] != 'W' && l <= n) {
      l++;
    }
    while (c[r] != 'R' && r > 0) {
      r--;
    }
    if (l <= r) {
      c[l] = 'R';
      c[r] = 'W';
      ans++;
    }
  }
}
inline void ReadIn() {
  n = ReadNum();
  for (int i = 1; i <= n; i ++) {
    c[i] = GetLetter();
  }
}
inline void PrintAns() {
  printf("%d\n", ans);
}

int main() {
  ReadIn();
  Process();
  PrintAns();
  return 0;
}
/*

*/


Measured memory_bytes: 3944
import Data.Maybe

deleteIndexOf :: Int -> [a] -> [a]
deleteIndexOf i = reverse . foldl (\a (j,x) -> if i == j then a else x:a) [] . zip [0..]

solve :: [Int] -> [Int]
solve xs = reverse $ fromMaybe [-1] (next xs)
  where
    next [] = Just []
    next xs = case filter (uncurry (==)) $ zip xs [1..] of
                [] -> Nothing
                ks -> let k = snd . last $ ks
                       in (:) <$> Just k <*> next (deleteIndexOf (k-1) xs)

main :: IO ()
main = do
    _ <- getLine
    b <- map read . words <$> getLine :: IO [Int]
    mapM_ print $ solve b

Measured memory_bytes: 1020
#include<cstdio>

int main(){
	int n, x;
	scanf("%d %d", &n, &x);
	while(n || x){
		int count = 0;
		for(int i = 1; i < n - 1; i++){
			for(int j = i + 1; j < n; j++){
				for(int k = j + 1; k <= n; k++){
					if(x == i + j + k){
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
		scanf("%d %d", &n, &x);
	}
	return 0;
}

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

int main() {
    long long n,m;
	cin >> n >> m ;
	vector<long long > a(n),b(n),c(n);
	for(long long  i=0;i<n;i++){
	    cin >> a.at(i) >> b.at(i);
		c.at(i) += a.at(i) *1000000 + b.at(i);
	}
	sort(c.begin(),c.end());

    long long r=0;
    long long e,f;

    for(long long  i=0;i<n;i++){
	     e=c.at(i)/1000000;
         f=c.at(i)%1000000;
         r+=min(m,f)*e;
		 
		 m-=f;
		 if(m<=0) break;
    } 
	 cout <<  r << endl;
	

}


Measured memory_bytes: 2560
N,M = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
cnt = 0
cost = 0
for i in range(N):
    a,b = A[i]
    if cnt+b<=M:
        cnt += b
        cost += a*b
    else:
        d = M-cnt
        cost += a*d
        break
print(cost)

Measured memory_bytes: 94124
n = int(input())
col = [int(i) for i in input().split()]

change = 0
i = 1
length = 1
while i < n:
    if col[i] == col[i-1]:
        length += 1
    else:
        change += length // 2
        length = 1
    i += 1
else:
    change += length // 2

print(change)

Measured memory_bytes: 3060