akhauriyash/Code-Regression huggingface dataset:
n, x = list(map(int, input().split(" ")))
L = list(map(int, input().split(" ")))

cnt = 0
d = 0

for i in range(1,n+1):
    D = d + L[i-1]
    
    if D <= x:
        cnt+=1
        d=D
    else:
        d=D
        
print(cnt+1)

Measured memory_bytes: 3060
n, k = map(int, input().split())
a = list(map(int, input().split()))
sumf = sum(a[:k])
for i in range(1,n-k+1):
    sumn = sumf - a[i-1] + a[i+k-1]
    print("Yes" if sumn>sumf else "No")
    sumf = sumn


Measured memory_bytes: 31680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string a, b, c;
  cin >> a >> b >> c;
  cout << char(a[0] - 32) << char(b[0] - 32) << char(c[0] - 32) << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 3616
use std::cmp::min;
use std::cmp::max;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let v = read_vec();
    let h: usize = v[0];
    let w: usize = v[1];

    let mut mn: usize = 100000000000;

    for a in 1..h {
        if h - a > 1 {
            let yoko:usize = (h - a) / 2;
            mn = if max(a*w, (h-a-yoko)*w) - min(yoko*w, a*w) < mn {
                max(a*w, (h-a-yoko)*w) - min(yoko*w, a*w)
            } else {
                mn
            };
        }

        if w > 1 {
            let tate:usize = w / 2;
            mn = if max(a*w, (w-tate)*(h-a)) - min(tate*(h-a), a*w) < mn {
                max(a*w, (w-tate)*(h-a)) - min(tate*(h-a), a*w)
            } else {
                mn
            };
        }
    }

    for a in 1..w {
        if w - a > 1 {
            let yoko:usize = (w - a) / 2;
            mn = if max(a*h, (w-a-yoko)*h) - min(yoko*h, a*h) < mn {
                max(a*h, (w-a-yoko)*h) - min(yoko*h, a*h)
            } else {
                mn
            };
        }

        if h > 1 {
            let tate:usize = h / 2;
            mn = if max(a*h, (h-tate)*(w-a)) - min(tate*(w-a), a*h) < mn {
                max(a*h, (h-tate)*(w-a)) - min(tate*(w-a), a*h)
            } else {
                mn
            };
        }
    }

    println!("{}", mn);
}

Measured memory_bytes: 4352
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
 {
     
     int n,a[100];
     cin>>n;
     for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
     int ans=1000000;
     for(int i=1;i<=100;i++)
      { 
           int s=0;
          
          for(int j=0;j<n;j++)
           {
              s+=(a[j]-i)*(a[j]-i); 
           }
          ans =min(ans,s);
            //  cout<<ans<<endl;
      }
 cout<<ans;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <complex>

using namespace std;

#define INF 1 << 16

typedef complex<int> P;

int abs(int n) {
	return n < 0 ? -n : n;
}

int main() {
	int W, H;
	while (cin >> W >> H, W || H) {
		vector<P> v;
		vector<int> type;
		vector< vector<int> > m(7);

		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x) {
				if (str[x] == '.') continue;

				v.push_back( P(x, y) );
				if (str[x] == 'S') type.push_back( 5 );
				else if (str[x] == 'G') type.push_back( 6 );
				else if (str[x] != '.') type.push_back( str[x] - '1' );

				m[type[type.size()-1]].push_back(v.size()-1);
			}
		}

		int count = 0, no;
		for (int i = 0; i < 5; ++i)
			if ( !m[i].size() )
				++count, no = i;

		queue<int> que;
		if (count >= 2) {
			cout << "NA" << endl;
			continue;
		}
		else if (count == 1) que.push(no);
		else
			for (int i = 0; i < 5; ++i)
				que.push(i);

		pair<int, int> ans = pair<int, int>(0, INF);
		while ( !que.empty() ) {
			int kind = que.front(); que.pop();
			vector<int> len(v.size(), INF);

			vector<int> types;
			types.push_back(5);
			for (int i = 0; i < 4; ++i)
				types.push_back( (kind + i + 1) % 5 );

			types.push_back(6);

			len[m[5][0]] = 0;
			for (int i = 0; i < 5; ++i) {
				int now = types[i], next = types[i+1];
				for (int j = 0; j < m[next].size(); ++j)
					for (int k = 0; k < m[now].size(); ++k)
						if (len[m[next][j]] > len[m[now][k]] + abs(v[m[now][k]].real() - v[m[next][j]].real()) + abs(v[m[now][k]].imag() - v[m[next][j]].imag()))
							len[m[next][j]] = len[m[now][k]] + abs(v[m[now][k]].real() - v[m[next][j]].real()) + abs(v[m[now][k]].imag() - v[m[next][j]].imag());
			}

			if (len[m[6][0]] < ans.second)
				ans = pair<int, int>(kind+1, len[m[6][0]]);
		}

		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 1076
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import Data.Graph
import Data.Int
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector (Int32, Int32) -> Int
solve !n !m !xyz = length $ components $ buildG
  (0, n - 1)
  (VU.toList $ VU.map (\(!x, !y) -> (fromIntegral x, fromIntegral y)) xyz)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, m) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  uvw <-
    VU.replicateM m
    $   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  print $ solve n m uvw


