akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    C = [readline().strip() for _ in range(H)]
    
    ans = 0
    for i in range(2**H):
        for j in range(2**W):
            cnt = 0
            for s in range(H):
                for t in range(W):
                    if (i >> s) & 1 and (j >> t) & 1 and C[s][t] == "#":
                        cnt += 1
            if cnt == K:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N;
    cin>>N;
    vector<int>A(N+2);
    rep(i,0,N) cin>>A[i+1];
    int sum=0;
    rep(i,0,N+2){
      sum+=abs(A[i]-A[i+1]);
    }
    rep(i,0,N){
      int tmp=sum-abs(A[i+1]-A[i])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]);
      cout<<tmp<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#500円玉
A = int(input())
#100円玉
B = int(input())
#50円玉
C = int(input())
#合計金額
X = int(input())
total = 0
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = a*500 + b*100 + c*50
            if(total == X):
                count = count + 1
print(count)
        
   
        

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        int answer = Math.Min(a * n, b);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N, K;
	while(cin >> N >> K){
		vector<long long> A(N), PS(N+1, 0), S(N+1, 0);
		for(int i=0;i<N;i++) cin >> A[i];
		for(int i=0;i<N;i++){
			PS[i+1] = PS[i] + max(0LL, A[i]);
			S[i+1] = S[i] + A[i];
		}
		long long res = 0;
		for(int i=0;i+K<=N;i++){
			res = max(res, PS[i] + PS[N] - PS[i+K] + max(0LL, S[i+K]-S[i]));
		}
		cout << res << endl;
	}
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;

int main()
{
    int k;
    cin >> k;
    queue<ll> q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }

    for (int i = 0; i < k - 1; i++) {
        ll x = q.front();
        q.pop();
        for (ll d = -1; d <= 1; d++) {
            ll y = x % 10 + d;
            if (y < 0 || y > 9)
                continue;
            q.push(10 * x + y);
        }
    }
    ll ans = q.front();
    cout << ans << endl;
}

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



using ll = long long;
const int INF = 1e9+5;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> dp(n+1,INF);
    vector<int> h(n);
    for(int i=0; i<n; i++) cin>>h[i];
    dp[0]=0;
    for(int i=1; i<n; i++){
        for(int j=i-1; j>=i-k; --j){
            if(j<0) break;
            dp[i]=min(dp[j]+abs(h[i]-h[j]), dp[i]);
        }
    }

    cout<<dp[n-1];
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> tpl;

const int MAXN = 1e5 + 10;
const ll inf = 1e18;

int N, M;
ll L[MAXN], R[MAXN], C[MAXN];
ll D[MAXN];
ll F[MAXN];

ll SEG[MAXN * 4], LAZY[MAXN * 4];

void f(int here, int l, int r){
    SEG[here] = min(SEG[here], LAZY[here]);
    if(l != r){
        LAZY[here * 2] = min(LAZY[here * 2], LAZY[here]);
        LAZY[here * 2 + 1] = min(LAZY[here * 2 + 1], LAZY[here]);
    }
    LAZY[here] = inf;
}

void init(int here, int l, int r){
    SEG[here] = inf, LAZY[here] = inf;
    if(l == r) return;
    int mid = (l + r) / 2;
    init(here * 2, l, mid); init(here * 2 + 1, mid + 1, r);
}

void update(int here, int l, int r, int x, int y, ll val){
    f(here, l, r);
    if(y < l || r < x) return ;
    if(x <= l && r <= y) {
        LAZY[here] = val;
        f(here, l, r);
        return;
    }

    int mid = (l + r) / 2;
    update(here * 2, l, mid, x, y, val);    update(here * 2 + 1, mid + 1, r, x, y, val);
    SEG[here] = min(SEG[here * 2], SEG[here * 2 + 1]);
}

