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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 1000000007;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }

  vector<ll> count(3);
  ll ans = 1;
  for (ll c : A) {
    int mul = 0, index = 0;
    rep(i, 0, 3) {
      if (count[i] != c) continue;
      mul++;
      index = i;
    }
    count[index]++;
    ans = mod(ans * mul, MOD);
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc178
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc178B();
            Console.Out.Flush();
        }

        public static void solve_abc178B()
        {
            long[] abcd = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long a = abcd[0];
            long b = abcd[1];
            long c = abcd[2];
            long d = abcd[3];
            long max1 = Math.Max(a, b);
            long min1 = Math.Min(a, b);
            long max2 = Math.Max(c, d);
            long min2 = Math.Min(c, d);
            Console.WriteLine(Math.Max(Math.Max(max1 * min2, min1 * max2), Math.Max(max1 * max2, min1 * min2)));
        }

        public static void solve_abc178A()
        {
            int x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(x == 0 ? 1 : 0);
        }
    }
}

Measured memory_bytes: 28460
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i <= x + k - 1; i++)
        cout << i << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,ans;
ll say[15];
ll ch[15][15];
void cal(){
	bool ch2=true;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			ll now=ch[i][j];
			if(now==-1){
				continue;
			}
			if(say[i]==1){
				if(now!=say[j]){
					ch2=false;
				}
			}
		//	else{
		//		if(now==say[j]){
		//			ch2=false;
		//		}
		//	}
		}
	}
	ll sum=0;
	if(ch2){
		for(ll i=0;i<n;i++){
			//cout << "K";
			if(say[i]==1){
				sum++;
			}
		}
		ans=max(ans,sum);
	}
}
void dep(ll now){
	if(now==n){
		//cout << "k";
		cal();
		return ;
	}
	say[now]=0;dep(now+1);
	say[now]=1;dep(now+1);
	return ;
}
int main() {
	cin>>n;
	for(ll i=0;i<15;i++){
		for(ll j=0;j<15;j++){
			ch[i][j]=-1;
		}
	}
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll x,y;
			cin>>x>>y;
			x--;
			ch[i][x]=y;
		}
	}
	dep(0);
	cout << ans;
	// your code goes here
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L (87);
  
  L.at(0) = 2LL;
  L.at(1) = 1LL;

  
  for ( int i=2; i<=N; i++) {
   
   (L.at(i) = L.at(i-2) + L.at(i-1));
  }
       cout << L.at(N) << endl;
}


Measured memory_bytes: 256
n=int(input())
a,b,c=map(int,input().split())
dp=[[0]*3 for i in range(n)]
dp[0][0],dp[0][1],dp[0][2]=a,b,c

for i in range(1,n):
  a,b,c=map(int,input().split())
  for j in range(3):
    if j==0:
      dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a
    elif j==1:
      dp[i][j]=max(dp[i-1][0],dp[i-1][2])+b
    else:
      dp[i][j]=max(dp[i-1][0],dp[i-1][1])+c
      
print(max(dp[-1]))

Measured memory_bytes: 82756
(X,K,D) = map(int,input().split())
x = abs(X)
a = int(x/D)
if a > K:
  print(x-(D*K))
else:
  if (K-a)%2 == 0:
    b = x%D
    print(b)
  else:
    print(abs(x%D-D))

Measured memory_bytes: 9012
import java.util.Scanner;

public final class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			final String s = scanner.next();
			if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}


Measured memory_bytes: 23764
n = int(input())
fs = []
ps = []
for _ in range(n):
    fs.append(list(map(int, input().split())))
for _ in range(n):
    ps.append(list(map(int, input().split())))

from itertools import product
ans = -float('inf')
for jo in product(range(2), repeat=10):
    if sum(jo) == 0:
        continue
    prof = 0
    for p, f in zip(ps, fs):
        sim = sum(i * j for i, j in zip(jo, f))
        prof += p[sim]
    if prof > ans:
        ans = prof

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.CodeFes2017QA
{
    class SnukesFavoriteYakiniku
    {
        public static void Main()
        {
            const string yes = "Yes";
            const string no = "No";
            const string yaki = "YAKI";
            var input = ReadLine().Trim();
            if (input.Length >= 4 && input.Substring(0, 4) == yaki) WriteLine(yes);
            else WriteLine(no);
        }
    }
}


