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

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

    int num[100010] = {};
    int a, b;
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        a--; b--;
        num[a]++;
        num[b]++;
    }

    for(int i = 0;i < n;i++){
        if(num[i] % 2 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


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

int main(){
  string s;
  string t ="CODEFESTIVAL2016";
  cin >> s;
  int count=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]) count++;
  }
  cout << count << endl;
  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    vector<ll> A(N+1), cum(N+1);
    REP(i,N+1) cin >> A[i];
    cum[0] = A[0];
    for(int i=1;i<=N;i++) cum[i] = cum[i-1] + A[i];

    if(N == 0 && A[0] == 1){
        cout << 1 << endl;
        return;
    }
    if(A[0] != 0){
        cout << -1 << endl;
        return;
    }

    ll cur = 1, ans = 0;
    REP(i,N+1){
        // cout << i << " " << cur << endl;
        if(cur - A[i] < 0){
            cout << -1 << endl;
            return;
        }
        ans += cur;
        cur -= A[i];
        if(cur > cum[N] - cum[i]){
            cout << -1 << endl;
            return;
        }
        cur = min(cur * 2, cum[N] - cum[i]);
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s;
	cin >> s;

	for(int i = 0; i < s.length(); ++i)
	{
		cout << "x";
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

double k(double A){
    return (A + 1)/2;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;cin >> N >> K;
    vector<double> p(N);
    REP(i,N) cin >> p[i];
    double maxv = 0,sum = 0;
    REP(i,N){
        sum += k(p[i]);
        if(i+1 > K) sum -= k(p[i-K]);
        maxv = max(maxv,sum);
    }
    cout << setprecision(20) << maxv << endl;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

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

    set<string> a;

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

        a.insert(s);
    }

    if (a.size() == 3)
    {
        println("Three");
    }
    else
    {
        println("Four");
    }
}


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

int main(){
  ll x;
  cin >> x;

  ll ans = 0;
  ans += (x/500)*1000;
  x = x%500;
  ans += (x/5)*5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
a = max(max(X),x)
b = min(min(Y),y)
if(a < b):
  print("No War")
else:
  print("War")

Measured memory_bytes: 9112
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = 0LL;
//    ans += (2 * o);
//    ll com = min({i,j,l});
//    ans += (6 * com);
//    i -= com,j -= com,l -= com;
//    ans += (i / 2) * 4;
//    ans += (j / 2) * 4;
//    ans += (l / 2) * 4;
    ans += o;
//    ans += (l / 2) * 2;
//    ans += (j / 2) * 2;
//    ans += (i / 2) * 2;
//    if(l % 2 && j % 2 && i % 2){
//        ans+=3LL;
//    }
    int ijl = (i % 2) + (j % 2) + (l % 2);
    if (ijl == 0) {
        ans += (l / 2) * 2;
        ans += (j / 2) * 2;
        ans += (i / 2) * 2;
    } else if (ijl == 1) {
        ans += (l / 2) * 2;
        ans += (j / 2) * 2;
        ans += (i / 2) * 2;
    } else if (ijl == 2) {
        if(i > 0 && j > 0 && l > 0){
            ans += 3;
            i--;
            j--;
            l--;
        }
        ans += (l / 2) * 2;
        ans += (j / 2) * 2;
        ans += (i / 2) * 2;
    } else if (ijl == 3) {
        if(i > 0 && j > 0 && l > 0){
            ans += 3;
            i--;
            j--;
            l--;
        }
        ans += (l / 2) * 2;
        ans += (j / 2) * 2;
        ans += (i / 2) * 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
 
  string X, Y;
  cin >> X >> Y;
  
  if (X == Y) {
    cout << "=" << endl;
  } else if (X < Y) {
    cout << "<" << endl;
  } else {
    cout << ">" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>

char ans[210];
char s[110],t[110];
int main(){
	int n;
	scanf("%d %s %s",&n,s,t);
	int i;
	for(i=0;i<=n;i++){
		int flag=1;
		for(int j=0;i+j<n;j++)flag&=s[i+j]==t[j];
		if(flag)break;
	}
	printf("%d",n+i);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+5;
char S[N][N];
int f[N][N],dr[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int que[N*N],s,t,h,w,sx,sy,tx,ty;
signed main(void){
	cin>>h>>w>>sx>>sy>>tx>>ty;
    for(int i=0;i<h;i++) {
	    cin>>S[i];
       for(int j=0;j<w;j++)
           f[i][j]=S[i][j]=='#';
    }
	f[--sx][--sy]=1;
    tx--;
	ty--;
    que[t++]=sx*N+sy;
    while(s<t){
       	int s1=s;
       	while(s<t){
           	int x=que[s++],y=x%N;
           	x/=N;
           	for(int i=0;i<4;i++){
               	int x1=x+dr[i][0];
			   	int y1=y+dr[i][1];
               	if((unsigned)x1>=h||(unsigned)y1>=w||f[x1][y1]){
               		continue;
			   	}
                f[x1][y1]=f[x][y];
               	que[t++]=x1*N+y1;
           	}
       	}
       	while(s1<s){
           	int x=que[s1++];
			int y=x%N;
           	x/=N;
           	for(int i=-2;i<3;i++) {
                for(int j=-2;j<3;j++) {
                    int x1=x+i;
					int y1=y+j;
                    if((unsigned)x1>=h||(unsigned)y1>=w||f[x1][y1]){
                    	continue;
					}
                    f[x1][y1]=f[x][y]+1;
                    que[t++]=x1*N+y1;
                }
            }
        }
    }
	cout<<(f[tx][ty]?f[tx][ty]-1:-1)<<endl;
    return 0;
}

Measured memory_bytes: 10328
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int part(int a[],int p,int r){
    int x=a[r];
    int i=p-1;
    for (int j = p; j < r; ++j) {
        if (a[j]<=x){
            i+=1;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

int main() {
    int n,a[100000];
    scanf("%d",&n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }

    int pos=part(a,0,n-1);

    for (int j = 0; j <n ; ++j) {
        if (j>0)
            printf(" ");
        if (j==pos)
            printf("[");
        printf("%d",a[j]);
        if (j==pos)
            printf("]");
    }
    printf("\n");
    
    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	// 例外処理
	if (10 % p == 0) { // 2 or 5
		int ans = 0;
		rep (r, n) {
			if ((s[r] - '0') % p == 0) {
				ans += r + 1;
			}
		}
		cout << ans;
		return 0;
	}

	vec<int> d(n+1);
	int ten = 1;
	for (int i = n - 1; i >= 0; i--) {
		int a = (s[i] - '0') * ten % p;
		d[i] = (d[i + 1] + a) % p;
		ten *= 10;
		ten %= p;
	}

	vec<int> cnt(p);
	int ans = 0;
	for (int i = n; i >= 0; i--) {
		ans += cnt[d[i]];
		cnt[d[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2180
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define memset(a,first,last,val) fs(i,first,last,1) a[i]=val
#define nl cout<<"\n";
#define chk(x) cout<<#x<<x<<" ", nl
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define mid(a,b) ((a+b)/2)
#define pb push_back
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

vl vb;
int N;

class triplet{ll f, s, t;};

vl in(ll n){
    vl ar;
    ll x;
    f(i,n)
    cin>>ar[i];
    return ar;
}
vll in_pr(ll n){
    vll ar;
    ll x,y;
    f(i,n)
    {cin>>x>>y;
    ar[i]={x,y};
    }return ar;
}
void out(vl v, char ch='\0'){
    fl(i,v)
    cout<<i<<ch;
}

void printArray(vector<int> arr, int n) 
{ 
    ll num=0;
    for (int i = 0; i < n; i++) 
    num*=10, num+=i;

    if(n==N)
    vb.pb(num);
        
} 

int printfactorialof(int n){
    if(n<=1)
        return 1;
    
    return n*printfactorialof(n-1);
}

void solve(){
    ll a,b;
    cin>>a>>b;
    if(a+b <= 16){
        if(a<=8 && b<=8)
            cout<<"Yay!",nl
        else
        {
            cout<<":(",nl
        }
        
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
   return 0;
}

Measured memory_bytes: 3616
n=int(input())
x =list(map(int,input().split()))
mn=x[0]
mx=x[0]
sum=x[0]
for i in range(1,n):
    mn=min(mn,x[i])
    mx=max(mx,x[i])
    sum+=x[i]
    
print(mn,mx,sum)


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

void chmax(int& a, int b){
    a = max(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(3*N);
    for(int i=0; i<3*N; i++) cin >> A[i], A[i]--;

    vector<vector<int>> dp(N, vector<int>(N, -1e9));
    dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0;
    int fix = 0, mx = 0;
    vector<int> mxr(N, -1e9);
    mxr[A[0]] = mxr[A[1]] = 0;

    for(int t=0; t<N-1; t++){
        vector<int> vs;
        for(int k=0; k<3; k++) vs.push_back(A[3*t+2+k]);
        sort(vs.begin(), vs.end());
        if(vs[0] == vs[2]){
            fix++;
            continue;
        }

        vector<tuple<int, int, int>> upd;
        
        if(vs[0] == vs[1] || vs[1] == vs[2]){
            int v2 = vs[1], v1;
            for(int v : vs) if(v != v2) v1 = v;
            for(int j=0; j<N; j++) upd.emplace_back(dp[v2][j]+1, v1, j);
        }

        for(int k=0; k<3; k++){
            int v = vs[k], a = vs[(k+1)%3], b = vs[(k+2)%3];
            upd.emplace_back(dp[v][v]+1, a, b);
            upd.emplace_back(mx, v, a);
            upd.emplace_back(mx, v, b);
            for(int i=0; i<N; i++) upd.emplace_back(mxr[i], v, i);                        
        }

        for(auto& [d, a, b] : upd){
            chmax(dp[a][b], d);
            chmax(dp[b][a], d);
            chmax(mx, d);
            chmax(mxr[a], d);
            chmax(mxr[b], d);
        }
    }

    int L = A.back();
    int ans = max(mx, dp[L][L]+1) + fix;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19472
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=(b);a<(c);a++)
#define PER(a,b,c) for(ll a=(b);a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

ll mod=1E9+7;

int main(){
    ll N=ii();
    ll K=ii();

    ll ret = 0;
    REP(k,K,N+2){
        ll a = (N)*(N+1)/2;
        ll b = (N-k)*(N-k+1)/2;
        ll c = k*(k-1)/2;
        ret+=a-b-c+1;
        ret%=mod;
    }
    oie(ret);
 
    return 0;
}

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

int main(){
  int64_t Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;

  int64_t P1= min(S, min(4*Q, 2*H));
  int64_t P2= min(D, 2*P1);

  int64_t ans= (N%2==1) ? P2*(N/2)+ P1
                        : P2*(N/2);
  cout << ans << endl;
}

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

int main()
{
    int n ,k;
    cin>>n;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int m[k] , min[n] , m1;
    min[0]=0;
    min[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
    {
        for(int j=0;j<k;j++)
        {
            if(i-j-1>=0)
           {

             m[j]=min[i-j-1]+abs(a[i]-a[i-j-1]);

            if(j==0)
            {
                m1=m[j];
            }
            else if(m1>m[j])
            {
                m1=m[j];
            }
           }
        //min2=min[i-2]+abs(a[i]-a[i-2]);
        }

         min[i]=m1;
    }

    cout<<min[n-1];

}


Measured memory_bytes: 1024
from itertools import product

N = int(input())

memo = [0]*N

for x,y,z in product(range(1,100),repeat=3):
    t = x*x+y*y+z*z+x*y+y*z+z*x
    if 0 < t <= N:
        memo[t-1] += 1

print(*memo,sep='\n')

Measured memory_bytes: 68380
#セグ木
from collections import deque
def f(L, R): return L|R # merge
def g(old, new): return old^new  # update
zero = 0 #零元

class segtree:
    def __init__(self, N, z):
        self.M = 1
        while self.M<N: self.M *= 2
        self.dat = [z] * (self.M*2-1)
        self.ZERO = z

    def update(self, x, idx, l=0, r=-1):
        if r==-1: r = self.M
        idx += self.M-1
        self.dat[idx] = g(self.dat[idx], x)
        while idx > 0:
            idx = (idx-1)//2
            self.dat[idx] = f(self.dat[idx*2+1], self.dat[idx*2+2])

    def query(self, a, b=-1, idx=0, l=0, r=-1):
        if r==-1: r = self.M
        if b==-1: b = self.M
        q = deque([])
        q.append([l, r, 0])
        ret = self.ZERO
        while len(q):
            tmp = q.popleft()
            L = tmp[0]
            R = tmp[1]
            if R<=a or b<=L: continue
            elif a<=L and R<=b:
                ret = f(ret, self.dat[tmp[2]])
            else:
                q.append([L, (L+R)//2, tmp[2]*2+1])
                q.append([(L+R)//2, R, tmp[2]*2+2])
        return ret
n = int(input())
s = list(input())
q = int(input())
seg = segtree(n+1, 0)

for i in range(n):
    num = ord(s[i]) - ord("a")
    seg.update((1<<num), i)
for _ in range(q):
    a, b, c = input().split()
    b = int(b) - 1
    if a == "1":
        pre = ord(s[b]) - ord("a")
        now = ord(c) - ord("a")
        seg.update((1<<pre), b)
        seg.update((1<<now), b)
        s[b] = c
    else:
        q = seg.query(b, int(c))
        bin(q).count("1")
        print(bin(q).count("1"))


Measured memory_bytes: 100008
s = input()
if(s == "SUN"): print("7")
if(s == "MON"): print("6")
if(s == "TUE"): print("5")
if(s == "WED"): print("4")
if(s == "THU"): print("3")
if(s == "FRI"): print("2")
if(s == "SAT"): print("1")


Measured memory_bytes: 3060
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n, d = MII()
    cnt = 0
    for i in range(n):
        x, y = MII()
        if x**2 + y**2 <= d**2:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, B;
    cin >> A >> B;

    int cnt = 0;
    repi(i, A, B + 1) {
        string S = to_string(i);
        string T = S;
        reverse(all(T));
        if(S == T) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    int a, b, c, ans;
    cin >> a >> b >> c;

    ans = c - (a - b);
    if(c - (a - b) < 0) ans = 0;
    cout << ans << endl;

}




Measured memory_bytes: 256
import copy
h,w=map(int,input().split())

def fun(aa,x,y):
    a=copy.deepcopy(aa)

    if h<=y or w<=x:
        return False

    if y==h-1 and x==w-1:
        count = 0
        for i in a:
            count += i.count('#')
        if count==1:
            return True
        else:
            return False

    if a[y][x]!="#":
        return False

    a[y][x]="."

    if fun(a,x+1,y) or fun(a,x,y+1):
        return True

    return False

a=[["" for i in range(w)] for j in range(h)]
for i in range(h):
    s=input()
    for j in range(w):
        a[i][j]=s[j]



print("Possible" if fun(a,0,0) else "Impossible")

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long i,s=0;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		s+=i;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll a[22][22];
mint dp[2][100005];
bool check[100005];

vector<ll> g[100005];

void dfs(ll u,ll p){
  if (check[u])return;
  check[u]=true;
  dp[0][u]=1;
  dp[1][u]=1;

  for (ll to:g[u]){
    if (to==p)continue;
    dfs(to,u);
    dp[0][u]*=(dp[1][to]+dp[0][to]);
    dp[1][u]*=dp[0][to];
  }
//  cout<<dp[0][u]<<"U"<<u<<endl;
}

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

  rep(i,n-1){
    ll x1,y1;
    cin>>x1>>y1;
    x1--;y1--;
    g[x1].push_back(y1);
    g[y1].push_back(x1);
  }

  rep(i,2)rep(j,100005)dp[i][j]=1;
  dfs(0,-1);
  mint ans=dp[0][0]+dp[1][0];
  cout<<ans;

}


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

#define ll long long

using namespace std;

ll arr[100005];
ll dp[100005],n;
ll func(ll x)
{
    if(x==n-1)
        return 0;
    if(x>=n)
        return 1e18;
    if(dp[x]!=-1)
        return dp[x];
    ll way1= abs(arr[x]-arr[x+1])+func(x+1);
    ll way2=abs(arr[x]-arr[x+2])+func(x+2);
    return dp[x]=min(way1,way2);
}

int main()
{
    memset(dp,-1,sizeof(dp));
    ll i,j,k,l,m;
    cin >> n;
    for(i=0;i<n;i++)
        cin >> arr[i];
    arr[n]=1e18;

    cout << func(0);
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,K,x,y,p,q;
	cin>>n;
	vector<long long>A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	long long dp[n][n];
	for(int i=0;i<n;i++){
		dp[i][i]=A[i];
	}
	for(int k=1;k<n;k++){
		for(int i=0;i<n-k;i++){
			int j=i+k;
			dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1]);
		}
	}
	cout<<dp[0][n-1]<<"\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();
}

Measured memory_bytes: 49776
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 0
max_R = 0
for c in s:
    if c == 'R':
        max_R += 1
        ans = max(ans, max_R)
    else:
        max_R = 0
print(ans)

Measured memory_bytes: 74580
def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod

X, Y = map(int, input().split())
mod = 10 ** 9 + 7
if (X + Y) % 3:
    print(0)
else:
    if 2 * Y - X < 0 or 2 * X - Y < 0:
        print(0)
    else:
        n = (X + Y) // 3
        r = (2 * Y - X) // 3
        print(comb(n, r))


Measured memory_bytes: 3064
#include <iostream>

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

constexpr int L = 30000 - 12;

constexpr int A[8][8] = {   
                {}, 
                {6}, // 1
                {3, 9}, // 2
                {3, 6, 9}, // 3
                {2, 3, 4, 9}, // 4
                {2, 3, 4, 6, 9}, // 5
                {2, 3, 4, 6, 9, 12}, // 6
                {2, 3, 4, 6, 8, 9, 10} // 7
            };
constexpr int B[] = {2, 3, 4, 6, 8, 9, 10, 12};

int main(void){
    int n; scanf("%d", &n);
    // gcd(ai, S-ai) = gcd(ai, S) に注意
    // 2x3=6の倍数を構成したい ?
    //  index |   1   2   3   4   5   6   7    8
    //  value |   2   3   4   6   8   9   10   12
    //  mod 6 |   2   3   4   0   2   3   4    0
    //  mod 6 |   2   5   3   3   5   2   0    0
    //  mod 6 |   4   1   3   3   1   4   0    0
    //      1 |   0
    //      2 |   3, 3
    //      3 |   3, 3, 0
    //      4 |   3, 3, 0, 0
    //      5 |   2, 2, 4, 4, 0
    //      6 |   2, 2, 4, 4, 0, 0
    //      7 |   2, 2, 4, 4, 3, 3, 0

    //  8 / 12  ~~~> 2 / 3

    if(n == 3){puts("2 5 63"); return 0;}
    int k = n % 8; n -= k;
    REP(i, k){
        printf("%d", L + A[k][i]);
        putchar( (i == k - 1 and n == 0) ? '\n' : ' ');
    }

    REP(i, n){
        int s = (i >> 3),
            t = (i & 7);
        int d = s * 12 + B[t];
        printf("%d", d);
        putchar(i == n - 1 ? '\n' : ' ');
    }



    return 0;
}


Measured memory_bytes: 632
#include <iostream>
#include <math.h>
#include <iomanip>

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

    long double prod = 1;
    bool exceeded = false;

    for(int i = 0; i < n; i++) {
        long double num;
        std::cin >> num;

        if(num == 0) {
            std::cout << "0" << "\n";
            return 0;
        }
        
        // std::cout << prod << "     " << num << "\n";
        // std::cout << std::fixed << prod * num << "\n";
        // std::cout << (prod*num) - pow(10,18) << "\n";

        if( (prod*num) > pow(10,18)) {
            // std::cout << "Exceeded set \n";
            exceeded = true;
        }
        else {
            prod = prod * num;
        }
    }

    if(exceeded)
        std::cout << "-1\n";
    else
        std::cout << std::fixed  << std::setprecision(0) << prod << "\n";

    return 0;

}




Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int dist(P p1, P p2) {
    return abs(p1.fi - p2.fi) + abs(p1.se - p2.se);
}

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vvint a(h, vint(w));
    map<int, P, greater<int>> mp;
    rep(i, h) rep(j, w) {{
        cin >> a[i][j];
        mp[a[i][j]] = P (i, j);
    }}

    vll c(h*w+1);
    for (auto x : mp) {
        if (x.fi+d > h*w) c[x.fi] = 0;
        else {
            c[x.fi] = c[x.fi+d] + dist(mp[x.fi], mp[x.fi+d]);
        }
    }
    int q;
    cin >> q;
    vint l(q), r(q);
    rep(i, q) {
        cin >> l[i] >> r[i];
    }
    rep(i, q) {
        cout << c[l[i]] - c[r[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 8576
// atcoder/abc166/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  str s;
  while (cin >> s) {
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3612
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      long n = Long.parseLong(st.nextToken());
      int m = Integer.parseInt(st.nextToken());
      
      st = new StringTokenizer(f.readLine());
      for(int k = 0; k < m; k++){
         n -= Long.parseLong(st.nextToken());
      }
      
      if(n < 0){
         out.println(-1);
      } else {
         out.println(n);
      }
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 34120
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  if(P==2 || P==5){
    i64 ans = 0;
    rep(i,N){
      if((S[i]-'0')%P==0){
        ans += (i+1);
      }
    }
    cout << ans << "\n";
    return;
  }

  vi Q(N+1,0);
  rep(i,N){
    Q[i+1] = (Q[i] + (S[N-1-i]-'0') * pow_mod(10, i, P)) % P;
  }

  vi cnt(P, 0);
  for(auto &q : Q){
    cnt[q]++;
  }

  i64 ans = 0;
  for(auto &p : cnt){
    ans += p * (p - 1) / 2;
  }

  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 2196
N=int(input())

p=list(map(int,input().split()))

for i in range(1,N):
    add=list(map(int,input().split()))
    temp=[[] for j in range(3)]
    for j in range(3):
        pnt=p[j]
        for k in range(3):
            if j==k:continue
            else:
                temp[k].append(pnt+add[k])
    for j in range(3):
        p[j]=max(temp[j])
print(max(p))

Measured memory_bytes: 3064
use std::cmp::{max, min};
// copy from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        m: usize,
        lr: [(usize, usize); m],
    }

    let mut imin = 0 as usize;
    let mut imax = 100000 as usize;
    for &e in lr.iter() {
        let (l, r) = e;
        imin = max(imin, l);
        imax = min(imax, r);
    }
    if (imax >= imin) {
        println!("{}", imax - imin + 1);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n, k;
  cin >> n >> k;
  deque<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int lim = min(k, n);

  ll ans = 0;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; b <= n; b++) {
      if (a + b > lim) continue;

      vector<ll> t;
      for (int i = 0; i < a; i++) {
        t.push_back(v[i]);
      }
      for (int i = 0; i < b; i++) {
        t.push_back(v[n - 1 - i]);
      }

      ll sum = 0;
      sort(all(t));
      for (int i = 0; i < a + b; i++) {
        if (i < k - (a + b) && t[i] < 0) {
          sum += 0;
        } else {
          sum += t[i];
        }
      }

      ans = max(sum, ans);
    }
  }

  cout << ans << ln;

  return 0;
}


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<long,long>
#define pil pair<int,long>
#define pli pair<long,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

int main(){
    double R;
   scanf("%lf",&R);
   printf("%lf\n",2*acos(-1)*R);
    return 0;
}

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

l = [0 for i in range(52)]
# print(l)

for i in range(n):
    char, num = input().split()
    num = int(num)

    if char == "S":
        l[num - 1] = 1

    elif char == "H":
        l[num-1+13] = 1

    elif char == "C":
        l[num-1+26] = 1

    elif char == "D":
        l[num-1+39] = 1

for i in range(52):
    if l[i] == 0:
        if 0 <= i and i <= 12:
            print(f"S {i+1}")
        if 13 <= i and i <= 25:
            print(f"H {i+1-13}")
        if 26 <= i and i <= 38:
            print(f"C {i+1-26}")
        if 39 <= i and i <= 51:
            print(f"D {i+1-39}")



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

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
    (k, x) <- getIntTuple
    mapM put (solve k x)
    where put x = putStr (show x ++ " ")

solve k x = [x - k + 1 .. x + k - 1]


Measured memory_bytes: 764
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	string s;
	cin >> n >> m >> s;
	set<int> st;
	rep(i,n+1){
		if(s[i] == '0') st.insert(i);
	}
	int cur = n;
	vector<int> ans;
	while(cur > 0){
		auto nex = st.lower_bound(cur-m);
		if(*nex >= cur){
			cout << "-1" << endl;
			return 0;
		}
		ans.push_back(cur - *nex);
		cur = *nex;
	}
	for(int i = ans.size()-1; i >= 0; --i){
		cout << ans[i];
		if(i != 0) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, cnt = 0, a, flag;
  double b;
  cin >> n >> m;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
    cnt += A.at(i);
  }
  a = cnt / (4 * m);
  b = cnt / (4.0 * m);
  flag = (a == b);
  cnt = 0;
  for (int i = 0; i < n; i++) {
    if ((A.at(i) > a) || (flag && A.at(i) == a)) {
      cnt++;
    }
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007


int main(){
  
  ll n;
  cin >> n;
  vector<char> c(n);
  ll r = 0;
  ll ans = 0;
  rep(i,n) {
    cin >> c[i];
    if(c[i] == 'R') r++;
  }

  ll r2 = 0;
  rep(i,r){
    if(c[i] == 'R') r2++;
  }

  cout << r-r2 << endl;


  return 0;
}

Measured memory_bytes: 3592
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]){
    val ab = readLine().split(" ").map(_.toInt)
    val (a,b) = (ab(0),ab(1))
    val n = 2*(a+b)
    val yebi  =  a*b
    println(s"$yebi $n")
  }
}
    



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

int main(){
  int N;
  long long K;
  cin>>N;
  cin>>K;
  vector<pair<int,int>>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i].first>>vec[i].second;
  }
  sort(vec.begin(),vec.end());
  long long temp=0;
  for(int i=0;i<N;i++){
    temp=temp+vec[i].second;
    if(temp>=K){
      cout<<vec[i].first<<endl;
      return 0;
    }
  }
  return 0;
}


  

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,m,i,j,a[10000],b[5000]={0},d;
while(cin>>n){
if(n==0)break;
for(i=0;i<(n-1)/2;i++)b[i]=0;
for(i=0;i<(n-1)/2;i++)a[i]=((i+1)*(i+1))%n;
sort(a,a+(n-1)/2);
b[0]=a[0];j=1;
for(i=1;i<(n-1)/2;i++){
if(a[i]!=b[j-1]){b[j]=a[i];j++;}
}
m=j;
for(i=0;i<m;i++)a[i]=b[i];
for(i=0;i<(n-1)/2;i++)b[i]=0;
for(i=0;i<m;i++){
for(j=0;j<m;j++){
if(i!=j){
d=a[i]-a[j];
if(d<0)d+=n;
if(d>(n-1)/2)d=n-d;
b[d-1]++;
}
}
}
for(i=0;i<(n-1)/2;i++)cout<<b[i]<<endl;
}
return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>

using namespace std;

struct Dice {
  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;
  Dice() : top(1), bottom(6), front(2), back(5), left(4), right(3) {}
  Dice(const Dice& d) : top(d.top), bottom(d.bottom), front(d.front), back(d.back), left(d.left), right(d.right) {}
  Dice(istream& is) {
    is >> top;
    is >> front;
    is >> right;
    is >> left;
    is >> back;
    is >> bottom;
  }
  bool operator==(const Dice& d) const {
    Dice tmp(d);
    tmp.Fit(top, front);
    return (top    == tmp.top) &&
           (bottom == tmp.bottom) &&
           (front  == tmp.front) &&
           (back   == tmp.back) &&
           (left   == tmp.left) &&
           (right  == tmp.right);
  }
  void E() {
    int tmp = right;
    right = top; top = left; left = bottom; bottom = tmp;
  }
  void N() {
    int tmp = back;
    back = top; top = front; front = bottom; bottom = tmp;
  }
  void S() {
    int tmp = front;
    front = top; top = back; back = bottom; bottom = tmp;
  }
  void W() {
    int tmp = left;
    left = top; top = right; right = bottom; bottom = tmp;
  }
  void Fit(int t, int f) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (f == front) break;
        N();
      }
      E();
    }
    if (f == front) {
      for (int i = 0; i < 4; ++i) {
        if (t == top) break;
        E();
      }
    }
  }
};

int main() {
  int n;
  cin >> n;
  vector<Dice> lst;
  for (int i = 0; i < n; ++i) {
    lst.push_back(Dice(cin));
  }

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (lst[i] == lst[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

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



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define UB(x,y) upper_bound(ALL(x),y)
#define LB(x,y) lower_bound(ALL(x),y)
signed main(){
  ll N,M,i,ans=0;cin>>N>>M;dsu D(N);ll x[N];
  REP(i,M){
    ll a,b;cin>>a>>b;D.merge(a-1,b-1);
  }
  REP(i,N)x[i]=D.leader(i);
  sort(x,x+N);
  REP(i,N-1)if(x[i]!=x[i+1])ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4616