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

#define lli long long int
#define ld long double
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n)  \
  ld n;        \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LDV(a, n)            \
  vector<ld> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define sum(n) accumulate(n.begin(), n.end(), 0);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(A)LLI(B)LLI(C)LLI(X)lli sum = 0;lli flag = 0;
  for(lli i = 0;i <= X / 500 && i <= A;i++) {
    for (lli u = 0; u <= (X - 500 * i) / 100 && u <= B; u++)
    {
      for (lli o = 0; o <= (X - 500 * i - 100 * u) / 50 && o <= C; o++)
      {
        sum = 500 * i + 100 * u + 50 * o;
        if(sum == X) flag++;
      }
    }
  }
  OUT(flag)
}


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

void sort(int x, int y , int z){
    int temp;
    if( x > y){
        temp = x;
        x = y;
        y = temp;
    }
    if(x > z){
        temp = x;
        x = z;
        z = temp;
    }
    if( y > z ){
        temp = y;
        y = z;
        z = temp;
    }
    cout << x << " "<< y << " " << z << endl;
}

int main(){
    int x , y, z;

    cin >> x >> y >> z;
    
    if( 1 <= x && 1 <= y && 1 <= z && x <= 10000 && y <= 10000 && z <= 10000 )sort(x,y,z);
}



Measured memory_bytes: 2984
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int W;
bool used[5][410] = {};
vector<string> grid;
int min_ans;
int dfs(int p, int bx){
  if(min_ans <= (10 - p) + bx + W - 1) return INF;
  if(p == 10) {
    return min_ans = bx + W - 1;
  }
  int res = INF;
  for(int dx = 0; dx <= W; dx++){
    if(p == 0 && dx > 0) break;
    bool bad = false;
    REP(y, 5) REP(x, W) if(grid[y][x] == 'X' && used[y][bx + dx + x]) bad = true;
    if(bad) continue;
    REP(y, 5) REP(x, W) if(grid[y][x] == 'X') used[y][bx + dx + x] = true;
    res = min(res, dfs(p + 1, bx + dx + 1));
    REP(y, 5) REP(x, W) if(grid[y][x] == 'X') used[y][bx + dx + x] = false;
  }
  return res;
}

