akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

string s;
int n,q;
int f[100005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>q>>s;
    for(int i=1;i<s.size();i++){
        if(s[i-1]=='A'&&s[i]=='C'){
            f[i]++;
        }
        f[i]+=f[i-1];
    }
    while(q--){
        int a,b;cin>>a>>b;
        cout<<f[b-1]-f[a-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 1488
l,r = map(int,input().split())
ans = 2020
if ((l//2019) != (r//2019)) or l%2019 == 0:
         print(0)
         exit()
else:
         for i in range(l%2019,r%2019):
                  for j in range(i+1,r%2019+1):
                           if (i*j)%2019 < ans:
                                    ans = (i*j)%2019
print(ans)


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 998244353;

const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;

	vector<pii> S(K);
	rep(i, 0, K)
	{
		cin >> S[i].first >> S[i].second;
	}

	vector<int> DP(2*N + 10, 0);
	vector<int> IMOS(2 * N + 10, 0);
	DP[0] = 1;

	rep(i, 0, N + 2)
	{
		if (i > 0)
		{
			IMOS[i] += IMOS[i - 1];
			IMOS[i] %= MOD;
			DP[i] = IMOS[i];
		}
		rep(j, 0, K)
		{
			IMOS[i + S[j].first] += DP[i];
			IMOS[i + S[j].first] %= MOD;
			IMOS[i + S[j].second + 1] = (IMOS[i + S[j].second + 1] - DP[i] + MOD) % MOD;
		}
	}

	cout << DP[N-1] << endl;

	return 0;
}


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  ll sum=0;
  cin>>n;
  rep(i,n){
    if(i%3!=0 && i%5!=0)
      sum+=i;
  }
  cout<<sum<<endl;
}


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

int main() {
  int n, t;
  cin >> n >> t;
  
  vector<int> cost(n);
  vector<int> time(n);
 
  for (int i = 0; i < n; i++) {
    cin >> cost.at(i) >> time.at(i);
  }
  
  int ans = 999999;
  
  for (int i = 0; i < n; i++) {
    if (cost.at(i) < ans && time.at(i) <= t) {
      ans = cost.at(i);
    }
  }
  
  if (ans < 999999) {
    cout << ans << endl;
  }
  else {
    cout << "TLE" << endl;
  }
  
  
}

Measured memory_bytes: 256
# coding: utf-8

numbers=input().rstrip().split(" ")

if int(numbers[0])==1:
    numbers[0]=14

if int(numbers[1])==1:
    numbers[1]=14
    
if int(numbers[0])>int(numbers[1]):
    print("Alice")

elif int(numbers[0])<int(numbers[1]):
    print("Bob")

else:
    print("Draw")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  string ans = "Yes";
  for (int i =0; i < S.size(); i++) {
    if (S[i] == 'U' || S[i] == 'D') continue;
    if ((i+1) % 2 == 1 && S[i] == 'R') continue;
    if ((i+1) % 2 == 0 && S[i] == 'L') continue;
    ans = "No";
    break;
  }
  cout << ans << endl;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

const int N = 1e5;

int num[4];
int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(num,-1,sizeof num);
	int n,m; cin >> n >> m;
	bool flag = true;
	FOR(i,m) {
		int a,b; cin >> a >> b;
		if(num[a] == -1 || num[a] == b) num[a] = b;
		else flag = false;
	}
	if(num[1] == 0 && n > 1) flag = false;
	if(!flag) cout << -1 << endl;
	else {
		REP(i,1,n) {
			if(num[i] == -1) {
				if(i == 1 && n > 1) num[i] = 1;
				else num[i] = 0;
			}
			cout << num[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

cnt = Counter(A)
ans = sum(A)
for _ in range(Q):
    b, c = map(int, input().split())
    num_b = cnt[b]
    diff = num_b * (c - b)
    ans += diff
    cnt[b] -= num_b
    cnt[c] += num_b
    print(ans)
    

Measured memory_bytes: 95092
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int GetDigit(int num) {
  int digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

bool is753(int n) {
  int digit = GetDigit(n);
  string s = to_string(n);
  int cnt7 = 0, cnt5 = 0, cnt3 = 0;
  for (int i = 0; i < digit; ++i) {
    if (s[i] == '7')
      cnt7++;
    else if (s[i] == '5')
      cnt5++;
    else if (s[i] == '3')
      cnt3++;
    else
      return false;
  }
  if (cnt7 > 0 && cnt5 > 0 && cnt3 > 0)
    return true;
  else
    return false;
}

int main() {
  int N;
  cin >> N;
  if (N >= 777777753) {
    cout << 26484 << endl;
  } else {
    int MAX = 26485;
    int store[4] = {0, 3, 5, 7};
    vector<int> v;
    for (int i1 = 0; i1 < 4; ++i1) {
      for (int i2 = 0; i2 < 4; ++i2) {
        for (int i3 = 0; i3 < 4; ++i3) {
          for (int i4 = 0; i4 < 4; ++i4) {
            for (int i5 = 0; i5 < 4; ++i5) {
              for (int i6 = 0; i6 < 4; ++i6) {
                for (int i7 = 0; i7 < 4; ++i7) {
                  for (int i8 = 0; i8 < 4; ++i8) {
                    for (int i9 = 0; i9 < 4; ++i9) {
                      int num = store[i1] * 100000000 + store[i2] * 10000000 +
                                store[i3] * 1000000 + store[i4] * 100000 +
                                store[i5] * 10000 + store[i6] * 1000 +
                                store[i7] * 100 + store[i8] * 10 +
                                store[i9] * 1;
                      if (is753(num)) v.push_back(num);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < MAX; ++i) {
      if (v[i] == N) {
        cout << i + 1 << endl;
        break;
      } else if (v[i] > N) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 512
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    string s;
    cin>>s;
    cout<<((s=="a"||s=="i"||s=="u"||s=="e"||s=="o")?"vowel":"consonant")<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		if(N<=111) {
			System.out.println(111);
		}else if(N<=222) {
			System.out.print(222);
		}else if(N<=333) {
			System.out.print(333);
		}else if(N<=444) {
			System.out.print(444);
		}else if(N<=555) {
			System.out.print(555);
		}else if(N<=666) {
			System.out.print(666);
		}else if(N<=777) {
			System.out.print(777);
		}else if(N<=888) {
			System.out.print(888);
		}else if(N<=999) {
			System.out.print(999);
		}
	}
}


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

using namespace std;


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n), b(m);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vector<long long> A = {0}, B = {0};
    for(int i = 0; i < n; i++) {
        A.push_back(a[i] + A[i]);
    }
    for(int i = 0; i < m; i++) {
        B.push_back(b[i] + B[i]);
    }
    int ans = 0, j = m;
    for(int i = 0; i < n + 1; i++) {
        if(A[i] > k) {
            break;
        }
        while(B[j] > k - A[i]) {
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11112
n=int(input())
f=[list(map(int, input().split())) for _ in range(n)]
p=[list(map(int, input().split())) for _ in range(n)]

from itertools import product
bits_l=list(product([0,1], repeat=10))
bits_l.remove((0,0,0,0,0,0,0,0,0,0))

ans=-float("inf")
for bits in bits_l:
    tmp_ans=0
    for shop in range(n):
        tmp_cnt=0
        for i, bit in enumerate(bits):
            if bit==1 and f[shop][i]==1:
                tmp_cnt+=1
        tmp_ans+=p[shop][tmp_cnt]
    ans=max(ans, tmp_ans)

print(ans)

Measured memory_bytes: 9340
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ h, w ] <- readInts
	[ y, x ] <- readInts
	print $ ( h - y ) * ( w - x )

Measured memory_bytes: 380
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
  print(1)
if x2 == 0:
  print(2)
if x3 == 0:
  print(3)
if x4 == 0:
  print(4)
if x5 == 0:
  print(5)


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

int main(){

    int n;
    cin>> n;
    for(int i=0; i<n; i++){
        int Y, M, D;
        cin>> Y>> M>> D;
        int ans=0;
        for(int y=1; y<=Y; y++){
            if(y==Y){
                for(int m=1; m<=M; m++){
                    if(m==M){
                        for(int d=1; d<=D; d++){
                            ans++;
                        }
                    }else{
                        if(y%3==0){
                            ans+=20;
                        }else if(m%2==1){
                            ans+=20;
                        }else{
                            ans+=19;
                        }
                    }
                }
            }else{
                if(y%3==0) ans+=200;
                else ans+=195;
            }
        }

        cout<< 196471-ans<< endl;

    }


    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, k;
  string s;
  cin >> n >> k >> s;
  int cnt = 0;
  rep(i,n) {
    if (i > 0 && s[i] == 'L' && s[i-1] == 'L') cnt++;
    else if (i < n-1 && s[i] == 'R' && s[i+1] == 'R') cnt++;
  }
  int ans = min(n-1, cnt + 2*k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int k,n,l,i;
  int ans=(1<<29);
  cin >> n >> l;
  vector<int> x(n);
  for(i=0;i<n;i++){
    x[i]=l+(i+1)-1;
    if(abs(x[i])<ans){
      ans=abs(x[i]);
      k=x[i];
    }
  }
  for(i=0;i<n;i++){
    if(k==x[i]){
      x[i]=0;
      break;
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    sum+=x[i];
  }
  cout << sum << endl;
  return 0;
}

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

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main() {
    int n, q, A[10010], key, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> key;
        if (search(A, n, key)) sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3104
h, w = map(int, input().split())

A = []
for i in range(h):
    a = list(input())
    if '#' in a:
        A.append(a)
        
for i in range(w - 1, -1, -1):
    for j in range(len(A)):
        if A[j][i] == '#':
            break
    else:
        for k in range(len(A)):
            del A[k][i]
            
for a in A:
    print(''.join(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MX=3*1e5+100;
const long long INF = 1e18;
ll N, M, k;
ll arr[MX];
int main()
{
    ll N ,k;
    int i=0;
    cin>>N>>k;
    ll num=1;
    while(i < N)
    {
        num=min(num*2, num+k);
        i++;

    }
    cout<<num;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (A >= B){
        cout << "delicious" << endl;
    }
    else if (B > X + A){
        cout << "dangerous" << endl;
    }
    else {
    cout << "safe" << endl;
    }
}


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

int main ()
{
    int s;
    cin >> s;
    int yekan = s % 10;
    int dahgan = s / 10 % 10;
    int sadgan = s / 100 % 10;
    int hezargan = s / 1000 % 10;
    if (yekan == dahgan || dahgan == sadgan || sadgan == hezargan)
        cout << "Bad";
    else
        cout << "Good";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	ll i=0,count=0,max=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
		{
			count++;
		}
		else
		{
			if(max<count)
			{
				max=count;
			}
			count=0;
		}
	}	
		if(max<count)
			{
				max=count;
			}
	cout<<max;
}	

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
    int n,m;
    cin >> n >> m;
    if(n < m) swap(n,m);
    if(m < n-1) {
        cout << 0 << endl;
        return 0;
    }
    combination c(n);
    mint ans = 0;
    if(n==m) {
        ans = (mint)(2)*c.fact[n]*c.fact[m];
    }
    else {
        ans = c.fact[n]*c.fact[m];
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    if(a%x==0) cout << b/x - a/x + 1 << "\n";
    else cout << b/x - a/x << "\n";
    return 0;
}

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

using namespace std;

int n;
double p[3000];
double dp[3000][3000];

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

    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];

    for(int i = 2; i <= n; i++)
    {
        dp[i][0] = dp[i-1][0] * (1-p[i]);
    }
    
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j <= i; j++)
        {
            dp[i][j] = (dp[i-1][j-1] * p[i]) + (dp[i-1][j] * (1-p[i]));
        }
    }

    double sum = 0;
    for(int i = (n+1)/2; i <= n; i++)
    {
        sum += dp[n][i];
    }

    printf("%.10lf", sum);
}

Measured memory_bytes: 68864
#include <stdio.h>
int main(){
    int a,b,c,x,count;
    scanf("%d %d %d %d",&a, &b, &c, &x);
    
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x){
                    count++;
           
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int W,H;
char fld[20][21];
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
bool used[20][20];
int rec(int y,int x){
    if(fld[y][x]!='.'||used[y][x])return 0;
    used[y][x]=true;
    int ret=0;
    for(int i=0;i<4;i++){
        int ty=y+dy[i],tx=x+dx[i];
        if(ty<0||ty>=H||tx<0||tx>=W)continue;
        ret+=rec(ty,tx);
    }
    return ret+1;
}
int main(){
    while(cin>>W>>H,W||H){
        fill_n(*used,400,false);
        for(int i=0;i<H;i++)cin>>fld[i];

        int sy,sx;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(fld[i][j]!='@')continue;
                sy=i;
                sx=j;
                fld[i][j]='.';
            }
        }

        cout<<rec(sy,sx)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(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 = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a1,b1,a2,b2,a3,b3,a4,b4;
    cin >> a1 >> b1 >> a2 >> b2;
    a3 = a2-(b2-b1);
    a4 = a1-(b2-b1);
    b3 = b2+(a2-a1);
    b4 = b1+(a2-a1);
    PRINT(a3 << " " << b3 << " " << a4 << " " << b4);
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int t , n , m , k , x , y , z;
string s;
int a[MAXX];
char c;

int main()
{
    _FastIO;

    cin >> t;
    while(t--){
        cin >> s;
        if(s == "AC")
            a[0]++;
        if(s == "WA")
            a[1]++;
        if(s == "TLE")
            a[2]++;
        if(s == "RE")
            a[3]++;
    }
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
    return 0;
}


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

int main()
{
	ll n,y;
	cin>>n>>y;
	
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n;j++)
		{
			ll k=n-i-j;
			if((i+j+k==n) && ((i*10000+j*5000+k*1000)==y)&&k>=0)
			{
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = list(map(int, in_s()))
    ans = min(S.count(0), S.count(1))
    print(ans * 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10004
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  Vi V(3);
  VIN(V)
  SORT(V);
  Yes((V[0]==V[1] && V[1]!=V[2])||(V[0]!=V[1] && V[1]==V[2]));
}

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

if M%2 == 1:
    for i in range(M//2):
        print((M//2)-i, (M//2)+2+i)
    for i in range((M+1)//2):
        print(M+1+i, M*2+1-i)

else:
    for i in range(M//2):
        print((M//2)-i, (M//2)+1+i)
    for i in range((M+1)//2):
        print(M+1+i, M*2+1-i)


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


void solve(long long N, long long K, long long R, long long S, long long P, std::string T){
    ll ans = 0;

    vector<int> f(N, 0);

    for(int i = 0;i < N;i++){
    //    cout<<ans<<endl;
        if(T[i] == 'r'){
            if(i - K < 0){
                ans += P;
                f[i] = 1;
            }else{
                if(!(T[i-K] == T[i] && f[i-K])){
                    f[i] = 1;
                    ans += P;
                }
            }
        }else if(T[i] == 's'){
            if(i - K < 0){
                ans += R;
                f[i] = 1;
            }else{
                if(!(T[i-K] == T[i] && f[i-K])){
                    f[i] = 1;
                    ans += R;
                }
            }
        }else if(T[i] == 'p'){
            if(i - K < 0){
                ans += S;
                f[i] = 1;
            }else{
                if(!(T[i-K] == T[i] && f[i-K])){
                    f[i] = 1;
                    ans += S;
                }
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


Measured memory_bytes: 896
N = int(input())
lower = []
upper = []
for i in range(N):
    a, b = map(int, input().split())
    lower.append(a)
    upper.append(b)
lower.sort()
upper.sort()
if N % 2 == 1:
    print(upper[(N-1)//2]-lower[(N-1)//2]+1)
else:
    print(upper[N//2]+upper[N//2 - 1]-lower[N//2]-lower[N//2 - 1]+1)

Measured memory_bytes: 25404
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

struct edge{
    int from;
    int to;
    int cost;
};
int n,m;
int d[1010];

signed main(){
    vector<edge> es;
    cin >> n >> m;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        edge e1 = {a-1,b-1,c};
        es.push_back(e1);
    }
    fill(d,d+n,-INF);
    d[0] = 0;
    rep(i,n){
        rep(j,m){
            struct edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    int neg[1010] = {0};
    rep(i,n){
        rep(j,m){
            struct edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                neg[e.to] = 1;
            }
        }
    }
    // rep(i,n) cerr << d[i] << " ";
    // cerr << endl;
    if(neg[n-1] == 1)cout << "inf" << endl;
    else cout << d[n-1] << endl;

    
    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://abc061.contest.atcoder.jp/tasks/abc061_d


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    char c11,c12,c13,c21,c22,c23;
    cin>>c11>>c12>>c13;
    cin>>c21>>c22>>c23;
    
    if(c11==c23&&c12==c22&&c13==c21) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 3020
#include <iostream>

using namespace std;

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

	while (1) {
		for (i = 0; i < n; i++) {
			if (a[i] % 2) {
				cout << ans << endl;
				return 0;
			}
			a[i] /= 2;
		}
		ans++;
	}
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ll = l % 2019
        rr = r - l + ll
        ans = 2019
        for i in range(ll, rr):
            for j in range(i + 1, rr + 1):
                ans = min(ans, i * j % 2019)
        print(ans)


Measured memory_bytes: 2940
#dp
n,m  = map(int,input().split())
ln = [-1 for i in range(n +1)]
mod_1 = 10**9 + 7
for i in range(m):
    ln[int(input())] = 0
#print(ln)
for i in range(n+1):
    if ln[i] ==0:
        pass
    elif i == 0:
        ln[i] = 1
    elif i == 1:
        ln[i] = 1
    else:
        ln[i] = (ln[i-1] + ln[i-2]) % mod_1
#print(ln)
print(ln[-1])

Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define vpi vector<pair<int,int> > 
#define vpll vector<pair<lli,lli> > 
#define vvi vector<vector<int> >
#define vvll vector<vector<lli> >
#define maxn 6005



int main(){
    fastio;
    int n;
    cin>>n;
    int ans=0;
    vll a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(all(a));
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] and a[j]!=a[k])
                if(a[i]+a[j]>a[k])
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
#include<algorithm>
#define MAX(x,y) ((x)>(y)?(x):(y))
int maxx,maxi,n,arr[55];
int main(){
	int i;
	scanf("%d",&n);
	maxx=0;
	for(i=1;i<=n;i++){
		scanf("%d",&arr[i]);
		if(abs(arr[i])>=abs(maxx)){
			maxx=arr[i];
			maxi=i;			
		}
	}
	printf("%d\n",2*n-1);
	for(i=1;i<=n;i++)	printf("%d %d\n",maxi,i);
	if(maxx<0){
		for(i=n;i>=2;i--)	printf("%d %d\n",i,i-1);
	}else{
		for(i=1;i<n;i++)	printf("%d %d\n",i,i+1);
	}
	return 0;
}

Measured memory_bytes: 128
from itertools import repeat
from itertools import combinations

def rec(s, i, total, m):
    if total == m:
        return 1

    if len(s) == i or total > m:
        return 0

    return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m)


def makeCache(s):
    cache = {}
    for i in range(len(s)):
        comb = list(combinations(s, i))
        for c in comb:
            cache[sum(c)] = 1

    return cache

def loop(s, m):
    for i in range(len(s)):
        comb = list(combinations(s, i))
        for c in comb:
            if sum(c) == m:
                return 1

    return 0

if __name__ == "__main__":
    n = int(input())
    a = [int (x) for x in input().split()]
    q = int(input())
    m = [int (x) for x in input().split()]
    s = makeCache(a)
    for i in m:
        #print("yes") if rec(a, 0, 0, i) > 0 else print("no")
        #print("yes") if loop(a, i) > 0 else print("no")
        print("yes") if i in s else print("no")



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

public class Main{

	public static void main(String[] args) throws IOException
	{
		int[][] room = new int[12][10];
		int i,j,n,x,y;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		n = Integer.parseInt(br.readLine() );//input n

		int[] b = new int[n];
		int[] f = new int[n];
		int[] r = new int[n];
		int[] v = new int[n];

		for(i=0; i<n; i++)
		{
			String[] str = br.readLine().split(" ");

			b[i] = Integer.parseInt(str[0]);
			f[i] = Integer.parseInt(str[1]);
			r[i] = Integer.parseInt(str[2]);
			v[i] = Integer.parseInt(str[3]);

			x = f[i] + 3*(b[i]-1);
			y = r[i];

			room[x-1][y-1] += v[i];
		}

		for(i=0; i<12; i++)
		{
			for(j=0; j<10; j++)
			{
				System.out.print(" " + room[i][j]);
			}

			System.out.println();
			if( (i+1)%3==0 && i<11) System.out.println("####################");
		}

	}
}

Measured memory_bytes: 24700
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll A,B,C;
    cin >> A >> B >> C;
    cout << B + min(A + B + 1, C)<< endl;
}

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

int main(){
  int d;
  std::cin >> d;
  std::vector<int> c(26);
  for (int i = 0; i < 26; i++) std::cin >> c[i];
  std::vector<std::vector<int> > s(d, std::vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      std::cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    std::cout << 1 << std::endl;
  }
  return 0;
}


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

using namespace std;

/*
	UNITY_NODE sumの単位元
	UNITY_LAZY addの単位元
	nodeの初期値に注意(init)
	addの呼び出し元に注意(区間の長さに比例する)
*/
template <class NODE, class LAZY, NODE UNITY_NODE, LAZY UNITY_LAZY>
struct LazySegTree {
// edit start
	void add(LAZY &a, LAZY b) {
		a += b;
	}
	void reflect(NODE& a, LAZY b, int l, int r) {
		a += b;
	}
	NODE merge(NODE a, NODE b) {
		return a + b;
	}
// end
	int n;
	vector<NODE> node;
	vector<LAZY> lazy;
	LazySegTree(int sz) {
		init(sz);
	}
	void init(int sz) {
		n = 1;
		while (n < sz) n *= 2;
		node.assign(2*n-1, 0);
		lazy.assign(2*n-1, UNITY_LAZY);
	}
	void eval(int l, int r, int k) {
		reflect(node[k], lazy[k], l, r);
		if (r - l > 1) {
			add(lazy[k*2+1], lazy[k] / 2);
			add(lazy[k*2+2], lazy[k] / 2);
		}
		lazy[k] = UNITY_LAZY;
	}
	void renode(int k) {
		node[k] = merge(node[k*2+1], node[k*2+2]);
	}
	void set(int a, int b, LAZY x, int k=0, int l=0, int r=-1) {
		if (r < 0) r = n;
		if (b <= l || r <= a) {
			eval(l, r, k);
		} else if (a <= l && r <= b) {
			add(lazy[k], x * (r - l));
			eval(l, r, k);
		} else {
			eval(l, r, k);
			set(a, b, x, k*2+1, l, (l+r) / 2);
			set(a, b, x, k*2+2, (l+r) / 2, r);
			renode(k);
		}
	}
	NODE get(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) r = n;
		eval(l, r, k);
		if (b <= l || r <= a) {
			return UNITY_NODE;
		} else if (a <= l && r <= b) {
			return node[k];
		} else {
			NODE t1 = get(a, b, 2*k+1, l, (l+r) / 2);
			NODE t2 = get(a, b, 2*k+2, (l+r) / 2, r);
			renode(k);
			return merge(t1, t2);
		}
	}
};

int main(){
	int n, q;
	cin >> n >> q;
	LazySegTree<long long, long long, 0, 0> L(n);
	while (q--) {
		int a, s, t, x;
		cin >> a >> s >> t;
		if (a == 0) {
			cin >> x;
			L.set(s-1, t, x);
		} else {
			cout << L.get(s-1, t) << endl;
		}
	}
}



Measured memory_bytes: 7040
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+2; 
int s[L],t[L];
int main() {
	string S,T;
	cin >> S >> T;
	auto f=[](char c){return c=='A'?1:2;};
	for(int i=0;i<S.size();i++){
		s[i+1]=(s[i]+f(S[i]))%3;
	}
	for(int i=0;i<T.size();i++){
		t[i+1]=(t[i]+f(T[i]))%3;
	}
	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if((s[b]+3-s[a-1])%3==(t[d]+3-t[c-1])%3){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}



	return 0;
}



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

int main(){
	string thought;
	string actual;
	cin >> thought;
	cin >> actual;
	int count = 0;
	for(int i = 0;i < (int)thought.size(); i++){
		if(thought[i] == actual[i]){
			count++;	
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int sum[N];
char str[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, q;
	cin >> n >> q;
	scanf("%s", str + 1);
	for (int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1];
		sum[i] += str[i] == 'A' && str[i + 1] == 'C';
	}
	while (q--)
	{
		int l, r;
		cin >> l >> r;
		r--;
		cout << sum[r] - sum[l - 1] << '\n';
	}
	return 0;
}

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

int main(){
  int n,m,x;
  int count1=0;
  int count2=0;
  cin >> n >> m >> x;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin >> a[i];
  }
  for(int i=x+1;i<=n;i++){
    for(int j=0;j<m;j++){
      if(i==a[j]){
        count1++;
      }
    }
  }
  for(int i=x-1;i>=0;i--){
    for(int j=0;j<m;j++){
      if(i==a[j]){
        count2++;
      }
    }
  }
  cout << min(count1,count2) << endl;
}

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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);
        }


        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            int n = int.Parse(sz);
            int[] a = new int[n];
            string[] szarr = Console.ReadLine().Split(' ');
            for(int i=0;i<szarr.Length;++i)
            {
                a[i] = int.Parse(szarr[i]);
            }

            insertionSort(a);

        }
        private static void insertionSort(int[] a)
        {
            Writeline(
                a);
            for (int i=1;i<a.Length;++i)
            {
                int v = a[i];
                int j = i - 1;
                while(j >= 0 && a[j] > v)
                {
                    a[j + 1] = a[j];
                    j--;
                }
                a[j + 1] = v;
                Writeline(
                a);
            }
        }
        private static void Writeline(int[] a)
        {
            string sz = "";
            for(int i=0;i<a.Length;++i)
            {
                sz += a[i];
                if( i < a.Length - 1)
                {
                    sz += " ";
                }
            }
            Console.WriteLine(sz);
        }
    }

}



Measured memory_bytes: 9652
package main

import (
	"bufio"
	"fmt"
	"os"
	// "sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 0x100000)
var wtr = bufio.NewWriter(os.Stdout)

// SplitSpace 空白で分割設定
func SplitSpace() {
	scanner.Split(bufio.ScanWords)
}

// NextLine 標準入力から１行読み込む
func NextLine() string {
	scanner.Scan()
	return scanner.Text()
}

// NextInt 標準入力から数値を一つ読み込む
func NextInt() int {
	n, _ := strconv.Atoi(NextLine())
	return n
}

// ReadLine 標準入力から長めの1行を読み込む
func ReadLine() string {
	buf := make([]byte, 0, 0x100000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func ChMin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func ChMax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//================

func main() {
	SplitSpace()
	N := NextInt()
	W := NextInt()
	// N := 1
	// W := 1000000000
	w := make([]int, N)
	v := make([]int, N)
	dp := make([][]int, N+1)
	maxv := 0
	for i := 0; i < N; i++ {
		w[i] = NextInt()
		v[i] = NextInt()
		// w[i] = 1000000000
		// v[i] = 10
		ChMax(&maxv, v[i])
	}
	maxv *= N
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, maxv+1)
		for j := 0; j < maxv+1; j++ {
			dp[i][j] = 1 << 30
		}
	}
	dp[0][0] = 0
	for i := 0; i < N; i++ {
		for sv := 0; sv <= maxv; sv++ {
			if sv-v[i] >= 0 {
				ChMin(&dp[i+1][sv], dp[i][sv-v[i]]+w[i])
			}
			ChMin(&dp[i+1][sv], dp[i][sv])
		}
	}
	res := 0
	for i := 0; i <= maxv; i++ {
		if dp[N][i] <= W {
			res = i
		}
	}
	// fmt.Println(dp)
	fmt.Println(res)
}


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

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
/*-------------------------------------------------*/
template <typename T>
vector<T> slide_min(const vector<T> &a, int len) {
  int n = a.size();
  vector<T> res(n - len + 1);
  deque<T> deq;
  REP(i, n) {
    // ++R
    while (!deq.empty() && a[deq.back()] >= a[i]) deq.pop_back();
    deq.emplace_back(i);
    if (i + 1 >= len) {
      int left = i + 1 - len;
      res[left] = a[deq.front()];
      // ++L
      if (deq.front() == left) deq.pop_front();
    }
  }
  return res;
}

template <typename T>
vector<T> slide_max(const vector<T> &a, int len) {
  int n = a.size();
  vector<T> res(n - len + 1);
  deque<T> deq;
  REP(i, n) {
    // ++R
    while (!deq.empty() && a[deq.back()] <= a[i]) deq.pop_back();
    deq.emplace_back(i);
    if (i + 1 >= len) {
      int left = i + 1 - len;
      res[left] = a[deq.front()];
      // ++L
      if (deq.front() == left) deq.pop_front();
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<int> p(n); REP(i, n) cin >> p[i];
  if (n == k) {
    cout << "1\n";
    return 0;
  }
  vector<int> inc(n, 0);
  REP(i, n - 1) {
    inc[i] += p[i] < p[i + 1];
    inc[i + 1] = inc[i];
  }
  vector<int> same(n - k + 1, -1), mn = slide_min(p, k + 1), mx = slide_max(p, k + 1);
  REP(i, n - k + 1) {
    if (inc[i + k - 2] - (i == 0 ? 0 : inc[i - 1]) == k - 1) continue;
    same[i] = (i < n - k && mn[i] == p[i] && mx[i] == p[i + k] ? 0 : 1);
  }
  int ans = 0;
  bool fixed = false;
  REP(i, n - k + 1) {
    if (same[i] == -1) {
      fixed = true;
    } else if (same[i] == 1) {
      ++ans;
    }
  }
  cout << ans + fixed << '\n';
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll W, H, N;
    cin >> W >> H >> N;

    char c[101][101];
    rep(i, 101) rep(j, 101) c[i][j] = 0;

    rep(i,N){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1) rep(j, x) rep(k, 101) c[j][k] = 1;
        if(a == 2) for(int j = x; j <= 100; ++j) rep(k,101) c[j][k] = 1;
        if(a == 3) rep(k, y) rep(j, 101) c[j][k] = 1;
        if(a == 4) for(int k = y; k <= 100; ++k) rep(j,101) c[j][k] = 1;
    }

    ll ans = 0;
    rep(i, W) rep(j, H) ans += c[i][j] == 0;
    print(ans);

    return 0;
}

Measured memory_bytes: 256