akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<iostream>
#include<vector>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

bool isPalin(string num){
  if(num[0] == num[4] && num[1] == num[3]){
	return true;
  }
  else{
	return false;
  }
}

int main(){
  int a,b;
  int ii;
  int cnt = 0;
  string num;
  cin >> a >> b;

  for(ii=a;ii<=b;ii++){
	num = to_string(ii);
	if(isPalin(num)){
	  cnt++;
	}
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAXN 100005

using namespace std;
typedef long long ll;

int N, ans, pnode, nd = 1, res[MAXN], aux = 0;
string S;

void tree ( int s )
{
	int cnt = nd + 1;
	for ( int i = 0; i < s - 1; i++ )
		res[cnt + i] = nd;
	if ( pnode )
		res[nd] = pnode;
	pnode = nd;
	nd += s;
}

int main ()
{
	cin >> S;
	S = "0" + S;
	N = S.length();

	for ( int i = 0; i < N; i++ )
		if ( S[i] != S[N - i - 1] )
			ans = -1;
	if ( S[1] == '0' )
		ans = -1;
	
	if ( S == "010" )
	{
		cout << "1 2\n";
		return 0;
	}
	
	for ( int i = 2; i < N; i++ )
	{
		if ( S[i] == '1' )
		{
			tree ( i );
			break;
		}
	}

	for ( int i = N - 3; i >= (N - 1) / 2; i-- ) 
	{
		if ( S[i] == '1' )
		{
			if ( aux )
				tree ( aux - i );
			aux = i;
		}
	}
	tree ( aux );

	if ( ans == -1 )
		cout << ans << "\n";
	else
	{
		for ( int i = 2; i < N; i++ )
		{
			cout << res[i] << " " << i << "\n";
		}
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

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

  if (n.find("A") != std::string::npos) {
    if (n.find("B") != std::string::npos) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

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

char s[N][N];
int h, w;

bool bio[N][N];
int bfs() {
    queue<pair<pair<int, int>, int>> q;
    q.emplace(make_pair(0, 0), 1);
    bio[0][0] = 1;
    while (!q.empty()) {
        const auto u = q.front(); q.pop();
        int x = u.first.first, y = u.first.second, d = u.second;
        for (int i = 0; i < 4; ++i) {
            int xx = x+dx[i], yy = y+dy[i];
            if (xx < 0 || xx >= w || yy < 0 || yy >= h) continue;
            if (s[yy][xx] == '#') continue;
            if (bio[yy][xx]) continue;
            if (yy == h-1 && xx == w-1) return h*w-d-1;
            q.emplace(make_pair(xx, yy), d+1);
            bio[yy][xx] = 1;
        }
    }
    return -1;
}

void solve() {
    scanf("%d%d", &h, &w);
    int c = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            scanf(" %c", s[i]+j);
            c += s[i][j] == '#';
        }
    }
    int ans = bfs();
    if (ans == -1) printf("-1");
    else printf("%d", ans-c);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
	
    
	ll arr[3][3];
	for(ll i=0;i<3;i++){
		for(ll j=0;j<3;j++){
			cin>>arr[i][j];
		}
	}
	ll n;cin>>n;
	for(ll p=0;p<n;p++){
		ll x;
		cin>>x;
		for(ll i=0;i<3;i++){
			for(ll j=0;j<3;j++){
				if(arr[i][j]==x)arr[i][j]=-1;
			}
		}
	}
	
	bool ans = 0;
	for(ll i=0;i<3;i++){
		bool flag=0;
		for(ll j=0;j<3;j++){
			if(arr[i][j]!=-1){
				flag=1;
				break;
			}
		}
		if(flag == 0){
			ans = 1;
			break;
		}
	}
	//cout<<ans<<endl;
	for(ll j=0;j<3;j++){
		bool flag=0;
		for(ll i=0;i<3;i++){
			if(arr[i][j]!=-1){
				flag=1;
				break;
			}
		}
		if(flag == 0){
			ans = 1;
			break;
		}
	}
	// for(ll i=0;i<3;i++){
	// 	for(ll j=0;j<3;j++){
	// 		cout<<arr[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	//cout<<ans<<endl;
	bool flag = 0;
	for(ll i=0;i<3;i++){
		if(arr[i][i]!=-1) {
			flag=1;break;
		}
	}
	if(flag==0) ans = 1;
	flag=0;

	//cout<<ans<<endl;
	for(ll i=2;i>=0;i--){
		if(arr[2-i][i]!=-1) {
			flag=1;break;
		}
	}
	if(flag==0) ans = 1;
	//cout<<ans<<endl;
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define f first
#define s second
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define pcnt __builtin_popcount
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define ms(c, x)  memset(c,x,sizeof c)
#define  No(x) cout<<(x?"NO":"No")<<endl;
#define  Yes(x) cout<<(x?"YES":"Yes")<<endl;
#define  nl cout<<endl;
template<typename T>
using osl=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using osg=tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

// for greater use greater<T>
template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

#ifdef LOCAL

void debug() { cerr << endl; }

template<class T, class... Args>
void debug(const T &t, const Args &... args) {
    cerr << t << " ";
    debug(args...);
}

#define dbg(...) {cerr<<__LINE__<<" [[DEBUG]] ";debug(__VA_ARGS__);};
#else
#define dbg(...) void(0)
#endif
const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

ll mul(ll a, ll b) {
    a *= b;
    return a % mod;
}

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline ll modInverse(ll x, ll p) {
    return power(x, p - 2, p);
}

const int MXN = 1e5 + 5;
void solve() {
  int n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<n;i++){
        ans+=n/i;
        if((n%i)==0)ans--;
  }
  cout<<ans<<endl;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1, tc = 1;
    //cin >> t;
    while (t--) {
        // cout<<"Case #"<<tc<<": " ;
        solve();
        tc++;
    }
#ifdef LOCAL
    cerr << endl << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
#endif
    return 0;
}
//look if it requires ll

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	pair<pair<string, int>, int> a[105];
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].first.second *= -1;
		a[i].second = i;
	}
	sort(a, a + n+1);
	
	for (int i = 1; i <= n; i++) {
		cout << a[i].second << endl;

	}
	return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

inline ll gcd(ll a, ll b) {
  for (; a; swap(b %= a, a));
  return b;
}

signed main() {
    string s;
    rep(i, 4) {
        char n;
        cin >> n;
        s += n;
    }
    sort(be(s));
    cout << (s == "1479" ? "YES" : "NO") << nl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int S,h,m,s;
    scanf("%d", &S);
    
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 60;
    printf("%d%s%d%s%d\n",h,":", m ,":",s );
    
    return 0;
}


Measured memory_bytes: 2764
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=1)
if k==1:print(0);exit()
if n==2:print(a[0]-a[1]);exit() 
ans=0
mod=10**9+7
f=[1]
for i in range(n):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod
for i in range(n-k+1):
  ans+=(a[i]-a[n-1-i])*comb(n-1-i,k-1)
  ans%=mod
