akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int d = abs(i - j);
      d=min(d, abs(i - x) + 1 + abs(j - y));
    //   d=min(d, abs(i - y) + 1 + abs(j - x));
      ans[d]++;
    }
  }
  for (int i = 1; i < n; i++) { cout << ans[i] << endl; }
}

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

using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

void solve(){
	ll d, t, s;
	cin >> d >> t >> s;

	cout << (s * t >= d ? "Yes\n" : "No\n");
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	if(s=="Sunny")
		cout << "Cloudy" << endl;
	else if(s=="Cloudy")
		cout << "Rainy" << endl;
	else 
		cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <bitset>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> length(N);
    for(int i=0;i<N;i++){
        cin>>length.at(i);
    }

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

    int count = 0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){

                if((length.at(i)+length.at(j))>length.at(k) and length.at(i)!=length.at(j) and length.at(j)!=length.at(k) and length.at(i)!=length.at(k)) count++;
            }
        }
    }
    cout<<count<<endl;



}








Measured memory_bytes: 3160
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

x,y = map(int,input().split())
t = x-y
a = 0
if t > 0:
  a = t
  x -= a*2
  y -= a
elif t < 0:
  a = t*-1
  x -= a
  y -= a*2
if x<0 or x%3 != 0:
  ans = 0
else:
  b = x//3
  a += b
  ans = cmb(a+b,b)
print(ans%1000000007)

Measured memory_bytes: 44148
import sys

use_clipboard=False
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	bl = list(map(int, input().split()))
	cl = list(map(int, input().split()))
	
	dd = sum([max(c-b,0) for b,c in zip(bl,cl)])
	pp = sum([max(b-c,0) for b,c in zip(bl, cl)])
	
	ss=sum([(c-b) % 2 for b,c in zip(bl,cl) if c >= b])
	pa(('dd',dd,'pp',pp))
	if (dd - ss)< pp*2:
		return 'No'
	
	return 'Yes'
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
  int N,L;
  cin>>N>>L;
  
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    cout<<S.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,m;
bool broken[200000],calc[200000];
int memo[200000];
ll md = 1000000007;
ll dp(int x){
    if(x==n){
        return 1;
    }
    else if(x>n)return 0;
    else if(broken[x])return 0;
    else if(calc[x])return memo[x];
    else{
        int res = 0;
        res = ((dp(x+1)%md)+(dp(x+2)%md))%md;
        calc[x]=true;
        memo[x]=res;
        return res;
    }
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int temp;
        cin>>temp;
        broken[temp]=true;
    }
    ll ans = 0;
    ans = ((dp(1)%md) + (dp(2)%md))%md;
    cout<<ans<<newl;
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(void){
    int N;
    cin >> N;
    N %= 10;
    if(N==3) cout << "bon" << endl;
    else if(N<=1 || (N>5 && N%2==0)) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int K, N, tmp;
int A[200005];

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

	cin >> K >> N;

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

	for(int i = 2; i <= N; i++){
		tmp = max(tmp, A[i]-A[i-1]);
	}

	tmp = max(tmp, K - A[N] + A[1]);

	cout << K-tmp << "\n";

	return 0;		
}

Measured memory_bytes: 1024
n, g = map(int, input().split())

pc = [list(map(int, input().split())) for i in range(n)]

p = [pc[i][0] for i in range(n)]
c = [pc[i][0]*(i+1)*100+pc[i][1] for i in range(n)]


ans = 1e18
for i in range(1<<n):
    sm = cnt = idx = 0
    for j in range(n):
        if (i>>j)&1:
            sm += c[j]
            cnt += p[j]
        else:
            idx = j+1
    if g-sm>0:
        tmp = (g-sm+idx*100-1)//(idx*100)
        if 0<=tmp<=p[idx-1]: ans = min(ans, cnt+tmp)
    else: ans = min(ans, cnt)