Measured memory_bytes: 13140
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d))
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	string a[3];
	cin >> a[0] >> a[1] >> a[2];
	char c;
	int x[3]={1},f=1;
	c='a';
	while(f){
		int d=c-'a';
		x[d]++;
		if(x[d]>a[d].size()){
			cout << char(c-'a'+'A') << endl;
			break;
		}
		c=a[d][x[d]-1];
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

typedef struct tagNode {
    int id;
    int outdegree;
    int *edgesTo;
    int *edgesCost;
    int done;
    int cost;
} Node;

typedef struct tagNodes {
    Node **nodes;
    int size;
} Nodes;


typedef struct tagPriorityQueue {
    Node node[1024];
    int size;
} PriorityQueue;

int findNodeWithTheLeastDistance(Nodes *quese)
{
    int i;
    int min = 0;

    for (i=1; i<quese->size; ++i) {
        int t = quese->nodes[min]->cost;
        int u = quese->nodes[i]->cost;
        if (quese->nodes[min]->cost > quese->nodes[i]->cost) {
            min = i;
        }
    }
    return min;
}

void removefromNodes(int u, Nodes *quese)
{
    int i;
    for (i=u; i<quese->size-1; ++i) {
        quese->nodes[i] = quese->nodes[i+1];
    }
    --quese->size;
}

void dijkstrasAlgorithm(Node **nodes, int sizeOfNodes)
{
    Nodes quese;
    quese.nodes = malloc(sizeOfNodes * sizeof(Node *));
    quese.size = sizeOfNodes;
    int i;
    int u;
    int v;
    
    for (i=0; i<quese.size; ++i) {
        quese.nodes[i] = nodes[i];
    }

    while (quese.size != 0) {
        int n = findNodeWithTheLeastDistance(&quese);
        u = quese.nodes[n]->id;
        removefromNodes(n, &quese);

        for (i=0; i<nodes[u]->outdegree; ++i) {
            v = nodes[u]->edgesTo[i];
            int alt = nodes[u]->cost + nodes[u]->edgesCost[i];
            if (alt < nodes[v]->cost) {
                nodes[v]->cost = alt;
            }
        }
    }
}

int main(int argc, int *argv[])
{
    Node **nodes;
    int sizeOfNodes;
    int i;
    int j;
    
    scanf("%d", &sizeOfNodes);
    nodes = malloc(sizeOfNodes * sizeof(Node *));
    for (i=0; i<sizeOfNodes; ++i) {
        int id;
        int outdegree;

        scanf("%d %d", &id, &outdegree);
        nodes[id] = malloc(sizeof(Node));
        nodes[id]->id = id;
        nodes[id]->outdegree = outdegree;
        nodes[id]->edgesTo = malloc(outdegree * sizeof(int));
        nodes[id]->edgesCost = malloc(outdegree * sizeof(int));
        for (j=0; j<outdegree; ++j) {
            scanf("%d %d", &nodes[id]->edgesTo[j], &nodes[id]->edgesCost[j]);
        }
        nodes[id]->done = 0;
        nodes[id]->cost = INT_MAX;
    }
/*
    printf("\n");
    for (i=0; i<sizeOfNodes; ++i) {
        printf("%d %d ", nodes[i]->id, nodes[i]->outdegree);
        for (j=0; j<nodes[i]->outdegree; ++j) {
            printf("%d %d ", nodes[i]->edgesTo[j], nodes[i]->edgesCost[j]);
        }
        printf("\n");
    }
    */
    nodes[0]->cost = 0; /* ????????????????????????????????????0 */

    dijkstrasAlgorithm(nodes, sizeOfNodes);

    //printf("\n");
    for (i=0; i<sizeOfNodes; ++i) {
        printf("%d %d\n", nodes[i]->id, nodes[i]->cost);
    }

    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

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

    int ans = 0;
    while (true)
    {
        bool flag = false;
        for (int i = 0; i < n; i++)
        {
            if (vec[i] % 2 != 0)
            {
                flag = true;
                break;
            }
            
            vec[i] /= 2;
        }

        if (flag)
        {
            break;
        }
        
        ans++;
    }
    
    cout << ans << endl; 
}

Measured memory_bytes: 256
n = int(input())
s = [int(x) for x in input()]

dp_1 = [False] * 10
dp_2 = [False] * 100
dp_3 = [False] * 1000

for x in s:
    for i in range(100):
        if dp_2[i]:
            dp_3[i * 10 + x] = True
    for i in range(10):
        if dp_1[i]:
            dp_2[i * 10 + x] = True
    dp_1[x] = True

print(sum(dp_3))

Measured memory_bytes: 9592
n, m = map(int, input().split())
reachable_islands_from_1 = []    # (using just one boat service)
reachable_islands_from_n = []    # same

for _ in range(m):
  a, b = map(int, input().split())
  if a == 1:
    reachable_islands_from_1.append(b)
  elif b == n:
    reachable_islands_from_n.append(a)

if len(list(set(reachable_islands_from_1) & set(reachable_islands_from_n))) == 0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")


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

a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]