print(ans)

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll s,w;
  //string s;
  cin >> s >> w;
  
  cout << ((s>w)? "safe" : "unsafe") << endl;
}

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

int main() {
    int a , b , c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "No" << endl;
    else if (a != b && b != c && a != c) cout <<"No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

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

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

l = [0]*n

for i in range(n):
	l[i] = i + 1
	
#print(l)

test = 0

for i in range(n):
	if p[i]!= l[i]:
		test = test + 1

print('YES' if test==0 or test==2 else 'NO')



Measured memory_bytes: 3060
#include<stdio.h>

int main() {
	char s[4];
	scanf("%s", s);
	int i;
	if ((s[0] == '7') || (s[1] == '7') || (s[2] == '7')) {
		printf("Yes");

	}
	else {
		printf("No");
	}

	return 0;

}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
char grid[25][25];
L w,h,xi,yi,c=1,flg=1;
L X[]={0,1,0,-1},Y[]={1,0,-1,0},mark[25][25];
void dfs(L x,L y){
    mark[x][y]=1;
    for(L i=0;i<4;i++){
        if(X[i]+x<0||X[i]+x>=h || Y[i]+y<0||Y[i]+y>=w || mark[X[i]+x][Y[i]+y] )continue;
        if(grid[X[i]+x][Y[i]+y]=='.'){
            c++;
            dfs(X[i]+x,Y[i]+y);
        }
    }
}
int main(){
    while(scanf("%lld%lld",&w,&h)){flg=1;
        if(w==0&&h==0)return 0;
        for(L i=0;i<h;i++){
           scanf("%s",grid[i]);
           for(L j=0;j<w&&flg;j++){
            if(grid[i][j]=='@'){
                xi=i;yi=j;flg=0;
            }
           }

        }
        dfs(xi,yi);
        cout<<c<<"\n";
        c=1;memset(mark,0,sizeof(mark));
    }
    return 0;
}



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

using namespace std;

int main(void){
    int A,B,K;
    cin>>A>>B>>K;
    int count=0;
    for(int i=min(A,B);i>=1;i--){
        if(A%i==0&&B%i==0) count++;
        if(count==K){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
length = gets.to_i
arr = gets.split(" ").map(&:to_i)
change_count = 0

length.times do |index|
    minimum_index = index
    (index..(length - 1)).each do |search_index|
        minimum_index = search_index if arr[minimum_index] > arr[search_index]
    end
    if minimum_index != index
        tmp = arr[minimum_index]
        arr[minimum_index] = arr[index]
        arr[index] = tmp
        change_count += 1
    end
end

puts arr.join(" ")
puts change_count



Measured memory_bytes: 8880
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N, int Q, string S) {
  vector<int> t(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      t[i] = 1;
    }
  }
  vector<int> tt(N + 1, 0);
  for (int i = 0; i < N; i++) {
    tt[i + 1] = tt[i] + t[i];
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    cout << tt[r - 1] - tt[l - 1] << endl;
    ;
  }
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  solve(N, Q, S);
  return 0;
}


Measured memory_bytes: 1856
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var X = Math.Abs(input[0]);
        var K = input[1];
        var D = input[2];
        var r = Math.Min(K, X / D);
        var X1 = X - r * D;

        if ((K - r) % 2 == 1)
        {
            Console.WriteLine(Math.Abs(X1 - D));
        }
        else
        {
            Console.WriteLine(X1);
        }
    }
}


