akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int n = reader.readInt();
            int[] a = reader.readIntsSplitByDelimiter(" ");

            Arrays.sort(a);

            int closestIndexs = 0;
            int halfMax = (a[n - 1] % 2 == 0) ? a[n - 1] / 2 : a[n - 1] / 2 + 1;
            int minAbs = Math.abs(halfMax - a[closestIndexs]);
            for (int i = 0; i < n; i++) {
                if (Math.abs(halfMax - a[i]) < minAbs) {
                    closestIndexs = i;
                    minAbs = Math.abs(halfMax - a[closestIndexs]);
                }
            }
            System.out.println(a[n - 1] + " " + a[closestIndexs]);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.br.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.br.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.br.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        br.close();
    }
}

Measured memory_bytes: 41476
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int a;

  cin >> a;

  cout << a*a*a << endl;
  
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 3e3+7;
int dp[lim][lim];

int main(){

    string s1,s2;
    cin>>s1;
    cin>>s2;
    int m=s1.length();
    int n=s2.length();
    for(int i=0;i<=m;i++){
        for(int j=0;j<=n;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                if(s1[i-1]==s2[j-1]) {
                    dp[i][j] = dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j] = max(dp[i-1][j], max(dp[i][j-1],dp[i-1][j-1]));
                }
            }
        }
    }
    int ind = dp[m][n];
    string s(ind,' ');
    int i=m,j=n;
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            s[ind-1]=s1[i-1];
            i--;j--;ind--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

int main()
{
    int r,b,g,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0;i<n/r+1;i++){
        for(int j=0;j<n/g+1;j++){
            if ((n-(i*r+j*g))%b==0){
                if (0<=n-i*r-j*g)
                ans++;
            }

        }
    }
    cout<<ans<<endl;
}


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

#define x first
#define y second

int n, k, q, a[2055], ans = 1023456789;

int solve(int x) {
	vector<int> cur, num;
	for (int i = 0; i < n; i++) {
		if (a[i] < x) {
			if (cur.size() >= k) {
				sort(cur.begin(), cur.end());
				for (int j = 0; j < cur.size() - k + 1; j++)
					num.push_back(cur[j]);
			}
			cur.clear();
		} else {
			cur.push_back(a[i]);
		}
	}
	
	if (cur.size() >= k) {
		sort(cur.begin(), cur.end());
		for (int j = 0; j < cur.size() - k + 1; j++)
			num.push_back(cur[j]);
	}
	
	if (num.size() >= q) {
		sort(num.begin(), num.end());
		return num[q - 1] - num[0];
	} else
		return 1023456789;
	
}

int main () {
	
	scanf("%d%d%d", &n, &k, &q);
	
	for (int i = 0; i < n; i++) 
		scanf("%d", a + i);
	
	for (int i = 0; i < n; i++) 
		ans = min(ans, solve(a[i]));
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc117/a.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    double t, x;
    cin >> t >> x;
    double a;
    a = t/x;
    cout << a << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100001

typedef struct{
  char mark;
  int num;
  int order;
}card;

int partition(card *, int, int);
void quicksort(card *, int, int);

int main()
{
  card *A;
  int i, j, n, judge=0;
  char a, b;

  scanf("%d%c", &n, &a);
  A = (card *)malloc(sizeof(card)*n*2 + 1);

  for(i=0; i<n; i++)
    {
      scanf("%c%c%d%c", &A[i].mark, &a, &A[i].num, &b); 
      A[i].order = i;
    }

  quicksort(A, 0, i-1);
  
  for(i=0; i<n; i++)
    {      
      if(A[i].num == A[i+1].num)
	{
	  if(A[i].order > A[i+1].order)
	    {
	      judge = 1;
	      break;
	    }
	}
    }

  if(judge ==0) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0; i<n; i++)
    {
      printf("%c %d\n", A[i].mark, A[i].num);
    }
  
  free(A);
  return 0;
}

