akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int ans=0,n,x,y,h,w,i,size;
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<n;i++){
scanf("%d %d %d %d\n",&x,&y,&h,&w);
size=x+y+h;
if(size<=60 && w<=2){
ans=ans+600;
}
else if(size<=80 && w<=5){
ans=ans+800;
}
else if(size<=100 && w<=10){
ans=ans+1000;
}
else if(size<=120 && w<=15){
ans=ans+1200;
}
else if(size<=140 && w<=20){
ans=ans+1400;
}
else if(size<=160 && w<=25){
ans=ans+1600;
}
}
printf("%d\n",ans);
ans=0;
}
return 0;
}


Measured memory_bytes: 1908
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] dist = new int[h*w][h*w];
		char[][] grid = new char[h][w];
		for(int i = 0; i < h; i++){
		    grid[i] = sc.next().toCharArray();
		    for(int j = 0; j < w; j++){
		        if(grid[i][j] == '#') continue;
		        int index = i*w + j;
		        int u = (i-1)*w + j;
		        int l = i*w + j-1;
		        if(i > 0 && grid[i-1][j] == '.'){
		            dist[index][u] = 1;
		            dist[u][index] = 1;
		        }
		        if(j > 0 && grid[i][j-1] == '.'){
		            dist[index][l] = 1;
		            dist[l][index] = 1;
		        }
		    }
		}
		
		// 計算
		int result = 0;
		wf(dist);
		for(int i = 0; i < h*w; i++){
		    for(int j = i+1; j < h*w; j++){
		        if(dist[i][j] == 1001001001) continue;
		        result = max(result, dist[i][j]);
		    }
		}
		
		// 出力
		System.out.println(result);
	}

	static void wf(int[][] dist) {
		int n = dist[0].length;
		int INF = 1001001001;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist[i][j] == 0) dist[i][j] = INF;
				if(i == j) dist[i][j] = 0;
			}
		}

		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
	}
}




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

#define ll long long

vector<ll> arr;
vector<vector<pair<ll,ll>>> dp;

pair<ll,ll> help(int i,int j)
{
    if(i>j) return {0,0};
    if(i==j) return {arr[i],0};

    if(dp[i][j].first != -1 ) return dp[i][j];

    auto p1= help(i+1,j),p2=help(i,j-1);

    if( p1.second+arr[i]>=p2.second+arr[j] ) {
        dp[i][j]= { p1.second+arr[i], p1.first };
    }else{
        dp[i][j]= {p2.second+arr[j], p2.first};
    }
    return dp[i][j];
}

int main()
{
    int n; cin>>n;
    arr.resize(n);
    dp.resize(n,vector<pair<ll,ll>>(n,{-1,-1}));
    for(int i=0;i<n;i++) cin>>arr[i];
    auto ans=help(0,n-1);
    cout<<ans.first-ans.second;
}

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

long long dp[3010][3010][4];
long long item[3010][3010];

void solve(long long R, long long C, long long K, std::vector<long long> r, std::vector<long long> c, std::vector<long long> v) {
    for (size_t i = 0; i < K; i++) {
        item[r[i]][c[i]] = v[i];
    }
    for (long long i = 1; i < R + 1; i++) {
        for (long long j = 1; j < C + 1; j++) {
            dp[i][j][0] = max({
                dp[i][j - 1][0],
                dp[i - 1][j][0],
                dp[i - 1][j][1],
                dp[i - 1][j][2],
                dp[i - 1][j][3],
            });
            for (long long k = 1; k < 4; k++) {
                dp[i][j][k] = max({
                    dp[i][j - 1][k - 1] + item[i][j],
                    dp[i][j - 1][k],
                    dp[i - 1][j][0] + item[i][j],
                    dp[i - 1][j][1] + item[i][j],
                    dp[i - 1][j][2] + item[i][j],
                    dp[i - 1][j][3] + item[i][j],
                });
            }
        }
    }

    cout << *max_element(dp[R][C], dp[R][C] + 4) << endl;
}

