akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
#define s(all)   s.begin(),s.end()
#define rep(i,n) for(long long i=0;i<n;i++)
#define ll       long long

int main() {
  ll ans=0;
  ll cnt=0;
  string s;
  cin>>s;
  rep(i,s.size()){
    if(s[i]=='W'){
      ans+=(i-(cnt));
      cnt++;
      cerr<<"at "<<i+1<<":count="<<cnt<<",answer="<<ans<<endl;
    }
  }
  cout<<ans;
}

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

struct Conflict
{
  int l, r;
  Conflict(int l, int r) : l(l),r(r) {}
  bool operator<(Conflict a) {
    return r<a.r;
  }
};

int main() {
  int n,m;
  std::cin >> n >> m;
  std::vector<Conflict> a;
  for(int i=0;i<m;i++) {
    int l,r;
    std::cin >> l >> r;
    a.emplace_back(l,r);
  }
  std::sort(a.begin(),a.end());
  int l = 0;
  int count = 0;
  for(auto c:a) {
    if(c.l>=l) {
      count++;
      l=c.r;
    }
  }
  std::cout << count << '\n';
}


Measured memory_bytes: 1400
#include    <iostream>
#include    <algorithm>

using namespace std;

int main() {
    int c[50], v[50];
    int n;
    int ans = 0;

    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = 0; i < n; i++)
        cin >> c[i];

    int vsum = 0, csum = 0;
    for(int i = 0; i < n; i++) {
        if(c[i] < v[i]) {
            vsum += v[i];
            csum += c[i];
        }
    }

    cout << vsum - csum << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = (ll)1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	string s;	cin >> s;
	int x, y;	cin >> x >> y;
	vint a, b;
	bool turn = false;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'F')	cnt++;
		else {
			if (turn)	b.push_back(cnt);
			else	a.push_back(cnt);
			cnt = 0;
			turn ^= true;
		}
	}
	if (turn)	b.push_back(cnt);
	else	a.push_back(cnt);
	set<int> dp;
	dp.insert(a[0]);
	srep(i, 1, a.size()) {
		set<int> dp2;
		reach(it, dp) {
			dp2.insert(it + a[i]);
			dp2.insert(it - a[i]);
		}
		dp = dp2;
	}
	if (!dp.count(x))	cout << "No" << endl;
	else {
		dp.clear();
		dp.insert(0);
		rep(i, b.size()) {
			set<int> dp2;
			reach(it, dp) {
				dp2.insert(it + b[i]);
				dp2.insert(it - b[i]);
			}
			dp = dp2;
		}
		if (!dp.count(y))	cout << "No" << endl;
		else	cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0;
	rep(bit, (1 << n - 1)) {
		ll tmp = 0;
		rep(i, n) {
			tmp = tmp * 10 + int(s[i] - '0');
			if (bit & (1 << i)) {
				ans += tmp;
				tmp = 0;
			}
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


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

int i,n,old,list[7],a[10];

int main(){
	while(scanf("%d",&n)*n){
		for(;n>9;n-=10){
			scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
			for(i=0;i<10;i++)list[(a[i]>60?60:a[i])/10]++;
		}
		for(;n>0;n--){
			scanf("%d",&old);
			list[(old>60?60:old)/10]++;
		}
		for(n=0;n<7;n++){
			printf("%d\n",list[n]);
			list[n]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    ll ans = 0;
    cin >> s;
    for(int i = 0; i < (int)s.size(); ++i){
        int r = i, a = 0, b = 0;
        while(r < (int)s.size() && s[r] == '<')
            r++, a++;
        while(r < (int)s.size() && s[r] == '>')
            r++, b++;
        ans += 1LL * a * (a + 1) / 2 + 1LL * b * (b + 1) / 2 - min(a, b);
        i = r - 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 900
use std::io::*;
use std::str::FromStr;

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

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let _n = parse_line::<usize>();
    let mut v = parse_line_vec::<f64>();
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());
    let mut iter = v.into_iter();
    let first = iter.next().unwrap();

    let result = iter.fold(first, |acc, cur| 0.5 * (acc + cur));

    println(result);
}


Measured memory_bytes: 4352
/*raghav0307 - Raghav Gupta*/

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

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
#define int ll

signed main(){
	fast_io();
	string s;
	cin >> s;
	int ans = 0;
	int a = 0;
	int n = s.length();
	for(int i = 0; i < n; i++){
		if(s[i] == 'A')	a++;
		else if(s[i] == 'B' and i < n-1 and s[i+1] == 'C'){
			ans += a;
			i += 1;
		}
		else a = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long a, b;
    cin >> a >> b;
    long long A = min(a, b), B = max(a, b);
    long long r = B % A;
    while(r != 0){
        B = A;
        A = r;
        r = B % A;
    }
    long long gcd = A;
    long long ans = a * b / gcd;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int loopcount = scan.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;

        for(int i = 0; i < loopcount; i++){
            switch(scan.next()){
                case "AC":
                    ac++;
                    break;

                case "WA":
                    wa++;
                    break;

                case "TLE":
                    tle++;
                    break;

                case "RE":
                    re++;
                    break;
            }
        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }
}


Measured memory_bytes: 58492
#include <cmath>
#include <stdio.h>
using namespace std;

bool loadable(int P, int n, int k, int w[]) {
	int num_tracks = 1, current_w = 0;

	for (int i=0; i<n; i++) {
		if (current_w + w[i] > P) {
			current_w = 0;
			num_tracks++;
		}

		if (num_tracks > k) return false;

		current_w += w[i];
	}

	return true;
}

int main() {
	int P, P_min, P_max;
	int n, k;
	int w[100000];
	
	scanf("%d %d\n", &n, &k);

	P_min = 1;
	int sum = 0;

	for (int i=0; i<n; i++) {
		scanf("%d", w + i);
		sum += w[i];
		if (P_min < w[i]) P_min = w[i];
	}

	P_max = sum - k + 1;
	
	while (P_max > P_min) {
		P = sqrt((long double)P_max * (long double)P_min);
		if (loadable(P, n, k, w)) {
			P_max = P;
		} else {
			P_min = P + 1; // P doesn't satisfy the condition, so P_min with satisfaction >= (P + 1)
		}
	}
	
	printf("%d\n", P_max);
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll a[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	int l=0,r=n-1,w=1; 
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;
		else ans=(ans*(y%mod))%mod,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

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

using namespace std;

const int mod = 1000000007;
const int INF = 1000000009;

void warshall_floyd(std::vector<std::vector<long long>> &Mat_G) {
  int num_vertex = Mat_G.size();
  for (int k = 0; k < num_vertex; k++) {
    for (int i = 0; i < num_vertex; i++) {
      for (int j = 0; j < num_vertex; j++) {
        Mat_G[i][j] = std::min(Mat_G[i][j], Mat_G[i][k] + Mat_G[k][j]);
      }
    }
  }
}

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

  int N, M, L;
  std::cin >> N >> M >> L;

  std::vector<std::vector<long long>> Graph(N, std::vector<long long>(N, INF));
  for (int i = 0; i < M; i++) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A, --B;
    Graph[A][B] = C;
    Graph[B][A] = C;
  }

  warshall_floyd(Graph);

  std::vector<std::vector<long long>> Graph2(N, std::vector<long long>(N, INF));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (Graph[i][j] <= L) {
        Graph2[i][j] = 1;
        Graph2[j][i] = 1;
      }
    }
  }

  warshall_floyd(Graph2);

  int Q;
  std::cin >> Q;

  while (Q--) {
    int s, t;
    std::cin >> s >> t;

    long long ans = Graph2[s - 1][t - 1];
    std::cout << (ans == INF ? -1 : ans - 1) << "\n";
  }

  return 0;
}

Measured memory_bytes: 4784
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
int i,j,k,l;
static const int MAX_N=10e5;
int mid;
int A[MAX_N];

int main(void){
	int N;
		cin >> N;
		rep(i,0,N){
			cin >> A[i];
			A[i]*=-1;
			mid+=A[i];
		}
	sort(A,A+N);puts((A[N/2]*-1-A[N/2-1]*-1)*-1);
	
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    rep(i,N) { v[i] = 0; }
    rep(i,N) {
        int D;
        cin >> D;
        rep(j,D) {
            int A;
            cin >> A;
            v[A - 1] = 1;
        }
    }
    int sum = 0;
    rep(i, N) {
        if (v[i] == 0) sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3580
def resolve():
    s=input()
    num=0
    for i in range(len(s)):
        for j in range(len(s)+1):
            s1=s[i:j]
            if 'B' not in s1 and 'D' not in s1 and 'E' not in s1 and 'F' not in s1\
                    and 'H' not in s1 and 'I' not in s1 and 'J' not in s1 and 'K' not in s1 and 'L' not in s1 and\
                    'M' not in s1 and 'N' not in s1 and 'O' not in s1 and 'P' not in s1 and 'Q' not in s1 and\
                    'R' not in s1 and 'S' not in s1 and 'U' not in s1 and 'V' not in s1 and 'W' not in s1 and\
                    'X' not in s1 and 'Y' not in s1 and 'Z' not in s1 and len(s1)>=num:
                num=len(s1)
    print(num)
resolve()

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
 
const ll mod = 1e9 + 9;
const int inf = 1e9 + 5;
const int N = 1e5 + 5;

bool check(string s){
    int n=sz(s);
    for(int i=0;i<n/2;++i){
        if(s[i]!=s[n-1-i])
            return false;
    }
    return true;
}

signed main(){
    fastio;
    int i,n;
    string s;
    cin>>s;
    n=sz(s);
    string s1=s.substr(0,(n-1)/2),s2=s.substr((n+3)/2-1,(n-1)/2);
    if(check(s) && check(s1) && check(s2))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

using namespace std;

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

    map<int, int> mp;
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        mp[i] = a;
    }

    int ans = 0;
    for (auto x:mp) {
        if (mp[x.second] == x.first) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#define int long long
using namespace std;

signed main(){
	int n,x,a[100000],res = 0;
	cin >> n >> x;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 1;i < n;i++){
		if(a[i - 1] > x) {
			res += a[i - 1] - x + a[i];
			a[i] = 0;
		}
		else if(a[i - 1] + a[i] > x){
			int d = a[i - 1] + a[i] - x;
			res += d;
			a[i] -= d;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
X = int(input())

bekijos = set()
for b in range(1, 1001, 1):
  for p in range(2, 1001, 1):
    a = b**p
    if a > 1000: break
    bekijos.add(a)

xs = set()
for x in range(1, X+1, 1):
  xs.add(x)    
    
print(max(bekijos&xs))

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N;
    cin >> N;
    int res = 0;
    FOR(i, 1, N + 1) {
        int x;
        cin >> x;
        res += i%2 == 1 && x%2 == 1 ? 1 : 0;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, tmp;
	vector<int> V;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		V.push_back(tmp);
	}
	sort(V.begin(), V.end());
	double ans = V[0];
	for (int i = 1; i < N; i++) {
		ans = (ans + V[i]) / 2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	string g;
	int a, b, c, d;
	string A, B, C, D;
	cin >> g;

	A = g[0];
	B = g[1];
	C = g[2];
	D = g[3];


	a = stoi(A);
	b = stoi(B);
	c = stoi(C);
	d = stoi(D);


	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
 	}

	if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}

	if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}

	if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}

	if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}

	if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}

	if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}

	if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}

	

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 55
#define MAX (1LL << 31) -1
#define MOD 1000000007
typedef long long ll;
typedef pair<int,ll> P;
typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
//#define F function<T(T,T)>

int N,Q;
string S;
vector<char> t,d;

bool checkR(int x){
    for(int i=0;i<Q;i++){
        if(S[x]==t[i]){
            if(d[i]=='L') x--;
            else x++;
        }
        if(x==-1) return false;
        if(x==N) return true;
    }
    return false;
}

bool checkL(int x){
    for(int i=0;i<Q;i++){
        if(S[x]==t[i]){
            if(d[i]=='L') x--;
            else x++;
        }
        if(x==-1) return true;
        if(x==N) return false;
    }
    return false;
}


signed main(){
    
    cin>>N>>Q>>S;
    t.resize(Q);
    d.resize(Q);

    for(int i=0;i<Q;i++) cin>>t[i]>>d[i];
    int ok=N,ng=-1;
    while(ok-ng!=1){
        int mid=(ng+ok)/2;
        if(checkR(mid)) ok=mid;
        else ng=mid;
    }
    int r=ok;
    ok=-1,ng=N;
    while(ng-ok!=1){
        int mid=(ng+ok)/2;
        if(checkL(mid)) ok=mid;
        else ng=mid;
    }
    int l=ok;
    if(l>=r) cout<<N<<endl;
    else cout<<N-( (N-1-r+1)+(l+1) )<<endl;
}

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

int main() {
  vector<char> num(4); // int型の配列変数vecを宣言  
  
  cin >> num.at(0) >> num.at(1) >> num.at(2) >> num.at(3);
  
  for(int i=0; i<4-2; i++) {
    if(num.at(i) == num.at(i+1) && num.at(i) == num.at(i+2)){
	  cout << "Yes" << endl;
	  return 0;
    }
  }
 
  cout << "No" << endl;
}


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

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

  int a, b, c; cin >> a >> b >> c;
  bool flag = false;
  if(a == b && b == c && c == a) flag = true;
  
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

#define N 3
#define N2 9

const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };

struct Puzzle {
	int f[N2];
	int space;
	string path;

	bool operator <(const Puzzle &p) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] == p.f[i])
				continue;
			return f[i] > p.f[i];
		}
		return false;
	}
};

