akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
struct Node{
    int num;
    int no;
    int c;
    vector<Node*> edge;
    void build(int i){
        no=i;
        num=edge.size();
        c=3;
    }
};
signed main(){
    int n,m;cin>>n>>m;
    vector<int> a(m);
    vector<int> b(m);
    vector<Node> node(n+1);
    rep(i,m){
        cin>>a[i]>>b[i];
        node[a[i]].edge.push_back(&node[b[i]]);
        node[b[i]].edge.push_back(&node[a[i]]);
    }
    rep1(i,n){
        node[i].build(i);
    }
    bool binary_graph=true;
    queue<Node> que;
    node[1].c=1;que.push(node[1]);
    while(!que.empty()){
        Node buf=que.front();que.pop();
        rep(i,buf.num){
            if(buf.edge[i]->no==buf.no)continue;
            //printf("node[%d].c=%d\n",buf.edge[i]->no,buf.edge[i]->c);
            if(buf.edge[i]->c==3){
                buf.edge[i]->c=buf.c*2%3;
                que.push(*buf.edge[i]);
            }
            else{
                if(buf.c==buf.edge[i]->c){
                    binary_graph=false;
                    goto FINE;
                }
                else{
                    //continue;
                }
            }
        }
    }
    FINE:
    if(binary_graph){
        int T=0;int F=0;
        rep1(i,n){
            if(node[i].c==1){
                T++;
            }
            else F++;
        }
        int sub=0;
        rep(i,m){
            if(node[a[i]].c!=node[b[i]].c){
                sub++;
            }
        }
        //cout<<sub<<endl;
        //cout<<T*F<<endl;
        long long res=T;
        res*=F;
        res-=sub;
        cout<<res<<endl;
    }
    else{
        long long res=n;
        res*=(n-1);
        res/=2;
        res-=m;
        cout<<res<<endl;
    }
    rep1(i,n){
        //printf("c[%d]=%d\n",i,node[i].c);
    }
    if(binary_graph){
        //cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 12672
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    vector<ll> c(27,0);
    for(ll i=0;i<26;++i)cin>>c[i+1];
    vector<vector<ll>> S(D+1, vector<ll>(27, 0));
    for(ll i=0;i<D;++i)
        for(ll j=0;j<26;++j)cin>>S[i+1][j+1];
    vector<ll> last(27,0);
    vector<ll> t(D+1,0);
    for(ll i=0;i<D;++i)cin>>t[i+1];
    ll score=0;
    for(ll i=1;i<=D;++i){
        last[t[i]]=i;
        score+=S[i][t[i]];
        for(ll j=1;j<=26;++j)score-=c[j]*(i-last[j]);
        prt(score);
    }
    fl;

    return 0;
}



Measured memory_bytes: 3732
#include<iostream>
#include<cmath>

using namespace std;

#define EPS 1e-5

struct point{
	double x;
	double y;
};
struct line{
	double a;
	double b;
};

int recog_point_position( const point& a , const point&b , const point& c );
bool get_line( const point& a , const point& b , line *a_b );
inline istream& operator >> ( istream& s , point& p );

int main(void)
{
	point a, b, c, p;

	while(1)
	{
		cin >> a >> b >> c >> p;
		if( cin.eof() ) break;

		int result_ab_c = recog_point_position( a , b , c );
		int result_ab_p = recog_point_position( a , b , p );
		int result_bc_a = recog_point_position( b , c , a );
		int result_bc_p = recog_point_position( b , c , p );
		int result_ca_b = recog_point_position( c , a , b );
		int result_ca_p = recog_point_position( c , a , p );

		cout << (( result_ab_c == result_ab_p && result_bc_a == result_bc_p && result_ca_b == result_ca_p ) ? "YES" : "NO") << endl;
	}

	return 0;
}

int recog_point_position( const point& a , const point& b , const point& c )
{
	line a_b;

	bool result = get_line( a , b , &a_b );
	if( result == false )
	{
		if( (a.x + b.x)/2 < c.x ) return 1; // 点が直線より右にある場合に1をリターン
		else return 0;
	}
	else if( result == true )
	{
		if( c.y > a_b.a * c.x + a_b.b ) return 1; // 点が直線より上にある場合に1をリターン
		else return 0;
	}

}

bool get_line( const point& a , const point& b , line *a_b )
{
	if( fabs(a.x - b.x) < EPS )
	{
		return false;
	}
	else
	{
		a_b->a = (a.y - b.y) / (a.x - b.x);
		a_b->b = a.y - a_b->a * a.x;

		return true;
	}
}

inline istream& operator >> ( istream& s , point& p )
{
	return s >> p.x >> p.y;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long int 
using namespace std;

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


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

	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> s[i][j];
		}
	}
	
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (s[i][j] == '#') {
				bool f = false;
				for (int r = 0;r < 4;r++) {
					if (s[i + dx[r]][j + dy[r]] == '#') {
						f = true;
						break;
					}

				}
				if (!f) {
					cout << "No" << endl;
					return 0;
				}
				
			}
		}
	}
	

	cout << "Yes" << endl;

	return 0;
}

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