// Generated by 1.1.7.1 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() {
    long long R;
    scanf("%lld", &R);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> r(K);
    std::vector<long long> c(K);
    std::vector<long long> v(K);
    for (int i = 0; i < K; i++) {
        scanf("%lld", &r[i]);
        scanf("%lld", &c[i]);
        scanf("%lld", &v[i]);
    }
    solve(R, C, K, std::move(r), std::move(c), std::move(v));
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  for(int i=0;i<=N;i++){
    if(floor(i*1.08)==N){
      cout<<i<< endl;
      return 0;
    }
  }
  cout<<":("<< endl;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int l = 0, r = 0; l < n; l = r) {
		while (r < n && a[l] == a[r]) r++;
		if (r < n && a[l] > a[r] + 1) {
			cout << "No" << endl;
			return 0;
		}
		if (r < n && a[l] == a[r] + 1) {
			a[r - 1]--;
		}
		if (l && a[r - 1] < a[l - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint a, b, k;
    cin >> a >> b >> k;

    cout << max(0LL, a - k) << ' ';

    k = max(k - a, 0LL);

    cout << max(0LL, b - k) << endl;

    cout << flush;

    return 0;
}

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

const int inf = 1e9;
int a,b;
int main(){
	cin >> a >> b;
	int ans = -inf;
	ans = max(ans,a+b);
	ans = max(ans,a-b);
	ans = max(ans,a*b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split(' ')))
q = int(input())
T = list(map(int, input().split(' ')))
r = 0

S.sort()


def binary_search(S, left, right, t):
    m = (left + right) // 2
    if S[m] == t:
        return True
    if left >= right:
        return False
    if S[m] > t:
        return binary_search(S, left, m, t)
    else:
        return binary_search(S, m + 1, right, t)


for t in T:
    if binary_search(S, 0, n, t):
        r += 1

print(r)



Measured memory_bytes: 16708
#include <iostream>

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi a(n),b(n),c(n);
    REP(i,n){
        cin>>a[i];
    }
    sort(all(a));
    REP(i,n){
        cin>>b[i];
    }
    sort(all(b));
    REP(i,n){
        cin>>c[i];
    }
    sort(all(c));
    ll r=0;
    ll l=0;
    ll ans=0;
    REP(i,n){
        while(r<n&&a[r]<b[i]){
            r++;
        }
        while(l<n&&c[l]<=b[i]){
            l++;
        }
        ans+=r*(n-l);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;

int main()
{
	fast();
	ll n, k;
	cin >> n >> k;
	if(n > k){
		ll m  = n / k;
		n = n - m * k;
	}
	ll mi = 1e18L+5;
	for(int i = 0 ;i < 100000; ++i){
		mi = min(mi, (ll)abs(n - k));
		n = abs(n - k);
	}
	cout << mi;
}			

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
r = s.count('R')
w = s.count('W')

all_paint = min(r, w)
all_convert_r = r - s[0:r].count('R')
all_convert_w = w - s[n-w:n].count('S')
print(min(all_paint, all_convert_r, all_convert_w))

Measured memory_bytes: 11932
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node 
{
    int parent, left, right;
};

Node node[MAX];
int n, depth[MAX];



void print(int u)
{
    int i, c;
    
    cout << "node " << u << ": ";
    cout << "parent = " << node[u].parent << ", ";
    cout << "depth = " << depth[u] << ", ";
    if (node[u].parent == NIL){
        cout << "root, ";
    } else if (node[u].left == NIL){
        cout << "leaf, ";
    } else {
        cout << "internal node, ";
    }
    cout << "[";

    for (i = 0, c = node[u].left; c != NIL; i++, c = node[c].right) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}


void getDepth (int u, int p)
{
    depth[u] = p;
    if ( node[u].right != NIL ){
        getDepth(node[u].right, p);
    }
    if ( node[u].left != NIL ){
        getDepth(node[u].left, p + 1);
    }
    
    
}

int main()
{
    int id, degree, child, first_child, root;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        node[i].parent = node[i].left = node[i].right = NIL;
    }

    for (int i = 0; i < n; i++){
        cin >> id >> degree;
        for (int j = 0; j < degree; j++){
            cin >> child;
            if (j == 0){
                node[id].left = child;
            } else {
                node[first_child].right = child;
            }
            first_child = child;
            node[child].parent = id;
        }
    }
    for (int i = 0; i < n; i++){
        if (node[i].parent == NIL){
            root = i;
        }
    }

    getDepth(root, 0);
    for (int i = 0; i < n; i++){
        print(i);
    }
    return 0;
}

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

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

    vector<int> A(n);


    rep(i, n) cin >> A[i];


    for (int i = 0; i < n-k; i++){
        if (A[i] < A[i+k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3920
#include<stdio.h>
#define MAXNUMBER_OF_NODE 101
#define WHITE 0
#define GLAY 1
#define BLACK 2
#define INFTY 2001


int main()
{
  int color[MAXNUMBER_OF_NODE],ajacency_list[MAXNUMBER_OF_NODE][MAXNUMBER_OF_NODE],lightest_weight_from_the_node[MAXNUMBER_OF_NODE],parent_of_node[MAXNUMBER_OF_NODE],minimum_cost;
  int i,j,number_of_node,node_index,v,sum;

  scanf("%d",&number_of_node);
  
  for(i = 0; i < number_of_node ; i++ )
    {
      color[i] = WHITE;
      lightest_weight_from_the_node[i] = INFTY;
      parent_of_node[i] = -1;
    }

  for(i = 0 ; i < number_of_node ;i++ )
    for(j = 0 ; j < number_of_node ; j++)scanf("%d",&ajacency_list[i][j]);
    
  lightest_weight_from_the_node[0] = 0;
  
  // printf("test1\n");
  while(1)
    {
      minimum_cost = INFTY;
      //node_index = -1;
      //printf("minimum_cost 1==%d\n",minimum_cost);
      for(i=0; i<number_of_node; i++ )
	{
	  // printf("test3\n");
	  if(color[i] != BLACK && lightest_weight_from_the_node[i] < minimum_cost)
	    {
	      minimum_cost = lightest_weight_from_the_node[i];
	      node_index = i;
	      //printf("test4\n");
	    }
	  //printf("node_index1 == %d\n",node_index);
	  // printf("test5\n");

	}
      //printf("minimum_cost2 == %d\n",minimum_cost);
      if(minimum_cost == INFTY)break;
      
      
      color[node_index] = BLACK;
      for(i = 1 ; i<=number_of_node ; i++)
	{
	  if(color[i] != BLACK && ajacency_list[node_index][i]!=-1 &&  lightest_weight_from_the_node[i]>ajacency_list[node_index][i])
	    {
	      // if(lightest_weight_from_the_node[i] > ajacency_list[node_index][i])////
		
		  lightest_weight_from_the_node[i] = ajacency_list[node_index][i];
		  parent_of_node[i] = node_index;
		  //printf("node_index2 == %d\n",node_index);
		  //printf("parent_of_node[%d] = %d\n",i,parent_of_node[i]);
		  color[i] = GLAY;
		  
		
		
	    }
	  
	}
    }
  //printf("test2\n");
     
      sum = 0;
      for(i = 0; i <= number_of_node ; i++)///
	{
	  if(parent_of_node[i] != -1)
	    {
	      sum += ajacency_list[i][parent_of_node[i]];
	      //printf("test7\n");
	      // printf("parent_of_node[%d] = %d\n\n",i,parent_of_node[i]);
	      // printf("ajacency_list[%d][parent_of_node[%d]]=%d\n",i,i,ajacency_list[i][parent_of_node[i]]);
	      //printf("sum = %d\n",sum);
	    }
	}

       printf("%d\n",sum);
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>

using namespace std;

int main(){ 
  int x,a,b; cin >> x >> a >> b;
  int d = abs(x-a); int f = abs(x-b);
  
  if( d < f){ cout << "A" << endl;}
  else{ cout << "B" << endl;}
  return 0;
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

bool ask(int a,int b){
	printf("? %d %d\n",a,b);
	fflush(stdout);
	string p; cin>>p;
	return (p=="Y");
}

int main(){
	int a,b; cin>>a>>b;
	if(a<=b){
		 printf("Impossible");
		 return 0;
	}
	int n=a+b;
	vector<int> g;
	rep(i,0,n){
		if(g.empty())g.push_back(i);
		else if(ask(g.back(),i)) g.push_back(i);
		else{
			 g.pop_back(); b--;
		}
		if(g.size()>b) break;
	}
	int x=g.back();
	vector<int> ans(n);
	rep(i,0,n) ans[i]=ask(x,i);
	printf("! ");
	rep(i,0,n) printf("%d",ans[i]);
	printf("\n"); fflush(stdout);
	return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>

int main(){
    int S,count=0;
    std::cin >> S;
    if(S%10==1){
        count++;
    }
    if(S/100==1){
        count++;
    }
    if((S%100)/10==1){
        count++;
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int red[555][555];
int blue[555][555];
int h, w;
int add[555][555];
char temp[555];

void getred(void)
{
	for(int i=1 ; i<=h ; i++)
	{
		red[i][1]=1;
	}
	for(int i=1 ; i<=h ; i+=2)
	{
		for(int j=2 ; j<=w-1 ; j++)
		{
			red[i][j]=1;
		}
	}
}

void getblue(void)
{
	for(int i=1 ; i<=h ; i++)
	{
		blue[i][w]=1;
	}
	for(int i=2 ; i<=h ; i+=2)
	{
		for(int j=2 ; j<=w-1 ; j++)
		{
			blue[i][j]=1;
		}
	}
}
int main(void)
{
	cin>>h>>w;
	getred();
	getblue();
	int i, j;
	for(i=1 ; i<=h ; i++)
	{
		scanf("%s",&temp[1]);
		for(j=1 ; j<=w ; j++)
		{
			if(temp[j]=='.')
			{
				add[i][j]=0;
			}
			else
			{
				add[i][j]=1;
			}
		}
	}
	for(i=1 ; i<=h ; i++)
	{
		for(j=1 ; j<=w ; j++)
		{
			if(add[i][j]==1)
			{
				red[i][j]=1;
				blue[i][j]=1;
			}
		}
	}
	for(i=1 ; i<=h ; i++)
	{
		for(j=1 ; j<=w ; j++)
		{
			if(red[i][j]==1)
			{
				printf("#");
			}
			else
			{
				printf(".");
			}
		}
		printf("\n");
	}
	printf("\n");
	for(i=1 ; i<=h ; i++)
	{
		for(j=1 ; j<=w ; j++)
		{
			if(blue[i][j]==1)
			{
				printf("#");
			}
			else
			{
				printf(".");
			}
		}
		printf("\n");
	}
}

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

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

    int n;
    cin >> n;
    vector<long> A(n);
    REP(i, n){
        cin >> A[i];
        A[i] -= (i + 1);
    }
    
    sort(A.begin(), A.end());
    long mid = n % 2 ? A[n / 2] : (A[n / 2] + A[n / 2]) / 2;

    long ans = 0;
    REP(i, n) ans += abs(A[i] - mid);
    cout << ans << endl;

    return 0;
}

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

vector<vector<int>> graph(111111);

int main(){
	int N,M;
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int A,B;
		cin >> A >> B;
		A--;
		B--;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}
	vector<bool> used(N,false);
	deque<int> deq;
	deq.push_back(0);
	deq.push_back(graph[0][0]);
	used[0]=used[graph[0][0]]=true;
	int X=2;
	
	bool flag=false;
	while(1){
		if(!flag){
			int& x=deq.front();
			bool f=true;
			for(auto t:graph[x]){
				if(!used[t]){
					deq.push_front(t);
					X++;
					used[t]=true;
					f=false;
					break;
				}
			}
			if(f)flag=true;
			if(!flag)continue;
		}
		int& x=deq.back();
		bool ff=true;
		for(auto t:graph[x]){
			if(!used[t]){
				deq.push_back(t);
				X++;
				used[t]=true;
				ff=false;
				break;
			}	
		}
		if(ff){
			cout << X << endl;
				while(!deq.empty()){
					int& x=deq.front();
					cout << x+1;
					deq.pop_front();
					if(deq.empty())cout << endl;
					else cout << " ";
				}
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
int main()
{
    int n,a[MAX];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maxv=-2000000000;
    int minv=a[0];
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,a[i]-minv);
        minv=min(minv,a[i]);
    }
    cout<<maxv<<endl;
}


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

int const N= 1e5;
int arr1[N];
int arr2[N];
int main()
{

int a,b;
cin>>a>>b;
int ans=a;
int count =1;
bool flag =false;
while(ans<b)
{
    ans+=a;
   // ans--;
    count++;
        ans--;

}
if(b==1)
    cout<<0;
    else
cout<<count;

}


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

typedef long long int ll;

using namespace std;

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
	
	int n;
	cin>>n;
	vector <int> p(n),q(n);
	for(int i=0;i<n;i++)
		cin>>p[i];
	for(int i=0;i<n;i++)
		cin>>q[i];
	vector <int> fact(9);
	fact[0]=fact[1]=1;
	for(int i=2;i<=8;i++)
		fact[i]=fact[i-1]*i;
	int a=0,b=0;
	set <int> s;
	set <int>::iterator it;
	for(int i=1;i<=n;i++)
		s.insert(i);
	for(int i=1;i<=n;i++)
	{int c=0;
		for(it=s.begin();it!=s.end()&&*it!=p[i-1];it++)
		{
			c++;
		}
		//cout<<c<<endl;
		a+=((c)*fact[n-i]);
		s.erase(p[i-1]);
	}

	s.clear();
	for(int i=1;i<=n;i++)
		s.insert(i);
	for(int i=1;i<=n;i++)
	{
		int c=0;
		for(it=s.begin();it!=s.end()&&*it!=q[i-1];it++)
		{
			c++;
		}
		b+=((c)*fact[n-i]);
		s.erase(q[i-1]);
	}
	//cout<<a<<" "<<b<<endl;
	cout<<abs(a-b)<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int tam; cin >> tam;
    int arr[tam];
    long ans = 0;
    for(int i = 0; i < tam; i++) cin >> arr[i];
    
    for(int j = 1; j < tam; j++){
        if(arr[j] <= arr[j-1]){
            ans += arr[j-1]-arr[j];
            arr[j] += arr[j-1] - arr[j];
        }
        //cout << arr[j] << "  ";
    }
    //cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 4368
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int v[256];

int main()
{
	for(int i=2;i<=9;i++)v['0'+i]=i;
	v['A']=11; v['T']=v['J']=v['Q']=v['K']=10;
	
	int CS; cin>>CS;
	rep(cs,CS)
	{
		int ace=0,score=0,cur=2;
		char cd[10]; rep(i,10)cin>>cd[i];
		rep(i,2)if(cd[i]=='A')ace++;
		
		score=v[cd[0]]+v[cd[1]];
		if(score==21)
		{
			cout<<"blackjack"<<endl; continue;
		}
		
		while(score>21&&ace)ace--,score-=10;
		
		while(score<=16||score==17&&ace)
		{
			score+=v[cd[cur]];
			if(cd[cur]=='A')ace++; cur++;
			
			while(score>21&&ace)ace--,score-=10;
		}
		if(score>21)cout<<"bust"<<endl;
		else cout<<score<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
//package hiougyf;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		 Scanner sc =new Scanner(System.in);
	int t=sc.nextInt();

	 int ac=0,wa=0,tle=0,re=0;
	 while(t-->0) {
		 String s=sc.next();
	 
		 if(s.equals("WA")) {
			 wa++;
		 }
		 if(s.equals("AC")) {
			 ac++;
		 }
		 if(s.equals("TLE")) {
			 tle++;
		 }
		 if(s.equals("RE")) {
			 re++;
		 }
	 }
		 System.out.println("AC x "+ac);
		 System.out.println("WA x "+wa);
		 System.out.println("TLE x "+tle);
		 System.out.println("RE x "+re);
		 
	 
	}
	
}
	

Measured memory_bytes: 58816
def main():
    L, R = map(int, input().split())
    if R//2019 - L//2019 > 1:
        print(0)
        return
    elif R//2019 == L//2019:
        U = list(range(L%2019, R%2019+1))
    else:
        print(0)
        return
    ans = 2019
    for i in U:
        for j in U:
            if i == j:
                continue
            ans = min(ans, (i*j)%2019)
    print(ans)


if __name__ == "__main__":
    main()


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

const int mod = 1e9 + 7;

long long binpow(long long a, int n) {
	if(n == 0) return 1;
	if(n & 1) return a * binpow(a % mod, n - 1) % mod;
	return binpow(a * a % mod, n / 2) % mod;
}

long long c(int n, int k) {
	long long ans = 1;
	for(int i = 1; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}
	long long a = 1;
	for(int i = 1; i <= n - k; i++) {
		a *= i;
		a %= mod;
	}
	ans *= binpow(a, mod - 2);
	ans %= mod;
	a = 1;
	for(int i = 1; i <= k; i++) {
		a *= i;
		a %= mod;
	}
	ans *= binpow(a, mod - 2);
	ans %= mod;
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	long long n = h - a + b + 1 - 2, m = b;
	long long cc = c(n, m);
	long long n1 = a + (w - b) - 2, m1 = w - b - 1; 
	long long cc1 = c(n1, m1); 
	long long ans = 0;
	for(; m < w; ) {
		ans += cc * cc1;
		ans %= mod;
		ans += mod;
		ans %= mod;

		cc *= n + 1;
		cc %= mod;
		cc *= binpow(m + 1, mod - 2);
		cc %= mod;
		n++, m++;
		
		cc1 *= m1;
		cc1 %= mod;
		cc1 *= binpow(n1, mod - 2);
		cc1 %= mod;
		m1--, n1--;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n,m; cin>>n;
  int p[n];
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p,p+n);
  cin>>m;
  int t[m];
  for(int i=0;i<m;i++){
    cin>>t[i];
  }
  sort(t,m+t);
  int j=0;
  for(int i=0;i<n;i++){
    if(p[i]==t[j]){
      j++;
      if(j==m){
        cout<<"YES"<<endl;
        return 0;
      }
    }else if(p[i]>t[j]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
using namespace std;

char ps[233];

int main()
{
	int n; scanf("%d",&n);
	scanf("%s",ps); int l=strlen(ps);
	ps[n]='\0';
	printf("%s",ps);
	if(l>n) printf("...");
	return 0;
}

Measured memory_bytes: 1736
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		Long[] a = new Long[n];
		long sum = 0;
		long aa = 0;
		for(i=0;i<n;i++) {
			aa = parseLong(sc.next());
			sum += aa;
			a[i] = aa;
		}
		sc.close();
		Arrays.parallelSort(a, Comparator.reverseOrder());
		ArrayList<Long> dif = new ArrayList<>();
		for (i = 1; i <= 31; i++) {
			long tmp=0;
			long tmp2=0;
			for (j = 0; j < a.length; j++) {
				tmp2 = a[j] >> 1;
				tmp = a[j] - tmp2;
				if(tmp == 0) break;
				a[j] = tmp2;
				dif.add(tmp);
			}
			if(j==0) break;
		}
		Collections.sort(dif, Comparator.reverseOrder());
		long dsum = 0;
		for (i = 0; i < Math.min(m, dif.size()); i++) {
			dsum += dif.get(i);
		}
		out.println(sum - dsum);
	}
}


Measured memory_bytes: 157804
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Out(N*N);
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll K,N;
string s;

// i桁目から見て、そこまででj個の非zeroを使った時のパターン数
// ただし、k=0ならそこまでの桁が一致している
ll dp[110][10][2];

// i=0123456..
// s=314159

signed main() {
  cin >> s >> K;
  N = s.size();
  dp[0][0][1]=0;
  dp[0][0][0]=1;
  rep(i, N) rep(j, 10) rep(k,2) {
    // if (dp[i][j][k] == 0)
    //  continue;
    rep(d, 10) { // 次の桁を0~9のどれにするか
      ll nd = s[i]-'0'; // 次の桁にある数
      ll ni = i+1, nj = j, nk = k;
      if (d > 0) nj++;
      if (nj >= 10) continue; // 非ゼロが発生しすぎている
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1; // 未満が確定
        if (d == nd) nk = 0; // 一致している
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  cout << dp[N][K][0] + dp[N][K][1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    /*
    iiii oo jjjj llll jiiiil
    iiii oo jjjj llll jjjlll
    */

    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;

    ll a = o, b = o;

    if (0 < i && 0 < j && 0 < l) {
        a += 3;
        a += (i - 1) / 2 * 2;
        a += (j - 1) / 2 * 2;
        a += (l - 1) / 2 * 2;
    }
    b += i / 2 * 2;
    b += j / 2 * 2;
    b += l / 2 * 2;

    cout << max(a, b) << "\n";
}


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

namespace ABC049_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var H = sss[0];
            var W = sss[1];
            var C = new string[H].Select(x => Console.ReadLine()).ToArray();
            for (var i = 0; i <= 2 * H - 1; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    Console.Write(C[i / 2][j]);
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
	public static final int MAX = Integer.MAX_VALUE - 90000;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int N = in.nextInt();
			int M = in.nextInt();
			if(N==0 && M==0) break;
			int[] C = new int[M];
			for(int i=0;i<M;i++){
				C[i] = in.nextInt();
			}
			int[] x = new int[N+1];
			for(int i=1;i<N+1;i++){
				x[i] = in.nextInt();
			}
			
			int[][] dp = new int[N+1][256];
			for(int i=0;i<N+1;i++){
				for(int j=0;j<256;j++){
					dp[i][j] = MAX;
				}
			}
			dp[0][128] = 0;
 			for(int i=0;i<N;i++){
 				for(int j=0;j<256;j++){
 					for(int k=0;k<C.length;k++){
 						int trg = Math.min(255,Math.max(0,j+C[k]));
 						dp[i+1][trg] = (int)Math.min(dp[i+1][trg],
 								dp[i][j]+Math.pow(x[i+1]-trg,2));
 					}
 				}
 			}
 			int ans=MAX;
 			for(int i=0;i<256;i++){
 				ans = Math.min(ans,dp[N][i]);
 			}
 			System.out.println(ans);
 			System.gc();
		}
	}
}

Measured memory_bytes: 85840
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair< ll, ll > P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll N;
  cin >> N;

  vector< ll > P(N);
  vector< ll > Q(N);

  REP(i, N)
  {
    cin >> P[i];
  }
  REP(i, N)
  {
    cin >> Q[i];
  }

  vector< ll > X(N);
  iota(X.begin(), X.end(), 1);

  int cnt = 1;
  int a = -1;
  int b = -1;
  do
  {
    // DEBUG_VEC(X);

    if (a == -1)
    {
      REP(ai, N)
      {
        if (X[ai] != P[ai])
        {
          break;
        }
        if (ai == (N - 1))
        {
          a = cnt;
        }
      }
    }

    if (b == -1)
    {
      REP(ai, N)
      {
        if (X[ai] != Q[ai])
        {
          break;
        }
        if (ai == (N - 1))
        {
          b = cnt;
        }
      }
    }

    if (a != -1 && b != -1)
    {
      break;
    }
    ++cnt;
  } while (next_permutation(X.begin(), X.end()));

  cout << abs(a - b) << endl;

  return 0;
}

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

using ll = long long;

const int MAXN = 1.1e5;
int N;
ll A[MAXN];
ll B[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N+1; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	ll ans = 0;
	for (int i = 0; i < N+1; i++) {
		if (i) {
			ll v = min(A[i], B[i-1]);
			ans += v;
			A[i] -= v;
			B[i-1] -= v;
		}
		if (i < N) {
			ll v = min(A[i], B[i]);
			ans += v;
			A[i] -= v;
			B[i] -= v;
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int a = n % 10;
    n /= 10;
    int b = n % 10;
    n /= 10;
    int c = n % 10;
    n /= 10;
    int d = n;
    if((a == b || c == d ) && b == c) printf("Yes");
    else printf("No");
    return 0; 
}                                                                                                                       


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,j,n) for(int i=j;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,A[105];
signed main(){
	cin>>N;
	fill(A,A+N,inf);
	rep(i,N-1){
		int B;cin>>B;
		chmin(A[i],B);
		chmin(A[i+1],B);
	}
	int sum=0;
	rep(i,N)sum+=A[i];
	cout<<sum<<"\n";
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
using namespace std;

#define mod  
#define ll  long long
#define endl "\n"
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x, y;
	cin >> x >> y;
	cout << x / (2 * y + 1)+(x%(2*y+1)!=0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 200010
#define lowbit(x) x&-x
int n,m,q,ans[N];
struct node {int l,r,id;}a[N],ask[N];
bool cmp(node a,node b){
	return a.r<b.r; 
}
int c[N];
void add(int x,int y){
	for(int i=x;i<=n;i+=lowbit(i)){
		c[i]+=y;
	}
}
int Q(int x){
	int ans=0;
	for(int i=x;i;i-=lowbit(i)){
		ans+=c[i];
	}
	return ans;
}
int main(){
	in3(n,m,q);
	for(int i=1;i<=m;i++){
		in2(a[i].l,a[i].r);
	}
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=q;i++){
		in2(ask[i].l,ask[i].r);
		ask[i].id=i;
	}
	sort(ask+1,ask+q+1,cmp);
	int j=1; 
	for(int i=1;i<=q;i++){
		while(j<=m&&a[j].r<=ask[i].r){
			add(a[j].l,1);j++;
		}
		ans[ask[i].id]=Q(ask[i].r)-Q(ask[i].l-1);
	}
	for(int i=1;i<=q;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 6144
import bisect


def palace():
    def average_temperature(height):
        return t - (height * 0.006)
    
    def get_key_from_value(dict, value):
        for k, v in dict.items():
            if v == value:
                return k
    
    n = int(input())
    t, a = map(float, input().split())
    
    h = list(map(int, input().split()))
    h_dict = {}
    for i in range(n):
        h_dict[i + 1] = average_temperature(h[i])
    
    h_sorted = sorted(h, reverse=True)
    temperatures = [average_temperature(height) for height in h_sorted]
    
    index = bisect.bisect_left(temperatures, a)
    if index - 1 >= 0 and index <= n - 1:
        choices = [temperatures[index - 1], temperatures[index]]
        abses = [abs(a - choices[0]), abs(a - choices[1])]
        if abses[0] >= abses[1]:
            print(get_key_from_value(h_dict, choices[1]))
        else:
            print(get_key_from_value(h_dict, choices[0]))
    else:
        if index - 1 >= 0:
            choice = temperatures[index - 1]
            print(get_key_from_value(h_dict, choice))
        if index <= n - 1:
            choice = temperatures[index + 1]
            print(get_key_from_value(h_dict, choice))


if __name__ == '__main__':
    palace()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int c = 0, res = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') c++;
    else {
      res = max(c, res);
      c = 0;
    }
  }
  res = max(c, res);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		long  a = in.nextLong();
		long  b = in.nextLong();
		if(a!=1&&b!=1) {
			BigInteger a1 = BigInteger.valueOf(a);
			BigInteger b1 = BigInteger.valueOf(b);
			BigInteger c = a1.multiply(b1);
			BigInteger two = BigInteger.valueOf(2);
			if(c.mod(two).equals(BigInteger.ZERO)) {
				System.out.println(c.divide(two));
			}
			else {
				System.out.println(c.divide(two).add(BigInteger.ONE));
			}
		}
		else {
			System.out.println(1);
		}

	}

}

Measured memory_bytes: 21972
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

using namespace std;

int masu[10000];


int main(){
	while(1){
		int n,m;
		sintt(n,m);
		
		if(n==0)break;
		
		rep(i,10000){
			masu[i]=0;
		}
		
		
		rep(i,n){
			rep(j,m){
				int a;
				sint(a);
				masu[j]+=a<<i;
			}
		}
		
		
		int maxi=0;
		
		rep(i,1<<n){
			int cont=0;
			rep(j,m){
				int cont2=0;
				//printf("%d-",masu[j]^i);
				rep(k,n){
					//printf("%d",(masu[j]^i)&(1<<k));
					if(((masu[j]^i)&(1<<k))>0){
						cont2++;
					}
				}
				//printf("-%d ",cont2);
				cont+=max(cont2,n-cont2);
			}//puts("");
			maxi=max(maxi,cont);
		}
		
		
		printf("%d\n",maxi);
	}
}
/*
3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1 

*/

Measured memory_bytes: 916
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var S = cin.ReadLine.ToCharArray();

            int x = 0;
            int ans = 0;
            for (int i = 0; i < N; i++){
                if(S[i] == 'I'){
                    x++;
                }else if(S[i] == 'D'){
                    x--;
                }

                if(x > ans){
                    ans = x;
                }
            }

            WriteLine(ans);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include <iostream>
	

using namespace std;


int main() { 
    int x = 0;
    cin >> x;
    int t = 1;
    int happiness = 0;
    while(x > 0){
        if(x >= 500){
            x = x - 500;
            happiness = happiness + 1000;
        }
        else if(x >= 5){
            x = x - 5;
            happiness = happiness + 5;
        } 
        else{
            break;
        }
    }
    cout << happiness << endl;

    return 0;
}

Measured memory_bytes: 256
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    ll n , k ; cin >> n >> k ;
    ll ans =0 ;
    for(int i=k;i<=n+1ll;i++){
        ans = (ans+(2ll*n-i+1)*i/2ll%M-(i-1ll)*i/2ll%M+M+1ll)%M;
        
    }
    cout << ans %M<< endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

pii solve(const string& s) {
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if ( (i+1 < n) and (s[i] == s[i+1])) return pii(i+1, i+2);
    if ( (i+2 < n) and (s[i] == s[i+2])) return pii(i+1, i+3);
  }
  return pii(-1, -1);
}

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

  pii ans = solve(s);
  cout << ans.fs << " " << ans.sc << endl;
}


Measured memory_bytes: 512