akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var s string
	fmt.Scan(&s)
	l := len(s)
	r := make([]int, l)
	for i := 0; i < l-1; i++ {
		if s[i] == 'R' && s[i+1] == 'L' {
			for j := i; j >= 0; j-- {
				if s[j] != 'R' {
					break
				}
				if (j-i)%2 == 0 {
					r[i]++
				} else {
					r[i+1]++
				}
			}
			for j := i + 1; j < l; j++ {
				if s[j] != 'L' {
					break
				}
				if (j-i)%2 == 0 {
					r[i]++
				} else {
					r[i+1]++
				}
			}
		}
	}
	for i := 0; i < l; i++ {
		if i == 0 {
			fmt.Printf("%d", r[i])
		} else {
			fmt.Printf(" %d", r[i])
		}
	}
	fmt.Println("")
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans=1;
ll cnt[3];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>x;
		ll tmp=(cnt[0]==x) + (cnt[1]==x) + (cnt[2]==x);
		ans=ans*tmp%mod;
		for (int j=0; j<3; j++) if (cnt[j]==x){
			cnt[j]++;
			break ;
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int,input().split())))
p = []
for i in range(n):
    p.append((list(map(int,input().split()))))

ans = -1000000000
for i in range(1,1024):
    pr = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if i>>k & 1 == 1 and f[j][k] == 1:
                count += 1
        pr += p[j][count]
    ans = max(ans,pr)
print(ans)

Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define inf 1000000000000


