akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	ll n;
	cin >> n;
	Array p(n);
	REP(i, n) cin >> p[i];

	map<ll, ll> mp;
	REP(i, n) {
		if (mp[p[i] - 1] > 0) {
			mp[p[i]] += mp[p[i] - 1] + 1;
			mp[p[i] - 1] = 0;
		}
		else {
			mp[p[i]] = 1;
		}
	}
	ll ans = n;
	for (auto i : mp) chmin(ans, n - i.second);
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[4];

int main(){

	int A = 0,B = 0;

	scanf("%s",buf);

	for(int i = 0; i < 3; i++){
		if(buf[i] == 'A'){

			A++;
		}else{

			B++;
		}
	}

	if(A > 0 && B > 0){

		printf("Yes\n");
	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    int N, M; cin >> N >> M;
    int a[M], b[M];
    rep(i,M) cin >> a[i] >> b[i];
    bool to[N+1], from[N+1];
    rep(i,N+1) to[i] = from[i] = false;
    rep(i,M) {
        if (a[i] == 1) to[b[i]] = true;
        if (b[i] == 1) to[a[i]] = true;
        if (a[i] == N) from[b[i]] = true;
        if (b[i] == N) from[a[i]] = true;
    }
    bool flag = false;
    rep(i,N+1) {
        if (to[i] && from[i]) flag = true;
    }
    if (flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    

    return 0;
}






Measured memory_bytes: 2176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long double INF = 1e18;

struct lab{
	long double L,a,b;
};
int main(){
	int N,M;
	cin>>N>>M;
	vector<lab>lb(N);
	REP(i,N)cin>>lb[i].L>>lb[i].a>>lb[i].b;
	long double res=0;
	REP(i,1<<N){
		vector<lab>l;
		int cnt=0;
		REP(j,N)if(i>>j&1){
			l.PB(lb[j]);cnt++;
		}
		if(cnt!=M)continue;
		long double tmp=0.0;
		REP(j,SZ(l))FOR(k,j+1,SZ(l)){
			tmp+=pow(l[j].L-l[k].L,2)+pow(l[j].a-l[k].a,2)+pow(l[j].b-l[k].b,2);
		}
		res=max(res,tmp);
	}
	cout<<fixed<<setprecision(20)<<res<<endl;
	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;
#define mod (llint)1000000007
#define int_max 2147483647
#define ll_max (llint)9223372036854775807

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aのb乗を求める(1000000007で割った余りやで)
llint modpow(llint a, llint b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	llint tmp = modpow(a, b / 2);
	tmp %= mod;
	tmp = tmp * tmp % mod;
	if (b % 2)return tmp * a % mod;
	else return tmp;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= mod;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, mod);
		ans %= mod;
	}
	return ans;
}


int main() {
	int a[3];
	rep(i, 3)cin >> a[i];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
	return 0;
}

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

int main(){
  int a,b; cin>>a>>b;
  int ans=0;
  if(a<b){
    ans+=b; b--;
  }else{
    ans+=a; a--;
  }
  if(a<b){
    ans+=b; b--;
  }else{
    ans+=a; a--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> cnt(m+1);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        vector<int> a(k);
        for(int j=0;j<k;j++){
            cin>>a.at(j);
            cnt.at(a.at(j))++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(cnt.at(i)==n)
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
"""
# 標準入力取得
## 文字列
     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())

## 数値
     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import copy

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007
# sortedと比較
# 
if __name__ == "__main__":
     N = int(sys.stdin.readline())
     L = list(map(int, sys.stdin.readline().split()))

     cnt = 0

     for i, e in enumerate(L, 1):
          if e != i:
               cnt += 1

     if cnt == 0 or cnt == 2:
          print("YES")
     else:
          print("NO")

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

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

    if(a>=13)cout<<b<<endl;
    else if(a<=5)cout<<0<<endl;
    else cout<<b/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=1e6+100;
ll dp[N];
ll a[N];
int32_t main(){
    string s;
    cin >> s;
    ll n=s.size();
    for (int i=1;i<=n;i++){
        if (s[i-1]=='1') a[i]=1;
        else a[i]=-1;
    }
    ll sig=0,ma=0;
    for (int i=1;i<=n;i++){
        sig+=a[i];
        ma=max(ma,sig);
    }
    for (int i=n;i;i--) dp[i]=max(dp[i],dp[i+1]+a[i]);
    sig=0;
    ll mi=0;
    //cout << ma << endl;
    ll ans=1e9;
    for (int j=1;j<=2;j++){
        sig=0,mi=0;
        for (int i=1;i<=n;i++){
            if (s[i-1]=='?'){
                if (sig+1+dp[i+1]>ma){
                    sig--;
                    mi=min(mi,sig);
                }
                else{
                    sig++;
                    mi=min(sig,mi);
                }
            }
            else{
                sig+=a[i];
                mi=min(mi,sig);
            }
        }
            ans=min(ans,ma-mi);
        ma++;
    }
    cout <<ans << endl;

}


Measured memory_bytes: 20012
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) {
    cin >>a[i];
  }
  ll ans=0;
  rep(i,n) ans+=a[i];
  cout <<ans-n<<endl;
}

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

int main()
{
	vector<int> ff = {4, 1, 4, 1, 2, 1, 2, 1};
	vector<int> v(8);
	while (true){
		for (int i = 0; i < 8; i++){
			if (scanf("%d", &v[i]) == EOF) return 0;
		}
		pair<int, vector<int>> mini;
		mini.first = 114514;
		for (int i = 0; i < 8; i++){
			int cnt = 0;
			vector<int> f;
			for (int j = 0; j < 8; j++){
				int x = (i + j) % 8;
				f.push_back(ff[x]);
				cnt += max(v[j] - ff[x], 0);
			}
			mini = min(mini, make_pair(cnt, f));
		}
		for (int i = 0; i < 8; i++){
			if (i) printf(" ");
			printf("%d", mini.second[i]);
		}
		puts("");
	}
	return 0;
}

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

using namespace std;

int main() {

  int n;
  bool f[55][35];

  while(1){

    memset(f, false, sizeof(f));

    cin>>n;
    if(n == 0) break;

    for(int i=0; i<n; i++){
      int t;
      cin>>t;
      if(t == 0) break;
      for(int j=0; j<t; j++){
        int tt;
        cin>>tt;
        f[i][tt] = true;
      }
    }

    set<int> s[55];
    for(int i=0; i<50; i++){
      s[i].insert(i);
    }
    int ans = 1;

    for(int day = 1; day <= 30; day++){
      set<int> v;
      for(int mem = 0; mem < n; mem++){
        if(f[mem][day]){
          set<int>::iterator it = s[mem].begin();
          while(it != s[mem].end()){
            v.insert((*it));
            it++;
          }
        }
      }

      for(int mem = 0; mem < n; mem++){
        if(f[mem][day]){
          s[mem] = v;
        }
      }
      bool flag = false;
      for(int mem = 0; mem < n; mem++){
        if(s[mem].size() == n) flag = true;
      }
      if(flag) break;
      ans++;
    }

    if(ans == 31) cout<<-1<<endl;
    else cout<<ans<<endl;

  }

  return 0;
}

Measured memory_bytes: 3188
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

def koch(d, p1, p2):
    

    if d == 0:
        return
    
    t = Point((p1.x + 2 * p2.x )/3,(p1.y + 2 * p2.y )/3 )
    s = Point((p2.x + 2 * p1.x )/3,(p2.y + 2 * p1.y )/3 )
    
    u = Point((t.x-s.x) * (math.cos(math.pi / 3)) - (t.y-s.y) * (math.sin(math.pi / 3)) + s.x, (t.x-s.x) * (math.sin(math.pi / 3)) + (t.y-s.y) * (math.cos(math.pi / 3)) + s.y)
    #print(s.x, s.y , t.x, t.y, u.x, u.y)
    

    
    koch(d - 1, p1, s)
    print(s.x, s.y)
    koch(d - 1, s, u)
    print(u.x, u.y)
    koch(d - 1, u, t)
    print(t.x, t.y)
    koch(d - 1, t, p2)


n = int(input())
    
p1 = Point(0, 0)
p2 = Point(100, 0)

print(p1.x, p1.y)
koch(n, p1, p2)
print(p2.x, p2.y)




Measured memory_bytes: 5788
#include <stdio.h>
#include <string.h>
int  main()
{int i,j,n,k;
char c[100008];
while(~scanf("%d",&n))
  {scanf("%s",c);getchar();
   k=strlen(c);
   for(i=0,j=1;i<k-1;i++)
    if(c[i]!=c[i+1])j++;
     printf("%d\n",j);
     }
  }

Measured memory_bytes: 384
import sys
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
K = i()
x = l()
ans = 0
for i in range(N):
    ans += min(x[i],K-x[i])*2
print(ans)

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

int main() {
  int n;
  cin >> n;
  int a = 0, b = 0, ba = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    for (int i = 0; i < str.length() - 1; i++) {
      if (str[i] == 'A' && str[i + 1] == 'B') { ans++; }
    }
      if (str[0] == 'B' && str[str.length() - 1] == 'A') {
        ba++;
      } else if (str[0] == 'B') { b++; } else if (str[str.length() - 1] == 'A') { a++; }
  }
  if (ba > 0) {
    ans += ba - 1;
    if (a > 0) {
        ans++;
    } else {
        a = 1;
    }
  }
  ans += (a > b) ? b : a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define debb(x) cout << (x) << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;


void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    // iota(itf,its) ;
    // n=unique(a+1,a+1+n,n)-(a+1);

	
	ll d,t,s;
	cin >> d >> t >> s;
	bool flag=(s*t >= d);
	if(flag){
		Yes;
	}
	else{
		No;
	}

    return 0;
}


Measured memory_bytes: 3664
def main():
    N = int(input())
    S = input()
    a = [0, 0, 0]
    for i in range(N):
        if S[i] == 'R':
            a[0] += 1
        elif S[i] == 'G':
            a[1] += 1
        else:
            a[2] += 1
    count = a[0] * a[1] * a[2]
    for i in range(N - 1):
        for j in range(1, N):
            if i - j < 0 or N <= i + j:
                break
            if S[i - j] != S[i] and S[i] != S[i + j] and S[i - j] != S[i + j]:
                count -= 1
    print(count)


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

multiset<int> S;
int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		int a;
		cin >> a;
		S.insert(a);
	}

	int m;
	cin >> m;
	FOR(i,0, m)
	{
		int a;
		cin >> a;
		multiset<int>::iterator it = S.find(a);
		if (it == S.end())
		{
			cout << "NO" << endl;
			return 0;
		}

		S.erase(it);
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define big 1000000007
vector<vector<int> > done(105, vector<int>(100005));
vector<vector<ll> > memo(105, vector<ll>(100005));
vector<vector<ll> > data1(105, vector<ll>(2));
ll n, w;
ll dp(ll i, ll m)
{
    if (m>w){
        return -1000000000;
    }
    if (i==n){
        return 0;
    }
    if (done[i][m] == 1)
    {
        return memo[i][m];
    }
    ll res = 0;
    res = max(data1[i][1] + dp(i + 1, m +data1[i][0]), dp(i + 1, m));
    done[i][m] = 1;
    memo[i][m] = res;
    return res;
}
int main()
{
    
    cin >> n >> w; //商品がn個あって、w以下の重さで価値を最大化せよ
    rep(i, n)
    {
        cin >> data1[i][0] >> data1[i][1];
    }
    cout << dp(0, 0); //0番目の商品を選ぶ前に、今の重さが0の時に最大値
}

Measured memory_bytes: 124536
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> mod(2019,0);
    string s;
    cin >> s;
    int n = s.size();
    int x=0;
    int keta=1;
    mod.at(0)++;
    for(int i=0; i<n; i++){
        x += (s.at(n-1-i) -'0') * keta;
        keta = (keta*10) %2019;
        //cout << x <<endl;
        mod.at(x%2019)++;
    }
    
    int ans=0;
    for(int i=0; i<2019; i++){
        if(mod.at(i) >= 2) ans += mod.at(i)*(mod.at(i)-1)/2;
    }
    cout << ans << endl;
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];

bool check (int x) {
	if(x == 1)return is_sorted(a + 1, a + n + 1);

	map < int, int > s;
	for (int i = 2; i <= n; i ++) {
		if (a[i] > a[i-1]) continue;
	    if (s.upper_bound(a[i]) != s.end()) {
    		s.erase(s.upper_bound(a[i]));
    	}
    	int k = a[i];
    	s[k]++;

    	while (k > 0 && s[k]==x) s.erase(k), s[--k]++;
    	if(k == 0) return 0;
	}
	return 1;
}

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}	

	int l = 0, r = 1e9 + 1;
	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (check(md))
			r = md;
		else
			l = md;
	}
	assert(r != 1e9 + 1);


	cout << r << '\n';
   	return Accepted;
}

// B...a

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    long int n;
    cin >> n;
    long int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    long int min = 10000000;
    int c = 0;
    for(int i=0;i<n;i++){
        if(min >= p[i]){
            c++;
            min = p[i];
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 45

int F[N];
makeFibonacci(){
  int i;

  F[0] = 1;
  F[1] = 1;
  for(i=2;i<N;i++){
    F[i] = F[i-2] + F[i-1];
  }
}

int main(){
  int n;

  makeFibonacci();
  scanf("%d",&n);
  printf("%d\n",F[n]);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  S.erase(unique(S.begin(), S.end()), S.end());
  cout << S.length() << '\n';
  return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
ld n,a[8],b[8],tot;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            tot+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
        }
    }
    cout<<setprecision(15)<<tot*2/n<<endl;
}


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

int main() {
    int N;
    cin >> N;
    double count = 0;
    double odd = 0;

    for(int i = 1; i < N+1; i++){
        count ++;
        if(i % 2 == 1) {
            odd ++;
        }
    }

    double ans = odd / count;
    cout << ans << endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<double> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    //double ans = 0.0;
    for (int i = 1; i < N; ++i){
      A[i]=(A[i-1]+A[i])/2;
    }
      
    cout << A[N-1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    int_fast8_t a, b, c;
    scanf("%" SCNdFAST8 " %" SCNdFAST8 " %" SCNdFAST8, &a, &b, &c);
    printf("%s\n", b - a == c - b ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
A = list(map(int, input().split()))
MAX = max(len(bin(K))-2, len(bin(max(A)))-2)
bK = bin(K)[2:].zfill(MAX)
degs = [0]*MAX # 2^iの位に１を持つ数の個数
for i in range(N):
    b = bin(A[i])[2:].zfill(MAX)
    for d in range(MAX):
        if b[d] == "1":
            degs[d] += 1

tot = 0
dp = [0]*MAX # dp[i]: 上からiケタ目が1でかつ初めて許した場合
for f in range(MAX):
    t = 2 ** (MAX-1)
    ans = 0
    is_free = 0
    for i in range(MAX):
        d = degs[i]
        if i == f:
            if bK[i] == "1":
                is_free = 1
        elif i < f:
            if bK[i] == "1":
                d = max(d, N-d)
        elif i > f and is_free:
            d = max(d, N-d)
        ans += t * d
        t //= 2
    tot = max(tot, ans)
t = 2 ** (MAX-1)
ans = 0
for i in range(MAX):
    d = degs[i]
    if bK[i] == "1":
        d = max(d, N-d)
    ans += t*d
    t //= 2
tot = max(tot, ans)    
print(tot)

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= q; i++)
    {
        int x;
        cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= n; i++)
    {
        int cur = k - q + cnt[i];
        if (cur <= 0)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    return 0;
}

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

int main() {
    int n=0,w=0;
    cin>>n>>w;
    long long arr[n][2];
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1];
    long long dp[n][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if (i==0){
                if (j>=arr[i][0])
                   dp[i][j]=arr[i][1];
            }
            else if (j<arr[i][0])
                dp[i][j]=dp[i-1][j];
            else{
                // cout<<arr[i][1]<<" "<<dp[i-1][j-arr[i][0]]<<endl;
                dp[i][j]=max(arr[i][1]+dp[i-1][j-arr[i][0]],dp[i-1][j]);
            }
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<=w;j++)
    //        cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[n-1][w]<<endl;
}


Measured memory_bytes: 81556
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    int now = 0;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.push_back({b,a});
    }
    sort(v.begin(),v.end());
    for(auto u : v){
        if(now + u.second > u.first){
            cout << "No" << endl;
            return 0;
        }
        now += u.second;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,k;
  cin >> a >> b >> k;
  int tmp;
  if(a>0){
    if(k>a){
      k-=a;
      a=0;
    }else{
      a-=k;
      k=0;
    }
  }
  if(b>0){
    b=max(0L,b-k);
  }
  cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<double> v(N); cin >> v;
    sort(ALL(v));

    double ans = v[0];

    FOR(i,1,N){
      ans = (ans + v[i]) / 2;
    }


    
    cout << fixed << setprecision(12) << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int r,c,n;
    cin >> r >> c >> n;
    vp v;
    rep(i,n){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int f1 = 0;
        int f2 = 0;
        if(x1==0||x1==r)f1=1;
        if(y1==0||y1==c)f1=1;
        if(x2==0||x2==r)f2=1;
        if(y2==0||y2==c)f2=1;
        if(f1+f2==2){
            int vf = 0;
            int vs = 0;
            if(x1==0){
                vf = y1;
            }else if(x1==r){
                vf = c + r + c - y1;
            }else{
                if(y1==c){
                    vf = c + x1;
                }else{
                    vf = c + r + c + r - x1;
                }
            }
            if(x2==0){
                vs = y2;
            }else if(x2==r){
                vs = c + r + c - y2;
            }else{
                if(y2==c){
                    vs = c + x2;
                }else{
                    vs = c + r + c + r - x2;
                }
            }
            if(vs < vf)swap(vf,vs);
            v.push_back(P(vf,vs));
        }
    }

    sort(v.begin(), v.end());

    rep(i,v.size()){
        //cout << v[i].first << ' ' << v[i].second << endl;
    }

    stack<P> sta;

    rep(i,v.size()){
        if(sta.size()==0){
            sta.push(v[i]);
        }else{
            while(sta.size()>0){
                if(sta.top().second < v[i].first){
                    sta.pop();
                }else{
                    break;
                }
            }
            if(sta.size()==0){
                sta.push(v[i]);
            }else{
                if(sta.top().second < v[i].second){
                    cout << "NO" << endl;
                    return 0;
                }else{
                    sta.push(v[i]);
                }
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}
 
 


Measured memory_bytes: 1400
#include <math.h>
#include <iostream>
using namespace std;

int main() 
{
	int N;
	cin >> N;
	if (N % 1000 == 0)
	{
		cout << "0";
	}
	else
	{
		int K = (1000 - (N % 1000));
		cout << ceil(K);
	}
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, c = 0;
    ll z = 1;
    bool b = 0;
    string s;
    cin >> n >> s;
    for (int i = 1; i <= n + n; i++) {
        if (s[i - 1] == 'B') {
            if (!b) a[i] = 1, b = 1;
            else b = 0;
        } else {
            if (!b) b = 1;
            else a[i] = 1, b = 0;
        }
    }
    int d = 0;
    for (int i = 1; i <= n + n; i++) if (a[i]) d++;
    if (d != n) z = 0;
    for (int i = 1; i <= n + n; i++) {
        if (a[i]) c++;
        else z = z * c % mod, c--;
    }
    for (int i = 1; i <= n; i++) z = z * i % mod;
    cout << z;
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class BIT {
    int size;
    VL dat;
public:
    void init(int in) {
        size = in;
        dat.clear();
        dat.resize(size, 0);
    }
    ll sum(int i) {
        ll ret = 0;
        while (i >= 0) {
            ret += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return ret;
    }
    void add(int i, ll x) {
        while (i <= size) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    int n;
    cin >> n;
    VI a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = (((ll)n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


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


int main(){
    int n,q;
    cin >> n >> q;
    queue<string> name;
    queue<int> time;
    string str;
    int num;
    for(int i=0; i<n; i++){
        cin >> str; name.push(str);
        cin >> num; time.push(num);
    }    
    long long process_time=0;
    while(time.empty()!=1){
        if(time.front()<=q){
            process_time+=time.front();
            time.pop();
            cout << name.front() << " " <<process_time << endl;
            name.pop();
        }
        else{
            process_time+=q;
            time.push(time.front()-q);
            time.pop();
            name.push(name.front());
            name.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 5688
#include <cstdio>
#include <algorithm>
#include <utility>

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

#define pow CHANGETHENAMESTUPID

using namespace std;

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

void load() {

}

ll solve() {
	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	ll raz = abs(a - b);
	if (raz % 2 == 0) return raz / 2;
	if (a > b) swap(a, b);
	ll lij = a - 1 + 1 + (b - a - 1) / 2;
	ll des = n - b + 1 + (b - a - 1) / 2;
	return min(lij, des);
}

int main() {
	load();
	printf("%lld\n", solve());
	return 0;
}


Measured memory_bytes: 128
def m():
    n = int(input())
    red = [list(map(int, input().split())) for _ in range(n)]
    blue = [list(map(int, input().split())) for _ in range(n)]
    red.sort(key=lambda x: x[1], reverse=True) # yの大きい順
    blue.sort(key=lambda y: y[0]) # xの小さい順
    ans = 0
    for b in blue:
        for r in red:
            if r[0] < b[0] and r[1] < b[1]:
                red.remove(r)
                ans +=1
                break
    return ans

print(m())


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	cout << n / 3600 << ":";
	n %= 3600;
	cout << n / 60 << ":";
	n %= 60;
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> a;
  for(int i=1;i<200;i++){
    if(A%i==0 && B%i==0){
      a.push_back(i);
    }
  }
  reverse(a.begin(),a.end());
  cout<<a.at(K-1)<<endl;
  return 0;
}

Measured memory_bytes: 256
def xor_circle(N: int, A: list)->bool:
    M = max(A)

    b = 1
    while b <= M:
        zero, one = 0, 0
        for a in A:
            if a & b:
                one += 1
            else:
                zero += 1

        if one != 2 * zero and one != 0:
            return False
        b <<= 1

    return True


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    yes = xor_circle(N, A)
    print('Yes' if yes else 'No')


Measured memory_bytes: 14116
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;
ll n,q,m,ans,a[51],b[51],c[51],d[51];
ll dd[20];

void dfs(ll it,ll now[]){
    if(it==n){
       ll score=0;
       for(int i=0;i<q;i++){
           if(now[b[i]]-now[a[i]]==c[i]) score+=d[i];
       }
       ans=max(ans,score);
       return; 
    }
    ll st;
    if(it==0) st=1;
    else{
        st=now[it-1];
    }
    for(int i=st;i<m+1;i++){
        now[it]=i;
        dfs(it+1,now);
    }
}

int main(void){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    dfs(0,dd);
    cout<<ans<<endl;
}
 



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<vector<i64>> G(N);
  rep(i,0,M) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<i64> four;
  bool six = false;
  rep(i,0,N) {
    if(G[i].size() % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    if(G[i].size() >= 6) six = true;
    if(G[i].size() == 4) four.emplace_back(i);
  }
  if(six || four.size() >= 3) {
    cout << "Yes" << endl;
    return 0;
  }
  if(four.size() <= 1) {
    cout << "No" << endl;
    return 0;
  }

  i64 ans = 0;
  queue<int> que;
  que.push(four[0]);
  vector<int> vis(N);
  vis[four[0]] = true;
  while(!que.empty()) {
    int v = que.front();
    que.pop();
    for(auto t: G[v]) {
      if(vis[t]) continue;
      if(t == four[1]) {
        ans++;
        continue;
      }
      que.push(t);
      vis[t] = true;
    }
  }
  if(ans == 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 6144
n=int(input())
s=list(input())
M=0
for i in range(n-1):
    L=s[:i+1]
    R=s[i+1:]
    check={}
    cnt=0
    for c in L:
        if c not in check:
            check[c]=1
    for c in check:
        if c in R:
            cnt+=1
    M=max(M,cnt)
print(M)

Measured memory_bytes: 3060
import numpy as np
from sys import stdin

'''
Reference: https://codeforces.com/blog/entry/75046#comment-591494 (1-based index)

(0-based index)

For a sequence A[l]..A[k]..A[r] with sum S contributes l * (N - r) to answer.
    0, 1, 2, ..., l....k....r, ..., N - 2, N - 1
    x  x  x   x   x         v   v     v      v
There are (l + 1) `x` and (N - r) `v`.

Enumerate all possible sequence is impossible. 
Consider all sequeuces with sum S and **ends** at specific r:
    A[l1]...A[r] -> l1 * (N - r)
    A[l2]...A[r] -> l2 * (N - r)
    A[l3]...A[r] -> l3 * (N - r)
    .
    .
    .
which contributes (l1 + l2 + ... + lm) * (N - r) in total.

We can find *sum of left index for all valid sequence* for each r using DP.

    dp[i][s] = the sum of left index for all sequence that
                    1. ends at i
                    2. has sum s
    
    dp[i][:A[i]] = 0  since any sequence ends at i has sum >= A[i]

    dp[i][A[i]] = i + 1
    dp[i][s] = sum(dp[j][s - A[i]] for j in range(i))

    Take A = [2, 3, 4] for example, sequences that end at A[2] are:
    
                   [4] -> dp[2][4] = 3
             [2,    4] ↘
                [3, 4] -> dp[2][s] = dp[2][s - 4] for all s
             [2, 3, 4] ↗
    
    The answer is sum(dp[r][S] * (N - r) for r in range(N))

So the naive implementation is:

    dp = np.zeros((N, max(S, A.max()) + 1), dtype=np.int64)
    for i, a in enumerate(A):
        dp[i, a] = i + 1
        for s in range(a + 1, S + 1):
            dp[i, s] = dp[:i, s - a].sum() % M  # here can be optimized
    
    ans = 0
    for i in range(N):
        ans += (N - i) * dp[i, S]
        ans = ans % M

has time O(N * S * N) which results in TLE.

Using another array to store the cumsum (prefix sum) of dp solves the problem.
One can compress the dp matrix to vector to reduce memory usage.
'''

N, S = map(int, input().split())
A = np.int32(input().split())
M = 998244353
V = max(A.max(), S)

ans = 0
cs = np.zeros(V + 1, dtype=np.int64)
for i, a in enumerate(A):
    dp = np.zeros(V + 1, dtype=np.int64)
    dp[a] = i + 1
    dp[a + 1 : S + 1] = cs[np.arange(a + 1, S + 1) - a]
    cs = (cs + dp) % M
    ans = (ans + (N - i) * dp[S]) % M
print(ans)


Measured memory_bytes: 12508