akhauriyash/Code-Regression huggingface dataset:
from collections import deque
 
h, w = map(int, input().split())
a = ''.join(input() + '#' for _ in range(h))
n = len(a) - 1
b = ['#'] * w
q = deque()
d = -1, 1, -w - 1, w + 1
r = 0
for i in range(n):
  if a[i] == '.':
    b[:-w] = a
    b[i] = 0
    q.append(i)
    while(q):
      i = q.popleft()
      r = max(r, b[i])
      for j in d:
        j += i
        if b[j] == '.':
          b[j] = b[i] + 1
          q.append(j)
print(r)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,m; scanf("%d%d",&n,&m);
    if(n==m) for(int i=1;i<=n;i++) cout<<n;
    if(n<m) for(int i=1;i<=m;i++) cout<<n;
    if(n>m) for(int i=1;i<=n;i++) cout<<m;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (void) {
	int s; cin >> s;
	vector <int> v(s);
	int sum = 0;
	for (int i = 0; i < s; i++) {
		cin >> v[i];
		sum += v[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		int flag = 0;
		sort(v.begin(), v.end());
		for (int i = 0; i < s; i++) {
			if (v[i] % 10 != 0) {
				sum -= v[i];
				flag = 1;
				break;
			}
		}
		if (flag == 1)
			cout << sum << endl;
		else
			cout << '0' << endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a > b)
    cout << "a > b" << endl;
  else if (a < b)
    cout << "a < b" << endl;
  else
    cout << "a == b" << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  long n;

  cin >> n;

  vector<long> a(n);
  fillLong(a, n);

  sortv(a);

  double sm = 0;

  sm = (double)(a[0] + a[1]) / 2.0;

  for(long i = 2; i < n; i++) {
    sm = (double)(sm + a[i]) / 2.0;
  }

  cout << std::setprecision(10) << sm << endl;
}


Measured memory_bytes: 888
N = int(input())

A = []
line = input().split(" ")
A.append(list(map(lambda x:int(x), line)))
line = input().split(" ")
A.append(list(map(lambda x:int(x), line)))

def count(n):
    ret = 0
    for i in range(0,max(n,1)):
        ret += A[0][i]
    for i in range(max(n-1,0),N):
        ret += A[1][i]
    return ret

l = []
for n in range(N):
    l.append(count(n))

print(max(l))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> w(n);
    int sum=0;
    REP(i,n){
        cin>>w[i];
        sum+=w[i];
    }
    int ans=INF,tmp=0;
    REP(i,n){
        tmp+=w[i];
        sum-=w[i];
        chmin(ans,abs(tmp-sum));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define inf 1000000007
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=-1;
	if(a==b && b==c && c==a)
		d=1;
	if(d==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;


	return 0;
}




Measured memory_bytes: 256
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
		if n >= i:
			if fn(n-i) == 1:
				dp[n] = 0
				return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")


Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==y)
		{
			flag++;
		}
		else
		{
			flag=0;
		}
		ans=max(flag,ans);
	}
	if(ans>=3)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[105];
int Prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int Count(int x)
{
	int cnt = 0;
	for(int i = 0; i <= 14; i++)
	{
		if(a[i] >= x - 1)
		{
			cnt++;
		}
	}
	return cnt;
}

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 0; i <= 14; i++)
	{
		int temp = n;
		while(temp > 0)
		{
			a[i] += temp / Prime[i];
			temp /= Prime[i];
		}
	}
	cout << Count(75) + Count(25) * (Count(3) - 1) + Count(15) * (Count(5) - 1) + Count(5) * (Count(5) - 1) * (Count(3) - 2) / 2;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>


using namespace std;

const int MAX_V = 10001;
const int MAX_E = 20001;
const int INF = 1e9+7;

int m, n;

typedef pair<int, int> P;

struct edge {
    int from, to, len, cost;
};

int d[MAX_V];//从起点出发到任意一点的最短路
int c[MAX_V];//money...


vector<edge>es[MAX_V+1];//邻接矩阵

void init(){
    for (int i = 1; i <= MAX_V;i++){
        es[i].clear();
    }
}


//就是求单源最短路的
void dijkstra(int s) {
    for (int i = 1; i <= n; i++) {
        d[i] = INF;
        c[i] = INF;
    }
    d[s] = 0;
    c[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first)continue;
        for (int i = 0; i < es[v].size(); i++) {
            edge e = es[v][i];
            if (d[e.to] > d[e.from] + e.len) {
                d[e.to] = d[e.from] + e.len;
                c[e.to] = e.cost;
                que.push(P(d[e.to], e.to));
            }else if(d[e.to]==d[e.from]+e.len&&c[e.to]>e.cost){
                c[e.to] = e.cost;
            }

            
        }
    }

}