int32_t main()
{
	IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("int.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif*/
   	int n,m;
   	cin>>n>>m;
   	vector<int> f(n+1,0);
   	for(int i=0;i<m;i++)
   	{
   		int u,v;
   		cin>>u>>v;
   		f[u]^=1;
   		f[v]^=1;
   	}
   	int ch=0;
   	for(int i=1;i<=n;i++)
   	{
   		ch|=f[i];
   	}
   	if(ch)
   		cout<<"NO";
   	else
   		cout<<"YES";
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;
const int N=20005;

int tot;

std:: deque <int> L,R;

void solve(LL n) {
	if (n==1) return ;
	solve(n/2);
	L.push_front(++tot);
	R.push_front(tot);
	if (n&1) {
		L.push_front(++tot);
		R.push_back(tot);
	}
}

int main(void) {
	LL n; scanf("%lld",&n);
	solve(n+1);
	printf("%d\n", L.size()+R.size());
	for (int i=0;i<L.size();++i) printf("%d ", L[i]);
	for (int i=0;i<R.size();++i) printf("%d ", R[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 256
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll mod=1e9+7;
const ll maxn=1e9+10,maxp=10110;

ll n,ans;
map <ll,ll> mp;
vector <ll> ve;

int main(){
	FAST_IO;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		ve.pb(x);
		mp[x]++;
	}
	sort(ve.begin(),ve.end());
	vector <ll>::iterator itr;
	itr=unique(ve.begin(),ve.end());
	ve.resize(distance(ve.begin(),itr));
	for(int i=0;i<ve.size();i++){
		for(int j=0;j<i;j++){
			for(int k=0;k<j;k++){
				if((ve[i]<ve[j]+ve[k])&&(ve[j]<ve[i]+ve[k])&&(ve[k]<ve[i]+ve[j])){
					ans+=mp[ve[i]]*mp[ve[j]]*mp[ve[k]];
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3708
#pragma region include
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <map>
    #include <string>
    #include <queue>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <cstdio>
    #define ALL(obj) (obj).begin(),(obj).end()
    #define RALL(obj) (obj).rbegin(),(obj).rend()
    #define REP(i, n) for(int i = 0; i < n; i++)
    #define REPR(i, n) for(int i = n; i >= 0; i--)
    #define FOR(i, m, n) for(int i = m; i < n; i++)
    #define MOD 1000000007
    #define INF 1000000000
    #define LLINF 4000000000000000000
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    #pragma endregion
     
    //#define __DEBUG__
    #ifdef  __DEBUG__
    #define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
    // vector出力
    template<typename T>
    ostream& operator << (ostream& os, vector<T>& v) {
        os << "{";
        REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
        os << "}";
        return os;
    }
    // pair出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, pair<T, U>& p) {
        return os << "(" << p.first << ", " << p.second << ")";
    }
    // map出力
    template<typename T, typename U>
    ostream& operator << (ostream& os, map<T, U>& map_var) {
        os << "{";
        for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
            os << "(" << itr->first << ", " << itr->second << ")";
            itr++;
            if (itr != map_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    // set 出力
    template<typename T>
    ostream& operator << (ostream& os, set<T>& set_var) {
        os << "{";
        for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
            os << *itr;
            ++itr;
            if (itr != set_var.end()) os << ", ";
            itr--;
        }
        os << "}";
        return os;
    }
    #endif
     
    int main() {
        cin.tie(0); ios::sync_with_stdio(false);
        string S;
        cin >> S;
        int a, b;
        int ans = 0;
        a = (S[0] - '0') * 10 + (S[1] - '0');
        b = (S[2] - '0') * 10 + (S[3] - '0');
        if (1 <= a && a <= 12) {
            ans += 1;
        }
        if (1 <= b && b <= 12) {
            ans += 2;
        }
        switch (ans) {
            case 0:
                cout << "NA" << endl;
                break;
            case 1:
                cout << "MMYY" << endl;
                break;
            case 2:
                cout << "YYMM" << endl;
                break;
            case 3:
                cout << "AMBIGUOUS" << endl;
                break;
        }
        getchar(); getchar();
    }

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

int cnt = 0;
bool path[9][9] = {};
int n, m;

void solve(int before, bool visit[]){
    bool judge = true;
    for(int i = 1; i <= n; i++){
        if(!visit[i])   judge = false;
    }

    if(judge){
        cnt++;
        return;
    }

    for(int j = 1; j <= n; j++){
        if(path[before][j] && !visit[j]){
            visit[j] = true;
            solve(j, visit);
            visit[j] = false;
        }
    }
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        path[a][b] = path[b][a] = true;
    }

    bool visit[n+1];
    for(int i = 1; i <= n; i++)  visit[i] = false;
    visit[1] = true;
    
    solve(1, visit);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int i;
	char a[4];
	scanf("%s", a);
	if((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2]== a[3]))
        {
        	printf("Yes\n");
        }
   	    else 
       	{
        	printf("No\n");
        }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, day, x;
  int i;

  scanf("%d %d %d", &n, &day, &x);

  for (i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    x += ((day-1)/num + 1);
  }

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

  return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

double func(int i, int j, int k, int N, VVV<double>&dp) {
    if (dp[i][j][k] != -1) {
        return dp[i][j][k];
    }

    if (i + j + k == 0) {
        return 0;
    }

    double ans = 0.0;
    if (i > 0) {
        ans += func(i - 1, j, k, N, dp) * i;
    }
    if (j > 0) {
        ans += func(i + 1, j - 1, k, N, dp) * j;
    }
    if (k > 0) {
        ans += func(i, j + 1, k - 1, N, dp) * k;
    }
    ans += N;
    ans *= 1.0 / (i + j + k);

    return dp[i][j][k] = ans;

}

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

	int N;
	cin >> N;
	V<int> A(4, 0);
	FOR(i, 0, N) {
	    int a;
	    cin >> a;
	    A[a]++;
	}

	VVV<double> dp(301, VV<double>(301, V<double>(301, -1)));
	cout << fixed << setprecision(10) << func(A[1], A[2], A[3], N, dp) << endl;

	return 0;
}

Measured memory_bytes: 216960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> E(N);
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		E[i] = p;
	}

	ll max = 0;
	ll e = 0;
	for (int j = 0; j < K; j++) {
		e += E[j];
	}
	max = e;

	for (int i = 1; i < N - K + 1; i++) {
		e -= E[i - 1];
		e += E[i + K - 1];
		if (max < e) {
			max = e;
		}
	}
	
	cout << setprecision(15) << (double)max / 2 + K / 2.0 << endl;

}

Measured memory_bytes: 1792
n,m = map(int, input().split())
step = []

now = 0
for i in range(m):
  next = int(input()) - 1
  step.append(next - now)
  now = next + 2

step.append(n-now)  
step.sort()

def fibo():
  s = []
  a = 1
  b = 1
  s.append(a)
  s.append(b)
  for i in range(n):
    c = a+b
    a = b
    b = c
    s.append(c)
  return s

ans = 1

if step[0] < 0:
  ans = 0

else:
  f = fibo()
  for i in step:
    ans *= f[i]

print(ans % 1000000007)

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

using namespace std;

int main() {
    
    int h,a;
    
    cin>>h>>a;
    
    if(h%a==0) {
        cout<<h/a;
        return 0;
    }
    
    cout<<h/a+1;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define pii pair<int,int>
#define it set<int>::iterator
 
multiset<int> st[100010];
map<pii,int> mp,bo;
queue<pii> q;
 
int fa[100010],n;
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
inline pii work(int x,int y) { return (x>y)?pii(y,x):pii(x,y); }
 
inline int find(int x) { return (x==fa[x])?x:fa[x]=find(fa[x]); }
 
int main()
{
    n=rd();
    for (int i=1;i<=n;i++) fa[i]=i;
    for (int i=1;i<=2*n-2;i++)
    {
        int x=rd(),y=rd();
        pii hh=work(x,y);
        st[x].insert(y);st[y].insert(x);
        if ((++mp[hh])>1) q.push(hh),bo[hh]=true;
    }
    while (--n)
    {
        int x,y;
        while (233)
        {
            if (q.empty()) { puts("NO");return 0; }
            x=find(q.front().first);
            y=find(q.front().second);
            q.pop();
            if (x!=y) break;
        }
        if (st[x].size()>st[y].size()) swap(x,y);
        fa[x]=y;
        for (it i=st[x].begin();i!=st[x].end();i++)
        {
            int hh=find(*i);
            if (hh==y) continue;
            st[y].insert(hh);st[hh].insert(y);
            pii h=work(y,hh);
            if ((++mp[h])>1&&!bo.count(h)) q.push(h),bo[h]=true;
            st[hh].erase(st[hh].find(x));
        }
        st[y].erase(x);st[x].clear();
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 43136
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin>>a>>b>>c;
  if( ((a==b)and b!=c) or ((b==c) and c!=a) or ((c==a) and c!=b))
    cout<<"Yes\n";
  else cout<<"No";
}

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

ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a+b, a, b))

ab.sort(key= lambda x:x[0])

ans = 0
for i in range(n):
    v, a, b = ab.pop()
    if i % 2 == 0:
        ans += a
    else:
        ans -= b

print(ans)


Measured memory_bytes: 22136
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  map<int, int> m;
  REP(i, N){
    int d;
    cin >> d;
    m[d]++;
  }

  int M;
  cin >> M;

  bool ans = true;
  REP(i, M){
    int d;
    cin >> d;
    m[d]--;
    if(m[d] < 0) ans = false;
  }

  ans? YES: NO;

  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 205;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

char s[N];
int n;
bool g[N][N];
int q[N], head, tail, level[N];

int Calc(int S) {
	int ret = 1;
	mset(level, 0);
	level[S] = 1;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		for (int i = 1; i <= n; ++i) {
			if (!g[u][i]) continue;
			if (level[i] && abs(level[u] - level[i]) == 1) {
				continue;
			} else if (level[i]) {
				return -1;
			}
			level[i] = level[u] + 1;
			ret = max(ret, level[i]);
			q[++tail] = i;
		}
	}
	return ret;
}

void init() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (int j = 1; j <= n; ++j) {
			g[i][j] = s[j] - '0';
		}
	}
}

void solve() {
	int ans = -1;
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, Calc(i));
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int TapNumber = 1;
  int PlugNumber = A;
  
  //if (B == 1) cout << 0 << endl;
  //else if (A >= B) cout << 1 << endl;
  //else {

  while (PlugNumber < B) {
    PlugNumber += A - 1;
    TapNumber++;
  }
    
  if (B == 1) cout << 0 << endl;
  else cout << TapNumber << endl;
}


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


#define REP(i,n) for(int i=0;i<int(n);i++)

int main(){ 
    int N,a,b;
    cin >> N;
    int ans =0;
    REP(i, N){
        cin >> a >> b;
        if(a == b){
            ans += 1;
        }
        else ans = 0;
        if (ans ==3) break;
    }
    if(ans == 3){
        cout << "Yes";
    }
    else cout << "No";    


}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ans = new List<int>();
		for(int i=X-K+1;i<=X+K-1;i++) ans.Add(i);
		Console.WriteLine(String.Join(" ",ans));
		
		
	}
	int K,X;
	public Sol(){
		var d = ria();
		K = d[0]; X = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
n, x = map(int, input().split())
l = list(map(int, input().split()))
cumlate = [0]*(n+1)
for i in range(n):
    cumlate[i+1] = cumlate[i] + l[i]
    if x < cumlate[i+1]:
        print(i+1)
        exit()
else:
    print(n+1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	int n; cin >> n;
	int i, ans;

	ans = 0;

	while(1){
		if( n < pow(2, ans) )
			break;

		ans++;
	}
	
	cout << pow(2, --ans) << endl;
	return 0;
}

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

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

    int count_4 = 0;
    int count_2 = 0;
    int a;

    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 4 == 0) {
            count_4++;
        }
        else if (a % 2 == 0) {
            count_2++;
        }
    }

    int count = count_4 + count_2 / 2;

    if (count >= (n / 2)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

//ポイント：
//制約が10^10となっているときに使えそうなアルゴリズム
//二部探索
//ダブリング
//ループ構造

//今回はmodのループする性質を用いる
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K,Q;
LL A[2000];

LL ans = INF;

void solve(){
    //A[i]=Yと決め打ちする
    for(int i=0;i<N;i++){
        LL Y = A[i];
        typedef priority_queue<LL,vector<LL>,greater<LL>> pri_queue;
        vector<pri_queue> part;
        part.push_back(pri_queue());
        for(int j=0;j<N;j++){
            if(A[j]<Y){
                part.push_back(pri_queue());
                continue;
            }
            part[part.size()-1].push(A[j]);
        }

        vector<LL> cand;
        for(int j=0;j<part.size();j++){
            while(part[j].size()>=K){
                cand.push_back(part[j].top());
                part[j].pop();
            }
        }
        sort(cand.begin(),cand.end());
        if(cand.size()<Q) continue;
        LL X = cand[Q-1];
        ans = min(ans,X-Y);
    }
}
 
int main(){
	cin >> N >> K >> Q;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

Measured memory_bytes: 3380
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());
		int Z = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		long A[] = new long[X];
		long B[] = new long[Y];
		long C[] = new long[Z];
		for(int i = 0; i < X; i++) {
			A[i] = Long.parseLong(sc.next());
		}
		for(int i = 0; i < Y; i++) {
			B[i] = Long.parseLong(sc.next());
		}
		for(int i = 0; i < Z; i++) {
			C[i] = Long.parseLong(sc.next());
		}
		long ans[] = new long[K];
		int cnt = 0;
		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);
		for(int i = X - 1; i >= 0; i--) {
			out : for(int j = Y - 1; j >= 0; j--) {
				for(int k = Z - 1; k >= 0; k--) {
					if(cnt >= K) {
						if(ans[0] < A[i] + B[j] + C[k]) {
							ans[0] = A[i] + B[j] + C[k];
							Arrays.sort(ans);
						} else {
							continue out;
						}
					} else {
						ans[cnt] = A[i] + B[j] + C[k];
						cnt++;
						if(cnt >= K) {
							Arrays.sort(ans);
						}
					}
				}
			}
		}
		for(int i = K - 1; i >= 0; i--) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 151320