void quicksort(card *A, int p, int r)
{
  int q;

  if(p < r)
    {
      q = partition(A, p, r);
      quicksort(A, p, q-1);
      quicksort(A, q+1, r);
    }
}

int partition(card *A, int p, int r)
{
  card change;
  int i = p-1, j;
  int x = A[r].num;

  for(j=p; j<r; j++)
    {
      if(A[j].num <= x)
	{
	  i = i + 1;
	  change = A[j];
	  A[j] = A[i];
	  A[i] = change;
	}
    }
  change = A[r];
  A[r] = A[i+1];
  A[i+1] = change;

  return i+1;
}

Measured memory_bytes: 1680
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll INF=1<<30;

int main(){
    ll n;
    cin >> n;
    ll a[n],ans=1,end=0;
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    for(ll i=n-2;i>=0;i--){
        if(end==2) break;
        if(a[i]==a[i+1]){
            ans *= a[i];
            i--;
            end++;
        }
    }
    if(end!=2) cout << 0 << endl;
    else cout << ans << endl;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	string ans = "hon";
	switch (N % 10) {
		case 3:
			ans = "bon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			ans = "pon";
			break;
		defalut:
			ans = "hon";
			break;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct edge{
   int to, cost;
};

vector<edge> G[1010];
int n, m;
int d[1010][2010];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    rep(i, 0, m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        G[a[i]].push_back({b[i], c[i]});
    }
    rep(i, 0, n) rep(j, 0, 2 * n + 1) d[i][j] = -INF;
    d[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(d[a[j]][i] == -INF) continue;
            d[b[j]][i + 1] = max(d[b[j]][i + 1], d[a[j]][i] + c[j]);
            // cout << " " << b[j] << " " << i + 1 << "=" << max(d[b[j]][i + 1], d[a[j]][i] + c[j]) << endl;
        }
    }
    int ans = -INF;
    for(int i = 0; i <= n; i++){
        ans = max(ans, d[n - 1][i]);
    }
    for(int i = n; i < 2 * n; i++){
        for(int j = 0; j < m; j++){
            if(d[a[j]][i] == -INF) continue;
            d[b[j]][i + 1] = max(d[b[j]][i + 1], d[a[j]][i] + c[j]);
        }
    }
    int ans2 = ans;
    for(int i = n + 1; i <= 2 * n; i++){
        ans = max(ans, d[n - 1][i]);
    }
    // cout << ans << " " << ans2 << endl;
    if(ans != ans2) cout << "inf" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 16128
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int a,b;
  scanf("%d %d",&a,&b);
  if (a + b >= a - b && a + b >= a * b) {
    printf("%d",a + b);
  } else if(a - b >= a + b && a - b >= a * b) {
    printf("%d",a - b);
  } else if(a * b >= a + b && a * b >= a - b) {
    printf("%d",a * b);
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100000
struct Node{
  int p,l,r;
};
struct Node T[MAX];
int dp[MAX],f[MAX];

void SetDe(int x,int c){
  if(x==-1)return;
  dp[x]=c;                                                        
  SetDe(T[x].r,c+1);
  SetDe(T[x].l,c+1);
}

int SetHei(int x){
  int k1=0,k2=0;
  if(T[x].l!=-1)k1=SetHei(T[x].l)+1;
  if(T[x].r!=-1)k2=SetHei(T[x].r)+1;
  if(k1>k2)return f[x]=k1;
  else return f[x]=k2;
}
int GetSibling(int x){
  if(T[x].p==-1)return -1;
  if(T[T[x].p].l!=x && T[T[x].p].l!=-1)return T[T[x].p].l;
  if(T[T[x].p].r!=x && T[T[x].p].r!=-1)return T[T[x].p].r;
  return -1;
}
int main(){
  int i,n,id;
  int le,ri,ro,deg;  
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=-1;
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&le);
    scanf("%d",&ri);
    T[id].l=le;
    T[id].r=ri;
    if(le!=-1)T[le].p=id;
    if(ri!=-1)T[ri].p=id;
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1)ro=i;
  } 
  SetDe(ro,0);
  SetHei(ro);
  for(i=0;i<n;i++){
    deg=0;
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("sibling = %d, ",GetSibling(i));
    if(T[i].l!=-1) deg++;
    if(T[i].r!=-1) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",dp[i]);
    printf("height = %d, ",f[i]);
    if(T[i].p==-1)printf("root\n");
    else if(T[i].l==-1 && T[i].r==-1)printf("leaf\n");
    else printf("internal node\n");				       
    }
  return 0;
}



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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	int N, K;
	cin >> N >> K;
	vector<long long> v;

	for(int i = 1; i <= N; i++){
		long long h;
		cin >> h;
		v.push_back(h);
	}

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

	long long d = 0;
	for(int i = 0; i <= v.size() - K; i++){
		long long h = v[i + K - 1] - v[i];
		if(i == 0 ) d = h;
		else if(h < d){
			d = h;
		}
	}
	cout << d << endl ;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    string s;
    int k;
    cin>>s>>k;
    int l=s.size();
    string res="";
    for(int i=0;i<l-1;i++){
        int d='z'+1-s[i];
        //cout<<s[i]<<' '<<d<<endl;
        if(d==26){
            res+='a';
        }
        else if(d<=k){
            res+='a';
            k-=d;
        }
        else{
            res+=s[i];
        }
    }
    k%=26;
    if('0'+s[l-1]+k>'0'+'z'){
        s[l-1]=s[l-1]-'z'+'a'+k-1;
        res+=s[l-1];
    }
    else{
        res+=s[l-1]+k;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#define upd(x, y) (x) = std::max(x, y)
char str[105];
int dp[105][105][105][105], row_pre[105][105], col_pre[105][105];
int main()
{
	// freopen("AGC004-E.in", "r", stdin);
	int n, m, x, y;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", str);
		for (int j = 0; j < m; j++)
		{
			row_pre[i][j] = (j ? row_pre[i][j - 1] : 0) + (str[j] == 'o');
			col_pre[j][i] = (i ? col_pre[j][i - 1] : 0) + (str[j] == 'o');
			if (str[j] == 'E')
			{
				x = i;
				y = j;
			}
		}
	}
	auto calc_row = [&] (int row, int l, int r)
	{
		int L = std::max(l, r - y), R = std::min(r, l + m - y - 1);
		return L <= R ? row_pre[row][R] - (L ? row_pre[row][L - 1] : 0) : 0;
	};
	auto calc_col = [&] (int col, int l, int r)
	{
		int L = std::max(l, r - x), R = std::min(r, l + n - x - 1);
		return L <= R ? col_pre[col][R] - (L ? col_pre[col][L - 1] : 0) : 0;
	};
	for (int i = 0; i <= x; i++)
	{
		for (int j = n - 1; j >= x; j--)
		{
			for (int k = 0; k <= y; k++)
			{
				for (int t = m - 1; t >= y; t--)
				{
					if (j - i < x)
						upd(dp[i][j][k][t], dp[i - 1][j][k][t] + calc_row(i - 1, k, t));
					if (j - i < n - x - 1)
						upd(dp[i][j][k][t], dp[i][j + 1][k][t] + calc_row(j + 1, k, t));
					if (t - k < y)
						upd(dp[i][j][k][t], dp[i][j][k - 1][t] + calc_col(k - 1, i, j));
					if (t - k < m - y - 1)
						upd(dp[i][j][k][t], dp[i][j][k][t + 1] + calc_col(t + 1, i, j));
				}
			}
		}
	}
	printf("%d\n", dp[x][x][y][y]);
	return 0;
}


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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const ll INF = 1e+18;
const ll MOD = 1e+9+7;

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

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

    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 ans = 0;
    while(true)
    {
        if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;
        ans++;
        int s = A, t = B;
        A = B/2+C/2;
        B = s/2+C/2;
        C = s/2+t/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
using namespace std;
const int inf=3e3+9;
ld a[inf],dp[inf][inf];
int n,vis[inf][inf];

ld solve(int pos,int head){

    if(pos==n+1)
        return (head>n/2);

    ld &ret=dp[pos][head];
    if(vis[pos][head])
        return ret;
    vis[pos][head]=1;

    ret=0;
    ret=a[pos]*solve(pos+1,head+1);
    ld x=1.0-a[pos];
    ret+=x*solve(pos+1,head);
    return ret;
}

int main(){


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

    cout<<fixed<<setprecision(10)<<solve(1,0)<<endl;
}


Measured memory_bytes: 175616
from collections import defaultdict
H, W, N = map( int, input().split())
D = defaultdict( int)
def check(t):
    a, b = t
    if a == 0 or a == H-1:
        return False
    if b == 0 or b == W-1:
        return False
    return True
for _ in range(N):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    if a >= 1:
        if b >= 1:
            D[(a-1,b-1)] += 1
        if b < W-1:
            D[(a-1,b+1)] += 1
        D[(a-1,b)] += 1
    if a < H-1:
        if b >= 1:
            D[(a+1,b-1)] += 1
        if b < W-1:
            D[(a+1,b+1)] += 1
        D[(a+1,b)] += 1
    if b >= 1:
        D[(a,b-1)] += 1
    if b < W-1:
        D[(a,b+1)] += 1
    D[(a,b)] += 1
ANS = [0]*10
for c in D:
    if check(c):
        ANS[D[c]] += 1
ANS[0] = (H-2)*(W-2)- sum(ANS)
for ans in ANS:
    print(ans)

Measured memory_bytes: 156628
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){

  int n; cin >> n;
  vector<int> A(n); for (int i=0; i<n; i++) cin >> A[i];
  int swapCount = 0;
  for (int i=0; i<n; i++){
    int minj=i;
    for (int j=i; j<n; j++) if (A[j]<A[minj]) minj=j;
    if (i != minj) {
      swap(A[i],A[minj]);
      swapCount++;
    }
  }

  cout << A[0];
  for (int k=1; k<n; k++) cout << " " << A[k];
  cout << endl << swapCount << endl;

  return 0;
}



Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class CPoll {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        map<string, int> memo;
        int m = 0;
        REP(i, N) {
            string s;
            in >> s;
            memo[s]++;
            m = max(m, memo[s]);
        }
        for (auto x: memo) {
            if (x.second == m) out << x.first << '\n';
        }
	}
};