using namespace std;

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

ll mod = 1e9 + 7;


int n;
char s[100005];
ll dp[100005][13];

int main(){
	int n;
	cin >> n;
	int d[100];

	for(int i=0;i<n;i++) cin >> d[i];

	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans += d[i]*d[j];
		}
	}

	cout << ans << endl;

	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           int[] AB = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = AB[0];
            int B = AB[1];
            Console.WriteLine(A * B);
        }
    }
}

Measured memory_bytes: 27992
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int main(){
    int n, m;
    cin>>n>>m;
    cout << max(0, n-2*m) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
vll d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sortc(string &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a == b && b != c) Yes();
  else if (b == c && c != a) Yes();
  else if (c == a && a != b) Yes();
  else No();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll large_P = 1e9 + 7;

int main(){
  ll N, X, Y;
  cin >> N >> X >> Y;
  
  Graph G(N);
  rep(i, N){
    if(i < N-1) G.at(i).push_back(i+1);
    if(i > 0) G.at(i).push_back(i-1);
  }
  
  G.at(X-1).push_back(Y-1);
  G.at(Y-1).push_back(X-1);
    
  vector<ll> distance_selection(N, 0); // 0 ~ N-1
  
  
  rep(i, N){
    vector<ll> distance(N, -1); // 0 ~ N-1
    distance.at(i) = 0;
    queue<ll> que; que.push(i);
    
    while(!que.empty()){
      ll v = que.front(); que.pop();
      
      for(ll next_v : G.at(v)){
        if(distance.at(next_v) != -1) continue;
        distance.at(next_v) = distance.at(v) + 1;
        que.push(next_v);
      }
    }
    rep(j, N) distance_selection.at(distance.at(j)) ++;
  }
  
  
  
  //rep(i, N){
    //rep(j, G.at(i).size()){
      //cout << G.at(i).at(j)+1 << ", ";
    //}
    //cout << endl;
  //}
  
  
  for(int i=1; i<N; i++) cout << distance_selection.at(i)/2 << endl;
  //for(int i=0; i<N; i++) cout << distance_selection.at(i) << endl;
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  llong N, K;
  cin >> N >> K;
  cout << min(N%K, abs(N%K-K)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
  ll N,Y;
  cin>>N>>Y;
  int flag=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
        int k=N-i-j;
        if(k<0) continue;
        ll ans=10*i+5*j+k;
        if(1000*ans==Y){
          cout<<i<<" "<<j<<" "<<k<<endl;
          flag=1;
          return 0;
        }
    }
  }
  if(flag==0){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = -1;
    for(int64_t bit = 0; bit < (1 << n); bit++){
        int tmp = 0;
        vector<int> algo(m);
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                tmp += c[i];
                for(int j = 0; j < m; j++){
                    algo[j] += a[i][j];
                }
            }
        }
        for(int i = 0; i < m; i++){
            if(algo[i] < x){
                tmp = -1;
                break;
            }
        }
        if(tmp != -1){
            if(ans == -1) ans = tmp;
            else ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A){
    i64 sum = 0;
    rep(i, N) sum += A[i];
    i64 cnt = 0;
    rep(i, N) if(A[i] * 4 * M >= sum) ++cnt;
    if(cnt >= M) cout << YES << endl;
    else cout << NO << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    
}

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

using namespace std;

class BlackAndWhiteBoxes {
public:
    BlackAndWhiteBoxes(int n) : n(n), pile(n, make_pair(0.0, 0)) {}
    void Input();
    int MaximumBoxes();
private:
    int n; // ?±±?????°
    vector<pair<double, int>> pile; // pile[i] := i??????????±±???????????????????????±?????°

    double GameValue(const string p);
};

double BlackAndWhiteBoxes::GameValue(const string p) {
    int idx = 1;
    while (idx < p.size() && p[0] == p[idx])
        ++idx;

    double v = (p[0] == 'B' ? idx : -idx);
    for (double two_pow = 2.0; idx < p.size(); two_pow *= 2.0, ++idx)
        v += (p[idx] == 'B' ? 1.0 / two_pow : -1.0 / two_pow);

    return v;
}

void BlackAndWhiteBoxes::Input() {
    string p;
    for (int i = 0; i < n; ++i) {
        cin >> p;
        pile[i] = make_pair(GameValue(p), p.size());
    }
}

int BlackAndWhiteBoxes::MaximumBoxes() {
    const int n1 = n / 2, INF = 40 * 100;
    vector<pair<double, int>> vl(1 << n1, make_pair(0.0, 0));
    for (int i = 0; i < 1 << n1; ++i) {
        for (int j = 0; j < n1; ++j)
            if (i >> j &1) {
                vl[i].first += pile[j].first;
                vl[i].second += pile[j].second;
            }
    }

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

    int max_size = 0;
    for (int i = 0; i < 1 << (n - n1); ++i) {
        double sum_v = 0.0;
        int sum_len = 0;

        for (int j = 0;  j < n - n1; ++j)
            if (i >> j & 1) {
                sum_v += pile[n1 + j].first;
                sum_len += pile[n1 + j].second;
            }

        auto it = lower_bound(vl.begin(), vl.end(), make_pair(-sum_v, INF));
        if (it != vl.begin())
            --it;

        if (max_size < it->second + sum_len && it->first == -sum_v)
            max_size = it->second + sum_len;
    }

    return max_size;
}

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

    int n;

    cin >> n;
    BlackAndWhiteBoxes bwb(n);
    bwb.Input();

    cout << bwb.MaximumBoxes() << endl;

    return 0;
}

Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
typedef __int128 ll;