A,B,C,D = map(int,input().split())
MOD = 998244353

dp = [[0]*(C+1) for _ in range(D+1)]
dp[B][A] = 1

for i in range(B,D+1):
    for j in range(A,C+1):
        if j > A:
            dp[i][j] += dp[i][j-1] * i
        if i > B:
            dp[i][j] += dp[i-1][j] * j
        if A < j and B < i:
            dp[i][j] -= (i-1) * (j-1) * dp[i-1][j-1]
        dp[i][j] %= MOD
print(dp[-1][-1])


Measured memory_bytes: 151840
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll D1 = A1 - B1, D2 = A2 - B2;
    if (D1 < 0) {
        D1 *= -1; D2 *= -1;
    }

    if (T1 * D1 + T2 * D2 > 0) {
        cout << 0 << endl; return 0;
    }
    if (T1 * D1 + T2 * D2 == 0) {
        cout << "infinity" << endl; return 0;
    }

    ll X = T1 * D1 + T2 * D2; X *= -1;
    ll Y = T1 * D1;
    ll ans = 2 * (Y / X) + 1;
    if (Y % X == 0) ans--;

    cout << ans << endl;


	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int XFirstDigits = X / 100;
        int XLastTwoDigits = X % 100;
        if(XFirstDigits * 5 >= XLastTwoDigits){
            System.out.println(1);
        }else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