Measured memory_bytes: 28148
import sys
import math
from itertools import accumulate as acc

def func(s):
    return (int(s)-1)%K


N,K=map(int,input().split())
a=list(map(int,input().split()))
x=[0]
tmp=0
for i in range(N):
    tmp=(tmp+a[i]-1)%K
    x+=[tmp]
dic={}
ans=0
if N<K:
    for i in range(N+1):
        if x[i] in dic: dic[x[i]]+=1
        else: dic[x[i]]=1
    for i in dic:
        ans+=dic[i]*(dic[i]-1)//2

    
else:
    for i in range(K):
        p=x[i]
        if p in dic: dic[p]+=1
        else: dic[p]=1
        ans+=dic[p]-1
    for i in range(K,N+1):
        p=x[i]
        if p in dic: dic[p]+=1
        else: dic[p]=1
        dic[x[i-K]]-=1
        ans+=dic[p]-1

print(ans)

Measured memory_bytes: 40740
dic = {"A":1,"B":2,"C":3,"D":4,"E":5,"F":6}
X,Y = input().split()
for key in dic:
    if key == X:
        x = dic[key]
    if key == Y:
        y = dic[key]
if x > y:
    print('>')
elif x < y:
    print('<')
else:
    print('=')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (int i = (begin); i > (end); i--)