int main(){
    cin>>n>>m;
    while(m!=0||n!=0){
        while(m--){
            edge temp;
            scanf("%d%d%d%d", &temp.from, &temp.to, &temp.len, &temp.cost);
            es[temp.from].push_back(temp);
            swap(temp.from, temp.to);
            es[temp.from].push_back(temp);
        }
        dijkstra(1);
    
        long long ans = 0;
        for (int i = 1; i <= n;i++){
            ans += c[i];
        }
        cout << ans << endl;
        init();
        cin >> n >> m;
    }

    return 0;
}


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

struct node {int id, way, p;};
struct qry {int x, y, val;};
const int maxn = 100;
node d[maxn];
qry a[10000];
int n, l, cnt;

bool cmp(const qry &a, const qry &b)
{
    return a.val < b.val;
}

void input()
{
    char ml[2];
    int tmp;
    for (int i = 1; i <= n; ++i)
    {
        cin >> ml >> tmp;
        d[i] = (node) {i, ml[0] == 'R', tmp};
    }
}

void solve()
{
    cnt = 0;
    for (int i = 1; i < n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (d[i].way == 1 && d[j].way == 0 && (d[j].p - d[i].p) % 2 == 0)
                a[cnt++] = (qry) {i, j, d[j].p - d[i].p};
    sort(a, a + cnt, cmp);
    int ans1 = 0, ans2;
    for (int i = 0; i < cnt; ++i)
        swap(d[a[i].x].id, d[a[i].y].id);
    for (int i = 1; i <= n; ++i)
    {
        int time = d[i].way ? l - d[i].p : d[i].p;
        if (time > ans1)
        {
            ans1 = time;
            ans2 = d[i].id;
        }
        else if (time == ans1 && d[i].way == 0)
            ans2 = d[i].id;
    }
    cout << ans1 << ' ' << ans2 << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    while (cin >> n >> l && n)
    {
        input();
        solve();
    }
}

Measured memory_bytes: 1232
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int X = Integer.parseInt(sc.next());
     	int Y = Integer.parseInt(sc.next());
      	
      	char S[][] = new char[50][50];
      
      	for(int x = 0; x < X;  x++){
          	String s = sc.next();
        	for(int y = 0; y < Y; y++){
            	S[x][y] = s.charAt(y);
           	}
        }
      //System.out.println(Arrays.deepToString(S));
      int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
      int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
      
      for(int i = 0; i < X;  i++){
        	for(int j = 0; j < Y; j++){
            	if(S[i][j] == '.'){
                	int count = 0;
                  	for(int k = 0; k < 8; k++){
                    	int x = i + dx[k];
                      	int y = j + dy[k];
                      	if(0 <= x && x < X && 0 <= y && y < Y && S[x][y] == '#'){
                        	count++;
                        }
                      S[i][j] = (char)('0' + count);
                    }
                }
           	}
      }
        for(int i = 0; i < X; i++){
        	for(int j = 0; j < Y; j++){
            	System.out.print(S[i][j]);
            }
          System.out.println();
        }
    }
}

Measured memory_bytes: 21204
#include <stdio.h>
void selectionSort(int *a,int n,int *count){
    int min,t;
    for(int i=0;i<n;i++){
        min = i;
        for(int j=i;j<n;j++){
            if(a[min]>a[j]){
                min = j;
            }
        }
        t = a[i];a[i] = a[min];a[min] = t;
        if(i != min) *count = *count + 1;
    }
};
void show(int *a,int n){
    for(int i=0;i<n;i++){
        if(i != n-1){
            printf("%d ",a[i]);
        }else
        {
            printf("%d\n",a[i]);
        }
        
    }
}
int main(){
    int A[100];
    int n;
    int c = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&A[i]);
    selectionSort(A,n,&c);
    show(A,n);
    printf("%d\n",c);

}


Measured memory_bytes: 2760
s=input()
t=input()

l=""
i=0
j=0
while True:
  if i < len(s):
    l+=s[i]
    i+=1
  if j < len(t):
    l+=t[j]
    j+=1
  if len(l) == len(s)+len(t):
    break