import itertools
import math

# input
N = int(input())
xy = list()
for i in range(N):
    xy.append(list(map(int, input().split())))

# solve
ans = 0
l = list()
for i in range(N):
    l.append(i)

ll = list(itertools.permutations(l))
for i in range(len(ll)):
    for j in range(N - 1):
        ans += math.sqrt(((xy[ll[i][j]][0] - xy[ll[i][j + 1]][0]) ** 2) + ((xy[ll[i][j]][1] - xy[ll[i][j + 1]][1]) ** 2))

# output
print(ans / len(ll))


Measured memory_bytes: 7972
N, M = gets.split.map(&:to_i)
LRDs = readlines.map{|l| l.split.map(&:to_i)}

@g = Array.new(N){[]}
@x = Array.new(N, 0)
@v = Array.new(N, false)

def fail
  puts 'No'; exit
end

LRDs.each do |l, r, d|
  l -= 1; r -= 1
  @g[l] << [r, d]
  @g[r] << [l, -d]
end
(0 ... N).each do |i|
  unless @v[i]
    @v[i] = true
    q = [i]
    while !q.empty?
      u = q.pop
      @g[u].each do |v, d|
        if @v[v]
          fail if @x[v] != @x[u] + d
        else
          @x[v] = @x[u] + d
          @v[v] = true
          q << v
        end
      end
    end
  end