road = []
for i in range(h):
    for j in list(range(w))[::(i % 2) * -2 + 1]:
        road.append((i + 1, j + 1))

answer = []
for f, t in zip(road[:-1], road[1:]):
    if a[f[0] - 1][f[1] - 1] % 2:
        answer.append(f + t)
        a[t[0] - 1][t[1] - 1] += 1

print(len(answer))
for ans in answer:
    print(*ans)




Measured memory_bytes: 86940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using arr = array<ll, 3>;

void solve(){
    ll N;
    cin >> N;
    vc<arr> A(N);
    vvc<arr> S1(N + 1), S2(N + 1);
    rep(i, N){
        cin >> A[i][0] >> A[i][1] >> A[i][2];
        if (A[i][1] >= A[i][2])
            S1[A[i][0]].eb(A[i]);
        else
            S2[N - A[i][0]].eb(A[i]);
    }

    auto comp1 = [&](arr a, arr b) { return (a[1] - a[2]) > (b[1] - b[2]); };
    auto comp2 = [&](arr a, arr b) { return (a[1] - a[2]) < (b[1] - b[2]); };
    priority_queue<arr, vc<arr>, decltype(comp1)> pq1{comp1};
    priority_queue<arr, vc<arr>, decltype(comp2)> pq2{comp2};

    ll ans = 0, cnt = 0;
    rep(i, N + 1){
        repa(a, S1[i]) pq1.emplace(a), cnt++;
        while(i < cnt){
            auto [k, l, r] = pq1.top();
            pq1.pop();
            cnt--;
            ans += r;
        }
    }
    while(!pq1.empty()){
        auto [k, l, r] = pq1.top();
        pq1.pop();
        ans += l;
    }
    cnt = 0;
    rep(i, N + 1){
        repa(a, S2[i]) pq2.emplace(a), cnt++;
        while(i < cnt){
            auto [k, l, r] = pq2.top();
            pq2.pop();
            cnt--;
            ans += l;
        }
    }
    while(!pq2.empty()){
        auto [k, l, r] = pq2.top();
        pq2.pop();
        ans += r;
    }
    cout << ans << endl;
}

int main() {
    init();
    ll T;
    cin>>T;
    rep(_, T) solve();
}