print(l)


Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int a,b;
int q;
long long s[100100];
long long t[100100];
long long que;
long long leasts(long long curdist){
	if(curdist>s[a])
	   return s[a];
	if(curdist<s[1])
	   return s[1];
	long long *p=lower_bound(s+1,s+a+1,curdist);
	long long le=*(p-1),ri=*p;
	if(curdist-le<ri-curdist)
	   return le;
	else
	   return ri;
}
long long oths(long long curdist){
	if(curdist>s[a])
	   return s[a];
	if(curdist<s[1])
	   return s[1];
	long long *p=lower_bound(s+1,s+a+1,curdist);
	long long le=*(p-1),ri=*p;
	if(curdist-le>=ri-curdist)
	   return le;
	else
	   return ri;
}
long long leastt(long long curdist){
	if(curdist>t[b])
	   return t[b];
	if(curdist<t[1])
	   return t[1];
	long long *p=lower_bound(t+1,t+b+1,curdist);
	long long le=*(p-1),ri=*p;
	if(curdist-le<ri-curdist)
	   return le;
	else
	   return ri;
}
long long otht(long long curdist){
	if(curdist>t[b])
	   return t[b];
	if(curdist<t[1])
	   return t[1];
	long long *p=lower_bound(t+1,t+b+1,curdist);
	long long le=*(p-1),ri=*p;
	if(curdist-le>=ri-curdist)
	   return le;
	else
	   return ri;
}
int main()
{
	cin>>a>>b>>q;
	for(int i=1;i<=a;i++)
		cin>>s[i];
	for(int i=1;i<=b;i++)
	   cin>>t[i];
	sort(s+1,s+a+1);
	sort(t+1,t+b+1);
	long long ans1=0,ans2=0,ans3=0,ans4=0,ans5=0,ans6=0,ans7=0,ans8=0;
	for(int i=1;i<=q;i++){
		cin>>que;
		long long goshrine=leasts(que),gotemp=leastt(que);
		long long othes=oths(que),othet=otht(que);
		ans1=0,ans2=0,ans3=0,ans4=0;
		{
			ans1+=llabs(goshrine-que);
			ans1+=llabs(leastt(goshrine)-goshrine);
		}
		{
			ans2+=llabs(othes-que);
			ans2+=llabs(leastt(othes)-othes);
		}
		{
			ans3+=llabs(gotemp-que);
			ans3+=llabs(leasts(gotemp)-gotemp);
		}
		{
			ans4+=llabs(othet-que);
			ans4+=llabs(leasts(othet)-othet);
		}
		{
			ans5+=llabs(goshrine-que);
			ans5+=llabs(otht(goshrine)-goshrine);
		}
		{
			ans6+=llabs(othes-que);
			ans6+=llabs(otht(othes)-othes);
		}
		{
			ans7+=llabs(gotemp-que);
			ans7+=llabs(oths(gotemp)-gotemp);
		}
		{
			ans8+=llabs(othet-que);
			ans8+=llabs(oths(othet)-othet);
		}
		cout<<min(min(ans1,ans2),min(ans3,ans4))<<endl;
	}
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>




int main(){
  	int N;
  	std::cin>>N;
  	std::string A, B;
  	std::cin>>A>>B;
  
  	std::string C;
  	for (int i=0; i<N; i++){
      	C.push_back(A[i]);
      	C.push_back(B[i]);
    }
  
  	std::cout<<C;
  
  
  
 	return 0; 
}

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

void BubbleSort();
void SelectionSort();

int N;
char a1[36][2];
char a2[36][2];

int main(){
  int i,j,n,flag=0;
  char A[36][2];
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%s",A[i]);
  for(i=0;i<N;i++)
    {
      a1[i][0]=A[i][0];
      a1[i][1]=A[i][1];
      a2[i][0]=A[i][0];
      a2[i][1]=A[i][1];
    }
  
  BubbleSort();
  SelectionSort();

  for(i=0;i<N;i++){
    printf("%c%c",a1[i][0],a1[i][1]);
    if(i<N-1)
      printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  
  for(i=0;i<N;i++){
    printf("%c%c",a2[i][0],a2[i][1]);
    if(i<N-1)
      printf(" ");
  }
  printf("\n");
  for(i=0;i<N;i++)
    if(a1[i][0]!=a2[i][0])
      flag=1;
  if(flag==1)
    printf("Not stable\n");
  else
    printf("Stable\n");
  
  return 0;
}

void BubbleSort(){
  int i,j,B[N],n;
  char keep[2];
  for(i=0;i<N;i++)
    B[i]=a1[i][1]-48;
  for(j=0;j<N;j++){
    for(i=N-1;i>0;i--){
      if(B[i]<B[i-1]){
	n=B[i];
	B[i]=B[i-1];
	B[i-1]=n;
	keep[0]=a1[i][0];
	a1[i][0]=a1[i-1][0];
	a1[i-1][0]=keep[0];
	keep[1]=a1[i][1];
	a1[i][1]=a1[i-1][1];
	a1[i-1][1]=keep[1];
      }
    }
  }
}

void SelectionSort(){
  int i,j,B[N],n,minj;
  char keep[2];
  for(i=0;i<N;i++)
    B[i]=a2[i][1]-48;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(B[j]<B[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      n=B[i];
      B[i]=B[minj];
      B[minj]=n;
      keep[0]=a2[i][0];
      a2[i][0]=a2[minj][0];
      a2[minj][0]=keep[0];
      keep[1]=a2[i][1];
      a2[i][1]=a2[minj][1];
      a2[minj][1]=keep[1];
    }
  }
}

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

int main() 
{
    int n;
    cin >> n;
    set<int> s={111,222,333,444,555,666,777,888,999};
    for (auto x:s)
    {
        if (x>=n)
        {
            cout << x;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	
	char s[10];
	

	int i,n,m,k,t;
	scanf("%s", s);
	n = 0;
	for (i = 0; s[i] != '\0'; i++) {
		n++;
	}
	if (s[0] != 'A') printf("WA");
	else {
		m = 0;
		for (i = 2; i <= n - 2; i++) {
			if (s[i] == 'C') {
				m++; k = i;
			}
		}

			
		if (m == 0) printf("WA");
		else if (m >= 2) printf("WA");
		else {
			t = 0;
			
				for (i = 1; i <= k - 1; i++) {
					if (s[i] == 'a') t++;
					if (s[i] == 'b') t++;
					if (s[i] == 'c') t++;
					if (s[i] == 'd') t++;
					if (s[i] == 'e') t++;
					if (s[i] == 'f') t++;
					if (s[i] == 'g') t++;
					if (s[i] == 'h') t++;
					if (s[i] == 'i') t++;
					if (s[i] == 'j') t++;
					if (s[i] == 'k') t++;
					if (s[i] == 'l') t++;
					if (s[i] == 'm') t++;
					if (s[i] == 'n') t++;
					if (s[i] == 'o') t++;
					if (s[i] == 'p') t++;
					if (s[i] == 'q') t++;
					if (s[i] == 'r') t++;
					if (s[i] == 's') t++;
					if (s[i] == 't') t++;
					if (s[i] == 'u') t++;
					if (s[i] == 'v') t++;
					if (s[i] == 'w') t++;
					if (s[i] == 'x') t++;
					if (s[i] == 'y') t++;
					if (s[i] == 'z') t++;
				}
				for (i = k + 1; i <= n; i++) {
					if (s[i] == 'a') t++;
					if (s[i] == 'b') t++;
					if (s[i] == 'c') t++;
					if (s[i] == 'd') t++;
					if (s[i] == 'e') t++;
					if (s[i] == 'f') t++;
					if (s[i] == 'g') t++;
					if (s[i] == 'h') t++;
					if (s[i] == 'i') t++;
					if (s[i] == 'j') t++;
					if (s[i] == 'k') t++;
					if (s[i] == 'l') t++;
					if (s[i] == 'm') t++;
					if (s[i] == 'n') t++;
					if (s[i] == 'o') t++;
					if (s[i] == 'p') t++;
					if (s[i] == 'q') t++;
					if (s[i] == 'r') t++;
					if (s[i] == 's') t++;
					if (s[i] == 't') t++;
					if (s[i] == 'u') t++;
					if (s[i] == 'v') t++;
					if (s[i] == 'w') t++;
					if (s[i] == 'x') t++;
					if (s[i] == 'y') t++;
					if (s[i] == 'z') t++;
				}
				

			

			if (t == n - 2) printf("AC");
			else printf("WA");
        }
			
		}
	return 0;
	}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val A = Array(N) { readLine()!! }
    val B = Array(M) { readLine()!! }

    for (i in 0..N - M) {
        for (j in 0..N - M) {
            var ok = true
            for (k in 0 until M) {
                if (A[i + k].substring(j, j + M) != B[k]) {
                    ok = false
                    break
                }
            }
            if (ok) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}


Measured memory_bytes: 38036
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pub push_back
#define ll long long
					  
using namespace std;

const int INF = (int)1e9 + 7;

int n;
int a[2000007];
pair<int, int> sp[2][20][200007];
int gg[200007];

pair<int, int> getSp(int l, int r, int type){
	int lvl = gg[r - l + 1];
	return min(sp[type][lvl][l], sp[type][lvl][r - (1 << lvl) + 1]);
}

pair<int, int> tmp[3];

int getVal(int l, int r){
	if (l > r) return INF;
	if (l % 2 == 0){
		return getSp(l, r, 0).x;
	} else {
		return getSp(l, r, 1).x;
	}
}

int sz = 0;
vector<int> g[200007];
pair<int, int> dd[200007];

void rec(int p, int l, int r){
	//cout << "===" << l << ' ' << r << "===" << endl;
	if (l > r) return;
	int now = sz++;
	g[p].pub(now);
	pair<int, int> v, u;
	if (l % 2 == 0){
		v = getSp(l, r, 0);
		u = getSp(v.y + 1, r, 1);
	} else {
		v = getSp(l, r, 1);
		u = getSp(v.y + 1, r, 0);
	}
	//cout << v.x << ' ' << u.x << ' ';
	dd[now] = mp(v.x, u.x);
	rec(now, l, v.y - 1);
	rec(now, v.y + 1, u.y - 1);
	rec(now, u.y + 1, r);
}

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("seating.in", "r", stdin);
	//freopen("seating.out", "w", stdout);
	for (int i = 2; i < 200007; i++) gg[i] = gg[i / 2] + 1;
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int lvl = 0; lvl < 20; lvl++){
		for (int l = 0, r = (1 << lvl) - 1; r < n; l++, r++){
			if (lvl == 0){
				if (l % 2 == 0){
					sp[0][0][l] = mp(a[l], l);
					sp[1][0][l] = mp(INF, l);
				} else {
					sp[0][0][l] = mp(INF, l);
					sp[1][0][l] = mp(a[l], l);
				}
			} else {
				sp[0][lvl][l] = min(sp[0][lvl - 1][l], sp[0][lvl - 1][r - (1 << (lvl - 1)) + 1]);
				sp[1][lvl][l] = min(sp[1][lvl - 1][l], sp[1][lvl - 1][r - (1 << (lvl - 1)) + 1]);
			}
		}
	}

	rec(-1, 0, n - 1);

	set<pair<pair<int, int>, int> > se;

	se.insert(mp(dd[0], 0));

	while(1){
		if (se.size() == 0) break;
		auto now = *se.begin();
		se.erase(se.begin());
		cout << now.x.x << ' ' << now.x.y << ' ';
		for (int to : g[now.y]) se.insert(mp(dd[to], to));
	}
}

Measured memory_bytes: 77696
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)printf("Zero\n");
	else if(a>0&&b>0)printf("Positive\n");
	else
	{
		if((b-a)%2==0)printf("Negative\n");
		else printf("Positive\n");
	}
}

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

using namespace std;

string s[2010];
int dp[2010][2010];
vector<pair<int, int> > vt[2010];
int ct[2010];

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0), cin.tie(0);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++){
        cin >> s[i];
        for (int j = 0; j < w; j++){
            s[i][j] -= '0';
        }
    }
    int ans = max(w, h);
    for (int i = 1; i < h; i++){
        ct[0] = 1;
        for (int j = 1; j < w; j++){
            ct[j] = 1 + ct[j - 1] * ((s[i][j] == s[i - 1][j]) == (s[i][j - 1] == s[i - 1][j - 1]));
            while (!vt[j].empty() && ct[j] < vt[j].back().first){
                auto p = vt[j].back();
                vt[j].pop_back();
                int fr = 0;
                if (!vt[j].empty()) fr = vt[j].back().second + 1;
                ans = max(ans, (i - fr) * p.first);
            }
            vt[j].push_back({ct[j], i - 1});
        }
    }
    for (int j = 1; j < w; j++){
        while (!vt[j].empty()){
            auto p = vt[j].back();
            vt[j].pop_back();
            int fr = 0;
            if (!vt[j].empty()) fr = vt[j].back().second + 1;
            ans = max(ans, (h - fr) * p.first);
        }
    }
    cout << ans;
    return 0;
}