int main(){
  while(cin>>W && W){
    grid.assign(5, "");
    REP(i, 5) cin>>grid[i];
    bool empty = true;
    REP(y, 5) REP(x, W) if(grid[y][x] != '.') empty = false;
    assert(not empty);
    memset(used, 0, sizeof(used));
    min_ans = INF;
    cout << dfs(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-
r, c = map(int, raw_input().split())
cl= [0] * c
for i in xrange(r):
	t = map(int, raw_input().split())
	for i, a in enumerate(t):
		print a,
		cl[i] += a
	print sum(t)

for a in cl: print a,
print sum(cl)

Measured memory_bytes: 6448
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	int st, en;

	bool pos = false;

	string s, key = "keyence";

	cin >> s;

	for (int k = 0; k < s.size(); k++) {
		if (s[k] == key[k]) {
			//cout << "f\n";
			if (k == 6) {
				//cout << "n\n";
				pos = true;
			}
		}
		else {
			//cout << k << "\n";
			st = k;
			if (equal(s.end()-7+st, s.end(), key.begin() + st, key.end()) == 1) {
				pos = true;
				//cout << "t\n";
			}
			break;
		}
	}

	if (pos)cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
inline int lowbit(int x) { return (x & (-x));}
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;
int n, k, ans;
int main()
{
	scanf("%d%d", &n, &k);
	while(n)
	{
		n /= k;
		++ans;
	}
	cout << ans << endl;
	return 0;
}
	

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

using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
#define x first
#define y second
const int INF = 1000000000, MAXN = 18;

string str;
map<string, map<string, int> > mp;
int N;
ll res;

int main(){
	cin>>N>>str;
	for(int mask=0; mask<(1<<N); ++mask){
		string s1, s2;
		for(int j=0; j<N; ++j){
			if(mask & (1<<j)) s1 += str[N + j];
			else s2 += str[N + j];
		}
		reverse(s2.begin(), s2.end());
		mp[s1][s2]++;
	}
	for(int mask=0; mask<(1<<N); ++mask){
		string s1, s2;
		for(int j=0; j<N; ++j){
			if(mask & (1<<j)) s1 += str[j];
			else s2 += str[j];
		}
		reverse(s1.begin(), s1.end());
		res += mp[s1][s2];
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 119552
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
a = X // 500
b = X // 100
c = X // 50
xflag = False
yflag = False
zflag = False
for i in range(a+1):
    x = 500*i
    if i > A:
        continue
    for j in range(b+1):
        y = 100*j
        if j > B:
            continue
        for k in range(c+1):
            z = 50*k
            if k > C:
                continue
            s = x+y+z
            if s==X:
                ans += 1
print(ans)

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

struct node {
  int key;
  node *next;
  node *prev;

  node(int key) : key(key), next(NULL), prev(NULL) {}
};

class list {
  public:
    list() : head(NULL), tail(NULL) {}

    ~list() {
      node *e = head;
      while (e) {
        node *n = e->next;
        delete e;
        e = n;
      }
    }

    void insert(int x) {
      node *n = new node(x);
      if (head) {
        head->prev = n;
      }
      n->next = head;
      head = n;
      if (!tail) {
        tail = n;
      }
    }

    void Delete(int x) {
      node *e = head;
      while (e) {
        if (e->key == x) {
          erase(e);
          break;
        }
        e = e->next;
      }
    }

    void deleteFirst() {
      if (head) {
        erase(head);
      }
    }

    void deleteLast() {
      if (tail) {
        erase(tail);
      }
    }

    void print() {
      node *e = head;
      while (e) {
        if (e == head) {
          cout << e->key;
        } else {
          cout << " " << e->key;
        }
        e = e->next;
      }
      cout << endl;
    }

  private:
    node *head;
    node *tail;

    void erase(node *e) {
      if (e->prev == NULL) {
        head = e->next;
      } else {
        e->prev->next = e->next;
      }
      if (e->next == NULL) {
        tail = e->prev;
      } else {
        e->next->prev = e->prev;
      }
      delete e;
    }
};

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

  list l;
  for (int i = 0; i < n; i++) {
    string c;
    cin >> c;
    if (c == "insert") {
      int x;
      cin >> x;
      l.insert(x);
    } else if (c == "delete") {
      int x;
      cin >> x;
      l.Delete(x);
    } else if (c == "deleteFirst") {
      l.deleteFirst();
    } else if (c == "deleteLast") {
      l.deleteLast();
    }
  }
  l.print();
  return 0;
}




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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  1 <= N <= 20;
  1 <= A <= 100;
  1 <= B <= 2000;
  if (A * N >= B) {
  cout << B << endl;
  }
  else {
  cout << A * N << endl;
  }
}

Measured memory_bytes: 256
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

template<class T>
vector<vector<T>> reads(size_t n, size_t m)
{
    vector<vector<T>> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(reads<T>(m));
    });
    return a;
}

int main()
{
    const size_t n = read<size_t>();
    const auto s = reads<string>(n);
    
    unordered_map<char, uint64_t> head_count;

    for(const auto& si : s)
    {
        head_count[si[0]]++;
    }

    const char key[] = {'M','A','R','C','H'};

    uint64_t count = 0;
    for(int i = 0; i < 5; ++i)
    {
        for(int j = i+1; j < 5; ++j)
        {
            for(int k = j+1; k < 5; ++k)
            {
                if(i < j && j < k)
                {
                    auto ci = head_count[key[i]];
                    auto cj = head_count[key[j]];
                    auto ck = head_count[key[k]];
                    count += ci * cj * ck;
                }
            }
        }
    }

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int m,n,t,yy[1000],vis[1000],d,sum;
string wa; 
int main()
{
    cin>>m>>n;
    while(n--)
    {
    	cin>>t;
    	while(t--)
    	{
    		cin>>d;vis[d]++;
		}
	}
	for(int i=1;i<=m;++i) if(!vis[i]) sum++;
	cout<<sum;
	return 0;
}


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

namespace abc139
{
    class abc139c
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().ToList().ConvertAll(uint.Parse);
            var r = Solve(h);
            Console.WriteLine(r);
        }

        static int Solve(List<uint> h)
        {
            int nMax = 0;
            var hNow = h.Last();
            var nMove = 0;
            for(var i = h.Count() - 2; i >= 0; --i) {
                if(h[i] >= hNow) {
                    ++nMove;
                }
                else {
                    nMax = Math.Max(nMax, nMove);
                    nMove = 0;
                }
                hNow = h[i];
            }
            nMax = Math.Max(nMax, nMove);
            return nMax;
        }
    }
}