Measured memory_bytes: 30744
#include <iostream>
using namespace std;
int main(){
    int n, x;
    char m;
    cin >> n;
    int card[4][13] = {};
    for(int i = 1; i <= n; i++){
        cin >> m >> x;
        if(m == 'S'){
            card[0][x - 1] = 1;
        } else if(m == 'H') {
            card[1][x - 1] = 1;
        } else if(m == 'C'){
            card[2][x - 1] = 1;
        } else if(m == 'D'){
            card[3][x - 1] = 1;
        }
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(card[i][j] == 0){
                if(i == 0){
                    cout << "S " << j + 1 << endl;
                } else if(i == 1){
                    cout << "H " << j + 1 << endl;
                } else if(i == 2){
                    cout << "C " << j + 1 << endl;
                } else {
                    cout << "D " << j + 1 << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
# coding=utf-8

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

n = int(input())
A = list(map(int, input().split()))
m = partition(A, 0, n-1)
A = list(map(str, A))
A[m] = "[%s]"%(A[m])
print(*A)

Measured memory_bytes: 18376
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        System.out.print(Character.toString(s1.charAt(0)).toUpperCase());
        System.out.print(Character.toString(s2.charAt(0)).toUpperCase());
        System.out.print(Character.toString(s3.charAt(0)).toUpperCase());
        scan.close();
    }
};

Measured memory_bytes: 26992
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

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

int main() {
    int a, ans = 0;
    cin >> a;
    for(int i = 1; i <= a; i++){
        for(int j = 1; j <= a; j++){
            for(int k = 1; k <= a; k++){
                ans += gcd(gcd(i,j), k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, a) for(int i=0;i<(int)a;++i)
#define INF 1145141919;
typedef long long ll;
typedef long double ld;
using namespace std;

int n, tmp;
vector<int> a;

void solver() {
    cin >> n;
    REP(i, n) {
        cin >> tmp;
        a.push_back(tmp);
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < n - 1; ++i)
        cout << a[i] << " ";
    cout << a[n - 1] << endl;
}

int main() {
    solver();
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){

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

  	int count = 0;
  	bool s[2*n+1];
  	int era;

  	for(int i=2 ; i<2*n+1 ; i++){
  		s[i] = true;
  	}

  	for(int i=2 ; i*i<(2*n+1) ;i++){
  		if(s[i] != false){
  			era = i;
  			for(int j=2 ; (j*era)<(2*n+1) ; j++){
  				s[j*era] = false;
  			}
  		}
  	}

  	for(int i=n+1 ; i<2*n+1 ; i++){
  		if(s[i] == true) count++;
  	}
  	cout << count << endl;
  }
 

	return 0;
}

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

// Problem https://atcoder.jp/contests/agc011/tasks/agc011_a

int main(void){
    int personNum,capa,maxwait,answer;
    answer = 0;
    cin >> personNum >> capa >> maxwait;
    vector<int> artime(personNum);
    for(int j=0;j<personNum;j++){
        cin >> artime.at(j); 
    }
    sort(artime.begin(),artime.end());
/**     for(int j=0;j<personNum;j++){
        cout << artime.at(j) << " ";
    }
    cout << endl;
    **/
    int stopbusTime;
    stopbusTime = artime.at(0);
    int getOnNum = 1;
    for(int j=1;j<personNum;j++){
        if(maxwait < (artime.at(j) - stopbusTime) or (capa <= getOnNum)){
            // jさんが着いたとき、もうすでに前のバスが出て行ったときの条件
            // cout << "Mr." << j << " may get on "<< stopbusTime <<" , but bus leave." << endl;
            // バスはその前に発車して→一人目になる状況
            // (1) 時間面:最初の人の出発待ちが耐えられなくなっていそう
            // (2) 容量面:乗った段階で最大量を超えていた
            answer = answer + 1; // 出発した
            getOnNum = 1; // 一人目
            stopbusTime = artime.at(j); // 到着時間更新
        }
        else{
            // それ以外→単に一人追加
            getOnNum = getOnNum + 1;
        }
    }
    if(0 < getOnNum){
        // 全員乗った段階で1人以上
        answer = answer + 1;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int w[101];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    FOR(i, 1, n+1)
        cin >> w[i];
    int first;
    int second;
    first = second = 0;
    int minS = 100 * 100 + 1;
    FOR(i,2,n+1)
    {
        first = 0;
        second = 0;
        FOR(j,1,i)
            first += w[j];
        FOR(x,i,n+1)
            second += w[x];
        // cout << first << " " << second << endl;
        minS = min(minS, abs(first - second));
    }
    cout << minS;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

if n==1 and m==1:
    print(1)
elif n==1 :
    print(m-2)
elif m==1 :
    print(n-2)
elif n==1 or m==2:
    print(0)
else:
    print((n-2)*(m-2))
    

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 200005;
typedef long long ll;
vector<pair<ll,ll> >s[MAXN],a,b;
struct Edge{
	int to,next,w;
}e[MAXN<<1];
int n,head[MAXN],cnt;
inline void insert(int u,int v,int w)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt,e[cnt].w=w;
	e[++cnt].to=u,e[cnt].next=head[v],head[v]=cnt,e[cnt].w=w;
}
inline void add(vector<pair<ll,ll> >&x,pair<ll,ll>a)
{
	if(x.size() && a.second>=x.back().second)return;
	while(x.size() && x.back().first==a.first && x.back().second>=a.second)x.pop_back();
	x.push_back(a);
}
int dfs(int x,int fa,ll mid)
{
	int v1=0,v2=0,w1=0,w2=0;
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		if(!v1)v1=v,w1=e[i].w;
		else v2=v,w2=e[i].w;
		if(!dfs(v,x,mid))return 0;
	}
	s[x].clear();
	if(v1){
		if(!s[v1].size() || !s[v2].size())return 0;
		a.clear(),b.clear();
		int p=0;
		for(int i=0;i<s[v1].size();++i){
			while(p<s[v2].size() && s[v1][i].first+s[v2][p].second+w1+w2>mid)++p;
			if(p>=s[v2].size())break;
			else{
				a.push_back(make_pair(s[v1][i].second+w1,s[v2][p].first+w2));
			}
		}
		p=0;
		for(int i=0;i<s[v1].size();++i){
			while(p+1<s[v2].size() && s[v1][i].second+s[v2][p+1].first+w1+w2<=mid)++p;
			if(s[v1][i].second+s[v2][p].first+w1+w2<=mid){
				b.push_back(make_pair(s[v2][p].second+w2,s[v1][i].first+w1));
			}
		}
		int p1=a.size()-1,p2=b.size()-1;
		while(p1>=0 && p2>=0){
			if(a[p1].first<=b[p2].first)add(s[x],a[p1]),--p1;
			else add(s[x],b[p2]),--p2;
		}
		while(p1>=0)add(s[x],a[p1]),--p1;
		while(p2>=0)add(s[x],b[p2]),--p2;
	}else{
		s[x].push_back(make_pair(0,0));
	}
	return s[x].size();
}
ll sum=0;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i){
		int f,w;
		scanf("%d%d",&f,&w),sum+=w;
		insert(f,i,w);
	}
	ll l=0,r=sum,mid,ans=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(dfs(1,0,mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 34012
#include<iostream>

using namespace std;

int week(int money){
	money = money + money * 0.05;
	if(money % 1000 != 0){
		money = money + 1000 - ( money % 1000 );
	}
	return money;
}

int main(void){
	int n;
	int money = 100000;
	cin >> n;
	for(int i = 0;i < n;i++){
		money = week(money);
	}

	cout << money << endl;
	
	return 0;
}

Measured memory_bytes: 3096
import sys
import queue

def main():
    K = int(input())
    q = queue.Queue()
    for i in range(1, 10):
        q.put(i)

    i = 0
    while True:
        i += 1

        n = q.get()
        center_num = (10 * n) + (n % 10)
        
        if n % 10 != 0:
            q.put(center_num - 1)
        
        q.put(center_num)

        if n % 10 != 9:
            q.put(center_num + 1)

        if i >= K:
            # print(q.queue)
            print(n)
            sys.exit()

if __name__ == '__main__':
    main()

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep (i, n) {
		cin >> v[i];
	}

	int ans = 0;
	for (int i = 1; i < n-1; i++) {
		int val = v[i];
		vector<int> s = {v[i-1], v[i], v[i+1]};
		sort(all(s));
		if (s[1] == val) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

int main(){
  ll N, A, B; cin >> N >> A >> B;
  ll ans = 0;
  if(A % 2 == B % 2){
    ans = (B - A) / 2;
  }else{
    ans = min(N - B, A - 1);
    ans += (B - A + 1) / 2;
  }
  
  cout << ans << endl;
}

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

N = int(input())

ans = [-1] * N

G = [[[], []] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    if w % 2 == 0:
        G[u - 1][0].append(v - 1)
        G[v - 1][0].append(u - 1)
    else:
        G[u - 1][1].append(v - 1)
        G[v - 1][1].append(u - 1)

def dfs(x):
    ans[x] = 0
    stack = [x]
    while stack:
        y = stack.pop()
        for i in G[y][0]:
            if ans[i] < 0:
                ans[i] = ans[y]
                stack.append(i)
        for j in G[y][1]:
            if ans[j] < 0:
                ans[j] = int(not ans[y])
                stack.append(j)
    return ans

ans = dfs(0)

for i in ans:
    print(i)




Measured memory_bytes: 79136
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,t,dp[110][10010],all=1,ans=0;

int main()
{
	cin>>n>>t;
	rep(i,n-1) all=all*(t+1)%MOD;
	all=all*(t+1)*t/2*n%MOD;
	dp[n][0]=1;
	for(int i=n;i>0;i--)
	{
		rep(j,10005)
		{
			rep(k,t+1)
			{
				if(dp[i][j]==0) continue;
				if(k<=i) dp[i-1][j+(j+k)/i]=(dp[i-1][j+(j+k)/i]+dp[i][j])%MOD;
				else dp[i-1][j]=(dp[i-1][j]+dp[i][j])%MOD;
			}
		}
	}
	repn(i,10003) ans=(ans+i*dp[0][i])%MOD;
	cout<<(all-ans+MOD)%MOD<<endl;
	rt0;
}

Measured memory_bytes: 6656
#include <iostream>
using namespace std;
typedef long long int ll;

int main(){
    ll n;
    cin >>n;
    ll ans=0;
    if(n%2==0){
        ll fact = 5;
        while(fact <= n){
            ans += n/fact/2;
            fact *= 5;
        }
    }
    cout << ans << endl;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    set<int> X, Y, Z, ans;

    int N;
    cin >> N;

    int x, y, z;
    cin >> x;
    REP(i, x) 
    {
        int a;
        cin >> a;
        X.insert(a);
    }
    
    cin >> y;

    REP(i, y)
    {
        int b;
        cin >> b;
        Y.insert(b);
    }

    cin >> z;

    REP(i, z)
    {
        int c; 
        cin >> c;
        Z.insert(c);
    }

    FOR(i, 1, N + 1)
    {
        if(!X.count(i) &&  Z.count(i))
            ans.insert(i);
        
        if(Y.count(i) && Z.count(i))
            ans.insert(i);
    }

    cout << ans.size() << endl;





    return 0;
}


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

int main(void){
    long long int n;
    long long int d;
    long long int ans;

    cin >> n;
    cin >> d;

    while(1){
        ans++;
        n = n - ( 2*d+1);
        if(n<=0){break;}
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
W = 0
ans = deque(list(S.rstrip()))

for _ in range(Q):
#    print(W,ans)
    qry = list(input().rstrip().split())
    if qry[0] == "1":
        W = 1-W
        continue
    T,F,C = qry
    C.rstrip()
    if (W == 0 and F=="2") or (W==1 and F=="1"):
        ans.append(C)
    else:
        ans.appendleft(C)
ans = "".join(map(str,ans))
if W == 1:
    ans = ans[::-1]
print(ans)

Measured memory_bytes: 9444
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
U = [[int(i) for i in input().split()] for j in range(m)]

E = [[] for i in range(n + 1)]

for u, v, w in U:
    E[u].append(v)
    E[v].append(u)

visited = [False] * (n + 1)

def dfs(v):
    if visited[v]:
        return 0
    
    visited[v] = True

    for e in E[v]:
        dfs(e)
    
    return 1

ans = 0

for i in range(1, n + 1):
    ans += dfs(i)

print(ans)

Measured memory_bytes: 116484
import Control.Applicative
import Control.Monad
import Data.List
main = do
    [h, w] <- (map read . words) <$> getLine
    printDataSet h w

printDataSet :: Int -> Int -> IO()
printDataSet 0 0 = putStr ""
printDataSet h w = do
    let flatBoard = intercalate "" $ replicate (h * w) "#."
    printChessBoard h w flatBoard
    putStrLn ""
    [h, w] <- (map read . words) <$> getLine
    printDataSet h w

printChessBoard :: Int -> Int -> String -> IO()
printChessBoard 0 _ _ = putStr ""
printChessBoard last width flatBoard
    | mod width 2 == 0 = do
        putStrLn $ take width flatBoard
        printChessBoard (last - 1) width $ drop (width + 1) flatBoard
    | otherwise = do
        putStrLn $ take width flatBoard
        printChessBoard (last - 1) width $ drop width flatBoard

Measured memory_bytes: 4092
#include<iostream>
#define C std::cout<<
#define F(i,x) for(i=x;i<N;i++)
main(){for(int N;std::cin>>N&&N;){int A[N],i,j;F(i,0)std::cin>>A[i];F(i,0){F(j,i+1)if(A[j-1]+1!=A[j])break;if(i)C" ";C A[i];if(j>i+1){C'-'<<A[j-1];i=j-1;}}C'\n';}}

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

#define MAX 10000
#define INFTY 99999999
#define WHITE 0
#define GRAY 1
#define BLACK 2

struct Node {
	vector<int> ch;
	vector<int> co;
};

Node G[MAX];
int n;
int d[MAX];
int p[MAX];
int color[MAX];

void dijkstra(int s){
	int u;
	for (int i = 0; i < n; i++) {
		p[i] = -1;
		d[i] = INFTY;
	}
	d[s] = 0;
	while (true) {
		int mincost = INFTY;
		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == INFTY) {
			break;
		}
		color[u] = BLACK;
		for (int i = 0; i < G[u].ch.size(); i++) {
			int co = G[u].co[i];
			int ch = G[u].ch[i];
			if (color[ch] != BLACK) {
				if (d[u] + co < d[ch]) {
					d[ch] = d[u] + co;
					p[ch] = d[u];
					color[ch] = GRAY;
				}
			}
		}
	}
}

int main(void){
	int u;
	int k;
	int v;
	int c;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			G[u].ch.push_back(v);
			G[u].co.push_back(c);
		}
	}
	dijkstra(0);
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << "\n";
	}
}

Measured memory_bytes: 8276
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N,M,K;
int c[1<<17];
vector<pair<int,pair<int,int> > >Es;
main()
{
	cin>>N>>M>>K;
	for(int i=0;i<N;i++)cin>>c[i];
	for(int i=0;i<M;i++)
	{
		int a,b,w;cin>>a>>b>>w;
		a--,b--;
		Es.push_back(make_pair(w,make_pair(a,b)));
	}
	sort(Es.begin(),Es.end());
	long ans=0;
	UF uf(N+K);
	int ec=0;
	for(pair<int,pair<int,int> >e:Es)
	{
		int a=e.second.first,b=e.second.second;
		if(c[a]==0)a=K+a;
		else a=c[a]-1;
		if(c[b]==0)b=K+b;
		else b=c[b]-1;
		if(ec<K-1&&uf.unite(a,b))
		{
			ec++;
			ans+=e.first;
		}
	}
	cout<<(ec<K-1?-1:ans)<<endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(int, char**)
{
    rep(i,9) rep(j,9) cout << i+1 << "x" << j+1 << "=" << (i+1)*(j+1) << endl;

    return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <vector>
using namespace std;
int x,y,z;
int main() {
	int n,a,b,vec;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		cin>>vec;
		if(vec<=a){
			x++;
		}
		else if(vec<=b){
			y++;
		}
		else{
			z++;
		}
	}
	cout<<min(min(x,y),z)<<endl;
}

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

int main(){
  int H,W,i,j;
  cin>>H>>W;
  bool a[H][W];
  int x;
  for(i=0;i<H;i++){
	for(j=0;j<W;j++){
		cin>>x;
		a[i][j]=(x%2==1);
	}
  }
  vector<int> v1,v2,v3,v4;
  for(i=0;i<H;i++){
	for(j=0;j<W-1;j++){
		if(a[i][j]){
		v1.push_back(i);
		v2.push_back(j);
		v3.push_back(i);
		v4.push_back(j+1);
		a[i][j+1]=!a[i][j+1];
		}
	}
  }
  for(i=0;i<H-1;i++){
	if(a[i][W-1]){
		v1.push_back(i);
		v2.push_back(W-1);
		v3.push_back(i+1);
		v4.push_back(W-1);
		a[i+1][W-1]=!a[i+1][W-1];
	}
  }
  cout<<v1.size()<<endl;
  for(i=0;i<v1.size();i++){
	cout<<v1[i]+1<<" "<<v2[i]+1<<" "<<v3[i]+1<<" "<<v4[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 4452
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 200005;
const int MM = 1000000007;

int N, M;
vector<int> G[MX];
int chk[MX];

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int c : G[1]) chk[c] |= 1;
	for(int c : G[N]) chk[c] |= 2;
	for(int i = 1; i <= N; i++) if( chk[i] == 3 ) return !printf("POSSIBLE\n");
	printf("IMPOSSIBLE\n");
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
  return 0;
}


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

int N, M;

int main() {
	ll k = 1;
	ll t;

	cin >> N >> M;
	t = 1900 * M + 100 * (N - M);
	for (int i = 0; i < M; ++i) k *= 2;

	cout << t * k << endl;
}

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

#define MAX 20

int main(){
	char str[MAX + 1];

	cin >> str;

	int flag = 0, i = 0;
	while( !flag || i >= 0){
		if( flag ){
			cout << str[i--];
		} else {
			if(str[i] == '\0'){
				i--;
				flag = 1;
			} else {
				i++;
			}
		}
	}
	cout << endl;
	return 0;
}


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

const int MAXN = 500001;
int N, Q;
int BIT[26][MAXN] = {0};

inline int lowbit(int x)
{
    return x & (-x);
}

void add(int id, int x, int k)
{
    while (x <= N)
    {
        BIT[id][x] = BIT[id][x] + k;
        x = x + lowbit(x);
    }
}

int get_sum(int id, int x)
{
    int ans = 0;
    while (x >= 1)
    {
        ans = ans + BIT[id][x];
        x = x - lowbit(x);
    }
    return ans;
}

int main()
{
    cin >> N;
    string s;
    cin >> s;
    for (int i = 0; i < N; i++)
    {
        add(s[i] - 'a', i + 1, 1);
    }
    
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int type;
        cin >> type;
        if (type == 1)
        {
            int idx;
            char c;
            cin >> idx >> c;
            add(s[idx - 1] - 'a', idx, -1);
            add(c - 'a', idx, 1);
            s[idx - 1] = c;
        }
        else
        {
            int l, r, cnt = 0;
            cin >> l >> r;
            for (int c = 0; c < 26; c++)
            {
                if (get_sum(c, r) - get_sum(c, l - 1) > 0)
                    cnt++;
            }
            cout << cnt << endl;
        }
        
    }
    // system("pause");
}

Measured memory_bytes: 51704
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) if(i % k == 0) {
        cout << "OK\n";
        exit(0);
    }
    cout << "NG\n";
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

	Scanner sc = new Scanner(System.in);
	
	int a =sc.nextInt();
	int b =sc.nextInt();
	
	if(a>b){
        System.out.println("a > b");
    
        }else if (a<b){
        System.out.println("a < b");

        }else{
        System.out.println("a == b");
        }  
	sc.close(); 
    }
}


Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define  ll long long int
#include<algorithm>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll s1,s2,s3,i,n,p;
    cin>>n;
    s1=0;
    if(n>=3)
    {

    for(i=3;i<=n;i=i+3)
    {
        if(i%5==0)
            continue;
        else
        s1=s1+i;
    }
    }
    s2=0;
    if(n>=5)
    {

    for(i=5;i<=n;i=i+5)
    {
        if(i%3==0)
            continue;
        else
        s2=s2+i;
    }
    }
    s3=0;
    if(n>=15)
    {

    for(i=15;i<=n;i=i+15)
    {
        s3=s3+i;
    }
    }
    p=(n*(n+1))/2;
    cout<<p-s1-s2-s3;



    return 0;
}







Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

constexpr ll MOD = 1e9 + 7;

void solve();

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

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    std::map<ll, ll> map;

    auto func = [&](ll n) -> void {
        for (ll i = 2; n > 1; i++) {
            if (n % i != 0) continue;
            ll j = 0; for (; n % i == 0; n /= i) j++;
            map[i] += j;
        }
    };

    for (ll i = 1; i <= n; i++)
        func(i);

    ll ans = 1;
    for (auto i : map)
        (ans *= i.second + 1) %= MOD;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
double dp[305][305][305];
int cnt[5];
int n;
void dfs(int x,int y,int z){
	if(x<0||y<0||z<0) return;
	if(dp[x][y][z]!=-1) return;
	double a=(double)n/(double)(x+y+z);
	dp[x][y][z]=a;
	dfs(x-1,y+1,z);dfs(x,y-1,z+1);dfs(x,y,z-1);
	if(x-1>=0&&dp[x-1][y+1][z]!=-1) dp[x][y][z]+=(double)x*dp[x-1][y+1][z]/(double)(x+y+z);
	if(y-1>=0&&dp[x][y-1][z+1]!=-1) dp[x][y][z]+=(double)y*dp[x][y-1][z+1]/(double)(x+y+z);
	if(z-1>=0&&dp[x][y][z-1]!=-1) dp[x][y][z]+=(double)z*dp[x][y][z-1]/(double)(x+y+z);
	return;
}
int main(){
	cin>>n;
//	cout<<n<<endl;
	
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		cnt[x]++;
		
	}
//	cout<<endl;
	for(int i=0;i<305;i++)for(int j=0;j<305;j++)for(int k=0;k<305;k++) dp[i][j][k]=-1;
	dp[0][0][0]=0;
	dfs(cnt[3],cnt[2],cnt[1]);
	printf("%.9f",dp[cnt[3]][cnt[2]][cnt[1]]);
}

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

_n = int(input())
lrlist = [list(map(int, input().split())) for _ in range(_n)]
Lp, Rq = max(l for l, r in lrlist), min(r for l, r in lrlist)

st = sorted([(max(r - Lp + 1, 0), max(Rq - l + 1, 0)) for l, r in lrlist], key=lambda x: (x[0], -x[1]))
ans = max([r - l + 1 for l, r in lrlist]) + max(Rq - Lp + 1, 0)

min_b = 10 ** 9
for i in range(_n - 1):
    min_b = min(st[i][1], min_b)
    ans = max(ans, min_b + st[i + 1][0])

print(ans)


Measured memory_bytes: 53028
h, w = map(int,input().split())
S = [input() for i in range(h)]

Q = [[0, 0, 0]]
V = [[0] * w for i in range(h)]
D = [[float("inf")] * w for i in range(h)]
st = 0
while st < len(Q):
    # print(Q)
    if Q[st] == [h-1, w-1]:
        D[-1][-1] = Q[st][2]
        break
    else:
        i = Q[st][0]
        j = Q[st][1]
        d = min(Q[st][2], D[i][j])
        D[i][j] = d

        if V[i][j] == 0:
            V[i][j] = 1
            for di, dj in [[-1,0], [1,0], [0,-1], [0,1]]:
                if 0 <= i+di <= h-1 and 0 <= j+dj <= w-1 and S[i+di][j+dj] == "." and V[i+di][j+dj] == 0:
                    Q.append([i+di, j+dj, d+1])
    st += 1

white = sum([S[i].count(".") for i in range(h)])
# print(white)

#print(D[-1][-1])

ans = white - D[-1][-1] - 1
if ans == -float("inf"):
    ans = -1
print(ans)


Measured memory_bytes: 41072