Measured memory_bytes: 36736
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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;}

#define P (1'000'000'007)

signed main() {
    capi(n);

    int c = 1;
    string s;

    if (n == 0) {
        cout << 0;
        return 0;
    }

    while(n != 0) {
        if (n % (abs(c) * 2)) {
            n -= c;
            s += "1";
        } else {
            s += "0";
        }

        c *= -2;
    }

    reverse(all(s));

    cout << s;

    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

/*---最大公約数 from 20190929---*/
long long gcd(long long x, long long y) { return y ? gcd(y,x%y) : x;}
/*---最小公倍数 from 20191222---*/
long long lcm(long long x, long long y){return (x*y)/gcd(x,y);}

int main(){
    int n;
    ll m;
    cin >> n >> m;
    vector<int> a(n),b(n);
    rep(i,0,n-1){
        cin >> a[i];
        b[i] = a[i]/2;
    }
    ll LCM = (ll)1;
    rep(i,0,n-1)LCM = lcm(LCM,(ll)b[i]);
    rep(i,0,n-1){
        if((LCM/b[i])%2==0){
            puts("0");
            return 0;
        }
    }
    // int two0 = 0;
    // int bb = b[0];
    // while(bb % 2 == 0){
    //     bb /= 2;
    //     two0++;
    // }
    // rep(i,1,n-1){
    //     bb = b[i];
    //     int two1 = 0;
    //     while(bb % 2 == 0){
    //         bb /= 2;
    //         two1++;
    //     }
    //     if(two0 != two1){
    //         puts("0");
    //         return 0;
    //     }
    // }

    int ans = 0;
    if(LCM > m){
        puts("0");
        return 0;
    }
    // for(int i=1;LCM*i<=m;i+=2){
    //     ++ans;
    // }
    int i = 1;
    while(LCM * i <= m){
        ++ans;
        i += 2;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
X = []
Y = []
for i in range(N):
  x, y = [int(item) for item in input().split()]
  X.append(x)
  Y.append(y)
if N == 1:
  print (1)
else:
  result={}
  maxv = -100
  for i in range(N):
      for j in range(N):
        dx, dy = X[j]-X[i], Y[j]-Y[i]
        if dx > 0 or dy > 0:
          if (dx, dy) not in result:
            result[(dx, dy)] = 1
          else:
            result[(dx, dy)] += 1
          if result[(dx, dy)]>maxv:
            maxv=result[(dx, dy)]
  print (N-maxv)

Measured memory_bytes: 3444
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    for (int i = 1; i < n; i++)
    {
        vs[i] += vs[i - 1];
    }

    int64_t ans = std::numeric_limits<int64_t>::max();
    for (int i = 0; i < n - 1; i++)
    {
        ans = min(ans, abs(vs[i] - (vs[n - 1] - vs[i])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int Way[100] = { 0 };

int main() {
	int N;
	for (int a = 0; a < 10; a++) {
		for (int b = 0; b < 10; b++) {
			for (int c = 0; c < 10; c++) {
				for (int d = 0; d < 10; d++) {
					Way[a + b + c + d]++;
				}
			}
		}
	}
	while (1) {
		if (scanf("%d", &N) == EOF)break;
		else {
			printf("%d\n", Way[N]);
		}
	}

	return 0;
}



Measured memory_bytes: 2024
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,M; cin >> N>>M;
	map<int, bool>c,d;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		if (a == 1)c[b]=1;
		if (b == N)d[a]=1;
	}
	bool x = 0;
	for (int i = 1; i <= N; i++) {
		if (c[i] == 1 && d[i] == 1) {
			x = 1; break;
		}
	}
	if (x)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 18944
#include<stdio.h>
#include<string.h>
int main(){
	char r[6],a[6];
	int hit,blow,i,j;
	while(scanf("%s%s",r,a)!=EOF){
		if(strcmp(r,"0")==0 && strcmp(a,"0")==0)break;
		hit=blow=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i])hit++;
			for(j=0;j<4;j++){
				if(j!=i && r[i]==a[j])blow++;
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
using std::min;
using std::max;
using std::sort;
#define MAXN 103

int main(void)
{
    int N, K, R;
    int a[MAXN],plate[MAXN];
    scanf("%d%d",&N,&K);
    int i,j,res=0;
    
    for(i=0;i<N;i++)
    {
        scanf("%d",a+i);
    }

    R=min(N,K);
    for(int A=0;A<=R;A++)
    {
        for(int B=0;B<=R-A;B++)
        {
            for(i=0;i<A;i++)
            {
                plate[i]=a[i];
            }
            for(j=0;j<B;j++)
            {
                plate[i+j]=a[N-1-j];
            }
            sort(plate,plate+A+B);
            i=0;
            while(i<K-(A+B) && plate[i]<0)
            {
                i++;
            }
            int s = 0;
            for(;i<A+B;i++)
            {
                s+=plate[i];
            }
            res = max(s,res);
        }
    }
    printf("%d\n",res);
    return 0;

}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        Queue<Tuple<int, int>> stack = new Queue<Tuple<int, int>>();
        int n = int.Parse(Console.ReadLine());
        List<int>[] edges = Enumerable.Repeat(0, n).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < n - 1; i++)
        {
            int[] a =  Console.ReadLine().Split().Select(int.Parse).ToArray();
            edges[a[0] - 1].Add(a[1] - 1);
            edges[a[1] - 1].Add(a[0] - 1);
        }
        int[] visit = new int[n];
        visit[0] = 1;
        visit[n - 1] = -1;
        stack.Enqueue(new Tuple<int, int>(0, 1));
        stack.Enqueue(new Tuple<int, int>(n - 1, -1));
        while (stack.Count != 0)
        {
            Debug.WriteLine(string.Join(" ", visit));
            var tup = stack.Dequeue();
            int[] edge = edges[tup.Item1].ToArray();
            Debug.WriteLine(string.Join(" ", edge));
            foreach (var vert in edge)
            {
                if (visit[vert] == 0)
                {
                    visit[vert] = tup.Item2;
                    stack.Enqueue(new Tuple<int, int>(vert, tup.Item2));
                }
            }
        }
        Console.WriteLine(visit.Count(x => x == 1) > visit.Count(x => x == -1) ? "Fennec" : "Snuke");
    }
}

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

using namespace std;

#define MAX 250

int H, T[MAX + 1];

void print(int node) {
	printf("node %d: key = %d, ", node, T[node]);
	if (node > 1) printf("parent key = %d, ", T[node / 2]);
	if (2 * node <= H) printf("left key = %d, ", T[2 * node]);
	if (2 * node + 1 <= H) printf("right key = %d, ", T[2 * node + 1]);
	printf("\n");
}

int main() {
	cin >> H;
	for (int i = 1; i <= H; ++i) {
		int key; cin >> key;
		T[i] = key;
	}
	for (int i = 1; i <= H; ++i) print(i);

	return 0;
}


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vi v;
    f(3){
        int x;cin>>x;v.pb(x);
    }
    sort(all(v));
    reverse(all(v));
    cout<<10*v[0]+v[1]+v[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N,A,B,C;cin >> N >> A >> B >> C;
    vector<string> s(N);
    for(int i =0;i <N;i++) cin >> s[i];
    string ansS;
    for(int i = 0; i <N;i++){
        if (s[i] == "AB"){
            if (A == 0 && B == 0) break;
            if (A == 1 && B == 1 && C == 0){
                if (i != N - 1){
                    if (s[i + 1] == "AC"){
                        A++;B--;
                        ansS.push_back('A');
                        continue;
                    }
                    else if (s[i + 1] == "BC") {
                        A--;B++;
                        ansS.push_back('B');
                        continue;
                    }
                }
            }
            if (A >= B){
                A--;B++;
                ansS.push_back('B');

            }
            else{
                A++;B--;
                ansS.push_back('A');
            }
        }
        else if (s[i] == "AC"){
            if (A == 0 && C == 0) break;
            if (A == 1 && B == 0 && C == 1){
                if (i != N-1){
                    if (s[i + 1] == "AB"){
                        A++;C--;
                        ansS.push_back('A');
                        continue;
                    }
                    else if (s[i + 1] == "BC"){
                        A--;C++;
                        ansS.push_back('C');
                        continue;
                    }
                }
            }
            if (A >= C){
                A--;C++;
                ansS.push_back('C');
            }
            else{
                A++;C--;
                ansS.push_back('A');
            }
        }
        else if (s[i] == "BC"){
            if (B == 0 && C == 0) break;
            if (A == 0 && B == 1 && C == 1){
                if (i != N - 1){
                    if (s[i + 1] == "AB"){
                        B++;C--;
                        ansS.push_back('B');
                        continue;
                    }
                    else if (s[i + 1] == "AC"){
                        B--;C++;
                        ansS.push_back('C');
                        continue;
                    }
                }
            }
            if (B >= C){
                B--;C++;
                ansS.push_back('C');
            }
            else{
                B++;C--;
                ansS.push_back('B');
            }
        }
    }
    if (ansS.size() != N) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for(int i =0;i <N;i++) cout << ansS[i] << endl;
    }
}

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

using namespace std;

#define MAXN 100010
typedef long long LL;

int n, sg[MAXN];
vector<int> adj[MAXN];

void Init()
{
    int i, u, v;
    scanf("%d", &n);
    for(i = 1; i < n; ++i){
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

void DFS(int u, int fa)
{
    for(auto &v: adj[u]){
        if(v == fa) continue;
        DFS(v, u);
        sg[u] ^= sg[v] + 1;
    }
}

int main()
{
    Init();
    DFS(1, 0);
    printf("%s\n", sg[1] ? "Alice" : "Bob");
    return 0;
}


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

int main(){
  int N,a,f=0;
  cin >> N;
  for(a=9;a>0;a--){
      if(N%a==0){
        if(N/a< 10){
          cout << "Yes" << endl;
          f=1;
          break;
        }else{
          cout << "No" <<endl;
          f=1;
          break;
        }
      }
  }
  if(f==0)
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;





int main(void) {
    ll a, b, c;
    cin >> a >> b >> c;
    
    if(a+b+1>=c) {
        pr(b+c);
    }else {
        pr(a+b+1+b);
    }
    
    
}













Measured memory_bytes: 256
// luogu-judger-enable-o2
var
	i,l,r,mid,n:longint;
	a:array[1..1000001] of longint;

function check(k:longint):longint;
var	i:longint;
begin
	if ((a[n-1]<=k)and(a[n]<=k))or((a[n+1]<=k)and(a[n]<=k)) then exit(0);
	if ((a[n-1]>k)and(a[n]>k))or((a[n+1]>k)and(a[n]>k)) then exit(1);
	for i:=1 to n-1 do begin
		if ((a[n-i-1]<=k)and(a[n-i]<=k))or((a[n+i+1]<=k)and(a[n+i]<=k)) then exit(0);
		if ((a[n-i-1]>k)and(a[n-i]>k))or((a[n+i+1]>k)and(a[n+i]>k)) then exit(1);
	end;
	if a[1]>k then exit(1) else exit(0);
end;

begin
	readln(n);
	for i:=1 to 2*n-1 do read(a[i]);
	l:=1;
	r:=2*n-1;
	while l<r-1 do begin
		mid:=(l+r) shr 1;
		//writeln(l,' ',r);
		if check(mid)=0 then begin 
			//writeln(mid);
			r:=mid 
		end 
		else l:=mid;
	end;
	writeln(r);
end.

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10); 
    int n;
    cin>>n;
    int x=n/100, y=n%100;
    if(x<=12 && y<=12 && x>0 && y>0) cout<<"AMBIGUOUS";
    else if(x<=12 && x>0) cout<<"MMYY";
    else if(y<=12 && y>0) cout<<"YYMM";
    else cout<<"NA";
    cout<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int a, b, sum, dig=0;
	int i=0;

	while(1){
		a=-1;
		b=-1;
		scanf("%d", &a);
		scanf("%d", &b);
		if(a == -1)
			break;
		sum = a+b;
		if(sum>=0 && sum<=9)
			dig=1;
		else if(sum>=10 && sum<=99)
			dig=2;
		else if(sum>=100 && sum<=999)
			dig=3;
		else if(sum>=1000 && sum<=9999)
			dig=4;
		else if(sum>=10000 && sum<=99999)
			dig=5;
		else if(sum>=100000 && sum<=999999)
			dig=6;
		else
			dig=7;
		printf("%d\n", dig);
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    vp rb(N*2);
    vec x(N*2);
    rep(i,N*2){
        cin>>x[i]>>rb[i].fi;
        rb[i].se = i/N;
    }
    vec ord(N*2);
    rep(i,N*2) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll p, ll q){
        return x[p] < x[q];
    });
    set<ll> red;
    ll ans = 0;
    rep(i,N*2){
        P p = rb[ord[i]];
        if(p.se == 0){
            red.insert(p.fi);
        }else{
            if(!red.empty()){
                auto ite = lower_bound(red.begin(), red.end(), p.fi);
                if(ite != red.begin()){
                    --ite;
                    red.erase(ite);
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
 
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;
 

void solve(){
    int a,b;
    cin >> a >> b;
    cout << a*b;
    
    
    
}


 
int main(){
    int T;
    T = 1;
    while(T--){
        solve(); 
    }
}
 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    char ch[100][100];
    int n,m;
    cin>>n>>m;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) cin>>ch[i][j];
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++) cout<<ch[i][j];
        cout<<endl;
        for (int j=0; j<m; j++) cout<<ch[i][j];
        cout<<endl;
    }
}


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

int n;
int a[101];
int main() {
  cin>>n;
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
  return 0;
}

Measured memory_bytes: 3508
(let ((a (concatenate 'list (read-line)))
      (b (concatenate 'list (read-line)))
      (c (concatenate 'list (read-line))))

  (defun judge (chr)
    (cond ((char= chr #\a) (if a (judge (pop a)) (format t "~A~%" #\A)))
          ((char= chr #\b) (if b (judge (pop b)) (format t "~A~%" #\B)))
          ((char= chr #\c) (if c (judge (pop c)) (format t "~A~%" #\C)))))

  (judge #\a))


Measured memory_bytes: 24368
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  string s;
  cin >> s;

  int Q;
  cin >> Q;

  vector<set<int>> set(26);
  REP(i, 26) set[i].insert(INF);
  REP(i, N) set[s[i]-'a'].insert(i);

  while(Q--){
    int a;
    cin >> a;
    if(a == 1){
      int b;
      cin >> b; b--;
      char c;
      cin >> c;

      set[s[b]-'a'].erase(b);
      set[c-'a'].insert(b);
      s[b] = c;
    }else{
      int l, r;
      cin >> l >> r;
      l--; r--;

      int ans = 0;
      REP(i, 26){
        int it = *set[i].lower_bound(l);
        if(it <= r) ans++;
      }

      cout << ans << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 24196
k, x =  map(int, input().split())

if k + x > 1000000 or k - x < -1000000:
    if x + k > 0:
        ans = [i for i in range(x - k + 1, 1000000 )]
    elif x - k < -1000000:
        ans = [i for i in range(-1000000, x + k - 1)]
else:
    ans = [i for i in range(x-k + 1, x+k)]
print(*ans)





Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  ll p = n / k;
  ans += (p * p * p);
  if (k % 2 == 0) {
    p = (n + k/2) / k;
    ans += (p * p * p);
  }
  printf("%lld\n", ans);

  return 0;
}


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

int main(){
  int a,b,c;
  int x;

  scanf("%d %d %d",&a,&b,&c);

  if(a>=b && a>=c){
    x = 10*a + b + c;
  }else if(b>=c && b>=a){
    x = 10*b + a + c;
  }else if(c>=b && c>=a){
    x = 10*c + b + a;
  }

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

  return 0;
}


Measured memory_bytes: 128
import java.util. *;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String ans = "No";
	String s = sc.next();
	String t = sc.next();
	t += t;
	if(t.contains(s)) ans = "Yes";
	System.out.println(ans);
    }
}


Measured memory_bytes: 21844