akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(9) + 10;

int N;
int a[200010];

vector<int> G[200010];
int ans[200010];
int dp[200010];

void dfs(int cur, int par = -1)
{
	auto itr = lower_bound(dp, dp + N, a[cur]);
	int tmp = *itr;
	*itr = a[cur];

	ans[cur] = lower_bound(dp, dp + N, inf) - begin(dp);

	for (int nxt : G[cur]) {
		if (nxt == par) continue;
		dfs(nxt, cur);
	}

	*itr = tmp;
}

signed main()
{
	cin >> N;
	rep(i, N) cin >> a[i];

	rep(i, N-1) {
		int u,v;cin>>u>>v;
		--u,--v;
		G[u].PB(v);
		G[v].PB(u);
	}

	fill(dp, dp + N, inf);
	dfs(0);

	rep(i, N) printf("%lld\n", ans[i]);
}



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

int main(void)
{
	int i, j;

	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	string s;
  	cin >> s;
  	
  	int ans = 0;
  	for(char c : s){
    	ans += (c-'0');
    }
  	ans %= 9;
  
  	if(ans == 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long K = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();
		if(A >= B || K <= A || B - A == 1) {
			System.out.println(K + 1);
			System.exit(0);
		}
		long t = K - (A - 1);
		long k = t / 2;
		long ans = k * B - (k - 1) * A + t % 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
s=input()

a=s[:2]
b=s[2:]

#print(a,b)

mo=["01","02","03","04","05","06","07","08","09","10","11","12"]

ans=""
if a in mo:
  if b in mo:
    ans="AMBIGUOUS"
  else:
    ans="MMYY"
else:
  if b in mo:
    ans="YYMM"
  else:
    ans="NA"
print(ans)
      


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    if(A==5 && B==5 && C==7)
        printf("YES\n");
    else if(A==5 && B==7 && C==5)
        printf("YES\n");
    else if(A==7 && B==5 && C==5)
        printf("YES\n");
    else
        printf("NO\n");
}


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

using namespace std;

const int Nmax = 1e5 + 5;
int n, i, x, y;
bitset<Nmax> erased, used;
vector<int> v[Nmax];

bool dfs(int node, int dad)
{
    used[node] = 1;
    for(auto it : v[node])
        if(!used[it] && !dfs(it, node)) return 0;

    if(!erased[node])
    {
        if(erased[dad] || !dad) return 0;
        erased[dad] = erased[node] = 1;
    }

    return 1;
}

int main()
{
   /// freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<n; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    cout << (dfs(1, 0) ? "Second" : "First") << '\n';

    return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define frd(x) freopen("x","r",stdin)
#define fwt(x) freopen("x","w",stdout)
#define fo(i,a) for(int i=1;i<=(a.n);i++)
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

template<int __>
struct ia
{
    int a[__],n;
    ia(int n=0):n(n) {}
    void rev(){reverse(a+1,a+n+1);}
    void hp(){make_heap(a+1,a+n+1);}
    int& operator[](int x){return a[x];}
    void sf(){fup(i,1,n)scanf("%d",a+i);}
    void mem(int x){memset(a,x,sizeof(a));}
    void sup(){sort(a+1,a+n+1,less<int>());}
    void sdn(){sort(a+1,a+n+1,greater<int>());}
    bool nexp(){return next_permutation(a+1,a+n+1);}
    int lb(int x){return lower_bound(a+1,a+n+1,x)-a;}
    int ub(int x){return upper_bound(a+1,a+n+1,x)-a;}
    void pf(){fup(i,1,n)printf("%d%c",a[i],i==n?'\n':' ');}
    ia operator+(const ia& b)
    {
        ia<__>c(max(n,b.n));c.mem(0);
        fo(i,c)c[i]=a[i]+b.a[i];
        return c;
    }
    ia operator-(const ia& b)
    {
        ia<__>c(max(n,b.n));c.mem(0);
        fo(i,c)c[i]=a[i]-b.a[i];
        return c;
    }
    ia operator*(const ia& b)
    {
        ia<__>c;c.mem(0);
        fo(i,(*this))fo(j,b)
            c.n=max(c.n,i+j-1),c[i+j-1]+=a[i]*b.a[j];
        return c;
    }
};

int main()
{
    ll l,r,ans=0;
    scanf("%lld%lld",&l,&r);
    for(;l<=r;l<<=1)
        ans++;
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
	int a[110], i=1, b[110];
	vector<int> ans;
	for(int i=0 ; i<110 ; i++){
		b[i] = 0;
	}

	while(cin >> a[i]){
		if(i==100)break;

		b[ a[i] ]++;
	}
	int num = 0;
	for(int i=1 ; i<=100 ; i++){
		if( num < b[i] ){
			ans.clear();
			num = b[i];
			ans.push_back(i);
		}
		else if( num == b[i] ){
			ans.push_back(i);
		}
	}

	sort( ans.begin() , ans.end() );
	for(int i=0 ; i<ans.size() ; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {

    var n = readLine.split(" ").map(_.toInt)
    while( n(0) != 0 || n(1) != 0) {
      val h = n(0)
      val w = n(1)

      for(i <- 0 to h-1) {
        val str = if(i%2==0) "#."*w else ".#"*w
        println(str.take(w))
      }
      println()
      n = readLine.split(" ").map(_.toInt)
    }
  }
}

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

int main(){
    int n, num = 0;
    int a, b, c;
    int l[10000];

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }

    sort(l,l+n);
    
    for(int i = 0; i < n-2; i++){
        a = l[i];
        for(int j = i + 1; j < n-1; j++){
            b = l[j];
            for(int k = j + 1; k < n; k++){
                c = l[k];
                if(c < a+b)
                    num++;
            }
        }
    }

    cout << num;
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri(), m = ri();
	int a[m], b[m];
	std::set<int> hen[n];
	for (int i = 0; i < m; i++) a[i] = ri() - 1, b[i] = ri() - 1, hen[a[i]].insert(b[i]), hen[b[i]].insert(a[i]);
	for (int i = 0; i < n; i++) {
		if (hen[0].count(i) && hen[n - 1].count(i)) {
			std::cout << "POSSIBLE" << std::endl;
			return 0;
		}
	}
	std::cout << "IMPOSSIBLE" << std::endl;
	
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if(s=="ABC")
        cout << "ARC";
    else
        cout << "ABC";
}


//freopen("testcases/17.in", "r", stdin);
//freopen("output.txt", "w", stdout);


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int a, b;
  string s;
  cin >> a >> b >> s;

  string ans = "Yes";

  int si = s.size();
  if (si != a + b + 1 || s[a] != '-') {
    ans = "No";
  }
  for (int i = 0; i < si; ++i) {
    if (i != a) {
      if ('0' > s[i] || s[i] > '9') {
        ans = "No";
      }
    }
  }

  cout << ans << '\n';

  return 0;
}


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

int main() {
	int tHP, tATK, aHP, aATK;
	cin >> tHP >> tATK >> aHP >> aATK;

	int turnT = (tHP + (aATK - 1))  / aATK;
	int turnA = (aHP + (tATK - 1))  / tATK;
	if (turnT >= turnA) {
		cout << "Yes";
	}
	else if (turnT < turnA) {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    rep(i,n){
        ll c;
        cin >> c;
        s[i] =  c;
    }
    vector<ll> t(n);
    copy(s.begin(),s.end(),t.begin());
    sort(t.begin(),t.end());
    ll q;
    cin >> q;
    ll match = 0;
    rep(i,n)if(s[i] == t[i])match++;
    rep(i,q){
        if(n == match){
            cout << i << endl;
            return 0;
        }
        ll x,y;
        cin >> x >> y;
        if(s[x-1] == t[x-1])--match;
        if(s[y-1] == t[y-1])--match;
        swap(s[x-1],s[y-1]);
        if(s[x-1] == t[x-1])++match;
        if(s[y-1] == t[y-1])++match;
        
    }
    if(s == t)cout << q << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 7592
import java.io.*;

class Main{
    public static void main(String[] args) {
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(x*x*x);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int bfs(const vector<string> &v, int x, int y) {
  int H = v.size(), W = v[0].size();
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int> > que;

  int res = 0;
  que.push({x, y});
  dist[x][y] = 0;
  while (!que.empty()) {
    int x = que.front().first, y = que.front().second;
    res = max(res, dist[x][y]);
    que.pop();
    for (int dir = 0; dir < 4; ++dir) {
      int nx = x + dx[dir], ny = y + dy[dir];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (v[nx][ny] == '#') continue;
      if (dist[nx][ny] == -1) {
        dist[nx][ny] = dist[x][y] + 1;
        que.push({nx, ny});
      }
    }
  }
  return res;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> v(H);
  for (int i = 0; i < H; ++i) cin >> v[i];
  
  int res = 0;
  for (int x = 0; x < H; ++x) {
    for (int y = 0; y < W; ++y) {
      if (v[x][y] == '#') continue;
      res = max(res, bfs(v, x, y));
    }
  }
  
  cout << res << endl;
}

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

const int N = 200005;

int n, m;
int a[N];

int solve() {
  int l, r, d;
  scanf("%d %d %d", &l, &r, &d);
  printf("%d\n", r/d - (l-1) / d);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3808
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>i>>j>>k;
    cout<<k<<" "<<i<<" "<<j;
    return 0;
}

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

using namespace std;

using int64 = long long;

void PrintVector(const vector<int64>& xs) {
  for (int i = 0; i < xs.size(); i++) {
    if (i > 0) cout << " ";
    cout << xs[i];
  }
  cout << endl;
}

vector<int64> Solve() {
  int64 m, k;
  cin >> m >> k;
  
  if (m == 1) {
    if (k == 0) {
      return {0, 0, 1, 1};
    } else {
      return {-1};
    }
  }
  
  if (k >= (1 << m)) return {-1};

  int size = (1 << m);
  vector<int64> xs;
  xs.push_back(k);
  for (int i = 0; i < size; i++) {
    if (i == k) continue;
    xs.push_back(i);
  }
  xs.push_back(k);
  for (int i = size - 1; i >= 0; i--) {
    if (i == k) continue;
    xs.push_back(i);
  }
  return xs;
}

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

  auto solution = Solve();
  PrintVector(solution);
}


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

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> h(n);
    for (int &i: h) scanf("%d", &i);
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i=2; i<n; i++) {
        // dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
        dp[i] = (int)1e9+5;
        for (int j=1; j<=k; j++) {
            if (i-j<0) break;
            dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j]);
        }
    }
    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
if S[0] == S[1] == S[2] or S[1] == S[2] == S[3]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 26692
N,M = map(int, input().split())
st = [list(map(int, input().split())) for _ in range(N)]
ch = [list(map(int, input().split())) for _ in range(M)]

INF = 10**9
d = lambda x, y: abs(x[0]-y[0]) + abs(x[1]-y[1])

for s in st:
    ans = 0
    dist = INF
    for i, c in enumerate(ch):
        dist_ = d(s, c)
        if dist_ < dist:
            dist = dist_
            ans = i
    print(ans+1)


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

using namespace std;

long long N;

int main(){
    cin >> N;
    long long ans = 0;
    for(long long i = 1; i<=sqrt(N); i++){
        if(N%i == 0){
            long long m = N/i-1;
            if(m && N/m == N%m){
                ans += m;
            }
            if(N/i != i){
                m = i-1;
                if(m && N/m == N%m){
                    ans += m;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,q,f[10000000],o;
int main(){
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		cin>>o;
		f[o]++;
	}
	for(int i=1;i<=n;i++){
		if(f[i]+k-q>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1024
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

#標準入力
n = int(input())
#inputはstr(string)で入力されるのでstrの場合は指定不要
S=input()
#inputが改行されている場合は別途入力でよい



print(S.count("ABC"))

Measured memory_bytes: 9072
// AtCoder :: Beginner Contest 174 :: Range Set Query
// https://atcoder.jp/contests/abc174/tasks/abc174_f

#include <bits/stdc++.h>

using namespace std;

const int MAXN{500000};

// Ref: https://codeforces.com/blog/entry/61203
inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
	if (pow == 0) {
		return 0;
	}
	int hpow = 1 << (pow-1);
	int seg = (x < hpow) ? (
		(y < hpow) ? 0 : 3
	) : (
		(y < hpow) ? 1 : 2
	);
	seg = (seg + rotate) & 3;
	const int rotateDelta[4] = {3, 0, 0, 1};
	int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
	int nrot = (rotate + rotateDelta[seg]) & 3;
	int64_t subSquareSize = int64_t(1) << (2*pow - 2);
	int64_t ans = seg * subSquareSize;
	int64_t add = hilbertOrder(nx, ny, pow-1, nrot);
	ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
	return ans;
}

struct Query {
    int left, right, index;
    int64_t ord;

    inline void calcOrder() {
        ord = hilbertOrder(left, right, 21, 0);
    }
};

inline bool operator<(const Query &lhs, const Query &rhs) {
    return lhs.ord < rhs.ord;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    vector<int> arr;
    arr.reserve(N);
    copy_n(istream_iterator<int>(cin), N, back_inserter(arr));
    vector<Query> queries(Q);
    for (int q{0}; q < Q; ++q) {
        cin >> queries[q].left >> queries[q].right;
        // Convert query to zero base
        queries[q].left--;
        queries[q].right--;
        queries[q].index = q;
        queries[q].calcOrder();
    }
    sort(queries.begin(), queries.end());
    vector<int> frequency(N+1);
    vector<int> solns(queries.size());

    int currLeft{0};
    int currRight{-1};
    int distinctElems{0};
    for (auto query : queries) {
        while (currLeft < query.left) {
            // Remove element
            auto value = arr[currLeft];
            frequency[value]--;
            if (frequency[value] == 0) {
                distinctElems--;
            }
            currLeft++;
        }
        while (currLeft > query.left) {
            // Add element
            currLeft--;
            auto value = arr[currLeft];
            frequency[value]++;
            if (frequency[value] == 1) {
                distinctElems++;
            }
        }
        while (currRight < query.right) {
            // Add element
            currRight++;
            auto value = arr[currRight];
            frequency[value]++;
            if (frequency[value] == 1) {
                distinctElems++;
            }
        }
        while (currRight > query.right) {
            // Remove element
            auto value = arr[currRight];
            frequency[value]--;
            if (frequency[value] == 0) {
                distinctElems--;
            }
            currRight--;
        }
        solns[query.index] = distinctElems;
    }

    // Print results.
    copy(solns.begin(), solns.end(), ostream_iterator<int>(cout, "\n"));
    return EXIT_SUCCESS;
}


Measured memory_bytes: 21356
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
events = []
for _ in range(n):
    s, t, x = map(int, input().split())
    events.append((s-x-0.5, 's', x)) # start construction
    events.append((t-x-0.5, 'e', x)) # end construction

for i in range(q):
    d = int(input())
    events.append((d, 'q', i)) # query
    
events = sorted(events)
is_stop = False
stops = set()
min_stop = float('inf')
ans = [-1]*q
for t, e, x in events: # time, event, distance/index
    if e == 's':
        stops.add(x)
        if x < min_stop:
            min_stop = x
            is_stop = True
    elif e == 'e':
        stops.remove(x)
        if min_stop == x:
            is_stop = False
    elif len(stops) > 0:
        if not is_stop:
             min_stop = min(stops)
             is_stop = True
        ans[x] = min_stop
         
print('\n'.join(map(str,ans)))

Measured memory_bytes: 106920
N, K = list(map(int, input().split()))
A = []
for i in range(K):
  d = input()
  A.append(list(map(int, input().split())))

L = [0] * N

for i in A:
  for j in i:
    L[j - 1] = 1

ans = 0
for i in L:
  if i == 0:
    ans += 1

print(ans)

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

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

    if (x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
        return 0;
    }

    const int MAX_N = 200000;    
    static int result[2 * MAX_N - 1] = {};
    static bool used[2 * MAX_N - 1] = {};

    vector<int> elt;
    for (int i = 1; i <= 2 * N - 1; i++) elt.push_back(i);

    result[N - 1] = x;
    result[N - 2] = x - 1;
    result[N]     = x + 1;

    elt.erase(remove(elt.begin(), elt.end(), x), elt.end());
    elt.erase(remove(elt.begin(), elt.end(), x - 1), elt.end());
    elt.erase(remove(elt.begin(), elt.end(), x + 1), elt.end());

    if (x - 2 >= 1) { result[N + 1] = x - 2; elt.erase(remove(elt.begin(), elt.end(), x - 2), elt.end()); }
    if (x + 2 <= 2 * N - 1) { result[N - 3] = x + 2; elt.erase(remove(elt.begin(), elt.end(), x + 2), elt.end()); }

    int idx = 0;
    for (int e : elt) {
        while (result[idx] != 0) idx++;
        result[idx] = e;
    }

    cout << "Yes" << endl;
    for (int i = 0; i < 2 * N - 1; i++) {
        cout << result[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long int ll;
#define mod 1000000007
#define ln "\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
    fio;
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=ceil(a/d);
    ll y=ceil(c/b);
    //cout<<x<<" "<<y;
    if(x<y)
    cout<<"No";
    else
    cout<<"Yes";
    return 0;
}


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

int main()
{
    long long i, j, k, n, t, x, y, s=0, c=0, l;
    cin >> x >> y;
    if(x==0)
    {
        if(y<100)
            cout << y;
        else
            cout << "101";
        }
    else
    {
        if(y==100)
        {
            y=101;
            for(i=1; i<=x; i++)
                y=y*100;
            cout << y;
        }
        else
        {
            for(i=1; i<=x; i++)
                y=y*100;
            cout << y;
        }
    }
}


Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-08-04 20:37:41
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 500+10;
int a[maxn],n,k,b[maxn];
bool judge(int x){
    for(int i = 0;i < n;i++) b[i] = a[i]%x;
    sort(b,b+n);
    int cnt = 0;
    int l = 0,r = n-1;
    while(l < r){
        int mi = min(b[l],x-b[r]);
        cnt += mi;
        b[l] -= mi;
        (b[r] += mi)%=x;
        if(b[l] == 0) l++;
        if(b[r] == 0) r--;
    }
    return cnt <= k;
}
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> k;
    int sum = 0;
    for(int i = 0;i < n;i++) cin >> a[i],sum += a[i];
    sort(a,a+n);
    int sq = sqrt(sum);
    int ma = 1;
    for(int i = 1;i <= sq;i++){
        if(sum%i == 0){
            if(judge(i) && i > ma) ma = i;
            if(judge(sum/i) && sum/i > ma) ma = sum/i;
        }
    }
    cout << ma << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,K;
    cin >> N >> K;
    vi P(N);
    in(N,P);
    int ans = 1;
    set<int> B;
    rep(i,K) B.insert(P[i]);
    int s = 0;
    reps(t,K,N){
        int a = *begin(B);
        int b = *rbegin(B);
        
        if(P[s] == a && b < P[t]){
            B.erase(a);
            B.insert(P[t]);
        }else{
            B.erase(P[s]);
            B.insert(P[t]);
            ans++;
        }
        s++;
        
    }
    
    vi an;
    P.pb(-1);
    int tt = 1;
    reps(i,1,N+1){
        if(P[i-1] < P[i]){
            tt++;
        }else{
            an.pb(tt);
            tt = 1;
        }
    }
    //outve(an);
    tt = 0;
    rep(i,an.size()){
        if(an[i] >= K) tt++;
    }
    //cout << ans << endl;
    ans -= (tt > 0 ? tt-1 : 0);
    //cout << tt << endl;
    cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    int x=0;
    while(a[i]%2==0){
      a[i]/=2;
      x++;
    }
    ans[i]+=x;
  }
  sort(ans.begin(),ans.end());
  cout<<ans[0]<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    vi b(n);
    REP(i,n){
        cin>>b[i];
    }
    int p=0;
    REP(i,n){
        p+=b[i];
        p-=a[i];
    }
    int x=0,y=0;
    REP(i,n){
        if(a[i]%2!=b[i]%2){
            y++;
            b[i]++;
        }
        if(a[i]<=b[i]){
            x+=(b[i]-a[i])/2;
        }else{
            y+=a[i]-b[i];
        }
    }
    if(p>=max(x,y)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
// use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;

const M: i64 = 1000_000_007i64;
fn main() {
    input! {
        x:i64,y:i64
    }
    if (x + y) % 3 != 0 {
        println!("0");
        return;
    }
    let mut ans = 1;
    // 移動回数 = (x+y)/3
    // 一回の移動につき (1,1)の後xまたはy方向に1ずつ進む。
    // したがって、移動Aを x-(x+y)/3 回、 移動Bを y-(x+y)/3回選ぶ、単なるパス選択の並び変えアルゴリズム。
    let x2 = x - (x + y) / 3;
    let y2 = y - (x + y) / 3;
    if x2 < 0 || y2 < 0 {
        println!("0");
        return;
    }
    // ans = (x2+y2)! / (x2! * y2!)
    for i in 1..(x2 + y2) + 1 {
        ans = ans * i % M;
    }
    for i in 1..x2 + 1 {
        ans = ans * modInv(i) % M;
    }
    for i in 1..y2 + 1 {
        ans = ans * modInv(i) % M;
    }
    println!("{}", ans);
}
fn modPow(x: i64, a: i64) -> i64 {
    if a == 1 {
        x
    } else {
        if a % 2 != 0 {
            (modPow(x, a - 1) * x) % M
        } else {
            let t = modPow(x, a / 2);
            t * t % M
        }
    }
}
fn modInv(x: i64) -> i64 {
    modPow(x, M - 2)
}


Measured memory_bytes: 2152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}
//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

using ll = long long;
using namespace std;

int main() {
	string s;
	cin >> s;
	int m = 15;
	int p = 0;
	for (int i = 0; i < 14; i++) {
		if (s[i] == 'o') {
			p++;
			m--;
		}
		else if(s[i] == 'x') {
			m--;
		}
	}
	if (m+p >= 8) cout << "YES";
	else cout << "NO";

}

Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3644
//
//  abc167_Easy_Linear_Programming.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

std::map<int, int> factorization (int n) {
  std::map<int, int> f;
  for (int i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      f[i] += 1;
      n /= i;
    }
  }
  if (n > 1) {
    f[n] += 1;
  }
  return f;
}

ll modpow (int x, int n) {
  if (n==0) return 1%mod;
  ll u = modpow(x, n/2);
  u = (u*u)%mod;
  if (n%2==1) u = (u*x)%mod;
  return u;
}

int main() {
  ll a, b, c, k;
  std::cin >> a >> b >> c >> k;

  ll sum = 0;

  if (a >= k) {
    sum += k;
  }
  else {
    sum += a;
    k -= a + b;
    if (k > 0) {
      if (k < c) {
        sum -= k;
      }
      else {
        sum -= c;
      }
    }
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3588
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！

  vector<int> a(3),b(3);
  REP(i,3) cin >> a[i] >> b[i];
  
  int cnt[4] = {};
  REP(i,3){
    cnt[a[i]-1]++;
    cnt[b[i]-1]++;
  }

  int check1 = 0, check2 = 0;
  REP(i,4){
    if(cnt[i] == 1) check1++;
    if(cnt[i] == 2) check2++;
  }

  if(check1 == 2 && check2 == 2) cout << "YES" << endl;
  else cout << "NO" <<endl;
  return 0;
}

Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[n,m,X,Y]=i2()
x=i2()
y=i2()

xt=max(max(x),X)
yt=min(min(y),Y)
if xt<yt:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int inf = 1e18;
const int M = 1e9 + 7;
int A[N][26];
int n;

void solve()
{
      int n;
      cin >>n;

      string s;
      cin >> s;

      mset(A,0);

      loop(i,0,n)
      {
            A[i][s[i]-'A']++;
      }


      for(int i = n-1; i >= 0; i--)
      {
            loop(j,0,26)
            {
                  A[i][j] += A[i+1][j];
            }
      }
            
      // loop(i,0,n)
      // {
      //       cout << A[i]['R'-'A'] << " " << A[i]['B'-'A'] << " " << A[i]['G'-'A'] << endl;
      // }

      int ans = 0;

      loop(i,0,n)
      {
            loop(j,i+1,n)
            {
                  if(s[i] != s[j])
                  {

                        char ch;
                        int a = 0;
                        if(s[i] == 'R' && s[j] =='B')a += A[j+1]['G'-'A'], ch = 'G';
                        if(s[i] == 'R' && s[j] =='G')a += A[j+1]['B'-'A'], ch = 'B';
                        if(s[i] == 'B' && s[j] =='G')a += A[j+1]['R'-'A'], ch = 'R';
                        if(s[i] == 'B' && s[j] =='R')a += A[j+1]['G'-'A'] ,ch = 'G';
                        if(s[i] == 'G' && s[j] =='R')a += A[j+1]['B'-'A'] ,ch = 'B';
                        if(s[i] == 'G' && s[j] =='B')a += A[j+1]['R'-'A'] , ch = 'R';
                        int diff = j-i;
                        if(j+diff < n && ch == s[j+diff])a--;
                        ans += a;
                        // cout << i << " " <<  j << " " << ans << " " << A[j+1][ch-'A'] << endl; 
                  } 
            }

      }

      cout << ans;
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

       int t = 1;
       // cin >> t;
       while(t--)solve();
  
}


Measured memory_bytes: 409908
def acinput():
    return list(map(int, input().split(" ")))

import numpy as np

N=int(input())
bars=acinput()

bar_cs=np.cumsum(bars)

res=10**15

for i in range(N-1):
    R=bar_cs[-1]-bar_cs[i]
    L=bar_cs[i]
    res=min(res,np.abs(R-L))
    #print(i,L,R)

print(res)

Measured memory_bytes: 34196
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> in(n), out(n);
  vector<int> cnt(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cnt[a]++, cnt[b]++;
  }

  for (int i = 0; i < n; i++) {
    if (cnt[i] % 2) return cout << "NO" << endl, 0;
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
long long knapsack(long long **arr,long long i,long long W,long long n,long long **dp){
	if(i==n || W==0)return 0;
	if(dp[i][W]!=-1)return dp[i][W];
	if(arr[i][0] <= W){
		return dp[i][W] = max(arr[i][1] + knapsack(arr,i+1,W-arr[i][0],n,dp),knapsack(arr,i+1,W,n,dp));
	}
	else
		return dp[i][W] = knapsack(arr,i+1,W,n,dp);
}
int main() {
	// your code goes here
	long long n,W;
	cin>>n>>W;
	
	long long **arr = new long long*[n];
	long long **dp = new long long*[n];
	for(long long i =0 ;i<n;i++){
		dp[i] = new long long[W+1];
		for(long long j = 0;j<W+1;j++)
			dp[i][j] = -1;
	}
	for(long long i =0 ;i<n;i++){
		arr[i] = new long long[2];
		for(long long j = 0;j<2;j++)
			cin>>arr[i][j];
	}
	cout<<knapsack(arr,0,W,n,dp)<<endl;
	return 0;
}

Measured memory_bytes: 81984
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int N = fs.nextInt();

            HashSet<Integer> hs = new HashSet<Integer>();

            for (int i = 0 ; i < N; i++) {
                int d = fs.nextInt();
                hs.add(d);
            }

            System.out.println(hs.size());
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int n=read();
	int m=sqrt(n+1);
	int ans=1e18;
	for(int i=1;i<=m;i++)
		if(n%i==0)
		{
			ans=min(ans,i+(n/i)-2);
		}
	cout<<ans;
}

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

int main(){
  string S;
  cin >> S;
  
  int N = S.size();
  int ans = 1;
  for(int i=1; i<N; i++){
    if(S[i-1]!=S[i]){
      ans++;
    }else{
      if(i+1<N){
        ans++;
        i++;
        S[i] = '1';
      }else{
        cout << ans;
        return 0;
      }
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int a[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  int b;
  cin>>b;
  int B[b];
  for(int i=0;i<b;i++){
    cin>>B[i];
  }
  int count=0;
  while(count<b){
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(B[count]==a[i][j]){
        a[i][j]=-1;
      }
    }
  }
    count++;
  }
  if(a[0][0]==-1&&a[0][1]==-1&&a[0][2]==-1){
    cout<<"Yes"<<endl;
  }
  else if(a[1][0]==-1&&a[1][1]==-1&&a[1][2]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[2][0]==-1&&a[2][1]==-1&&a[2][2]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[0][0]==-1&&a[1][0]==-1&&a[2][0]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[0][1]==-1&&a[1][1]==-1&&a[2][1]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[0][2]==-1&&a[1][2]==-1&&a[2][2]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1){
    cout<<"Yes"<<endl;
  }
   else if(a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 return 0; 
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      int c=0;
      for (String s : line)
        seqS[c++] = Integer.parseInt(s);

      int q = Integer.parseInt(br.readLine());
      line = br.readLine().split(" ");
      
      int cnt=0;
      for (String ref : line) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] > ref ) right = mid;
      else if(tar[mid] < ref ) left = mid + 1;
      else return true;
    }

    return false;
  }
}


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


int main(){
    string str;
    while(cin>>str){
        for(int i=(int)str.size()-1;i>0;i--){
            for(int j=0;j<=i;j++){
                str[j]=(str[j]+str[j+1]-2*'0')%10+'0';
            }
        }
        cout<<str[0]<<endl;
    }

    return 0;
}

Measured memory_bytes: 1172
//Waqt Ha Badal Jayega//

#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ld long double
using namespace std;

ll minSwaps(ll arr[], ll n)
{
	pair<ll, ll> arrPos[n];
	for (ll i = 0; i < n; i++)
	{
		arrPos[i].first = arr[i];
		arrPos[i].second = i;
	}
	sort(arrPos, arrPos + n);
	vector<bool> vis(n, false);
	ll ans = 0;
	for (ll i = 0; i < n; i++)
	{

		if (vis[i] || arrPos[i].second == i)
			continue;

		ll cycle_size = 0;
		ll j = i;
		while (!vis[j])
		{
			vis[j] = 1;
			j = arrPos[j].second;
			cycle_size++;
		}
		if (cycle_size > 0)
		{
			ans += (cycle_size - 1);
		}
	}
	return ans;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*
	ll t;
	cin >> t;
	while (t--)
	{
		ll n, m;
		cin >> n >> m;
		ll a[n];
		for (ll i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		ll x, y;
		ll count = 0;
		vector<pair<ll, ll> >f;
		while (m--)
		{
			cin >> x >> y;
			f.push_back(make_pair(x, y));
		}
		cout << f.size() << "\n";

	}*/
	ll n, k;
	cin >> n >> k;
	ll count = 0;
	ll a[n];
	for (ll i = 1; i <= n; i++)
	{
		a[i] = 0;
	}
	ll x, y;
	while (k--)
	{
		cin >> x;
		while (x--)
		{
			cin >> y;
			a[y] = 1;
		}
	}
	for (ll i = 1; i <= n; i++)
	{
		if (a[i] == 0)
		{
			count++;
		}
	}
	cout << count << "\n";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int a[maxn], b[maxn];
int main(){
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i], b[i] = a[i];
	sort(b + 1, b + 1 + N);
	int max1 = b[N], max2 = b[N - 1];
	for (int i = 1; i <= N; i++){
		if (a[i] == max1) cout << max2 << endl;
		else cout << max1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3200