Measured memory_bytes: 55548
n = int(input())
L = list(map(int,input().split()))


a = 1000
k = 0

for i in range(n-1):
    if L[i]<L[i+1] and k == 0:
        k = a//L[i]
        a = a-L[i]*k
    elif L[i]>L[i+1] and k > 0:
        a = a + L[i]*k
        k = 0
else:
    if k > 0:
        a = a + L[n-1]*k

print(a)    



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

int main(){
    ll n,k,x,y;
	cin>>n>>k>>x>>y;
	if(min(n,k)==n){
		cout<<n*x;
		return 0;
	}
	cout<<(k*x)+(n-k)*y;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i;
	int sum[3];
	cin>>n;
	for(i=n;i<1000;i++){
		int x=i;
		int j=0;
		while(x>0){
			sum[j]=x%10;
			x/=10;
			j++;
		}
		if(sum[0]==sum[1]&&sum[1]==sum[2]){
			break;
		}
	}
	cout<<sum[0]<<sum[1]<<sum[2]<<endl;
	return 0;
}

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

int main(void){
   
   string s;
   cin >> s;
   
   if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
       cout << "Bad" <<endl;
   }
   else{
       cout << "Good" <<endl;
   }
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<bool> a(52);
	for (int i = 0; i < n; i++) {
		int x; string s;
		cin >> s >> x;
		if (s == "H")x += 13;
		if (s == "C")x += 26;
		if (s == "D")x += 39;
		a[x - 1] = true;
	}
	vector<string> b(4);
	b[0] = "S"; b[1] = "H"; b[2] = "C"; b[3] = "D";
	for (int i = 0; i < 52; i++) {
		if (!a[i]) {
			cout << b[i / 13] << " " << i % 13 + 1 << endl;
		}
	}
	return 0;
}


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

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var Li = RL();
            int cnt = 0;
            foreach (var num in Li)
            {
                cnt += int.Parse(num.ToString());
            }

            bool ret= cnt % 9 == 0;


            Console.WriteLine(bool2ret(ret));
            Console.ReadLine();

        }

        static IEnumerable<long> RL2IE() { return spr(RL()).Select(x => (long)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 32728
import bisect
from collections import defaultdict as dd
def check(A, B, d, coef):
    M = 10**50
    for x in d[A]:
        if x not in d[B]:
            continue
        for y in d[A][x]:
            yi = bisect.bisect_left(d[B][x], y)
            if yi < len(d[B][x]):
                M = min((d[B][x][yi] - y)*coef, M)
    return M
def main():
    N = int(input())
    dx = {"U":dd(list), "D":dd(list), "R":dd(list), "L":dd(list)}
    dy = {"U":dd(list), "D":dd(list), "R":dd(list), "L":dd(list)}
    dxpy = {"U":dd(list), "D":dd(list), "R":dd(list), "L":dd(list)}
    dxmy = {"U":dd(list), "D":dd(list), "R":dd(list), "L":dd(list)}
    for _ in range(N):
        x, y, u = input().split()
        x = int(x)
        y = int(y)
        dx[u][x].append(y)
        dy[u][y].append(x)
        dxpy[u][x+y].append(y)
        dxmy[u][x-y].append(y)
    for d in [dx, dy, dxpy, dxmy]:
        for j in d:
            for k in d[j]:
                d[j][k].sort()
    M = 10 ** 50
    M = min(M, check("U", "D", dx, 5))
    M = min(M, check("R", "L", dy, 5))
    M = min(M, check("R", "D", dxmy, 10))
    M = min(M, check("U", "L", dxmy, 10))
    M = min(M, check("U", "R", dxpy, 10))
    M = min(M, check("L", "D", dxpy, 10))
    print('SAFE' if M == 10** 50 else M)
main()


Measured memory_bytes: 143552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long int;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    bool ok=true;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3!=0 && A[i]%5!=0) {
                ok=false;
                break;
            }
        }
    }
    
    if(ok) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    
    return 0;
}



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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;

    rep(i, n) {
        if (i == k-1) cout << tolower(s[i], locale());
        else cout << s[i];
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 100001

bool visited[MAX];
vector<int> same_row[MAX];

class Disjoint_Sets{
public:
	ll* parent;
	ll* size;
	Disjoint_Sets(ll n){
		parent = new ll[n];
		size = new ll[n];
		For(i,0,n) parent[i]=i;
		For(i,0,n) size[i]=1;
	}
	void merge(ll a,ll b){
		ll parent_a = find(a);
		ll parent_b = find(b);
		if(parent_a==parent_b) return;
		if(size[parent_a]<size[parent_b]){
			parent[parent_a] = parent_b;
			size[parent_b] += size[parent_a];
			size[parent_a] = 0;
		}else{
			parent[parent_b] = parent_a;
			size[parent_a] += size[parent_b];
			size[parent_b] = 0;
		}
	}
	ll find(ll a){
		if(parent[a]==a){
			return a;
		}
		parent[a]=find(parent[a]);
		return parent[a];
	}
}; 

vector<int> components[MAX];

vector<int> col_has[MAX];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	Disjoint_Sets D(MAX);
	int n;cin>>n;
	For(i,0,n){
		int x,y;cin>>x>>y;
		same_row[x].pb(y);
		col_has[y].pb(x);
	}

	For(i,0,MAX){
		if(same_row[i].size()!=0){
			For(j,1,same_row[i].size()){
				D.merge(same_row[i][j],same_row[i][j-1]);
			}
		}
	}

	For(i,0,MAX){
		components[D.find(i)].pb(i);
	}

	ll final=0;
	For(i,0,MAX){
		set<int> s;
		for(int x:components[i]){
			for(int y:col_has[x]) s.insert(y);
		}
		final+=(s.size()*components[i].size());
	}

	cout<<final-n<<endl;









	
}


Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int c[n];
  int a[n][m];
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  int ans = INF;
  rep(i,1<<n) {
    int cost = 0; 
    vector<int> u(m);
    rep(j,n) {
      if(i & (1<<j)) {
        cost += c[j];
        rep(k,m) u[k] += a[j][k];
      }
    }
    bool f = true;
    rep(j,m) {
      if(u[j] < x) f = false;
    }
    if(f) ans = min(ans,cost);
  }
  cout << (ans == INF ? -1 : ans) << endl;
  return 0;
}


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


