akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define MINF 0xc0c0c0c0

#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
#include <assert.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

static const double EPS = 1e-10;

int main(){
  int W;
  while(~scanf("%d",&W)){
    int H = W;
    int dp[102][102];
    memset(dp,0,sizeof(dp));

    for(int y = 0; y < H; y++){
      for(int x = 0; x < W; x++){
        int num;
        scanf("%d",&num);
        dp[y+1][x+1] = dp[y+1][x] + dp[y][x+1] - dp[y][x] + num;
      }
    }

    int res = MINF;
    for(int ly = 1; ly <= H; ly++){
      for(int lx = 1; lx <= W; lx++){
        for(int ry = ly; ry <= H; ry++){
          for(int rx = lx; rx <= W; rx++){
            int sum = dp[ry][rx] - dp[ry][lx-1] - dp[ly-1][rx] + dp[ly-1][lx-1];
            res = max(sum,res);
          }
        }
      }
    }

    printf("%d\n",res);
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::vector<int> c(100002);
    for(int i=0;i<n;i++){
        cin >> a ;
        c[a]++;
        c[a+1]++;
        c[a+2]++;
    }
    cout << *max_element( c.begin() , c.end());
    
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int n;
long long res=1;
long long t;
long long gcd(long long a,long long b){
	if(a<b)
		swap(a,b);
	if(b==0)
		return a;
	return gcd(b,a%b);
}
long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>t;
		res=lcm(t,res);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<int> red(n, 0), ball(n, 1);
    red[0] = 1;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        ball[x]--;
        ball[y]++;
        if (red[x])
        {
            red[y] = 1;
            if (ball[x] == 0)
            {
                red[x] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += red[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
a,b=map(int,input().split())
ans=0
if max(a,b)==a:
  ans=ans+a
  a=a-1
  if max(a,b)==a:
    ans=ans+a
    a=a-1
  elif max(a,b)==b:
    ans=ans+b
    b=b-1
elif max(a,b)==b:
  ans=ans+b
  b=b-1
  if max(a,b)==a:
    ans=ans+a
    a=a-1    
  elif max(a,b)==b:
    ans=ans+b
    b=b-1      
print(ans)   
    


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

ll a[2000], dp[2000][2000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%lld", &a[i]);
	ll Max = 0;
	for (int t = 1; t <= n; t++) {
		rep(i, n) {
			int j = (i + t - 1) % n;
			if ((n - t) & 1) {
				if (a[i] > a[j])dp[i][j] = dp[(i + 1) % n][j];
				else dp[i][j] = dp[i][(j + n - 1) % n];
			}
			else dp[i][j] = max(dp[(i + 1) % n][j] + a[i], dp[i][(j + n - 1) % n] + a[j]);
			Max = max(Max, dp[i][j]);
		}
	}
	printf("%lld\n", Max);
}

Measured memory_bytes: 34468
#include <iostream>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

X = int(sys.stdin.readline())
print(int(math.ceil((-1 + math.sqrt(1 + 8 * X)) / 2)))

# ans = 0
# x = 1
# s = 0
# while s < X:
#     s += x
#     x += 1
# print(x - 1)
#


Measured memory_bytes: 13596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;


int main() {
	
	int a, b;
	cin >> a >> b;

	int ans = a * b - (a + b - 1);

	cout << ans << endl;	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long st[800005]={};
long long h[200005], w[200005];
void update(int x, int l, int r, int z, long long int zz){
	if(l > z || r < z)return;
	if(l == r){
		st[x] = zz;
		return;
	}
	int mid = (l+r)/2;
	update(x*2, l, mid, z, zz);
	update(x*2+1, mid+1, r, z, zz);
	st[x] = max(st[x*2], st[x*2+1]);
}
long long query(int x, int l, int r, int ll, int rr){
	if(l > rr || r < ll)return 0;
	if(l >= ll && r <= rr)return st[x];
	int mid = (l+r)/2;
	return max(query(x*2, l, mid, ll, rr), query(x*2+1, mid+1, r, ll, rr));
}
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)cin >> h[i];
	for(int i = 0; i < n; i++){
		cin >> w[i];
	}
	long long ans = 0;
	for(int i = 0; i < n; i++){
		long long asd = query(1, 1, n, 1, h[i]);
		update(1, 1, n, h[i], asd + w[i]);
		ans = max(ans, asd + w[i]);
	}
	cout << ans;
}

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

typedef long long ll;

const int INF = 10000000;
const int MAX_V = 10010;
struct edge {
    int to, cost, dis;
    edge(int to, int dis, int cost) : to(to), dis(dis), cost(cost){}
};
vector<vector<edge> > G(MAX_V);
int cost[MAX_V];
int dis[MAX_V];
typedef pair<int, int> P;
int n, m;

void dijkstra(int s) {
    fill(dis, dis + MAX_V, INF);
    fill(cost, cost + MAX_V, INF);
    dis[s] = 0;
    cost[s] = 0;
    priority_queue<P, vector<P>, greater<P> > pq;
    pq.push(P(0, s)); // d {c, from}
    while(!pq.empty()) {
        P p = pq.top(); pq.pop();
        int from = p.second;
        if(dis[from] < p.first) continue;
        for(int i = 0; i < G[from].size(); i++) {
            edge e = G[from][i];
            if(dis[e.to] > dis[from] + e.dis) {
                dis[e.to] = dis[from] + e.dis;
                cost[e.to] = e.cost;
                pq.push(P(dis[e.to], e.to));
            }
            else if(dis[e.to] == dis[from] + e.dis) {
                cost[e.to] = min(cost[e.to], e.cost);
            }
        }
    }
};

int main() {
    while(scanf("%d%d", &n, &m) != EOF && n) {
        int u, v, d, c;
        for(int i = 0; i <= n; i++) {
            G[i].clear();
        }
        for(int i = 0; i < m; i++) {
            scanf("%d%d%d%d", &u, &v, &d, &c);
            G[u].push_back(edge(v,d,c));
            G[v].push_back(edge(u,d,c));
        }

        dijkstra(1);
        int ans = 0;
        for(int i = 2; i <= n; i++) {
            ans += cost[i];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 5092
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, c = LI()
clock_pos = []
value = []
for i, j in LIR(n):
    clock_pos += [i]
    value += [j]




arr = [0]
counter_arr = [0]
round_arr = [0]
round_counter_arr = [0]
ret = 0
counter_ret = 0
for i in range(n):
    ret += value[i]
    counter_ret += value[-i - 1]
    arr.append(max(arr[i], ret - clock_pos[i]))
    round_arr.append(ret - clock_pos[i] * 2)
    counter_arr.append(max(counter_arr[i], counter_ret - (c - clock_pos[-i - 1])))
    round_counter_arr.append(counter_ret - (c - clock_pos[-i - 1]) * 2)



ans = max(arr[-1], counter_arr[-1])
for j in range(n):
    ans = max(ans, round_arr[j] + counter_arr[n - j], round_counter_arr[j] + arr[n - j])


print(ans)


Measured memory_bytes: 87260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a == 1) ans+= 300000;
    if(a == 2) ans+= 200000;
    if(a == 3) ans+= 100000;
    if(b == 1) ans+= 300000;
    if(b == 2) ans+= 200000;
    if(b == 3) ans+= 100000;
    if(a == 1 && b == 1) cout << ans+400000 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];
        int count = 0;
        int max = 0;
        for (int i = 0 ; i < N ; i++) {
            H[i] = sc.nextInt();
            if (max < H[i]) max = H[i];
        }
        int[][] HN = new int[max][N];
        for (int i = 0; i < max; i++) {
            for (int j = 0; j < N ; j++) {
                if (0 < H[j]) {
                    HN[i][j] = 1;
                    H[j]--;
                } else HN[i][j] = 0;
            }
        }
        for (int[] line : HN) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < line.length; i++) {
                if (i == 0 && line[0] != 0) sb.append(line[i]);
                else if (0 < i && line[i] != line[i-1]) sb.append(line[i]);
                else continue;
            }
            count += sb.toString().split("0").length;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t, u;
  ll a, b;
  cin >> s >> t >> a >> b >> u;
  
  if(u == s)
  cout << a-1 << " " << b << "\n";
  if(u == t)
  cout << a << " " << b-1 << "\n";


}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

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

    vi v(n);
    for(auto& c:v)
        cin>>c;

    for(int i=k;i<n;++i)
    {
        if(v[i]>v[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

#define PI 3.14159265358979323846264338327950L
#define ll long long
#define lli long long int

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n];
    map<int, int> maps;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        if (maps.find(arr[i]) == maps.end()) {
            maps[arr[i]] = 1;
        } else {
            maps[arr[i]]++;
        }
    }
    bool dp[1000001];
    fill(dp, dp + 1000001, false);
    int counts = 0;
    for (auto i = maps.begin(); i != maps.end(); ++i) {
        int temp = i->first;
        if (maps[temp] == 1 && !dp[temp]) {
            counts++;
        }
        for (int j = temp; j <= 1000000; j += temp) {
            dp[j] = true;
        }
    }
    cout << counts << "\n";


    return 0;
}


Measured memory_bytes: 14780
N = int(input())
L = ["".join(sorted(list(input()))) for i in range(N)]
D = {}
for s in L :
    if s not in D :
        D[s] = 1
    else :
        D[s] +=  1
ans = 0
for k in D :
    n = D[k]
    ans += n*(n-1)//2
print(ans)

Measured memory_bytes: 66776
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int gcds(int a, int b){
    int c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    char a, b; cin >> a >> b;
    if (a == b) cout << "=" << endl;
    else if (a > b) cout << ">" << endl;
    else if (a < b) cout << "<" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<ll, ll>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

n, a = map(int, input().split())
X = list(map(int, input().split()))

# i番目までからj個選んで和をkにできる選び方の総数
# 選ばない状態も持ちたいから配列は1まわり大きく
dp = [[[0 for k in range(n*a+1)] for j in range(n+1)] for i in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*a+1):
            # 初期条件
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1

            # x_iが和を超過してしまう場合
            elif i > 0 and k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]

            # 和を作れる場合
            # 加算する場合としない場合の両方を考える
            elif i > 0 and j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

            # その他
            else:
                dp[i][j][k] = 0

# i枚選んだ時の合計がiAであればよい
ans = 0
for i in range(1, n+1):
    ans += dp[n][i][i*a]

print(ans)


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

using namespace std;

typedef long long ll;
int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<ll> P(n);
        vector<ll> J(n-1);
        for(int i=0;i<n;i++) cin >> P[i];
        for(int i=0;i<n-1;i++) cin >> J[i];

        sort(J.begin(),J.end());
        reverse(J.begin(),J.end());

        ll r = accumulate(P.begin(),P.end(),0);
        ll ret = r * n;
        for(ll i=0;i<J.size();i++){
            r += J[i];
            ret = max(ret,r*(n-i-1));
        }
        cout << ret << endl;
    }
    return 0;
}

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

int main()
{
	int age,price;
	cin >> age >> price;
	if (age >= 13)
		cout << price << endl;
	else if (age <= 12 && age>=6)
		cout << price / 2 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
const int n = 50;
signed main() {
	int k; cin >> k;
	int k1 = k / n, k2 = k % n;
	cout << n << endl;
	for (int i = 1; i <= 50; i++) {
		if (i != 1)cout << ' ';
		if (i <= k2)cout << n - 1 + k1 - k2 + n + 1;
		else cout << n - 1 + k1 - k2;
	}
	cout << endl;
	cin >> k;
}

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

dictionary = [[] for i in range(N + 1)]

for i in range(N-1):
    a, b = map(int, input().split())
    dictionary[a].append(b)

num = [0] * (N + 1)

for i in range(Q):
    p, x = map(int, input().split())
    num[p] += x

for i in range(1, N + 1):
    print(num[i])
    for j in range(0, len(dictionary[i])):
        num[dictionary[i][j]] += num[i]




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


int main(){
    int n, r;
    cin >> n >> r;
    if(n<10) r += 100*(10-n);
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

      	int length = sc.nextInt();
      	int a[] = new int[length];
  		int b[] = new int[length - 1];
      	int a_sum = 0;
      
     	for(int i = 0; i < b.length; i++) b[i] = sc.nextInt();
      
      	a[0] = b[0];      
      	
      	for(int i = 1;i < length-1; i++){
        	if(b[i - 1] < b[i]) a[i] = b[i -1];
            else a[i] = b[i];
        }
      
      	a[length -1] = b[length -2];
      
      	for(int num: a) a_sum += num;
     
        System.out.println(a_sum);
        
	}
}


Measured memory_bytes: 35964
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int sigma(int n){
	int coun = 0;
	for (int i = 1; i <= n; i++){
		coun += i;
	}
	return coun;
}

int main(){
	int a, b;
	cin >> a >> b;
	cout << sigma(b-a) - b << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,s;
    int dp[10010];
    cin>>n;
    memset(dp,-1,sizeof(dp));dp[0]=0;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        for(j=10000;j>=s;j--)
            if (dp[j-s]==0) dp[j]=0;
    }
    for(i=10000;i>=1;i--)
        if (i%10!=0 && dp[i]==0) break;
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

S = []
for n in range(N):
	S.append(input())

Acount  = 0
Bcount  = 0
ABcount = 0
BXAcount = 0

for s in S:
	if s[0]  == "B" :
		Bcount += 1
	if s[-1] == "A" :
		Acount += 1
	for i in range(len(s)-1) : 
		if s[i] == "A" and s[i+1] == "B" :
			ABcount += 1
	if s[0] == "B" and s[-1] == "A" :
		BXAcount += 1

#print(S)
#print("Acount  = " + str(Acount))
#print("Bcount  = " + str(Bcount))
#print("ABcount = " + str(ABcount))
if BXAcount >= 1 and Acount == BXAcount and Bcount == BXAcount :
		print(min(Acount, Bcount) + ABcount -1)
else:
	print(min(Acount, Bcount) + ABcount)



Measured memory_bytes: 3700
def main():
    inf = 1<<29
    n,w = map(int,input().split())
    A = []
    for _ in range(n):
        a,b = map(int,input().split())
        A.append([a,b])
    dp = [0]*(w+1)
    for i in range(n):
        a = A[i][0]
        b = A[i][1]
        for j in range(w,b-1,-1):
            dp[j] = max(dp[j],dp[j-b]+a)
    res = 0
    for i in range(w+1):res = max(res,dp[i])
    print(res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5916
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    p = 1
    for _ in range(60):
        n = 0
        for i in range(N):
            A[i], d = A[i] // 2, A[i] % 2
            n += d
        ans = (ans + n * (N - n) * p) % MOD
        p = p * 2 % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 136744
a = list()
ans = "No"
for i in range(3):
  a += list(map(int, input().split()))
n = int(input())
c = [int(input()) for i in range(n)]
b = [0] * 9
for i in c:
  for k,j in enumerate(a):
    if i == j:
      b[k] = 1
if b[0] and b[1] and b[2]:
  ans = "Yes"
if b[3] and b[4] and b[5]:
  ans = "Yes"
if b[6] and b[7] and b[8]:
  ans = "Yes"
if b[0] and b[3] and b[6]:
  ans = "Yes"
if b[1] and b[4] and b[7]:
  ans = "Yes"
if b[2] and b[5] and b[8]:
  ans = "Yes"
if b[0] and b[4] and b[8]:
  ans = "Yes"
if b[2] and b[4] and b[6]:
  ans = "Yes"
print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>
int main(){
  char s[11],t[12];
  scanf("%s%s",s,t);
  int i;

  for(i=0;i<strlen(s);i++){
    //printf("%c",s[i]);
    //printf("%c\n",t[i]);
    if(s[i]!=t[i]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}




Measured memory_bytes: 1680
from collections import deque

n = int(input())
Adj_dict = {x:[] for x in range(1,n+1)}
AB_dict = {}
AB = []
for _ in range(n-1):
    a, b = map(int, input().split())
    Adj_dict[a].append(b)
    Adj_dict[b].append(a)
    AB.append([a,b])
    AB_dict.update({str(a)+'_'+str(b):0})

max_edges = 0
node_max_edges = 0
for key, value in Adj_dict.items():
    edges = len(value)
    if edges >= max_edges:
        max_edges = edges
        node = key

dq = deque()
dq.append(1)

Visited = [False for _ in range(n+1)]
Visited[1] = True
Colors = [0 for _ in range(n+1)]

while dq:
    c = 1
    node = dq.popleft()
    Next_nodes = Adj_dict[node]

    for next_node in Next_nodes:
        if Visited[next_node] == True:
            continue
        dq.append(next_node)
        Visited[next_node] = True

        if c == Colors[node]:
            c += 1
        Colors[next_node] = c
        c += 1
        if node < next_node:
            AB_dict[str(node)+'_'+str(next_node)] = Colors[next_node]
        else:
            AB_dict[str(next_node)+'_'+str(node)] = Colors[next_node]

print(max_edges)
for ab in AB:
    a = ab[0]
    b = ab[1]
    print(AB_dict[str(a)+'_'+str(b)])
# print(AB_dict)

Measured memory_bytes: 55656
H,W = map(int,input().split())
list_ = []
result = []
a = []
for i in range(H):
  tmp_set = list(input())
  if set(tmp_set) != {'.'}:
    list_.append(tmp_set)
    
for i in range(len(list_[0])):
  dot_ = 0
  a = [x[i] for x in list_]
  if set(a)!={'.'}:
    result.append(a)
    	
result = [list(x) for x in zip(*result)]
for i in result:
  print(''.join(i))

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

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

    int x[n], y[m];

    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];

    sort(x, x + n, greater<int>());
    sort(y, y + m);

    string ans;
    if (x[0] < y[0] && X < y[0] && x[0] < Y) {
        ans = "No War";
    } else {
        ans = "War";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(void){
  int n;
  bool a[50];
  int s,x,y;
  scanf("%d",&n);
    for(int i=0;i<50;i++){
a[i]=false;
  }
  x=100;
  for(int i=0;i<n;i++){
    scanf("%d",&y);
    if(y==x+1)a[x-1]=true;
    x=y;
  }
  s=0;
    for(int i=0;i<n;i++){
    scanf("%d",&x);
      s+=x;
  }
      for(int i=0;i<n-1;i++){
    scanf("%d",&x);
      if(a[i])s+=x;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<ll> a(n);
    bool minus = false;
    ll ans = 0;

    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i] < 0){
            minus = !minus;
            a[i] = -1 * a[i];
        }
        ans += a[i];
    }
    sort(ALL(a));

    if(minus) ans = ans - 2 * a[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3944
#include <stdio.h>
int main()
{
    int ara[5];
    int i;
    for(i=0;i<5;i++)
        scanf("%d",&ara[i]);
    for(i=0;i<5;i++)
    {
        if(ara[i]==0)
            break;
    }
    printf("%d",i+1);
    return 0;
}


Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<string> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i];
    sort(v[i].begin(), v[i].end());
  }
  sort(v.begin(), v.end());
  ll cnt = 1;
  ll ans = 0;
  for(int i=1;i<n;++i) {
    if(v[i] == v[i-1]) {
      cnt++;
    } else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int n , a;
	cin >> n >> a;
	if (n % 500 - a <= 0)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const long long mod=1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    int n = s.size();
    int ans1 = 0, ans2 = 0;//黒スタート, 白スタート
    rep(i, n){
        if (i % 2 == s[i] - '0') ans1++;//偶奇が一緒ならans1++
        else ans2++;
    }
    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#include <vector>
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main(){
    ll n;
    cin>>n;
    vector<ll> nums(100000);
    ll i=0;
    for(auto p : prime_factor(n)) {
    while(p.second--) {
        nums[i]++;
    }
            i++;
            //cout<<nums[i]<<endl;
  }
  ll sum=0;
  i=0;
    while(nums[i]!=0){
        ll k=1;
        ll cntr=1;
        for(ll j=1;j<=nums[i];j+=k){
            sum++;
            k++;
           // cout<<j<<endl;
        }
        i++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3992
#include <stdio.h>

int main()
{
 
  int i, j, tmp, l;
  int N;
  int A[1000];
 
  scanf("%d", &N);
  
  for(i=0; i<N; i++){
 
  scanf("%d",&A[i]);
  
  }

  for(i=1; i<N; i++){
      for(j=0; j<N-1; j++){ 
      printf("%d ",A[j]);
    }
    printf("%d\n",A[N-1]);
    tmp=A[i];/*i*/
    if(A[i-1]>tmp){/*i-1*/
      l=i;/*i*/
      do{
	A[l]=A[l-1];
	l--;
      }
      while(l>0 && tmp<A[l-1]);
      A[l]=tmp;
    }
  }

  for(j=0; j<N-1; j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[N-1]);
  return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C;
  cin>>A>>B>>C;
  cout<<max(0,C-(A-B))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll n, m;
    cin >> n >> m;
    if (n < m) swap(n,m);

    ll ans = 0;
    if (m == 1)  {
        if (n == 1) ans = 1;
        else if (n == 2) ans = 0;
        else ans = n - 2;
    } else if (m == 2) ans = 0;
    else {
        ans = n*m - n*2 - (m-2)*2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
str = gets.chomp.split("").map(&:to_i)
state = [0, 0]
ans = 0
str.size.times do |i|
  state[str[i]] += 1
  if state[0]>= 1 && state[1]>=1
    state[0] -= 1
    state[1] -= 1
    ans += 2
  end
end
# puts "#{state}"
puts ans

Measured memory_bytes: 7676
#include <iostream>
using namespace std;
#include <string>
char s[3001][3001];
int n[2][3001][3001];
int main(){
  int h,w;
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }
  for(int i = 0; i < h;i++){
    for(int j = w-1;j>=0;j--){
      int temp = 0;
      if(s[i][j] == 'O'){
        temp++;
      }
      n[0][i][j] = n[0][i][j+1]+temp;
    }
  }
  for(int i = 0; i < w; i++){
    for(int j = h-1; j>=0;j--){
      int temp = 0;
      if(s[j][i] == 'I')temp ++;
      n[1][j][i] = n[1][j+1][i] + temp;
    }
  }
  long long int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == 'J'){
        ans +=n[0][i][j+1]*n[1][i+1][j];
      }
    }
  }
  cout << ans << endl;
}



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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200){
        P(s);
    }else{
        P("red");
    }
}

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

int main ()
{
    string s;
    long sum=0;
    cin>>s;
    int i,x=s.size();
    for(i=0;i<x;i++) sum+=s[i]-'0';

    if((sum%9)==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  int a;
  string s;
  cin >> a >> s;
  
  if (a < 3200) {
    printf("red\n");
  } else {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S=io.read()
local count=0
local i=1
while i~=#S  do
    if string.sub(S,i,i)=="0" and string.sub(S,i+1,i+1)=="1" or string.sub(S,i,i)=="1" and string.sub(S,i+1,i+1)=="0" then
        count=count+2
        S=string.sub(S,1,i-1)..string.sub(S,i+2,#S)
        i=i-1
    else
        i=i+1
    end
end
print(count)
        

Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;
using P = pair<int,int>;


void lcs(vector<vector<int>> &tbl,V2<P> &par,string &s, string &t, int a, int b){
    int am = a-1, bm = b-1;
    if(s[am]==t[bm]){
        tbl[a][b] = tbl[am][bm] + 1;
        par[a][b].fs = am;
        par[a][b].sd = bm;
        return;
    }
    else{
        if(tbl[a][bm]<tbl[am][b]){
            tbl[a][b] = tbl[am][b]; par[a][b].fs = am; par[a][b].sd = b;
        }else{
            tbl[a][b] = tbl[a][bm]; par[a][b].fs = a; par[a][b].sd = bm;
        }
    }
}


void solve(){
    string s, t;
    cin >> s >> t;
    int n, m;
    n = s.size(); m=t.size();
    if(n>m){
      //swap(s,t);
      //swap(n,m);
    }
    vector<vector<int>> tbl(n+3, vector<int>(m+3)); V2<P> par(n+3, V<P>(m+3,P(-1,-1)) );
    FOR(i,1,n+1){
        FOR(j,1,m+1){
            lcs(tbl, par, s, t, i, j);
        }
    }
  string ret;
   {
     int la=n, lb = m;
     while(la>=0 && lb >= 0){
       int na = par[la][lb].fs,
           nb = par[la][lb].sd;
       if( (na<0 || nb<0 || tbl[la][lb]>tbl[na][nb]) && s[la-1]==t[lb-1] && s[la-1]!='\0' ) ret += s[la-1];
       la = na;
       lb = nb;
     }
     reverse(ALL(ret));
     if(s.size()==0) s+=' ';
     cout << ret <<  endl;
   }
    /*FOR(i,0,n+1){
        FOR(j,0,m+1){
            cout << tbl[i][j] << " ";
        }cout << "\n";
    }cout << "\n";
    FOR(i,0,n+1){
        FOR(j,0,m+1){
            cout << par[i][j].fs << "," <<par[i][j].sd << " ";
        }cout << "\n";
    }cout << "\n";
    cout << tbl[n][m] << endl;*/
  
}

int main(void){
    solve();
    return 0;
}

Measured memory_bytes: 106240
use std::io::BufRead;

fn main() {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let nums: Vec<isize> = buf.split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
    let (x ,y) = (nums[2], nums[3]);
    // read x countery
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let x_towns: Vec<isize> = buf.split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
    
    // read y countory
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let y_towns: Vec<isize> = buf.split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
    jadge(x, y, x_towns, y_towns);
}

fn jadge(x: isize, y: isize, x_towns: Vec<isize>, y_towns: Vec<isize>) {
    if x >= y {
        println!("War");
        return;
    }
    let mut max_x = x;
    let mut min_y = y;
    for xtown in x_towns {
        if xtown > max_x {
            max_x = xtown;
        }
    }
    for ytown in y_towns {
        if ytown < min_y {
            min_y = ytown;
        }
    }

    if min_y <= max_x {
        println!("War");
    } else {
        println!("No War");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	cout << h*w-w*a-h*b+a*b << endl;
	return 0;
 }



Measured memory_bytes: 256
#include <stdio.h>

#define NUMBER 20
int main(void){
  int i,j;
  int num;
  int ans = 0;
  int max = 0;
  int takasa[NUMBER];

  scanf("%d",&num);

  for (i = 0; i < num; i++){
    scanf("%d",&takasa[i]);
    if (takasa[i] >= max){
      max = takasa[i];
      ans += 1;
    }
  }

  printf("%d",ans);

  return 0;
}

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

N = int(input())
A = list(map(int, input().split()))
iA = [(i, A[i]) for i in range(N)]
iA.sort(key=lambda t: t[1], reverse=True)
dp = [[0]*(N+1) for _ in range(N+1)]

for i in range(N):
    for j in range(N):
        if i+j<N:
            idx, v = iA[i+j]
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]+(idx-i)*v)
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]+(N-1-j-idx)*v)
    
ans = 0

for i in range(N+1):
    ans = max(ans, dp[i][N-i])

print(ans)

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

using namespace std;

int N, K;
int main(void){
	scanf("%d %d", &N, &K);
	long long int s = 0;
	for(int i = 1;i <= N;++i){
		s += max(i - K, 0) * (N/i);
		if(N % i != 0){
			int t = N - ((N/i) * i);
			if(K <= t) s += (K != 0 ? t - K + 1 : t);
		}
	}
	printf("%lld\n", s);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

void solve(){
	for(int i = 1; i < 10; i ++){
		for(int j = 1; j < 10; j ++)
			printf("%dx%d=%d\n", i, j, i * j);
	}
}

int main(int argc, char const *argv[]){
	solve();
	return 0;
}

Measured memory_bytes: 924
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
set<int> st;
vector<int> v;

int main(void){
	fio();
	cin>>n>>s;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='R')st.insert(i);
	}
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='W'){
			auto it=st.end();
			if(it==st.begin())continue;
			it--;
			if(*it<i)continue;
			cev++;
			st.erase(it);
		}
	}
	cout<<cev<<endl;
	return 0;
}



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