bool isResolved(Puzzle p) {
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] != i + 1) {
			return false;
		}
	}
	return true;
}

string bfs(Puzzle p) {
	queue<Puzzle> Q;
	p.path = "";
	Q.push(p);
	map<Puzzle, bool> M;
	M[p] = true;
	Puzzle u, v;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		if (isResolved(u))
			return u.path;
		int sx = u.space / N;
		int sy = u.space % N;
		for (int r = 0; r < 4; ++r) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= N || ty >= N)
				continue;
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!M[v]) {
				M[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	return "";
}

int main() {
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = bfs(p);
	cout << ans.size() << endl;

	return 0;
}

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

int main() {
    int a, b;
    char op;
    
    while(true) {
        cin >> a >> op >> b;
        if (op == '?') {
            break;
        } else if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else if (op == '/') {
            cout << a / b << endl;
        }
    }
    
    return 0;
}


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

int main(){
   int n;
   cin >> n;
   if (n>=64) cout << 64 << endl;
   else if (n>=32) cout << 32 << endl;
   else if (n>=16) cout << 16 << endl;
   else if (n>=8) cout << 8 << endl;
   else if (n>=4) cout << 4 << endl;
   else if (n>=2) cout << 2 << endl;
   else if (n==1) cout << 1 << endl;
}


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

using namespace std;

const int INF = 100000000;

typedef pair<int ,int> P;
char masu[1003][1003];
int W,H,K,ans=0;
int sx[10],sy[10];
int gx[10],gy[10];

int d[1003][1003];

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

queue<P> que;

void sho(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[j][i]=INF;
        }
    }
    while(que.size()){
        que.pop();
    }
}

