akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vstr s(n);
  rep(i,n)cin>>s[i];
  ll ans=0;
  vvc c(n,vc(n));
  rep(a,n){
    rep(i,n){
      rep(j,n){
        ll nx=(a+i)%n;
        c[nx][j]=s[i][j];
      }
    }
    bool ch=true;
    rep(i,n){
      rep(j,n){
        if(c[i][j]!=c[j][i]){
          ch=false;
        }
      }
    }
    if(ch) ans+=n;
  }
  COUT(ans);
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N,Q; cin >> N >> Q;
	vector<int> a(N),l(Q),r(Q);
	rep(i,N) cin >> a[i];
	rep(i,Q) cin >> l[i] >> r[i];

	sort(all(a));
	rep(i,Q) {
		int k = upper_bound(all(a),r[i]) - lower_bound(all(a),l[i]);
		cout << k << endl;
	}

}



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

int dsum ( int64_t n )
{
	int sum = 0;
	while ( n > 0 ) {
		sum += n % 10;
		n /= 10;
	}
	return ( sum );
}
int main()
{
	int64_t N;
	int64_t pat = 9999999999999999LL;
	cin >> N;
	int64_t g = 1000000000000000LL;
	while ( pat > N ) {
		int i = 1;
		while ( i <= 9 && (pat % g + g * i) <= N ) i++;
		i--;
		pat = g * i + pat % g;
		g /= 10;
	}
	cout << dsum(pat) << endl;
	return ( 0 );
}


Measured memory_bytes: 384
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  H,W,M=LI()
  h=[0]*H
  w=[0]*W
  d={}
  for _ in range(M):
    a,b=LI()
    a-=1
    b-=1
    h[a]+=1
    w[b]+=1
    d[(a,b)]=1

  h_koho=[]
  w_koho=[]

  h_max=max(h)
  w_max=max(w)

  for i,x in enumerate(h):
    if x==h_max:
      h_koho.append(i)
  for i,x in enumerate(w):
    if x==w_max:
      w_koho.append(i)

  for x in h_koho:
    for y in w_koho:
      if (x,y) not in d:
        return h_max+w_max

  return h_max+w_max-1

# main()
print(main())


Measured memory_bytes: 87244
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 1500; i++)
    {
        if (i * 8 / 100 == a && i / 10 == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(;;){
        c-=b;
        // cout<<"c="<<c<<endl;
        if(c<=0){cout<<"Yes\n";return 0;}
        a-=d;
        // cout<<"a="<<a<<endl;
        if(a<=0){cout<<"No\n";return 0;}
    }
/*    while(true){
        c-=b;
        cout<<"c="<<c<<endl;
        if(c<=0)cout<<"Yes\n";return 0;
        a-=d;
        cout<<"a="<<a<<endl;
        if(a<=0)cout<<"No\n";return 0;
    }
    return 0;


*/
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int table[] = new int[X + 1];

		int Max = 1;
		for (int i = 2; i < Math.sqrt(X); i++) {
			int p = 2;
			int tmp;
			while ((int) Math.pow(i, p) <= X) {
				p++;
			}
			Max = Math.max(Max, (int) Math.pow(i, p - 1));
		}
		System.out.println(Max);
	}

}