#define IREP(i, n) IFOR(i, 0, n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define pb push_back
#define f first
#define s second
#define ll long long
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

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

  vec a(N, -1);
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }

  ll ans = 0;
  ll button_id = 0;
  while (ans <= N) {
    ans += 1;
    button_id = a[button_id];
    if (button_id == 1) {
      break;
    } else if (ans == N) {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int a, b;
    int d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%d %d %.5lf", d, r, f);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

// 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) {}

    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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    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 {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    mint ans = 0;
    rep(i, N) {
        if (i >= K - 1) {
            ans += mint(A[i]) * comb(i, K - 1); // max
        } else {
            ans += mint(A[i]) * comb(i, K - 1); // max
        }

        ans -= mint(A[i]) * comb(N - 1 - i, K - 1); // min
    }

    cout << ans.x << endl;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main() {
	string S;
	int count=0;
	cin >> S;
	bool p = S[0] == 'R';
	bool q = S[1] == 'R';
	bool s = S[2] == 'R';
	if (p & q & s) {
		cout << 3;
	}
	else if ((p & q)|| (q& s)) {
		cout << 2;
	}
	else if (p || q || s) {
		cout << 1;
	}
	else{
		cout << 0;
	}
}


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

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> r(n, 0);
 
    int pos;
    if (k <= n * 2) {
        pos = 0;
        rep(i, k)
            pos = a[pos] - 1;
    } else {
        int count1 = 0;
        int start;
        pos = 0;
        rep(i, n) {
            if (r[pos] != 0) {
                start = pos;
                break;
            }
            ++count1;
            r[pos] = count1;
            pos = a[pos] - 1;
        }
        int count2 = 0;
        rep(i, n) {
            count2++;
            pos = a[pos] - 1;
            if (pos == start) {
                break;
            }
        }

        int rem = (k - (count1 - count2)) % count2;

        pos = start;
        rep(i , rem) {
            pos = a[pos] - 1;
        }
    }
 
    cout << pos + 1 << endl;
 
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B,C,X;
cin >> A >> B >> C >> X;
int cnt = 0;
for (int i = 0;i <= A;i++) {
  for (int j = 0;j <= B;j++) {
    for (int k = 0;k <= C;k++) {
      if (i * 500 + j * 100 + k * 50 == X) {
        cnt++;
      }
    }
  }
}
cout << cnt << endl;

return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int MAX_OVER = 100000000;

int check(int x) {
  int ans = 0;
  while(x != 0) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}

int main(){
  int N;
  scanf("%d", &N);
  int ans = MAX_OVER;
  for (int A = 1; A < N; A++) {
    ans = min(ans, check(A) + check(N - A));
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int maxn = 3e5 + 7;

int head[maxn << 1];
struct Edge {
	int to,next;
} edge[maxn << 1];
int tot;

void init() {
	memset(head,-1,sizeof(head));
	tot = 0;
}

void addedge(int u,int v) {
	edge[tot].to = v;
	edge[tot].next = head[u];
	head[u] = tot++;
}

map<int,int>cntx,cnty;
pii a[maxn];

int main() {
	fast_io;
	int n,m,num;
	cin >> n >> m >> num;
	int maxx = 0, maxy = 0;
	rep(i,1,num) {
		int x,y;
		cin >> x >> y;
		a[i].first = x, a[i].second = y;
		cntx[x]++, cnty[y]++;
		maxx = max(maxx, cntx[x]), maxy = max(maxy, cnty[y]);
	}
	int numx = 0, numy = 0;
	for(auto temp: cntx) {
		if(temp.second == maxx) numx++;
	}
	for(auto temp: cnty) {
		if(temp.second == maxy) numy++;
	}
	int cnt = 0;
	rep(i,1,num) {
		if(cntx[a[i].first] == maxx && cnty[a[i].second] == maxy) cnt++;
	}
	if(numx * numy == cnt) cout << maxx + maxy - 1 << endl;
	else cout << maxx + maxy << endl;
	return 0;
}

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

int main(){
    int a,b,c,x; // a:500 b:100 c:50
    cin >> a >> b >> c >> x;
    int cnt = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                if(((500 * i) + (100 * j) + (50 * k)) == x)cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N, M;
    vector <int> tmp[100001];
    int P[100000], Y[100000];
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        tmp[P[i]].push_back(Y[i]);
    }
    
    for (int i = 0; i < N; i++) {
        sort(tmp[i+1].begin(), tmp[i+1].end());
    }

    for (int i = 0; i < M; i++) {
        printf("%012lld\n", ll(P[i])*1000000 + int(lower_bound(tmp[P[i]].begin(), tmp[P[i]].end(), Y[i]) - tmp[P[i]].begin())+1);
    }

    return 0;
}

Measured memory_bytes: 7808
def reconst(n):
    former=train[:n]
    latter=train[n:]
    formerRe="".join(reversed(former))
    latterRe="".join(reversed(latter))
    return [former+latterRe,formerRe+latter,formerRe+latterRe,latter+former,latterRe+former,latter+formerRe,latterRe+formerRe]

n = int(input())
for _ in range(n):
    s = set()
    train = input()
    s.add(train)
    leng = len(train)
    for i in range(1,leng):
        for t in reconst(i):
            if not t in s:
                s.add(t)
    print(len(s))


Measured memory_bytes: 5636
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
for i in range(N):
  rem=B[i]-A[i]
  if rem>0:
    cnt+=(A[i]+min(rem,A[i+1]))
    A[i+1]-=rem
    if A[i+1]<0:
      A[i+1]=0
  else:
    cnt+=B[i]
    
print(cnt)

Measured memory_bytes: 82020
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    double ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
 //   cout << a[m - 1];
    int r = 0;
    for (int i = 0; i < n; i++) {
        if ((double)a[i] >= (double)(ans / (4 * m)))r++;
    }
    if (r>=m)cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;

}

Measured memory_bytes: 3632
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    ll L, R; input(L,R);
    if (L % 2019 == 0) {
        cout << 0 << endl;
    }
    else if (L / 2019 < R / 2019) {
        cout << 0 << endl;
    }
    else {
        int ans = INF;
        L %= 2019;
        R %= 2019;
        FOR(i, L, R) {
            FOR(j, i + 1, R + 1) {
                ans = min(ans, i*j % 2019);
            }
        }
        cout << ans << endl;
    }
    getchar(); getchar();
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;

int dp[max_n];


int main () {
	make2(n, k);
	makev(v, n);
	dp[0] = 0;
	dp[1] = abs(v[0] - v[1]);
	FOR(i,2,n) {
		int best = dp[i-1] + abs(v[i] - v[i-1]);
		FOR(j,1,k+1) {
			if (i-j<0) break;
			best = min(best, dp[i-j] + abs(v[i] - v[i-j]));
		}
		dp[i] = best;
	}
	printf("%d\n", dp[n-1]);
}	





Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> a(0);
    vector<int> b(0);
    for (int i = 1; i < A+1; i++)
    {
        if (A%i==0)
        {
            a.push_back(i);
        }
        
    }
    for (int i = 1; i < B+1; i++)
    {
        if (B%i==0)
        {
            b.push_back(i);
        }
        
    }
    vector<int> c(0);
    for (int i = 0; i < a.size(); i++)
    {

        for (int j = 0; j < b.size(); j++)
        {
            if (a[i]==b[j])
            {
                c.push_back(a[i]);
            }
            
        }
        
        
    }
    sort(c.begin(),c.end(),greater<int>());
    cout << c[K-1] << endl;
    
    
    
}

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

int main() {
    ll N;
    cin >> N;
    for (ll i=1; i<=3500; ++i) {
        for (int j=1; j<=3500; ++j) {
            if (4LL*i*j - N*i - N*j <= 0) continue;
            if ((N*i*j)%(4LL*i*j - N*i - N*j) == 0) {
                cout << i << ' ' << j << ' ' << (N*i*j)/(4LL*i*j - N*i - N*j) << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int q;
	while(cin>>q,q){
		int n,m;
		cin>>n>>m;
		vvi in(n,vi(m));
		rep(i,q){
			int a,b;
			cin>>a>>b;
			a--;b--;
			in[a][b]=1;
		}
		int a,b;
		cin>>a>>b;
		int ma=-1;
		rep(i,n-a+1){
			rep(j,m-b+1){
				int co=0;
				rep(k,a)rep(q,b)if(in[i+k][j+q])co++;
				ma=max(ma,co);
			}
		}
		
		cout<<ma<<endl;
	}
}

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

const int MAX_N=1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> cnt(MAX_N,0);
    for (int i=0;i<N;++i){
        int a,b; cin >> a >> b;
        ++cnt[--a]; --cnt[b];
    }
    for (int i=0;i<MAX_N-1;++i) cnt[i+1]+=cnt[i];
    int ans=0;
    for (int i=1;i<MAX_N;++i){
        if (i<=cnt[i]) ans=i;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int in; cin >> in;
  if(in == 1){
    cout << "Hello World" << endl;
  }else{
    int a,b; cin >> a >> b;
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
s = [list(map(int,input().split())) for _ in range(n)]
s.sort(key=lambda x:(x[1],x[1]-x[0]))
time = 0
ans = 1
for v in s:
  time += v[0]
  if time > v[1]:
    ans = 0
print('Yes' if ans else 'No')

Measured memory_bytes: 65896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M];

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

	ll i,n,c = 0,j,k;

	cin >> n;
	for(i=1;i<=n;++i)
		cin >> ar[i];

	sort(ar+1,ar+1+n);

	for(i=1;i<=n;++i)
	{
		for(j=i+1;j<=n;++j)
		{
			for(k=j+1;k<=n;++k)
			{
				if(ar[i] != ar[j] && ar[i] != ar[k] && ar[j] != ar[k] && ar[k]<ar[i]+ar[j])
					c++;
			}
		}
	}

	cout << c << "\n";
}

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

int main(int argc, char *argv[])
{
    double e, f, max = 0;
    int A, B, C, D, E, F;
    int i, j, k, l, w = 0, s = 0;
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

    e = 1.0 * E * 100 / ( E + 100 );

    for ( i = 0; i <= 30; i++ ){
        int ww = 100*A*i;
        if ( ww > F ){
            break;
        }
        for ( j = 0; j <= 30; j++ ){
            int www = ww + 100*B*j;
            if ( www > F ){
                break;
            }
            for (k = 0; k < 5000; k++ ){
                int ss = k*C;
                if ( www + ss > F ){
                    break;
                }
                f = 1.0*ss*100/(www + ss);
                if ( f > e ){
                    break;
                }
                for (l = 0; l < 5000; l++ ){
                    int sss = ss + l*D;
                    if ( www + sss > F ){
                        break;
                    }
                    f = 1.0*sss*100/(www+sss);
                    if ( f > e ){
                        break;
                    }
                    if ( f > max){
                        max = f;
                        w = www;
                        s = sss;
                    }
                }
            }
        }
    }
    if ( w == 0 ){
        printf("%d %d\n", 100*A*1, 0);
    } else {
        printf("%d %d\n", w+s, s);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

constexpr int MAX = 114;
constexpr int INF = (1 << 29);

vector<int> G[MAX], G2[MAX][3];
bool visited[MAX][MAX];

bool dfs(int curr, int goal, int rem)
{
    if (visited[curr][rem]) return 0;
    visited[curr][rem] = 1;
    
    if (rem == 0) {
        return (curr == goal);
    }    
    for (auto& next : G[curr]) {
        if (dfs(next, goal, rem - 1)) {
            return 1;
        }
    }
    return 0;
}

void solve(int N)
{    
    vector<int> d(N, INF);
    d[N - 1] = 0;

    bool update = 1;
    while (update) {
        update = 0;

        for (int i = 0; i < N; i++) {
            int cost = 0;
            for (int j = 0; j < 3; j++) {
                int mc = INF;
                for (auto& u : G2[i][j]) {
                    mc = min(mc, d[u]);
                }
                cost = max(cost, mc + 1);                
            }

            if (cost < d[i]) {
                d[i] = cost;
                update = 1;
            } 
        }            
    }
    
    if (d[0] == INF) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << d[0] << endl;
    }
}

int main()
{
    int N, M, a[3];
    cin >> N >> M >> a[0] >> a[1] >> a[2];
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v; u--; v--;
        G[u].emplace_back(v);
    }
    
    for (int i = 0; i < 3; i++) {
        for (int from = 0; from < N; from++) {
            for (int to = 0; to < N; to++) {
                if (from == to) continue;
                memset(visited, 0, sizeof(visited));
                if (dfs(from, to, a[i])) {
                    G2[from][i].emplace_back(to);
                }
            }
        }
    }       
    solve(N);
    return 0;
}

Measured memory_bytes: 3208
def resolve():
    s = input()
    t = input()

    dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

    for i in range(len(s)):
        for j in range(len(t)):
            match = s[i] == t[j]
            dp[i + 1][j + 1] = max(dp[i][j] + match , dp[i + 1][j + 1])
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i + 1][j + 1])
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j + 1])

    res = ''
    i = len(s)
    j = len(t)

    while i > 0 and j > 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1] + 1:
            res = s[i - 1] + res
            i -= 1
            j -= 1

    print(res)