end
puts 'Yes'

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a,b;
   cin>>a>>b;

   if(a%b==0) cout<<-1<<'\n';
   else cout<<a<<'\n';
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

bool obs(ll a, ll b) {
    if (a > b) swap(a, b);
    for (ll m = a + 1; m < min(b, a + 4); ++m) {
        if (m % 3 == 1) return true;
    }
    return false;
}

ll solve(ll a, ll b, ll c, ll d) {
    ll bl = 1;
    ll loss = 0;

    rep(i, 30) {
        // yoko
        ll p = a / bl, q = b / bl, r = c / bl, s = d / bl;
        if (p == r && p % 3 == 1 && obs(q, s)) {
            ll d1 = min(a % bl, c % bl) + 1;
            ll d2 = bl - max(a % bl, c % bl);
            chmax(loss, min(d1, d2));
            debug(i, d1, d2);
        }
        // tate
        if (q == s && q % 3 == 1 && obs(p, r)) {
            ll d1 = min(b % bl, d % bl) + 1;
            ll d2 = bl - max(b % bl, d % bl);
            chmax(loss, min(d1, d2));
            debug(i, d1, d2);
        }

        bl *= 3;
    }

    return loss * 2 + abs(a - c) + abs(b - d);
}

int main() {
    int Q;
    cin >> Q;
    while (Q--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        --a, --b, --c, --d;
        cout << solve(a, b, c, d) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#define max(a,b) ((a>b)?a:b)
using namespace std;
int ops[]={1,-1};
char sop[]={'+','-'},N[4];
bool add(int op){
	int num=N[0]-'0';
	for(int i=0;i<3;i++){
		num+=(N[i+1]-'0')*ops[op%2];
		op/=2;
	}
	return num==7;
}
void print(int op){
	for(int i=0;i<3;i++){
		printf("%c%c",N[i],sop[op%2]);
		op/=2;
	}
	printf("%c=7\n",N[3]);
}
int main()
{
	scanf("%s",N);
	for(int i=0;i<8;i++)
		if(add(i)){
			print(i);
			break;
		}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

ans = 0

for i in range(1,N-1):
    l = set()
    count = 0
    for j, s in enumerate(S):
        if j < i:
            l.add(s)
        else:
            if s in l:
                count += 1
                l.discard(s)
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 3060
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    a <- getInt
    print $ a + (a^2) + (a^3)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;
    cin>>n;
    vint a(n);
    rep(i,n)cin>>a[i];

    int mi=1001001001;
    for(int d=-100;d<=100;d++){
        int sum=0;
        rep(i,n){
            int t=abs(a[i]-d);
            sum+=t*t;
        }
        chmin(mi,sum);
    }
    cout<<mi<<endl;
    return 0;
}


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

int main() {
  long long H, cnt=0, a=1, ans=1;
  cin >> H;
  while(H>=1){
    H/=2;
    cnt++;
  }
  for(long long i=1; i<cnt; i++){
    a=a*2;
    ans+=a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
using namespace std;

int main()
{
    ll t,n,m,i,j,k,x,y,u,v,l,r;
    string s;

    cin >> s;
    l = s.length();
     j=0;
        for(i=0;i<l;i++)
            if(s[i]=='o')
            j++;
        if((15-l + j)>=8)
            cout << "YES";
        else
            cout << "NO";

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
heights = gets.split.map(&:to_i)
costs = Array.new(N) { nil }
costs[0] = 0
N.times do |i|
  cost = costs[i]
  (1..2).each do |j|
    next if i+j >= N
    costs[i+j] = [costs[i+j], costs[i] + (heights[i+j] - heights[i]).abs].compact.min
  end
end
puts costs.last

Measured memory_bytes: 11396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int n = Integer.parseInt(in.readLine());
			if(n == 0){
				break;
			}
			ArrayList<Long> nums = new ArrayList<Long>();
			long max = 0;
			long min = -100000;
			nums.add(new Long(0));
			for(int i= 0; i < n;i++){
				int nn = Integer.parseInt(in.readLine());
				if(nn > min){
					min = nn;
				}
				if(nums.get(nums.size()-1)*nn >= 0){
					long j = nums.get(nums.size()-1) + nn;
					nums.set(nums.size()-1, j);
				}
				else {
					nums.add((long)nn);
				}	
			}
			if(nums.size() == 1 && nums.get(0) < 0){
				max = min;
			}
			else{
				if(nums.get(0) < 0){
					nums.remove(0);
				}
				if(nums.get(nums.size()-1) < 0){
					nums.remove(nums.size()-1);
				}
				
				max = nums.get(0);
				for(int h = 0;h < nums.size(); h= h+2){
					long sub = 0;
					for(int i = h ; i < nums.size();i = i+2){
						if(i-h < 2){
							sub = sub + nums.get(i);
						}
						else{
							sub = sub + nums.get(i) + nums.get(i-1);	
						}
						if(max < sub ){
							max = sub;
						}
					}
				}
			}
			System.out.println(max);
		}	
	}
}

Measured memory_bytes: 21756
#include<cstdio>
#include<cstring>
using namespace std;
bool err;
char ch[300];
int main()
{
	scanf("%s",ch);
	for(int i=0;i<strlen(ch)-1;i++)
	{
		if(ch[i]=='A'&&ch[i+1]=='C') 
		{
			err=1;break;
		}
	}
	if(err) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int InsertionSort(vector<int>& Array, int N, int g)
{
  	int count = 0;
  	for(int i = g; i< N;i++)
    {
    	int tmp = Array[i];
	  	int j = i -g;
      	while(j>=0 && Array[j] > tmp)
        {
          	Array[j+g] = Array[j];
          	j = j-g;
          	count++;
        }
    	Array[j+g] = tmp;
    }
  	return count;
}

void ShellSort(vector<int> Array, int N)
{
  	int count=0;
  	vector<int> G;
  	G.push_back(1);
  	int g=G[0];
  	while(N > g*3+1)
    {
      g=g*3+1;
      G.push_back(g);
    }
  	int m = G.size();
  	for(int i=m-1;i>=0;i--)
    {
      count+=InsertionSort(Array, N, G[i]);
    }
  	cout << m << endl;
  	for(int i=m-1;i>0;i--) cout << G[i] << " ";
  	cout << G[0] << endl;
  	cout << count << endl;
  	for(int i=0;i<N;i++) cout << Array[i] << endl;
}


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
  	vector<string> S;
	//vector<long> A(N);
  	int idx = 0;
  	//while(cin >> A[idx]) idx++;
  	while(cin >> s)
    {
      S.push_back(s);
      idx++;
    }
  	vector<long> ans;
  	long front, back;
  	idx = 0;
	for(int i=0;i<S.size();i++)
    {
      if(S[i] == "+")
      {
        back = ans.back();
        ans.pop_back();
        front = ans.back();
        ans.pop_back();
        ans.push_back(front + back);
      }
      else if(S[i] == "-")
      {
        back = ans.back();
        ans.pop_back();
        front = ans.back();
        ans.pop_back();
        ans.push_back(front - back);        
      }
      else if(S[i] == "*")
      {
        back = ans.back();
        ans.pop_back();
        front = ans.back();
        ans.pop_back();
        ans.push_back(front * back);
      }
      else
      {
        ans.push_back(stol(S[i]));
      }
    }
  	cout << ans[0] << endl;
  	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> field(H);
  for (int i=0; i<H; i++) cin >> field[i];
  // BFSのためのデータ構造(グリッドグラフ)
  // 全頂点を「未訪問」に初期化
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int>> que;
  // 初期条件
  dist[0][0] = 1;
  que.push(make_pair(0, 0)); // スタート地点を発見済み頂点にする
  // BFS開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    pair<int, int> p = que.front(); // キューから先頭頂点を取り出す
    que.pop();
    // pから辿れる頂点をすべて調べる
    for (int dir=0; dir<4; dir++) {
      int nh = p.first+dx[dir], nw = p.second+dy[dir];
      // 場外に出た場合と黒のマスに到達してしまった場合と訪問済みの点はスルー
      if (nh<0||nh>=H||nw<0||nw>=W) continue;
      if (field[nh][nw]=='#') continue;
      if (dist[nh][nw]!=-1) continue;
      dist[nh][nw] = dist[p.first][p.second]+1;
      que.push(make_pair(nh, nw));
    }
  }
  int white = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (field[i][j]=='.') white++;
    }
  }
  if (dist[H-1][W-1]==-1) cout << -1 << endl;
  else cout << white-dist[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,j,k,n,m;
    char a[5];

    scanf("%s",a);
    j=0;
    for(i=0;i<2;i++)
    {
        if(a[i]==a[i+1] && a[i+1]==a[i+2])
        {
            j=1;
        }
    }
    if(j==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


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

using namespace std;


void solve() {
    int N, Q; string S;
    cin >> N >> S >> Q;

    vector<set<int>> s(26);

    for (int i = 0; i < (int)S.size(); i++) {
        s[S[i] - 'a'].insert(i+1);
    }

    for (int q = 0; q < Q; q++) {
        int query; cin >> query;

        if (query == 1) {
            int i; char c; 
            cin >> i >> c;
            s[S[i-1] - 'a'].erase(i);
            s[c - 'a'].insert(i);
            S[i-1] = c;
        }

        else if (query == 2) {
            int l, r; cin >> l >> r;

            int cnt = 0;

            for (int i = 0; i < 26; i++) {
                auto lit = s[i].lower_bound(l);
                auto rit = s[i].upper_bound(r);
                if (lit != rit) cnt++;
            }

            cout << cnt << '\n';
        }
    }
}


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

    solve();

    return 0;
}

Measured memory_bytes: 27240
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String x = sc.next();
    String y = sc.next();
    
    int xNum = 0;
    int yNum = 0;
    
    if (x.equals("A")) {
      xNum = 10;
    } else if (x.equals("B")) {
      xNum = 11;
    } else if (x.equals("C")) {
      xNum = 12;
    } else if (x.equals("D")) {
      xNum = 13;
    } else if (x.equals("E")) {
      xNum = 14;
    } else if (x.equals("F")) {
      xNum = 15;
    }
    
    if (y.equals("A")) {
      yNum = 10;
    } else if (y.equals("B")) {
      yNum = 11;
    } else if (y.equals("C")) {
      yNum = 12;
    } else if (y.equals("D")) {
      yNum = 13;
    } else if (y.equals("E")) {
      yNum = 14;
    } else if (y.equals("F")) {
      yNum = 15;
    }
    
    if (xNum == yNum) {
      System.out.println("=");
    } else if (xNum < yNum) {
      System.out.println("<");
    } else if (xNum > yNum) {
      System.out.println(">");
    }
  }
}