Measured memory_bytes: 21588
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
x,y = map(int, input().split())
print('Yes' if (x in g1 and y in g1) or (x in g2 and y in g2) or (x in g3 and y in g3) else 'No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long tnum;

#define loop(i, num) for(int i = 0; i < num; i++)

tnum* tnumAlloc(int num);
tnum getNumStdin();
tnum* getNumsStdin(int);
char* getCharsStdin(int maxlength);
string getStringStdin();
void printlnNums(int count, tnum* nums);
void printlnNum(tnum num);
void printString(string str);

#define min(a,b) (a <= b ? a : b)
#define max(a,b) (a >= n ? a : b)

/*void sort(T* start, T* end) (in <algorithm>)
example:
	int a[5] = {2, 1, 3, 5, 4};
	sort(a, a + 5);
	-> a: {1, 2, 3, 4, 5}
*/

int main() {
    char *s, *t;

    s = getCharsStdin(2000);
    t = getCharsStdin(2000);

    tnum tl = strlen(t);
    tnum sl = strlen(s);
    tnum countmin = 999999;
    tnum count = 0;

    loop(j, sl-tl+1){
        count = 0;
        loop(i, tl){
            if(s[i+j] != t[i])
                count++;
        }
        if(count < countmin)
            countmin = count;
    }
    

    printlnNum(countmin);

    return 0;
}



//have to be free()
tnum* tnumAlloc(int num) {
	return (tnum*)calloc(num,sizeof(tnum));
}

tnum getNumStdin() {
	tnum ret;
	scanf("%lld", &ret);

	return ret;
}

//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = tnumAlloc(num);
	for (int i = 0; i < num; i++) {
		scanf("%lld", &buf[i]);
	}

	return buf;
}

//have to be free()
char* getCharsStdin(int maxlength) {
	char* ret = (char*)malloc(maxlength+1);
	scanf("%s", ret);

	return ret;
}

//have to be free()
string getStringStdin() {
	string ret;
	cin >> ret;
	return ret;
}

void printlnNum(tnum num) {
	printf("%lld\n", num);
}

// can be used for debugging
void printlnNums(int count, tnum *nums) {
	loop(i, count) {
		printf("%lld", nums[i]);
		if (i != count - 1) printf(" ");
	}
	printf("\n");
}

void printString(string str) {
	cout << str;
}


Measured memory_bytes: 3748
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }


fun main() {
    val m = mutableMapOf<Long, Int>()

    var result = 0

    val (n, d) = readLongArray(2)
    for (i in 0 until n) {
        val (x, y) = readLongArray(2)
        if (x*x + y*y <= d*d) {
            result += 1
        }
    }

    println(result)

}

Measured memory_bytes: 52628
#include<iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//1000000000000223
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, a[200009], b[200009];
vector<int> v1, v2;
ll sum, mx=2e9;
int main()
{
    IO
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i]>>b[i];
        if(a[i]<b[i])
            v1.push_back(i);
        else if(a[i]>b[i])
            v2.push_back(i), mx=min(mx,1LL*b[i]);
        sum+=a[i];
    }
    if(v1.empty()&&v2.empty())
        return cout<< 0, 0 ;
    cout<<sum-mx;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char dn[1300000], * di = dn;
int keta1 = 1, keta2;
char C1[10] = { '1', '0', '0', '0', '0', '0' };
char C2[10] = { '0', '0', '0', '0', '0', '0' };

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


	int N, M;
	scanf("%d %d", &N, &M);

	if (N % 2) {
		int n = N - 1;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}

		rep1(i, M) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}
	else {
		int n = N;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}
		rep1(i, (M + 1) / 2) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
		C2[0]--;
		int tmp = 0;
		while (C2[tmp] < '0') {
			C2[tmp++] += 10;
			C2[tmp]--;
			if (C2[keta2 - 1] == '0') keta2--;
		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int fpow(int b,int e)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2);
	if(e%2) return b*tmp*tmp;
	else return tmp*tmp;
}