ll m = 1000000007;

ll modexp(ll a, ll b){
	if (b==0){
		return 1;
	}
	if (b%2==0){
		ll tmp = modexp(a,b/2);
		return (tmp*tmp)%m;
	} else {
		ll tmp = modexp(a,(b-1)/2);
		return (((tmp*tmp)%m)*a)%m;
	}
}

ll inv(ll x){
	return modexp(x,m-2);
}

ll ncr(ll n, ll r){
	if (n-r<r){
		r=n-r;
	}//r is small.
	ll num = 1;
	for (ll i = n; i>=n-r+1; i--){
		num*=i;
		num%=m;
	}
	//cout<<num<<endl;
	ll denom = 1;
	for (ll i = 1; i<=r; i++){
		denom*=i;
		denom%=m;
	}
	//cout<<denom<<endl;
	return (num*inv(denom))%m;
}

int main(){
	long long nx,ax,bx;
	cin>>nx>>ax>>bx;
	ll n = nx, a = ax, b = bx;
	ll total = modexp(2,n)-1;
	ll adiff = ncr(n,a);
	ll bdiff = ncr(n,b);
	//cout<<adiff<<" "<<bdiff<<endl;
	ll sum = total+2*m-adiff-bdiff;
	sum%=m;
	long long ans = sum;
	cout<<ans<<endl;
	return 0;
}

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



public class Main {


	static List<Integer> ansset;

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int L=sc.nextInt();
    	List<String> data=new ArrayList<String>();

    	for(int i=0;i<N;i++) {

    		data.add(sc.next());
    	}

    	data.sort(null);

    	for(String str:data) {
    		System.out.print(str);
    	}

    	System.out.println();


    }
}




Measured memory_bytes: 21588
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
x = []
for i in range(n+1):
    if i == 0:
        x.append(2)
    if i == 1:
        x.append(1)
    if i >= 2:
        x.append(x[-2] + x[-1])
print(x[-1])

Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



