akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}

bool ue[510] = {true};
class Jishojun{
public:
    bool operator()(const P& riLeft, const P&riRight){
        return (riLeft.first < riRight.first || (riLeft.first == riRight.first && ((ue[riLeft.first] && riLeft.second < riRight.second) || (!ue[riLeft.first] && riLeft.second > riRight.second))));
    }
};

int gojohou(int a,int b){
    if(b == 0)return a;
    return gojohou(b,  a % b);
}
int main(){
    int saisho;
    cin >> saisho;
    int a = saisho / 100;
    int c = saisho % 10;
    int b = (saisho - a * 100 - c) / 10;
    int s = max(b, c);
    if(a < s)a++;
    printf("%d\n", a * 111);
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = (int) 1e5;
const int MAXVAL = (int) 1e5 + 5;

int aib[2 * MAXVAL + 1][2], n;

inline void update(int pos, int val, int r) {
    pos += n + 1;
    for(int i = pos; i <= 2 * MAXVAL; i += lsb(i)) {
        aib[i][r] += val;
    }
}

inline int query(int pos, int r) {
    int ans = 0;
    pos += n + 1;
    for(int i = pos; i > 0; i -= lsb(i)) {
        ans += aib[i][r];
    }
    return ans;
}

int arr[MAXN + 1];

inline ll check(int val) {
    memset(aib, 0, sizeof(aib));
    ll ans = 0;
    int cnt = 0;
    update(1, 1, 0);
    for(int i = 1; i <= n; i++) {
        cnt += (arr[i] <= val);
        ans += query(cnt - i / 2, i & 1) + query(cnt - (i - 1) / 2, 1 - i & 1);
        update(cnt - i / 2 + 1, 1, i & 1);
    }
    return ans;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    ll nr = 1LL * n * (n + 1) / 2;
    int res = 0;
    for(int step = 1 << 29; step; step >>= 1) {
        if(check(res + step) < nr / 2 + 1) {
            res += step;
        }
    }
    cout << res + 1;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
vector<string> split(string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    vector<std::string> result;
 
    while (first < str.size()) {
        string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == string::npos) {
            last = str.size();
        }
    }
 
    return result;
}
 
int main() {
  string S;
  cin >> S;
  
  char sr = '/';
  
  vector<string> v = split(S, sr);
  int year = atoi(v[0].c_str());
  int month = atoi(v[1].c_str());
  
  string ans;
  if(year >= 2019 && month > 4){
    ans = "TBD";
  }
  else{
    ans = "Heisei";
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll XY[110][110]={0};
  ll y,x;
  char bw;
  cin>>y>>x;
  rep(i,y){
    rep(j,x){
      cin>>bw;
      if(bw=='#')XY[i][j]=1;
      else XY[i][j]=0;
    }
  }
  ll ab=0;
  ll ans[110][110]={0};
  rep(i,y){
    rep(j,x){
      if(i==0&&j==0)ans[i][j]=XY[i][j];
      else if(i==0)ans[i][j]=ans[i][j-1]+max(XY[i][j]-XY[i][j-1],ab);
      else if(j==0)ans[i][j]=max(XY[i][j]-XY[i-1][j],ab)+ans[i-1][j];
      else ans[i][j]=min(ans[i-1][j]+max(XY[i][j]-XY[i-1][j],ab),ans[i][j-1]+max(XY[i][j]-XY[i][j-1],ab));
    }
  }
  cout<<ans[y-1][x-1]<<endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))

A.sort()

count = 0
X = 0


for i in A:
  if count == 0:
    count += 1
    X += i
    continue
  else:
    X = (X + A[count]) / 2
    count += 1

print(X)

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

#define int long long
#define LD long double

const int N = 100010;

int inf = 1e15;
int mod = 1e9 + 7;

signed main()
{
    //freopen("IN.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;
    int a[m], b[m];
    int mask[m];
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        int R = 0;
        for(int j = 0; j < b[i]; j++) {
            int x; cin >> x; x--;
            R |= (1 << x);
        }
        mask[i] = R;
    }
    int dp[(1 << n)][m + 1];
    for(int i = 0 ; i < (1 << n); i++) {
        for(int j = 0; j <= m; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= m; i++) {
        for(int j = 0; j < (1 << n); j++) {
            int x = (j | mask[i - 1]);
            dp[x][i] = min(dp[x][i], dp[j][i - 1] + a[i - 1]);
        }
        for(int j = 0; j < (1 << n); j++) {
            dp[j][i] = min(dp[j][i], dp[j][i - 1]);
        }
    }

    if(dp[(1 << n) - 1][m] == inf) {
        cout << "-1\n";
    }
    else {
        cout << dp[(1 << n) - 1][m] << "\n";
    }
    return 0;
}


Measured memory_bytes: 32256
def Frog1():
    N = int(input())
    Hs = list(map(int,input().split()))
    dp = [0 for i in range(N)]
    dp[0] = 0
    dp[1] = abs(Hs[1]-Hs[0])
    for i in range(2,N):
        dp[i] = min(abs(Hs[i-1]-Hs[i])+dp[i-1],abs(Hs[i-2]-Hs[i])+dp[i-2])
    print(dp[N-1])
Frog1()


Measured memory_bytes: 13924
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, ans=0;
	cin >> n;
	vector<lli> a(n);
	rep(i,n) cin >> a[i];
	map<int, int> mp;
	rep(i,n){
		int sa = i-a[i];
		int wa = i+a[i];
		ans += mp[sa];
		mp[wa]++;
	}
	cout << ans << endl;
	return 0;
}

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