ll query(int here, int l, int r, int x, int y){
    f(here, l, r);
    if(y < l || r < x) return inf;
    if(x <= l && r <= y) return SEG[here];
    int mid = (l + r) / 2;
    ll res = query(here * 2, l, mid, x, y);
    res = min(res, query(here * 2 + 1, mid + 1, r, x, y));
    return res;
}

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

    cin >> N >> M;
    for(int i = 1 ; i <= M ; i++) cin >> L[i] >> R[i] >> C[i];

    vector<tpl> V;
    for(int i = 1 ; i <= M ; i++){
        V.push_back(tpl(pll(L[i], R[i]), C[i]));
    }   

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

    init(1, 1, N);
    update(1, 1, N, 1, 1, 0);
    for(auto val : V){
        int l = val.first.first, r = val.first.second;
        ll v = val.second;
        ll b = query(1, 1, N, l, l);
        update(1, 1, N, l, r, b + v);
    }

    ll ans = query(1, 1, N, N, N);
    if(ans == inf) ans = -1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 12912
import math
N= int(input())
mn = 100
ref = 100
for i in range(1,int(math.sqrt(N))+1):
    if N%i == 0:
        #print(i,int(N/i))
        ref = max(len(str(i)),len(str(int(N/i))))
        #print(mn,ref)
        if ref < mn:
            mn = ref
print(mn)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    
     char x,y;
     cin>>x>>y;
     int c=x;
     int d=y;
     if(c>d){
         cout<<">" <<endl;
     }
     else if(c<d){
         cout<<"<" <<endl;
     }
     else
        cout<<"=" <<endl;
        
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

inline int waste(int a, int b, int m) { return (((a % m) + (b % m)) % m); }
inline int worse(int a, int b, int m) { return (((a % m) * (b % m)) % m); }
inline int worst(int a, int b, int m) { return (((a % m) - (b % m) + m) % m);}

using namespace std;

int a[200000];
int b[200000];
int c[200000];
int d[200000];
int n,m,k;
bool check(int val)
{
    int x = -1;
    int y = val-1;
    while(x<=val-1 && y>=-1)
    {
      if(x==-1 && y<m){
        if(d[y]<=k){
          return true;
        }
      }
      if(y==-1 && x<n){
        if(c[x]<=k){
          return true;
        }
      }
        else if((x)>=0 && (y)>=0 && (x)<n && (y)<m){
          if((c[x]+d[y])<=k){
            return true;
          }
        }
        x++;
        y--;
    }
    return false;
}
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   cin >> n >> m >> k;
   for(int i = 0 ; i < n  ; i++){
      cin >> a[i];
   }
   for(int i = 0 ; i < m  ; i++){
      cin >> b[i];
   }
   c[0] = a[0];
   for(int i  = 1; i < n ; i++){
      c[i] = a[i]+c[i-1];
   }

   d[0] = b[0];
   for(int i = 1 ; i<m ; i++){
      d[i] = b[i]+d[i-1];
   }
   int low = 0;
   int high = n+m;
   int ans = 0;
   while(low<=high)
   {
      int mid = (low+high)/2;
      if(check(mid)){
          ans = mid;
          low = mid+1;
      }
      else{
        high = mid-1;
      }
   }
   cout << ans;
}