int bfs(){
    for(int i=0;i<K;i++){
        sho();
        que.push(P(sx[i],sy[i]));
        d[sx[i]][sy[i]]=0;
        while(que.size()){
            P p=que.front();que.pop();
            if(p.first==gx[i+1]&&p.second==gy[i+1])break;
            for(int j=0;j<4;j++){
                int nx = p.first+dx[j],ny = p.second+dy[j];
                if(0<=nx&nx<W&&0<=ny&&ny<H&&masu[nx][ny]!='X'&&d[nx][ny]==INF){
                    que.push(P(nx,ny));
                    d[nx][ny] = d[p.first][p.second] + 1;
                }
            }
        }ans+=d[gx[i+1]][gy[i+1]];
    }
    return ans;
}

signed main(){
    cin >> H >> W >> K;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> masu[j][i];
            int a=masu[j][i]-'0';
            if(isdigit(masu[j][i])){
                gx[a]=j,gy[a]=i,sx[a]=j,sy[a]=i;
            }else if(masu[j][i]=='S'){
                sx[0]=j,sy[0]=i;
            }
        }
    }
    int answer = bfs();
    cout << answer << endl;
return 0;
}

Measured memory_bytes: 10052
using System;

class program
{
    public static int Main()
    {
        var str = Console.ReadLine();
        var a = int.Parse(str.Split(' ')[0]);
        var b = int.Parse(str.Split(' ')[1]);

        Console.WriteLine("{0} {1} {2:f8}", a/b, a%b, System.Math.Round((double)a/b, 8));

        return 0;
    }
}

