akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
arr = [sinput() for i in range(n)]
cnt = col.Counter(arr)
print("AC x",cnt["AC"])
print("WA x",cnt["WA"])
print("TLE x",cnt["TLE"])
print("RE x",cnt["RE"])


Measured memory_bytes: 44840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint d(N);
    rep(i, N) cin >> d[i];
    sort(all(d));
    int mid = d[N / 2 - 1], mid2 = d[N / 2];
    cout << mid2 - mid;
    return 0;
}

Measured memory_bytes: 640
#coding: utf-8
import sys

memo = {1:1}
def factorial(n):
    for i in range(len(memo)+1,n+1):
        if n not in memo:
            memo[i] = memo[i-1] * i % int(1e9+7)
    return memo[n]

N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    sys.exit()
elif N == M:
    ans = factorial(N) * factorial(M) * 2
else:
    ans = factorial(N) * factorial(M)
ans = ans % int(1e9+7)
print(ans)


Measured memory_bytes: 17900
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
//const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);


signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll k, cnt = 0; cin >> k;
	rep(i, k) {
		cnt += (modpow(10, i, k) * 7 % k);
		//cout << cnt << endl;
		if (cnt % k == 0) { cout << i + 1 << endl; return 0; }
	}
	cout << "-1\n";
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for(int i = 0; i < m; i++)
  {
      cin >> a[i] >> b[i];
  }

  for(int j = 1; j <= n; j++)
  {
      int k = 0;
      for(int i = 0; i < m; i++)
      {
          if(a[i] == j)
            k++;
          if(b[i] == j)
            k++;
      }
      cout << k;
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;

    int M = N;
    int f_N = 0;

    while(M > 0){
        f_N += M % 10;
        M /= 10;
    }

    if(N % f_N == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main()
{
  std::vector<int> values;
  int x;
  for(int i=0;i<3;i++)
  {
    std::cin>>x;
    values.push_back(x);
  }
  
  std::sort(values.begin(), values.end());
  int p, q;
  p=values[2]*10+values[1];
  q=p+values[0];
  
  std::cout<<q<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b == c*d) {
		cout << a*b << endl;
	}
	else if (a*b > c*d) {
		cout << a*b << endl;
	}
	else {
		cout << c*d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, h, m, s;
  cin >> a;
  h = a / 3600;
  m = (a - (h * 3600)) / 60;
  s = a % 60;
  cout << h << ":" << m << ":" << s << endl;

}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e1 + 5);

int a[MAX_N];
int k;

int main(void) {
  // Here your code !
  for (int i = 0; i < 5; ++i) {
    scanf("%d", &(a[i]));
  }
  scanf("%d", &k);

  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if (abs(a[i] - a[j]) > k) {
        printf(":(\n");
        return 0;
      }
    }
  }

  printf("Yay!\n");

  return 0;
}


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