void solve() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	rep(i, h + 1)rep(j, w + 1) {
		if (i * a + (h - i) * (w - a) != j * b + (w - j) * (h - b))continue;

		int cntw[1000] = {};
		int cnth[1000] = {};
		rep(y,h) {
			rep(x,w) {
				int aa, bb;
				if (y < i) {
					aa = a;
				}
				else {
					aa = w - a;
				}	
				if (x < j) {
					bb = b;
				}
				else {
					bb = h - b;
				}
				if (cnth[y] < aa && cntw[x] < bb) {
					cnth[y]++;
					cntw[x]++;
					cout << 1;
				}
				else {
					cout << 0;
				}
			}
			cout << endl;
		}
		return;
	}



	cout << "No" << endl;
}


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


	solve();


	return 0;
}

Measured memory_bytes: 1280
program Megalomania;
const maxn=2*trunc(1e5);
var a,b:array[1..maxn] of longint;
    n:longint;

procedure rf;
var i:Longint;
begin
	readln(n);
	for i:=1 to n do readln(a[i],b[i]);
end;

procedure swap(var x,y:longint);
var tmp:longint;
begin
	tmp:=x;
    x:=y;
    y:=tmp;
end;

procedure sort(l,r:longint);
var i,j,x:Longint;
begin
	i:=l; j:=r;
	x:=b[(l+r) div 2];
	repeat
	  while b[i]<x do inc(i);
	  while b[j]>x do dec(j);
	  if i<=j then
	    begin
	      swap(b[i],b[j]);
	      swap(a[i],a[j]);
	      inc(i);
	      dec(j);
	    end;
	until i>j;
	if l<j then sort(l,j);
	if i<r then sort(i,r);
end;

procedure greedy;
var i,sum:longint;
    check:boolean;
begin
	sum:=0; check:=true;
	for i:=1 to n do
	  begin
        sum:=sum+a[i];
        if sum>b[i] then 
          begin
            check:=false;
            break;
          end;
      end;
    if check then write('Yes') else write('No');
end;

begin
	rf;
	sort(1,n);
	greedy;
end.

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<map>

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

#define mk(a,b) make_pair(a,b)

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

int Stv[1<<8];

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}
const int N=305;

int n,m,Dat[N][N],B[N],Pos[N],Ind[N];
int main(){
	n=read(),m=read();
	Rep(i,1,n) Rep(j,1,m) Dat[i][j]=read();
	Rep(i,1,n) B[Dat[i][1]]++,Pos[i]=1;
	int Ans=n;
	Rep(k,1,m){
		int pos=0,maxval=0;
		Rep(i,1,m) if (B[i]>maxval){
			pos=i;maxval=B[i];
		}
		Ind[pos]=true;
		Rep(i,1,n) if (Dat[i][Pos[i]]==pos){
			Pos[i]++;
			while (Ind[Dat[i][Pos[i]]]) Pos[i]++;
			B[Dat[i][Pos[i]]]++;
		}
		B[pos]=0;
		if (pos==0) break;
		Ans=min(Ans,maxval);
	}
	printf("%d\n",Ans);
}
/*
4 5
5 1 3 4 2
2 5 3 1 4
2 3 1 4 5
2 5 4 3 1
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
int n;
void dfs(string s, char ch) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    } else {
        for (char c = 'a'; c <= ch; ++c) {
            if (c == ch)
                dfs(s + c, c + 1);
            else
                dfs(s + c, ch);
        }
    }
}
int main() {
    cin >> n;
    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
a = 0
b = 0
c = 0
for i in range(N):
    if P[i] <= A:
        a+=1
    elif P[i] <= B:
        b+=1
    else:
        c+=1
print(min(a,b,c))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)

void init() {
    int n, k; cin >> n >> k;
    cout << (n-2)/(k-1)+1 << '\n';
}

void solve() {
    
}

int main () {
    cin.tie(0); cin.sync_with_stdio(0);
    int T = 1;
    //cin >>T;
    for (int i=1; i<=T; i++) {
        init();
        solve();
    }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Node :
type Node struct {
	to []int
}

var route []int

func dfs(from, to, prev int) bool {
	if to == from {
		route = append(route, to)
		return true
	}
	ret := false
	for _, v := range node[from].to {
		if v == prev {
			continue
		}
		ret = dfs(v, to, from)
		if ret == true {
			break
		}
	}
	if ret == true {
		route = append(route, from)
	}
	return ret
}

// UnionFind（１）
type UnionFind struct {
	par []int
}

/* コンストラクタ */
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}