resolve()

Measured memory_bytes: 113628
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		sc.close();
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<>();
			used[i].add(-1);
		}
		int sum = 0;
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used[j].last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used[now].add(d);
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		Random r = new Random();
		while(true) {
			int d = r.nextInt(D);
			for(int q = 0; q < 26; q++) {
				long temp = 0;
				temp -= s[d][con[d]];
				temp += s[d][q];
				temp -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
				temp += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
				if(temp > 0) {
					con[d] = q;
					used[con[d]].remove(d);
					used[q].add(d);
				}
			}
			if(System.currentTimeMillis() - start > 200)
				break;
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


Measured memory_bytes: 52728
using System;
class Program {
  static bool IsPalindromic(int n) {
    char[] str = new char[5];
    for (int i = 0; i < 5; ++i) {
      str[i] = Convert.ToChar(n % 10);
      n /= 10;
    }
    if (str[0] == str[4] && str[1] == str[3]) return true;
    else return false;
  }
  static void Main(string[] args) {
    string[] values = Console.ReadLine().Split();
    int A = int.Parse(values[0]);
    int B = int.Parse(values[1]);

    int ans = 0;
    for (int i = A; i <= B; ++i) {
      if (IsPalindromic(i)) ++ans;
    }

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 15312
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        if(p<=a)c1++;
        else if(b+1<=p)c3++;
        else c2++;
    }
    cout<<min({c1,c2,c3})<<endl;
}


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

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      int n=sc.nextInt();
	      int count=0;
	      for(int i=1;i<n;i++) {
	  count+=(n-1)/i;
	        
	          }
	        
	   System.out.println(count);
	      
	}