Measured memory_bytes: 9844
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    long long a[n],b[n];
    f(i,0,n){
        cin>>a[i];
    }
    f(i,0,n){
        cin>>b[i];
    }
    f(i,1,n){
        a[i]+=a[i-1];
    }
    f2(i,n-1,0){
        b[i-1]+=b[i];
    }
    f(i,0,n){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
a, b = map(int, input().split())
if b==1:
    print(0)
else:
    if b >= a:
        if (b - a) % (a - 1) == 0:
            print((b - a) // (a - 1) + 1)
        else:
            print((b - a) // (a - 1) + 1 + 1)
    else:
        print(1)

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

int main()
{
  char s[200000]={};
  int i,j;
  int l_a,l_z;
 
  scanf("%s",s);
  
  int l=strlen(s);
  
  for(i=0;i<l;i++)
  {
    if(s[i]=='A')
    {
     l_a=i;
      break;
    }
  }
  
  for(i=l-1;i>0;i--)
  {
    if(s[i]=='Z')
    {
      l_z=i;
      break;
    }
  }
      
  
  printf("%d\n",l_z-l_a+1);
  
  return 0;
}

Measured memory_bytes: 384
N=int(input())
L=[1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,30,35,40,45,42,48,54,49,56,63,64,72,81]
if N in L:
  print('Yes')
else:
  print('No')

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

int main() {
  int V[9], N, B;
  for (auto &v : V) cin >> v;
  cin >> N;
  while (cin >> B) for (int i = 0; i < 9; i++) if (V[i] == B) V[i] = 0;
  bool b = 0;
  if (!(V[0] + V[3] + V[6]) || !(V[1] + V[4] + V[7]) || !(V[2] + V[5] + V[8]) || !(V[0] + V[1] + V[2]) || !(V[3] + V[4] + V[5]) || !(V[6] + V[7] + V[8]) || !(V[0] + V[4] + V[8]) || !(V[2] + V[4] + V[6])) b = 1;
  cout << ((b) ? "Yes" : "No") << "\n";
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int A,B,C,D;

int main()
{
	cin >> A >> B >> C >> D;
	int ans = max(0,min(B,D) - max(A,C));
	cout << ans << endl;

	return 0;
}


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

int main(void){
    int s;
    cin >> s;
    int cnt=1;
    while(s != 4 && s != 2 && s != 1){
        // cout << s << ' ';
        if(s%2 == 0){
            s = s / 2;
        }else{
            s = (3*s+1);
        }
        cnt++;
    }
    // cout << endl;
    cout << cnt + 3<< endl;
    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef unsigned long long llint;

string a, b;

void run() {
    llint N, M;
    cin >> N >> M;
    cin >> a >> b;
    llint L = N / __gcd(N, M) * M;
    N = L / N, M = L / M;
    llint NM = N / __gcd(N, M) * M;

    for (int k = 0; k < L; k += NM) {
        if (a[k / N] != b[k / M]) {
            cout << -1 << "\n";
            return;
        }
    }

    cout << L << "\n";
}

int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
//    freopen("output", "w", stdout);
    run();
//    fclose(stdout);
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define min(a,b) a > b ? b : a

int pow(int n,int m){
	int sum = 1;
	for(int i = 0;i < m;i++)
		sum *= n;
	return sum;
}

int main(void){
	int y, z, e, m;
	while(1){
		scanf("%d",&e);
		if(e == 0)
			break;
		m = 0x7FFFFFFF;
		for(z = 0;pow(z,3) <= e;z++){
			for(y = 0;pow(y + 1,2) <= e - pow(z,3);y++);
			m = min((z + y + (e - pow(z,3) - pow(y,2))),m);
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

void DFS(int node, vector<int> &color,
  const vector<vector<int>> &adj) {
  
  for (auto &x : adj[node]) {
    if (color[x] != -1) continue;
    color[x] = 3 - color[node];
    DFS(x, color, adj);
  }
}

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

  int n; cin >> n;
  vector<vector<int>> adj(n);
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    for (int j = 0; j < n; ++j) {
      if (s[j] == '1') adj[i].emplace_back(j);
    }
  }
  vector<int> color(n, -1);
  color[0] = 1;
  DFS(0, color, adj);

  for (int i = 0; i < n; ++i) {
    for (int &x : adj[i]) {
      if (color[i] == color[x]) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  int ans = 0;
  for (int st = 0; st < n; ++st) {
    vector<int> q = {st}, level(n, -1);
    level[st] = 0;
    for (int it = 0; it < (int)q.size(); ++it) {
      int node = q[it];
      for (int &x : adj[node]) {
        if (level[x] == -1) {
          level[x] = level[node] + 1;
          q.emplace_back(x);
        }
      }
    }
    ans = max(ans, *max_element(level.begin(), level.end()));
  }
  cout << 1 + ans << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int i,ss=0,tt=0,e=0;
  char s[1000],t[1000];
  scanf("%s",s);
  scanf("%s",t);
  for(i=0;i<=11;i++){
    if(s[i]=='\0'){
      ss=i;
      break;
    }
    if(i==11){e=1;}
  }
  for(i=0;i<=11;i++){
    if(t[i]=='\0'){
      tt=i;
      break;
    }
    if(i==11){e=1;}
  }
  if(ss+1==tt){
    for(i=0;i<ss;i++){
      if(s[i]!=t[i]){e=1;}
    }
  }else{e=1;}
  if(e==0){printf("Yes\n");}
  else{printf("No\n");}
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	io;
	ll n;
	cin>>n;
	vector<ll>v(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	sort(v.rbegin(),v.rend());
	ll s=0;
	s+=v[0];
	ll idx=1,cnt=0;
	for(ll i=2;i<n;i++){
		s+=v[idx];
		cnt++;
		if(cnt==2){
			cnt=0;
			idx++;
		}
	}cout<<s;
	return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b,c;
  cin >> a >> b;
  
  if((0 <= a) && (a <= 5)){
    c = 0;
  } 
  else if ((6 <= a) && (a <= 12)){
    c = b /2;
  }
  else {
    c = b;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x; cin >> x;
    x--;
    cout << (x / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b,c,d; cin >> a >>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    string s,t; cin>>s>>t;

    ll ans = 0;

    for(ll i=0;i<3;i++) if(s[i] == t[i]) ans++;

    cout<<ans<<endl;
} 
 
signed main(){
 
   FastRead;    
 
 
    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;

void solve(std::string s, long long K) {
    set<string> ss;
    for(int i = 0; i < s.size(); i++) {
        string t;
        for(int j = i, k = 0; j < s.size() and k <= K; j++, k++) {
            t += s[j];
            ss.insert(t);
            while(ss.size() > K) {
                ss.erase(--ss.end());
            }
        }
    }
    cout << *ss.rbegin() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    std::string s;
    std::cin >> s;
    long long K;
    scanf("%lld",&K);
    solve(s, K);
    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  string s;
  cin >> s;
  if ((int)size(s) <= k) {
    cout << s << '\n';
  } else {
    cout << s.substr(0, k) + "...\n";
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kansu(string t,string u){
  int ans=0;
  for(char c='a';c<='z';c++){
    bool is_t=false,is_u=false;
    for(int i=0;i<t.size();i++){
      if(t.at(i)==c){
        is_t=true;
      }
    }
    for(int i=0;i<u.size();i++){
      if(u.at(i)==c){
        is_u=true;
      }
    }
    if(is_t && is_u){
      ans++;
    }
  }
  return ans;
}
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,n-1){
    int p;
    string t,u;
    t=s.substr(0,i);
    u=s.substr(i);
    p=kansu(t,u);
    ans=max(ans,p);
  }
  cout << ans;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<bool> used(n+1,false);
  vector<int> rseq(n);
  REP(i,n) rseq[i]=n-i;
  REP(i,m){
    int tmp;
    cin >> tmp;
    rseq.push_back(tmp);
  }
  for(int i=n+m-1;i>=0;--i)
    if(!used[rseq[i]]){
      used[rseq[i]]=true;
      cout << rseq[i] << endl;
    }
  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
int cnt = 0;
Vi v(10);
bool f = false;

void dfs(int depth) {
    if (depth == 10) {
        if (cnt == n) {
            ll sum = 0;
            REP(i, 10) {
                sum += pow(10LL, 9-i) * v[i];
            }
            cout << sum << '\n';
            f = true;
        } else cnt++;
        return;
    }
    bool isLeadZero = true;
    REP(i, depth) {
        isLeadZero &= v[i] == 0;
    }
    if (isLeadZero) {
        REP(i, 10) {
            v[depth] = i;
            dfs(depth+1);
            if (f) break;
        }
        return;
    }
    REP2(i, max(0, v[depth-1]-1), min(10, v[depth-1]+2)) {
        v[depth] = i;
        dfs(depth+1);
        if (f) break;
    }
}

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

    return 0;
}


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

using namespace std;

int main()
{
	int n,x;
	cin>>n>>x;
	int count=0;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	long long sum=0;
	int i;
	for(i=0;i<n;i++)
{
		sum+=a[i];
		
		if(sum>x)
			break;
		}
	if(sum<x)
		i-=1;
	cout<<i<<endl;
	
	
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n, k;
  cin >> n >> k;
  int ans = ((n-1)+(k-2)) / (k-1);
  cout << ans << endl;

}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    sx, sy, tx, ty = list(map(int, readline().split()))

    xdif = tx - sx
    ydif = ty - sy

    res = ""

    res += "U" * ydif
    res += "R" * xdif
    res += "D" * ydif
    res += "L" * xdif

    res += "L"
    res += "U" * (ydif + 1)
    res += "R" * (xdif + 1)
    res += "D"
    res += "R"
    res += "D" * (ydif + 1)
    res += "L" * (xdif + 1)
    res += "U"

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
Ali=0
Bob=0
a.sort()
ab_flag=0
while len(a)!=0:
    if ab_flag==0:
        Ali += a.pop()
        ab_flag=1
    else:
        Bob += a.pop()
        ab_flag=0
print(Ali-Bob)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N,K;
	string S;
	cin >> N >> K >> S;
	int rec = 0;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			rec++;
		}
	}
	rec += 2 * K;
	if (rec < S.length()) {
		cout << rec << endl;
	}
	else {
		cout << S.length() - 1 << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<string, P> PSP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n, q;
  while(cin >> n >> q, n | q) {
    vector<PSP> v(n);
    rep(i, n) {
      cin >> v[i].fi;
      int tmp;
      cin >> tmp >> v[i].se.se;
      v[i].se.fi = v[i].se.se - tmp + 1;
    }

    rep(i, q) {
      int y;
      cin >> y;
      string ans = "Unknown";
      rep(i, n) {
        if (v[i].se.fi <= y && y <= v[i].se.se) {
          ans = v[i].fi + " " + to_string(y - v[i].se.fi + 1);
          break;
        }
      }
      cout << ans << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
using namespace std;
 
/*
It's been a long day without you, my friend
And I'll tell you all about it when I see you again
We've come a long way from where we began
Oh I'll tell you all about it when I see you again
When I see you again
When I see you again
*/
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;
 
const int mod = 1e9+7;
 
int sod(int n){int sum =0;while(n > 0){sum += n %10;n /= 10;}return sum;}
 
int dig(int n){if(n==0) return 1;int cnt =0;while(n > 0){n /= 10;cnt++;}return cnt;}
 
int divs(int n){int cnt = 0;for(int x=1;x*x<=n;x++){if(n % x == 0){cnt++;if(n/x != x)cnt++;}}return cnt;}
 
int isprime(int n){if(n < 2)return false;for(int x=2;x*x<=n;x++)if(n % x == 0) return false;return true;}
 
int power(int x,unsigned int y,int p=mod) {int res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
 
const int inf = 1e18;

bool pal(string s){int l = 0 , r = s.size()-1;while(l < r){if(s[l++] != s[r--])return false;}return true;}



int32_t main(){
    FAST;

    int n;  cin >> n;

    for(int x=1;x*x<=n;x++){
        if(n % x == 0){
            int fi = x;
            int se = n / x;

            if(fi <= 9 and se <= 9){
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";

    return 0;
}
 
 
 
// const int N = 1e6;
// bool prime[N+3];
// void sieve(){
 
//   memset(prime , true , sizeof prime );
 
//   prime[0] = false , prime[1] = false;
//   prime[2] = true;
 
//   for(int x=2;x*x<=N;x++){
//     if(prime[x] == true){
//       for(int i=x*x;i<=N;i+=x)
//         prime[i] = false;
//     }
//   }
 
// } 


// const int N = 1e6+50;
// int spf[N+11];
 
// void SPF(){
 
// 	spf[1] = 1; 
  
//     for (int i = 2; i <= N; i++) 
//     { 
//         if (spf[i] == 0) 
//         { 
//             spf[i] = i; 
  
//             for (int j = 2*i; j <= N; j += i) 
//                 if (spf[j] == 0) 
//                    spf[j] = i; 
//         } 
//     } 
// }
 

Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

typedef	long long	ll;

int main(){
	int n;	scanf("%d",&n);
	int a[100];
	rep(i,n)	scanf("%d",a+i);

	ll dp[99][21]={};
	dp[0][a[0]]=1;
	for(int i=1;i<n-1;i++){
		rep(j,21){
			if(j+a[i]<=20)	dp[i][j+a[i]]+=dp[i-1][j];
			if(j-a[i]>=0)	dp[i][j-a[i]]+=dp[i-1][j];
		}
	}

	printf("%lld\n",dp[n-2][a[n-1]]);

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    
    Double[] v = new Double[n];
    List<Double> gu = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      v[i] = sc.nextDouble();
      gu.add(v[i]);
    }

    for (int i = 0; i < n - 1; i++) {
      Collections.sort(gu);
      double a = (gu.get(0) + gu.get(1)) / 2;
      gu.add(a);
      gu.remove(0);
      gu.remove(0);
    }
    
    System.out.println(gu.get(0));
    
  }
}


Measured memory_bytes: 25284
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {

    int k, s;
    cin >> k >> s;

    int cnt = 0;

    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {

            int z = s - x - y;
            if (0 <= z && z <= k)
                cnt++;

        }
    }

    cout << cnt << endl;

    return 0;    

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
	int a;
	int b;
	
	scanf("%d %d",&a,&b);
	getchar();
	
	if(a==2 && b==1||a==1 && b==2){
		printf("3");
	}
		else if(a==2 && b==3||a==3 && b==2){
		printf("1");
	}
			else if(a==3 && b==1||a==1 && b==3){
		printf("2");
	}
	return 0;
}

Measured memory_bytes: 2964
import numpy as np
n,k=map(int,input().split())
X=list(map(int,input().split()))
X=np.array(X)
m=abs(X[:n-k+1])+abs(X[:n-k+1]-X[k-1:])
p=abs(X[k-1:])+abs(X[k-1:]-X[:n-k+1])
ans=np.min(np.minimum(p,m))
print(ans)   

Measured memory_bytes: 23108
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

ans = int(math.floor(float(b)/float(a)))

if ans > c:
    ans = c

print(ans)

Measured memory_bytes: 38384
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int x, t;
    cin >> x >> t;

    cout << max(0, x - t) << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int leap(int x){
  if(x % 400 == 0)return 1;
  if(x % 100 == 0)return 0;
  if(x % 4 == 0)return 1;
  return 0;
}

int main(){
  int a, b, num, i, first = 1;
  while(1){
    scanf("%d%d", &a, &b);
    if(a == 0 && b == 0)return 0;
    if(!first)puts("");
    first = 0;
    num = 0;
    for(i = a;i <= b;i++){
      if(leap(i)){
	printf("%d\n", i);
	num++;
      }
    }
    if(num == 0)puts("NA");
  }
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
   //string a,b,c;
   stack<char>aa,bb,cc;
   string a,b,c;
   cin>>a>>b>>c;
   int len1=a.size();
   int len2=b.size();
   int len3=c.size();
   for(int i=len1-1;i>=0;i--)
   {
       aa.push(a[i]);
   }
   for(int i=len2-1;i>=0;i--)
   {
       bb.push(b[i]);
   }
   for(int i=len3-1;i>=0;i--)
   {
       cc.push(c[i]);
   }
   char ccc=aa.top();
   while(1)
   {
       //cout<<ccc<<" ";

       if(ccc=='a')
       {
           if(aa.empty())
           {
             cout<<"A";
             break;
          }
           ccc=aa.top();
           aa.pop();
       }
       else if(ccc=='b')
       {
           if(bb.empty())
           {
             cout<<"B";
             break;
           }
           ccc=bb.top();
           bb.pop();
       }
       else if(ccc=='c')
       {
            if(cc.empty())
           {
             cout<<"C";
              break;
           }
           ccc=cc.top();
           cc.pop();
       }

   }
}


Measured memory_bytes: 5968
#include <cstdio>
using namespace std;
  
int a[4];
int c[8];
int k;
  
int calc(){
    int op = c[k++];
    int ret = 0;
    if(op >= 0){
        ret = op;
    }
    else if(op >= -3){
        int x = calc();
        int y = calc();
        if(op == -1){
            ret = x + y;
        }
        else if(op == -2){
            ret = x - y;
        }
        else{
            ret = x * y;
        }
    }
    else{
        throw 0;
    }
    return ret;
}
  
void print(){
    int op = c[k++];
    if(op >= 0){
        printf("%d", op);
    }
    else{
        char ch;
        if(op == -1){ ch = '+'; }
        else if(op == -2){ ch = '-'; }
        else{ ch = '*'; }
  
        putchar('(');
        print();
        printf(" %c ", ch);
        print();
        putchar(')');
    }
}

const int bnum = 30;
  
void solve(int i, int S, int oprem, int numrem){
    if(i == 6){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[6] = a[j];
            }
        }
        try{
            k = 0;
            if(calc() == 10 && k == 7){
                k = 0;
for(int j=0;j<bnum;++j)putchar('(');
                print();
for(int j=0;j<bnum;++j)putchar(')');
                puts("");
                throw "";
            }
        }catch(int){}
        return;
    }
  
    if(oprem > 0){
        for(int op = -1; op >= -3; --op){
            c[i] = op;
            solve(i + 1, S, oprem - 1, numrem + 1);
        }
    }
  
    if(numrem > 0){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[i] = a[j];
                solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
            }
        }
    }
}
  
int main(){
    while(1){
        for(int i = 0; i < 8; ++i){
            c[i] = -9;
        }
        for(int i = 0; i < 4; ++i){
            scanf("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
        try{
            solve(0, 15, 3, 0);
            puts("0");
        }catch(...){}
    }
}

Measured memory_bytes: 1128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

int h, w, ans = 0;
int map[1405][1405];

int main(){
	std::cin >> h >> w;
	rep(i, h){
		rep(j, w)std::cin >> map[i][j], map[i][j] = (1 - map[i][j]);
		map[i][w] = 0;
	}

	rep(i, w){
		REP(j, 1, h)map[j][i] = (map[j][i] == 0 ? 0 : map[j - 1][i] + 1);
	}

	rep(i, h){
		int max = 0;
		std::stack<P> s;
		rep(j, w + 1){
			if (s.empty() || s.top().first < map[i][j])s.push(P(map[i][j], j));
			else if (s.top().first > map[i][j]){
				int pos = j;
				while (s.size() && s.top().first >= map[i][j]){
					P p = s.top(); s.pop();
					max = std::max(max, p.first * (j - p.second));
					pos = p.second;
				}
				s.push(P(map[i][j], pos));
			}
		}
		ans = std::max(max, ans);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 8888
import sys

fin = sys.stdin.readline
N, X = [int(elem) for elem in fin().split()]
l_list = [int(elem) for elem in fin().split()]

count = 1
current_d = 0
for l in l_list:
    current_d += l
    if current_d > X:
        break
    count += 1
print(count)


Measured memory_bytes: 38384
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2182
// dp[i][j] := A(i,j)
// dp[i][j] = (n*10+s mod 11 = (n mod 11)*10+s)
// 10 = 10, 20 = 9, 30 = 8, 40 = 7, ... 100 = 1
#include <bits/stdc++.h>
using namespace std;
int dp[80000][11];
string num;
int main() {
    while(cin>>num && num!="0") {
        memset(dp, 0, sizeof(dp));
        dp[0][num[0]-'0'] = 1;
        int res = dp[0][0];
        for (int i=1; i<num.length(); i++) {
            if (num[i]!='0') dp[i][num[i]-'0'] = 1;
            for (int j=0; j<11; j++) {
                // printf("%d %d\n",(j*10+int(num[i]-'0'))%11,int(num[i]-'0'));
                dp[i][(j*10+int(num[i]-'0'))%11] += dp[i-1][j];
            }
            res += dp[i][0];
        }
        // for (int i=0; i<num.length(); i++) {
        //     for (int j=0; j<11; j++) printf("%d ",dp[i][j]);
        //     puts("");
        // }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

bool kaibun(ll m){
  bool ret = true;

  if((m / 10000) != (m % 10)) ret = false;
  if(((m % 10000) / 1000) != ((m % 100) / 10)) ret = false;

  return ret;
}

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

  ll cnt = 0;

  rep2(i, A, B + 1){
    if(kaibun(i)) cnt++;
  }

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


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

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

    long long a[h][w];

    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    long long x = 0, y = 0;
    vector<long long> pre_x;
    vector<long long> pre_y;
    vector<long long> next_x;
    vector<long long> next_y;
    long long count = 0;

    while(count < h*w-1){
    
        if(y % 2 == 0){
            if(a[y][x] % 2 != 0){
                pre_x.push_back(x);
                pre_y.push_back(y);
                a[y][x]--;
                if(x + 1 < w){
                    //printf("a\n");
                    a[y][x + 1]++;
                    next_x.push_back(x + 1);
                    next_y.push_back(y);
                }
                else if(y + 1 < h){
                    //printf("b\n");
                    a[y + 1][x]++;
                    next_x.push_back(x);
                    next_y.push_back(y + 1);
                }
            }

            if(x + 1 < w){
                x++;
            }
            else if(y + 1 < h){
                y++;
            }
        }
        else{
            if(a[y][x] % 2 != 0){
                pre_x.push_back(x);
                pre_y.push_back(y);
                a[y][x]--;
                if(x - 1 >= 0){
                    //printf("c\n");
                    a[y][x - 1]++;
                    next_x.push_back(x - 1);
                    next_y.push_back(y);
                }
                else if(y + 1 < h){
                    //printf("c\n");
                    a[y + 1][x]++;
                    next_x.push_back(x);
                    next_y.push_back(y + 1);
                }
            }
            if(x - 1 >= 0){
                x--;
            }
            else if(y + 1 < h){
                y++;
            }
        }
        count++;
    }

    cout << pre_x.size() << endl;

    for(long long i = 0; i < pre_x.size(); i++){
        printf("%lld %lld %lld %lld\n", pre_y[i]+1, pre_x[i]+1, next_y[i]+1, next_x[i]+1);
    }
    return 0;
}

Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        int t=0;
        while(a && a%2==0){
            a /=2;
            t++;
        }
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

P solve() {
    int l = s.size();
    for (int i = 0; i < l-1; i++) {
        if (s[i] == s[i+1])
            return make_pair(i+1, i+2);
    }

    for (int i = 0; i < l-2; i++) {
        if (s[i] == s[i+2])
            return make_pair(i+1, i+3);
    }

    return make_pair(-1, -1);
}

void input() {
    cin >> s;
}

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

    input();
    P res = solve();
    cout << res.first << " " << res.second << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N;  cin >> N;
    vector<int> h(N);  rep(i, N) cin >> h[i];

    int ans = 0;
    for (int l=0; l<N; ++l) {
        while (h[l] > 0) {
            int r;
            for (r=l+1; r<N; ++r) {
                if (h[r] == 0) break;
            }
            for (int x = l; x < r; ++x) --h[x];
            ++ans;
        }
    }

    print(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int[][] a;
	static ArrayList<String> ans = new ArrayList<>();
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int h = scanner.nextInt();
		final int w = scanner.nextInt();
		a = new int[h][w];
		for (int r=0; r<h; r++){
			for (int c=0; c<w; c++){
				a[r][c] = scanner.nextInt();
			}
		}
		for(int r=0; r<h; r++){
			for (int c=0; c<w; c++){
				int now = a[r][c];
				if(now%2==1){
					int right;
					int down;
					boolean rightEven = true;
					boolean downEven = true;
					if (c!=w-1) {
						right=a[r][c+1];
						rightEven = right%2==0;
					}
					if (r!=h-1) {
						down=a[r+1][c];
						downEven = down%2==0;
					}
					if(rightEven && downEven) {
						if (c!=w-1) move(r,c,r,c+1);	//toRight
						else if (r!=h-1) move(r,c,r+1,c);	//toDown
					}else if (!rightEven) move(r,c,r,c+1);	//toRight
					else move(r,c,r+1,c);	//toDown
				}
			}
		}
		System.out.println(ans.size());
		ans.forEach(System.out::println);
	}

	static void move(int y, int x, int y_, int x_){
		ans.add((y+1)+" "+(x+1)+" "+(y_+1)+" "+(x_+1));
		a[y][x]--;
		a[y_][x_]++;
	}
}

Measured memory_bytes: 98832
#include<iostream>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int snuke[110] = {0};
	while (K--) {
		int d;
		cin >> d;
		while (d--) {
			int su;
			cin >> su;
			snuke[su] = 1;
		}
	}
	int cnt = 0;
	for(int i=1;i<=N;i++){
		if (snuke[i] == 0)cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3640