akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S =sc.next().toCharArray();
		char c = S[0];
		boolean flag = true;
		for(int i =1; i < S.length; i++) {
			if (S[i] == c) {
				flag = false;
				break;
			}
			c = S[i];
		}
		if(flag) out.println("Good");
		else out.println("Bad");
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}

Measured memory_bytes: 256
N = int(input())
prime = {2: 0}
def fact(m):
    flag = 0
    for p in list(prime):
        if m % p == 0:
            prime[p] += 1
            r = m // p
            flag = 1
            if r != 1:
                fact(r)
                break
    if flag == 0: prime[m] = 1
        

if N == 1:
    print(1)
else:
    for i in range(2, N+1): fact(i)
    res = 1
    for i in prime.values():
        res = (res * (i + 1)) % 1000000007
    print(res)
    

Measured memory_bytes: 3064
n,k=map(int,input().split())
r,s,p = map(int,input().split())
t=input()

def score(c):
	if c=="r":
		return p
	elif c=="s":
		return r
	else:
		return s

isUsed = [False]*n
ans = 0
for i in range(n):
	if i < k:
		ans+=score(t[i])
		isUsed[i]=True
	else:
		if t[i] == t[i-k] and isUsed[i-k]:
			continue
		ans+=score(t[i])
		isUsed[i]=True

print(ans)


Measured memory_bytes: 43120
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int a[]=new int[N];
		int sum=0;
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		/*if(sum<=K) {
			System.out.println(sum);
			return;
		}*/
		//System.out.println(sum);
		//ArrayList<Integer> youso=new ArrayList<Integer>();
		for(int i=1;i<=(int)Math.sqrt(sum);i++) {
			if(sum%i==0) {
				i=sum/i;
				int sum2=0;
				int b[]=new int[N];
				for(int x=0;x<N;x++) {
					b[x]=a[x]%i;

				}
				Arrays.sort(b);
				int tmp=N-1;
				for(int x=0;x<N;x++) {
					int p=b[x];
					while(p!=0) {
						//System.out.println(tmp);
						if(i-b[tmp]>=p) {
							b[tmp]=(b[tmp]+p)%i;
							sum2+=p;
							p=0;
							if(b[tmp]==0)tmp--;
						}else {
							sum2+=i-b[tmp];
							p-=i-b[tmp];
							b[tmp]=0;
							tmp--;
						}
					}

				}

				//System.out.println(i+" "+sum2);
				if(sum2<=K) {
					//System.out.println(sum2);
					System.out.println(i);
					return;
				}
				i=sum/i;
			}
		}
		for(int i=(int)Math.sqrt(sum);i>1;i--) {
			if(sum%i==0) {
				//int b[]=new int[N];
				int sum2=0;
				int b[]=new int[N];
				for(int x=0;x<N;x++) {
					b[x]=a[x]%i;

				}
				Arrays.sort(b);
				int tmp=N-1;
				for(int x=0;x<N;x++) {
					int p=b[x];
					while(p!=0) {
						if(i-b[tmp]>=p) {
							b[tmp]=(b[tmp]+p)%i;
							sum2+=p;
							p=0;
							if(b[tmp]==0)tmp--;
						}else {
							sum2+=i-b[tmp];
							p-=i-b[tmp];

							b[tmp]=0;
							tmp--;
						}
					}

				}

				//System.out.println(i+" "+sum2);
				if(sum2<=K) {
					//System.out.println(sum2);
					System.out.println(i);
					return;
				}
			}
		}
		System.out.println(1);
		return;
	}
}


Measured memory_bytes: 27856
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 1e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n, k;
ll a[maxn], b[maxn];

bool read() {
    if (scanf("%d %d", &n, &k) != 2)
        return false;

    forn (i, n)
        scanf("%lld %lld", a + i, b + i);

    return true;
}