static long nCr(int n, int r, 
    int p) 
{ 


if (r == 0) 
return 1; 


int[] fac = new int[n + 1]; 
fac[0] = 1; 

for (int i = 1; i <= n; i++) 
fac[i] = fac[i - 1] * i % p; 

return (fac[n] * modInverse(fac[r], p) 
% p * modInverse(fac[n - r], p) 
% p) 
% p; 
} 
static long modInverse(int n, int p) 
{ 
    return pow(n, p - 2)%mod; 
} 
static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
} 
static int divCount(int n) 
{ 
    // sieve method for prime calculation 
    boolean hash[] = new boolean[n + 1]; 
    Arrays.fill(hash, true); 
    for (int p = 2; p * p < n; p++) 
        if (hash[p] == true) 
            for (int i = p * 2; i < n; i += p) 
                hash[i] = false; 
  
    // Traversing through  
    // all prime numbers 
    int total = 1; 
    for (int p = 2; p <= n; p++)  
    { 
        if (hash[p]) 
        { 
  
            // calculate number of divisor 
            // with formula total div =  
            // (p1+1) * (p2+1) *.....* (pn+1) 
            // where n = (a1^p1)*(a2^p2)....  
            // *(an^pn) ai being prime divisor 
            // for n and pi are their respective  
            // power in factorization 
            int count = 0; 
            if (n % p == 0)  
            { 
                while (n % p == 0)  
                { 
                    n = n / p; 
                    count++; 
                } 
                total = total * (count + 1); 
            } 
        } 
    } 
    return total; 
} 
  
}




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