Measured memory_bytes: 23764
N = int(input())
steps = list(map(int, input().split()))

dp = [99999999] * N
dp[0] = 0
for i in range(1, N):
    a = abs(steps[i] - steps[i - 1]) + dp[i - 1]
    if i < 2:
        dp[i] = a
        continue
    b = abs(steps[i] - steps[i - 2]) + dp[i - 2]
    dp[i] = a if a <= b else b

print(dp[N - 1])


Measured memory_bytes: 84704
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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



	public void exec() throws Exception{
		final String S = sc.next();
		final String T = sc.next();
		out.println(T+S);
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int a, b;

	cin >> a >> b;

	cout << (a - 1) * (b - 1) NL;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        int table[] = new int[3];
        
        Scanner sc = new Scanner(System.in);
        
        table[0] = sc.nextInt();
        table[1] = sc.nextInt();
        table[2] = sc.nextInt();
        
        Arrays.sort(table);
        
        System.out.println(table[0]+" "+table[1]+" "+table[2]);
    }
}



Measured memory_bytes: 26312
#include<bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;
 
using namespace std;
 
int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> jud(n,false);
    int ans=0;
    REP(i,n){
        int max;
        bool flg=false;
        for(int j=0;j<n;j++){
            if(jud[j]) continue;
          	if(red[j].f1>=blue[i].f1) break;
                //cout << blue[i].f1 << ":" << red[j].f1 << endl;
                if(red[j].s2 < blue[i].s2){
                    if(!flg){
                        max=j;
                        flg=true;
                    }
                    if(red[max].s2 < red[j].s2) max = j;
                }
        }
        if(flg){
            jud[max] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int a[100000], dp[100001];
signed main() {
	int n; cin >> n;
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
n=int(input())
if 100<=n<=111:
    print(111)
elif 112<=n<=222:
    print(222)
elif 223<=n<=333:
    print(333)
elif 334<=n<=444:
    print(444)
elif 445<=n<=555:
    print(555)
elif 556<=n<=666:
    print(666)
elif 667<=n<=777:
    print(777)
elif 778<=n<=888:
    print(888)
elif 889<=n<=999:
    print(999)

Measured memory_bytes: 3064
import math

a, b, C = map(float, input().split())

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
sinC = math.sqrt(1 - math.cos(math.radians(C)) ** 2)
S = a * b * sinC / 2
L = a + b + c
h = S * 2 / a

print("{:.8f}".format(S))
print("{:.8f}".format(L))
print("{:.8f}".format(h))


Measured memory_bytes: 5692