Measured memory_bytes: 27996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n);
    for(int i = 0; i < n; i++) cin >> a[i], a[i]--;
    int now = 0;
    for(int i = 1; i <= n; i++) {
        int next = a[now];
        if(next == 1) {
            cout << i << endl;
            return 0;
        }
        now = next;
    }
    puts("-1");
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  ll A, B, C, D;
  IN(A);
  IN(B);
  IN(C);
  IN(D);
  ll t = (C + B - 1) / B;
  ll a = (A + D - 1) / D;
  PRINT((t<=a)?"Yes":"No");
}


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

using namespace std;
typedef long long ll;

#define pb push_back

int T, n, m;
const int maxn = 100000+5;
const int maxm = 100000+5;

ll dp[maxn+5]; //minimal weight for val
ll ind[maxn+5];
vector<int> G[maxn];
vector<int> Ginv[maxn];

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

  int u, v;
  for(int i = 1; i <= n; i++) G[i].clear(), Ginv[i].clear(), ind[i] = 0;
  for(int i = 0; i < m; i++)
  {
    cin >> u >> v;
    G[u].pb(v);
    Ginv[v].pb(u);
    ind[v]++;
  }
  queue<int> q;
  memset(dp, 0, sizeof(dp));
  for(int i = 1; i <=n; i++) if(ind[i] == 0) q.push(i);
  while(!q.empty())
  {
    int x = q.front(); q.pop();
    for(int i = 0; i < G[x].size(); i++)
    {
      int y = G[x][i];
      dp[y] = max(dp[y], dp[x]+1ll);
      if(--ind[y] == 0)q.push(y);
    }
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2 :
    print(-1)
else :
    t = (N - 1) * (N - 2) // 2 - K
    print(N + t - 1)
    for i in range(1, N) :
        print(i, N)

    i, j = 1, 2
    while t > 0 :
        print(i, j)
        
        j += 1
        if j == N :
            i, j = i + 1, i + 2
        t -= 1

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

                                    typedef long long ll;
                                    typedef  double ld;
                                    #define rep(i,a,n) for(ll i=(a); i<(n); i++)
                                    #define per(i,a,n) for(ll i=(n-1); i>=(a); i--)
                                    #define F first
                                    #define S second
                                    #define maxx(a,b) a=max(a,b)
                                    #define minn(a,b) a=min(a,b)
                                    #define db(x) cerr<<#x<<" = "<<x<<endl
                                    #define N 1111111
                                    #define mod 1000000007
                                    #define rt return
                                    #define inf 12345678908761

                                    using namespace std;

                                    int main(){

                                        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

                                        //freopen("Ulug'bek","r",stdin);
                                        //freopen("Abdimanabov","w",stdout);

                                        int n; cin>>n;
                                        vector<int> v(n), ans(n,0);
                                        for(auto &x: v)
                                            cin>>x;
                                        ans[1]=abs(v[1]-v[0]);
                                        rep(i,2,n)
                                        ans[i]=min(abs(v[i]-v[i-1])+ans[i-1],abs(v[i]-v[i-2])+ans[i-2]);

                                        cout<<ans[n-1];

                                    rt 0;
                                    }



















Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int n,m,x,min,max,i,ans;

  cin >> n >> m;
  if(m < n){
    x = n;
    n = m;
    m = x;
  }
  min = m%n;
  max = n;
  for(i=1; i<min; i++){
    if(min%i==0 && max%i==0) ans = i;
  }
  if(n == m) ans = n;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1160
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 1e6+5;
const int LG = 25;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[MAX_N];

int main(){
    fastio;
    ll a,b;
    cin>>a>>b;
    if((a+b)%2 == 0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE";

}






Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi A(n);
  ll sum = 0;
  for(auto &a:A){cin>>a;sum += a;}
  ll cnt = 0;
  for(auto a:A){
    if(sum <= 4*m*a){
      cnt++;
    }
  }
  if(cnt >= m){
    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int N, M;
string A[55], B[55];

int main()
{
	int i, j;

	si(N);	si(M);

	fl(i,0,N)
	{
		cin >> A[i];
	}

	fl(i,0,M)
	{
		cin >> B[i];
	}

	fl(i,0,N - M + 1)
	{
		fl(j,0,N - M + 1)
		{
			// cout << i << " " << j << "\n";
			int l, k;
			bool thisGot = 1;
			fl(l,0,M)
			{
				fl(k,0,M)
				{
					if(A[i + l][j + k] != B[l][k])
					{
						// cout << "# " << l << " " << k << "\n";
						thisGot = 0;
					}
				}
			}
			if(thisGot)
			{
				printf("Yes\n");return 0;
			}
		}
	}

	printf("No\n");


	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    cin>>n;
    double T, A;
    cin>>T>>A;
    double dist = 1e9;
    int ans=-1;
    for (int i=1; i<=n; i++) {
	double x;
	cin>>x;
	double res = T-x*0.006;
	if (abs(A-res) < dist) {
	    ans=i;
	    dist = abs(A-res);
	}
    }

    cout<<ans<<endl;
    
    
    return 0;
}


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    int N, W;
    cin>>N>>W;
    vector<vector<int>> dp(N+1, vector<int>(W+1, 0));
    vector<int> Vs(N+1), Ws(N+1);
    for (int n = 1; n <= N; n++) cin>>Vs[n]>>Ws[n];

    for (int n = 1; n <= N; n++) {
        for (int w = 1; w <= W; w++) {
            dp[n][w] = dp[n-1][w];
            if (w - Ws[n] >= 0) dp[n][w] = max(dp[n][w], dp[n][w-Ws[n]] + Vs[n]);
        }
    }
    cout<<dp[N][W]<<endl;

    return 0;
}


Measured memory_bytes: 6844
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	cout << S.substr(0,3) << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int t;
	int n, s, f;
	int h;
	int i;
	
	while (scanf("%d", &t), t != 0){
		h = 0;
		scanf("%d", &n);
		for(i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			h += f - s;
		}
		if (h >= t){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - h);
		}
	}
	return (0);
}

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