const int maxn=1e6+7;
ll c,x[maxn],w[maxn],val[maxn],shun[maxn],ni[maxn],rval[maxn];
int n;
int main (){
    scanf("%d %lld",&n,&c);
    for(int i=1;i<=n;i++){
        scanf("%lld %lld",&x[i],&w[i]);
        val[i]=val[i-1]+w[i];
        shun[i]=max(shun[i-1],val[i]-x[i]);
    }
    for(int i=n;i>=1;i--){
        rval[i]=rval[i+1]+w[i];
        ni[i]=max(ni[i+1],rval[i]-c+x[i]);
    }
    ll ans=0;
    for(int i=n;i>=1;i--){
        ans=max(ans,rval[i]-2*(c-x[i])+shun[i-1]);
        ans=max(ans,ni[i]);
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,val[i]-2*x[i]+ni[i+1]);
        ans=max(ans,shun[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15360
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int W,H;
char c[69][70];
string dp[69][69];

int main(){
	while(cin>>W>>H&&W){
		rep(i,69)fill(dp[i],dp[i]+69,"");
		rep(i,H)rep(j,W)cin>>c[i][j];
		rep(i,H)rep(j,W)if(isdigit(c[i][j])){
			if(!i&&!j)dp[i][j]=c[i][j];
			else if(!i)dp[i][j]=dp[i][j-1]+c[i][j];
			else if(!j)dp[i][j]=dp[i-1][j]+c[i][j];
			else{
				string l=dp[i][j-1],u=dp[i-1][j];
				if(l.size()>u.size())dp[i][j]=l+c[i][j];
				else if(l.size()<u.size())dp[i][j]=u+c[i][j];
				else{
					dp[i][j]=max(l,u)+c[i][j];
				}
			}
			if(dp[i][j][0]=='0')dp[i][j]=dp[i][j].substr(1);
		}
		//rep(i,H)rep(j,W)cout<<dp[i][j]<<(j==W-1?"\n":" ");
		string ans="";
		rep(i,H)rep(j,W)if(dp[i][j].size()>ans.size()||dp[i][j].size()==ans.size()&&dp[i][j]>ans)ans=dp[i][j];
		cout<<ans<<endl;
	}
}

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

int main(){
    vector<vector<char>> vec(3, vector<char>(3));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >>  vec.at(i).at(j);
        } 
    }

    for (int i = 0; i < 3; i++) {
        cout << vec.at(i).at(i);
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll t;
  cin >> t;
  while(t--) {
    ll n,ans=0;
    cin >> n;
    vec a(n),now;
    for(ll i=0;i<n;i++) cin >> a[i];
    string s;
    cin >> s;
    for(ll i=n-1;i>=0;i--) {
      for(ll p:now) {
        a[i]=min(a[i],a[i]^p);
      }
      now.push_back(a[i]);
      ans|=s[i]=='1'&&a[i];
    }
    cout << ans << endl;
  }
}

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

#define ll long long
#define INF 99999999
/*int main()
{
    ll a,b;
    cin >> a >> b;
    ll tmp1,tmp2;
    vector<pair <ll,ll> > c;
    ll f,ff;
    for(ll i = 0;i < a;i++)
    {
        cin >> f >> ff;
        c.push_back(make_pair(f,ff));
    }
    ll ans = 0;
    sort(c.begin(),c.end());
    for(ll i = 0;i < a;i++)
    {
        if(c[i].second < b)
        {
            ans += c[i].first*c[i].second;
            b -= c[i].second;
        }
        else
        {
            ans += c[i].first * b;
            cout << ans << endl;
            return 0;
        }
    }
}
*/

int main()
{
    ll a,b;
    cin >> a >> b;
    ll tmp1,tmp2;
    vector<pair <ll,ll> > c(a);
    for(ll i = 0;i < a;i++)
    {
        cin >> tmp1>> tmp2;
        c[i] = make_pair(tmp1,tmp2);
    }
    ll ans = 0;
    sort(c.begin(),c.end());
    for(ll i = 0;i < a;i++)
    {
        if(c[i].second < b){
            ans += c[i].first * c[i].second;
            b -= c[i].second;
        }
        else
        {
            ans += c[i].first * b;
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <utility>
#include <stdlib.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.begin(),x.end(),greater<int>())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << n - k << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
using namespace std;

int main() {
    long long a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }
    else if(a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3088
#include<stdio.h>
#include<string.h>
int main()
{
	int tc;
	scanf("%d",&tc);
	char input[10005];
	scanf("%s",input);
	int len = strlen(input);
	for(int i = 0;i<len;i++)
	{
		input[i] += tc;
		if(input[i] > 'Z')
		{
			input[i] -= 'Z'-'A'+1;
		}
	}
	printf("%s",input);
}

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

using namespace std;

int main(){
	while(true){
		int n,p; cin >> n >> p;
		if(n == 0)break;
		vector<int> a(n,0);
		int s = p;
		int cnt = 0;
		while(true){
			if(s == 0){
				s = a[cnt];
				a[cnt] = 0;
			}
			else{
				s--;
				a[cnt]++;
			}
			if(s == 0 && a[cnt] == p)break;
			cnt++;
			cnt = cnt % n;
		}
		cout << cnt << endl;
	}
	
	return 0;
}

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

int A, B;
int D[5];

void set_dig(int n) {
	for (int i = 0; i < 5; ++i) {
		D[i] = n % 10;
		n /= 10;
	}
}

int main(void) {
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; ++i) {
		set_dig(i);
		if (D[0] == D[4] && D[1] == D[3])
			++ans;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

a = Array.new(5)
a[0] = gets.to_i
a[1] = gets.to_i
a[2] = gets.to_i
a[3] = gets.to_i
a[4] = gets.to_i

m = a.map{|x|x%10}.map{|x|x==0?10:x}.min
puts a.map{|x|(x+9)/10*10}.inject(:+) - 10 + m


Measured memory_bytes: 1788
#include <cstdio>

int main()
{
	int f[50]= {1, 1, 2};
	int n;
	scanf("%d", &n) ;
	for (int i = 3; i <= n; ++i)
		f[i] = f[i-1] + f[i-2];
	printf("%d\n", f[n]);
	
	return 0;
}


Measured memory_bytes: 2760
import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# 一行に文字列が一個 * n行
s_lis=[readline().rstrip().decode() for _ in range(n)] # .decodeはバイト列から文字列へ変換
# 一行に文字列が一個 * n行で文字列をアルファベット順に変換
s_lis=["".join(sorted(readline().rstrip().decode())) for _ in range(n)]
# 一行に文字列が複数個 * n行
s_lis=[readline().rstrip().split().decode() for _ in range(n)] # .decodeはバイト列から文字列へ変換

# 一行に数値が一個 * n行
s_lis=[int(readline().rstrip()) for _ in range(n)] 
# 一行に数値が複数個 * n行
s_lis=[int(readline().rstrip().split()) for _ in range(n)]

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

s=list(str(input()))
t=list(str(input()))
t_p=t

if s+list(t[-1])==t:
    print("Yes")

else:
    print('No')

Measured memory_bytes: 9120
dict ={}
raw_input()
for i in raw_input().split():
 if i in dict:
  dict[i]=dict[i]+1
 else:
  dict[i]=1

raw_input()
for i in raw_input().split():
 if i in dict:
  dict[i]=dict[i]-1
  if dict[i]<0:
   print "NO"
   exit()
 else:
  print "NO"
  exit()
print "YES"

Measured memory_bytes: 37456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,C;
    cin >> A>>B>>C;
      if(A%2==1||B%2==1||C%2==1){
        cout <<0<<endl;
        return 0;
        }
    if(A==B&&B==C){
        cout << -1 << endl;
        return 0;
        }
  

   int sumsum=0;
   
    for(int i=0;i<1000000000000000;i++){
        int O=0,P=0,Q=0;
        O=(B+C)/2;
        P=(A+C)/2;
        Q=(A+B)/2;
        sumsum++;
        if(O%2==1||P%2==1||Q%2==1){
        cout <<sumsum<<endl;
        return 0;
        }
        A=O,B=P,C=Q;
    }    
}

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

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

dic = {}


for i in A:

    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

#print(dic)

if N % 2 == 0:

    flag = True
    now = 1

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break

        now += 2

    if len(dic) != N // 2:
        flag = False

    if flag:
        print ((2 ** (N // 2)) % (10 ** 9 + 7))

    else:
        print (0)

else:

    flag = True
    now = 2

    if 0 not in dic or dic[0] != 1:
        flag = False

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break
        now += 2

    if flag:
        print ((2 ** (N // 2)) % (10**9 + 7))

    else:
        print (0)   

Measured memory_bytes: 14436
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	string s;
	int a;
	cin >> a;
	cin >> s;
	if (a >= 3200)PRI(s);
	else PRI("red");
	return 0;
}

Measured memory_bytes: 3604
n, m = map(int, input().split())
pd = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
dict = defaultdict(list)
for i, (p, d) in enumerate(pd):
    dict[p].append((d, i))

ans = ['' for _ in range(m)]
for key in dict:
    v = dict[key]
    v.sort()

    for i, (y, idx) in enumerate(v):
        tmp = str(key).zfill(6) + str(i + 1).zfill(6)
        ans[idx] = tmp

for a in ans:
    print(a)


Measured memory_bytes: 94680
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> p = inp(n);

    bool ans = 1;
    REP(i, n-1) if (p[i] > p[i+1]) ans = 0;
    REP(j, n) REP(i, j) {
        swap(p[i], p[j]);
        bool okay = true;
        REP(i, n-1) if (p[i] > p[i+1]) okay = 0;
        ans |= okay;
        swap(p[i], p[j]);
    }
    say(YES(ans));
    
}

Measured memory_bytes: 256
n=int(input());q=lambda i:input('%d\n'%i);i,j=0,n-1;a,b=q(i),q(j)
while 1:
 k=(j+i+1)//2;c=q(k)
 if(k-i)%2==(a==c):j=k
 else:a=c;i=k

Measured memory_bytes: 3660
#include "bits/stdc++.h"

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(c) begin(c), end(c)

using ll = long long;
using namespace std;
// const int MOD = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	REP(i, N) cin >> a[i];
	sort(ALL(a));
	cout << abs(a[0] - a[N - 1]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a[210], n;
    while(cin >> n) {
        bool flag = true;
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
            if(a[i] & 1) flag = 0;
        }
        int cnt = 0;
        while(flag) {
            cnt++;
            for(int i = 0; i < n; ++i) {
                a[i] >>= 1;
                if(a[i] & 1) {
                    flag = 0;
                    break;
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    int n,a[] = {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};
    cin>>n;
    for(int i=1;i<=32;i+=1){
        if(i==n){
            cout<<a[i-1]<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define TOTAL 3

int main(void)
{
	int i, j, tmp;

	int num[TOTAL];

	scanf("%d %d %d", &num[0], &num[1], &num[2]);

	for(i = 0; i < TOTAL; i++)
		for(j = i + 1; j < TOTAL; j++)
			if (num[i] > num[j])
			{
				tmp = num[i];

				num[i] = num[j];

				num[j] = tmp;
			}

	printf("%d %d %d\n", num[0], num[1], num[2]);

	return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc int t;cin>>t;while(t--)
#define otc int t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b)
{return (a.fi > b.fi);}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	set<string> st;
	while (n--)
	{
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;

}

Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, K; cin >> N >> K;
    VLL A(N); REP(i,N) cin >> A[i];

    int M = N * (N + 1) / 2;
    VLL B(M);
    int ib = 0;
    FOR(i, 0, N) {
        ll sum = 0;
        FOR(j, i, N) {
            sum += A[j];
            B[ib++] = sum;
        }
    }

    ll ans = 0;
    for (int i = 40; i >= 0; i--) {
        ll bit = ans + (1LL << i);
        int cnt = 0;
        for (auto b : B) {
            if ((bit & b) == bit) cnt++;
        }
        if (cnt >= K) {
            ans += (1LL << i);
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 7128
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  vector<int> color(3);
  rep(i,3){cin>>color[i];}
  sort(color.begin(),color.end());
  int a=color[0],b=color[1],c=color[2];
  if (a==b && b==c){cout << 1;}
  else if (a==b || b==c){cout << 2;}
  else {cout << 3;}

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){return IntStream.range(0, v);};
	public static void main(String[] __){
		final char[][] v=Stream.of(".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz").map(o->o.toCharArray()).toArray(char[][]::new);
		for(int n=s.nextInt();n>0;n--) {
			ArrayDeque<Character> r=new ArrayDeque<>();
			char last='0';
			int index=0;
			for(char c:s.next().replaceFirst("^0+", "").replaceAll("00+", "0").toCharArray()) {
				if(c=='0') {
					last=c;
					continue;
				}
				if(last=='0') {
					r.add(v[c-'1'][index=0]);
				}else {
					r.pollLast();
					index=(index+1)%v[c-'1'].length;
					r.add(v[c-'1'][index]);
				}
				last=c;
 			}
			System.out.println(r.toString().replaceAll("(\\[|\\]|, )",""));
		}
	}
}

Measured memory_bytes: 36812
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
ll n, ans=0;

void solve(int i){
    int tmp=0, pos=1;
    while(n%i==0){
        n/=i;
        ++tmp;
        if(tmp==pos){
            pos++;
            tmp=0;
            ++ans;
        }
    }
}

int main(){
    scanf("%lld",&n);
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            solve(i);
        }
    }
    if(n!=1) ++ans;
    printf("%lld\n", ans);
    return 0;
}
/*

*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     ·ð×æ±£ÓÓ      ÓÀÎÞBUG


Measured memory_bytes: 3800
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N;
    long cnt;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        cnt = IntStream.range(0, N).filter(i -> sc.nextInt() != i + 1).count();
    }

    void solve(PrintWriter out) {
        out.println(cnt == 0 || cnt == 2 ? "YES" : "NO");
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 27732
#include<bits/stdc++.h>
 
using namespace std;
 
const int MAX = 1005;
 
typedef long double ld;
 
ld dp[MAX][MAX];
pair<int,int> arr[MAX];
int n;
 
ld dist(int i,int j)
{
    return hypotl(arr[i].first-arr[j].first,arr[i].second-arr[j].second);
}
 
ld solve(int idx,int lst)
{
    ld &ret = dp[idx][lst];
    if(ret == ret)
        return ret;
    if(idx == n-1)
        return ret = dist(idx,idx-1) + dist(idx,lst);
    return ret = min(solve(idx+1,lst) + dist(idx,idx-1), solve(idx+1,idx-1) + dist(idx,lst));
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i].first>>arr[i].second;
    sort(arr,arr+n);
    cout<<fixed<<setprecision(10)<<solve(1,0)<<"\n";
    return 0;
}


Measured memory_bytes: 19220
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int n;
	cin >> n;
	
	vector<string> v(6);
	
	while(n--)
	{
		double l;
		cin >> l;
		
		int r = (l - 160.0) / 5.0;
		if(5 <= r) r = 5;
		
		v[r] += "*";
	}
	
	rep(i, 6) cout << i + 1 << ":" << v[i] << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e9+7

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = -1;
    for (int i = b * 10; i < b * 10 + 10; ++i) {
        if ((i * 8) / 100 == a) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	static int []segmentTree;

	static void build(int []nums) {
		int n = nums.length;
		for (int i=0; i<n; i++)
			segmentTree[n+i] = nums[i];
		for (int i=n-1; i>0; i--) {
			segmentTree[i] = segmentTree[2*i] + segmentTree[2*i+1];
		}
	}

	static int query(int l, int r, int n) {
		int sum = 0;
		for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
			if ((l&1) == 1) {
				sum += segmentTree[l++];
			}
			if ((r&1) == 1) {
				sum += segmentTree[--r];
			}
		}
		return sum;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, k;
		n = in.nextInt();
		k = in.nextInt();
		int []nums = new int[n];
		for (int i=0; i<n; i++) nums[i] = in.nextInt();
		int dp[] = new int[n+1];
		for (int i=1; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
			for (int j=1; j<=k; j++) {
				if (i-j >= 0) {
					// System.out.println(dp[i]+" "+(dp[i-j]+Math.abs(nums[i] - nums[i-j])));
					dp[i] = Math.min(dp[i], dp[i-j]+Math.abs(nums[i] - nums[i-j]));
				}
				else {
					break;
				}
			}
		}
		// for (int i=0; i<n; i++)
		// 	System.out.print(dp[i]+" ");
		// System.out.println();
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 51380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ll n,m,x;
       cin>>n>>m>>x;
       ll c[n];
       ll xx[n][m];
       fri(i,0,n)
       {
              cin>>c[i];
              fri(j,0,m)
              {
                     cin>>xx[i][j];
              }
       }
       ll ans = mod;
       fri(msk,0,(1<<n))
       {
              ll vals[m];
              ll cst = 0;
              memset(vals,0,sizeof vals);
              fri(j,0,n)
              {
                     if(msk & (1LL << j))
                     {
                            cst += c[j];
                            fri(i,0,m){
                                   vals[i] += xx[j][i];
                            }
                     }
              }
              bool ff = true;
              fri(i,0,m){
                     if(vals[i] < x){ff = false;}
              }
              if(ff){
                     ans = min(ans,cst);
              }
       }
       if(ans == mod){
              cout<<-1<<endl;
       }
       else{
              cout<<ans<<endl;
       }


}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const int MAX_N = 1e5 + 7;

bool is_palindrome(string s) {
        int n = s.length();
        for (int i = 0; i < n; ++i)
        {
                if (s[i] != s[n - i - 1]) return false;
        }
        return true;
}


void solve()
{
        int a, b; cin >> a >> b;
        int res = 0;
        for (int i = a; i <= b; ++i)
        {
                string s = to_string(i);
                if (is_palindrome(s)) res++;
        }
        cout << res << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3704
import collections
N = int(input())
li = [i for i in range(1, N+1)]
l1 = list(map(lambda x:str(x)[0]+str(x)[-1], li))
l2 = list(map(lambda x:str(x)[-1]+str(x)[0], li))
c1 = collections.Counter(l1)
c2 = collections.Counter(l2)

num = 0
for l in set(l1):
    num += c1[l] * c2[l]
print(num)

Measured memory_bytes: 36660
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
string s;
int d;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s>>d;
    /*
    if(s.size()==1){
            cout<<(s[0]-'0')/d<<"\n";
            return 0;
    }
    */
    int n=s.size();
    ll dp[n+1][2][d];
    memset(dp,0,sizeof dp);
    dp[0][0][0]=1;
    for (int i = 0; i <n; i++)
    {
        for(int j=0;j<2;j++){
            for(int k=0;k<d;k++){
                //cout<<i<<" "<<j<<" "<<k<<"\n";
                if(j){
                    for(int l=0;l<=9;l++){
                        dp[i+1][j][(k+l)%d]+=dp[i][j][k];
                        dp[i+1][j][(k+l)%d]%=MOD;
                    }
                }
                else{
                    for(int l=0;l<s[i]-'0';l++){
                        dp[i+1][1][(k+l)%d]+=dp[i][j][k];
                        dp[i+1][1][(k+l)%d]%=MOD;
                    }
                    dp[i+1][0][(k+(s[i]-'0'))%d]+=dp[i][j][k];
                        dp[i+1][0][(k+(s[i]-'0'))%d]%=MOD;
                }
            }
        }
    }
    cout<<(dp[n][0][0]+dp[n][1][0]-1+MOD)%MOD<<"\n";
}



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

typedef struct segtree{
	int n;
	vector<int> a;
	segtree(){};
	segtree(int n){init(n);};

	void init(int n_){
		n = 1;
		while(n<n_)n*=2;
		a.resize(2*n-1,INT_MAX);
	}

	void update(int pos,int x){
		pos += n-1;
		a[pos]=x;
		while(pos>0){
			pos = (pos-1)/2;
			a[pos] = min(a[2*pos+1], a[2*pos+2]);
		}
	}

	int findMinValue(int ll,int rr){
		int vl=INT_MAX,vr=INT_MAX;
		for (int l=ll+n, r=rr+n ; l<r ; l=(l>>1),r=(r>>1)){
			if(l&1) vl=min(vl,a[l-1]),l++;
			if(r&1) r--,vr=min(vr,a[r-1]);
		}
		return min(vl,vr);
	}

}segtree;

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

	vector<int> dist(n+1,1e9);
	dist[n]=0;

	segtree seg(n+1);
	seg.update(n,0);

	repr(i,n-1,0){
		if(s[i]=='1')continue;
		int val;
		if(n-i<=m) val = seg.findMinValue(i,n+1);
		else val = seg.findMinValue(i,i+m+1);
		// cout<<val<<endl;
		if(val==INT_MAX){
			cout<<-1<<endl;
			return 0;
		}
		dist[i]=val+1;
		seg.update(i,dist[i]);
	}

	vector<int> ans;
	int prev=0;

	repi(i,1,n+1){
		if(dist[i]<dist[prev]){
			ans.push_back(i-prev);
			prev=i;
		}
	}

	for(auto x:ans)cout<<x<<" ";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A,B,C,D; cin >> A >> B >> C >> D;
    if(abs(A-B)<=D && abs(B-C)<=D) cout << "Yes" << endl;
    else if(abs(A-C)<=D) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
N,A,B=map(int,input().split())
S=input()

P=0
Q=1
for i in range(len(S)):
    if S[i]=='a'and P<A+B:
        print('Yes')
        P+=1
    elif S[i]=='b'and P<A+B and Q<=B:
        print('Yes')
        P+=1
        Q+=1
    elif S[i]=='c ':
        print('No')
    else:
        print('No')

Measured memory_bytes: 9316