Measured memory_bytes: 5700
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
typedef long int l;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
using namespace std;
#define MAX 1000001 
l spf[MAX];
void precompute()
{
	spf[1] = 1;
	for (l i = 2; i < MAX; i++)
		spf[i] = i;

	for (l i = 4; i < MAX; i += 2)
		spf[i] = 2;

	for (l i = 3; i * i < MAX; i++)
	{
		if (spf[i] == i)
		{
			for (l j = i * i; j < MAX; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

int main()
{
	FAST;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	vector<ll> red;
	vector<ll> green;
	vector<ll> blue;
	f(i, 0, n)
	{
		if (s[i] == 'R')
			red.push_back(i);
		else if (s[i] == 'B')
			blue.push_back(i);
		else
			green.push_back(i);
	}
	ll r = red.size(), g = green.size(), b = blue.size();
	ll ans =0;
	f(i, 0, r)
	{
		f(j, 0, g)
		{
			f(k, 0, b)
			{
				ll mini = min(red[i], min(green[j], blue[k]));
				ll maxi = max(red[i], max(green[j], blue[k]));
				ll mid = red[i] + green[j] + blue[k] - mini - maxi;
				if ((2 * mid) != mini + maxi)
					ans += 1;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<math.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1&&b==2)
    {
        printf("3\n");
    }
    else if(a==1&&b==3)
    {
        printf("2\n");
    }
    else if(a==2&&b==1)
    {
        printf("3\n");
    }
    else if(a==3&&b==1)
    {
        printf("2\n");
    }
    else if(a==2&&b==3)
    {
        printf("1\n");
    }
    else if(a==1&&b==2)
    {
        printf("3\n");
    }
    else if(a==3&&b==2)
    {
        printf("1\n");
    }
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c=0;cin>>a>>b;
  vector<vector<ll>>d(a,vector<ll>(b));
  rep(i,a){
    rep(o,b)cin>>d[i][o];
  }
  rep(i,a){
    for(ll o=i+1;o<a;o++){
      ll e=0;
      double f;
      rep(j,b)e+=abs(d[i][j]-d[o][j])*abs(d[i][j]-d[o][j]);
      f=sqrt(e);
      e=sqrt(e);
      if(e==f)c++;
    }
  }
  cout<<c;
}



Measured memory_bytes: 27140
#include <stdio.h>
#include <math.h>

int main(void){

  int h,w,k;
  scanf("%d %d %d", &h, &w, &k);
  char chocolate[h][w];
  for (int i = 0; i < h; i++) {
    scanf("%s", chocolate[i]);
  }

  int white[h];
  int h_cut[h-1];
  for (int i = 0; i < h-1; i++) {
    h_cut[i] = 0;
  }
  long cuts;
  long min_cuts = (h-1)*(w-1);

  int flag;

  int width;

  for (int i = 0; i < pow(2,h-1); i++) {
    cuts = 0;
    for (int j = 0; j < h-1; j++) {
      cuts += h_cut[j];
    }
    for (int j = 0; j < h; j++) {
      white[j] = 0;
    }
    width = 0;
    for (int j = 0; j < w; j++) {
      width++;
      if (h_cut[0] == 0) {
        white[0] = chocolate[0][j] - '0';
      } else {
        white[0] += chocolate[0][j] - '0';
      }
      for (int l = 1; l < h-1; l++) {
        if (h_cut[l] == 0) {
          if (h_cut[l-1] == 0) {
            white[l] = white[l-1];
            white[l] += chocolate[l][j] - '0';
          } else {
            white[l] = chocolate[l][j] - '0';
          }
        } else {
          if (h_cut[l-1] == 0) {
            white[l] += white[l-1];
          }
          white[l] += chocolate[l][j] - '0';
        }
      }
      if (h_cut[h-2] == 0) {
        white[h-1] += white[h-2];
      }
      white[h-1] += chocolate[h-1][j] - '0';

      flag = 0;
      for (int l = 0; l < h; l++) {
        if (white[l] > k) {
          flag = 1;
          break;
        }
      }
      if (flag == 1 && width > 1) {
        cuts++;
        width = 0;
        for (int l = 0; l < h; l++) {
          white[l] = 0;
        }
        j--;
      }
      if (flag == 1 && width == 1) {
        cuts = (h-1)*(w-1);
        break;
      }
    }

    //printf("%d\n", cuts);
    if (cuts < min_cuts) {
      min_cuts = cuts;
    }

    h_cut[0]++;
    for (int j = 0; j < h-1; j++) {
      if (h_cut[j] == 2) {
        h_cut[j+1]++;
        h_cut[j] = 0;
      } else {
        break;
      }
    }
  }

  printf("%ld\n", min_cuts);

  return 0;
}

Measured memory_bytes: 128
S = input()

mod = [0] * 2019
mod[0] = 1
digit = 1
temp = 0
 
for i in S[::-1]:
    temp = (temp + digit * int(i)) % 2019
    mod[temp] += 1
    digit = (digit * 10) % 2019

ans = 0
for m in mod:
    ans += m * (m - 1) // 2

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  int A = 0;
  int B = 0;
  int AB = 0;
  int ans = 0;
  for (int i=0; i<N; i++) {
    cin >> s[i];
    if (s[i][s[i].size()-1] == 'A') {
      A++;
    }
    if (s[i][0] == 'B') {
      B++;
    }
    if (s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') {
      AB++;
    }
    for (int j=0; j<s[i].size()-1; j++) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') {
        ans++;
      }
    }
  }
  if (max(A,B) == AB && AB != 0) {
    ans--;
  }
  cout << ans + min(A,B) << endl;
}

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

namespace ConsoleApp2
{
    public class Program
    {
        static long mod = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            long[] NH = Read(Console.ReadLine());
            long N = NH[0];
            long H = NH[1];
            long maxA = 0;
            List<long[]> swordDamages = new List<long[]>();

            for (int i = 0; i < N; i++)
            {
                long[] sword = Read(Console.ReadLine());
                swordDamages.Add(sword);
                maxA = Math.Max(maxA, sword[0]);
            }

            swordDamages.Sort((x, y) => (int)(y[1] - x[1]));

            long count = 0;

            foreach (var item in swordDamages)
            {
                if (maxA < item[1])
                {
                    H -= item[1];
                    count++;
                    if (H < 1)
                    {
                        Console.WriteLine(count);
                        Console.ReadLine();
                        return;
                    }
                }
            }

            if (H % maxA == 0)
            {
                count += H / maxA;
            }
            else
            {
                count += H / maxA + 1;
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }

        private static long[] Read(string input)
        {
            string[] strings = input.Split(' ');
            long num = strings.Length;
            long[] ints = new long[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = long.Parse(strings[i]);
            }

            
            return ints;
        }
    }
}


Measured memory_bytes: 25784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	string s;
	cin >> s;
	s += 'T';
	int x, y;
	cin >> x >> y;
	x += 8000; y += 8000;
	vector<int> dx, dy;
	int n = s.size(); int c = 0; bool fi = true; bool isx = true;
	rep(i, n) {
		if (s[i] == 'F') c++;
		else {
			if (fi) {
				x -= c;
				fi = false;
			}
			else if (isx) dx.pb(c);
			else dy.pb(c);
			c = 0; isx = !isx;
		}
	}
	if (x < 0) {
		cout << "No\n";
		return 0;
	}
	vector<bitset<16000>> dpx(10010), dpy(10010);
	dpx[0][8000] = true; dpy[0][8000] = true;
	rep(i, dx.size()) dpx[i + 1] = (dpx[i] << dx[i]) | (dpx[i] >> dx[i]);
	rep(i, dy.size()) dpy[i + 1] = (dpy[i] << dy[i]) | (dpy[i] >> dy[i]);
	if (dpx[dx.size()][x] && dpy[dy.size()][y]) cout << "Yes\n";
	else cout << "No\n";
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[132];
    char t[132];

    Scs(s);
    Scs(t);

    int ans = 0;
    Rep(i,3) ans += s[i] == t[i];

    printf ("%d\n", ans );

    return 0;
}



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

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=acos(-1);

bool comp(P p1, P p2){
    if (p1.first != p2.first) {
        return p1.first < p2.first;
    }
    else if (p1.second != p2.second) {
        return p1.second > p2.second;
    }
    else {
        return true;
    }
}


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

    int a[N];
    map<int,int> m;

    rep(i,N) {
        cin >> a[i];
        if (!m.count(a[i])) {
            m[a[i]] = 1;
        }
        else {
            m[a[i]]++;
        }
    }

    int ans = 0;
    int value,n;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        n = iter->first;
        value = iter->second;
        if (n==value) {
            continue;
        }
        else if (n<value) {
            ans += value-n;
        }
        else {
            ans += value;
        }
    }
 

    cout << ans << endl;

}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int[] A = new int[N]; 
        for(int i = 0; i < N; i++){
            A[i] = input.nextInt();
        }
        int Times = 1;
        for(int i = 0; i < N; i++){
            Times *= 3;
        }
        System.out.println(Times - similarA(N, A));
    }
    private static int similarA(int N, int[] A){
        int times = 1;
        int kind;
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0){
                kind = 1;
            }
            else{
                kind = 2;
            }
            times *= (3 - kind);
        }
        return times;
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[200+7];
	cin>>s;
	int n;
	n=strlen(s)-1;
	for(int i=1;i<strlen(s);i++)
	{
		int count=0;
		int cnt=0;
		//cout<<n<<endl;
		if(n%2==0)
		{
			for(int j=0;j<n/2;j++)
			{
				if(s[j]==s[n/2+j])
					count++;
					//cout<<count<<endl;
				if(count==n/2)
				{
					cnt=1;
					cout<<n<<endl;
				}
			}
	    }
	    n--;
	    if(cnt==1)
	    break;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans=0;
    for(ll i=k; i<n+2; i++){
        ans += (i*n - i*i + i + 1)%MOD;
    }
    printf("%lld\n", ans%MOD);
    return 0;
}