int main() {
	CPoll solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 25216
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int calcSumOfDigit(int num)
{
    int rem = 0;
    int sum = 0;
    while(num > 0)
    {
        rem = num % 10;
        num /= 10;

        sum += rem;
    }

    return sum;
}

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

    int res=0;
    int first , second, third, fourth, fifth;

    for(int i = A; i <= B; i++)
    {
        first = i % 10;
        second = (i / 10) % 10;
        fourth= (i / 1000) % 10;
        fifth = (i / 10000);
        if(first == fifth && second == fourth)
            res++;
    }

    cout << res <<endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int N;
int A[200001];
 
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  sort(A, A + N, greater<int>());
  
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += A[i / 2];
  }
  
  cout << ans;
}

Measured memory_bytes: 4356
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// セグメント木　学習中
template <class T>
class SegmentTree {
	int n;	// 葉の数
	vector<T> data;	// データを格納するvector
	T def;	// 初期値かつ単位元
	function<T(T, T)> operation; // 区間クエリで使う処理
	function<T(T, T)> update;	// 点更新で使う処理

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def; // 交差しない
		if (a <= l && r <= b)
			return data[k]; // a,l,r,bの順で完全に含まれる
		else {
			return operation(_query(a, b, 2 * k + 1, l, (l + r) / 2), _query(a, b, 2 * k + 2, (l + r) / 2, r));	//左右を分割して再帰
		}
	}