int main() {
    int N, M;
    cin >> N >> M;

    vector<int> P(M);
    vector<int> Y(M);

    for(int i = 0; i < M; i++) cin >> P[i] >> Y[i];
    vector<vector<int>> X(N + 1);
    for(int i = 0; i < M; i++) {
        X[P[i]].push_back(Y[i]);
    }

    for(int i = 1; i <= N; i++) {
        sort(X[i].begin(), X[i].end());
    }
    for(int i = 0; i < M; i++) {
        cout << setfill('0') << right << setw(6) << P[i];
        int id = lower_bound(X[P[i]].begin(), X[P[i]].end(), Y[i]) - X[P[i]].begin();
        cout << setfill('0') << right << setw(6) << id + 1 << endl;
    }
   

    return 0;
}

Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<sstream>
using namespace std;

const int inf = 1<<30;

int D[15];

string sToi(int i){
  stringstream ss;
  ss<<i;
  return ss.str();
}

int main(){
  int N,K;
  cin>>N>>K;
  for(int i=0;i<K;i++){
    cin>>D[i];
  }
  int m = N;
  for(int i=N;i<=100000;i++){
    string str = sToi(i);
    bool flg = true;
    for(int j=0;j<(int)str.size();j++){
      for(int k=0;k<K;k++){
	if(str[j] - '0' == D[k]) flg = false;
      }
    }
    if(flg){
      m = i;
      break;
    }
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, L, T;
    cin >> N >> L >> T;
    vector<ll> ans;
    pair<ll, ll> a[N];
    for(ll i = 0; i < N; i++) cin >> a[i].first >> a[i].second;
    ll index = 0;
    for(ll i = 1; i < N; i++){
        if(a[i].second == a[0].second) continue;
        ll dist = (ll)abs(a[i].first - a[0].first);
        if(a[0].second == 2) dist = L - dist;
        ll add = (2 * T - dist) / L + (2 * T >= dist);
        index += (a[0].second == 1 ? 1 : -1) * add;
    }
    if(index < 0) index += ((-index) / N + 1) * N;
    index %= N;
    for(ll i = 0; i < N; i++){
        if(a[i].second == 1){
            ans.push_back((a[i].first + T) % L);
        }else{
            ll po = a[i].first - T;
            if(po < 0) po += ((-po) / L + 1) * L;
            ans.push_back(po % L);
        }
    }
    ll pos = ans[0];
    ll here;
    sort(ans.begin(), ans.end());
    if(a[0].second == 1){
        for(ll i = N -  1; i >= 0; i--){
            if(ans[i] == pos){
                here = i;
                break;
            }
        }
    }else{
        for(ll i = 0; i < N; i++){
            if(ans[i] == pos){
                here = i;
                break;
            }
        }
    }
    vector<ll> output(N);
    for(ll i = 0; i < N; i++) output[(index + i) % N] = ans[(here + i) % N];
    for(ll out : output) cout << out << endl;
    return 0;
}


Measured memory_bytes: 4468
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int>  pii;
template<class T>
void read(T &res)
{
    res = 0;
    char c = getchar();
    T f = 1;
    while(c < '0' || c > '9')
    {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
    {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
} 
map<int,int> mm;
const ll mod = 1e9+7;
int gcd(int a,int b){return b == 0? a : gcd(b,a % b);}
ll getpow(ll a,ll b)
{
	ll ans = 0;
	while(b)
	{
		if(b & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

const int maxn = 4000 + 5;
char a[maxn];
int vis[maxn];
std::vector<int> vv[3];
int n;
ll query(int i,int l,int r)
{
	ll ans =0 ;
	int s = 0;
			for(int j = 0; j < vv[l].size(); j ++ )
			{
				if(vv[l][j] > i)
				{
					s ++ ;
					vis[vv[l][j]] = 1;
				}
			}
			// printf("%d\n",s);
			for (int j = 0; j < vv[r].size(); j ++ )
			{
				if(vv[r][j] > i)
					break;
				int x = i - vv[r][j];
				int y = i + x;
				if(y <= n && vis[y] == 1)
					ans += s - 1;
				else
					ans += s;
			}
			s =0 ;
			for(int j = 0; j < vv[l].size(); j ++ )
			{
				if(vv[l][j] > i)
				{
					vis[vv[l][j]] = 0;
				}
			}




			for(int j = 0; j < vv[r].size(); j ++ )
			{
				if(vv[r][j] > i)
				{
					s ++ ;
					vis[vv[r][j]] = 1;
				}
			}
			// printf("%d\n",s);
			for (int j = 0; j < vv[l].size(); j ++ )
			{
				if(vv[l][j] > i)
					break;
				int x = i - vv[l][j];
				int y = i + x;
				if(y <= n && vis[y] == 1)
					ans += s - 1;
				else
					ans += s;
			}
			for(int j = 0; j < vv[r].size(); j ++ )
			{
				if(vv[r][j] > i)
				{
					vis[vv[r][j]] = 0;
				}
			}
			return ans;
}
int main()
{
	read(n);
	scanf("%s",a + 1);
	for (int i = 1; i <= n; i ++ )
	{
		if(a[i] == 'R')
			vv[0].push_back(i);
		else if(a[i] == 'G')
			vv[1].push_back(i);
		else
			vv[2].push_back(i);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i ++ )
	{
		if(a[i] == 'R')
		{
			ans += query(i,1,2);
		}
		else if(a[i] == 'G')
		{
			ans += query(i,0,2);
		}
		else
			ans += query(i,0,1);
		// printf("%d\n",ans);
	}
	printf("%lld\n",ans);
}

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

long long sum, tmp;
unsigned long long ans;
int i, j, n;
int a[200100];

int main() {
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= n; i++) {
		while (j + 1 <= n && (tmp ^ a[j + 1]) == sum + a[j + 1]) {
			tmp ^= a[j + 1];
			sum += a[j + 1];
			j++;
		}
		if (tmp == sum) {
			ans += j - i + 1;
		}
		tmp ^= a[i];
		sum -= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4600
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		(new Main()).execute();
	}
	public void execute() {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long H[] = new long[N] ;
		long max = 0 ;
		boolean ans = true ;
		for(int i = 0 ; i < N ; i ++) {
			H[i]= sc.nextLong();
			if(max < H[i]) {
				max =  H[i];
			}
			if(H[i] < max - 1) {
				ans = false ;
				break ;
			}
		}

		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 61120
// finish date: 2019/6/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


//割り算(分母だけ)  -  逆元(求めたい数とbigmodを渡す)
int divide_denominator(int a, int p = bigmod, int b = -1) {
    if (b < 0) b = p - 2;  //int gyakugen(int a, int p, int b = p - 2とできなかったため。)
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int d = divide_denominator(a, p, b / 2);
        return mul(d, d);
    } else {
        return mul(a, divide_denominator(a, p, b - 1));
    }
}

//割り算
int divide(int a, int b) {
    return mul(a, divide_denominator(b));
}


int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    FOR(k, K, N + 2) {
        int a = divide(mul(add(N, N - k + 1), k), 2);
        int b = divide(mul(k - 1, k), 2);
        ans = add(ans, add(sub(a, b), 1));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Map as Map

type M = Map.Map String Integer

getLines :: IO [String]
getLines = map (sort . BC.unpack) . BC.lines <$> BC.getContents

solve :: [String] -> M -> Integer
solve [] _ = 0
solve (s:ss) m = count + solve ss nextm
  where sorted = sort s
        count = fromMaybe 0 $ Map.lookup sorted m
        nextm = Map.insert sorted (count + 1) m

main :: IO ()
main = do
  getLine
  ls <- getLines
  print $ solve ls Map.empty

Measured memory_bytes: 71036
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.14159265358979
#define coutdb cout<<fixed<<setprecision(30)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, L, A[100000]; cin >> N >> L;
  REP(i, N) cin >> A[i];
  int last = -1;
  REP(i, N-1){
    if(A[i]+A[i+1] >= L) last = i+1;
  }
  if(last == -1){
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    for(int i = 1; i < last; i++) cout << i << endl;
    for(int i = N-1; i > last; i--) cout << i << endl;
    cout << last << endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

map<ii, bool> mapa;
const int ms = 110;
vector<ii> g[ms];
int n,m,a,b,c;
int dist[ms];
void ssp(int node){
	priority_queue<iii,vector<iii>,greater<iii>> pq;
	memset(dist,0x3f3f3f3f,sizeof(dist));
	dist[node] = 0;
	pq.push(iii(0,ii(node,-1)));
	while(pq.size()){
		iii sup = pq.top();
		pq.pop();
		
		int d = sup.first;
		int u = sup.second.first;
		int p = sup.second.second;
		if(d > dist[u])
			continue;
		if(p!=-1){
			mapa[{p,u}] = 1;
			mapa[{u,p}] = 1;	
		}
			
		for(auto it : g[u]){
			if(dist[it.first] > it.second+ d){
				dist[it.first] = dist[u] + it.second;
				pq.push(iii(dist[it.first],ii(it.first,u)));
			}	
		}
	
	}
}

int main(){
	cin >> n >> m;
	for(int i = 0;i<m;i++){
		cin >> a >> b >> c;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	for(int i = 1;i<=n;i++)
		ssp(i);
	int v1 = mapa.size()/2;
	cout<<(m-v1)<<endl;
}

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

int main(){
    string S;
    cin >> S;
    bool c = false, f = false;
    for(int i = 0;i < S.size();i++) {
        if(S.at(i) == 'C') c = true;
        if(c && S.at(i) == 'F') f = true;
        if(c && f) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
	int A,B;
	cin >> A >> B;
	int res = 0;
	for (int i = A; i < B+1; ++i) {
		string str = to_string(i);
		string rev = str;
		reverse(rev.begin(),rev.end());
		if (str == rev) {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
s=int(input())
A=[s]
for i in range(10**6):
  if A[i]%2==0:
    A.append(A[i]//2)
  else:
    A.append(3*A[i]+1)
  
  if (i+2)!=len(set(A)):
    print(i+2)
    exit()


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

int main(){
    string b;
    cin >> b;
    if(b=="A"){
        cout << "T" << endl;
    }
    if(b=="T"){
        cout << "A" << endl;
    }
    if(b=="C"){
        cout << "G" << endl;
    }
    if(b=="G"){
        cout << "C" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	int ai;
	for(int i=1;i<=n;i++)
	{
		cin>>ai;
		a[ai] = i;
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<" ";
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  }
  else if (A >= 6) {
    cout << B / 2 << endl;
  }
  else if (A < 6) {
    cout << 0 << endl;
  }
}

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

using namespace std;

int main(){
    int a, b, k, cnt = 0;
    cin >> a >> b >> k;
    int c = __gcd(a, b);
    for (int i = c; i > 0; i--){
        if (c % i == 0){
            cnt++;
            if (cnt == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int h,w;

	cin >> h >> w;
	vector<bool> goodx(110);
	vector<bool> goody(110);
	vector<string> board(110);

	rep(i, 0, h) {
		cin >> board[i];
	}
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (board[i][j] == '#') {
				goodx[i] = true;
				goody[j] = true;
			}
		}
	}
	rep(i, 0, h) {
		if (goodx[i] == true) {
			rep(j, 0, w) {
			
				if (goody[j] == true) {

					cout << board[i][j];



				}
			}
		cout << endl;
		}
		
	}



	/*
	ll x;
	ll y;

	bool goodx[110] = { false };
	bool goody[110] = {false};

	string board[110];

	cin >> x >> y;
	rep(i, 0, x) {
		cin >> board[i];
	}
	rep(i, 0, x) {
		rep(j, 0, y) {
			if (board[i][j] == '#') {
				goodx[i] = true;
				goody[j] = true;
			}
		}
	}
	rep(i, 0, x) {
		if (goodx[i] == true) {
			rep(j, 0, y) {
				if (goody[j]) {
					cout << board[i][j];
				}
			}
			cout << endl;
		}
	}*/
	
}
	

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

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

const int MAX = 2e5;

int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  char t[Q], d[Q];
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];

  int left = -1, right = N;
  for (int i = Q - 1; i >= 0; i--) {
    if (d[i] == 'R') {
      if (t[i] == s[right - 1]) {
        right--;
      }
      if (left > -1 && t[i] == s[left]) {
        left--;
      }
    } else {
      if (t[i] == s[left + 1]) {
        left++;
      }
      if (right < N && t[i] == s[right]) {
        right++;
      }
    }
  }

  cout << max(right - left - 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 900
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

count = 0
n.times do
  a = gets.split.map(&:to_i)
  count += 1 if a.zip(b).map{|x,y| x * y}.inject(:+) + c > 0
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0,N=0;
  cin >>a>>b;
  vector<int> L(b),R(b);
  for(int i=0;i<b;i++)cin>>L[i]>>R[i];
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  N=R[0]-L[b-1]+1;
  if(0>N)N=0;
  cout << N << endl;
}  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 31;
const int maxV = 90010;

 
const int maxN = 1e6+8;
const ll INF = 1000000000000000010LL;
const int MOD = 1e9+7;

int a[maxN];
int b[maxN];
 
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{		
		scanf("%d",&b[i]);		
	}
	a[1] = b[1];
	int ans = 0;
	ans += a[1];
	for(int i=2;i<n;i++)
	{
		a[i] = min(b[i-1],b[i]);
		ans += a[i];
	}
	a[n] = b[n-1];
	ans += a[n];
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2304
x,y = map(int, input().split())
a = 2 * x - 0.5 * y
b = (-1) * x + 0.5 * y
c = round(a)
d = round(b)
if c == a and d == b and c >= 0 and d >= 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int h, w;
    cin >> h >> w;
    rep(i, h) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

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

#define clr(ar, val) memset(ar, val, sizeof(ar))

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 dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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

ll n,x,c;
int main() {
    cin>>n>>x;
    ll ans=0;
    REP(i,n){
        cin>>c;
        if(ans==0){ans=abs(c-x);continue;}
        ans=gcd(ans,abs(c-x));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

class BIT
{
public:
	std::vector<LL>bit;
	void init(LL n)
	{
		bit.resize(n + 1, 0);
	}
	LL sum(LL i)
	{
		if (!i) return 0;
		return bit[i] + sum(i - (i & -i));
	}
	void add(LL i, LL x)
	{
		if (i >= (LL)bit.size()) return;
		bit[i] += x;
		add(i + (i & -i), x);
	}
};

int main()
{
	LL N, K;
	in >> N >> K;
	std::vector<LL>a(N);
	rep(i, N) in >> a[i];

	std::vector<LL>a_imos(N + 1);
	std::map<LL, LL>b_rev;
	rep(i, N)
	{
		a[i] -= K;
		a_imos[i + 1] = a_imos[i] + a[i];
	}

	std::vector<LL>b(N + 1);
	BIT tree; tree.init(N + 2);
	for (LL i = 1; i <= N; ++i) b[i] = a_imos[i];
	std::sort(b.begin(), b.end());
	rep(i, N + 1) b_rev[b[i]] = i + 1;
	rep(i, N + 1) tree.add(b_rev[b[i]], 1);
	tree.add(b_rev[0], -1);

	LL ans = 0;
	for (LL i = 1; i <= N; ++i)
	{
		auto it = std::lower_bound(b.begin(), b.end(), a_imos[i - 1]) - b.begin();
		ans += tree.sum(N + 1) - tree.sum(it);
		tree.add(b_rev[a_imos[i]], -1);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 18944
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
//#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
#include <unordered_map>
//#include <stack>
#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	const int m = n / 2;
	unordered_map<int, int> um1;
	unordered_map<int, int> um2;
	REP(i, m) {
		int v;
		cin >> v;
		um1[v]++;
		cin >> v;
		um2[v]++;
	}
	int nmax1 = 0;
	int vmax1;
	int nsecond1 = 0;
	for (const auto &e : um1) {
		if (nmax1 <= e.second) {
			nsecond1 = nmax1;
			vmax1 = e.first;
			nmax1 = e.second;
		}
		else if (nsecond1 < e.second) {
			nsecond1 = e.second;
		}
	}
	int nmax2 = 0;
	int vmax2;
	int nsecond2 = 0;
	for (const auto &e : um2) {
		if (nmax2 <= e.second) {
			nsecond2 = nmax2;
			vmax2 = e.first;
			nmax2 = e.second;
		}
		else if (nsecond2 < e.second) {
			nsecond2 = e.second;
		}
	}
	int ans;
	if (vmax1 != vmax2) {
		ans = n - nmax1 - nmax2;
	}
	else {
		ans = min(n - nmax1 - nsecond2, n - nsecond1 - nmax2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4376
#include <stdio.h>
int main()
{
    int A,B,x=1,y=2,z=3;
    scanf("%d %d", &A,&B);
    if( (A==1 && B==2) || (A==2 && B==1) ) {
        printf("%d\n",z);
    }
    else if( (A==1 && B==3) || (A==3 && B==1) ) {
        printf("%d\n", y);

    }
    else  {
        printf("%d\n", x);
    }
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>cnt(1e6+5,0);
    for(auto x:a){
        if(cnt[x]!=0){
            cnt[x]=2;
            continue;
        }
        for(ll i=x;i<1e6+5;i+=x)cnt[i]++;
    }
    ll ans=0;
    for(auto x:a){
        if(cnt[x]==1)ans++;
    }
    cout<<ans<<endl;
}

















































Measured memory_bytes: 12756
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	int aa = std::abs(a);
	int ab = std::abs(b);

	int c = std::abs(ab - aa);
	if (b == 0) {
		if (a > 0) {
			c++;
		}
	} else if (b < a) {
		c++;
		// 両方の符号がおなじ
		if ((a != aa) ^ (b == ab)) {
			c++;
		}
	} else if ((a == aa) ^ (b == ab)) {
		// 両方の符号が一致しない
		c++;
	}
	std::cout << c << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> v(h);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v[y] |= (1 << x);
    }
    auto dp = make_v<int>(h + 1, 1 << 4, 1 << 4);
    fill_v(dp, -INF);
    dp[0][0][0] = 0;
    for (int i = 1; i < h; i++) {
        for (int j = 0; j < (1 << 4); j++) {
            for (int k = 0; k < (1 << 4); k++) {
                chmax(dp[i][k][0], dp[i - 1][j][k]);
                for (int l = 0; l < 3; l++) {
                    if (((j | k | v[i] | v[i - 1]) & (1 << l)) ||
                        ((j | k | v[i] | v[i - 1]) & (1 << (l + 1)))) {
                        continue;
                    }
                    chmax(dp[i][k | (1 << l) | (1 << (l + 1))][0],
                          dp[i - 1][j][k] + 1);
                }
                if (j == 0 && k == 0 && v[i] == 0 && v[i - 1] == 0) {
                    chmax(dp[i][(1 << 4) - 1][0], dp[i - 1][j][k] + 2);
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << 4); i++) {
        for (int j = 0; j < (1 << 4); j++) {
            chmax(ans, dp[h - 1][i][j]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 19628
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int64_t x,y;
int main(){
    cin>>x>>y;
    int64_t kouho=x;
    int64_t count=1;
    while(kouho<=y){
       kouho*=2;
       count++;
    }
    cout<<count-1<<endl;
    return 0;
}




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

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    LL ans = 0;
    int mi = 1;
    for (int i = 1; i <= N; ++i) {
        int t; cin >> t;
        if (t < mi) {
            continue;
        } else if (t == mi) {
            ++mi;
            continue;
        }
        ans += (t-1)/mi;
        if (i == 1)  mi = 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N=100005,Mod=1e9+7;
int a[N],fac[N],inv[N];
inline int qpow(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod,b>>=1;
	}
	return ans;
}
int C(int n,int m){
	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main (){
	int n,k;scanf ("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[n]=qpow(fac[n],Mod-2);
	for (int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	sort(a+1,a+n+1);int ans=0;
	for (int i=k;i<=n;i++) ans=(ans+1ll*a[i]*C(i-1,k-1))%Mod;
	for (int i=1;i<=n-k+1;i++) ans=(ans-1ll*a[i]*C(n-i,k-1)%Mod+Mod)%Mod;
	printf ("%d",ans); 
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	vector<int> cnt(110000);
	cnt[1] = 1;
	cnt[0] = 1;
	for(int i = 2;i < 110000;i++){
		if(cnt[i])continue;
		for(int j = i+i;j < 110000;j+=i){
			cnt[j] = 1;
		}
	}
	// trace(cnt);
	int x;cin >> x;
	for(int i = x;i < 110000;i++){
		if(!cnt[i]){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3876
import numpy as np
from collections import Counter
import collections
a = list(map(int,input().split()))
N = a[0]
K = a[1]
d = np.array([])
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
l = Counter(b)
h = len(li) -K
Num = 0
if K >= len(li):
  print(0)
  exit()
d = np.append(d,list(l.values()))
d = np.sort(d)
for i in range(h):
  Num += d[i]
print(int(Num))

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

int main(){
  long long int n,k,ans,t;
  cin>>n>>k;
  if(n>=k && n%k==0){ cout<<"0"; return 0;}
  else if(n<k) {
    long long int x,y;
    x=n-k;
    if(x<0) x*=-1;
    y=x-k;
    if(y<0) y*=-1;
    cout<<min(x,y);
    return 0;
  }
  else {
    t=n/k;
    ans=n-t*k;
    long long int a,b;
    a=ans-k;
    if(a<0) a*=-1;
    b=a-k;
    if(b<0) b*=-1;
    cout<<min(a,b);
  }
}


Measured memory_bytes: 256
# ref https://qiita.com/drken/items/03c7db44ccd27820ea0d#j-%E5%95%8F%E9%A1%8C---sushi

N = int(input())
a = tuple(int(i) for i in input().split())

"""
i: 寿司が残り3個の皿の枚数
j: 寿司が残り2個の皿の枚数
k: 寿司が残り1個の皿の枚数

dp[i][j][k]: 必要な操作回数の期待値
"""
dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

# 初期条件
dp[0][0][0] = 0.0

C_1 = a.count(1)
C_2 = a.count(2)
C_3 = a.count(3)

for i in range(C_3+1):
    for j in range(C_2+C_3-i+1):
        for k in range(N-i-j+1):
            if i == j == k == 0:
                continue

            tmp = N
            if i > 0:
                tmp += dp[i-1][j+1][k] * i
            if j > 0:
                tmp += dp[i][j-1][k+1] * j
            if k > 0:
                tmp += dp[i][j][k-1] * k

            dp[i][j][k] = tmp / (i+j+k)

print(dp[C_3][C_2][C_1])

Measured memory_bytes: 254088
using System;

class Print_a_Rectangle
{
  public static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    int x;
    
    for(int i=1;i<=n;i++)
    {
      if(i%3==0) Console.Write(" {0}",i);
      else{
        x = i;
        do
        {
          if(x%10==3)
          {
            Console.Write(" {0}",i);
            break;
          }
          if(x==0) break;
          
          x = x/10;
          
        }while(true);
      }
    }
    
    Console.WriteLine();
  }
}

Measured memory_bytes: 9384