Measured memory_bytes: 3764
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
s,t=input().split()
ans=[]
for i in range(n):
    ans.append(s[i])
    ans.append(t[i])
print(*ans,sep="")

Measured memory_bytes: 38256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int a = sc.nextInt();
        final int b = sc.nextInt();
        final int c = sc.nextInt();
        Set<Integer> se = new HashSet<Integer>();
        se.add(a);
        se.add(b);
        se.add(c);
        System.out.println(se.size());
    }
}


Measured memory_bytes: 21972
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);*/

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

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

struct point
{
    LL x,y;
}s[55],c[55];

int main()
{
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    rep(i,n)cin>>s[i].x>>s[i].y;
    rep(i,m)cin>>c[i].x>>c[i].y;
    rep(i,n)
    {
        LL mn=400000004,flag=-1;
        rep(j,m)
        {
            LL tmp=abs(s[i].x-c[j].x)+abs(s[i].y-c[j].y);
            if(tmp<mn)
            {
                flag=j;
                mn=tmp;
            }
        }
        cout<<flag+1<<endl;
    }
    return 0;
}

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

int main(){
  int A, B , K;
  cin >> A >> B >> K;
  for(int i = min(A,B); i >= 1; i--){
    if(A % i == 0 && B % i == 0){
      K--;
     if(K == 0){
       cout << i << endl;
     }
    }
  }
}
    

