akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<int> G[100000];
int n; ll a[100000];
bool used[100000];
int sta;
pair<bool,ll> dfs(int x) {
	used[x] = true;
	int len = G[x].size();
	if (x!=sta&&len == 1) {
		return { true,a[x] };
	}
	ll sum = 0; ll ma = 0;
	rep(i, len) {
		int v = G[x][i];
		if (used[v])continue;
		pair<bool, ll> p = dfs(v);
		if (!p.first)return { false,0 };
		ma = max(ma, p.second); sum += p.second;
	}
	if (sum < a[x])return { false,0 };
	ll d = sum - a[x];
	ll chk = min(sum / 2, sum - ma);
	if (d > chk)return { false,0 };
	else return { true,a[x] - d };
}
int main() {
	cin >> n; fill(used, used + n, false);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n-1) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	rep(i, n) {
		if (G[i].size() == 1)sta = i;
	}
	if (dfs(sta).first)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){   
    int a,b,c,x,y,ans=0;
    cin >> a >> b >> c >> x >> y;
    if(a+b>2*c){
        ans+=2*c*min(x,y);
    }else{
        ans+=(a+b)*min(x,y);
    }
    if(x>y){
        if(a>2*c){ans+=2*c*(x-y);}else{ans+=a*(x-y);}
    }else{
        if(b>2*c){ans+=2*c*(y-x);}else{ans+=b*(y-x);}
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,v[50];
	scanf("%d",&n);
	rep(i,n) scanf("%d",v+i);

	sort(v,v+n);

	double ans=v[0];
	rep(i,n-1) ans=(ans+v[i+1])/2;
	printf("%f\n",ans);

	return 0;
}


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n;
	int ans=0;
	
	cin >> n;
	
	for(int i=1; i<=n; i++){
		if(i<10 || (100<=i && i<=999) || (10000<=i && i<=99999)){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main()
{
	int a, b;
	char op;
	while (cin >> a >> op >> b){
		if (op == '+'){
			cout << a + b << endl;
		}
		else if (op == '-'){
			cout << a - b << endl;
		}
		else if (op == '*'){
			cout << a * b << endl;
		}
		else if (op == '/'){
			cout << a / b << endl;
		}
		else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;cin>>a;return a;}

// no change 
const ll MOD = 1e9+7;  
void Titan(){
	string s;
	cin >> s;
	int n = s.size();
	ll sum = 0;
	fo(n){
		int a = s[i] - '0';
		sum+=a;
	}

	cout << (sum%9==0 ? "Yes" : "No");





	
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std;
int main(){
    int h,w,tr;
    cin>>h>>w>>tr;
    string s[h];
    vi v[h],c(h,0);
    int ans[h][w],a=1,arr[w];
    memset(arr,0,sizeof(arr));
    pan(i,h) {
        int count=0;
        cin>>s[i];
        pan(j,w){
            if(s[i][j]=='#'){ 
                v[i].pb(j);
                count++;
            }
        }
        c[i]=count;
    }
    int chut=0;
    for(int i=h-1;i>=0;i--){
        if(c[i]!=0){
            chut=i;
            break;
        }
    }
    int i=0,j=0,dum=1,x,k=0;
    for( k=0;k<h;k++){
        if(c[k]!=0){
            int q=0;
            for(int we:v[k]){
                for(q;q<=we;q++){
                    arr[q]=dum;
                }
                dum++;

            }
            dum--;
            for(int we=v[k][v[k].size()-1];we<w;we++)
                arr[we]=dum;
            dum++;
            for(i;i<=k;i++){
                for(j=0;j<w;j++){
                    ans[i][j]=arr[j];
                }
            }
        }
        if(k==chut) break;
    }
    k++;
    for(k;k<h;k++){
        for(j=0;j<w;j++)
            ans[k][j]=arr[j];
    }
    pan(i,h){
        pan(j,w) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 2048
#include <stdio.h>
#define LL long long
LL sum;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int main(){
	int n,a,b,c,d;
	scanf("%d",&n);
	for(a=1;a<=n;a++)
		for(b=1;b<=n;b++)
			for(c=1;c<=n;c++)
				d=gcd(a,b),d=gcd(c,d),sum+=d;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int M;
    cin >> M;
    cout << 48 - M << endl;
}


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

int main() {

  string s;
  cin>>s;

  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
  
}


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

int main(){
  int n;
  cin >> n;
  int count = 0;
  for(int i = 0; i < n; i++){
    long int a;
    cin >> a;
    if(a % 2 == 1) count++;
  }
  if(count % 2 == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

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

#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;

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


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

using namespace std;

//#define cin fi
//#define cout fo
//
//ifstream fi ("");
//ofstream fo (".INP");

int cnt;
int n ,m , u, v;
int vis[1000001];
vector<int> adj[1000001];

void dfs(int u){
	cnt++;
	vis[u] = 1;
	for (int v : adj[u]){
		if (!vis[v]) dfs(v);
	}
}

int main(){
//	freopen("test.txt" , "r" , stdin);
	ios_base:: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m  ; i++){
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int res = 0;
	for (int i = 1; i <= n ; i++){
		if (!vis[i]){
			cnt = 0;
			dfs(i);
			res = max(res, cnt);
		}
	}
	cout <<res ;
	return 0;
}


Measured memory_bytes: 40308
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<string> a(n + 1, "");
	cout << 0 << endl;
	cin >> a[0];
	if(a[0][0] == 'V')
	{
		return 0;
	}
	a[n] = a[0];
	stack<pair<int, pair<int, int>>> s;
	s.push(make_pair(n / 2, make_pair(0, n)));
	for (int i = 1, t, u, v; i < 20; ++i)
	{
		t = s.top().first;
		u = s.top().second.first;
		v = s.top().second.second;
		s.pop();
		cout << t << endl;
		cin >> a[t];
		if(a[t][0] == 'V')
		{
			return 0;
		}
		if(((a[u] == a[t]) == (t - u) % 2) && t - u > 1)
		{
			s.push(make_pair((u + t) / 2, make_pair(u, t)));
		}
		if(((a[t] == a[v]) == (v - t) % 2) && v - t > 1)
		{
			s.push(make_pair((t + v) / 2, make_pair(t, v)));
		}
	}
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int x, y; cin >> x >> y && (x && y);) {
    int mp[1000001]; memset(mp, -1, sizeof mp);
    int cnt = 0;
    while(!~mp[x % y]) {
      if(x % y == 0) {
        cout << cnt << " 0" << endl;
        goto exit;
      }
      mp[x % y] = cnt ++;
      x %= y;
      x *= 10;
    }
    cout << mp[x % y] << " " << cnt - mp[x % y] << endl;
    exit:;
  }
  
  return 0;
}

Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1)
#define set(x,i) (x|(1<<i))
#define unset(x,i) (x&~(1<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}

int main()
{
	boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif
 ll n,m,x,i,j;
 cin>>n>>m>>x;
vector<ll> v[n];
REP(i,n)
{
	REP(j,m+1)
	{
		ll x;
		cin>>x;
	v[i].pb(x);
}
}

ll cost=INF;
for(i=1;i<(1<<n);i++)
{
	ll b[m];
	for(j=0;j<m;j++)
		b[j]=0;
	ll c=0;
for(j=0;j<n;j++)
{
	if(i&(1<<j))
	{
    for(ll k=1;k<m+1;k++)
      b[k-1]+=v[j][k];
  c=c+v[j][0];
	}
}
int f=0;
for(j=0;j<m;j++)
{
	if(b[j]<x)
     f=1;
}
if(f==0&&c<cost)
	cost=c;
}
if(cost==INF)
cout<<"-1";
else
cout<<cost;

}

Measured memory_bytes: 3656
/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"Yes"<<endl
#define NO                      cout<<"No"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second
#define print(a)                for(auto it: a) cout<<it<<" "
#define all(a)                  a.begin(),a.end()
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------
vll G[100005];
int vis[100005];
void dfs(int n)
{
    vis[n]=1;
    for(auto it: G[n])
    {
        if(!vis[it]) dfs(it);
    }
}
int main()
{
    AHNAF;
    int n,m;cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y;cin>>x>>y;
        G[x].pb(y);G[y].pb(x);
    }
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(!vis[i]) {
            cnt++;
            dfs(i);
        }
    }
    cout<<cnt-1;

}



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

bool sub(int i)
{
  int j;
  for(j = 2;j*j <= i;j++){
    if(i % j == 0){
      return false;
    }
  }
  
  return true;
}

int main()
{
  int X,i;
  cin >> X;
  
  i = X;
  while(!sub(i)){
    i++;
  }
  cout << i << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct edge {
    int from, to; ll cost;
    edge(int s, int t, ll w = 0) : from(s), to(t), cost(w) {}
};
int main() {
    init();

    int n;
    cin >> n;
    vector<VI> a(n, VI(n)), wh(n, VI(n, -1));
    FOR(i, 0, n)FOR(j, 0, n - 1) {
        cin >> a[i][j];
        wh[i][--a[i][j]] = j;
    }

    int v = n * (n - 1) / 2;
    vector<vector<edge>> g(v);

    vector<VI> id(n, VI(n));
    int o = 0;
    FOR(i, 0, n)FOR(j, i + 1, n)id[i][j] = o++;

    VI in(v, 0);
    FOR(i, 0, n)FOR(j, 0, n - 2) {
        int x = i, y = a[i][j], X = i, Y = a[i][j + 1];
        if (x > y)swap(x, y);
        if (X > Y)swap(X, Y);
        g[id[x][y]].emplace_back(id[x][y], id[X][Y]);
        in[id[X][Y]]++;
    }
    
    VI ans, len(v, 0);
    queue<int> que;
    FOR(i, 0, v)if (in[i] == 0) {
        que.push(i);
        len[i] = 1;
    }

    while (!que.empty()) {
        int now = que.front(); que.pop();
        ans.push_back(now);
        for (edge next : g[now]) {
            if (--in[next.to] == 0) {
                que.push(next.to);
                chmax(len[next.to], len[now] + 1);
            }
        }
    }

    if (v == ans.size()) {
        int mlen = 0;
        for (int i : len)chmax(mlen, i);
        cout << mlen << "\n";
    }
    else cout << "-1\n";
}


Measured memory_bytes: 55040
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
 
        String a = s.next();
        String b = s.next();
        String c = s.next();
        String tempStr = "";
 
        tempStr = a;
        a = b;
        b = tempStr;
        tempStr = a;
        a = c;
        c = tempStr;
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

char S[304][304];

int main(){
  int N;
  scanf("%d", &N);
  for (int i=0; i<N; i++){
    std::string s;
    std::cin >> s;
    for (int j=0; j<N; j++){
      S[i][j]=s[j];
    }
  }
  int ans = 0;
  for (int d=-N+1; d<=N-1; d++){
    //printf("d=%d\n", d);
    bool ok=true;
    for (int i=0; i<N; i++){
      for (int j=0; j<N; j++){
	int I = j+d;
	if (I<0) I+=N;
	if (I>=N) I-=N;
	int J = i-d;
	if (J<0) J+=N;
	if (J>=N) J-=N;
	if (S[i][j]!=S[I][J]) {
	  ok=false;
	  break;
	}
      }
    }
    if (ok){
      //printf("+=%d\n", N-abs(d));
      ans += N-abs(d);
    }
  }
  std::cout << ans << std::endl;
		      
  return 0;
}


Measured memory_bytes: 384
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll k,l;
    string str;
    ll q;
    cin>>str;
 	rep(i,str.length()){
      if(str[i]=='1')sum++;}
  cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(c-a) <= d)
		puts("Yes");
	else if(abs(c-b) <= d && abs(b-a) <= d)
		puts("Yes");
	else
		puts("No");
 } 

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

constexpr int INF = 1e9;

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<string> v(m);
        for(int i=0; i<m; ++i) {
            cin >> v[i];
        }

        int sy, sx;
        for(int i=0; i<m; ++i) {
            for(int j=0; j<n; ++j) {
                if(v[i][j] == '&') {
                    sy = i;
                    sx = j;
                }
            }
        }

        using state = tuple<int, int, int>;
        vector<vector<int>> d(m, vector<int>(n, INF));
        priority_queue<state, vector<state>, greater<state>> que;
        d[sy][sx] = 0;
        que.push(make_tuple(0, sy, sx));
        int dx[4] = {0, 1, 0, -1},
            dy[4] = {1, 0, -1, 0};
        int res = INF;
        while(!que.empty()) {
            int cur, y, x;
            tie(cur, y, x) = que.top();
            que.pop();
            if(d[y][x] < cur) {
                continue;
            }
            for(int i=0; i<4; ++i) {
                int ny = y + dy[i], nx = x + dx[i];
                if(ny < 0 || m <= ny || nx < 0 || n <= nx) {
                    res = min(res, d[y][x]);
                    continue;
                }
                if(d[ny][nx] > d[y][x] + ((v[y][x] == '.' || v[y][x] == '&') && v[ny][nx] == '#')) {
                    d[ny][nx] = d[y][x] + ((v[y][x] == '.' || v[y][x] == '&') && v[ny][nx] == '#');
                    que.push(make_tuple(d[ny][nx], ny, nx));
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3268
import sys
import math


def main():
    N, K = map(int, sys.stdin.readline().rstrip().split())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    high = max(A) + 1  # OK が取れる側
    low = 0  # NG となる側

    while high - low > 1:
        x = (high - low) // 2 + low

        cnt = 0
        for a in A:
            cnt += math.ceil(a/x) - 1

        if cnt <= K:  # OK
            high = x
        else:
            low = x

    print(high)


main()

Measured memory_bytes: 31012
#include<iostream>
using namespace std;
bool fun(string a)
{
	int n,i,j;//n存储字符串长度 
	char t1,t2;//临时存储需判断的两个字符 
	n=a.length();
	for(i=0,j=n-1;i<=j;i++,j--)//从字符串首尾开始判断 
	{
		t1=a[i];
		t2=a[j];
		if(t1!=t2)return false;//若不相等即不是回文 
	}	
	return true;
}
int main()
{
	string a;//存储待判断的字符串 
	cin>>a;
    string b=a.substr(0,(a.length()-1)/2);
	string c=a.substr((a.length()+3)/2-1,a.length());
	if(fun(a)&&fun(b)&&fun(c))cout<<"Yes";
	else cout<<"No";
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
alias g='g++ -std=c++17 -O2 pra.cpp'
cd programming
cd cpp
cd practice

1≤n≤200,000
0≤ai≤109
aiはすべて異なる値である
5
3 5 2 1 4
*/
#define rep(i, n) for(int i=0; i<(n); i++)
using veci = vector<int>;
using ll = long long;
int a[200500];
ll counter=0;
int L[150000];
int R[150000];
int INF = INT_MAX;
void merge(int a[], int left, int mid, int right){
    int n1 = mid - left;//左側の個数
    int n2 = right - mid;//右側の個数
    for (int i=0; i<n1; i++) L[i] = a[left + i];
    for (int i=0; i<n2; i++) R[i] = a[mid + i];
    L[n1] = INF;//番兵
    R[n2] = INF;
    int i=0;
    int j=0;
    for (int k=left; k<right; k++){
        if (L[i] <= R[j]){
            a[k] = L[i];
            i++;
            
        }
        else{
            a[k] = R[j];
            j++;
            counter += n1 - i;//後ろから見てi番目の番号を加える
            //バブルソートは後ろの数を持って後ろから数えていく手法
        }
        
    }
}
void mergeSort(int a[], int left, int right){
    if (left+1 < right){//要素が一つになるまで分割する, 奇数なら左側に加える
        int mid = (left + right)/2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}
int main(){//計算量nlong(n)以下で反転数を求める
    int n; cin >> n;
    rep(i, n) cin >> a[i];
    mergeSort(a, 0, n);
    cout << counter << endl;
}


Measured memory_bytes: 4660
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    int ans = 0;
    for (auto i = 1; i <= n; i++) {
        if(i < 10) ans++;
        if(i < 1000 and 99 < i) ans++;
        if(i < 100000 and 9999 < i) ans++;
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vvint g(n, vint());
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    queue<P> q;
    q.push(P(0, 1));
    q.push(P(n - 1, 2));
    vint col(n);
    col[0] = 1;
    col[n - 1] = 2;
    while (q.size())
    {
        P p = q.front();
        q.pop();
        int i = p.first;
        int c = p.second;
        for (int j : g[i])
        {
            if (col[j])
                continue;
            col[j] = c;
            q.push(P(j, c));
        }
    }

    int f = 0, s = 0;
    rep(i, n)
    {
        if (col[i] == 1)
        {
            f++;
        }
        else
        {
            s++;
        }
    }

    if (f > s)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 9316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 100005
ll mod=1e9+7;
 
ll mul(ll a,ll b){
  return (a*b)%mod;
}
 
int bit[MAX_N];
void add(int i,int x){
  i++;
 
  while(i<MAX_N){
    bit[i]+=x;
    i+=(i&-i);
  }
}
 
int sum(int i){
  i++;
 
  int res=0;
  while(i){
    res+=bit[i];
    i-=(i&-i);
  }
  return res;
}
 
ll N,R,a,b;
ll fact[MAX_N];
int t[MAX_N];
 
int main(){
  fact[0]=1;
  for(int i=1;i<MAX_N;i++)
    fact[i]=mul(fact[i-1],i);
 
  while(1){
    scanf("%lld",&N);
    if(N==0)break;
    scanf("%lld",&R);
    memset(bit,0,sizeof(bit));
    for(int i=0;i<N;i++)t[i]=i;
 
    for(int i=0;i<R;i++){
      scanf("%lld %lld",&a,&b);
      a--,b--;
      swap(t[a],t[b]);
    }
 
    ll ans=0;
    for(int i=0;i<N;i++){
      ll num=t[i];
      ll cnt=num-sum(num);
      ans+= mul(fact[N-1-i],cnt);
      ans%=mod;
      add(t[i],1);
    }
 
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 4660
#include <bits/stdc++.h>
#define rep(i,n) for(long long i = 0; i < (long long)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	int ans = 10000;
	string s, t;
	cin >> s >> t;
	rep (i, 1 + s.size() - t.size()) {
		string u = s.substr(i, t.size());
		int cnt = 0;
		rep (j, t.size()) if (u[j] != t[j]) cnt++;
		ans = min (ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for(int i = n-1; i >= 0; i--) {
            System.out.print(""+a[i] + (i == 0 ? "" : " "));
        }
        System.out.println();
    }
}

Measured memory_bytes: 17264
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(' ').map(String::toInt)
    val ans = when {
        b <= c || d <= a -> 0
        a <= c && d <= b -> d - c
        a <= c && b <= d -> b - c
        c <= a && b <= d -> b - a
        else -> d - a
    }
    println(ans)
}


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.14159265359;
typedef pair<int,int> P;

int fac[1000010], finv[1000010], inv[1000010];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
    int N,M;
    cin >> N >> M;
    vector<int> vec;
    for(int i = 2;i * i <= M;i++) {
        if(M % i == 0) {
            vec.push_back(0);
            while(M % i == 0) {
                vec.at(vec.size() - 1)++;
                M = M / i;
            }
        }
    }
    if(M != 1) {
        vec.push_back(1);
    }
    COMinit();
    int ret = 1;
    for(int i = 0;i < vec.size();i++) {
        ret = ret * COM(N + vec.at(i) - 1,vec.at(i)) % MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 23680
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
        int n = nk[0];
        int k = nk[1];

        if (n <= 8) Console.WriteLine(0);
        else
        {
            List<Tuple<int, int>> edge = new List<Tuple<int, int>>();
            for (int i = 9; i <= n; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (((i >> j) & 1) == 1) edge.Add(new Tuple<int, int>(j + 1, i));
                }
            }
            Console.WriteLine(edge.Count);
            Console.WriteLine(string.Join("\n", edge.Select(x => $"{x.Item1} {x.Item2}")));
        }

        for (int i = 0; i < k; i++)
        {
            int res = 0;
            string judge;
            for (int j = 0; j < 8; j++)
            {
                Console.WriteLine(j + 1);
                judge = Console.ReadLine();
                if (judge == "Yes") goto end;
                if (judge == "Near") res |= (1 << j);
            }
            Console.WriteLine(res);
            judge = Console.ReadLine();
            if (judge == "Yes") goto end;
            throw new Exception();
            end:;
        }
    }
}


Measured memory_bytes: 20488
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/


void solve(){
    in(n);
    vi a(n),b(n);
    vi pos,pos2;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
        pos.pb(a[i]+b[i]);
        pos2.pb(a[i]-b[i]);
    }
    sort(call(pos));
    sort(call(pos2));
    ll ans=abs(pos.back()-pos.front());
    ll ans2=abs(pos2.back()-pos2.front());
    ce(max(ans,ans2));
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/



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

ll K;

int main(){
    cin >> K;
    cin.ignore();
    if(K%2 == 0){
        cout << -1 << endl;
        return 0;
    }
    ll se = 7;
    ll cnt = 1;
    map<ll, bool> mp;
    while(1){
        se %= K;
        if(se == 0){
            cout << cnt << endl;
            return 0;
        }
        if(mp.find(se) != mp.end()){
            cout << -1 << endl;
            return 0;
        }
        mp[se] = true;
        ++cnt;
        se = se * 10 + 7;
    }
    return 0;
}

Measured memory_bytes: 66048
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long ans = 0;
        if(a % x !=0){
         ans = b/x - a/x;
        }else{
         ans = b/x - a/x + 1;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long a[n],ans=0;
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(ans<abs(a[i]-a[0]))
            ans=abs(a[i]-a[0]);
    }
    for(int i=01;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(ans<abs(a[i]-a[j]))
            ans=abs(a[i]-a[j]);
        }
    }
    cout<<ans<<endl;
 return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;

  char array[H][W];

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) cin>>array[i][j];  
  }

  for(int i = 0; i < W + 2; i++) cout<<"#";
  cout<<endl;

  for(int i = 0; i < H; i++){
    cout<<"#";
    for(int j = 0; j < W; j++) cout<<array[i][j];
    cout<<"#"<<endl;
  }

  for(int i = 0; i < W + 2; i++) cout<<"#";
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

}

Measured memory_bytes: 26244
from collections import deque
K=int(input())
queue=deque(list(range(1,10)))
for i in range(K):
    k=queue.popleft()
    if k%10!=0:
        queue.append(10*k+(k%10)-1)
    queue.append(10*k+(k%10))
    if k%10!=9:
        queue.append(10*k+(k%10)+1)
print(k)

Measured memory_bytes: 18860
fun main() {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val n = input[0]
    val k = input[1]
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()

    val aMap = HashMap<Int, Int>()

    for (x in a) {
        aMap[x]?.let {
            aMap[x] = it + 1
        }

        if (aMap[x] == null) {
            aMap[x] = 1
        }
    }
    val sortedMap = aMap.toList().sortedBy { it.second }.toMap()

    var reduce = aMap.entries.size - k
    if (reduce <= 0) {
        print(0)
        return
    }

    var result = 0

    for (x in sortedMap) {
        result += x.value
        reduce -= 1

        if (reduce == 0) {
            print(result)
            return
        }
    }
}


Measured memory_bytes: 84488
#include<stdio.h>

int main(){
    int n;
    int x = 0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        if(i%2 == 1){
            x++;
        }
    }
    float a = 1.0*x/n;
    printf("%lf", a);

    return 0;
}

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

constexpr int MAXN = 1e3 + 3;
constexpr double down = 0.996;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
	cin >> s;
	for(auto c : s) {
		if (c == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}

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

 struct NODE{
  int k;
  struct  NODE *p;
  struct NODE *l;
  struct NODE *ri;
};

struct NODE *N,*r;

void ins(int o){
struct NODE *a=N;
struct NODE *b=r;
struct NODE *c;
  c=(struct NODE*)malloc(sizeof(struct NODE));
  
  c->k = o;
  c->l = N;
  c->ri = N;
  while(b!=N){
    a = b;
    if(c->k < b->k){
      b=b->l;
    }
    else{
      b=b->ri;
    } 
  }
  c->p=a;
  if(a==N){
    r=c;
  }
  else{
    if(c->k < a->k){
      a->l=c;
    }
    else{
      a->ri=c;
    }
  }
}

void T(struct NODE *R){
  if(R==N)return;
  T(R->l);
  printf(" %d",R->k);
    T(R->ri);
}

void S(struct NODE *R){
  if(R==N)return;
  printf(" %d",R->k);
  S(R->l);
  S(R->ri);
}


int main(){
  int i,j,o,h;
  char O[10];
  scanf("%d",&o);
  for(i=0;i<o;i++){
    scanf("%s",O);
    if(strlen(O)==6){
      scanf("%d",&h);
      ins(h);
    }
    else{
      T(r);
      printf("\n");
      S(r);
      printf("\n");
    }
  }
  return 0;
}




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

string S, T;

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

    int lenS = S.size(), lenT = T.size(), res = 1010;
    for(int i = 0; i < lenS-lenT+1; i++){
        int cn = 0;
        for(int j = 0; j < lenT; j++){
            if(S[i+j] != T[j]) ++cn;
        }
        res = min(res, cn);
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 50, MOD = 1000000007;

int dp[3][MAXN][MAXN];
int N;

void convolve(int c, int a, int b) {
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			dp[c][i][j] = 0;
			for(int k = 0; k < N; k++)
				dp[c][i][j] = (dp[c][i][j] + (ll)dp[a][i][k] * dp[b][k][j]) % MOD;
		}
	}
}

void copy(int a, int b) {
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			dp[a][i][j] = dp[b][i][j];
}

int main() {
	ll K;
	cin >> N >> K;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			cin >> dp[0][i][j];
	int base = 0, res = 1, other = 2;
	copy(res, base);
	K--;
	while(K) {
		if(K & 1) {
			convolve(other, base, res);
			swap(other, res);
		}
		convolve(other, base, base);
		swap(other, base);
		K >>= 1;
	}
	int ans = 0;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			ans = (ans + dp[res][i][j]) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 256
N, W  = (int(i) for i in input().split()) 
w = []
v = []
for i in range(N):
    aa, bb = [int(i) for i in input().split()] 
    w.append(aa)
    v.append(bb)

# dp[i][w] : i-1番目までで重さがwのときの最大価値

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(W + 1):
    dp[0][i] = 0

for i in range(N):
    for j in range(W + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[N][W])



Measured memory_bytes: 171784
//In The Name of Allah
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template < class T > using Tree = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define all(x)			(x).begin(), (x).end()
#define SZ(x) 			(ll)(x.size())
#define sep             ' '
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

int main(){
    fast_io
    //dbl_io(10);
    ll H, W;
    cin >> H >> W;
    ll ans = H * W;
    if (H % 3 == 0 || W % 3 == 0)
    	ans = 0;
    ans = min({ans, H, W});
    for (ll i = 1; i < W; i ++){
    	ll s1 = i * H;
    	ll s2 = (W - i) * (H / 2);
    	ll s3 = (W - i) * (H - H / 2);
    	ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    swap(H, W);
    for (ll i = 1; i < W; i ++){
    	ll s1 = i * H;
    	ll s2 = (W - i) * (H / 2);
    	ll s3 = (W - i) * (H - H / 2);
    	ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
z['   '],i;
main(j){
	for(;++i<2e3;)
		if(!(z[i>>5]&1<<i))
			for(j=-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=i+1>>1;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
	return 0;
}

Measured memory_bytes: 0
let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      match List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) with
      | u :: _ :: l -> (g.(u-1) <- l; read (i + 1))
      | _ -> exit 1
  in
  read 0;
  let d = Array.make n 0 in
  let f = Array.make n 0 in
  let time = ref 1 in
  let rec dudu = function
    | [] -> ()
    | hd :: tl when d.(hd-1) = 0 -> (wa (hd - 1); dudu tl)
    | _ :: tl -> dudu tl
  and wa i =
    d.(i) <- !time; incr time;
    dudu g.(i);
    f.(i) <- !time; incr time
  and doit i =
    if i < n then (if d.(i) = 0 then wa i; doit (i + 1))
  in
  doit 0;
  let rec print i =
    if i < n then (Printf.printf "%d %d %d\n" (i + 1) d.(i) f.(i); print (i + 1))
  in
  print 0;

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

map<string,int> mp;

int main(int argc,char* argv[]){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	
	ll ans=0;
	for(auto x:mp){
		ans+=1ll*x.second*(x.second-1)/2;
	}
	
	cout<<ans;
	return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

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

  list<int> lst;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (n % 2 == 0) {
      if ((i + 1) % 2 == 0) {
        lst.push_front(a);
      } else {
        lst.push_back(a);
      }
    } else {
      if ((i + 1) % 2 == 0) {
        lst.push_back(a);
      } else {
        lst.push_front(a);
      }
    }
  }

  for (int x : lst) {
    cout << x << " ";
  }
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <math.h>

int main(){
	int h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,k;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	while(b<=a){
		k--;
		b<<=1;
	}
	while(c<=b){
		k--;
		c<<=1;
	}
	if(k>=0){
		printf("Yes"); 
	}
	else{
		printf("No"); 
	}
	return 0;
}

Measured memory_bytes: 1712
import Control.Monad

main :: IO ()
main = do
  [n,t] <- getInts
  xs <- replicateM n $ do
          [c,t] <- getInts
          return (c,t)
  putStrLn $ maybe "TLE" show $ solve t xs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> [(Int,Int)] -> Maybe Int
solve t xs = case [c | (c,t') <- xs, t' <= t] of
              [] -> Nothing
              ys -> Just $ minimum ys



Measured memory_bytes: 1020