akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };  //Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
  int n,c,l; cin >> n >> c >> l;
  int buf{};int head{};int ans{};
  vector<int> t(n);
  for(auto i = 0; i != n; i++){
    cin >> buf;
    t.at(i) = buf;
  }
  sort(t.begin(), t.end());

  for(auto i = 0; i < n;){
    ++ans;
    head = i;// headth,  ith passenger.
    // ith < nthPas times increment a little bit diff
    while(i < n && t.at(i) <= t.at(head) + l && i - head < c)
      ++i;
  }

  cout << ans << endl;
  return 0;
}
//from head to T[head]+l put in bus && num of people who put <= c
//if(t[head] + l <= T[head+j])go to next bus

// every updating head, ++ans, while
//i - head == num of people put in bus


Measured memory_bytes: 640
# include<iostream>
# include<vector>
using namespace std;
using vector1 = vector<int>;
using vector2 = vector<vector1>;
int last(int d, int j, vector2 t){
  for(int i=1; i<=d; i++){
    if(t[i][j] == j) return i;
  }
  return 0;
}
int down(vector1 c, int d, int p, vector2 t){
  int m = 0;
  for(int i=1; i<p; i++){
    m += c[i] * (d - last(d, i, t));
  }
  return m;
}
int main(){
  int D; cin >> D;
  vector1 c(26+1, 0); for(int i=1; i<=26; i++) cin >> c[i];
  vector2 s(D+1, vector1(26+1));
  for(int i=1; i<=D; i++){
    for(int j=1; j<=26; j++){
      cin >> s[i][j];
    }
  }

  vector2 S_(D+1, vector1(26+1));
  vector2 t(D+1, vector1(26+1));

  for(int i=0; i<=D; i++) S_[i][0] = 0;
  for(int j=0; j<=26; j++) S_[0][j] = 0;
  for(int i=1; i<=D; i++){
    S_[i][1] = S_[i-1][1] + s[i][1];
    t[i][1] = 1;
  }
  for(int i=1; i<=D; i++){
    for(int j=2; j<=26; j++){
      t[i][j] = j;
      int new_ = S_[i-1][j] + s[i][j] - down(c, i, j, t);
      t[i][j] = t[i][j-1];
      int old_ = S_[i][j-1] - c[j] * (i - last(i, j, t));
      //S_[i][j] = max(S_[i-1][j] + s[i][j] - down(c, i, last), S_[i][j-1]);
      if(new_ >= old_){
        S_[i][j] = new_; t[i][j] = j;
      }else{
        S_[i][j] = old_; t[i][j] = t[i][j-1];
      }
    }
  }

  for(int i=1; i<=D; i++) cout << t[i][26] <<"\n";
/*  for(auto a : t){
    for(auto b : a){
      cout << b <<"  ";
    };
    cout <<"\n";
  };
cout <<"\n";

//  cout << S_[D][26] <<"\n";
  for(auto a : S_){
    for(auto b : a){
      cout << b <<"  ";
    };
    cout <<"\n";
  };
*/
  return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int cnt=1;
  for(int i=0;i<N-1;i++){
    if(s[i]!=s[i+1])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 512
import collections

N = int(input())
xy = [tuple(map(int, input().split())) for i in range(N)]

if N==1: print(1)
else:
  xy = sorted(xy, key=lambda x: (x[0], x[1]))
  xy_list = set(xy)

  pq_collections = [0]*int((N*(N-1))/2)
  pq_c_index = 0

  for i, xy1 in enumerate(xy):
    for xy2 in xy[i+1:]:
      p = xy2[0] - xy1[0]
      q = xy2[1] - xy1[1]
      pq_collections[pq_c_index] = (p, q)
      pq_c_index += 1

  c = collections.Counter(pq_collections)

  print(N - c.most_common()[0][1])

Measured memory_bytes: 3572
#include<stdio.h>
int main (){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else {
    printf("a == b\n");
  } return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int n;
	cin >> n;
	vdef a(n, 0);
	for (int i = 0; i < n; ++i) cin >> a[i];

	vdef color;
	color.emplace_back(a[0]);

	for (int i = 1; i < n; ++i)
	{
		if (color[0] < a[i])
		{
			color[0] = a[i];
		}
		else if (color[color.size() - 1] >= a[i])
		{
			color.emplace_back(a[i]);
		}
		else
		{
			for (int j = 0; j < color.size(); ++j)
			{
				if (color[j] < a[i])
				{
					color[j] = a[i];
					break;
				}
			}
		}
	}

	ans = color.size();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1276
using System;

class Program
{
 static void Main(string[] args)
 {
   int num = int.Parse(Console.ReadLine());
   int cnt = 0;
   int pushNum = 0;
   int readPos = 0;
   
   string[] button = new string[num];
   
   for( cnt = 0; cnt < num; cnt++ )
   {
     button[cnt] = Console.ReadLine();
   }
   
   for( cnt = 0; cnt < num; cnt++ )
   {
     pushNum++;
     
     if( button[readPos] == "2" )
     {
		break;
     }
     else
     {
      readPos = int.Parse(button[readPos]) - 1;
     }
   }
   
   if( cnt == num )
   {
     pushNum = -1;
   }
   
   Console.WriteLine(pushNum);
 }
}

Measured memory_bytes: 15712
#include <iostream>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

bool isMonth(int v) {
    return (1 <= v && v <= 12);
}

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

    int head, end;
    head = stoi(S.substr(0, 2));
    end = stoi(S.substr(2, 2));

    if (isMonth(head)) {
        if (isMonth(end)) printf("AMBIGUOUS");
        else printf("MMYY");
    } else {
        if (isMonth(end)) printf("YYMM");
        else printf("NA");
    }

    printf("\n");
    return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a[3];

  rep(i,0,3){
    scanf("%d",&a[i]);
  }
  sort(a,a+3);
  printf("%d\n", a[0]+a[1]);

  return 0;
}

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



int main(){
  char t[20];
  int dat[20];
  int i=0;
  int amari,cn=0,zc=0,tv;
  cin >> t;
  while (t[i]!='\0'){
    dat[i]=t[i]-'0';
    i++;
  }
  if (dat[0]==0){
    cout << 0 << endl;
    return 0;
  }
  while(zc<i){
    amari=0;
    for (int j=zc;j<i;j++){
      tv=dat[j]+amari*10;
      amari=tv%2;
      dat[j]=tv/2;
    }
    if (dat[zc]==0)zc++;
    cn++;
  }
  cout << cn << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  string s;
  map<string,long long> m{};
  
  for(int i = 0;i<n;i++){
    cin >> s;
    sort(s.begin(), s.end());
    
    if(m.count(s) == 0){
      m.insert(make_pair(s,1));
    }else{
      m[s] = m[s] + 1;
    }
  }
  long long res = 0;
  for( auto i = m.begin(); i != m.end() ; ++i ) {
    if(i->second >1){
      //cout << i->second << " "<<i->second<< endl;
      res += (i->second)*(i->second-1)/2;
    }
  }
 

  
  cout << res;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000009;

int p[50], t[50];
int dp[50][10];
int n;

int main()
{
    while(~scanf("%d",&n),n)
    {
        for(int i=1; i<=n; i++)
        {
            int tx,ty;
            scanf("%d%d",&tx,&ty);
            p[i] = tx, t[i] = ty;
        }
        p[0] = 0, t[0] = 0;
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=3;j++)
            {
                dp[i][j] = INF;
            }
        }

        dp[0][0] = 0;

        int flag ;
        int se = -1;

        for(int i=1; i<=n; i++)
        {
            flag=0;

            for(int j=0; j<=3; j++)
            {
                if(dp[i-1][j] != INF)
                {
                    if(j == 3)
                    {
                        if(4*p[i-1] + p[i] + t[i-1] <= t[i])
                            dp[i][1] = min(dp[i][1],dp[i-1][3] + p[i] + p[i-1]);
                        //else
                           // flag = 1, se = i;
                    }
                    else
                    {
                        if( ((abs(p[i] - p[i-1])) * (j+1) + t[i-1] > t[i]) && ( (j+1)*p[i-1] + p[i] + t[i-1] > t[i] ))
                        {
                            /*flag = 1, se = i;printf("NO\n");*/
                        }
                        else
                        {
                            //int temp = 1000000009;
                            if ((abs(p[i] - p[i-1])) * (j+1) + t[i-1] <= t[i])
                            {
                                /*//printf("%d")printf("NO1\n");*/
                                 dp[i][j+1] = min(dp[i][j+1],dp[i-1][j] + abs(p[i] - p[i-1]));
                            }

                            if ((j+1) * p[i-1] + p[i] + t[i-1] <= t[i])
                            {
                                //printf("NO2\n");
                                if(j > 0)
                                    dp[i][1] = min(dp[i][1],dp[i-1][j] + p[i] + p[i-1]);
                            }
                        }
                    }
                }
            }

            for(int j=0;j<=3;j++)
            {
                if(dp[i][j] < INF)
                {
                    flag = 1;
                    break;
                }
            }

            if(!flag)
            {
                se = i;
                break;
            }
        }

       /* for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=3;j++)
            {
                printf("%9d ",dp[i][j]);
            }
            printf("\n");
        }*/
        if(!flag)
        {
            printf("NG %d\n",se);
        }
        else
        {
            int mint = 1000000009;

            for(int i=0;i<=3;i++) if(mint > dp[n][i]) mint=dp[n][i];
            printf("OK %d\n",mint+p[n]);
        }
    }
    return 0;
}

/*

2
10 100
100 270
2
10 100
100 280
3
100 150
10 360
40 450
3
100 150
10 360
40 440
2
100 10
50 200
2
100 100
50 110
1
15 10
4
1 10
2 20
3 100
90 200
0
*/

Measured memory_bytes: 1188
#include<stdio.h>
int main() {
	int x;
	scanf("%d", &x);
		if (400 <= x && x <= 599)
			printf("8");
		if (600 <= x && x <= 799)
			printf("7");
		if (800 <= x && x <= 999)
			printf("6");
		if (1000 <= x && x <= 1199)
			printf("5");
		if (1200 <= x && x <= 1399)
			printf("4");
		if (1400 <= x && x <= 1599)
			printf("3");
		if (1600 <= x && x <= 1799)
			printf("2");
		if (1800 <= x &&x<= 1999)
			printf("1");
	
	return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#define N 200000
int main(){
	int n,i,j,max,min;
	int a[N];
	scanf("%d",&n);
	//scanf("%d",&a[0]);
	
	for(i = 0; i < n; i++){
		scanf("%d",&a[i]);
		//max = mac(max,a[i - 1],a[i]);
	}
	min = a[0];
	max = a[1] - a[0];
	for(i = 1; i < n; i++){
    	if(max < a[i] - min) max = a[i] - min;
    	if(min > a[i]) min = a[i];
  	}
	printf("%d\n",max);

	return 0;
}



Measured memory_bytes: 2492
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);

int main() {
  FASTIO
  int n; cin >> n; 
  bool res = false;
  while(n > 0) {
    if(n%10 == 7) {
      res = true;
      break;
    }
    n = n/10;
  }
  if(res) {
    cout << "Yes\n";
  }  else {
    cout << "No\n";
  }

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int n = read();
    vector<int> V(n);
    for (auto& v:V) v = read();
    map<int, int> M[2];
    int value[2][2] = {{}}, key[2][2] = {{}};
    for (int i = 0; i < n; i++) M[i%2][V[i]]++;
    for (int i = 0; i<2; i++)
        for (auto m:M[i]) {
            if (m.second > value[i][0]) {
                key[i][1] = key[i][0];
                key[i][0] = m.first;
                value[i][1] = value[i][0];
                value[i][0] = m.second;
            }
            else if (m.second > value[i][1]) {
                key[i][1] = m.first;
                value[i][1] = m.second;
            }
        }
    int ans;
    if (key[0][0] != key[1][0]) ans = n-value[0][0]-value[1][0];
    else ans = n-max(value[0][0]+value[1][1], value[1][0]+value[0][1]);
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main(){
	int n;
	cin >> n;
	if(n/100 == 7) cout << "Yes" << endl;
	else if((n%100)/10 == 7) cout << "Yes" << endl;
	else if(n%10 ==7) cout << "Yes"<< endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

A, B, C, D, E, F = map(int, input().split())
if C > D:
    C, D = D, C

mx_rate = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        total = (i * A + j * B) * 100
        if total > F:
            continue
        sugar_limit = min(F - total, (total // 100) * E)
        if sugar_limit > 0:
            for k in range(sugar_limit // C + 1):
                sugar_total = k * C
                if sugar_total < sugar_limit:
                    sugar_total += ((sugar_limit - sugar_total) // D) * D
                rate = 100 * sugar_total / (sugar_total + total)
                if rate >= mx_rate:
                    mx_rate = rate
                    ans_water = total + sugar_total
                    ans_sugar = sugar_total
print(ans_water, ans_sugar)



Measured memory_bytes: 9492
#include<bits/stdc++.h>
#define _ 0
using namespace std;
const double pi = acos(-1);
char a[105],b[105];

int main(){
	scanf(" %s",a);
	scanf(" %s",b);
	int lena = strlen(a);
	int lenb = strlen(b);
	if(lena > lenb) return 0^_^0 & puts("GREATER");
	else if( lena < lenb) return 0^_^0 & puts("LESS");
	else {
		 for(int i = 0; i < lena; i++) {
		 	 if(a[i] > b[i]) return 0^_^0 & puts("GREATER");
			 if(a[i] < b[i]) return 0^_^0 & puts("LESS");
		    }
		}

	return 0^_^0 & puts("EQUAL");
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

int A,B;

void solve() {
	if (A > 0) {
		cout << "Positive" << endl;
		return;
	}

	ll size = B - A;
	if (size % 2 != 0) {
		cout << "Positive" << endl;
	}
	else {
		cout << "Negative" << endl;
	}
}

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

	if (A <= 0 && B >= 0) {
		cout << "Zero" << endl;
	}
	else {
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int x[2019][2019];
int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll l,r;
    cin >> l >> r;
    int min=INF;
    rrep1(i,l,r){
        int a=i%2019;
        rrep1(j,i+1,r){
            int b=j%2019;
            if (x[a][b]!=0)
            {
                cout << min;
                return 0;
            }
            int c=a*b%2019;
            if (c<min)
            {
                min=c;
                if (min ==0)
                {
                    cout << min;
                    return 0;
                } 
            }
        }
    }
    cout << min;
    
    return 0;
}


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

void solve() {
    int a, b, c,d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>

#include <cassert>
#include <cmath>
#include <ctime>

#pragma comment(linker, "/STACK:200000000")

using namespace std;

mt19937 mt (736);

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
	int n, m, x;

	cin >> n >> m >> x;

	vector<int> arr (m);

	for (auto &it : arr)
		cin	>> it;

	auto it = lower_bound (arr.begin (), arr.end (), x);

	cout << min (it - arr.begin (), arr.end () - it) << endl;
}

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

#ifdef LOCAL
    solve ();

    cout << "clock: " << clock () << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	k = int(sys.stdin.readline())
	s = sys.stdin.readline().rstrip()
	if len(s) <= k:
		print(s)
		exit()
	s = s[:k]
	print(s + "...")
	


main()

Measured memory_bytes: 68384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int max = 0;
		int[] data = new int[100];
		try {
			while ((str = br.readLine()) != null) {
				data[Integer.parseInt(str) - 1]++;
			}
			
			for(int i = 0; i < 100; i++) {
				max = Math.max(data[i], max);
			}
			
			for(int i = 0; i < 100; i++) {
				if(max == data[i]) System.out.println(i+1);
			}
		} catch(IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 16860
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[5]="RGBY";
ll a[100000];
int parent[100000];
int find(int a)
{
	if (parent[a] < 0)return a;
	return parent[a] = find(parent[a]);
}
void merge(int a, int b)
{
	a = find(a), b = find(b);
	if (a != b)
	{
		parent[a] += parent[b];
		parent[b] = a;
	}
}
map<int,Vll> M;
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	if(m==n-1)return !printf("0");
	if(n<2*(n-m-1))return !printf("Impossible");
	MEM_1(parent);
	fup(i,0,n-1,1)scanf("%lld",a+i);
	fup(i,0,m-1,1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		merge(x,y);
	}
	fup(i,0,n-1,1)
		M[find(i)].pb(a[i]);
	ll ans=0;
	int cnt=0;
	priority_queue<ll,Vll,greater<ll> > q;
	for(auto it=M.begin();it!=M.end();it++)
	{
		Vll &v=it->Y;
		sort(ALL(v));
		ans+=v[0],cnt++;
		fup(i,1,(int)v.size()-1,1)q.push(v[i]);
	}
	while(cnt<2*(n-m-1))
	{
		ans+=q.top();
		q.pop();
		cnt++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 7936
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	ll X, K, D;
	cin >> X >> K >> D;
	if (abs(X) / D > K) cout << abs(X) - D * K << endl;
	else {
		K -= abs(X) / D;
		X %= D;
		ll a = abs(X), b = D - abs(X);
		// cout << a << " " << b << endl;
		if (K % 2 == 0) cout << a << endl;
		else cout << b << endl;
	}
	return 0;
}

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

using namespace std;
typedef priority_queue<int> Pr;

int main() {
    long long n;
    cin >> n;
    Pr a;
    int u = 0;
    for(long long i = 0; i < n; i ++) {
        cin >> u;
        a.push(u);
    }
    int j = 0;
    for(long long i = 0; i < n - 1; i ++){
        int g = a.top();
        a.pop();
        int v = a.top();

        if(g == v){
            cout << "NO" << endl;

            j = 0;
            break;
        }else{
            j = 1;
        }
    }
    if (j == 1)cout << "YES" << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int max1 = max(b,c);
    int max2 = max(a,max1);
    cout << a+b+c-max2 << endl;
}

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

int main() {
	ll n, m = 1000, k = 0;
	cin >> n;
	vector<ll> a(n);

	rep(i,n) cin >> a[i];
	rep(i,n-1) {
		if(a[i] >= a[i+1]) {
			m += k * a[i];
			k = 0;
		}
		if(a[i] <= a[i+1] && m >= a[i]) {
			k += m / a[i];
			m -= k * a[i];
		}

	}

	if(k != 0) m += k * a[n-1];

	cout << m <<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <map>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[101];
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  map<int,int> num;
  for(int i = 0; i < N; i++){
    num[d[i]]++;
  }
  cout << num.size() << endl;
  return 0;
}

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

int h[100008], dp[100008];

int main() 
{
  int n ;cin>>n;
  for(int i=0;i< 100008; i++) { dp[i] = 1e9 ;  if(i<n) cin>>h[i] ;}
  dp[0]=0 ;
  dp[1]= abs(h[1]-h[0]) ;
  
  for(int i=2 ; i<n ; i++)
  { 
    dp[i] = min( dp[i], abs(h[i] - h[i-2]) + dp[i-2]);
    dp[i] = min( dp[i], abs(h[i] - h[i-1]) + dp[i-1]);
  }  
  
  cout << dp[n-1] ;
  return 0 ; 
}


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


void solve() {

  string s;
  cin >> s;
  string ans = "Sunny";
  if (s=="Sunny") {
    ans = "Cloudy";
  } else if(s== "Cloudy") {
    ans = "Rainy";
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H,i,A[MAX+1];

  cin>>H;
  for(i=1;i<=H;i++) cin>>A[i];

  for(i=1;i<=H;i++){
    cout<<"node "<<i<<": key = "<<A[i]<<", ";
    if(parent(i)>=1) cout<<"parent key = "<<A[parent(i)]<<", ";
    if(left(i)<=H) cout<<"left key = "<<A[left(i)]<<", ";
    if(right(i)<=H) cout<<"right key = "<<A[right(i)]<<", ";
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll n;
    cin >> n;
    
    ll a[n], delta[n], s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    ll rm_sum = n * (n+1) / 2;
    
    if (s % rm_sum != 0) {
        cout << "NO" << endl;
    } else {
        ll k = s / rm_sum;
        for (int i = 0; i < n; ++i) {
            delta[i] = a[(i+1)%n] - a[i];
            if (delta[i] - k > 0 || (k - delta[i]) % n != 0) {
                cout << "NO" << endl;
                return 0;
            }
            
        }
        cout << "YES" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)
	
	ans := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				ans += gcd(gcd(a,b),c)
			}
		}
	}
	fmt.Println(ans)
}

func gcd(num1,num2 int)int {
	for num2 != 0{
		r := num1 % num2
		num1 = num2
		num2 = r
	}
	return num1
}

Measured memory_bytes: 1776
import java.io.*;
import java.util.*;

class Main {

	private static class UnionFind {
		int[] parent;

		public UnionFind(int n) {
			parent = new int[n];

			for (int i = 0; i < n; i++) {
				parent[i] = i;
			}
		}

		public boolean union(int v, int w) {
			int a = root(v);
			int b = root(w);
			if (a == b) return false;
			parent[a] = parent[b];
			return true;
		}

		public boolean connected(int v, int w) {
			return root(v) == root(w);
		}

		public void clear() {
			for (int i = 0; i < parent.length; i++) {
				parent[i] = i;
			}
		}

		public int id(int v) {
			return parent[v];
		}

		private int root(int v) {
			while (parent[v] != parent[parent[v]]) parent[v] = parent[parent[v]];
			return parent[v];
		}
	}

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		for (int i = 0; i < M; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
		}

		int answer = 0;
		UnionFind uf = new UnionFind(N);
		for (int i = 0; i < M; i++) {
			uf.clear();
			for (int j = 0; j < M; j++) {
				if (i == j) continue;
				uf.union(a[j], b[j]);
			}

			int count = 0;
			for (int j = 0; j < N; j++) {
				if (uf.id(j) == j) {
					count++;
				}
			}
			if (count > 1) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    int n;  cin >> n;
    map<int, int> a;
    a[0] = 3;
    ll res=1;
    REP(i, n){
        int x;  cin >> x;
        res *= a[x];
        res %= MOD;
        a[x] -= 1;
        a[x+1] += 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 1000000007
dp = [INF] * (N + K)
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[N - 1])


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

double calc(long long x){
	long long sum = 0, rec = x;
	while (rec){
		sum += rec % 10;
		rec /= 10;
	}
	return 1.0 * x / sum;
}

int main(){
	int k;
	long long ans, x;
	cin >> k;
	ans = 0; x = 1;
	for (int i = 1; i <= k; i++){
		while (true){
			if (calc(ans + x) <= calc(ans + x * 10)) break;
			x *= 10;
		}
		ans += x;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[5];
  for(int i=0; i<5; i++)cin>>a[i];
  for(int i=0; i<5; i++)
  {
    if(a[i]==0){cout<<i+1<<endl;break;}
  }
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

signed main(){
	int A,B;
	cin>>A>>B;
	int g=gcd(A,B);

	int ans=1;
	for(int i=2;i*i<=g;i++){
		if(g%i)continue;
		ans++;
		while(g%i==0)g/=i;
	}
	if(g!=1)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

ll dp[101010][2];

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

	vector<ll>a(n);
	rep(i, 0, n)cin >> a[i];

	dp[0][0] = a[0];
	dp[0][1] = -a[0];

	rep(i, 1, n) {
		dp[i][0] = max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
		dp[i][1] = max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
	}
	cout << dp[n - 1][0] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 50
int d[MAX_V][MAX_V];
int V;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M;
	cin >> V >> M;
	vector<int> a(M), b(M);
	rep(i, 0, V) rep(j, 0, V) {
		if(i == j) d[i][j] = 0;
		else d[i][j] = 1e9;
	}
	rep(i, 0, M) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		d[a[i]][b[i]] = 1;
		d[b[i]][a[i]] = 1;
	}

	int rsl = 0;
	rep(i, 0, M) {
		rep(j, 0, V) rep(k, 0, V) {
			if(j == k) d[j][k] = 0;
			else d[j][k] = 1e9;
		}
		rep(j, 0, M) {
			d[a[j]][b[j]] = 1;
			d[b[j]][a[j]] = 1;
		}
		d[a[i]][b[i]] = 1e9;
		d[b[i]][a[i]] = 1e9;
		warshall_floyd();
		rep(j, 0, V) {
			bool flag = false;
			rep(k, j + 1, V) {
				if(d[j][k] == 1e9) {
					flag = true;
					break;
				}
			}
			if(flag) {
				rsl++;
				break;
			}
		}
		d[a[i]][b[i]] = 1;
		d[b[i]][a[i]] = 1;
	}

	cout << rsl << endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;

void insert(int);
void inorder(Node);
void preorder(Node);

int main(){

  int n, i, x;
  char com[10];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  
  if ( y == NIL ){
    root = z;
  }
  else if (z->key < y->key) {
    y->left = z;
  }
  else {
    y->right = z;
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 24040
#include<cstdio>
#include<iostream>
using namespace std;
int a[1000010];
int main()
{
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(a[1]) 
	{
		cout<<"-1";
		return 0;
	}
	for(int i=1;i<=n;i++) if(a[i]-a[i-1]>=2)
	{
		cout<<"-1";
		return 0;
	}
	for(int i=1;i<=n;i++) 
	{
		if(a[i]==a[i-1]+1) ans++;
		else ans+=a[i];
	}
	cout<<ans;
	return 0;
}

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

int		main()
{
	int n;
	double m;
	cin >> n >> m;
	vector<int> v(n);
	double total = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		total += v[i];
	}
	int c = 0;
	double hoge = total / (4.0 * m);
	//cout << hoge << endl;
	for (int i = 0; i < n; i++)
	{
		if (v[i] >= hoge)c++;
	}
	cout << (c >= m ? "Yes" : "No") << endl;
	
}



Measured memory_bytes: 256
n = gets.to_i
$e = Array.new(n+1,0)
2.upto(n) do |i|
    cur = i
    2.upto(i) do |j|
        while cur % j == 0
            $e[j] += 1
            cur /= j
        end
    end
end

def num(m)
    $e.count{|v| v >= m - 1}
end

puts num(75) + num(25) * (num(3)-1) + num(15) * (num(5)-1) + num(5) * (num(5)-1) * (num(3)-2) / 2


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

using ll = long long;

int main(){
    int n;
    cin>>n;
    string s;
    int flag=1;
    int count=0;
    cin>>s;
    if(n%2!=0)
    flag=0;
    else{
        int j=n/2;
        for(int i=0;i<n/2;i++,j++){
        if(s[i]!=s[j])
        flag=0;
        }
    }
    if(flag==0)
    cout<<"No";
    else
    cout<<"Yes";
    
    
    return 0;
}


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

#define INF (1 << 20)

using namespace std;

int W, H;

struct pos{
	int x1;
	int y1;
	int x2;
	int y2;
};

int DP[60][60][60][60];

int map_[60][60];

bool map(int x, int y){
	if(x < 0 || y < 0 || x >= W || y >= H){
		return false;
	}else if(map_[x][y] == 1){
		return false;
	}
	return true;
}

int main(){
	
	int dx_[4] = {1, 0, -1, 0};
	int dy_[4] = {0, 1, 0, -1};
	
	while(true){
		cin >> W >> H;
		if(W == 0 && H == 0){
			break;
		}
		
		int tx, ty, kx, ky;
		cin >> tx >> ty >> kx >> ky;
		tx--;
		ty--;
		kx--;
		ky--;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cin >> map_[j][i];
			}
		}
		
		for(int i = 0; i <= 50; i++){
			for(int j = 0; j <= 50; j++){
				for(int k = 0; k <= 50; k++){
					for(int l = 0; l <= 50; l++){
						DP[i][j][k][l] = INF;
					}
				}
			}
		}
		
		queue<pos> que;
		pos pos_first;
		pos_first.x1 = tx;
		pos_first.y1 = ty;
		pos_first.x2 = kx;
		pos_first.y2 = ky;
		que.push(pos_first);
		
		DP[tx][ty][kx][ky] = 0;
		
		for(int step = 1; step <= 100; step++){
			
			if(que.empty()){
				break;
			}
			
			//cout << que.size() << endl;
			
			queue<pos> que_copy;
			
			while(true){
				
				if(que.empty()){
					break;
				}
				
				pos p = que.front();
				que.pop();
				for(int i = 0; i < 4; i++){
					int dx1 = dx_[i];
					int dy1 = dy_[i];
					int dx2 = -dx1;
					int dy2 = -dy1;
					if(!map(p.x1 + dx1, p.y1 + dy1)){
						dx1 = 0;
						dy1 = 0;
					}
					if(!map(p.x2 + dx2, p.y2 + dy2)){
						dx2 = 0;
						dy2 = 0;
					}
					pos pp;
					pp.x1 = p.x1 + dx1;
					pp.y1 = p.y1 + dy1;
					pp.x2 = p.x2 + dx2;
					pp.y2 = p.y2 + dy2;
					//cout << pp.x1 << " " << pp.y1 << " " << pp.x2 << " " << pp.y2 << " " << step << endl;
					if(DP[pp.x1][pp.y1][pp.x2][pp.y2] != INF){
						continue;
					}
					DP[pp.x1][pp.y1][pp.x2][pp.y2] = step;
					que_copy.push(pp);
				}
				
			}
			
			que = que_copy;
			
		}
		
		int ans = INF;
		
		for(int i = 0; i < W; i++){
			for(int j = 0; j < H; j++){
				if(DP[i][j][i][j] < ans){
					ans = DP[i][j][i][j];
				}
			}
		}
		
		if(ans == INF){
			cout << "NA" << endl;
		}else{
			cout << ans << endl;
		}
		
	}
	
	return 0;
}

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

using namespace std;

int main(){
    int x,i;
    cin >>x;
    if(x==2){
        cout <<2<<endl;
        return 0;
    }else if(x==3){
        cout <<3<<endl;
        return 0;
    }else{
        for(int h=0;h>-1;h++){
            int y=sqrt(x+h);
            vector<int> judge(y+1,1);
            judge[0]=0;
            judge[1]=0;
            for(i=2;i<sqrt(x+h);i++){
                if((h+x)%i==0){
                    break;
                }else{
                    judge[i]=0;
                }
            }
            if(!std::accumulate(judge.begin(),judge.end(),0)){
                cout <<x+h<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

res = min(a) + min(b)
for _ in range(M):
  x, y, c = map(int, input().split())
  discounted_v = a[x-1] + b[y-1] - c
  if discounted_v < res: res = discounted_v
  
print(res)
  
           




Measured memory_bytes: 24832
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e8
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    bool kill = false;
    ll mod = 998244353;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    if(v[0]!=0) {
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(v));
    ll ans = 1;
    if(v.size()==1) {
        if(v[0]==0) {
            cout << 1 << endl;
        }
        else cout << 0 << endl;
        return 0;
    }
    if(v[0]!=0 || v[1]==0) {
        cout << 0 << endl;
        return 0;
    }
    if(v[1]!=1) {
        cout << 0 << endl;
        return 0;
    }
    ll pre = 1;
    ll cnt = 0;
    ll now = 1;
    v.push_back(0);
    REP(i,1,n) {
        ans *= pre;
        ans %= mod;
        cnt++;
        if(v[i+1]!=v[i]) {
            if(v[i+1]!=0 && v[i+1]!=(v[i]+1)) {
                cout << 0 << endl;
                return 0;
            }
            pre = cnt;
            cnt = 0;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string s;int n,res,cnt;
int main(){
	cin>>s;
	n=s.size();
	for(int i=0;i<n;++i){
		++cnt;
		if(s[i]!='A'&&s[i]!='C'&&s[i]!='T'&&s[i]!='G')
			cnt=0;
		res=max(res,cnt);
	}
	printf("%d\n",res);
	return 0;
}

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

const int b = 540;
int main(){
    while(1){
        int pc,stu;
        cin >> pc >> stu;
        if(pc==0) break;
        
        int r;
        cin >> r;
        vector<vector<int> > log(stu+1, vector<int>(730, 0));
        for(int i=0; i<r; i++){
            int t,n,m,s;
            cin >> t >> n >> m >> s;
            log[m][t-b] += s*2-1;
        }
        for(int i=1; i<=stu; i++){
            for(int j=1; j<730; j++){
                log[i][j] += log[i][j-1];
            }
        }
        
        int q;
        cin >> q;
        for(int i=0; i<q; i++){
            int s,e,who;
            cin >> s >> e >> who;
            int count=0;
            for(int j=s-b; j<e-b; j++){
                if(log[who][j]>0) count++;
            }
            cout << count << endl;
        }
    }
    return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

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

signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int bc, bd, bcd;
    int ac, ad, acd;
    bc = B / C;
    bd = B / D;
    bcd = B / (C * D / gcd(C, D));
    ac = (A - 1) / C;
    ad = (A - 1) / D;
    acd = (A - 1) / (C * D / gcd(C, D));
    int ans = B - (A - 1) - (bc + bd - bcd - ac - ad + acd);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100009];
int arr[100009];
ll sum = 0;
int k;
long long Frog1(int n){
 
    if(n==0) return 0;
 
    else if(dp[n]!=-1) return dp[n];
    else {
            ll sum = INT_MAX;
            for(int i=n-1,j=1;i>=0 && j<=k;i--,j++ ){
 
                ll x;
                if(dp[i]!=-1) x = dp[i];
                else x = Frog1(i);
 
                x = abs(arr[i] - arr[n]) + x;
                sum = min(sum,x);
                //cout << n  << " " << i  << " " << j << endl;
            }
            dp[n] = sum;
            return sum;
    }
}
 
 
int main()
{
    int n;
    memset(dp,-1,sizeof(dp));
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> arr[i];
    cout << Frog1(n-1) << endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF (llong)1e18+5
#define INF 1e9+1
#define endl '\n'

using namespace std;
using llong = long long;
using VI = vector<int>;
using VLL = vector<long long>;
using PII = pair<int, int>;

//struct cmp {
//	bool operator() (pair<PII, int> a, pair<PII, int> b)
//	{
//		return a.ss > b.ss;
//	}
//};

int main()
{
	IOS;
	
	int l, r, d;
	cin >> l >> r >> d;
	if (r % d == 0 || l % d == 0) cout << (r - l) / d + 1;
	else cout << (r - l) / d;

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int H = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    
    String[] t = sc.nextLine().split(" ");
    int h = Integer.parseInt(t[0]);
    int w = Integer.parseInt(t[1]);
    
    System.out.println((H-h) * (W-w));
  }
}

Measured memory_bytes: 21844