int main(){
  int a,b,c,m;
  cin>>a>>b>>c;
  if(a==b+c || b==a+c || c==a+b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
} 
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1e9+7
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) cc.begin(), c.end()
#define mini(a, b, c) min(c, min(a, b))
//#define mini(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int32_t main(){
    fast
    
    // Fuck Ratings, I'm in Love with Experience. 
    // Once a Charas, Always a CHARAS.
    
  //  int t=1;
//    cin>>t;
  //  int u=t;
//f
int l,r,d,i,c=0;
cin>>l>>r>>d;
for(i=l;i<=r;i++){
    if(i%d==0)
    c++;
}
cout<<c<<endl;
 //  */
//}
    return 0;
}

Measured memory_bytes: 3592
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

summation = 0
for i, ai in enumerate(a):
  summation += ai
  if summation > x:
    print(i)
    exit(0)

if summation == x:
  print(N)
else:
  print(N-1)



Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f;
const double eps = 1e-9;

int n,m,q;
int a[maxn];

int main()
{
    while(~scanf("%d%d%d",&n,&m,&q))
    {
        int ans1=abs(n-m);
        int ans2=abs(n-q);
        if(ans1<ans2)
        {
            puts("A");
        }
        else puts("B");
    }
}


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

int main() {
  int n;
  cin>>n;
  set<char> s;
  for (int i=0; i<n; i++) {
    char c;
    cin>>c;
    s.insert(c);
  }
  if (s.size() == 3) {
    cout<<"Three"<<endl;
  } else {
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second
 
/*
//functions from gfg
 
long long int power(long long int x,long long int y,long long  int p)
{
    long long int res = 1;     // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            {//d=(long double)x/p;
            res = (res*x) % p;
            }
 
        // y must be even now
        y = y>>1; // y = y/2
        x=(x*x)%p;
        
    }
    return res%p;
}
 
long long int gcd(long long int a,long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
long long int binomialCoeff(long long int n, ll k) 
{ 
    ll res = 1; 
  
    // Since C(n, k) = C(n, n-k) 
    if (k > n - k) 
        k = n - k; 
  
    // Calculate value of [n*(n-1)*---*(n-k+1)] / [k*(k-1)*---*1] 
    for (ll i = 0; i < k; ++i) 
    { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
  
    return res; 
} 
 

void sieve(int n, vector<ll> &primes) 
{ 
    vector<int> prime(n,1);
    ll p;
    for ( p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == 1) 
        { 
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 0; 
        } 
    } 
  
    for(p=2;p<=n;p++)
    {
        if(prime[p])
        primes.pb(p);
    }
   
} 


void dfs(vector<ll> adj[] ,ll src,vector<ll> &vis)
{
    vis[src]=1;
    for(ll i=0;i<adj[src].size();i++)
    {
        if(vis[adj[src][i]]==0)
        dfs(adj,adj[src][i],vis)
    }
}
 
*/

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
   
    	ll n,i,j,p,x,m,ans=0,maxi=0;
        cin>>m>>n;
        vector<ll> a(n),b(n);
        for(i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
          if(a[i]>maxi)
            maxi=a[i];
        }
      	
      	ll dp[20005];
      	dp[0]=0;
      	for(i=1;i<20005;i++)
        {
        	dp[i]=100000000000000;
        }
      	for(i=1;i<20005;i++)
        {
        	for(j=0;j<n;j++)
            {
            	if(a[j]>=i)
              	dp[i]=min(dp[i],b[j]);
              	else
                {
                  dp[i] = min(dp[i],b[j]+dp[i-a[j]]);
                }
            }
        }
       ans=dp[m];
      for(i=m+1;i<m+maxi;i++)
      {
      	ans=min(ans,dp[i]);
      }
      	
      	
        cout<<ans<<endl;
        
        
   
    
    
    // for(i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    
	return 0;
}

Measured memory_bytes: 3828
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b;

	ans = (a*3 + b ) / 2;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3560
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    k,t=parseMap(split(readline()))
    a=sort(parseMap(split(readline())),rev=true)[1]
    println(max(a-1-(k-a),0))
end
main()

Measured memory_bytes: 169748
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    a,b,c,d = map(int,ipt().split())
    ans = b-a+1
    ans -= b//c-(a-1)//c
    ans -= b//d-(a-1)//d
    g = c*d//math.gcd(c,d)
    ans += b//g-(a-1)//g
    print(ans)
    return

if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int n, a; cin >> n >> a;
    cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,d[1005][1005];
char c[1005][1005];
bool used[1005][1005];
int main(){
	scanf("%d%d",&n,&m);
	rep(i,n) scanf("%s",&c[i]);
	queue<P>que;
	rep(i,n)rep(j,m){
		d[i][j] = INF;
		if(c[i][j] == '#'){
			d[i][j] = 0;
			que.push(mp(i,j));
		}
	}
	while(!que.empty()){
		P p = que.front(); que.pop();
		if(used[p.fi][p.sc]) continue;used[p.fi][p.sc] = 1;
		int dx[4]={0,0,1,-1};
		int dy[4]={1,-1,0,0};
		rep(k,4){
			int nx = p.fi+dx[k];
			int ny = p.sc+dy[k];
			if(0<=nx&&nx<n&&0<=ny&&ny<m&&!used[nx][ny]){
				d[nx][ny] = min(d[nx][ny],d[p.fi][p.sc]+1);
				que.push(mp(nx,ny));
			}
		}
	}
	int ans = 0;
	rep(i,n)rep(j,m) ans = max(ans,d[i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 22580
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0567 : Best Pizza **/
int main()
{
	int N, a, b, c;
	cin>>N;
	cin>>a>>b>>c;
	vector<int> t(N);
	rep(i, N) cin>>t[i];
	sort(t.begin(), t.end(), greater<int>());
	
	int p = a;
	int ans=0;
	rep(i, N) {
		c += t[i];
		p += b;
		ans = max(ans, c/p);
	}
	cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll b(n-1);
	rep(i, n) cin>>b[i];

	ll ans=b[0]+b[n-2];

	rep(i, n-2){
		ans += min(b[i], b[i+1]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

string s;
ll ans = 0;

void sum_num(ll num, ll sum, int l){
    int N = s.size();
    if(l == N-1){
        //cout << sum + num << endl;  
        ans += sum + num;
        return;
    }

    sum_num(s[l+1]-'0', sum+num, l+1);

    sum_num(num*10 + (s[l+1]-'0'), sum, l+1);

}

int main(){

    cin >> s;

    sum_num(s[0]-'0',0,0);

    cout << ans << endl;  
}

Measured memory_bytes: 3600
#include <cstdio>

long long X, Y;

void solve()
{
	if(X==Y || X==Y-1 || X==Y+1)
		printf("Brown\n");
	else
		printf("Alice\n");
}

int main()
{
	scanf("%lld %lld", &X, &Y);
	solve();
	return 0;
}

Measured memory_bytes: 128
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+8;
static const int INF = 0x3f3f3f3f;
static const int MOD = 998244353;

int main(){
    int ans[con];
    memset(ans,0,sizeof ans);
    int N;sc(N);
    int arr[N+1];
    FOR(i,1,N+1){
        sc(arr[i]);
    }
    ans[2] = abs(arr[2]-arr[1]);
    FOR(i,3,N+1){
        
        ans[i] = min(abs(arr[i]-arr[i-1])+ans[i-1],abs(arr[i]-arr[i-2])+ans[i-2]);
    }
    cout << ans[N];
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <malloc.h>
using namespace std;

int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	int result = B;
	result += min(B,C);
	C-=min(B,C);
	result += min(A+1,C);
	cout<<result<<endl;
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll s;
  scanf("%lld",&s);
  ll ans=1;
  while(s!=4&&s!=2&&s!=1) {
    if (s%2==0) s/=2;
    else s=s*3+1;
    ans++;
  }
  cout << ans+3 << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vector<vector<int>> data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100005
int n;
vector<int> edges[MAXN];

int dfs(int cur, int pre) {
    int res = 0;
    for (int i : edges[cur]) {
        if (i == pre) continue;
        res ^= 1 + dfs(i, cur);
    }
    return res;
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        edges[x].pb(y);
        edges[y].pb(x);
    }

    cout << (dfs(1, -1) ? "Alice" : "Bob");

    return 0;
}

Measured memory_bytes: 10368
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		{
			for (long i = 1; i < 1L << 30; i *= 2) {
				if (i == N) {
					System.out.println("No");
					return;
				}
			}
		}

		System.out.println("Yes");
		int M = (N % 2 == 0 ? N - 1 : N);
		for (int i = 2; i <= M; ++i) {
			System.out.println(1 + " " + i);
		}
		for (int i = 2; i <= M; i += 2) {
			System.out.println((i + 1) + " " + (i + N));
		}
		for (int i = 3; i <= M; i += 2) {
			System.out.println((i - 1) + " " + (i + N));
		}
		System.out.println((2 + N) + " " + (1 + N));
		if (M != N) {
			for (int i = 2; i <= M; ++i) {
				if (2 <= (1 ^ i ^ N) && (1 ^ i ^ N) <= M && (1 ^ i ^ N) != i) {
					System.out.println(i + " " + N);
					System.out.println((1 ^ i ^ N) + " " + (N + N));
					return;
				}
			}

		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int main()
{
	int n;
	cin >> n;
	int h, t;
	h = t = 0;
	for (int i = 0; i < n; i++){
		string s1, s2;
		cin >> s1 >> s2;
		if (s1 == s2){
			h++; t++;
		} else if (s1 > s2){
			t += 3;
		} else {
			h += 3;
		}
	}
	cout << t << " " << h << endl;

}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define mod 1000000007
#define rep(i,n)    for(ll i=0;i<n;++i)
#define forup(i,a,b)    for(ll i=a;i<=b;++i)
#define all(v)    v.begin(),v.end()
#define inf 1000000010
#define pii pair<ll,ll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define MAXN 110
#define bsize 555
#define sz(v) v.size()
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll power(ll x,ll y, ll md){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,n)    cin>>h[i];
    vector<ll> dp(n,0);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    forup(i,2,n-1){
        ll x=1e15;
        for(ll j=i-1;j>=max(i-k,(ll)0);j--){
            x = min(x,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=x;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
(N, L) = list(map(int, input().split()))

pai = 0

for n in range(N):
    if L < 0:
        if L+n == 0:
            next

    pai = pai + L + n

if L+N <= 0:
    pai = pai - (L + N - 1)

if L > 0:
    pai = pai - L

print(pai)

Measured memory_bytes: 3060
import math
a,b,c,d=map(int,input().split())
e=c*d//math.gcd(c,d)
if a%c==0:
  p=b//c-a//c+1
else:
  p=b//c-a//c
if a%d==0:
  q=b//d-a//d+1
else:
  q=b//d-a//d
if a%e==0:
  r=b//e-a//e+1
else:
  r=b//e-a//e
print(b-a+1-(p+q-r))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int mx=1000005;
#define slv {cout<<"Yes"<<endl;return 0;}
#define slv1 {cout << "No" << endl;return 0;}

int a[100002];


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin >> n;
    vector <int> a(n);
    map <int,int> cnt;
    rep(i,n){
    	cin >> a[i];
    	++cnt[a[i]];
    }
    if(cnt[0]==n)slv
    if(n%3)slv1
    vector <int > all;
    for(auto &p :cnt){
    	for(int i=0;i<p.second/(n/3);++i){
    		all.push_back(p.first);
    	}
    }
    if(all.size()==3 && (all[0]^all[1]^all[2])==0)slv
    else slv1

}


Measured memory_bytes: 4224
N = int(input())
S = str(input())


R = 0
G = 0
B = 0

for i in range(N):
    s = S[i]
    if (s == 'R'):
        R +=1
    if (s == 'G'):
        G +=1
    if (s == 'B'):
        B +=1

count = R * G * B


for i in range(N):
    for j in range(1, N//2 + 1):
        if i + j*2 >= N:
            break
        if S[i] != S[i + j] and S[i + j] != S[i + 2 * j] and S[i + 2 * j] != S[i]:
            count -= 1




print(count)

Measured memory_bytes: 9164
N,M = map(int, input().split())

a_list = [0] * N

uncorrect = 0
changezero = True

for i in range(M):
    s,c = map(int, input().split())
    if s == 1:
        changezero = False 
    if a_list[s-1] == 0:
        a_list[s-1] += c
    else:
        if a_list[s-1] != c:
            uncorrect += 1

if changezero and N >= 2:
    a_list[0] += 1

if uncorrect >= 1:
    print(-1)
elif a_list[0] == 0 and N >= 2:
    print(-1)
else:
    ans = 0
    for i in range(N):
        ans += a_list[i] * (10 ** (N-i-1))

    print(ans)

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

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

Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  //zの初期設定
  z = (Node *)malloc(sizeof(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 inParse(Node *u){
  if(u == NIL) return;
  inParse(u->left);
  printf(" %d",u->key);
  inParse(u->right);
}

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

int main(){
  int i,n,k;
  char order[10];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",order);
    if(strcmp(order,"insert") == 0){
	scanf("%d",&k);
	insert(k);
  }
    else if(strcmp(order,"print") == 0){
      inParse(root);
      printf("\n");
      preParse(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 1e5 + 7;
const ll INF = 1e9 + 5;
ll n, k;



int main()
{
    MohamedMotaz;
    cin >> n;// >> k;
    vector<ll> v(n);
    vector<ll> dp(n, INF);
    f(i,0,n) cin >> v[i];
    dp[0] = 0;
    f(i,0,n){
        for (int j : {i + 1, i + 2}){
            dp[j] = min(dp[j], dp[i] + abs(v[j] - v[i]));
        }
        //f(x,0,n) cout << dp[x] << " "; cout << endl;
    }
    //f(i,0,n) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n- 1];
}



Measured memory_bytes: 1792
import numpy as np
num = int(input())
data = list(map(int ,input().split()))
count =0
for i in range(num):
  for j in range(num-1):

    if (i>j):
      continue
    for k in range(num-2):
    
      if (j>k):
        continue
      datalist = [data[i],data[j+1],data[k+2]]
      max_i=np.argmax(datalist)
      
      if(datalist[max_i]<(datalist[(max_i+1)%3]+datalist[(max_i+2)%3])and not datalist[0]==datalist[1] and not datalist[1]==datalist[2] and not datalist[2]==datalist[0]):
        
        count +=1
      
      
print(count)

Measured memory_bytes: 27164