int fpowm(int b,int e,int mod)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2)%mod;
	if(e%2) return b*tmp%mod*tmp%mod;
	else return tmp*tmp%mod;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin>>s;
	int now=0,mx=0;
	for(auto i:s)
	{
		if(i=='A' || i=='C' || i=='G' || i=='T')
		{
			now++;
			mx=max(mx,now);
		}
		else
		{
			now=0;
		}
	}
	cout<<mx<<"\n";
	return 0;
}








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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int res = 0;
    rep(i, n)
    {
        if (v[i] - c[i] > 0)
        {
            res += v[i] - c[i];
        }
    }

    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    ll ans = 0;
    for(int i = 0; i < n - 1; i++) {
        if(a[i] > a[i + 1]) {
            ans += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
int  main() {
	int t;
	//cin >> t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		string s;
		cin>>s;
		//int dp[n];
		//dp[0]=s[0]=='W'?1:0;
		int cnt=0;
		int l=0;
		int r=n-1;
		while(l<r)
		{
			if(s[l]=='R')l++;
		    if(s[r]=='W')r--; 
            if(s[l]=='W'&&s[r]=='R')
            {
            	cnt++;
            	s[l]='R';
            	s[r]='W';
            	l++;r--;
            }
		}
		cout<<cnt;
	}

}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a;
	cin>>a;
	LL sum=0;
	for(int i=1;i<=a;i++){
		if(i%3!=0 and i%5!=0) sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3648
N, K = map(int, input().split())
X = [int(x) for x in input().split()]

import bisect
zero = bisect.bisect_left(X, 0)

left = max(zero - K, 0)
ans = float('inf')
while 1:
    right = left+K-1
    if left > zero + 1 or len(X) <= right: break
    lv, rv = X[left], X[right]
    if lv * rv > 0:
        ans = min(ans, max(abs(rv), abs(lv)))
    else:
        ans = min(ans, min(rv*2 - lv, rv - lv*2))
    left += 1

print(ans)

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

using namespace std;
using ll = long long;

# define var auto

int main() {
    int num;
    cin >> num;
    vector<int> ar(num);
    for(var i=0;i<num;i++)
        cin >> ar[i];
    vector<int> dp(num);
    dp[1]=abs(ar[0]-ar[1]);
    for(var i=2;i<num;i++)
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    cout << dp[num-1] << endl;

    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int m, k;
    cin >> m >> k;
    if(m==0){
        if(k==0) cout << "0 0" << endl;
        else cout << "-1" << endl;
        return 0;
    }
    if(m==1){
        if(k==0) cout << "0 0 1 1" << endl;
        else if(k==1) cout << "-1" << endl;
        else cout << "-1" << endl;
        return 0;
    }
    if(k >= (1<<m)){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<(1<<m);i++){
        if(i==k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for(int i=(1<<m)-1;i>=0;i--){
        if(i==k) continue;
        cout << i << " ";
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 1792
n=input()
n1=n[:2]
n2=n[2:]
A=int(n1)
B=int(n2)
if 0<A<13:
    if 0<B<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<B<13:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
import java.util.Scanner;

//クラス名は必ずMainにする必要があります。



public class Main {
    public static void main(String args[] ) throws Exception {
		Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());

        System.out.println((int)(a+Math.pow(a, 2)+Math.pow(a, 3)));
 	}
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         ll a,b,c,d;cin>>a>>b>>c>>d;
         cout<<max({a*c,a*d,b*c,b*d});
    }
}


Measured memory_bytes: 3648
MOD = 1000000007

x,y = map(int,input().split())
if (x+y)%3!=0:
    print(0)
    exit()
p = (x+y)//3
W = x-p+1
H = y-p+1

if W == 1 or H == 1:
    print(1)
    exit()
if W < 1 or H < 1:
    print(0)
    exit()

numer = 1

inv = [0 for _ in range(max(W,H))]
inv[0] = 1

for i in range(W+H-2):
    numer *= i+1
    numer %= MOD

for i in range(1,len(inv)):
    inv[i] = inv[i-1]*pow(i+1,MOD-2,MOD) %MOD

print(numer*inv[H-2]*inv[W-2]%MOD)

Measured memory_bytes: 67312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 110;

int len; ll k;
char str[MAXN];
ll ans;

int main(){
	int head, tail, prev;
	scanf("%s", str + 1);
	len = strlen(str + 1);
	head = tail = 0;
	prev = 1;
	for(int i = 1; i <= len; i++){
		if(str[i] == str[1]){
			head++;
		}else{
			break;
		}
	}
	for(int i = len; i >= 1; i--){
		if(str[i] == str[len]){
			tail++;
		}else{
			break;
		}
	}
	for(int i = 2; i <= len; i++){
		if(str[i] != str[i - 1]){
			ans += prev >> 1;
			prev = 1;
		}else{
			prev++;
		}
	}
	ans = ans + (prev >> 1);
	scanf("%lld", &k);
	if(prev == len){
		printf("%lld\n", (k * len) >> 1);
		return 0;
	}
	// printf("%lld\n", ans);
	ans = ((ans - (head >> 1) - (tail >> 1)) * k) + (head >> 1) + (tail >> 1);
	// printf("%d %d %lld\n", head, tail, ans);
	if(str[1] == str[len]) ans = ans + ((head + tail) >> 1) * (k - 1);
	else ans = ans + ((head >> 1) + (tail >> 1)) * (k - 1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int n, i, a[10000] = { 0 }, h;
	cin >> n;
	for (i = 0; i <n; i++) {
		cin >> a[n-i];
	}
	for (i = 1; i < n+1; i++) {
		if (i == n ) {
			cout << a[i] << endl;
		}
		else {
			printf("%d ", a[i]);
		}
	}
}

Measured memory_bytes: 3224
#include <stdio.h>
int solve(int ,int);

int A[20],n;
int main() {
  int i,j,q,m[200],t;
  scanf("%d",&n );
  for (i = 0; i < n; i++) {
    scanf("%d",&A[i] );
  }
  scanf("%d",&q);
  for (i = 0; i < q; i++) {
    scanf("%d",&m[i]);
  }
  for (i = 0; i < q; i++) {
  t= solve(0,m[i]);
  if (t ==1) {
    printf("yes\n");
  }

  if (t ==0) {
    printf("no\n");
  }

}
  return 0;
}
int solve(int i,int m){
  int res=0;
   if (m == 0)
   return 1;
   if (i >= n)
  return 0;
  if (solve(i + 1, m - A[i]) == 1 || solve(i + 1, m) == 1)
  res = 1;
  // res = solve(i + 1, m - A[i]);
  return res;
}



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

#define ll long long
#define endl "\n"
#define M 10000001

int isPrime[M];
int countDiv[M];

void Seive()
{
    for(int i = 2; i*i < M; i++)
    {
        if(isPrime[i] == 0)
        {
            for(int j = i*i; j < M; j+=i)
            {
                isPrime[j] = i;
            }
        }
    }
    for(int i = 1; i < M; i++)
    {
        if(isPrime[i] == 0)
            isPrime[i] = i;
    }
}

void Div()
{
    countDiv[1] = 1;
    for(int i = 2; i < M; i++)
    {
        map<int,int> counts;
        int n = i;
        while(n > 1)
        {
            int prime = isPrime[n];
            n /= prime;
            counts[prime]++;
        }
        int c = 1;
        for(auto i : counts)
        {
            c *= (i.second+1);
        }
        countDiv[i] = c;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    Seive();
    Div();
    ll n;
    cin>>n;
    ll sum = 0;
    for(ll i = 1; i <= n; i++)
    {
        sum += (i)*countDiv[i];
    }
    cout<<sum<<endl;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		boolean a = false;
		out:for(int i = 0;i < c.length();i++) {
			for(int k = i+1;k < c.length();k++) {
				if(c.charAt(i)==c.charAt(k)) {
					System.out.println("no");
					a = true;
					break out;
				}
			}
		}
		if(a == false)System.out.println("yes");
	}

}


Measured memory_bytes: 23636
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

int main() {
  ll x, n;
  cin >> x >> n;
  vl p(n);
  cin >> p;

  constexpr ll m = 102;
  vector<bool> a(m);
  for (auto&& i : p) {
    a[i] = true;
  }

  ll mini = 1000, ans = 0;
  rep(i, m) {
    if (a[i] == false and mini > abs(x-i)) {
      mini = abs(x-i);
      ans = i;
    }
  }

  cout << ans << el;
}


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


int main(void)
{
    int n;
    cin >> n;
    int tmp;
    vector<int> ti(0);
    for(int i  = 0; i < n; i++){
        cin >> tmp;
        ti.push_back(tmp);
    }
    int m;
    cin >> m;
    vector<int> pi;
    vector<int> xi;
    int tmp2;
    int sum;
    for(int i  = 0; i < m; i++){
        cin >> tmp >> tmp2;
        pi.push_back(tmp);
        xi.push_back(tmp2);
    }
    for(int i = 0; i < m; i++){
        sum = 0;
        for(int j = 0; j < n; j++){
            if(j != (pi[i]-1))
                sum += ti[j];
            else
                sum += xi[i];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
A_n = [int(input()) for i in range(n)]

def insertionSort(A, n, g, _count):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            _count += 1
        A[j+g] = v
    return _count

def shellSort(A, n):
    count = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    for i in reversed(range(m)):
        count = insertionSort(A, n, G[i], count)
    return m, G, count

m, G, count = shellSort(A_n, n)
print(m)
print_G_str = ''
for i in range(m):
    print_G_str += str(G[m - 1 - i])
    if i < m - 1:
        print_G_str += ' '
print(print_G_str)
print(count)
for A in A_n:
    print(A)



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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define ff first
#define ss second
int main (){
    int n, x, i, j, m;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;

int main(){
  int n,x;
  cin>>n>>x;
  int a[n];
  rep(i,n)cin>>a[i];
  ll ans =0;
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  }
  rep(i,n-1){
    ll v =a[i]+a[i+1];
    if(v>x){
      ans+=a[i+1]-(x-a[i]);
      a[i+1]=x-a[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
N, K = [int(x) for x in input().strip().split(" ")]
hs = [int(x) for x in input().strip().split(" ")]
d = [0] * N

for i in range(N-1):
    i = i+1
    tmp = pow(10, 18)
    for j in range(K):
        j = j + 1
        if i-j < 0:
            continue
        tmp = min(tmp, d[i-j] + abs(hs[i-j] - hs[i]))
    d[i] = tmp
print(d[-1])


Measured memory_bytes: 52192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n; cin >> n;
    vector<ll> A(n+1), B(n);
    rep(i, n+1) cin >> A[i];
    rep(i, n) cin >> B[i];

    ll res = 0;
    rep(i, n){
        ll num = min(A[i], B[i]);
        res += num, A[i]-=num, B[i] -=num;
        if(B[i]>0){
            num = min(A[i+1], B[i]);
            res +=num, A[i+1] -=num, B[i] -=num;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  int h,w,k;
  cin>>h>>w>>k;

  vector<string> p(h);
  vector<bool> q(h,false);
  rep(i,h){
    cin>>p[i];
    rep(j,p[i].size()){
      if(p[i][j]=='#') q[i]=true;
    }
  }

  vector<vector<int>> ans(h,vector<int>(w,0));

  int cnt=1;
  rep(i,h){
    if(!q[i]) continue;
    bool mada=true;
    rep(j,w){
      if(mada && p[i][j]=='#') mada=false;
      else if(p[i][j]=='#') cnt++;
      ans[i][j]=cnt;
      if(j==w-1) cnt++;
    }
  }

  int memo;
  rep(i,h){
    if(q[i]) {
      memo=i;
      break;
    }
  }

  rep(i,memo){
    rep(j,w){
    ans[i][j]=ans[memo][j];
    }
  }

  for(int i=memo+1;i<h;i++){
    if(!q[i]){
      rep(j,w){
        ans[i][j]=ans[memo][j];
      }
    }
    if(q[i]) memo=i;
  }

  rep(i,h){
    rep(j,w){
      cout << ans[i][j];
      if(j!=w-1) cout << " ";
    }
    cout << endl;
  }

}

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

int main()
{
    ll N; cin >> N;
    vector<ll> a(N, 0);
    rep(i,N) {
        ll tmp = 0;
        cin >> tmp;
        a[i] = tmp;
    }
    ll ans = 0;
    rep(i, N) {
        if (a[i] % 2) {
            if ((i+1) % 2) {
                ans++;
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
typedef vector<int> Vector;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    int X, Y;
    cin >> X >> Y;
    X--;
    Y--;
    vector<int> reward(205);
    reward[0] = 300000;
    reward[1] = 200000;
    reward[2] = 100000;

    int ans = reward[X] + reward[Y];
    if(X == 0 and Y == 0){
        ans += 400000;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll f[3] = {2, 3, 5};
pque<pair<ll, ll>> que;
set<ll> st;

int main(){
	int tq; scanf("%d", &tq);
	REP(iq, tq){
		ll n, a, b[3]; scanf("%lld", &n);
		REP(i, 3) scanf("%lld", b+i);
		scanf("%lld", &a);

		while(que.size()) que.pop();
		st.clear();

		ll ans = LLONG_MAX;
		que.emplace(0, n);
		while(que.size()){
			auto [s, n] = que.top(); que.pop();
			// DEBUG("%lld %lld\n", s, n);
			if(!st.emplace(n).second) continue;
			if(n <= LLONG_MAX / a && n * a <= LLONG_MAX - s) SML(ans, s + n * a);
			REP(i, 3){
				ll p = n % f[i], q = f[i] - p;
				que.emplace(s + p * a + b[i], (n - p) / f[i]);
				que.emplace(s + q * a + b[i], (n + q) / f[i]);
			}
		}

		printf("%lld\n", ans);
	}
}


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

constexpr int mod = 1e9 + 7;
struct Mint {
  int v;
  Mint(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
  Mint& operator*=(Mint r) { v = (long long)v * r.v % mod; return *this; }
  Mint& operator/=(Mint r) { return *this *= r.inv(); }
  Mint& operator+=(Mint r) { if ((v += r.v) >= mod) v -= mod; return *this; }
  Mint& operator-=(Mint r) { if ((v -= r.v) < 0) v += mod; return *this; }
  friend Mint operator*(Mint l, Mint r) { return l *= r; }
  friend Mint operator/(Mint l, Mint r) { return l /= r; }
  friend Mint operator+(Mint l, Mint r) { return l += r; }
  friend Mint operator-(Mint l, Mint r) { return l -= r; }
  Mint pow(long long n) const {
    Mint res = 1;
    for (Mint t = *this; n; t *= t, n >>= 1) if (n & 1) res *= t;
    return res;
  }
  Mint inv() const { return pow(mod - 2); }
  friend string to_string(Mint a) { return to_string(a.v); }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x = 0, y = 0, z = 0;
  Mint res = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    res *= (x == a) + (y == a) + (z == a);
    if (res.v == 0) {
      cout << "0\n";
      return 0;
    }
    if (x == a) {
      ++x;
      continue;
    }
    if (y == a) {
      ++y;
      continue;
    }
    if (z == a) {
      ++z;
      continue;
    }
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 256
import java.math.BigInteger
import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val As = Seq.fill(N)(BigInt(sc.nextLong))

  val limit = BigInt("1000000000000000000")

  if (As.contains(BigInt(BigInteger.ZERO))) {
    println(0)
  } else {
    println(loop(BigInt(BigInteger.ONE), As))
  }

  @tailrec def loop(acc: BigInt, li: Seq[BigInt]): BigInt = li match {
    case _ if acc > limit => BigInt(-1)
    case head +: tail => loop(acc * head, tail)
    case _ => acc
  }

}


Measured memory_bytes: 69028
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int cnt[1000][1000];
int main(){
      int n;
      char fld[1000][1000];
      while(scanf("%d",&n)&&n){
            memset(cnt,0,sizeof(cnt));
            REP(i,n){
                  scanf("%s",fld[i]);
                  REP(j,n)if(fld[i][j]=='*')cnt[i][j]++;
            }
            //REP(i,n){REP(j,n)cout<<cnt[j][i];cout<<endl;}
            REP(i,n)REP(j,n){
                  if(i!=0)cnt[j][i]+=cnt[j][i-1];
                  if(j!=0)cnt[j][i]+=cnt[j-1][i];
                  if(i!=0&&j!=0)cnt[j][i]-=cnt[j-1][i-1];
            }
            //REP(i,n){REP(j,n)cout<<cnt[j][i]<<" ";cout<<endl;}
            int ans=0;
            REP(x,n)REP(y,n){
                  for(int d=ans;d<min(n-x,n-y);d++){
                        int nx=x+d,ny=y+d;
                        int c=cnt[ny][nx];
                        if(x!=0)c-=cnt[ny][x-1];
                        if(y!=0)c-=cnt[y-1][nx];
                        if(x!=0&&y!=0)c+=cnt[y-1][x-1];
                        if(c==0&&ans<d+1){
                              //cout<<x<<" "<<y<<" "<<d+1<<endl;
                              ans=d+1;
                        }
                  }
            }
            printf("%d\n",ans);
      }
}

Measured memory_bytes: 6080
import java.util.*;

public class Main {
	static boolean reverse(int n) {
      int k =n;
      int rev = 0;
      while(n!=0){
        rev = rev*10+n%10;
        n /=10;
      }
      if(k==rev){
        return true;
      }
      else{
        return false;
      }
    }
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0; 
		for(int i = a; i<= b; i++) {
			if(reverse(i)) ans++; 
		}
		System.out.println(ans); 
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll a[N], cum[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    string s;
    cin >> n >> m >> s;
    int c = 0;
    for(int i = 1; i <= n; i++){
        if(s[i] == '1') c++;
        else{
            if(c >= m) return cout << -1, 0;
            c = 0;
        }
    }
    reverse(s.begin(), s.end());
    vector<int> v;
    int ans = 0;
    for(int i = min(m, n); i != n; i = min(i + m, n)){
        int kam = m;
        while(s[i] == '1') i--, kam--;
        v.push_back(kam);
        ans += kam;
    }
    v.push_back(n - ans);
    reverse(v.begin(), v.end());
    for(auto i: v) cout << i << ' ';

    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n;cin>>n;
	int p=pow(2,n);

	vector<VPII> s(n);

	REP(i,n){
		int a; cin>>a;
		s[i].resize(a);
		REP(j,a){
			int x,y; cin>>x>>y;
			x--;
			s[i][j] = make_pair(x,y);
		}
	}

	int result = 0;
	//dump(p)

	for(int k=0;k<p;k++){
		int nin = 0;
		int t = k;
		
		vector<int> shoujiki(n);
		REP(i,n){
			shoujiki[i] = t%2;
			nin += t%2;
			t/=2;
		}
		if(result >= nin){
			continue;
		}
		//dump(k)
		//REP(i,n){
		//	dump(shoujiki[i])
		//}

		bool f = true;

		REP(i,n){
			if(shoujiki[i] == 0){
				continue;
			}
			//dump(i)
			REP(j,SIZE(s[i])){
				int x=s[i][j].first;
				int y=s[i][j].second;
				//dump(j)
				//dump(x)
				//dump(y)
				//dump(shoujiki[x])
				if(shoujiki[x] != y){
					f = false;
				}
			}
		}

		if(f){
			result = nin;
		}
	}

	cout << result << endl;

	return;
}

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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,Q;
ll V,W;
ll level[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	int ma=0;
	level[0]=1;
	if(N>1) {
		ll cur=1;
		while(level[ma]<=1LL<<30) {
			level[ma+1]=level[ma]+cur;
			ma++;
			cur*=N;
		}
	}
	
	while(Q--) {
		cin>>V>>W;
		if(N==1) {
			V=min(V,W);
		}
		else {
			while(V!=W) {
				if(V>W) swap(V,W);
				x=lower_bound(level,level+ma,W+1)-level-1;
				W=(W-level[x])/N+level[x-1];
			}
		}
		cout<<V<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

ll p(ll a,ll b){
	ll sum=1,cnt=0;
	for(ll i=a;cnt<b;i--){
		sum*=i;
		cnt++;
	}
	return sum;
}

ll c(ll a,ll b){
	ll r=1;
	for(ll i=1;i<=b;i++){
		r*=i;
	}
	return a/r;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll>mp;
	ll n,a;
	cin>>n;
	vector<ll>v(200001);
	for(ll i=0;i<n;i++){
		cin>>a;
		mp[a]++;
		v[i]=a;
	}
	vector<ll>vv(200001);
	for(auto p:mp){
		auto a=p.first;
		auto b=p.second;
		vv[a]=b;
	}
	ll sum=0;
	vector<ll>vvv(200001);
	for(ll i=0;i<200001;i++){
		vvv[v[i]]=c(p(mp[v[i]],2),2);
		if(vv[i]==0)continue;
		sum+=c(p(mp[i],2),2);
	}
	for(ll i=0;i<n;i++){
		cout<<sum-vvv[v[i]]+c(p(mp[v[i]]-1,2),2)<<endl;
	}
	return 0;
}



Measured memory_bytes: 15836
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B;
  cin >> B >> A;
  int C = 10 * A;
  int D = (25 * B + 1) / 2;
  int ans = max(C, D);
  if (ans / 10 != A) {
    cout << "-1" << endl;
  }
  else if ((2 * ans) / 25 != B) {
    cout << "-1" << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <climits>
#include <bitset>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
#include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef pair<int,long long> pil;
typedef pair<long long,int> pli;
typedef vector<vector<long long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef priority_queue<int, vector<int>, greater<int> > minq;
typedef priority_queue<int> maxq;
// to initialize PQs with a vector, do 
// minq(v.begin(),v.end()) or maxq(v.begin(),v.end())
// or minq(a,a+10) for arrays

#define emplace_back pb
const char el = '\n';
const long long M = 1000000007;

/*
Edge cases:


*/
ll numdiffusing(int k, int n) {
    ll minsum = 0;
    minsum = (ll)(k)*(k-1)/2;
    ll maxsum = (ll)n*(n+1)/2; //using k terms
    if (k<n+1) maxsum -= (ll)(n-k)*(n-k+1)/2;

    return maxsum-minsum+1;
}

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

    int n,K; cin>>n>>K; cin.ignore();

    ll ret=0;
    for (int k = K; k<=n+1; ++k) {
        // cout<<"found "<<numdiffusing(k,n)<<" diff sums "
        // "using "<<k<<" terms"<<el;
        ret += numdiffusing(k,n);
        ret %= M;
    }

    cout<<ret<<el;



}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

long long int num_abc[26] = {0};
int main(void){
    string S;
    long long int N;
    cin >> N;
    cin >> S;
    //ひとまず文字列を26文字でカウントしていく
    for(int i = 0; i < N; i++){
      num_abc[S[i] - 'a']++;
    }
    long long int ans = 1;
    for(int i = 0; i < 26; i++){
      ans *= (num_abc[i] + 1);
      if(ans > 1000000007){
        ans = ans % 1000000007;
      }
    }
    ans = ans - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
    int i,len,count=0;
    char a[110];
    
    scanf("%s",a);
    
    len=strlen(a);
    
    for(i=0;i<len;i++){
        if(a[i]!=a[len-i-1]){
            count++;
        }
    }
    
    printf("%d\n",count/2);
    
    
    return 0;
}

Measured memory_bytes: 128