int main(){
  int n;cin>>n;
  int a[100000];
  for(int i=1;i<100000;i++) a[i]==0;
  for(int x=1;x<100;x++){
    for(int y=1;y<100;y++){
      for(int z=1;z<100;z++){
        a[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<a[i]<<endl;
  }
}
        
        


Measured memory_bytes: 3760
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        int[] sum = new int[n+1];
        int[] xor = new int[n+1];
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            a[i] = x;
            sum[i] += x + sum[i-1];
            xor[i] = x ^ xor[i-1];
        }
        long ans = 0;
        int r = 1;
        for (int i = 0; i < n; i++) {
            while(r <= n && (sum[r] - sum[i]) == (xor[r] ^ xor[i])){
                r++;
            }
            ans += r - i - 1;
        }
        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 89556
# ABC 073: B – Theater
n = int(input())

l = []
r = []
for i in range(n):
    tmp = [int(s) for s in input().split()]
    l.append(tmp[0])
    r.append(tmp[1])

audiences = 0

for i in range(n):
    audiences += r[i] - l[i] + 1

print(audiences)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int k;
  cin >> k;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k-1] << endl;

  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*
多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9+7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	long double a, b;
	scanf("%Lf%Lf", &a, &b);
	printf("%.0Lf\n", floor(a * b));

	Please AC;
}

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

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    bool flag = false;
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    reverse(s2.begin(), s2.end());
    if(s1 < s2) flag = true;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256