int main(){
  
  string a;
  cin >> a;
  
  if( a == "abc" || a == "acb" || a == "bca" || a == "bac" || a == "cab" || a == "cba" ){
  
    cout << "Yes" << endl;
  
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}
  

Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int X, Y;


int main() {

    cin >> X >> Y;
    ll ans = 0;

    if (X == 1) {
        ans += 300000;
    } else if (X == 2) {
        ans += 200000;
    } else if (X == 3) {
        ans += 100000;
    }

    if (Y == 1) {
        ans += 300000;
    } else if (Y == 2) {
        ans += 200000;
    } else if (Y == 3) {
        ans += 100000;
    }

    if (X == 1 && Y == 1) {
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  string s;
  cin>>s;
  int f=0;
  rep(i,2){
    if(s.at(i)!=s.at(i+1))f=1;
  }

  if(f==1)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char str[200010];
bool a[200010];
int pos[2],l[200010],r[200010],sum[200010];
int main()
{
	cin>>str+1;
	int n=strlen(str+1);
	for(int i=1;str[i];++i)
		if(str[i]=='R')
			a[i]=1;
	for(int i=1;i<=n;++i)
		l[i]=(str[i-1]=='L'?l[i-1]:i);
	for(int i=n;i>=1;--i)
		r[i]=(str[i+1]=='R'?r[i+1]:i);
	for(int i=1;i<=n;++i)
 	{
		if(str[i]=='L')sum[l[i]+((i-l[i])%2==0?0:-1)]++;
		else sum[r[i]+((r[i]-i)%2==0?0:1)]++;
	}
	for(int i=1;i<=n;++i)
		cout<<sum[i]<<" ";
	cout<<endl;
	return 0;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, mark[N];
vector<int> adj[N];

void DFS(int u, int p) {
    for (int v : adj[u]) if (v != p) {
        DFS(v, u);
        mark[u] += (mark[v] == 0);
    }
    if (mark[u] >= 2) {
        cout << "First" << endl;
        exit(0);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    DFS(1, 0);
    cout << (mark[1] ? "Second" : "First") << endl;
    return 0;
}

Measured memory_bytes: 9556
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> A(N);
  rep(i,N) std::cin >> A[i];

  rep(i,N) A[i] = -A[i];

  const int INF = 1e9+5;
  std::vector<int> dp(N, INF);
  rep(i,N) *std::upper_bound( all(dp), A[i] ) = A[i];
  std::cout << std::distance(dp.begin(), std::lower_bound( all(dp), INF)) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
@$_=(1e9)x@@for@@=0..<>;/ (.*) /,$
$`[$1]=$$1[$`]=$' for@M=<>;for$i(@@){//,map$$_[$']-=$-=$$_[$']-$$_[$i]-$$i[$'],@@for@@}print~~grep/ .* /*$
$`[$&]<$',@M

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    string s, t;
    cin >> s >> t;
    int n = int(s.size());
    int m = t.size();
    int ans = n;
    for (int i = 0; i + m - 1 < n; ++i) {
        int j = i + m - 1;
        int cur = 0;
        for (int k = i; k <= j; ++k) {
            cur += s[k] != t[k - i];
        }
        ans = min(ans, cur);
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  x3=x2+y1-y2;
  y3=-x1+x2+y2;
  x4=x1-y2+y1;
  y4=x2-x1+y1;
  printf("%d %d %d %d",x3,y3,x4,y4);
  return 0;
}


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

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

int main()
{
    ll n,m,x;
    cin >> n >> m >> x;
    vector<ll> c(n);
    vector< vector<ll> > a(n,vector<ll>(m));
    for( int i = 0; i < n; ++i )
    {
        cin >> c[i];
        for( int j = 0; j < m; ++j )
        {
            cin >> a[i][j];
        }
    }
    
    vector<ll> ans;
    for( int i = 0; i < (1<<n); ++i )
    {
        vector<ll> A(m);
        ll sum = 0;
        for( int j = 0; j < n; ++j )
        {
            if( i & (1 << j))
            {
                for( int z = 0; z < m; ++z )
                {
                    A[z] = A[z] + a[j][z];
                }
                sum = sum + c[j];
            }
        }

        bool flag = true;
        for( int i = 0; i < A.size(); ++i )
        {
            if( A.at(i) < x)
            {
                flag = false;
            }
        }
        if( flag == true )
        {
            ans.push_back(sum);
        }
    }

    ll min = 1000000000000;
    for( int i = 0; i < ans.size(); ++i )
    {
        if( min > ans.at(i) )
        {
            min = ans.at(i);
        }
    }

    if( ans.size()==0)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << min << endl;
    return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string a,b,c;
	cin>>a>>b>>c;
	//cout<<a.size()<<endl;
	int aa=0,bb=0,cc=0;
	int ord=1;
	REP(i,300){
		if(ord==1){
			if(aa==a.size()){
				cout<<"A"<<endl;
				return 0;
			}
			ord=a[aa]-96;
			aa++;
			continue;
		}
		if(ord==2){
			if(bb==b.size()){
				cout<<"B"<<endl;
				return 0;
			}
			ord=b[bb]-96;
			bb++;
			continue;
		}
		if(ord==3){
			if(cc==c.size()){
				cout<<"C"<<endl;
				return 0;
			}
			ord=c[cc]-96;
			cc++;
			continue;
		}
	}	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
using namespace std;
#define ll long long

int main(){
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  for(int i=0; i<D; i++){
    cin >> p[i] >> c[i];
  }
  D++;
  int ans=1010;
  for(int bit=0; bit < (1 << D); bit++){
    int sum=0;
    int count=0;
    int incomplete;
    for(int i=0; i<D-1; i++){
      if(bit & (1<<i)){
        sum += (i+1)*100*p[i] + c[i];
        count += p[i];
      }else{
        incomplete=i;
      }
    }
    for(int i=0; i<p[incomplete]; i++){
      if(sum >= G){
        ans = min(ans, count);
      }
      sum += (incomplete+1)*100;
      count++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xyh = []
hmax = 0
xmax = -1
ymax = -1
for _ in range(n):
    x,y,h = li()
    if h > hmax:
        hmax = h
        xmax = x
        ymax = y
        
    xyh.append((x,y,h))
    
xans = -1
yans = -1
hans = -1
flag = False
    
for x in range(101):
    for y in range(101):
        hcent = hmax + abs(xmax-x) + abs(ymax-y)
        consis = True
        
        for xi,yi,hi in xyh:
            if hi != max(0, hcent - abs(x-xi) - abs(y-yi)):
                consis = False
                
        if not consis:
            continue
                
        if consis:
            xans = x
            yans = y
            hans = hcent
            
            flag = True
            break
            
    if flag:
        break
            
            
print(xans, yans, hans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define all(a) (a.begin(),a.end())
#define fi first
#define sc second
#define ort(x,y) (x+y)/2
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d2(x,y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d3(x,y,z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define lim (int) (1e5+5)
#define inf (int) (1e7)
#define heap priority_queue
#define mem(a,val) memset(a,val,sizeof(a))
#define y1 asdassa
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
lli n,ar[lim],dp[lim][2];
lli dfs(lli x,lli fl)
{
	lli re=0;
	if(x==n+1) return fl;
	if(~dp[x][fl]) return dp[x][fl];
	re+=dfs(x+1,fl || (ar[x]-1)%2==0);
	re+=dfs(x+1,fl || (ar[x]+1)%2==0);
	re+=dfs(x+1,fl || ar[x]%2==0);
	return dp[x][fl]=re;
}
int main()
{
	mem(dp,-1);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&ar[i]);
	printf("%lld\n",dfs(1,0));
}


Measured memory_bytes: 1792
#include <cassert>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;

bool visit[100001];
bool white[100001];
int parent[100001];
vector<int> edges[100001];
int n;
int dist;

void dfs(int s, int e, int d) {
  if (s == e) dist = d;
  visit[s] = true;
  for (int to : edges[s]) {
    if (visit[to]) continue;
    parent[to] = s;
    dfs(to, e, d+1);
  }
}

void dfs2(int s, int e) {
  white[s] = true;
  for (int to : edges[s]) {
    if (white[to]) continue;
    if (to == e) continue;
    dfs2(to, e);
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  int e = n-1;
  dfs(0, e, 0);
  int v = e;
  int d2 = (dist-1)/2;
  while (d2 > 0) {
    int vp = parent[v];
    v = vp;
    --d2;
  }
  dfs2(v, parent[v]);
  int nw = 0;
  for (bool w : white) {
    if (w) ++nw;
  }
  if (nw >= n-nw) {
    cout << "Snuke" << endl;
  }
  else {
    cout << "Fennec" << endl;
  }
}



Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005][3];
char check;

int main(){
	ll n;
	cin>>n;
	ll a[n],b[n],c[n],res=0;
	for(ll i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];

	for(ll i=1;i<=n;i++){
		dp[i][0]=a[i-1]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i-1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i-1]+max(dp[i-1][0],dp[i-1][1]);
		//cout<<"i:"<<i<<" dp:"<<dp[i][0]<<endl;
		//cout<<"i:"<<i<<" dp:"<<dp[i][1]<<endl;
		//cout<<"i:"<<i<<" dp:"<<dp[i][2]<<endl;
	}
		//res=max(dp[n],res);
	for(ll i=0;i<3;i++){
		res = max(dp[n][i],res);
	}

	cout<<res<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
using namespace std;

const int INF=1e9+1000;
const double EPS = 1e-10;  
typedef long long ll;
int f[50000];

int main() {
    int n,i;
    f[0]=0;
    for(i=1;;i++){
   		f[i]=f[i-1]+i;
   		if(f[i]>=1000000000) break;
    }
    while(scanf("%d",&n)!=EOF){
    	printf("%d\n",lower_bound(f,f+i+1,n)-f );
    }
    return 0;  
}

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

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

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a,b;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
		return 0;
		}
	else {
		cin>>a>>b;
		cout<<a+b<<endl;
		return 0;
		}
}


Measured memory_bytes: 256
sub f{my$a=pop;
	++$d;
	$$a{$_}>$x[$_]++&&f($_),--$x[$_]for 2..$N;
	$%+=$d--==$N
}
$N=<>;
print f!!map${$`}{$'+0}=${$'+0}{$`}=/ /,<>


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans,a[100005],b[100005],c[100005];
ll gcd(int x,int y){
	if(x%y==0)return y;
	return gcd(y,x%y);
}
int main(){
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	b[0]=a[0];
	for(int i=1;i<n;i++)
		b[i]=gcd(b[i-1],a[i]);
	c[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		c[i]=gcd(c[i+1],a[i]);
	for(int i=0;i<n-2;i++)
		ans=max(ans,gcd(b[i],c[i+2]));
	ans=max(ans,c[1]);
	ans=max(ans,b[n-2]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>
#include <functional>


using namespace std;

typedef long long ll;
typedef long double ld;


const int sze = 1 << 15, INF = 1e9 + 10;


pair<int, int> ans;
ld cnt = 0;


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

	vector<int> values(n);

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

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

	int l = -1, r = n;
	while (r - l > 1)
	{
		int m = (l + r) >> 1;

		if (values[m] * 2 >= values[n - 1])
			r = m;
		else
			l = m;
	}

	if (l == -1)
		cout << values[n - 1] << ' ' << values[r];
	else if (r == n)
		cout << values[n - 1] << ' ' << values[l];
	else
	{
		if (values[n - 1] - values[r] > values[l])
			cout << values[n - 1] << ' ' << values[r];
		else
			cout << values[n - 1] << ' ' << values[l];
	}

	return 0;
}

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

int main() {

  int n;
  cin >> n;
  
  vector<int> a(n);

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

  vector<int> c;

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      c.push_back(i);
    } else {
      c.insert(c.begin(), i);
    }
  }

  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      cout << a[c[i]];
      if (i != n - 1) {
        cout << " ";
      }
    }
  } else {
    for (int i = n - 1; 0 <= i; i--) {
      cout << a[c[i]];
      if (i != 0) {
        cout << " ";
      }
    }
  }

  cout << endl;

}

Measured memory_bytes: 3828
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let s: String = read();
    let t: String = read();
    println!("{}", s.chars().zip(t.chars()).filter(|&(a, b)| a != b).count());
}

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

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

  if (N % 1000 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1000 - N % 1000 << endl;
  }
}


Measured memory_bytes: 3604
#include <iostream>


using namespace std;
int main()
{
    int K;
    cin >> K;
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << arr[K-1] << endl;
}

Measured memory_bytes: 256
open Printf
open Scanf

let mix_juice n k p_list =
  let sort_p_list = List.sort compare p_list in
  let sort_p_list_to_k = List.init k (fun i -> List.nth sort_p_list i) in
  List.fold_right (+) sort_p_list_to_k 0

let n, k = sscanf (read_line ()) "%d %d" (fun n k -> (n, k))
let p_list = List.map (fun n -> int_of_string n) (String.split_on_char ' ' (read_line ()))
let () = printf "%d\n" (mix_juice n k p_list)

Measured memory_bytes: 4160
#include<stdio.h>
#include<stdlib.h>
#define MAX 500001

typedef struct Node {
    long key;
    struct Node *p, *l, *r;
} Node;

Node *root, *NIL;


void insert(long k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = z->r = NIL;
    
    while (x != NIL) {
	y = x;
	if (z->key < x->key) x = x->l;
	else x = x->r;
    }
    z->p = y;
    
    if (y == NIL) root = z;
    else if (z->key < y->key) y->l = z;
    else y->r = z;
}

Node * find(Node *x, long k) {
    while (x != NIL && k != x->key) {
	if (k < x->key) x = x->l;
	else x = x->r;
    }
    return x;
}

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

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

void print() {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}

Node* getMinimum(Node *x) {
    while (x->l != NIL) x = x->l;
    return x;
}

Node* getSuccessor(Node *x) {
    if (x->r != NIL) return getMinimum(x->r);
    
    Node *y;
    y = x->p;
    while ( y!=NIL && x == y->r) {
	x = y;
	y = y->p;
    }
    return y;
}
void deleteNode(Node *z) {
    Node *y;
    Node *x;
    if (z->l == NIL || z->r == NIL) y = z;
    else y = getSuccessor(z);

    if (y->l != NIL) x = y->l;
    else x = y->r;
    
    if (x != NIL) x->p = y->p;
    
    if (y->p == NIL) root = x;
    else if (y == y->p->l) y->p->l = x;
    else y->p->r = x;

    if (y!= z) z->key = y->key;
}


int main() {
    long n, i, x;
    char st[20];
    scanf("%ld", &n);
    for (i = 0; i < n; i++) {
 	scanf("%s", st);
	scanf("%ld", &x);
	Node *u = find(root, x);
	if (st[0] == 'f') {
	    if (u != NIL) printf("yes\n");
	    else printf("no\n");
	}
	else if (st[0] == 'i') insert(x);
	else if(st[0] == 'd') deleteNode(find(root, x));
	else if (st[0] == 'p') print();
    }
    return 0;
}

Measured memory_bytes: 19364
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int A,B,C,D,E,F;
set<int> W,S;
int resa=0,ress=0;

int main()
{
    cin>>A>>B>>C>>D>>E>>F;
    for(int i=0;100*A*i<=F;i++)
        for(int j=0;100*(A*i+B*j)<=F;j++)
            W.insert(100*(A*i+B*j));
    for(int i=0;i*C<=F;i++)
        for(int j=0;i*C+j*D<=F;j++)
            S.insert(i*C+j*D);
    resa=A*100;
    for(auto a=W.begin();a!=W.end();a++)
        for(auto b=S.begin();b!=S.end();b++)
        {
            if(*a+*b>F)break;
            if(*a*E<*b*100)break;
            if(1.0*ress*100/resa<1.0**b*100/(*a+*b))
            {
                resa=*a+*b;
                ress=*b;
            }
        }
    cout<<resa<<" "<<ress<<endl;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

vector< long long int > v;
long long int ans[214514] = {};
bool f[214514] = {};
vector< long long int > a;
vector< vector< long long int > > d;

void kansu( long long int k ) {

    if ( v.size() == 0 || a[ k ] > v.back() ) {

        v.push_back( a[ k ] );
        ans[ k ] = v.size();

        for ( long long int i = 0; i < d[ k ].size(); i++ ) {
            if ( f[ d[k][i] ] ) continue;
            f[ d[k][i] ] = true;
            kansu( d[k][i] );
        }

        v.pop_back();

    } else {

        long long int p = std::lower_bound( v.begin(), v.end(), a[k] ) - v.begin();
        long long int cnt = v[p];
        v[p] = a[k];
        ans[k] = v.size();

        for ( long long int i = 0; i < d[k].size(); i++ ) {
            if ( f[ d[k][i] ] ) continue;
            f[ d[k][i] ] = true;
            kansu( d[k][i] );
        }

        v[p] = cnt;

    }

    return;

}

int main() {

    long long int n;
    cin >> n;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        a.push_back( in );
    }

    for ( long long int i = 0; i < n; i++ ) {
        vector< long long int > v;
        d.push_back( v );
    }
    for ( long long int i = 0; i < n - 1; i++ ) {
        long long int p, q;
        cin >> p >> q;
        p--;
        q--;
        d[p].push_back( q );
        d[q].push_back( p );
    }

    f[0] = true;
    v.push_back( a[0] );
    kansu( 0 );

    for ( long long int i = 0; i < n; i++ ) {
        cout << ans[i] << endl;
    }

    return 0;

}


Measured memory_bytes: 28740
package main

import "fmt"

func main() {
	var input int
	var max int
	var sum int

	for i := 0; i < 5; i++ {
		fmt.Scan(&input)

		if i == 0 {
			max = input
		}

		if input%10 == 0 {
			sum += input
		} else {
			sum += (input + (10 - input%10))
		}

		if input%10 != 0 && (10-input%10) > (10-max%10) {
			max = input
		}
	}

	var ans int
	if max%10 == 0 {
		ans = sum
	} else {
		ans = sum - (10 - max%10)
	}

	fmt.Print(ans)
}


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

Measured memory_bytes: 3632
S = gets.chomp # 文字列として取り出す
FAVARITE = 753
minimum = 10**4
try_count = S.length-2 # S桁の数字から連続した3桁の数字を取り出すパターン数
try_count.times do |i|
  num = S[i..(i+2)]
  diff = (FAVARITE - num.to_i).abs
  minimum = diff if diff < minimum
end
puts minimum


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	string s; cin>>s;
	ll n = s.length();
	ll cnt = 0;
	ll acnt = 0;
	REP(i,n-2)
	{
		if( s[i]=='A' ) ++acnt;
		else acnt = 0;
		if( s[i]=='A' && s[i+1]=='B' && s[i+2]=='C' )
		{
			cnt += acnt;
			--acnt;
			s[i] = 'B';
			s[i+1] = 'C';
			s[i+2] = 'A';
			++i;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n):
    if p[i] == i+1:
        tmp = p[i]
        if i < n-1:
            p[i] = p[i+1]
            p[i+1] = tmp
        else:
            p[i] = p[i-1]
            p[i-1] = tmp
        ans += 1

print(ans)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int A,B;
  int T;
  cin>>A>>B;
  cin>>T;
  int count=0;
  for(int i=0;i<T;i++){
    if((i+1)%A==0){
      count+=B;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


def main():
    X, Y = map(int, input().split())

    if (X + Y) % 3 or X > Y*2 or Y > X*2:
        return 0

    n = (X + Y) // 3
    r = Y - n
    return(combination(n, r))


print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

class union_find {
private:
	int par[114514];
	int rank[114514];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (x == par[x])return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int n, m, x[114514], y[114514], z[114514];
set<int> mu;
union_find ta;

signed main() {
	cin >> n >> m;
	ta.init(n);
	rep(i, m) {
		cin >> x[i] >> y[i] >> z[i];
		ta.unite(x[i] - 1, y[i] - 1);
	}
	rep(i, n) {
		mu.insert(ta.find(i));
	}
	cout << mu.size() << endl;
}

Measured memory_bytes: 9088
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] pqr={sc.nextInt(),sc.nextInt(),sc.nextInt()};
    Arrays.sort(pqr);
    System.out.println(pqr[0]+pqr[1]);
  }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    vector<ll> h(n),dp(n);rep(i,n)cin>>h[i];
    dp[0]=0;
    rep2(i,1,n){
        ll m = INF;
        rep2(j,1,min(i,k)+1){
            m = min(m,abs(h[i]-h[i-j])+dp[i-j]);
        }
        dp[i]=m;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool check(string s, string t)
{
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        return false;
    }
    return true;
}
int main()
{
    string s,t;
    cin>>s>>t;
    if(s.size()+1==t.size() && check(s,t))
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}
//Author: master_sam

Measured memory_bytes: 3632
s = gets.chomp
t = gets.chomp

min_diff = 1 << 31
(0..(s.length - t.length)).each do |i|
  diff = 0
  (0...t.length).each do |j|
    diff += 1 if s[i + j] != t[j]
  end
  min_diff = diff if diff < min_diff
end
puts min_diff


Measured memory_bytes: 14304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define EMP 0
#define WALL 1
#define START 2
#define GOAL 3

int w,h;

int dfs(pii s, pii g, vector<vector<int>> v, int depth){
    if(depth>10)return INF;
    int ret = INF;
    
    int dy[]={1,0,-1,0};
    int dx[]={0,1,0,-1};

    int y,x;
    tie(y,x) = s;

    rep(i,4){
        int ddy = y+dy[i];
        int ddx = x+dx[i];
        
        if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)continue;
        if(v[ddy][ddx]==WALL)continue;
        
        while(1){
            if(pii(ddy,ddx)==g){
                return 1;
            }
            ddy+=dy[i];
            ddx+=dx[i];
            if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)break;
            if(v[ddy][ddx]==WALL){
                v[ddy][ddx]=EMP;
                ddy-=dy[i];
                ddx-=dx[i];
                ret = min(ret,1+dfs(pii(ddy,ddx),g,v,depth+1));
                v[ddy+dy[i]][ddx+dx[i]] = WALL;
                break;
            }
        }
    }
    return ret;
}

int main(){
    while(cin>>w>>h&&(w||h)){
        vector<vector<int>> v(h,vector<int>(w));
        rep(i,h)rep(j,w)cin>>v[i][j];
        
        pii s,g;
        rep(i,h)rep(j,w){
            if(v[i][j]==START){
                s = pii(i,j);
                v[i][j] = EMP;
            }
            if(v[i][j]==GOAL){
                g = pii(i,j);
                v[i][j] = EMP;
            }
        }
        
        int res = dfs(s,g,v,1);
        if(res>=INF-100)cout<<-1<<endl;
        else cout<<res<<endl;
    }
}

Measured memory_bytes: 3152
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	
	int a,b;
	cin>>a>>b;
	int c = (b-1)/(a-1);
  	if(c*(a-1)==(b-1)) cout<<c;
	else cout<<c+1;
	
	
	
	
	return 0;
}


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


#define loop(x) for(int i = x; i--;)
#define ll long long
#define pb push_back
#define pob pop_back
vector<vector<ll int>> dp;
vector<int> weight,value;

ll int solve(int w , int num){
    if(num >= value.size() || w <= 0) return 0;
    if(dp[num][w] != INT_MIN) return dp[num][w];
    ll int temp = INT_MIN;
    if(w >= weight[num]) {
        temp = value[num]+solve(w-weight[num],num+1);
    }
    dp[num][w] = max(temp,solve(w,num+1));
    return dp[num][w];
}

int main(){
     int t = 1;
    // scanf("%lld",&t);
    while(t--) {
        ll int ans = 0;
        int n = 0, w = 0;
        
        scanf("%d %d",&n,&w); // Input size of array
        weight.reserve(n);
        value.reserve(n);
        for(int i = 0; i < n; i++) { // Input array
            int wei,val;
            scanf("%d %d",&wei,&val);
             weight.pb(wei);
             value.pb(val);
        }
        vector<ll int> temp;
        loop(w+1){
            temp.pb(INT_MIN);
        }
        loop(n+1){
            dp.push_back(temp);
        }
        ans = solve(w,0);
        printf("%lld\n",ans);
    }
}



Measured memory_bytes: 80372
#include<stdio.h>

int main() {
	int card1 = 0;
	int card0 = 0;
	int cardm1 = 0;
	int number = 0;

	scanf("%d %d %d %d", &card1, &card0, &cardm1, &number);

	if (card1 >= number) {
		printf("%d", number);
	}
	else if(card1 + card0 >= number){
		printf("%d", card1);
	}
	else {
		printf("%d", card1 - (number - card1 - card0));
	}

	return 0;
}

Measured memory_bytes: 1732
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var lineAry = line.Split(' ');
            int N = ConvToInt(lineAry[0]);
            int K = ConvToInt(lineAry[1]);

            line = System.Console.ReadLine();
            List<int> valList = new List<int>();
            foreach (var l in line.Split(' '))
            {
                valList.Add(ConvToInt(l));
            }
            valList.Sort();

            Console.WriteLine(valList.Take(K).Sum());
            return;
        }

        static int ConvToInt(string str)
        {
            int val = 0;
            return int.TryParse(str, out val) == true ? val : 0;
        }
    }
}


Measured memory_bytes: 28472
#include<iostream>
#include<vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(){
  ll d_sum=0,q_cnt=0,n,t_ans,ans=0,head,tmp;
  string s;
  cin >> s;
  n=s.size();
  vector<ll> dp[100002];
  for(int i=0;i<100002;i++){
    for(int j=0;j<13;j++){
      dp[i].push_back(0);
    }
  }
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    if(s[i]=='?')tmp=-1;
    else tmp=s[i]-'0';
    for(int j=0;j<10;j++){
      if(tmp!=-1&&tmp!=j) continue;
      for(int k=0;k<13;k++){
        dp[i+1][(k*10+j)%13] += dp[i][k];
      }
    }
    for(int j=0;j<13;j++){
      dp[i+1][j]%=MOD;
    }
  }
  cout << dp[n][5]<<endl;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long int
using namespace std;
int M;
vector<int>adj[100005];
vector<int> down(100005,0);
vector<int> up(100005,0);
vector<int>prefix[100005];
vector<int>suff[100005];
int dfs(int x,int pre){
      int cnt=1;
      for(int i=0;i<adj[x].size();i++){
            int y=adj[x][i];
            if(y==pre)continue;
            cnt=cnt*dfs(y,x)%M;
            prefix[x].pb(cnt);
      }
      prefix[x]=vector<int>(adj[x].size()+1,1);
      for(int i=0;i<adj[x].size();i++){
            int y=adj[x][i];
            if(y==pre){
                  prefix[x][i+1]=prefix[x][i];
            }
            else
            prefix[x][i+1]=prefix[x][i]*down[y]%M;
      }
      suff[x]=vector<int>(prefix[x].size(),1);
      for(int i=(int)adj[x].size()-1;i>=0;i--){
            int y=adj[x][i];
            if(y==pre){
                  suff[x][i]=suff[x][i+1];
            }
            else
            suff[x][i]=suff[x][i+1]*down[y]%M;
      }
      cnt++;
      return down[x]=cnt;
}
int push(int x,int pre){
      int cnt=1;
      for(int i=0;i<adj[x].size();i++){
            int y=adj[x][i];
            if(y==pre)continue;
            up[y]=((up[x])*prefix[x][i]%M*suff[x][i+1]%M+1)%M;
            push(y,x);
      }
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n>>M;
      for(int32_t i=0;i<n-1;i++){
            int32_t x,y;
            cin>>x>>y;
            adj[x].pb(y);
            adj[y].pb(x);
      }
      dfs(1,0);
      up[1]=1;
      push(1,0);
      for(int i=1;i<=n;i++){
            int ans=(up[i]*(down[i]-1))%M;
            cout<<(ans)%M<<"\n";
      }
}


Measured memory_bytes: 26368
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int ans[101][101];
int a[101];
int main() {
  int h, w, n;
  cin >> h >> w >> n;
  rep(i, 0, n) cin >> a[i];

  int now = 0;
  rep(i, 0, h) {
    vector<int> tmp;
    rep(j, 0, w) {
      tmp.push_back(now + 1);
      if (--a[now] == 0) ++now;
    }
    if (i & 1) reverse(tmp.begin(), tmp.end());
    rep(j, 0, w) cout << tmp[j] << " \n"[j == w - 1];
  }

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    
    string a;
    cin >> a;
    
    if(a[0] == a[1] && a[1] == a[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 3596