/* xの所属するグループを返す */
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

/* xの所属するグループ と yの所属するグループ を合体する */
func (u UnionFind) unite(x, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}

/* xとyが同じグループに所属するかどうかを返す */
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}

/* xの所属するグループの木の大きさを返す */
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

type pair struct {
	f, t int
}

var node []Node

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	node = make([]Node, N)
	p := make([]pair, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f].to = append(node[f].to, t)
		node[t].to = append(node[t].to, f)
		p[i] = pair{f, t}
	}

	out(node)
	f := dfs(0, N-1, -1)
	out(route, f)
	var fe, su int
	if f {
		k := len(route) / 2
		fe = route[k]
		su = route[k-1]
	}

	out("f", fe, "su", su)
	u := newUnionFind(N)
	for i := 0; i < N-1; i++ {
		if (p[i].f == fe && p[i].t == su) ||
			(p[i].f == su && p[i].t == fe) {
			continue
		}
		//		out("connect", p[i].f, p[i].t)
		u.unite(p[i].f, p[i].t)
	}
	fcnt := u.size(0)
	scnt := u.size(N - 1)
	if len(route)%2 == 1 {
		fcnt++
	}
	out(fcnt, scnt)

	if fcnt > scnt {
		fmt.Println("Fennec")
	} else {
		fmt.Println("Snuke")
	}

}