print(ans)

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

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n){
       REP(i, n) par[i] = -1;
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    int size(int x){
        return (-par[root(x)]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(x > y) swap(x, y);
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> A(m), B(m);
    REP(i, m){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    int ans = 0;
    REP(i, m){
        UnionFind UF(n);
        REP(j, m){
            if(i == j) continue;
            UF.unite(A[j], B[j]);
        }
        if(UF.size(0) != n) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  double r;
  cin >> r;
  cout << setprecision(20) << fixed << r * 2 * M_PI << endl;
  return 0;
}

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


int main()
{
  ll sum1[10010], sum2[10010];
  while (1)
  {
    ll n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    fill(sum1, sum1 + n, 0);
    fill(sum2, sum2 + n, 0);
    rep(mi, m)
    {
      ll s;
      cin >> s;
      int k;
      cin >> k;
      if (k == 1)
      {
        ll c;
        cin >> c;
        c--;
        sum1[c] += s, sum2[c] += s;
      }
      else
      {
        rep(ki, k)
        {
          ll c;
          cin >> c;
          c--;
          sum1[c] += s;
        }
      }
    }
    ll Max = 0;
    rep(i, n) rep(j, n)
    {
      if (i == j)
        continue;
      Max = max(Max, sum1[i] - sum2[j] + 1);
    }
    cout << Max << "\n";
  }
}


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

int main() {
  int x,n; cin>>x>>n;
  int p[n]; for (int i=0; i<n; i++) cin >> p[i];
  
  int tmp_m;
  int tmp_p;
  int ans;
  for (int i=0; i<=100; i++) {
    bool m_flg = true;
    bool p_flg = true;
    tmp_m = x - i;
    tmp_p = x + i;
    
    for (int j=0; j<n; j++) {
      int tmp = p[j];
      if (tmp_m == tmp) {
        m_flg = false;
        break;
      }
    }

    for (int j=0; j<n; j++) {
      int tmp = p[j];
      if (tmp_p == tmp) {
        p_flg = false;
        break;
      }
    }

    if (m_flg) {
      cout << tmp_m << endl;
	  return 0;
    }
    if (p_flg) {
      cout << tmp_p << endl;
	  return 0;
    }
  }
  
}

Measured memory_bytes: 3632
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h = map(int, input().split())

    ans, bef, cnt = 0, 0, 0

    for i in h:
        if i <= bef:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
        bef = i
    print(max(ans, cnt))

if __name__ == '__main__':
    main()


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
int Heal[N];
for(int i=0;i<N;i++){
  cin>>Heal[i];
}
int healsum=0;
for(int i=0;i<N;i++){
  for(int j=i+1;j<N;j++){
         healsum=healsum+Heal[i]*Heal[j];
  }
}
cout<<healsum;
}


Measured memory_bytes: 256
from collections import deque
H, W, K = map(int, input().split())
m = [input() for i in range(H)]
v = [[0]*W for i in range(H)]
f = 0
for i in range(H):
	if f:
		break
	for j in range(W):
		if m[i][j] == "S":
			x = i
			y = j
			f = 1
			break
dq = deque([[x,y,0]])
v[x][y] = 1
ans = (min(x, y, H-1-x, W-1-y)+K-1)//K
while dq:
	x, y, c = dq.popleft()
	ans = min(ans, (min(x, y, H-1-x, W-1-y)+K-1)//K)
	if c < K:
		c += 1
		if x > 0 and m[x-1][y] == "." and not v[x-1][y]:
			dq.append([x-1,y,c])
			v[x-1][y] = 1
		if x < H-1 and m[x+1][y] == "." and not v[x+1][y]:
			dq.append([x+1,y,c])
			v[x+1][y] = 1
		if y > 0 and m[x][y-1] == "." and not v[x][y-1]:
			dq.append([x,y-1,c])
			v[x][y-1] = 1
		if y < W-1 and m[x][y+1] == "." and not v[x][y+1]:
			dq.append([x,y+1,c])
			v[x][y+1] = 1
print(ans+1)

Measured memory_bytes: 9196
n = gets.to_i
arr = []
n.times do
  arr << gets.to_i
end
arr.sort!
arr << 0
ans = 0
count = 0
for i in 0..(n-1)
  if arr[i] == arr[i+1]
    count += 1
  else
    ans += 1-(count % 2)
    count = 0
  end
end
puts ans

Measured memory_bytes: 16304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,a,b;
    cin >> n >> a >> b;

    if((a+b)%2 == 0){
        cout << "Alice" << endl;
    }
        else
        {
            cout << "Borys" << endl;
        }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

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

using Graph = vector<vector<P>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

//文字列Sと、Sのi文字目からの文字列Tの最長一致の接頭辞長
vector<int> z_algorithm(string& s){
    int n = s.size(), c = 0;
    vec ret(n);
    for(int i=1;i<n;i++){
        if(i+ret[i-c] < c + ret[c]) ret[i] = ret[i-c];
        else{
            int j = max(0LL,c+ret[c]-i);
            while(i+j < n && s[j] == s[i+j]) j++;
            ret[i] = j;
            c = i;
        }
    }
    ret[0] = n;
    return ret;
} 

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    string s;
    cin>>n>>s;
    ll ans=0;
    rep(i,n){
        string t=s.substr(i);
        auto lco = z_algorithm(t);
        rep(j,t.size()){
            int l = min(lco[j],j);
            ans=max(ans,l);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
const int N = 1e5 + 2;
ll ansmax = 1e9 + 7, ansmin = -1e9;

ll a[N + 2], tmin[4 * N], tmax[4 * N];
void buildmin(int v, int l, int r)
{
    if(l == r)
    {
        tmin[v] = a[l - 1];
        return;
    }
    int mid = (l + r) / 2;
    buildmin(2 * v, l, mid);
    buildmin(2 * v + 1, mid + 1, r);
    tmin[v] = min(tmin[2 * v], tmin[2 * v + 1]);
}
void buildmax(int v, int l, int r)
{
    if(l == r)
    {
        tmax[v] = a[l - 1];
        return;
    }
    int mid = (l + r) / 2;
    buildmax(2 * v, l, mid);
    buildmax(2 * v + 1, mid + 1, r);
    tmax[v] = max(tmax[2 * v], tmax[2 * v + 1]);
}

void get_min(int v, int l, int r, int nl, int nr)
{
   // cout << v << ' ' << l << ' ' << r << endl;
    if(l > r || r < nl || l > nr)return;
    if(l >= nl && r <= nr)
    {
        ansmin = min(tmin[v], ansmin);
        return;
    }
    int mid = (l + r) / 2;
    get_min(2 * v, l, mid, nl, nr);
    get_min(2 * v + 1, mid + 1, r, nl, nr);
    return;
}
void get_max(int v, int l, int r, int nl, int nr)
{
   // cout << v << ' ' << l << ' ' << r << endl;
    if(l > r || r < nl || l > nr)return;
    if(l >= nl && r <= nr)
    {
        ansmax = max(tmax[v], ansmax);
        return;
    }
    int mid = (l + r) / 2;
    get_max(2 * v, l, mid, nl, nr);
    get_max(2 * v + 1, mid + 1, r, nl, nr);
    return;
}

void updatemin(int v, int tl, int tr, int pos, int new_val) {
	if (tl == tr)
		tmin[v] = new_val;
	else {
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			updatemin(v*2, tl, tm, pos, new_val);
		else
			updatemin(v*2+1, tm+1, tr, pos, new_val);
		tmin[v] = min(tmin[v*2], tmin[v*2+1]);
	}
}
void updatemax(int v, int tl, int tr, int pos, int new_val) {
	if (tl == tr)
		tmax[v] = new_val;
	else {
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			updatemax(v*2, tl, tm, pos, new_val);
		else
			updatemax(v*2+1, tm+1, tr, pos, new_val);
		tmax[v] = max(tmax[v*2], tmax[v*2+1]);
	}
}


int main() {
    fast;
    int n; cin >> n;
    int a[n];
    FOR(i, n, 0)cin >> a[i];
    ll ans = 0;
    FOR(i, n, 0)
    {
        FOR(j, n, i + 1)
        {
            ans += a[i] * a[j];
        }
    }
    cout << ans;
	return 0;
}
/*
6 4
1 4 2 0 5 3
2 5
*/


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI
#include <numeric>	//gcd

using namespace std;

int main() {

	int A, B;
	cin >> A >> B;

	switch (A + B) {
	case 3:cout << 3 << endl; break;
	case 4:cout << 2 << endl; break;
	case 5:cout << 1 << endl; break;
	}

	return 0;

}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int d, t, s;
    cin >> d >> t >> s;
    cout << ((s*t >= d)?"Yes\n":"No\n");
    return 0;
}

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

bool ok(int n)
{
    char s[100];
    sprintf(s,"%d",n);
    int len=strlen(s);
    for(int i=0;i<len/2;i++)
    {
        if(s[i]!=s[len-i-1])return 0;
    }return 1;
}
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++)
    {
        if(ok(i))ans++;
    }cout<<ans;
    return 0;
}


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

char rev(char c)
{
	char ret;
	
	if(c=='L')ret='R';
	else if(c=='R')ret='L';
	else if(c=='D')ret='U';
	else if(c=='U')ret='D';
	
	return ret;
}

string rev(string str)
{
	string ret="";
	
	for(int i=0;i<str.size();i++)
		ret+=rev(str[i]);
	
	return ret;
}

string conv(string str)
{
	string ret="";
	char b,e;
	int f,s;
	
	b=str[0];
	e=str[str.size()-1];
	
	for(int i=0;i<str.size()-1;i++)
	{
		if(str[i]!=str[i+1])
		{
			f=i+1;
			s=str.size()-i-1;
			break;
		}
	}
	
	ret+=rev(e);
	for(int i=0;i<f+1;i++)
		ret+=b;
	for(int i=0;i<s+1;i++)
		ret+=e;
	ret+=rev(b);
	
	return ret;
}

int main()
{
	int sx,sy,tx,ty;
	int tmp;
	string ans[2]={"",""};
	string stmp="";
	char c;
	
	cin >> sx >> sy >> tx >> ty;
	
	tmp=tx-sx;
	if(tmp<0)
	{
		c='L';
		tmp=-tmp;
	}
	else c='R';
	for(int i=0;i<tmp;i++)
		ans[0]+=c;
	
	tmp=ty-sy;
	if(tmp<0)
	{
		c='D';
		tmp=-tmp;
	}
	else c='U';
	for(int i=0;i<tmp;i++)
		ans[0]+=c;
	
	stmp=ans[0];
	ans[0]+=rev(ans[0]);
	
	ans[1]=conv(stmp);
	ans[1]+=rev(ans[1]);
	
	cout << ans[0] << ans[1] << endl;
	return 0;
}

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

const int MAXN = 1000;
int n, a[MAXN];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int s = 0;
	for(int i = 1; i <= n; ++i) {
		s += a[i];
	}
	int p = 1;
	for(int i = 2; i <= n; ++i) {
		if(fabs(n * a[i] - s) < fabs(n * a[p] - s)) {
			p = i;
		}
	}
	printf("%d\n", p - 1);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		int a[1000];
		rep(i, n)
			scanf("%d", &a[i]);
		sort(a, a+n, greater<int>());
		int ans = 0;
		rep(i, n){
			if(i%m != m-1)
				ans += a[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1044
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) ans++;
	}
	cout << min(N - 1, ans + 2 * K) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const int INF = 1e9+1;

// ~1日までの最大値 それを除く
// ~2日までの最大値 それを除く
// ...
// ~M日までの最大値

//今日からi日後までに得られる報酬の最大値をdp[i]とすると
//dp[i+1] = M の最大値

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    vector<pair<int, int> > X(N);
    priority_queue<int> que;
    for (int i = 0; i < N; i++) {
        X[i] = make_pair(A[i],B[i]);
    }
    sort(X.begin(),X.end());
    
    ll res = 0;
    int i = 0;
    for (int m = 1; m <= M; m++) {
        while (i < N && X[i].first <= m) {
            que.push(X[i].second);
            i++;
        }
        if (!que.empty()) {
            res += (ll) que.top();
            que.pop();
        }
        
    }
    cout << res << endl;
    



}


Measured memory_bytes: 2428
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int x,y;
  cin>>x>>y;
  for(int i=0;i<=x;i++){
    if(i*2+(x-i)*4==y){
      cout<<"Yes"<<"\n";
      return 0;
    }
  }
  cout<<"No"<<"\n";
}

Measured memory_bytes: 3648
using System;

namespace abc089_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(System.Console.ReadLine());
            var march = new int[5];
            for (var i = 0; i < n; i++)
            {
                var s = System.Console.ReadLine();
                if (s[0] == 'M')
                {
                    march[0]++;
                }
                else if (s[0] == 'A')
                {
                    march[1]++;
                }
                else if (s[0] == 'R')
                {
                    march[2]++;
                }
                else if (s[0] == 'C')
                {
                    march[3]++;
                }
                else if (s[0] == 'H')
                {
                    march[4]++;
                }
            }
            long ans = 0;
            for (var i = 0; i < 3; i++)
            {
                for (var j = i + 1; j < 4; j++)
                {
                    for (var h = j + 1; h < 5; h++)
                    {
                        ans += (long)march[i] * march[j] * march[h];
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
using namespace std;
int main(){
    // Your code here!
    
    int n, m, k;
    
    cin >> n >> m >> k;
    
    for(int i = 0; i <= n; ++i) {
        
        
        for(int j = 0; j <= m; ++j) {
            
            int count = (n - i) * j + i * m - j * i;
            
            if(count == k) {
                cout << "Yes" << endl;
                return 0;
            }
            
            
        }
        
    }
    
    cout << "No" << endl;
    
    return 0;
    
}


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

int main(){

    int t,k;
    cin>>t;
    vector<pair<int,int>> v;

    for(int i = 0;i<t;i++){
        cin>>k;

        v.push_back(make_pair(k,i+1));
    }

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

    for(int i = 0;i<t;i++){
        cout<<v[i].second<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1780
#include <stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (a == b && b == c) {
		printf("%d", 1);
	}
	else if (a == b || b == c||a==c) {
		printf("%d", 2);
	}
	else if (a != b && b != c){
		printf("%d", 3);
}

		

	return 0;

	}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,x;
    cin >> n >> x;
    vector<ll> A(n,0);
    rep(i,n) cin >> A[i];
    
    // rep(i,n) cout << A[i] << " ";cout << endl;
    ll cnt=0LL;
    for(int i=0; i<=n-2; i++){
        int left = i, right = i+1;
        if(A[left]+A[right]>x){
            ll res = abs(A[right]+A[left] - x);
            if(res > A[right]){
                A[right]=0;
                A[left]-=res-A[right];
            }
            else{
                A[right] -= res;
            }
            cnt +=res;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

class Solution
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var count = new Dictionary<int, int>();
        foreach (var a in array)
        {
            for (int i = -1; i <= 1; i++)
            {
                var ax = a + i;
                if (!count.ContainsKey(ax))
                {
                    count[ax] = 0;
                }
                count[ax]++;
            }
        }

        var max = count.Max(c => c.Value);
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 21216
#include<iostream>
#include<queue>
#include<cstdint>
using namespace std; // 575

const int MAX = 402;
const int around[5] = {0, 1, 0, -1, 0};

bool reverse(char a, char b) {
	return a == '.' && b == '#' || a == '#' && b == '.';
}
int main() {
	int H, W;
	string S[MAX];
	cin >> H >> W;
	for (int i = 0;i <= W + 1;++ i) S[0] += '*';
	S[H + 1] = S[0];
	for (int i = 1;i <= H;++ i) {
		cin >> S[i];
		S[i] = '*' + S[i] + '*';
	}
	int64_t black, white, ans = 0;
	queue<pair<int, int> > que;
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			black = white = 0;
			que.push(make_pair(j, i));
			while(!que.empty()) {
				if (S[que.front().second][que.front().first] == '.') ++ white;
				else if (S[que.front().second][que.front().first] == '#') ++ black;
				for (int k = 0;k < 4;++ k) if (reverse(S[que.front().second][que.front().first], S[que.front().second + around[k]][que.front().first + around[k + 1]])) que.push(make_pair(que.front().first + around[k + 1], que.front().second + around[k]));
				S[que.front().second][que.front().first] = '*';
				que.pop();
			}
			ans += black * white;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

ある黒→白→……となるエリアを全部数えると、
そのエリアが黒nマス、白mマスとしてnmになることは自明
よってそれを数えていくだけ
なお、全部が市松模様としたときは最大でn=m=HW/2、よって答えが(HW)^2/4とオーバーフロー注意
*/

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

using namespace std;

const int mod = 1e9 + 7;

vector<vector<int> > dp;
vector<vector<int> > adj;

int mult(int a, int b) {
	long long ans = (long long) a * (long long) b;
	return ans % mod;
}

int add(int a, int b) {
	a += b;
	if (a >= mod)
		a -= mod;
	return a;
}

pair<int, int> solve(int index, int parent) {
	int black = 1, white = 1;
	pair<int, int> p;
	for (int i : adj[index]) {
		if (i != parent) {
			p = solve(i, index);
			black = mult(black, p.first);
			white = mult(white, add(p.first, p.second));
		}
	}
	return { white, black };
}

int main() {
	int n, x, y;
	cin >> n;
	if (n == 1) {
		cout << 2 << "\n";
		return 0;
	}
	adj.resize(n);

	for (int i = 0; i < n-1; i++) {
		cin >> x >> y;
		x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	dp.resize(n, vector<int>(2, -1));	//0 -> white, 1 -> black

	for (int i = 0; i < n; i++) {
		if (adj[i].size() == 1)
			dp[i][0] = dp[i][1] = 1;
	}
	pair<int, int> p = solve(0, -1);
	cout << add(p.first, p.second) << "\n";
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50,M=2205;

int sp[M],pri[M],pn;
ll n,a[N],b[N],ans;
map<ll,int> c,vis;

void seive(){
	sp[1]=1;
	lop(i,2,M){
		if(!sp[i])pri[++pn]=i,sp[i]=i;
		for(int j=1;i*pri[j]<M;++j){
			sp[i*pri[j]]=pri[j];
			if(i%pri[j]==0)break;
		}
		//Pr("sp[%d]=%d\n",i,sp[i]); 
	}
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	seive(); 
	read(n); 
	rep(i,1,n){
		ll r,j,x,t;
		read(a[i]); 
		for(r=a[i],b[i]=a[i]=1,j=1,x=pri[j];j<=pn;x=pri[++j]){
			for (t=x*x*x;r%t==0;r/=t);
			t=x*x;
			if(r%t==0)r/=t,a[i]*=t,b[i]*=x;
			if(r%x==0)r/=x,a[i]*=x,b[i]*=t;
		}
		if(r>1){
			t=(ll)sqrt(r+0.5);
			if(t*t==r)a[i]*=r,b[i]*=t;
			else a[i]*=r,b[i]*=r*r;
		}
		++c[a[i]];
	}
	rep(i,1,n)if(!vis[a[i]]){
		vis[a[i]]=1,vis[b[i]]=1;
		if(a[i]==b[i])++ans;
		else ans+=max(c[a[i]],c[b[i]]); 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26880
from collections import deque
K = int(input())

lunlun = deque(list(range(1, 10)))

added_count = len(lunlun)
start_index = 0
while True:
  if (len(lunlun) > K):
    break
  
  next_count = 0
  for i in range(added_count):
    check_num = lunlun[start_index + i]
    for n in range(-1, 2):
      d = check_num % 10 + n
      if(d < 0 or 9 < d):
        continue
      to_add = check_num * 10 + d
      lunlun.append(to_add)
      next_count += 1
  
  start_index += added_count
  added_count = next_count

print(lunlun[K - 1])


Measured memory_bytes: 12276
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

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

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 1e5 + 5;
 
long long n, a, b;

void exec()
{
    read(n), read(a), read(b);
    std::cout << std::max(0ll, (b * n - b + a) - (a * n - a + b) + 1) << std::endl;
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
color = [0]*9
for i in a:
  color[min(8,i//400)] += 1
kind = 0
for i in color[:8]:
  if i:
    kind += 1
if kind == 0 and color[8]:
  color[8] -= 1
  kind += 1
print(kind,kind+color[8])

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

int main() {
  using puu = std::pair<unsigned long long, unsigned long long>;
  unsigned N;
  std::cin >> N;
  std::vector<puu> x(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> x[i].first >> x[i].second;
    if (x[i].first > x[i].second) {
      std::swap(x[i].first, x[i].second);
    }
  }
  std::sort(x.begin(), x.end(), [](puu i, puu j) -> bool { return i.first < j.first; });
  unsigned long long min_min = x.front().first;
  unsigned long long min_max = x.back().first;
  std::sort(x.begin(), x.end(), [](puu i, puu j) -> bool { return i.second < j.second; });
  unsigned long long max_min = x.front().second;
  unsigned long long max_max = x.back().second;
  unsigned long long cand = (max_max - max_min) * (min_max - min_min);
  unsigned long long band = max_max - max_min;
  unsigned long long max_prev = 0;
  unsigned long long min_prev = max_min;
  for (auto p = x.rbegin(); p < x.rend(); ++p) {
    band = std::min(band, std::max(max_prev, p->second) - min_prev);
    min_prev = std::min(min_prev, p->first);
    max_prev = std::max(max_prev, p->first);
  }
  std::cout << std::min(cand, band * (max_max - min_min));
  return 0;
}

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

string getRes(int A) {
	string s = "";
    while (A != 0) {
        s += (A - 1) % 26 + 'a';
        A = (A - 1) / 26;
    }
    reverse(s.begin(), s.end());
    return s;
}

int32_t main() { fastio;
	int n; cin >> n;
	cout << getRes(n) << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long
 
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
 
int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b, c;
    cin>>a>>b>>c;
    int sum = b + c;
    int ans = (a/(sum))*b;
    int rem = a % sum;
    ans += min(rem, b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Struct {
    char str[11];
    int  score;
    int  idx;
} Struct;
int cmp_func ( 
    const void *x,
    const void *y)
{
    Struct *a = (Struct *)x;
    Struct *b = (Struct *)y;
    int ret = strcmp(a->str, b->str);
    if ( ret != 0 )
        return ret;
    return b->score - a->score;
}
int main ( void )
{
    int i, n;
    Struct data[100];
    scanf("%d", &n);
    for ( i = 0; i < n; i++ )
    {
        data[i].idx = i+1;
        scanf("%s %d", &data[i].str, &data[i].score);
    }
    qsort(data, n, sizeof(Struct), cmp_func);
    for ( i = 0; i < n; i++ ) printf("%d\n", data[i].idx);
    return 0;
}

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

int solve(string);

int main(void) {
    int i,n;
    string s;
    
    cin >> n;
    for(i=0;i<n;i++) {
        cin >> s;
        cout << solve(s) << endl;
    }
    return 0;
}

int solve(string s){
    string s1,s2,rs1,rs2;
    set<string> str;
    for(int i=1;i<s.length();i++) {
        s1 = rs1 = s.substr(0,i);
        s2 = rs2 = s.substr(i,s.length()-1);
        reverse(rs1.begin(),rs1.end());
        reverse(rs2.begin(),rs2.end());
        str.insert(s1+s2);
        str.insert(s2+s1);
        str.insert(rs1+s2);
        str.insert(rs2+s1);
        str.insert(s1+rs2);
        str.insert(s2+rs1);
        str.insert(rs1+rs2);
        str.insert(rs2+rs1);

    }
    return str.size();
}

Measured memory_bytes: 1300
import scala.collection.immutable.Nil
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val events = Array.tabulate(n - 1){_ ⇒
    val Array(l, r) = readLine.trim.split(' ').map(_.toInt)
    Event(l, r)
  }
  val branch = Branch(events)
  println(branch.canSaveTime)
  case class Event(left: Int, right: Int)
  object Branch {
    def apply(events: Array[Event]): Branch = {
      val refCount = Array.tabulate(events.length + 1){_ ⇒ 0}
      val reference = Array.tabulate(events.length + 1){_ ⇒ Nil: List[Int]}
      for (i ← events.indices){
        val Event(left, right) = events(i)
        refCount(i) += 2
        reference(left - 1) ::= i
        reference(right - 1) ::= i
      }
      val depth = calDepth(events)
      val branches = Array.tabulate(events.length + 1){_ ⇒ Ending: Branch}
      val queue = mutable.Queue[Int](events.length)
      while (queue.nonEmpty){
        val top = queue.dequeue()
        for (prev ← reference(top)) {
          refCount(prev) -= 1
          if (refCount(prev) == 0){
            queue.enqueue(prev)
            val Event(left, right) = events(prev)
            branches(prev) = Choice(depth(prev), branches(left - 1), branches(right - 1))
          }
        }
      }
      branches(0)
    }
    private[this] def calDepth(events: Array[Event]): Array[Int] = {
      val depth = Array.tabulate(events.length + 1){_ ⇒ -1}.also{d ⇒ d(0) = 0
        d(events.length) = 0}
      val queue = mutable.Queue[Int](0)
      while (queue.nonEmpty){
        val top = queue.dequeue()
        val Event(left, right) = events(top)
        if (depth(left - 1) == -1) {
          depth(left - 1) = depth(top) + 1
          queue.enqueue(left - 1)
        }
        if (depth(right - 1) == -1){
          depth(right - 1) = depth(top) + 1
          queue.enqueue(right - 1)
        }
      }
      depth
    }

  }
  sealed trait Branch {
    def endingCount: Int
    def canSaveTime: Long
    def cannotSaveTime: Long
  }
  case object Ending extends Branch {
    override def endingCount: Int = 1
    override def canSaveTime: Long = 0
    override def cannotSaveTime: Long = 0
  }
  case class Choice(depth: Int, left: Branch, right: Branch) extends Branch {
    override val endingCount = left.endingCount + right.endingCount
    override val canSaveTime: Long = List(
      left.cannotSaveTime + right.cannotSaveTime + endingCount,
      left.cannotSaveTime + right.canSaveTime + left.endingCount + 1,
      left.canSaveTime + right.cannotSaveTime + right.endingCount + 1,
      left.canSaveTime + right.canSaveTime + depth + 2
    ).min
    override val cannotSaveTime: Long = left.cannotSaveTime + right.cannotSaveTime + endingCount
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


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

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


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

#define fori(i,n) for (int i = 0; i < (n); i++)
#define repk(i,k,n)  for (int i = k; i < n; ++i)
#define repr(i,k,n) for (int i = k; i >= n; --i)

int main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    int arr[10] = {0};
    arr[a]++;
    arr[b]++;
    arr[c]++;
    if (arr[5] == 2 && arr[7] == 1) cout << "YES";
    else cout << "NO";
    return 0;
}



Measured memory_bytes: 3560
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vvint cld(3*n);
    REP(i,m){
        int u,v;
        cin >> u >> v;
        u--; v--;
        cld[u].pb(v+n);
        cld[u+n].pb(v+2*n);
        cld[u+2*n].pb(v);
    }
    vint visited(3*n, -1);
    queue<int> q;
    int s,t;
    cin >> s >> t;
    s--; t--;
    q.push(s);
    visited[s]=0;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i : cld[now]){
            if(visited[i]==-1 || visited[i]>visited[now]+1){
                q.push(i);
                visited[i] = visited[now]+1;
            }
        }
        
    }
    if(visited[t]==-1){
        cout << -1 << endl;
    }else{
        cout << visited[t]/3 << endl;
    }
    return 0;
}

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

int main(){
	int l;
	int a,b,c,d;
	cin>>l>>a>>b>>c>>d;
	int e=(c+a-1)/c;
	int f=(b+d-1)/d;
	
	if(e<f||f==e)
	cout<<l-f<<endl;
	else if(f<e)
	cout<<l-e<<endl;
	
	return 0;
	}

Measured memory_bytes: 3096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
s = [input() for _ in range(N)]

cnt_s = Counter(s)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
	if val == tmp:
		print(key)


Measured memory_bytes: 51772