void solve() {
    ll ans = 0;

    for (int i = 0; i < n; ++i)
        if ((a[i] | k) == k)
            ans += b[i];

    for (int bit = 30; bit >= 0; --bit)
        if ((k >> bit) & 1) {
            ll cur = 0;

            for (int i = 0; i < n; ++i)
                if ((a[i] >> bit) & 1 ^ 1) {
                    ll x = ((a[i] >> bit) << bit);
                    ll y = ((k >> bit) << bit);

                    if ((x | y) == y)
                        cur += b[i];
                }

            ans = max(ans, cur);
        }

    printf("%lld\n", ans);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 3584
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f[2000][2000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m >> h >> w;
	cout << max(min(m,w)-max(n,h),(LL)0)<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n,w;
	cin>>n>>w;
	ll sum=0;
	ll w1[n+1]={0},v1[n+1]={0};
	for(ll i=1;i<=n;i++){
		cin>>w1[i]>>v1[i];
		sum+=v1[i];
	}
	ll dp[sum+1];
	for(ll i=0;i<=sum;i++){
		dp[i]=1000000000000;
	}
	dp[0]=0;
	// dp[v1[0]]=w1[0];
	for(ll i=1;i<=n;i++){
		for(ll j=sum-v1[i];j>=0;j--){
			dp[j+v1[i]] = min(dp[j+v1[i]],dp[j]+w1[i]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=sum;i++){
		// cout<<" value "<<i<<" weight "<<dp[i]<<endl;
		if(dp[i]<=w){
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back

bool fun(pair<ll,ll> a , pair<ll,ll> b)
{
	return a.second - a.first > b.second - b.first;
}

int main()
{
	ll n,m;
	cin>>n>>m;

	map<ll , vector<ll> > hm;

	ll a[n];

	for(ll i = 0 ; i < n; i++)
	{
		ll t1;
		cin>>t1;

		a[i] = t1;

		hm[t1].pb(i);

		// cout<<a[i]<<" ";
	}

	pair<ll,ll> p[m];

	for(ll i = 0 ; i < m ; i++)
	{
		cin>>p[i].second>>p[i].first;
	}

	sort(p,p+m);
	reverse(p,p+m);

	sort(a,a+n);

	ll k = 0;

	for(ll i = 0 ; i < m ; i++)
	{
		ll t2 = p[i].second;
		while(k < n && t2 > 0)
		{
			// cout<<k<<" "<<p[i].first<<" "<<a[k]<<endl;
			if(a[k] < p[i].first)
			{
				a[k] = p[i].first;
				k++;
				t2--;
			}
			else
			{
				break;
			}
		}
	}

	ll sum = 0;

	for(ll i = 0 ; i < n ; i++)
	{
		// cout<<a[i]<<endl;
		sum += a[i];
	}

	cout<<sum<<endl;

}	

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

struct unionfind {
    vector<int> par; // 各要素の親(根の場合は-1)
    unionfind(int n) {
        par.resize(n, -1);
    }
    int root(int x) { // 要素xの属する集合の根のindexを返す(xが根の場合はx)
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { // 要素xとyを同一の集合(根)に結合
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    bool same(int x, int y) { // 要素xとyが同一の集合に属するか判定
        return root(x) == root(y);
    }
    int size(int x) { // 要素の属する集合の大きさ
        return -par[root(x)];
    }
};

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問の有無

void dfs(int cur, int &cnt) {
    cnt++;
    visited[cur] = true;
    for (edge e : graph[cur]) {
        if (not visited[e.to]) {
            dfs(e.to, cnt);
        }
    }
}

void solve1() {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a;
        cin >> b;
        graph[a].push_back({b, 0});
        graph[b].push_back({a, 0});
    }
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        if (not visited[i]) {
            dfs(i, cnt);
            ans = max(cnt, ans);
        }
    }
    cout << ans << endl;
}

void solve2() {
    int n, m;
    cin >> n >> m;
    unionfind f(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        f.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, f.size(i));
    }
    cout << ans << endl;
}

int main() {
    // solve1();
    solve2();
}

Measured memory_bytes: 27548
#include <stdio.h>
 
int main(void){
	int d, r;
	double a, b;
	double f;

	scanf("%lf", &a);
	scanf(" %lf", &b);
	d = a/b;
	r = (int)a%(int)b;
	f = a/b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 648
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_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

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

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

fn main() {
    let (m, d) = parse_pair::<usize, usize>();

    let min_d = 22;
    let max_d = d + 1;
    let min_d_1 = 2;
    let min_m = 4;
    let max_m = m + 1;

    let count = (min_d..max_d).fold(0, |acc, cd| {
        let d_1 = cd % 10;
        if d_1 < min_d_1 {
            return acc;
        }

        let d_10 = cd / 10;
        let d_product = d_1 * d_10;

        acc + (min_m..max_m).filter(|&m| m == d_product).count()
    });

    println(count);
}


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


int main(void)
{
  int N;
  scanf("%d",&N);
  int i;
  int H[N];
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  int maxH = 0;
  int count = 0;
  for(i=0;i<N;i++){
    if( H[i] >= maxH ){
      count ++;
      maxH = H[i];
    }
  }
  printf("%d", count); 
  return (0);
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int p[12];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> p[i];
    }

    int mx = *std::max_element(p, p + N),
        sum = std::accumulate(p, p + N, 0),
        cost = mx / 2 + (sum - mx);

    std::cout << cost << std::endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <iostream>
using namespace std;

class ASumOfInteriorAngles {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin >> n;
        cout << (n - 2) *(180) << endl;
	}
};


int main() {
	ASumOfInteriorAngles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s, a = "AKIHABARA";

    cin >> s;
    int cnt = 0;

    int i = 0;
    REP(j, s.size())
    {
        cnt += s[j] != 'A';

        while (i < 9 && a[i] != s[j])
            i++;

        if (i >= 9)
        {
            cout << "NO" << endl;
            return 0;
        }

        i++;
    }

    cout << (cnt == 5 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
x = [0]
v = [0]
for _ in range(N):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)
opt_l = [0]
acc_v = 0
for i in range(1, N + 1):
    opt_l.append(max(opt_l[-1], v[i] + acc_v - x[i]))
    acc_v += v[i]
opt_r = [0]
acc_v = 0
for i in range(1, N + 1):
    opt_r.append(max(opt_r[-1], v[-i] + acc_v - (C - x[-i])))
    acc_v += v[-i]
ans = 0
acc_v = 0
for i in range(N + 1):
    ans = max(
        ans,
        acc_v + v[i] - x[i],
        acc_v + v[i] - 2 * x[i] + opt_r[N - i]
    )
    acc_v += v[i]
acc_v = 0
for i in range(N + 1):
    ans = max(
        ans,
        acc_v + v[-i] - (C - x[-i]),
        acc_v + v[-i] - 2 * (C - x[-i]) + opt_l[N - i]
    )
    acc_v += v[-i]
print(ans)


Measured memory_bytes: 18932
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get_nsp
ans=700
S.each do|s|
  ans+=100 if s=="o"
end
puts ans

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

int main() {
	int H, W, j,i;
	cin >> H >> W;

	vector<string> vec(H);


	for (j = 0; j < H; j++) {
			cin >> vec.at(j);
	}

	for (i = 0; i < W+2; i++) {
		cout << "#";
	}

	cout << endl;

	for (i = 0; i < H; i++) {
		cout << "#"+ vec.at(i) + "#"<< endl;
	}

	for (i = 0; i < W + 2; i++) {
		cout << "#";
	}


}

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

int main()
{
	int x, y;
	while (true)
	{
		cin >> x >> y;
		if (x == 0 && y == 0)
		{
			break;
		}
		cout << min(x, y) <<" "<< max(x, y) << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;

int main(){
  cin >> N;
  int ans = 0;
  bool flag = true;
  while(N / 10 > 0) {
    if(N % 10 != 9) flag = false;
    N /= 10;
    ans += 9;
  }

  ans += N - 1;
  if(flag) ans++;
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    int ans_total = 0;
    rep(i, n){
        int ans = 0;
        if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]){
            ans = 2;
        } else if ( a[i] == b[i] && b[i] == c[i]) {
            ans = 0;
        } else {
            ans = 1;
        }
        ans_total += ans;
    }
    cout << ans_total << endl;
 
}



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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

bool _check(ll i){
    string s = to_string(i);
    ll m = s.length();
    if(m % 2 == 1)
        return true;
    else
        return false;
}

int main()
{
    int a , b , ans = 0 , temp = 1;
    cin >> a >> b;

    while(temp < b){
        temp--;
        temp += a;
        ans++;
    }

    cout << ans << "\n";

	return 0;
}


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

int f(int i){
	int ans = 0;
	while(0 < i){
		ans += i%10;
		i /= 10;
	}
	return ans;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		int d = f(i);
		if(a <= d && d <= b){
			sum += i;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << 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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int temp = n % 10;
    if (temp == 3)
        cout << "bon"
             << "\n";
    else if (temp == 0 || temp == 1 || temp == 6 || temp == 8)
        cout << "pon"
             << "\n";
    else
        cout << "hon"
             << "\n";
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

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

  if (a<=b) {
    ans=b-(a+W);
  } else {
    ans=a-(b+W);
  }
  if (ans<0) ans=0;

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

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#define MAX 1000
using namespace std;

int main()
{
	int n,i=0,j=0;
	int S[MAX]={0};
	double a=0.0,m=0.0,temp=0.0;

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

		for(j=0;j<n;j++)
		{
			cin >> S[i] ;
			m = m + S[i] ;
			i++;
		}

	m = m / n ;

	for(i=0;i<n;i++)
	{
		temp = temp + (S[i] - m)*(S[i] - m) ;
	}

	a = temp / n ;

	a = sqrt(a);

	cout << a << endl;

	a = 0.0;
	m = 0.0;
	temp = 0.0;
	i=0;

	}

	return 0;
}

Measured memory_bytes: 1236
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NumDecimals #-}
module Main (main) where
import Control.Applicative
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS
import Data.Function (fix)
import Data.Maybe (fromJust)
import Data.Vector ((!),Vector())
import qualified Data.Vector as V
import Debug.Trace (traceId)
import Debug.Trace (traceShowId)
import System.IO (hFlush)
import System.IO (stdout)
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Mutable as MV
import qualified Control.Monad.ST as ST
import qualified Debug.Trace as Log
import qualified Data.Vector.Generic as GV

getInt :: IO Int
getInt = fst . fromJust . BS.readInt <$> BS.getLine


main :: IO ()
main = do
  let !t1 = V.force $ dpTable 1e6
      !t2 = V.force $ dpTableOdd 1e6
  -- print fs
  fix $ \continue -> do
    x <- getInt
    if (x == 0)
      then return ()
      else do
      putStrLn $ show (t1 V.! x) ++ ' ':show (t2 V.! x)
      hFlush stdout
      continue

f :: Int -> Int
f !n = (n * (n+1) * (n+2)) `div` 6

fs :: Vector Int
fs = V.map f $ V.enumFromTo 1 200

fsOdd :: Vector Int
fsOdd = V.filter odd $ fs

dpTable :: Int -> V.Vector Int
-- dpTable n | traceShow n False = undefined
dpTable n = constructN'' n ge
  where
    ge :: V.Vector Int -> Int
    ge !v
      | k == 0 = 0
      | otherwise       = 1 + V.foldl' (\l r -> min l $!g r) maxBound fs
      where
        k = V.length v
        g !fi
          | k - fi >= 0 = v V.! (k - fi)
          | otherwise   = maxBound

-- constructN' :: Int -> (V.Vector a -> a) -> V.Vector a
-- constructN' !n fun = ST.runST $ do
--     v  <- MV.new n
--     flip fix 0 $ \loop !len -> do
--       if len == n
--         then V.freeze v
--         else do
--         v' <- V.unsafeFreeze v
--         let !x = fun (V.unsafeTake len v')
--         x `seq` MV.write v len x
--         GV.elemseq v' x $ loop (len+1)

constructN'' :: Int -> (V.Vector a -> a) -> V.Vector a
constructN'' !n fun = ST.runST $ do
    v  <- MV.new n
    v' <- V.unsafeFreeze v
    flip fix 0 $ \loop !len -> do
      if len == n
        then return v'
        else do
        let v'' = V.unsafeTake len v'
            !x = fun v''
        GV.elemseq v'' x $ MV.write v len x
        loop (len+1)
    
dpTableOdd :: Int -> V.Vector Int
dpTableOdd n = constructN'' n ge
  where
    ge !v
      | V.length v == 0 = 0
      | otherwise       = 1 + V.foldl' (\l r -> min l (g r)) maxBound fsOdd -- [ v V.! (k - fi) | fi <- fs, k - fi >= 0]
      where
        k = V.length v
        g fi
          | k - fi >= 0 = v V.! (k - fi)
          | otherwise   = maxBound
       
       

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  
  for (int i = 0; i < N - 2; i++) {
    if ('A' == S.at(i) && 'B' == S.at(i + 1) && 'C' == S.at(i + 2)) {
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){	
	ll N,M,pair;
	cin>>N>>M;

	pair=min(N,M/2);
	
	cout<<pair+(M-pair*2)/4<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    vll a(n);
    rep(i, n) cin >> a[i];
    rep(i,n-k){
        if(a[i]<a[k+i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string X, Y;
    cin >> X >> Y;
    long long F[X.length()+1][Y.length()+1];
    for (int i=0; i<=X.length(); i++) F[i][0]=0;
    for (int j=0; j<=Y.length(); j++) F[0][j]=0;
    for (int i=1; i<=X.length(); i++)
    {
        for (int j=1; j<=Y.length(); j++)
        {
            if (X[i-1]==Y[j-1]) F[i][j]=F[i-1][j-1]+1;
            else F[i][j]=max(F[i-1][j], F[i][j-1]);
        }
    }
    //cout << F[X.length()][Y.length()];
    string res="";
    int i=X.length(), j=Y.length();
    while ((i>0) && (j>0))
    {
        if (X[i-1]==Y[j-1])
        {
            res=X[i-1]+res;
            i--;
            j--;
        }
        else if (F[i-1][j]>F[i][j-1]) i--;
        else j--;
    }
    cout << res;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m,q;
    cin >> n >> m >> q;
    vector<vector<int32>> cnt(n+1, vector<int32>(n+1, 0));
    REP(i,m){
        int32 l, r;
        cin >> l >> r;
        cnt[0][r]++;
        cnt[r][0]++;
        if(l+1 <= n){
            cnt[l+1][r]--;
            cnt[r][l+1]--;
        }
        if(l == r){
            cnt[l][l]--;
            if(l+1 <= n){
                cnt[l+1][l]++;
                cnt[l][l+1]++;
                cnt[l+1][l+1]--;
            }
        }
    }
    // REP(i,n+1){
    //     REP(j,n+1){
    //         cout << cnt[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    // cout << "\n";
    REP(i,n+1)REP(j,n){
        cnt[i][j+1] += cnt[i][j];
    }
    REP(i,n+1)REP(j,n){
        cnt[j+1][i] += cnt[j][i];
    }
    // REP(i,n+1){
    //     REP(j,n+1){
    //         cout << cnt[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    REP(i,q){
        int32 p,q;
        cin >> p >> q;
        ANS(cnt[p][q]);
    }
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const int N=4005;
char c[N];
int a[N],tree[2][N],cntb[N][N],cntw[N][N],ind[2][N];
int dp[N][N];
int prev(int x)
{
    return (x&(x-1));
}
int next(int x)
{
    return 2*x-prev(x);
}
void update(int type, int ind, int diff)
{
    while(ind<=N)
    {
        tree[type][ind]+=diff;
        ind=next(ind);
    }
}
int get(int type, int ind1, int ind2)
{
    int ans=0;
    while(ind2)
    {
        ans+=tree[type][ind2];
        ind2=prev(ind2);
    }
    ind1--;
    while(ind1)
    {
        ans-=tree[type][ind1];
        ind1=prev(ind1);
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=2*n;i++)
    {
        cin>>c[i]>>a[i];
        ind[c[i]=='W'][a[i]]=i;
    }
    for(int i=0;i<n;i++)
    {
        cntb[i][0]=get(0,ind[0][i+1]+1,2*n);
        for(int j=1;j<=n;j++)
        {
            update(1,ind[1][j],1);
            cntb[i][j]=get(1,ind[0][i+1]+1,2*n)+cntb[i][0];
        }
        for(int j=1;j<=n;j++)
            update(1,ind[1][j],-1);
        update(0,ind[0][i+1],1);
    }
    for(int i=0;i<n;i++)
        update(0,ind[0][i+1],-1);
    for(int i=0;i<n;i++)
    {
        cntw[i][0]=get(1,ind[1][i+1]+1,2*n);
        for(int j=1;j<=n;j++)
        {
            update(0,ind[0][j],1);
            cntw[i][j]=get(0,ind[1][i+1]+1,2*n)+cntw[i][0];
        }
        for(int j=1;j<=n;j++)
            update(0,ind[0][j],-1);
        update(1,ind[1][i+1],1);
    }
    for(int i=0;i<n;i++)
        update(1,ind[1][i+1],-1);
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0 && j==0) continue;
            if(i==0)
                dp[i][j]=dp[i][j-1]+cntw[j-1][i];
            else if(j==0)
                dp[i][j]=dp[i-1][j]+cntb[i-1][j];
            else
                dp[i][j]=min(dp[i-1][j]+cntb[i-1][j],dp[i][j-1]+cntw[j-1][i]);
        }
    }
    cout<<dp[n][n]<<endl;
    return 0;
}


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e18
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double a, b;
    cin >> a >> b;
    ll c = a * b;
    cout << c << "\n";

    return (0);
}

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

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



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define endl "\n"
const int limit = 1e7 + 1;
const int inf = 1e7;
int n;
double f[310][310][310];
int a[310];
int mod3[3];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    double tmp, x, y, z;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mod3[a[i] % 3]++;
    }
    int i, j, k;
    for (k = 0; k <= n; k++)
    {
        for (j = 0; j <= n; j++)
        {
            for (i = 0; i <= n; i++)
            {
                tmp = i + j + k;
                if (i + j + k == 0)
                    continue;
                if (i + j + k > n)
                    continue;
                x = y = z = 0;
                if (i != 0)
                    x = (double)i / tmp * f[i - 1][j][k];
                if (j != 0)
                    y = (double)j / tmp * f[i + 1][j - 1][k];   
                if (k != 0)
                    z = (double)k / tmp * f[i][j + 1][k - 1];
                f[i][j][k] += x + y + z + (double)n / tmp;
            }
        }
    }
    cout<< setprecision(12) <<f[mod3[1]][mod3[2]][mod3[0]]<<endl;
    return 0;
}

Measured memory_bytes: 225536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std; 

string list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
	int n, l, p;
	string s, ans;

	while(cin >> n){
		if(n==0){return 0;}
		ans = "";
		int* key = new int[n];
		for(int i=0; i<n; i++){ cin >> key[i];}
		cin >> s;
		l = s.length();
		for(int i=0; i<l; i++){ 
			p = list.find(s.substr(i,1)) - key[i%n];
			if(p<1){ p+=104; p=p%52;}
			ans += list.substr(p,1);
		}
		cout << ans << endl;
		delete[] key;
	}	
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
typedef pair<int,int> pii;
#define F first
#define S second

int main(){
    int n;
    cin>>n;
    vector<vector<pii>> vv(n);
    rep(i,n){
        int a;
        cin>>a;
        int m;
        cin>>m;
        rep(j,m){
            int b,c;
            cin>>b>>c;
            vv[a].push_back(pii(b,c));
        }
    }
    priority_queue<pii> pq;
    pq.push(pii(0,0));
    vector<int> dp(n,-1);
    while(pq.size()){
        auto top=pq.top();
        pq.pop();
        if(dp[top.S]>=0) continue;
        dp[top.S]=-top.F;
        for(pii x:vv[top.S]){
            if(dp[x.F]>=0) continue;
            pq.push(pii(top.F-x.S,x.F));
        }
    }
    rep(i,n){
        cout<<i<<" "<<dp[i]<<endl;
    }
}

Measured memory_bytes: 7876
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

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

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	REP (i,n+1) {
		REP (j,n+1) {
			int tmp = r * i + g * j;
			if (tmp <= n && (n-tmp)%b == 0) {
				ans++;
			} 
		}
	}
	cout << ans << endl;
}


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

int main(void){
    ll N,A,B;
    cin>>N>>A>>B;

    ll res = 0;
    if(abs(A-B)%2==0){
        res =(B-A)/2;
    }
    else{
        res = min(A-1,N-B) + (B-A-1)/2 + 1;
    }

    cout<<res<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;cin>>s;
    int n=s.size();
    int x,y;cin>>x>>y;
    vin hori,vert;
    int res=0;int sum=0;
    rep(i,n){
        if(s[i]=='T'){
            if(res%2==0)hori.push_back(sum);
            else vert.push_back(sum);
            res++;
            sum=0;
        }
        else sum++;
    }
    if(res%2==0)hori.push_back(sum);
    else vert.push_back(sum);
    int h=hori.size();
    int v=vert.size();
    if(v==0){
        if(x==n&&y==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }
    vvbo dph(h,vbo(2*n+50,false));
    dph[0][hori[0]+n]=true;
    rep(i,h-1)rep(j,2*n+20){
        if(dph[i][j]){
            dph[i+1][j+hori[i+1]]=true;
            dph[i+1][j-hori[i+1]]=true;
        }
    }
    vvbo dpv(v,vbo(2*n+50,false));
    dpv[0][vert[0]+n]=true;
    dpv[0][-vert[0]+n]=true;
    rep(i,v-1)rep(j,2*n+20){
        if(dpv[i][j]){
            dpv[i+1][j+vert[i+1]]=true;
            dpv[i+1][j-vert[i+1]]=true;
        }
    }
    if(dph[h-1][x+n]&&dpv[v-1][y+n])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 16128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct Item {
    double v, w;
} item[100000];

bool cmp(Item a, Item b) {
    return a.v / a.w > b.v / b.w;
}
int main() {
    int N, W;
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> item[i].v >> item[i].w;
    }
    sort(item, item + N, cmp);
    double ans = 0;
    int i = 0;
    while (W > 0 && i<N) {
        if (item[i].w > W)
            ans += item[i].v * W / item[i].w;
        else ans += item[i].v;
        W -= item[i].w;
        i++;
    }
    printf("%.8lf", ans);
    return 0;
}



Measured memory_bytes: 4892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll ans = 1;
    ll N;
    cin >> N;
    map<ll, ll>cnt;
    rep(i, N){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    for(ll i = (N % 2 ? 0 : 1); i < N; i+=2){
        if(i == 0){
            if(cnt[i]!=1)ans = 0;
        }
        else{
            if(cnt[i] == 2)ans = (ans * 2) % MOD;
            else ans = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 998244353  

void func()
{
    ll n;
    cin>>n;
    ll a[n];
    ll x=0;
    loop(i,0,n){
        cin>>a[i];
        x=x^a[i];
    }
    loop(i,0,n){
        ll t=x^a[i];
        cout<<t<<" ";
    }
    cout<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

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

int main()
{
    int x, n;
    cin >> x >> n;
    int arr[n];
    bool b = false; // checks if the program has found the closest number
    bool inarr = false;
    for (int i=0;i<n;i++){ // inputs value in array
    	cin >> arr[i];
	}
	int cnt = 0; // initial value of displacement
	while (b == false){
		int temp = x-cnt; //initial value will be x - displacement
		for (int i=0;i<2;i++){
			for(int j=0;j<n;j++){ // test if the temp value is one of numbers in arr
				if (temp == arr[j]){
					inarr = true;
				}
			}
			if (inarr == false){ // if it is not then we found our answer
				b = true;
				cout << temp;
				break; // after we break the for loop the b==true statement will let the code out of the while loop
			} else {
				temp = x+cnt; // next option after x - displacement is x + displacement
				inarr = false;
			}
		}
		cnt++; // next option after x +/- displacement is x +/- displacement + 1 
	}
	return 0; // IDK why I even need this
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
const int sz = 200000;
vector<int>g[sz];
bool used[sz];
pii res[sz];
int deg[sz];
int cnt;
set<pii>st;
void ae(int a,int b){
    g[a].emplace_back(b);
    g[b].emplace_back(a);
}
void dfs(int s, int p){
    used[s] = true;
    show(s, g[s]);
    for(int x: g[s]){
        if(x == p)continue;
        if(!used[x]){
            dfs(x,s);
        }else if(st.count(pii(x,s))==0 and st.count(pii(s,x)) == 0){
            res[cnt++] = pii(s,x);
            st.emplace(s,x);
            st.emplace(x,s);
            deg[s]++;
        }
    }
    if(p == -1)return;
    if(deg[s] & 1){
        res[cnt++] = pii(s, p);
        deg[s]++;
    }else{
        res[cnt++] = pii(p, s);
        deg[p]++;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(m & 1){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--,b--;
        ae(a,b);
    }
    dfs(0,-1);
    show(cnt);
    for(int i = 0; i < m; i++){
        cout << res[i].first + 1 << " " << res[i].second + 1 << "\n";
    }
}

Measured memory_bytes: 20224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const ll INF=1000000000000000000ll;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll f(ll a,ll b,ll c,ll d)
{
    ll top=max(max(a,b),max(c,d));
    ll bot=min(min(a,b),min(c,d));
    return top-bot;
}
ll n,a[maxn],sum[maxn];
int main()
{
    while(scanf("%lld",&n)==1)
    {
        for(int i=1;i<=n;i++)
        {
             scanf("%lld",&a[i]);
             sum[i]=sum[i-1]+a[i];
        }
        ll ans=INF;
        for(int mid=2;mid<n-1;mid++)
        {
            int m1=upper_bound(sum+1,sum+1+mid,sum[mid]/2)-sum;
            int m2=upper_bound(sum+1+mid,sum+1+n,(sum[n]-sum[mid])/2+sum[mid])-sum;
            ans=min(ans,f(sum[m1],sum[mid]-sum[m1],sum[m2]-sum[mid],sum[n]-sum[m2]));
            ans=min(ans,f(sum[m1-1],sum[mid]-sum[m1-1],sum[m2]-sum[mid],sum[n]-sum[m2]));
            ans=min(ans,f(sum[m1],sum[mid]-sum[m1],sum[m2-1]-sum[mid],sum[n]-sum[m2-1]));
            ans=min(ans,f(sum[m1-1],sum[mid]-sum[m1-1],sum[m2-1]-sum[mid],sum[n]-sum[m2-1]));
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 3328