Measured memory_bytes: 40320
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,k,a,ans;
int main(){
	scanf("%d%d",&n,&k);
	fo(i,1,n){
		scanf("%d",&a);
		ans+=min(a,k-a);
	}
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 128
y,x=map(int,input().split())
g=[input() for i in range(y)]
flag=True
for yy in range(1,y-1):
    for xx in range(1,x-1):
        if g[yy][xx]=='#':
            if g[yy-1][xx]==g[yy+1][xx]==g[yy][xx-1]==g[yy][xx+1]=='.':
                flag=False
if(flag):
    print("Yes")
else:
    print("No")

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

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323
#define debug(x) cout<<"Case "<<x<<": "
#define For(i,n) for(long long i=0;i<n;i++)
#define Frabs(i,a,b) for(long long i = a; i < b; i++)
#define Frabr(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;

//Handle:cyber_rajat


int main(int argc, char const *argv[])
{
	sync;
	ll n,k;
	cin>>n>>k;
	ll arr[n+5]={0},dp[n+5];
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=0;i<=n+2;i++)
		dp[i]=1000000000;
	dp[0]=0,dp[1]=0;
	for(ll i=2;i<=n;i++)
	{
		for(ll j=1;j<=k;j++)
		{
			if(i<=j || j>=n)
				break;
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

int main() {
    ll h;
    cin >> h;
    ll ans = 0;
    ll num = 1;
    while (h > 0) {
        ans += num;
        h /= 2;
        num *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
local n, q = io.read("*n", "*n")
local cost = {}
local edge = {}
local asked = {}
for i = 1, n do
  cost[i] = 0
  edge[i] = {}
  asked[i] = false
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
for iq = 1, q do
  local p, x = io.read("*n", "*n")
  cost[p] = cost[p] + x
end
local tasks = {1}
for i = 1, n do
  local p = tasks[i]
  asked[p] = true
  local e = edge[p]
  for j = 1, #e do
    local c = e[j]
    if not asked[c] then
      table.insert(tasks, c)
      cost[c] = cost[c] + cost[p]
    end
  end
end
print(table.concat(cost, " "))


Measured memory_bytes: 57384
#include<iostream>
#include<string>
#include<map>

using namespace std;
int main(){
    string s;
    cin >> s;
    map<char,string> ma;
    ma['T'] = "a";
    ma['L'] = "i";
    ma['U'] = "u";
    ma['R'] = "e";
    ma['D'] = "o";
    char a[11][10] = {"w","","k","s","t","n","h","m","y","r"};
    for(int i = 0; i < s.size(); i+=2){
        if(s[i] == '0' && ma[s[i+1]] == "u"){
            cout << "nn";
        }else{
            cout << a[s[i]-'0'] << ma[s[i+1]];
        }
    }
    cout << endl;
}



Measured memory_bytes: 3216
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(2e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    // pre();
    int tc;
    // cin>>tc;
    tc=1;
    while(tc--){
    	int a,b,c;
    	cin>>a>>b>>c;
    	if(a+b+c>=22)
    		cout<<"bust\n";
    	else
    		cout<<"win\n";
    	
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
int main(void){
    IOS;
    int x; cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int x;
	int count = 1;
	for (int i = 0; i < 5; i++) {
		cin >> x;
		if (x == 0) {
			cout << count << endl;
		}
		else {
			count++;
		}
	}

	return 0;

}


Measured memory_bytes: 3620
A,B = map(int,input().split())
S = list(input())
judge = 0 #0:OK , -1:NG

if(len(S) == A+B+1):
 s1 = S[:A]
 s2 = S[A+1:]
 s3 = S[A]
 if('-' in s1):
   judge = -1
 elif('-' in s2):
   judge = -1
 else:
  if((len(s1)==A)and(len(s2)==B)and(s3=='-')):
   judge = 0
  else:
   judge = -1
else:
 judge = -1

if(judge == 0):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstring>

#define int long long

const int Maxv = 200010; 

int num[Maxv], sum[Maxv], Xr[Maxv], ans, n, l = 1, r; 

signed main() {
    scanf("%lld", &n); 
    for (int i = 1; i <= n; i++) 
        scanf("%lld", &num[i]); 
    
    sum[1] = Xr[1] = num[1]; 
    for (int i = 2; i <= n; i++) {
        sum[i] = sum[i - 1] + num[i];
        Xr[i] = Xr[i - 1] ^ num[i]; 
    }

    for (r = 1; r <= n; r++) {
        for (; sum[r] - sum[l - 1] != (Xr[r] ^ Xr[l - 1]); l++); 
        ans += (r - l + 1); 
    }

    printf("%lld\n", ans); 

    return 0; 
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    bool check = true;
    string s, t;
    cin >> s >> t;
    map<char, char> mp1, mp2;
    for (int i = 0; i < s.size(); i++){
        if (mp1.find(s[i]) == mp1.end()) mp1[s[i]] = t[i];
        else if (mp1[s[i]] != t[i]) check = false;
        if (mp2.find(t[i]) == mp2.end()) mp2[t[i]] = s[i];
        else if (mp2[t[i]] != s[i]) check = false;
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    int mn = N + 1, ret = 0;
    FOR(i, 0, N) {
        int p;
        cin >> p;
        mn = min(mn, p);
        if (p <= mn)
            ret++;
    }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let m: usize = read(&mut stdin_lock, &mut buf, b' ');
    let d: usize = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 1..m + 1 {
        for j in 1..d + 1 {
            let d1 = j % 10;
            let d10 = j / 10;
            if d1 >= 2 && d10 >= 2 && i == d1 * d10 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String a = sc.next();
	if (Character.isUpperCase(a.charAt(0))) {
	    System.out.print('A');
	} else {
	    System.out.print('a');
	}
    }
}


Measured memory_bytes: 35660
#include <iostream>
#define endl '\n'
using namespace std;

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

    char c;
    cin >> c;
    if((int)c < 97){
        cout << "A";
    }else{
        cout << "a";
    }

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
        string s;
        cin >> s;
        int n = s.length();
        int arr[n];

        for(int i = 0; i< n; i++)
        {
                if(s[i]=='A')
                {
                        arr[i] = 1;
                }
                else if(s[i] == 'Z')
                {
                        arr[i] = 2;
                }
                else
                {
                        arr[i] = 0;
                }
        }
        int a;
        int b;
        for(int i = 0; i< n; i++)
        {
                if(arr[i] == 1)
                {
                        a = i;
break;
                }
        }
        for(int i = n; i>0;i--)
        {
                if(arr[i] == 2)
                {
                        b = i;
break;
                }
        }
        int ans = b-a +1;
        cout << ans << endl;
}


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

int main(void){

  int act,ctt;
  int activi[1000] = {0};
  int judge[1000] = {0};
  int res[1000] = {0};
  int buff,idxbf=0;

  cin >> act >> ctt;
  for(int i = 0;i<act;i++) cin >> activi[i];
  for(int i = 0;i<ctt;i++) cin >> judge[i];

  for(int i = 0;i<ctt;i++){
    for(int j = 0;j<act;j++){
      if(activi[j] <= judge[i]){
        res[j]++;
        break;
      }
    }
  }

  buff = res[0];
  for(int i = 0;i<act;i++){
    if(buff < res[i]){
      buff = res[i];
      idxbf = i;
    }
  }

  cout << idxbf + 1 << endl;

  return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>

int main(void) {
    int A1, A2, A3;

    scanf("%d", &A1);
    scanf("%d", &A2);
    scanf("%d", &A3);

    int A12, A13, A23;
    int result;

    A12 = A1 < A2 ? A2 - A1 : A1 - A2;
    A13 = A1 < A3 ? A3 - A1 : A1 - A3;
    A23 = A2 < A3 ? A3 - A2 : A2 - A3;

    if (A12 >= A13 && A13 >= A23 || A12 >= A23 && A23 >= A13) {
        result = A13+A23;
    } else if (A13 >= A12 && A12 >= A23 || A13 >= A23 && A23 >= A12) {
        result = A12+A23;
    } else {
        result = A12+A13;
    }
    printf("%d\n", result);

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int a[127]={};
char s[30];
int main(){
	cin >> s;
	int l=1;
	for(int i=0;s[i]!='\0';i++)	a[s[i]]=1,l++;
	for(int c='z';c>='a';c--)
		if(!a[c]) s[l++]=c;
	//cout << s << endl;
	if(next_permutation(s,s+l))	cout << s;
	else	cout << -1;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  ll h, w;
  cin >> h >> w;
  ll res = 0;
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    if(a >= h && b >= w)res++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }
    int ans = X;
    for (int x : A) {
        int i = 0;
        while (1 + i * x <= D) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// C - Build Stairs
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	bool ok = true;
	for (int i = 1; i < n; i++)
		if (a[i] < a[i - 1]) {
			a[i]++;
			if (a[i] < a[i - 1]) {
				ok = false;
				break;
			}
		}

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t A, B, M, ans = 1000000;
  cin >> A >> B >> M;
  vector<int64_t> a(A), b(B);
  for (int i = 0; i < A; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < B; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, a.at(x - 1) + b.at(y - 1) - c);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ans = min(ans, a.at(0) + b.at(0));
  cout << ans << endl;  
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
    return 0<=a&&a<=5000;
}
int main(){
    while(cin>>n&&n){
        int x[5000],y[5001],an=0;
        for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
        for(int i=0;i<n;i++)
            for(int j=i;j<n;j++){
                int dx = x[i]-x[j];
                int dy = y[i]-y[j];
                int x1 = x[i]-dy; int x2 = x[j]-dy;
                int y1 = y[i]+dx; int y2 = y[j]+dx;
                int x3 = x[i]-dy, y3 = y[i]+dx,x4 = x[j]+dy,y4 = y[j]-dx;
                if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
                    an = max(an, dx*dx+dy*dy);
                if(c(x3)&&c(y3)&&p[x3][y3]&&c(x4)&&c(y4)&&p[x4][y4])
                    an = max(an, dx*dx+dy*dy);
            }
        cout<<an<<endl;
    }
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


/*
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 1e5, M = 1e9+7;

ll dp[N];
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
ll a[N];

int n;

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

	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);

	for(int i=2; i<n; ++i)
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i]-a[i-2])+dp[i-2]);

	cout << dp[n-1] << ends;
}


Measured memory_bytes: 5168
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<int> p[100010];
queue<int> q;
int vis1[100010],vis2[100010],n;
void dfs()
{
    int i,j,x,y;
    q.push(1);
    q.push(0);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        y=q.front();
        q.pop();
        for(i=0;i<p[x].size();i++)
        {
            j=p[x][i];
            if(vis1[j]==0)
            {
                vis1[j]=y+1;
                q.push(j);
                q.push(y+1);
            }
        }
    }
}
void bfs()
{
    int i,j,x,y;
    while(!q.empty())
        q.pop();
    q.push(n);
    q.push(0);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        y=q.front();
        q.pop();
        for(i=0;i<p[x].size();i++)
        {
            j=p[x][i];
            if(vis2[j]==0)
            {
                vis2[j]=y+1;
                q.push(j);
                q.push(y+1);
            }
        }
    }
}
int main()
{
    int i,j,k,x,y;
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        p[x].push_back(y);
        p[y].push_back(x);
    }
    memset(vis1,0,sizeof(vis1));
    vis1[1]=-1;
    dfs();
    memset(vis2,0,sizeof(vis2));
    vis2[n]=-1;
    bfs();
    vis2[n]=-1;
    y=0;
    for(i=1;i<=n;i++)
        if(vis2[i]<vis1[i])
            y++;
        x=n-y;
        if(x>y)
            printf("Fennec\n");
        else
            printf("Snuke\n");
        return 0;
}

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


int main() {
string A;
cin >> A;
int cou = 0;
for(int i = 0;i < 3;i++) {
    if(A.at(i) == '1') {
        cou++;
    } 
}

cout << cou << endl;

return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, count, ans = 0;
   // long long a, b;
    int fl, fl1, fl2, fl3;
    string s;
//    cin >> t;
    long long c, e, f;
    long long time;
    long long h, w;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    cin >> h >> w >> m;
    long long* arr = new long long[h + 5];
    long long* brr = new long long[w + 5];
    set<pair<long long, long long>> seta;
    for (i = 0; i <= h; i++)
        arr[i] = 0;
    for (i = 0; i <= w; i++)
        brr[i] = 0;
    for (i = 0; i < m; i++){
        cin >> x >> y;
        arr[x]++;
        brr[y]++;
        seta.insert(make_pair(x, y));
    }
    vector< long long> vec;
    vector<long long> vec1;
    long long maxim = -1;
    for (i = 0; i <= h; i++) {
        if (arr[i] > maxim) {
            vec.clear();
            maxim = arr[i];
            vec.push_back(i);
        }
        if (arr[i] == maxim)
            vec.push_back(i);
    }
//    cout << maxim << endl;
    maxim = -1;
    for (i = 0; i <= w; i++) {
        if (brr[i] > maxim) {
            vec1.clear();
            maxim = brr[i];
            vec1.push_back(i);
        }
        if (brr[i] == maxim)
            vec1.push_back(i);
    }
    ans = arr[vec[0]] + brr[vec1[0]];
//    cout << maxim << endl;
//    cout << ans << endl;
    for (i = 0; i < vec.size(); i++)
        for (j = 0; j < vec1.size(); j++)
            if (seta.find(make_pair(vec[i], vec1[j])) == seta.end()){
                cout << ans;
                return 0;
            }
    cout << ans - 1;
    return 0;
}
/*2
5
1 1 1 1 1
1
10
 1
 7
5 6 6 1 3 5 4

 */

Measured memory_bytes: 34992
fun main(args: Array<String>) {
    var N= nextInt()
    val dp = IntArray(N + 1) { 1000000007 }
    dp[0] = 0
    for (n in 1 .. N) {
        var y6 = 1
        while (y6 <= n) {
            dp[n] = Math.min(dp[n], dp[n - y6] + 1)
            y6 *= 6
        }
        var y9 = 1
        while (y9 <= n) {
            dp[n] = Math.min(dp[n], dp[n - y9] + 1)
            y9 *= 9
        }
    }
    println(dp[N])
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")


Measured memory_bytes: 31872
#include<bits/stdc++.h>  
using namespace std;
typedef long long int64;

typedef pair< int, int > Pi;

int n;
vector< Pi > seg;
void update( int id, int x){
  int i = id + n - 1;
  seg[i].first += x;
  seg[i].second = -id;
  while(i > 0){
    i = ( i - 1 ) / 2;
    seg[i] = max( seg[i * 2 + 1], seg[i * 2 + 2]);
  }
}
void init( int& size){
  n = 1;
  while( n < size ) n *= 2;
  seg.resize( n * 2 - 1, Pi(-1,-1));
}

int main(){
  int N, R, L;
  scanf("%d %d %d", &N, &R, &L);
  init(N);
  for(int i = 0; i < N; i++) update( i, 0);


  int most = 0, now = 0;
  vector< int > array(N, 0);

  while(R--){
    int d, t, x;
    scanf("%d %d %d", &d, &t, &x);
    d--;
    array[most] += t - now;
    update( d, x);
    now = t;
    most = -seg[0].second;
  }
  array[most] += L - now;
  printf("%d\n", distance( array.begin(), max_element( array.begin(), array.end())) + 1);
}

Measured memory_bytes: 3376