using namespace std;

struct Edge {
    int id;
    int node;
};

int main (void) {
    int N;
    cin >> N;

    vector<vector<Edge>> node(N+1);
    for ( int i = 0; i < N-1; i++ ) {
        int a, b;
        cin >> a >> b;
        node.at(a).push_back((Edge){i, b});
        node.at(b).push_back((Edge){i, a});
    }

    vector<int> ans(N-1);
    queue<int> q;
    vector<bool> used(N+1, false);
    q.push(1);
    used.at(1) = true;

    while ( !q.empty() ) {
        int n = q.front(); q.pop();
        int n_connect = node.at(n).size();
        int c = -1;
        for ( int i = 0; i < n_connect; i++ ) {
            int n_ = node.at(n).at(i).node;
            int edge = node.at(n).at(i).id;
            if ( used.at(n_) )
                c = ans.at(edge);
        }
        int k = 1;
        for ( int i = 0; i < n_connect; i++ ) {
            int n_ = node.at(n).at(i).node;
            int edge = node.at(n).at(i).id;
            if ( used.at(n_) )
                continue;
            if ( k == c )
                k++;
            ans.at(edge) = k;
            k++;
            q.push(n_);
            used.at(n_) = true;
        }
    }

    int mx = 0;
    for ( int i = 1; i <= N; i++ ) {
        mx = max(mx, (int)node.at(i).size());
    }
    cout << mx << endl;
    for ( int i = 0; i < N-1; i++ ) {
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 9784
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,a,b;

int main(){
    cin>>N;
    a=0;
    while(a*4<=N){
        b=0;
        while(a*4+b*7<=N){
            if(a*4+b*7==N){
                out("Yes");
                return 0;
            }
            b++;
        }
        a++;
    }
    out("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <vector>

#define ll long long
using namespace std;

int main()
{
    //freopen("C:\\Users\\23733\\Desktop\\in.txt","r",stdin);
    int head, tail, cnt = 0;
    cin >> head >> tail;
    for(int i = head; i <= tail; i++)
    {
         if((i % 10 == i / 10000) && (i / 10 % 10 == i / 1000 % 10))
                    cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
v=gets.split.map(&:to_i)

p (0..[n,k].min).map{|a|
  (0..[n-a,k-a].min).map{|b|
    l = (v[0,a]+v[-b,b]).sort
    drop_cnt = k-a-b
    l.drop_while{|i|
      (i<=0) && ((drop_cnt-=1)>=0)
    }.inject(:+)||0
  }.max
}.max

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

int main(void){

    int f=0;
    string s;
        cin>>s;
    for(int i=0; i!=s.size(); i++){

        if(s[i]=='B')
            f=1;
    }
    if(f)
        cout<<"ARC";
    else
        cout<<"ABC";


}


Measured memory_bytes: 3592
n = int(input())
ls = []
lt = []
for i in range(n):
    s,t = input().split()
    t = int(t)
    ls.append(s)
    lt.append(t)

x = input()

def solve():
    for i in range(n):
        if ls[i] == x:
            return sum(lt[i+1:])

print(solve())

Measured memory_bytes: 38384
#include <cstdio>

int X;

int main()
{
	scanf("%d", &X);
	int i=1;
	int sum = 0;
	while(1){
		sum += i;
		if(sum >= X)
			break;
		i ++;
	}
	printf("%d\n", i);
	return 0;
}

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

using namespace std ;

const int N = 1e5 + 10 ;
const int mod = 1e9+7 ;
#define ll long long

int n ;
int a[ N ] ;
int cnt[ N ] ;
ll ans = 0 ;

ll power( int a , int b ) {
	ll ans = 1 , base = a ; 
	while( b ) {
		if( b & 1 ) ans = ans * base % mod ;
		base = base * base % mod ;
		b >>= 1 ;
	}
	return ans ;
}

int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) scanf( "%d" , &a[ i ] ) , cnt[ a[ i ] ] ++ ; 
	for( int i = 0 ; i < n ; i ++ ) {
		if( cnt[ i ] > 2 ) return puts( "0" ) , 0 ;
	}
	if( n & 1 && cnt[ 0 ] != 1 ) return puts( "0" ) , 0 ;
	if( !( n & 1 ) && cnt[ 0 ] ) return puts( "0" ) , 0 ;
	printf( "%lld\n" , power( 2 , n / 2 ) ) ;
} 

Measured memory_bytes: 1024