Measured memory_bytes: 256
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc027/tasks/agc027_b

まず、最適な動きはどのような条件を満たすか、を考えるべき

ある1回の、ゴミ箱から出発し、取る予定のごみをすべて取って戻る。
の動作では、最も遠いゴミまで移動し、復路で回収していくのが最適なのは自明

少なく値も1度は右端に行くので、その時を考えてみよう？
2つしかない場合を考えてみる x=lとx=r

1. 右と左を1回で持ち帰る

    X*3 + r + (r-l)*2^2 + l*3^2
    
2. 右と左を分けて持ち帰る

    X*4 + r + r*2^2 + l + l*2^2

式2-式1 = X+2l*2^2 + l + l*3^2
        = X

？？？？？？？
ちょっとまて、ギャグか？

右端からk個までのゴミを一度に取るコストをPとする
ゴミ箱からの距離yのゴミが増えたと考えると、
分けて取る場合コストは、

P+2X + y+4*y = P+2X+5y

一緒に取る場合のコストは

P+X + {(k+2)^2-(k+1)^2}y
= P+X+(2k+3)y

一緒に取ったほうが良い条件は
X+(2-2k)y > 0
である

(2-2k) <= 0 であるので、yが大きい方がこの式は成立しずらい
貪欲に取っていけばO(N**2)で部分点か？

