akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,k,*a = map(int,read().split())

a = [i for i in a if i<k]
n = len(a)

a.sort(reverse=True)

K = 2*k+1
mask = (1<<K)-1

dpl = [1]
dp = 1
for i in a:
    dp |= (dp<<i)&mask
    dpl.append(dp)

#print(dpl)
for i in range(n):
    x = dpl[n-1-i]<<a[n-1-i]
    mask = ((1<<a[n-1-i])-1)<<(k)
    #print(bin(x)[::-1])
    #print(bin(mask)[::-1])
    if x&mask:
        print(i)
        break
else: print(n)



Measured memory_bytes: 75416
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

struct node {
    int p = -1;
    int d;
    vector<int> c;
};

void dfs(int s, vector<node> &v, vector<bool> &seen, int depth) {
    seen[s] = true;
    v[s].d = depth;
    rep(i, v[s].c.size()) {
        int next = v[s].c[i];
        if (seen[next])
            continue;
        dfs(next, v, seen, depth + 1);
    }
}

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

    int N;
    cin >> N;
    vector<node> v(N);
    int s = 0;
    rep(i, N) {
        int id, k;
        cin >> id >> k;
        rep(j, k) {
            int a;
            cin >> a;
            v[id].c.push_back(a);
            v[a].p = id;
        }
    }

    rep(i, N) {
        if (v[i].p == -1) {
            s = i;
            break;
        }
    }

    vector<bool> seen(N, false);
    int depth = 0;
    dfs(s, v, seen, depth);

    rep(i, N) {
        cout << "node"
             << " " << i << ":"
             << " ";
        cout << "parent = " << v[i].p << ","
             << " ";
        cout << "depth = " << v[i].d << ","
             << " ";
        if (i == s) {
            cout << "root, [";
            if (v[i].c.empty()) {
                cout << "]";
            } else {
                rep(j, v[i].c.size() - 1) { cout << v[i].c[j] << ", "; }
                cout << v[i].c.back() << "]";
            }

        } else if (v[i].c.size() == 0) {
            cout << "leaf, [";
            if (v[i].c.empty()) {
                cout << "]";
            } else {
                rep(j, v[i].c.size() - 1) { cout << v[i].c[j] << ", "; }
                cout << v[i].c.back() << "]";
            }
        } else {
            cout << "internal node, [";
            if (v[i].c.empty()) {
                cout << "]";
            } else {
                rep(j, v[i].c.size() - 1) { cout << v[i].c[j] << ", "; }
                cout << v[i].c.back() << "]";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 6676
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
typedef pair<long long int, long long int> ii;
typedef vector<long long int> vi;
typedef vector<ii> vii;
// #define INF 1000000000000000
       
#define endl '\n'
#define MOD 1000000007
// #define INF 1ll<<30
long long int inf =  100000000000000000;
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif  
    long long int q,h,s,d;
    cin>>q>>h>>s>>d;
    long long int n;
    cin>>n;
    if(n==1)
    {
        long long int mn = min(4*q,min(2*h,s));
        long long int ans = mn*n;
        cout<<ans<<endl;
    }
    else
    {
        long long int mn = min(4*q,min(2*h,s));
        if(2*mn<=d)
        {
            long long int ans = mn*n;
            cout<<ans<<endl;
        }
        else
        {
            if(n%2!=0)
            {
                long long int ans = mn+(n/2)*d;
                cout<<ans<<endl;
            }
            else
            {
                long long int ans = (n/2)*d;
                cout<<ans<<endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int team[101],num=0,point,lank[101],co=0,flag=0;
    queue<int> que;
    string str;
    for(int i=1;i<101;i++)team[i]=-1;
    while(cin>>str){
        if(str[0]=='0'&&str[2]=='0')break;
        for(int i=0;;i++){
            if(str[i]==','){
                for(int j=0;j<i;j++)num+=(str[j]-'0')*(int)pow(10,i-j-1);
                team[num]=0;
                point=i;
            }
            else if(str[i]=='\0'){
                for(int j=point+1;j<i;j++)team[num]+=(str[j]-'0')*pow(10,i-j-1);
                break;
            }
        }
        num=0;
    }
    point=0;
    for(int i=1;flag!=1;i++){
        flag=1;
        for(int j=1;j<101;j++){
            if(point<team[j]){
                flag=0;
                point=team[j];
                if(co!=0){
                    for(int k=0;k<co;k++)que.pop();

                }
            co=1;
            que.push(j);
            }
            else if(point==team[j]){
                    flag=0;
                    que.push(j);
                    co++;
            }
        }
        for(int j=0;j<co;j++){
            lank[que.front()]=i;
            team[que.front()]=-1;
            que.pop();
        }
        point=0;co=0;
    }
    while(cin>>num)cout<<lank[num]<<endl;

}

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

using namespace std;

#define loop(n) for(int lp=0; lp<(n); lp++)
#define ascent(i, a, b)  for(int (i)=(a); (i)<(b); (i)++)
#define descent(i, a, b) for(int (i)=(a); (i)<(b); (i)--)

int w, h;

int flg[60][60];
int m[60][60];

//int dx[4] = {-1, 0, 1, 0};
//int dy[4] = {0, 1, 0, -1};

stack<pair<int, int> > land;
void island(int x, int y) {
  if(x < 0 || w <= x || y < 0 || h <= y) return;

  land.push(make_pair(x, y));

  while(!land.empty()) {
    pair<int, int> p = land.top(); land.pop();

    int _x = p.first;
    int _y = p.second;
    //cout << " " << _x << "," << y << endl;

    if(m[_y][_x]) {
      //     cout << " " << x << "," << y << " is island" << endl;
      flg[_y][_x] = 1;
    }

    for(int dx = -1; dx <= 1; dx ++) {
      for(int dy = -1; dy <= 1; dy ++) {
	if(dx == 0 && dy == 0) continue;
	if(!flg[_y+dy][_x+dx] && 0 <= _x+dx && _x+dx < w && 0 <= _y+dy && _y+dy < h) {
	  //	    cout << "  " << _x+dx << "," << _y+dy << endl;
	  if(m[_y+dy][_x+dx]) {
	    land.push(make_pair(_x+dx, _y+dy));
	  }
	}
      }
    }
  }
}

int bfs() {
  int ans = 0;
  //  flg[0][0] = 1;

  ascent(y, 0, h) {
    ascent(x, 0, w) {
      if(!flg[y][x]) {
	flg[y][x] = 1;
	if(m[y][x]) {
	  ans ++;
	  //	  cout << " " << x << "," << y << endl;
	  island(x, y);
	}
      }
    }
  }

  return ans;
}

int main() {
  while(cin >> w >> h, w) {
    ascent(i, 0, h) {
      ascent(j, 0, w) {
	cin >> m[i][j];
	flg[i][j] = 0;
      }
    }

    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

int main()
{
    int N, M, t, x, y;   cin >> N >> M;
    long long ans;
    vector<long long> a(N), c(31,0);
    for(int i=0; i<N; i++)  cin >> a[i];
    sort(a.begin(),a.end(),greater<long long>());
    for(int i=30; i>=0; i--){
        for(int j=0; j<N; j++){
            if(a[j] >= pow(2,i))    c[30-i]++;
        }
    }
    t = 0;
    ans = 0;
    for(int i=0; i<=30; i++){
        x = c[i];
        for(int j=0; j<x; j++){
            a[j] /= 2;
            if(t + j >= M-1){
                for(int k=0; k<N; k++)  ans += a[k];
                cout << ans;
                return 0;
            }
        }
        t += x;
        if(i < 30) sort(a.begin(),a.begin()+c[i+1],greater<long long>());
    }
    for(int i=0; i<N; i++)  ans += a[i];
    cout << ans;
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int a[5];
int main(){
    rep(i, 5) cin >> a[i];
    int ans =0;
    rep(i, 5) ans+=int(ceil(a[i]/10.0)*10);
    int mx = 0;
    rep(i, 5) chmax(mx, int(ceil(a[i]/10.0)*10) - a[i]);
    cout << ans - mx<< endl;
}



Measured memory_bytes: 888
//by Top
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 111;
     
using namespace std;

int n, q, k, dp[404][404], a[maxn], pref[maxn];
bool was[404][404];

int get(int l, int r){
	return pref[r] - pref[l - 1];
}

int rec(int l, int r){
	if (was[l][r])
		return dp[l][r];
	if (r == l)
		return 0;
	if (r - l == 1)
		return dp[l][r] = get(l, r);
	was[l][r] = true;
	int sum = inf;
	for (int x = l; x < r; x++)
		sum = min(sum, rec(l, x) + rec(x + 1, r));
	dp[l][r] = sum + get(l, r);
	return dp[l][r];	
}

void solve(){
	cin >> n;

	for (int i = 1; i <= n; i++){
		cin >> a[i];
		pref[i] += pref[i - 1] + a[i];
	}
	
	cout << rec(1, n);
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>

using namespace std;

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

int main () {
    // N
    // A_1 ...... A_N
    int N, M;
    cin >> N >> M;
    vi vec(M);
    int res = 0;
    for (auto& v: vec) {
        cin >> v;
        res += v;
    }
    if (N - res < 0) {
        std::cout << -1 << endl;
        return 0;
    }
    std::cout << N - res << endl;
    return 0;
}

Measured memory_bytes: 3200
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		int h = sc.nextInt();
		int w = sc.nextInt();

		int[][] map = new int[h][w];

		List<String> ans = new ArrayList<>();

		boolean isBeforeOneEven = true;
		boolean isBeforeRowEven = true;

		boolean isLast = false;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {

				int tmp = sc.nextInt();

				map[i][j] = tmp;

				// System.out.println("tmp: " + tmp);

				if (!isBeforeOneEven)
					tmp++;

				if (j + 1 == w) {
					isLast = true;
					if (!isBeforeRowEven)
						tmp++;
				}

				if (tmp % 2 == 0) {
					// System.out.println("even: " + tmp);
					isBeforeOneEven = true;
				} else {

					if (j + 1 == w) {
						if (i + 1 == h) {
							// System.out.println("last");
						} else {
							String str = (i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1);
							ans.add(str);
							// System.out.println("odd end: " + str);
						}
					} else {
						String str = (i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2);
						ans.add(str);
						// System.out.println("odd not end: " + str);
					}

					isBeforeOneEven = false;
				}
				if (isLast) {
					isBeforeRowEven = isBeforeOneEven;
					isBeforeOneEven = true;
					isLast = false;
				}
			}
		}

		Integer size = ans.size();
		ans.add(0, size.toString());

		ans.forEach(s -> System.out.println(s));
	}
}


Measured memory_bytes: 100220
# Porblem D - Gathering Children
import re

# input process
S = input()

# initialization
ans_list = []
in_list = re.findall(r"R+L+", S)

# ["RRL", "RL"]
# part of list process
for p in in_list:
    p_r = re.findall(r"R+", p)[0]
    p_l = re.findall(r"L+", p)[0]
    l_count = 0
    r_count = 0

    # R to L process
    for i in range(1, len(p_r)+1):
        if i%2==0:
            l_count = l_count + 1
        else:
            r_count = r_count + 1

    # L to R process
    for i in range(1, len(p_l)+1):
        if i%2==0:
            r_count = r_count + 1
        else:
            l_count = l_count + 1

    # output prcess R
    for i in range(len(p_r)-1):
        ans_list.append(0)
    ans_list.append(r_count)

    # output process L
    ans_list.append(l_count)
    for i in range(len(p_l)-1):
        ans_list.append(0)

# output process
for a in ans_list:
    print(a, end=" ")


Measured memory_bytes: 62172
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  int w[n]; for(int i = 0; i < n; i++) cin >> w[i];
  int s = 0;
  for(int i = 0; i < n; i++){
    s += w[i];
  }
  int s1 = 0, s2, z, minz = 10000000;
  for(int i = 0; i < n; i++){
    s1 += w[i];
    s2 = s - s1;
    if(s1 - s2 > 0) z = s1 - s2;
    else z = s2 - s1;
    minz = min(z, minz);
  }
  cout << minz << endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = "APPROVED"
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            ans = "DENIED"
            break

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<ll> red(A), green(B), normal(C);

    for (int i = 0; i < A; i++)
        cin >> red[i];

    for (int i = 0; i < B; i++)
        cin >> green[i];

    for (int i = 0; i < C; i++)
        cin >> normal[i];

    sort(red.begin(), red.end(), greater<ll>());
    sort(green.begin(), green.end(), greater<ll>());
    sort(normal.begin(), normal.end(), greater<ll>());

    priority_queue<ll, vector<ll>, greater<ll>> q;

    
    for (int i = 0; i < X; i++)
        q.push(red[i]);

    for (int i = 0; i < Y; i++)
       q.push(green[i]);

    for (int i = 0; i < C; i++) {
        if (normal[i] >= q.top()) {
            q.pop();
            q.push(normal[i]);
        }
        else break;
    }

    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 4724
h,w=map(int,input().split())
if h*w%3==0:
  print(0)
else:
  ans=min(h,w)
  hh=h//2
  for ww in range(1,w):
    A=[hh*ww,(h-hh)*ww,h*(w-ww)]
    ans=min(ans,max(A)-min(A))
  ww=w//2
  for hh in range(1,h):
    B=[ww*hh,(w-ww)*hh,(h-hh)*w]
    ans=min(ans,max(B)-min(B))
  print(ans)

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n){cin >> a.at(i);}

  int odd = 0;
  rep(i,n){
    if(a.at(i) % 2 == 1) odd++;
  }

  if(odd % 2 == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 640
s=list(input())
t=list(input())
f=0
for i in range(len(s)-len(t),-1,-1):
  l=[]
  for j in range(len(t)):
    if s[i+j]=='?':l.append(t[j])
    else:l.append(s[i+j])
  if ''.join(t)==''.join(l):
    if f==0:
      for m in range(len(t)):
        s[i+m]=t[m]
    f=1
if f==0:print('UNRESTORABLE')
else:
  for k in range(len(s)):
    if s[k]=='?':s[k]='a'
  print(''.join(s))

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

int main() {
  ll a,b;cin>>a>>b;
  ll ans=a/gcd(a,b)*b;
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int A[200100],B[200100];
priority_queue<int,vector<int>,greater<int> > PQ1;
priority_queue<int,vector<int>,less<int> > PQ2;
int main()
{
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>A[i];
	while(K--)
	{
		while(!PQ1.empty())
			PQ1.pop();
		for(int i=0;i<N;i++)
		{
			PQ1.push(i+A[i]);
			while(PQ1.top()<i)
				PQ1.pop();
			B[i]=(int)(PQ1.size());
		}
		while(!PQ2.empty())
			PQ2.pop();
		for(int i=N-1;i>=0;i--)
		{
			PQ2.push(i-A[i]);
			while(PQ2.top()>i)
				PQ2.pop();
			B[i]+=(int)(PQ2.size());
			B[i]--;
		}
		bool OK=true;
		for(int i=0;i<N;i++)
		{
			if(B[i]!=N)
				OK=false;
			A[i]=B[i];
		}
		if(OK)
			break;
	}
	for(int i=0;i<N;i++)
		cout<<A[i]<<" ";
	return 0;
}

Measured memory_bytes: 7116
# Maximize the Formula
A = gets.chomp.split(" ").map(&:to_i)
A.sort!
max = A.max
min = A.min 
mid = (A.size % 2).zero? ? A[A.size/2 - 1, 2].inject(:+) / 2.0 : A[A.size/2]
puts max*10+mid + min

Measured memory_bytes: 3836
#include<stdio.h>
int main(){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a, &op, &b);
    if(op == '?' )break;
    else if(op == '+' )printf("%d\n",a+b);
    else if(op == '-' )printf("%d\n",a-b);
    else if(op == '*' )printf("%d\n",a*b);
    else if(op == '/')printf("%d\n",a/b);
    
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	int res = 0;
	cin >> n;
	res += n / 500 * 1000;
	n %= 500;
	res += n / 5 * 5;
	cout << res << endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{  
  int X, Y;
  cin>>X>>Y;
  int ANS = 0;
  while( X <= Y)
  {
    ANS++;
    X *= 2;
  }
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,a,c;
int main(){
	cin>>n;
	rep(i,n){
		cin>>a;
		c^=(a%2);
	}
	cout<<(c?"NO":"YES")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100] = {};
int b[100100] = {};
int c[100100] = {};
int Ans = 0;


int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    sort(a, a+n);
    
    int j = 0;
    
    c[0] = 1;
    b[0] = a[0];
    for(int i = 1; i < n; i++)
    {
        if(a[i] == a[i-1])
        {
            c[j] = c[j] + 1;
        }
        else
        {
            j = j + 1;
            c[j] = 1;
            b[j] = a[i];
        }
    }
    
    
    for(int i = 0; i < j+1; i++)
    {
        if(c[i] >= b[i])
        {
            Ans = Ans + c[i] - b[i];
            c[i] = b[i];
        }
        else
        {
            Ans = Ans + c[i];
            c[i] = 0;
        }
    }
    
    cout << Ans << endl;
    
    
}


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

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> v(N), w(N);
	for(int i = 0; i < N; i++) {
		cin >> v.at(i) >> w.at(i);
	}
	int dp[N+1][W+1];
	for(int i = 0; i < W+1; i++) {
		dp[0][i] = 0;
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < W+1; j++) {
			if(w.at(i) <= j) {
				dp[i+1][j] = max(dp[i][j-w.at(i)]+v.at(i), dp[i][j]);
			}
			else {
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	cout << dp[N][W] << endl;
}


Measured memory_bytes: 7044
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,x,m = readInts()
an = x
ans = an
moddict = {an:1}
for i in range(2,n+1):
	an = pow(an,2,m)
	if an in moddict:
		break
	else:
		moddict[an]=i
	ans += an
#print(ans)
if an in moddict:
	rep = (n-len(moddict))//(len(moddict)-moddict[an]+1)
	rem = (n-len(moddict))%(len(moddict)-moddict[an]+1)
	#print(rep,rem)
	rep_sum = 0
	boo = 0
	for key in moddict:
		if boo or key==an:
			boo = 1
			rep_sum+=key

	ans += rep_sum*rep
	for i in range(rem):
		ans+=an
		an=pow(an,2,m)


print(ans)

Measured memory_bytes: 15576
import collections
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    # 菲再起にしたい　Whileでスタックに突っこみながら見てスタックの中身全部に代入
    def find(self, x):
        de = collections.deque()
        t = x
        while t!=self.parent[t]:
            de.append(t)
            t = self.parent[t]
        while de:
            tmp = de.pop()
            self.parent[tmp] = t
        return t
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.depth[x]<self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x]+=self.cnt[y]
            if self.depth[x]==self.depth[y]:
                self.depth[x]+=1
    def same(self, x, y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.cnt[self.find(x)]

n,m = map(int,input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x,y,z = map(int,input().split())
    utree.unite(x,y)
s = {utree.find(i) for i in range(1,n+1)}
print(len(s))

Measured memory_bytes: 17928
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

double N, M;
int A;
string S;

int main() {
    cin >> S;
    int y = (S[0] - '0') * 10 + (S[1] - '0');
    int m = (S[2] - '0') * 10 + (S[3] - '0');
    
    if (y >= 1 && y <= 12 && m >= 1 && m <= 12)PRI("AMBIGUOUS")
    else if (y >= 1 && y <= 12 &&(m <= 0 || m > 12))PRI("MMYY")
    else if ((y <= 0 || y > 12) && m >= 1 && m <= 12)PRI("YYMM")
    else PRI("NA")
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string a;
	cin >> a;
	for (int i = -1; i <= 1; i += 2)
	{
		for (int j = -1; j <= 2; j += 2)
		{
			for (int k = -1; k <= 1; k += 2)
			{
				int op[4] = { 1,i,j,k };
				int sum = 0;
				for (int o = 0; o < 4; o++)
				{
					sum += (a[o]-'0') * op[o];
				}
				if (sum != 7) continue;
				putchar(a[0]);
				for (int o = 1; o < 4; o++)
				{
					if (op[o] == 1) putchar('+');
					else putchar('-');
					putchar(a[o]);
				}
				puts("=7");
				exit(0);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 


long long int N,P,A,B,C,K,sum[200200]={},res=0;
long long int dp[300300]={};
string S,T;


int main(){
    cout << fixed << setprecision(18);
    cin>>S>>T;
    IFYes(S==T.substr(0,S.size()));
}


Measured memory_bytes: 3632
using System;
using System.Linq;

class AtCoder {
  static void Main() {
    long I = long.Parse(Console.ReadLine().Trim());
    long root = (long)Math.Floor(Math.Sqrt(I));
    long i = 0;
    long j = 0;
    
    while(root > 0) {
      if(I % root == 0) {
        i = root;
        j = I / root;
        break;
      }
      root--; 
    }
    Console.WriteLine(i + j - 2);
  }
}

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

int main (void) {
  int N, M;
  cin >> N >> M;

  vector<string> a(N), b(M);
  REP (i, N)
    cin >> a[i];
  REP (i, M)
    cin >> b[i];

  REP (i, N) REP (j, N) {
    if (i + M > N || j + M > N) continue;
    bool ok = true;
    REP (k, M) REP (l, M) {
      ok = ok && a[i+k][j+l] == b[k][l];
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
        #include <iomanip>
        #include <vector>
        #include <algorithm>
        #include <numeric>
        #include <functional>
        #include <cmath>
        #include <queue>
        #include <stack>
        #include <string>
         
        #define repd(i,a,b) for (int i=(a);i<(b);i++)
        #define rep(i,n) repd(i,0,n)
        typedef long long ll;
         
        using namespace std;
         
        int main(int argc, const char * argv[]) {
          int a;
          int b;
          cin >> a;
          b = (((int)((a-1)/111)) + 1)*111;
          cout << b << endl;
        }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    int D;
    int[] c;
    int[][] s;

    int[] t;
    int[][] l; // 最終開催日から何日たっているか

    public void Solve()
    {
        D = ReadInt();
        c = ReadInt(26).ToArray();
        s = new int[D][];
        for (int i = 0; i < D; i++) s[i] = ReadInt(26).ToArray();

        t = ReadInt(D).Select(x => x - 1).ToArray();

        l = new int[D][];
        for (int i = 0; i < D; i++) l[i] = new int[26];

        int score = Calc();
        int m = ReadInt();
        for (int i = 0; i < m; i++)
        {
            int d = ReadInt() - 1;
            int q = ReadInt() - 1;
            score += Change(d, q);
            Console.WriteLine(score);
        }
    }

    int Calc()
    {
        int score = 0;
        { // i = 0 のとき
            score += s[0][t[0]];
            for (int j = 0; j < 26; j++)
            {
                l[0][j] = 1;
            }
            l[0][t[0]] = 0;
            for (int j = 0; j < 26; j++)
            {
                score -= l[0][j] * c[j];
            }
        }
        for (int i = 1; i < D; i++)
        {
            score += s[i][t[i]];
            for (int j = 0; j < 26; j++)
            {
                l[i][j] = l[i - 1][j] + 1;
            }
            l[i][t[i]] = 0;
            for (int j = 0; j < 26; j++)
            {
                score -= l[i][j] * c[j];
            }
        }
        return score;
    }

    int Change(int d, int q)
    {
        int a = t[d]; // 本来開催されるはずだったコンテスト
        t[d] = q;
        int diff = s[d][q] - s[d][a]; // 変動するスコア（戻り値）

        int x = (d == 0 ? 0 : l[d - 1][a]) + 1; // 前日の l
        { // i = 0 のとき
            diff -= (x - l[d][a]) * c[a];
            l[d][a] = x;
        }
        for (int i = 1; d + i < D && l[d + i][a] != 0; i++)
        {
            diff -= (x + i - l[d + i][a]) * c[a];
            l[d + i][a] = x + i;
        }

        int y = l[d][q];
        for (int i = 0; d + i < D && l[d + i][q] != 0; i++)
        {
            l[d + i][q] = i;
            diff += y * c[q];
        }
        return diff;
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 41224
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


const int MOD = 1000000007;

int main(void) {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, 0, N) cin >> A[i];

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

  int e;
  if(N % 2 == 1) {
    if(A[0] == 0) {
      REP(i, 1, (N + 1) / 2) {
        if(A[i * 2 - 1] == i * 2 && A[i * 2] == i * 2);
        else goto ZERO;
      }
      e = N / 2;
      goto EXP;
    }
    goto ZERO;
  } else {
    REP(i, 0, N / 2) {
      if(A[i * 2] == i * 2 + 1 && A[i * 2 + 1] == i * 2 + 1);
      else goto ZERO;
    }
    e = N / 2;
    goto EXP;
  }

ZERO:
  cout << 0 << endl;
  return 0;

EXP:
  long ans = 1;
  REP(i, 0, e) {
    ans *= 2;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b;
c=a*b;
if(a<=9 && b<=9){
    cout<<a*b<<endl;
}
else if (a>=9 || b>=9){
    cout<<"-1"<<endl;
}













return 0;
}


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

const int maxn = 1e3+5, maxs = 2e4+5, inf = 1e9;
int n, h, a[maxn], b[maxn], dp[maxs];

int main(){
	scanf("%d %d", &h, &n);
	for(int i = 1; i<=n; i++) scanf("%d %d", &a[i], &b[i]);
	fill(dp+1, dp+maxs, inf);
	for(int i = 1; i<=n; i++){
		for(int s = a[i]; s<maxs; s++) dp[s] = min(dp[s], dp[s-a[i]] + b[i]);
	}
	printf("%d\n", *min_element(dp+h, dp+maxs));
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
int H, W, D, A[303][303], Q;
pair<int, int> idx[90101];
//---------------------------------------------------------------------------------------------------
int memo[90101];
int f(int x) {
    if (0 < memo[x]) return memo[x];
    if (x < D) return 0;
 
    int y = x - D;
    int cost = abs(idx[x].first - idx[y].first) + abs(idx[x].second - idx[y].second);
    int res = cost + f(y);
    return memo[x] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W >> D;
    rep(y, 0, H) rep(x, 0, W) {
        cin >> A[y][x];
        A[y][x]--;
        idx[A[y][x]] = make_pair(x, y);
    }
    cin >> Q;
    rep(q, 0, Q) {
        int L, R; cin >> L >> R;
        L--; R--;
        int ans = f(R) - f(L);
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 4608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var list = new List<Pair>();
            for (int i = 0; i < n; i++)
            {
                var col = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();
                list.Add(new Pair() { A = col[0], B = col[1] });
            }
            {
                var sorted = list.OrderBy(p => p.A).ToList();
                var a = sorted.First().A - 1;
                var b = sorted.Last().A - a;
                var c = sorted.Last().B;
                var sum = a + b + c;

                Console.WriteLine(sum);

                Console.Read();
            }
        }

        class Pair
        {
            public int A { get; set; }
            public int B { get; set; }
        }
    }
}


Measured memory_bytes: 25008
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

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

	if(n==7 || n==5 || n==3) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    H, W, Q = map(int, input().split())
    S = [list(map(lambda x: x=="1", input())) for _ in range(H)]
    #XYXY = zip(*[iter(map(int, sys.stdin.read().split()))]*4)

    M, L, R, U, D = [], [], [], [], []
    for x, s in enumerate(S):
        M_, L_, R_, U_, D_ = [], [], [], [], []
        for y, c in enumerate(s):
            m = l = r = u = d = 0
            if c:
                if x >= 1:
                    m += S[x-1][y]
                    u -= S[x-1][y]
                if x < H-1:
                    m += S[x+1][y]
                    d -= S[x+1][y]
                if y >= 1:
                    m += s[y-1]
                    l -= s[y-1]
                if y < W-1:
                    m += s[y+1]
                    r -= s[y+1]
                m = 2 - m
                # l = m - l
                # r = m - r
                # u = m - u
                # d = m - d
            M_.append(m)
            L_.append(l)
            R_.append(r)
            U_.append(u)
            D_.append(d)
        M.append(M_)
        L.append(L_)
        R.append(R_)
        U.append(U_)
        D.append(D_)
    M.append([0]*(W+1))
    L.append([0]*(W+1))
    R.append([0]*(W+1))
    U.append([0]*(W+1))
    D.append([0]*(W+1))

    #for m in M:
    #    print(m)
    for x in range(H):
        m = 0
        for y in range(W):
            m += M[x][y]
            M[x][y] = m + M[x-1][y]
            L[x][y] += L[x-1][y]
            R[x][y] += R[x-1][y]
            U[x][y] += U[x][y-1]
            D[x][y] += D[x][y-1]

    Ans = []
    #for x1, y1, x2, y2 in XYXY:
    for _ in range(Q):
        x1, y1, x2, y2 = map(int, input().split())
        ans = 0
        ans += M[x2-1][y2-1] + M[x1-2][y1-2] - M[x2-1][y1-2] - M[x1-2][y2-1]
        ans -= L[x2-1][y1-1] - L[x1-2][y1-1]
        ans -= R[x2-1][y2-1] - R[x1-2][y2-1]
        ans -= U[x1-1][y2-1] - U[x1-1][y1-2]
        ans -= D[x2-1][y2-1] - D[x2-1][y1-2]
        assert ans % 2 == 0, ans
        #Ans.append(ans//2)
        print(ans//2)
    #print("\n".join(map(str, Ans)))

main()


Measured memory_bytes: 241160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);
            Console.WriteLine(A * B / 2);

        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>

#define PI 3.14159265358979323

using namespace std;

int main() {
	double r;
	cin >> r;
	double s = PI * r * r;
	double l = 2 * PI * r;
	printf("%.8lf %.8lf\n", s, l);
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define MAX 1e9
using namespace std;

typedef long long ll;

int
main(void){

  string s; cin >> s;
  string r(s);reverse(r.begin(),r.end());
  int count = 0;


  for(int i = 0; i < s.length() /2; ++i){
    if(s[i] != r[i]) ++count;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<unordered_map>
#include<queue>

#define inf 0x3f3f3f3f
#define ii pair<int,int> 
#define iii pair<int, ii>
#define pb push_back

const int maxn = 5010;


using namespace std;
typedef vector<int> vi;
int arr[3];

int main () {
	string s;
	
	cin >> s;
	for(int i = 0 ;s[i] ;i++){
		int x = s[i] - 97;
		arr[x]++;
	}
	
	if( arr[0] == 1  && arr[1] == 1  && arr[2] == 1 )cout<<"Yes\n";
	else cout<<"No\n";
}
	
	 


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

int main() {
  int r, D, x2000;
  cin >> r >> D >> x2000;
  
  long long int xp = x2000;
  for (int i = 1; i <= 10 ; i++) {
    long long int x = r * xp - D;
    cout << x << endl;
    xp = x;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,i,j=1,t;
    int a[100000]={0};
    scanf("%d",&n);
    
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    
    i=0;
    while(n>0&&j<100000)
    {
        if(a[i]!=2)
        {
            t = a[i]-1;
            i = t;
            j++;
        }
        else
        {
            n=0;
        }
        
    }
    if(j>=100000)
    {
        j=-1;
    }
    printf("%d\n",j);
    
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void) {

	int a, b, c, x;
	int y = 0;
	scanf("%d %d %d", &a, &b, &c);

	for (x = a; x <= b; x++) {

		if (c%x == 0) {
			y++;
		}
		
	}

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


	return(0);

}


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

const int maxn = 1e5;

int n, a[maxn], b[maxn], c[maxn];
int dp[maxn][4];

int main(int argc, char *argv[]) {  
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][1] = a[0];
	dp[0][2] = b[0];
	dp[0][3] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][1] = std::max(dp[i-1][2] + a[i], dp[i-1][3] + a[i]);
		dp[i][2] = std::max(dp[i-1][1] + b[i], dp[i-1][3] + b[i]);
		dp[i][3] = std::max(dp[i-1][2] + c[i], dp[i-1][1] + c[i]);
	}
	std::cout << std::max(dp[n-1][1], std::max(dp[n-1][2], dp[n-1][3])) << '\n';
}

Measured memory_bytes: 2944