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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> cnt(26);
  rep(i,n) cnt[s[i]-'a'].insert(i);
  rep(qi,q) {
    int i;
    cin >> i;
    if(i == 1) {
      int a;
      char b;
      cin >> a >> b;
      a--;
      cnt[s[a]-'a'].erase(a);
      cnt[b-'a'].insert(a);
      s[a] = b;
    }
    else {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int ans = 0;
      rep(j,26) {
        auto it = cnt[j].lower_bound(l);
        if(it == cnt[j].end()) continue;
        if(*it <= r) ans++;
      }
      cout << ans << endl;
    }
  }
}

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

int main() {
    int m;
    string s, s1, s2;

    while (1) {
        cin >> s;
        if (s == "-") break;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int h;
            cin >> h;
            s1 = s.substr(0, h);
            s2 = s.substr(h, s.size()-h);
            s = s2 + s1;
        }
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <functional>
using namespace std;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

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

int main()
{
  int N;
  cin>>N;
  SegmentTree< int > seg(N, [](int a, int b) { return gcd(a, b); }, 0);
  for(int i=1;i<=N;i++){
    int a;cin>>a;
    seg.update(i,a);
  }
  int ans=max(seg.query(2,N+1),seg.query(1,N));
  for(int i=2;i<N;i++){
    ans=max(gcd(seg.query(1,i),seg.query(i+1,N+1)),ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main() {
  int d;
  while (cin >> d) {
    int ans = 0;
    for (int x = d; x < 600; x += d) {
      ans += x * x;
    }
    ans *= d;
    cout << ans << endl;

  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
string s[510];
int ans;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	for (int i = 0; i < n; i++)cin >> s[i];
	for (int i = 0; i < n; i++) {
		bool bl = false;
		for (int j = 0; j < n; j++)if (s[j][i] == '.')bl = true;
		if (bl)ans++;
	}
	int mi = 1000;
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++)if (s[i][j] == '.')cnt++;
		if (cnt == n)continue;
		bool bl = false;
		for (int j = 0; j < n; j++)if (s[j][i] == '#')bl = true;
		if (bl)mi = min(mi, cnt);
		else mi = min(mi, cnt + 1);
	}
	if (mi == 1000)cout << -1 << endl;
	else cout << ans + mi << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

LL dp[55][55][2505];

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

    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    REP(i, n) cin >> x[i];

    REP(i, 55) REP(j, 55) REP(k, 2505) dp[i][j][k] = 0;
    
    REP(i, 55) dp[i][0][0] = 1;
    REP(i, n){
        REP(j, i+1){
            REP(k, 2505){
                dp[i+1][j+1][k] = dp[i][j+1][k];
                if(k >= x[i]) dp[i+1][j+1][k] += dp[i][j][k-x[i]];
            }
        }
    }
    
    LL ans = 0;
    REP(j, n){
        ans += dp[n][j+1][a*(j+1)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 59520
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
const ll MOD=10;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
int N,M;
ll A[MAXN];
ll B[MAXN];
ll K;
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M>>K;
    for(int u=1;u<=N;u++){
        cin>>A[u];
        A[u]+=A[u-1];
    }
    for(int u=1;u<=M;u++){
        cin>>B[u];
        B[u]+=B[u-1];
    }
    int ans=0;
    for(int a=0;a<=N;a++){
        ll fb=K-A[a];
        if(fb<0)break;
        int l=0,r=M,lst=0;
        while(l<=r){
            int mid=(l+r)>>1;
            if(B[mid]<=fb){
                lst=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        ans=max(ans,a+lst);
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

int main(){
    string s;
    cin >> s;
    bool flag = true;
    for(int i = 1; i < s.size(); i++){
        flag = s[i] == '9' ? true : false;
    }
    int ans = s[0] - '0' + 9 * (s.size() - 1); 
    cout << (flag ? ans : ans - 1) << endl;
    return 0;
}

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

public class Main{
    public static void main(String[] args)throws IOException{
	BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
	String s=r.readLine();
	String[] t;
	t=s.split(" ");
	int[] n=new int[t.length];
	for(int i=0;i<t.length;i++){
	    n[i]=Integer.parseInt(t[i]);
	}
	int nm=n[0];
	int[] count=new int[nm];
	for(int j=0;j<n[0];j++){
	    String a=r.readLine();
	    String[] alpha;
	    alpha=a.split(" ");
	    int gh=alpha.length;
	    int[] number=new int[gh];
	    for(int k=0;k<alpha.length;k++){
		number[k]=Integer.parseInt(alpha[k]);
	    }
	    for(int l=0;l<n[1];l++){
		if(number[l]==1){
		    count[j]++;
		}
	    }
	}
        Arrays.sort(count);
        System.out.println(count[nm-1]);
    }
}	

Measured memory_bytes: 17048
#include <cstdio>
#include <cstring>
#define N 5
char s[N], t[N];
int ans;

int main() {
    scanf("%s%s", s, t);
    for (int i = 0; i < 3; i++)
        if (s[i] == t[i]) ans++;
    printf("%d", ans);
}


Measured memory_bytes: 128
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def prefix(p:String) = {
    val m = p.length
    val a = new Array[Int](m)
    var k=0

    a(0) = 0
    for(q<-1 until m) {
      while(k>0 && p(k)!=p(q)) k = a(k-1)
      if(p(k) == p(q)) k = k+1
      a(q) = k
    }

    a
  }

  def main(args:Array[String]) = {
    val t = readLine.trim
    val p = readLine.trim
    val b = new ArrayBuffer[Int]
    var q = 0

    val f = prefix(p)

    for(i<-0 until t.length) {
      while(q>0 && p(q)!=t(i)) q = f(q-1)
      if(p(q)==t(i)) q = q+1
      if(q==p.length) {
        b += i-p.length+1
        q = f(q-1)
      }
    }

    if(b.length>0) println(b.mkString("\n"))
  }
}

Measured memory_bytes: 181284
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N; string S; cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		int k = S[i] - 'A';
		k = (k + N) % 26;
		char c = 'A' + k;
		cout << c;
	}
	return 0;
}

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

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

  vector<int> S(N+1, 0);
  rep(i,N) {
    int a;
    cin >> a;
    S[i+1] = (S[i] + a) % M;
  }

  ll ans = 0;
  map<int, int> m;
  for(int i = 0; i <= N; i++) {
    ans += m[(M+S[i])%M];
    m[S[i]]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3584
require 'pp'

m, d = gets.chomp!.split(" ").map(&:to_i)

count = 0
1.upto(m) do |m0|
    1.upto(d) do |d0|
        d1 = d0 % 10
        d10 = d0 / 10

        if d1 >= 2 && d10 >= 2 && d1 * d10 == m0
            count += 1
        end
    end
end

puts count


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    int ans=0;
    int max=0;
    for(int i=0;i<n;i++){
        if(max<=h[i]){
            ans++;
            max=h[i];
        }
    }
    cout << ans;
}

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

int main() {
	int n, cnt = 0;
	cin >> n;
	vector<int> a(n + 5);
	REP(i, 1, n) cin >> a[i];
	rep(i, n + 1) {
		if (i % 2 == 1 && a[i] % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var x = new long[8];
            var y = 0;
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] < 400) x[0]++;
                else if (a[i] < 800) x[1]++;
                else if (a[i] < 1200) x[2]++;
                else if (a[i] < 1600) x[3]++;
                else if (a[i] < 2000) x[4]++;
                else if (a[i] < 2400) x[5]++;
                else if (a[i] < 2800) x[6]++;
                else if (a[i] < 3200) x[7]++;
                else y++;
            }
            for (int i = 0; i < 8; i++)
            {
                if (x[i] != 0) ans++;
            }
            if (ans!= 0)
                WriteLine("{0} {1}", ans, ans + y);
            else
                WriteLine("{0} {1}", 1, x.Sum() + y);







            Console.Out.Flush();
        }
    }
}




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

typedef tuple<int, int, int> Edge;
const int INF = 1 << 28;

int n, m;
vector<vector<Edge>> g;

int main()
{
	while (cin >> n >> m, n){
		g.clear(); g.resize(n);
		for (int i = 0; i < m; i++){
			int a, b, d, c;
			cin >> a >> b >> d >> c, a--, b--;
			g[a].emplace_back(d, c, b);
			g[b].emplace_back(d, c, a);
		}
		int res = 0;
		vector<pair<int, int>> dist(n, make_pair(INF, INF));
		priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
		dist[0] = make_pair(0, 0);
		pq.push(Edge(0, 0, 0));
		while (pq.size()){
			int s, c, v;
			tie(s, c, v) = pq.top(); pq.pop();
			if (dist[v] < make_pair(s, c)) continue;
			res += c;
			for (Edge &e : g[v]){
				int d, co, u;
				tie(d, co, u) = e;
				if (dist[u] > make_pair(s + d, co)){
					dist[u] = make_pair(s + d, co);
					pq.push(Edge(s + d, co, u));
				}
			}
		}
		cout << res << endl;
	}
}

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

namespace ConsoleApp1
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var dict = new Dictionary<int, int>();
            var temp = A.OrderBy(x => x).ToArray();
            for (int i = 0; i < n; i++) dict[temp[i]] = i;
            bool[] visted = new bool[n];
            int s = temp[0];
            int result = 0;
            for (int i = 0; i < n; i++) {
                if (visted[i]) continue;
                int cur = i, sum = 0, min = A[i], an = 0;
                while (!visted[cur])
                {
                    visted[cur] = true;
                    an++;

                    if (min > A[cur]) min = A[cur];
                    sum += A[cur];
                    cur = dict[A[cur]];
                }
                result += Math.Min(sum + (an - 2) * min, min + sum + (an + 1) * s);
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18288
def main():
    S = list(input())
    N = len(S)

    P = 2019
    num = [0] * P
    num[0] = 1
    now, ans = 0, 0
    _10 = 1
    for s in S[::-1]:
        now = (now + int(s)*_10) % P
        _10 *= 10
        _10 %= P
        ans += num[now]
        num[now] += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int S2(int N){

  int sum = 0;

  while (N != 0) {
    sum += N % 10;
    N /= 10;
  }

  return sum;
}

int main()
{

  int N;

  cin >> N;

  int result = S2(N);

  if (N % result == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	
	if (x <= 599) {
		cout << "8\n";
	} else if (x <= 799) {
		cout << "7\n";
	} else if (x <= 999) {
		cout << "6\n";
	} else if (x <= 1199) {
		cout << "5\n";
	} else if (x <= 1399) {
		cout << "4\n";
	} else if (x <= 1599) {
		cout << "3\n";
	} else if (x <= 1799) {
		cout << "2\n";
	} else {
		cout << "1\n";
	}

}


Measured memory_bytes: 3636
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
       int x = input.nextInt();
       String s = input.next();
       
        int c=0;
        for(int i = 0;i<x-2;i++){
            
           if(s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C'){
               c++;
               
           }
            
            
    
    }
        System.out.println(c);
    
}}


Measured memory_bytes: 21332
X,Y,A,B,C=map(int,input().split())
P=sorted([int(x) for x in input().split()])
Q=sorted([int(x) for x in input().split()])
R=[int(x) for x in input().split()]
saare=[]
for item in P:
	saare.append([item,'R'])
for item in Q:
	saare.append([item,'G'])
for item in R:
	saare.append([item,'C'])
 
saare.sort(reverse=True)
# print(saare)
 
p=A-X
q=B-Y
 
i=0
 
ans=0
 
while X or Y:
 
	if saare[i][1]=='R' and X:
		X-=1
		# p+=1
		ans+=saare[i][0]
		# print("EAT RED",saare[i][0])
	elif saare[i][1]=='G' and Y:
		Y-=1
		# q+=1
		ans+=saare[i][0]
		# print("EAT GREEN",saare[i][0])
	elif saare[i][1]=='C':
		if not Y:
			X-=1
			p+=1
			ans+=saare[i][0]
			# print("EAT RED",saare[i][0])
		elif not X:
			Y-=1
			q+=1
			ans+=saare[i][0]
			# print("EAT GREEN",saare[i][0])
		else:
			if P[p] >= Q[q]:
				q+=1
				Y-=1
				ans+=saare[i][0]
				# print("EAT GREEN",saare[i][0])
			else:
				p+=1
				X-=1
				ans+=saare[i][0]
				# print("EAT RED",saare[i][0])
	i+=1
print(ans)

Measured memory_bytes: 47436
n = int(input())
S = input()
q = int(input())


class BIT:
    def __init__(self, n):
        """
        初期化
        Input:　
            n: 配列の大きさ
        """
        self.n = n
        self.bit = [0] * (n+10)

    def add(self, x, w):
        """
        更新クエリ(add)
        Input:
            x: インデックス
            w: 加える値
        Note:
            self.bitが更新される
        """        
        while x <= self.n:
            self.bit[x] += w
            x += x&-x
    
    def sum(self, x):
        """
        部分和算出クエリ
        Input:
            x: インデックス
        Return:
            [1,a]の部分和
        """
        cnt = 0
        while x > 0:
            cnt += self.bit[x]
            # 次の最下位桁はどこか
            x -= x&-x
        return cnt   
    
    def psum(self, a, b):
        """
        区間[a,b)(0-indexed)における和
        Input
            a,b: 半開区間
        Return
            [a,b)の和
        """
        return self.sum(b-1) - self.sum(a-1)


def str2num(s):
    return ord(s)-ord("a")

bits = [BIT(n) for i in range(26)]
# 入力
ans = []
for i, s in enumerate(S):
    ind = str2num(s)
    bits[ind].add(i+1, 1)

S = list(S)
for _ in range(q):
    x,a,b = input().split()
    if x == "1":
        i = int(a)
        # 更新処理
        ind_before = str2num(S[i-1])
        ind = str2num(b)
        bits[ind_before].add(i,-1)
        bits[ind].add(i, 1)
        S[i-1] = b
    else:
        l = int(a)
        r = int(b)
        cnt = 0
        for bit in bits:
            if bit.psum(l,r+1) > 0:
                cnt += 1
        ans.append(cnt)
print(*ans)

        


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

int n;
bool flag = true;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;

    if ((d % 2 == 0) & (d % 3 != 0) & (d % 5 != 0)) {
      flag = false;
    }
  }

  if (flag) {
    printf("APPROVED");
  } else {
    printf("DENIED");
  }

  return 0;
}

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

using namespace std;

int main() {
  int N, K, C;
  cin >> N >> K >> C;

  string S;
  cin >> S;

  vector<int> ldp(N, 0);
  for (int i = 0; i < N; i++) {
    if (i - C <= 0) {
      ldp[i] = 1;
    } else {
      if (S[i] == 'x') {
        ldp[i] = ldp[i - 1];
      } else {
        ldp[i] = ldp[i - C - 1] + 1;
      }
    }
  }

  vector<int> rdp(N, 0);
  for (int i = N - 1; i >= 0; i--) {
    if (i + C >= N) {
      rdp[i] = 1;
    } else {
      if (S[i] == 'x') {
        rdp[i] = rdp[i + 1];
      } else {
        rdp[i] = rdp[i + C + 1] + 1;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    int l = (i - 1 >= 0 ? ldp[i - 1] : 0);
    int r = (i + 1 <= N - 1 ? rdp[i + 1] : 0);
    if (l + r < K) {
      cout << i + 1 << "\n";
    }
  }

  return 0;
}

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

#define MAX_N 2000

int N = 3;
// int s[] = {1, 0, 1};
// string s = "101";
string s;

int main() {
    cin >> s;

    int result = 0;
    rep(i, N) {
        if (s[i] == '1') {
            result++;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
nn=int(input())
import sys
input=sys.stdin.readline
cc=[int(input()) for _ in range(nn)]
c=[cc[0]]
for i in range(1,nn):
    if cc[i]!=c[-1]:
        c.append(cc[i])
n=len(c)
mod=10**9+7
dp=[0]*(n+1)
sm=[0]*(max(c)+1)
dp[0]=1
for i in range(n):
    x=c[i]
    dp[i+1]+=sm[x]+dp[i]
    sm[x]+=dp[i]
    dp[i]%=mod
    dp[i+1]%=mod
print(dp[n])


Measured memory_bytes: 65756
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll pos[N+1]={0};
    FORI(i,0,N)
    {
        READV(x);
        pos[x]=i+1;
    }
    set<ll> P;
    P.insert(0);
    P.insert(N+1);
    ll ans=0;
    FORI(i,1,N+1)
    {
        auto it=P.lower_bound(pos[i]);
        ll hi=*it;
        it--;
        ll lo=*it;
        ans+=i*(hi-pos[i])*(pos[i]-lo);
        P.insert(pos[i]);
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 14728
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N];
  map<int, int> students;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    students[A[i]] = i;
  }

  sort(A, A+N);
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << students[A[i]] + 1;
  }
  cout << endl;
}


Measured memory_bytes: 5888
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int Maxn = 100000 + 100;
const int Mod = 1000000000 + 7;
int n,l,a[Maxn];
string S;
int x,y;
bool f = false;
int main()
{
    cin>>x>>y;
    if( (x+y) % 2 == 0 )
        cout<<(x+y)/2<<endl;
    else
        cout<<(x+y)/2+1<<endl;
    return 0;
}

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

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

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

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

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, A, B;
    cin >> N >> A >> B;
    cout << ((B - A) % 2 == 0 ? "Alice" : "Borys") << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int h, w;
string s[12];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> h >> w;
  rep(i, h) cin >> s[i];

  vector<vint> cmb;
  vector<vint> oth;
  set<int> used;
  rep(bit, 1<<h) {
    if(__builtin_popcount(bit) != (h+1)/2) continue;
    if(used.count(((1<<h)-1)^bit)) continue;
    used.insert(bit);
    cmb.push_back({});
    oth.push_back({});
    rep(i, h) {
      if(bit>>i&1) cmb.back().push_back(i);
      else oth.back().push_back(i);
    }
  }
  vector<string> t, u;
  map<string, int> mp;
  set<string> st;
  rep(k, cmb.size()) {
    do {
      t.clear(); u.clear();
      rep(i, cmb[k].size()) t.push_back(s[cmb[k][i]]);
      rep(i, oth[k].size()) t.push_back(s[oth[k][i]]);
      rep(i, w) {
	u.push_back("");
	rep(j, h) u[i] += t[j][i];
      }
      mp.clear();
      rep(i, w) mp[u[i]]++;
      bool flag = true;
      st.clear();
      rep(i, w) {
	string tmp = u[i];
	reverse(all(tmp));
	if(u[i] == tmp && mp[u[i]]%2 == 1) st.insert(u[i]);
	if(u[i] != tmp && mp[u[i]] != mp[tmp]) {
	  flag = false;
	  break;
	}
      }
      if(flag && w%2 == (int)st.size()) {
	cout << "YES" << endl;
	return 0;
      }
    }while(next_permutation(all(cmb[k])));
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,n;
  cin>>h>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  Int sum=0;
  for(Int a:as) sum+=a;
  cout<<(sum>=h?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,n,k,m;
    cin>>n>>m;
    for(i=m-n+1;i<=m;i++)
    {
        cout<<i<<" ";
    }
    for(i=m+1;i<=m+n-1;i++)
    {
        cout<<i<<" ";
    }

    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;

int solve(int *dp, int *A, int i) {
    if(dp[i] >= 0) return dp[i];
    dp[i] = min(solve(dp, A, i-1) + abs(A[i]-A[i-1]), solve(dp, A, i-2) + abs(A[i]-A[i-2]));
    return dp[i];
}

int main() {
    int n;
    cin >> n;
    int A[n], dp[n];
    for(int i = 0; i < n; i++) {
        cin >> A[i];
        dp[i] = -1;
    }
    dp[0] = 0; dp[1] = abs(A[1]-A[0]);
    cout << solve(dp, A, n-1);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e5;
const int size=1e5;
const long inf=1e9;
int main(){
	int N;long M;cin>>N>>M;
	long A[N];int cnt[N]={};
	rep(i,0,N){
		cin>>A[i]; A[i]/=2;
		long temp=A[i];
        while(temp%2==0){
            temp/=2;
            cnt[i]++;
        }
	}
    rep(i,1,N)if(cnt[i-1]!=cnt[i]){
        cout<<0<<endl;
        return 0;
    }
	long x=A[0];
	rep(i,1,N){
		x=x/__gcd(x,A[i])*A[i];
        if(x>inf){
            cout<<0<<endl;
            return 0;
        }
    }cout<<(M/x+1)/2<<endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  inf 0x3fffffff 
int main()
{
	char a[1500];
	int i, t, n,len,flag1,flag2;
	while (scanf("%s", a) != EOF)
	{
		flag1=flag2=0;
		len = strlen(a);
		for (i = 0; i < len; i++)
		{
			if (a[i] == 'N'&&flag1 ==0)
				flag1 = 1;
			if (a[i] == 'S'&&flag1 == 0)
				flag1 = -1;
			if (a[i] == 'W'&&flag2 == 0)
				flag2 = 1;
			if (a[i] == 'E'&&flag2 == 0)
				flag2 = -1;
			if (a[i] == 'N'&&flag1 == -1)
				flag1 = 10;
			if (a[i] == 'S'&&flag1 == 1)
				flag1 = 10;
			if (a[i] == 'W'&&flag2 == -1)
				flag2 = 10;
			if (a[i] == 'E'&&flag2 == 1)
				flag2 = 10;
		}
		if ((flag1 == 10 || flag1 == 0) && (flag2 == 10 || flag2 == 0))
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
N = int(input())
A = [int(n) for n in input().split()]
MAX = 10**18
ans = 1
if 0 in A:
    print("0")
    sys.exit()
for a in A:
    if ans > MAX:
        print("-1")
        sys.exit()
    ans *= a
else:
    if ans > MAX:
        print("-1")
    else:
        print(ans)

Measured memory_bytes: 21656
#include<bits/stdc++.h>
#define rep(i,l,r) for (ll i=l;i<=r;i++)
using namespace std;
typedef long long ll;
ll a,b,c,ans,N,K,M,H,D,tt,t,dp[1000007],ji[1000007];
ll co=1000000007;
int main(){
	scanf("%lld%lld%lld",&N,&H,&D);
	ji[0]=1;rep(i,1,N) ji[i]=ji[i-1]*i%co; 
	rep(i,1,N) a=(a+ji[i])%co;
	dp[0]=ji[N];ll s=ji[N];
	rep(i,1,H){
		if (i>b+D) s=(s-dp[b]+co)%co,b++;
		if (i<H) dp[i]=a*s%co;
		else dp[i]=s;
		s=(s+dp[i])%co;
	}
	printf("%lld\n",dp[H]);
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
   int n,k,l;
   cin>>n>>k>>l;
   vector<int> p(k),q(k),r(l),s(l);
   UnionFind uf(n),uf2(n);

   for(int i=0;i<k;i++){
      cin>>p[i]>>q[i];
      p[i]--;q[i]--;
   }
   for(int i=0;i<l;i++){
      cin>>r[i]>>s[i];
      r[i]--;s[i]--;
   }

   for(int i=0;i<k;i++)uf.merge(p[i],q[i]);
   for(int i=0;i<l;i++)uf2.merge(r[i],s[i]);

   map<pair<int,int>,int> mp;

   for(int i=0;i<n;i++){
      mp[make_pair(uf.root(i),uf2.root(i))]++;
   }

   for(int i=0;i<n;i++){
      cout<<mp[make_pair(uf.root(i),uf2.root(i))]<<" ";
   }
   cout<<endl;
   
}

   


Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;



int main() {
	long long int N,x;
	int X[100008];

	cin >> N >> x;

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

	long long int Y = 0;
	for (long long int i = 0; i < N-1; i++) {
		if (X[i] + X[i + 1] > x) {
			if (X[i ] >= x) {
				Y += X[i + 1];
				X[i + 1] = 0;
				Y += X[i] - x;
				X[i] = x;

			}
			else {
				Y += X[i + 1] - x + X[i];
				X[i + 1] = x - X[i];
			}
		}
	}
	cout << Y << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<queue>

using namespace std;

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

bool valid(int n) {return 0 <= n && n < 1024;}

int num(string str) {
  int n = 0;
  rep (i, str.size()) {
    n = n * 2 + str[i] - '0';
    if (n >= 1024) throw 1;
  }
  return n;
}

int exp1(string str);
int exp2(string str);
int exp3(string str);

int exp1(string str) {
  if (str.size() == 0u) throw 1;
  int t = 0, n = str.size(), s = 0;
  vector<int> v;
  rep (i, n) {
    if (str[i] == '(') ++t;
    if (str[i] == ')') {
      --t;
      if (t < 0) throw 1;
    }
    if (t == 0 && (str[i] == '+' || str[i] == '-')) {
      v.push_back((s == 0 || str[s - 1] == '+' ? 1 : -1) * exp1(str.substr(s, i - s)));
      s = i + 1;
    }
  }
  if (t != 0) throw 1;
  if (v.size() == 0u) return exp2(str);
  v.push_back((s == 0 || str[s - 1] == '+' ? 1 : -1) * exp1(str.substr(s, n - s)));
  int res = 0;
  rep (i, v.size()) {
    res += v[i];
    if (!valid(res)) throw 1;
  }
  return res;
}

int exp2(string str) {
  int t = 0, n = str.size(), s = 0;
  vector<int> v;
  rep (i, n) {
    if (str[i] == '(') ++t;
    if (str[i] == ')') {
      --t;
      if (t < 0) throw 1;
    }
    if (t == 0 && str[i] == '*') {
      v.push_back(exp1(str.substr(s, i - s)));
      s = i + 1;
    }
  }
  if (v.size() == 0u) return exp3(str);
  v.push_back(exp1(str.substr(s, n - s)));
  int res = 1;
  rep (i, v.size()) {
    res *= v[i];
    if (!valid(res)) throw 1;
  }
  return res;
}

int exp3(string str) {
  int t = 0, n = str.size();
  bool f = true;
  rep (i, n) if (!isdigit(str[i])) f = false;
  if (f) return num(str);
  if (str[0] != '(' || str[n - 1] != ')') throw 1;
  str = str.substr(1, n - 2);
  vector<int> v;
  rep (i, n) {
    if (str[i] == '(') ++t;
    if (str[i] == ')') {
      --t;
      if (t < 0) throw 1;
    }
    if (t == 0 && (str[i] == '+' || str[i] == '-' || str[i] == '*')) {
      return exp1(str);
    }
  }
  throw 1;
}

const char c[] = {'0', '1', '+', '-', '*', '(', ')'};
int solve0(string str, vector<int> dot) {
  if (dot.size() == 0u) {
    try {
      return exp1(str);
    } catch(int n) {
      return -1;
    }
  }
  int n = dot.back();
  dot.pop_back();
  int res = -1;
  rep (i, 7) {
    str[n] = c[i];
    res = max(res, solve0(str, dot));
  }
  return res;
}

int main() {
  string str;
  cin >> str;
  vector<int> dot;
  rep (i, str.size()) if (str[i] == '.') dot.push_back(i);
  cout << solve0(str, dot) << endl;
  return 0;
}

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

using namespace std;

int n, ac, wa, tle, re;
string s;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n;
	while (n--) {
		cin >> s;

		if (s == "AC")
			++ac;
		if (s == "WA")
			++wa;
		if (s == "TLE")
			++tle;
		if (s == "RE")
			++re;
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void){
        int m,f,r,n,i,c;
        char a[50];
        c=0;
	while(1){
             scanf("%d %d %d",&m,&f,&r);
             if(m==-1 && f==-1 && r==-1){
                  break;
             }
             if(m+f>=80){
                  a[c]='A';
             }
             if(m+f>=65 && m+f<80){
                  a[c]='B';
             }
             if(m+f>=50 && m+f<65){
                  a[c]='C';
             }
             if(m+f>=30 && m+f<50 && r>=50){
                  a[c]='C';
             }
             if(m+f>=30 && m+f<50 && r<50){
                  a[c]='D';
             }
             if(m+f<30){
                  a[c]='F';
             }
             if(m==-1 || f==-1){
                  a[c]='F';
             }
             c=c+1;
	}
        for(i=0;i<c;i++){
	     printf("%c\n",a[i]);
        }
	return 0;
}


Measured memory_bytes: 2052
na,nb,nm =  map(int, (input().split()))

a = list(map(int, input().split()))
b = list(map(int, input().split()))

mina = a[0]
minb = b[0]
for i in range(na):
    if a[i] < mina :
        mina = a[i]
for j in range(nb):
    if b[j] < minb :
        minb = b[j]
min = mina + minb

#  m入力
for k in range(nm):
    i,j,disc = map(int, input().split())
    if min > a[i-1]+b[j-1]-disc:
        min = a[i-1]+b[j-1]-disc

print(min)


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int X; cin>>X;
    if(X>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585

"""
import sys
from sys import stdin
from collections import namedtuple
input = stdin.readline


def closest_part(points, n):
    # ?????¬???p324???
    if n <= 1:
        return float('inf')
    m = n // 2
    x = points[m].x
    d = min(closest_part(points[:m], m), closest_part(points[m:], n-m))

    points.sort(key=lambda p:p.y)
    b = []
    for p in points:
        if (p.x - x)**2 >= d:
            continue
        for j in range(len(b)):
            dx = p.x - b[-j-1].x
            dy = p.y - b[-j-1].y
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.append(p)
    return d

pos = namedtuple('pos', ['x', 'y'])
def main(args):
    n = int(input())
    points = [pos(*list(map(int, input().split()))) for _ in range(n)]
    points.sort()               #  x????????§??????????????????

    result = closest_part(points, n)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 88492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A == 1) A = 14;
		if(B == 1) B = 14;
		if(A > B) System.out.println("Alice");
		else if(A < B) System.out.println("Bob");
		else System.out.println("Draw");
	}
}

Measured memory_bytes: 21972
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 10005;
int const magic = 4001;

bool good[maxn][3];

char kek[maxn];

bool okay(char c1, char c2) {
	if (c1 == '?' or c2 == '?') return true;
	return c1 == c2;
}

void check(string s1, string s2, int type) {
	int sz2 = s2.size();
	int sz1 = s1.size();
	for (int shift = -sz2; shift <= (int)s1.size(); shift++) {
		bool ok = true;
		for (int i = 0; i < s1.size(); i++) {
			int j = i - shift;
			if (j >= 0 && j < s2.size()) {
				if (!okay(s1[i], s2[j])) {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			good[magic + shift][type] = 1;
		}
	}
	int fst = maxn, lst = -1;
	for (int i = 0; i < maxn; i++) {
		if (good[i][type]) fst = min(fst, i), lst = max(lst, i);
	}
	for (int i = 0; i < fst; i++) good[i][type] = 1;
	for (int i = lst + 1; i < maxn; i++) good[i][type] = 1;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string a, b, c; cin >> a >> b >> c;
	// 0 : a -> b
	check(a, b, 0);
	// 1 : a -> c
	check(a, c, 1);
	// 2: b->c
	check(b, c, 2);
	int ans = a.size() + b.size() + c.size();
	int lim = b.size() + c.size();

	for (int shift_b = -lim; shift_b <= lim; shift_b++) {
		for (int shift_c = -lim; shift_c <= lim; shift_c++) {
			if (good[shift_b + magic][0] and good[shift_c + magic][1]) {
				int shift = shift_c - shift_b;
				if (shift < -(int)c.size() or shift > (int)b.size() or good[shift + magic][2]) {
					int l = min({ 0, shift_b, shift_c });
					int r = max({ (int)a.size() - 1, shift_b + (int)b.size() - 1, shift_c + (int)c.size() - 1 });
					ans = min(ans, r - l + 1);
				}
			}
		}
	}
	cout << ans << endl;




	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5


*/

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N; cin>>N;
    int h[N]; REP(i,N) cin>>h[i];
    int dp[N+1]; REP(i,N) dp[i] = INF;
    dp[0] = 0;
    REP(i,N-1) {
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[N-1] <<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Point {
  lli x, y;
};

lli n, k;
vector<Point> p;
vector<lli> xs, ys;
int main() {
  cin >> n >> k;
  init_n(p, n);
  for (lli i=0; i<n; ++i) cin >> p[i].x >> p[i].y;
  for (Point& q : p) {
    xs.push_back(q.x); ys.push_back(q.y);
  }
  sort(begin(xs), end(xs));
  sort(begin(ys), end(ys));

  lli ans = 5e18;
  for (lli xi=0; xi<n; ++xi) {
    for (lli xj=xi+1; xj<n; ++xj) {
      for (lli yi=0; yi<n; ++yi) {
        for (lli yj=yi+1; yj<n; ++yj) {
          lli cnt = 0;
          for (Point& q : p) {
            if (xs[xi]<=q.x && q.x<=xs[xj] 
                && ys[yi]<=q.y && q.y<=ys[yj] && cnt<k) {
              ++cnt;
            }
          }
          if (cnt >= k) ans = min(ans, (xs[xj]-xs[xi])*(ys[yj]-ys[yi]));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int x,y,s;

void solve(){
    int ans = -1;
    for(int i=1;i<s;i++){
        for(int j=1;j<s;j++){
            int a = i*(100+x)/100;
            int b = j*(100+x)/100;
            if(a+b==s){
                a = i*(100+y)/100;
                b = j*(100+y)/100;
                ans = max(ans,a+b);
            }
        }
    }
    cout << ans << endl;
}

int main(){
    while(true){
        cin >> x >> y >> s;
        if(x==0 and y==0 and s==0) break;
        solve();
    }
}

Measured memory_bytes: 2952
import numpy as np

n,c = map(int,input().split())
table = np.zeros(10**5+2, dtype=np.int32)
chs = [[] for _ in range(c+1)]

for _ in range(n):
    s,t,c = map(int,input().split())
    chs[c].append([s,t])

# 同チャンネル内の連続番組を合体
times = []
for ch in chs:
    if not ch: continue
    ch.sort()
    for i in range(len(ch)):
        if i == 0: continue
        if ch[i-1][1] == ch[i][0]:
            ch[i] = [ch[i-1][0], ch[i][1]]
            ch[i-1] = []
    for arr in ch:
        if not arr: continue
        times.append(arr)

# いもす法
for arr in times:
    table[arr[0]] += 1
    table[arr[1]+1] -= 1

# 累積和の最大値
ans = table.cumsum().max()

print(ans)



Measured memory_bytes: 39272