一緒に取った場合の削減分は↑である(最大でX削減できる)
k=1なら、yに関わらず確定でX削減できるやん？
つまり、2個ずつ取っていくのが最適か？
うーんそうでもなさそう？
少なくとも個別よりN//2*Xは削減できるのは確定
yが大きい奴は寄与が小さくなりがちなので、1つめ、or2つめに置くべき。
また、3つめ以降はyが小さい奴にkが大きい奴を置いたほうが良いので、貪欲に決まる？

結果として、3つ目以降に置くゴミの数(or 1,2番目に据える数)を決めれば、あとは累積和などを用いてO(lonN)で決定？
N*調和級数の和の計算量になる
"""

N,X = map(int,input().split())

y = list(map(int,input().split()))
ys = [0]
for i in range(N):
    ys.append(ys[-1] + y[i])

origin = X*2*N
for i in range(N):
    origin += 5 * y[i]
    
ans = N//2 * X
#print (origin,ans)

for i in range(1,N//2+1):

    now = i * X

    nn = 2
    nind = N-i*2
    while True:

        if nind-i <= 0:
            now += X*nind + (2-2*nn)*ys[nind]
            break
        else:
            now += X*i + (2-2*nn)*(ys[nind]-ys[nind-i])
            nind -= i
            nn += 1

    ans = max(ans,now)
    #print (i,now)

print (origin-ans)


Measured memory_bytes: 97872
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int n;
  cin >> n;
  int a[n], t[n];
  rep(i, n) {
    cin >> a[i];
    t[i] = a[i];
  }
  sort(t, t + n);
  rep(i, n) {
    if(a[i] == t[n - 1]) cout << t[n - 2] << endl;
    else cout << t[n - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
// ss_wk参考
class Rooted_Tree
{
public:
	int id;
	int parent;
	int sibling;//兄弟
	int depth;//深さ
	int height;//高さ
	string type;//種類
	int degree;//字数
	vector<int> child;//子供
	Rooted_Tree(){
		id =parent= sibling =degree =depth =height = -1;
		type ="non";
	}
};
//再帰で木をたどり高さと深さを求める
int fill_depth(vector<Rooted_Tree> &rt,int id,int depth){
	int buf =-1;
	rt[id].depth =depth;
	rt[id].height = 0;
	for(int i =0;i <rt[id].degree;i++){
		buf = fill_depth(rt, rt[id].child[i], depth+1);
		rt[id].height =max(rt[id].height,buf);
	}
	return rt[id].height+1;
}
bool asc(const Rooted_Tree &right,const Rooted_Tree &left){
	return right.id <left.id;
}

int main(){
	int n;
	vector<Rooted_Tree> rt;
	cin>>n;
	for(int i =0;i < n;i++){
		Rooted_Tree buf;
		cin>>buf.id;
		buf.degree = 0;
		for(int j =0;j <2;j++){
			int i_buf;
			cin>>i_buf;
			if(i_buf !=-1){
				buf.degree++;
				buf.child.push_back(i_buf);
			}
		}
		rt.push_back(buf);
	}
	//id番号でsort
	sort(rt.begin(),rt.end(),asc);
	 //ID==iのnodeが持っている子のnodeを埋めていく。
    //子が　(いない場合)、一人の場合、二人の場合の三つで場合分け。
	for(int i =0;i < n;i++){
		if(rt[i].degree==1){
			rt[rt[i].child[0]].parent =rt[i].id;
		}else if(rt[i].degree==2){
			rt[rt[i].child[0]].parent =rt[i].id;
			rt[rt[i].child[0]].sibling =rt[i].child[1];

			rt[ rt[i].child[1] ].parent=rt[i].id;
			rt[ rt[i].child[1] ].sibling=rt[i].child[0];
		}
	}
	for(int i =0;i < n;i++){
		if(rt[i].parent==-1){
			rt[i].type ="root";
			fill_depth(rt, i, 0);
		}else{
			if(rt[i].degree!=0)rt[i].type ="internal node";
			else rt[i].type ="leaf";
		}
	}
	for(int i=0; i<n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", rt[i].id, rt[i].parent, rt[i].sibling, rt[i].degree, rt[i].depth, rt[i].height, rt[i].type.c_str());
	}

	return 0;
}

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

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

  string s;
  string intersection;
  for (char c = 'a'; c <= 'z'; c++)
    for (int i = 0; i < 50; ++i)
      intersection.push_back(c);

  rep(i,0,n-1) {
    cin >> s;
    sort(s.begin(), s.end());
    string t;
    set_intersection(
      s.begin(), s.end(),
      intersection.begin(), intersection.end(),
      std::back_inserter(t)
    );
    intersection = t;
  }

  for (char c : intersection) cout << c;
  cout << endl;
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll A=in<ll>(),B=in<ll>(),X=in<ll>();

	if(!A){
		out(B/X+1LL);
	}
	else out(B/X-(A-1LL)/X);
	return 0;
}


Measured memory_bytes: 256