public:
	// _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
	// _update:更新関数
	SegmentTree(size_t _n, T _def, function<T(T, T)> _operation,
		function<T(T, T)> _update)
		: def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	// 場所i(0-indexed)の値をxで更新
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	// [a, b)の区間クエリを実行
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	// 添字でアクセス
	T operator[](int i) {
		return data[i + n - 1];
	}
};

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string N;
	cin >> N;
	ll sum = 0;
	rep(i, 0, N.size()) {
		sum += N[i] - '0';
	}
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000000;
struct edge{
	int to,cost;
};
struct pos{
	int to;
	ll cost;
};
struct pos2{
	int to,from;
	ll cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 1002
ll dp[100001];
ll dp2[100001];
vector<pos> vec[100001];
vector<int> vec2[100001];
int main() {
	int n,k;
	cin>>n>>k;
	n=n/2+n%2;
	if(n>=k){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}





Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=2e5+10;
vector<int> p[N];
int n,m,k,x,y,ps,ans;
inline bool check(int x,int y){
    if(p[x].empty()) return 1;
    vector<int>::iterator it=lower_bound(p[x].begin(),p[x].end(),y);
     return it==p[x].end()||*it!=y;
}
int main(){
    scanf("%d%d%d",&n,&m,&k);ans=n;
    rep(i,1,k) scanf("%d%d",&x,&y),p[y].push_back(x);
    rep(i,1,n) sort(p[i].begin(),p[i].end());
    rep(i,1,n){
        ps++;while(!check(i,ps)) ++ps;
        vector<int>::iterator it=lower_bound(p[i].begin(),p[i].end(),ps);
        if(it!=p[i].end()) ans=min(ans,(*it)-1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 12212
import math
from functools import reduce

def gcd(*numbers):
  return reduce(math.gcd, numbers)

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[abs(a-X) for a in A]
print(gcd(*B))

Measured memory_bytes: 20504
#include <iostream>
#include <cstdio>
using namespace std;
int a, b, k;
int main() {
	cin >> k;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//解答写し（解説動画）
long long calc(long long A){
  long long cnt1=(A+1)/2;
  long long ans=(cnt1+1)%2;
  if((A%2==0))ans^=A;
  return ans;
}
int main() {
  long long A,B;
  cin>>A>>B;
  long long ans=calc(B)^calc(A-1);
  cout<<ans<<endl;   
  return 0;
}

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

fun main(args: Array<String>) = IO().exec {
    val N = int()
    val C = int()
    val D = Array(C){LongArray(C){long()}}
    val c = Array(N){IntArray(N){int()-1}}
    val cost = Array(3){LongArray(C)}
    for (y in 0 until N)
        for (x in 0 until N)
            for (color in 0 until C)
                cost[(y+x)%3][color] += D[c[y][x]][color]
    var ret = 1L.shl(60)
    for (c1 in 0 until C)
        for (c2 in 0 until C) {
            if (c1 == c2) continue
            for (c3 in 0 until C) {
                if (c1 == c3 || c2 == c3) continue
                ret = Math.min(ret, cost[0][c1] + cost[1][c2] + cost[2][c3])
            }
        }
    println(ret)
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

int main() {
int N;
cin>>N;
vector<int> L(N);
for(int i=0;i<N;i++){
    cin>>L.at(i);
}
int ans=0;
for(int i=0;i<N;i++){
    for(int j=1+i;j<N;j++){
        for(int k=1+j;k<N;k++){
            if((L[i]+L[j]>L[k])&&(L[i]+L[k]>L[j])&&(L[k]+L[j]>L[i])&&(L[i]!=L[j])&&(L[i]!=L[k])&&(L[j]!=L[k])){
                ans++;
            }
        }
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 3636
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = test.ConvertIntArray(test.ReadInput());
            var h = n[0];
            var count = 0;
            while (h > 0)
            {
                h -= n[1];
                count++;
            }
            Console.WriteLine(count);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

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

int main()
{
	int ans = 0;
	string s, t; cin >> s >> t;
	for(int i = 0; i < 3; ++i)
	{
		if (s[i] == t[i]) ++ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  int i;
  REP(i,N) cin >> x[i];
  REP(i,M) cin >> y[i];
  x.push_back(X);
  y.push_back(Y);
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x[N] < y[0])cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 0;i < N;i ++) {
			int a = sc.nextInt();
			if(a % 2 != 0) {
				System.out.println("first");
				return;
			}
		}
		System.out.println("second");
	}
}

Measured memory_bytes: 48320
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
 int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>21) cout<<"bust" <<endl;
  else cout<<"win" <<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long int a,b;
    scanf("%ld %ld",&a,&b);


    long int x = a*b;
    long int tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    long int tmp2 = a % b;
    while(tmp2!=0){
        a = b;
        b = tmp2;
        tmp2 = a % b;
    }

    printf("%ld\n",x/b);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	std::ios::sync_with_stdio(false);
	int k,a,b;
	cin>>k>>a>>b;
	bool golf=false;
	for(int t=a;t<=b;t++)
	{
		if(t%k==0){
			golf=true;
			break;
		}
	}
	if(golf==true)
	cout<<"OK\n";
	else
	cout<<"NG\n";
} 

Measured memory_bytes: 3652
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    string ans;
    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else ans = "Sunny";

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define FI "First"
#define SE "Second"
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,sum=0,min_a=10000000000000;
  string ans;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
    min_a = min(min_a,a[i]);
  }
  if(n%2==1){
    if(sum%2!=0){
      ans = FI;
    }else{
      ans = SE;
    }
  }else{
    if(sum%2==1){
      ans = FI;
    }else{
      if(min_a%2==1){
        ans = FI;
      }else{
        ans = SE;
      }
    }
  }
  cout << ans << endl;
}



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

int main() {
  long h,w,ans=9999999999999999;
  cin >> h >> w;
  if(h%3==0||w%3==0) {
    ans=0;
  } else {
    if(w>=3) ans=min(ans,h);
    if(h>=3) ans=min(ans,w);
    for(long i=1;i<h;i++) {
      ans=min(ans,max(w*i,(w+1)/2*(h-i))-min(w*i,w/2*(h-i)));
    }
    for(long i=1;i<w;i++) {
      ans=min(ans,max(h*i,(h+1)/2*(w-i))-min(h*i,h/2*(w-i)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    a = input()
    b = input()
    l = max(len(a), len(b))
    a = a.zfill(l)
    b = b.zfill(l)
    if a > b:
        print('GREATER')
    elif a < b:
        print('LESS')
    else:
        print('EQUAL')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
//typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int M,T,PP,R;
    while(cin>>M>>T>>PP>>R && M){
        vector<int> tim(T,0); //各チームの所用時間
        vector<vector<bool>> solve(T,vector<bool>(PP,false)); //チームごとに各問題が解けたかどうかをboolで
        vector<vector<int>> WA(T,vector<int>(PP,0)); //チームごとに各問題を何回間違えたか
    
        rep(i,0,R){
            int m,t,p,r;
            cin>>m>>t>>p>>r;
            t--; p--; 
            if(r==0){ //正解したら、その時のmを足してとsolveをtrueに
                solve[t][p]=true;  
                tim[t]+=m;   
            }
            else WA[t][p]++; //間違えたらWAを増やす
        }
    
        vector<int> solve_count(T,0); //チームごとに結局何問正解できたか
        //２重forで数えます
        rep(i,0,T){
            rep(j,0,PP){
                if(solve[i][j]){
                    solve_count[i]++;
                    tim[i]+=WA[i][j]*20;   
                }
            }
        }
        vector<pair<int,pair<int,int>>> rank; //いよいよソートします。この配列は３つの値を持ち、<問題数、時間、チーム番号>で格納。
        /*ソート自体は昇順で行いますが、問題数は降順、時間は昇順、チーム番号は降順でソートしたいので、
        降順にしたいものにはマイナスをつけることで対処します。これにより、元の値が大きいほど値が小さくなるのでうまくいきます。
        */
        rep(i,0,T){
            rank.pb(MP(-solve_count[i],MP(tim[i],-(i+1))));
        }
        Sort(rank);
        
        /*rep(i,0,T){
            cout<<rank[i].fi<<" "<<rank[i].se.fi<<" "<<-rank[i].se.se<<endl;
        }*/
        
        //最後に出力です。出力するものはrank[].se.seだけですが、マイナスをつけて格納しているのでマイナスをつけて出力します。
        rep(i,0,T){
            if(i)cout<<",";
            cout<<-rank[i].se.se;
            while(i+1<T && rank[i].fi==rank[i+1].fi && rank[i].se.fi==rank[i+1].se.fi){
                i++;
                cout<<"=";
                cout<<-rank[i].se.se;
            }
        }
        cout<<endl;
    }
    
    return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    reverse(all(a));
    ll mx=0;
    ll mx2=0;
    bool flg=true;
    for (int i = 0; i < n-1; ++i) {
        if(a[i]==a[i+1]){
            if(mx<a[i]&&flg){
                mx=a[i];
                flg=false;
                i++;
            }
            else if(mx2<a[i]&&!flg){
              mx2=a[i];
            }
        }
    }
    cout <<mx*mx2<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin>>N;
    string s[N];
    cout<<0<<endl;
    cin>>s[0];
    if(s[0]=="Vacant"){
        return 0;
    }
    cout<<N-1<<endl;
    cin>>s[N-1];
    if(s[N-1]=="Vacant"){
        return 0;
    }
    int a=0,b=N-1,c=(N-1)/2;
    for(int i=0;i<20;i++){
        cout<<c<<endl;
        cin>>s[c];
        if(s[c]=="Vacant"){
            return 0;
        }
        if((c-a)%2==1&&s[a]==s[c]){
            b=c;
            c=(a+c)/2;
        }else if((c-a)%2==1&&s[a]!=s[c]){
            a=c;
            c=(c+b)/2;
        }else if((c-a)%2==0&&s[a]==s[c]){
            a=c;
            c=(c+b)/2;
        }else{
            b=c;
            c=(a+c)/2;
        }
    }
    
}


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

int main(void)
{
	int n, m, k;
	int a[300000], b[300000];
	int i, ans, k2, an, bn;

	scanf("%d%d%d", &n, &m, &k);

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

	k2 = k;
	an = 0;
	for (i = 0; i < n; i++)
	{
		k2 -= a[i];
		if(k2 >= 0) an++;
		else
		{
			k2 += a[i];
			break;
		}
	}
	bn = 0;
	for (i = 0; i < m; i++)
	{
		k2 -= b[i];
		if(k2 >= 0) bn++;
		else
		{
			k2 += b[i];
			break;
		}
	}
	ans = an + bn;
	for (;;)
	{
		if (an > 0)
		{
			an--;
			k2 += a[an];
		}
		else
		{
			break;
		}

		for (i = bn; i < m; i++)
		{
			k2 -= b[i];
			if(k2 >= 0) bn++;
			else
			{
				k2 += b[i];
				break;
			}
		}
		if (ans < an + bn) ans = an + bn;
	}


	printf("%d\n", ans);

	return 0;
}


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


int main(){
      int s;
      cin >>s;
      int b,c;
      b = s/100;
      c = s%100;
      if(b>0 && b<13){
            if(c>0 && c<13){
                  cout << "AMBIGUOUS";
            }else{
                  cout << "MMYY";
            }
      }else{
            if(c>0 && c<13){
                  cout << "YYMM";
            }else{
                  cout << "NA";
            }
      }
      cout << endl;
      

}

Measured memory_bytes: 256
lis=list(map(int,input().split()))
N ,A, B= lis[0],lis[1],lis[2]

ans = 0
for i in range(1,N+1):
    i1 =  i%10
    i10 = (i%100 -i1)/10
    i100 = (i%1000 -i1 - 10*i10)/100
    i1000 = (i%10000 -i1 - 10*i10-100*i100)/1000
    i10000 = (i -i1 -10*i10 -100*i100 - 1000*i1000)/10000
    if A<=i1+i10+i100+i1000+i10000<=B:
        ans += i
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rr register
#define int long long
#define f_for(i,a,b) for(rr int i=a;i<=b;i++)
using namespace std;
int n,m;
string a,b;
signed main(){
    cin>>a;
    b=a;// 把原来的赋到b上最后比较
    bool t=true;
    int len=a.length()-1;
    for(rr int i=0; i<=len; i++)
        switch(a[i]){
            case 'q': a[i]='p';break;
            case 'p': a[i]='q';break;
            case 'b': a[i]='d';break;
            case 'd': a[i]='b';break;
        }
    for(rr int i=0;i<=len;i++)
        if(a[i]!=b[len-i])
            t=false;//我这里没有翻转，我把它倒过来比较更省时间。
    if(t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;//岛国题。。加回车
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define rep(n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=0; i<n; i++)
const int INF = 2e18;

void solve(){
	
	int x,k,d;cin>>x>>k>>d;
	// cout<<fixed<<setprecision(12);
	x = abs(x);
	if(k < (x/d)) cout<<x-k*d;
    else{
        k -= (x/d);
        x -= (x/d)*d;
        if(k%2) cout<<d-x;
        else cout<<x;
    }
}
	
signed main(){
    fast;    
    // int t;cin>>t;while(t--)
    solve();    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<int> ans;
    if (N == 3) {
        ans.push_back(2); ans.push_back(5); ans.push_back(63);
    } else if (N == 4) {
        ans.push_back(2); ans.push_back(3); ans.push_back(4); ans.push_back(9);
    } else if (N > 15000) {
        for (int i = 1;i < 30000;++i) {
            if (i%2 == 0) ans.push_back(i);
        }
        if (N%2 == 0) ans.push_back(30000);
        for (int i = 1;i <= 30000;++i) {
            if ((int)ans.size() == N) break;
            if (i%2 != 0 && i%3 == 0) {
                ans.push_back(i);
            }
        }
    } else {
        ans.push_back(3); ans.push_back(9);
        int x;
        if (N%3 == 0) x = N - 1;
        else if (N%3 == 1) x = N - 2;
        else x = N;
        for (int i = 1;i <= 30000;++i) {
            if (i%2 == 0) {
                ans.push_back(i);
                if ((int)ans.size() == x) break;
            }
        }
        if (N%3 == 0) ans.push_back(30000);
        else if (N%3 == 1) ans.push_back(30000),ans.push_back(29994);
    }
    rep(i,N) cout << ans[i] << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3752
// https://atcoder.jp/contests/abc179/tasks/abc179_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  ll res = 0;

  rep1(a, N) {
    rep1(b, N) {
      if (a * b >= N) break;
      res++;
    }
  }

  cout << res << "\n";
}


Measured memory_bytes: 3660
import itertools as it
h,w,k = map(int, input().split())
a,b,c,d = [],[],[],[]
for i in range(h):
    a.append(i)
for i in range(1,h+1):
    b += it.combinations(a,i)
for i in range(w):
    c.append(i)
for i in range(1,w+1):
    d += it.combinations(c,i)
board = [str(input()) for i in range(h)]
ans = 0
for i in b:
    for j in d:
        sh = 0
        for m in i:
            for l in j:
                if board[m][l] == '#':
                    sh += 1
        if sh == k:
            ans += 1
print(ans)


Measured memory_bytes: 9212