akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();        
 
        int ans = 0;
        int xtmp = 0;
        int ytmp = 0;
        int ttmp = 0;
 
        for (int i = 0; i < n; i++) {
          int t = sc.nextInt();
          int x = sc.nextInt();
          int y = sc.nextInt();
          
          int sumtmp = Math.abs(x - xtmp) + Math.abs(y - ytmp);
          
          if (sumtmp <= (t - ttmp) && ((t - ttmp) - sumtmp) % 2 == 0){
          } else {
            System.out.println("No");
            return;
          }
          xtmp = x;
          ytmp = y;
          ttmp = t;
        }
 
        System.out.println("Yes");
 
        sc.close();
 
        }
 
    }

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

int main() {
    ll n,m,ans;
    cin>>n>>m;
    if (n==1&&m==1) ans=1;
    else if (n==1||m==1) ans=n*m-2;
    else ans=(n-2)*(m-2);
    cout<<ans<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define M 8000010
#define N 1000010
using namespace std;
typedef long long ll;
int n,a,b,ans[105][105],x=1,y=1,z=1;
int main(){
	cin>>a>>b>>n;
	for(int i=1;i<=n;i++){
		int wxh;scanf("%d",&wxh);
		while(wxh--){
			ans[x][y]=i;
			y+=z;
			if(y>b||y<1)x++,y-=z,z=-z;
		}
	}
	for(int i=1;i<=a;i++,puts(""))for(int j=1;j<=b;j++)printf("%d ",ans[i][j]);
	return 0;
}

Measured memory_bytes: 384
'use strict'

function Main(input) {
    const pix = input.split('\n');
    pix.shift();

    const tatePix = [];
    pix.forEach(v => {
        tatePix.push(v);
        tatePix.push(v);
    });

    for (const v of tatePix) {
        console.log(v);
    }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


void copy(char *to,char *from,int n){
	int i;
	for(i=0;i<6;i++){
		if(i<n)	to[i] = from[i];
		else to[i] = '\0';
	}
}


int check(char *a,char *b){
	int i;
	for(i=0;i<5;i++){
		if(a[i] < b[i])			return -1;	//a -> b
		else if (a[i] > b[i])	return 1;	//b -> a
	}
	return 0;	//a == b
}

int int_sort( const void * a , const void * b ) {
  return strcmp(( char * )a , ( char * )b );
}

int main(void){
	char s[5001];
	int K;
	int i,j;
	scanf("%s",s);
	scanf("%d",&K);
	
	char kouho[25000][6];
	int index = 0;
	
	
	for(i=0;s[i] != '\0';i++){
		for(j=1; s[i+j-1] != '\0' ;j++){
			if(j>5) break;
			copy(kouho[index],&s[i],j);
			index++;
		}
	}
		
	
	qsort(kouho,index,sizeof(kouho[0]),int_sort);

	int ex[25000];
	for(i=0;i<25000;i++){
		ex[i] = 1;
	}
	for(i=0;i<index;i++){
		if(check(kouho[i],kouho[i+1]) == 0){
			ex[i+1] = -1;
		}
	}
	
		
	int count = 0,flag = 0;
	i = 0;
	while(flag <= K){
		if(ex[i] > 0){
			count = i;
			flag++;
		}
		i++;
	}
	
	
	printf("%s",kouho[count-1]);
	
	
	return 0;}

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

int n;
const int maxn = 2e5 + 5;

map<int, int> mp;
int a[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        ans += mp[i - a[i]];
        mp[i + a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21444
<?php
  
$input= fgets(STDIN);
$age_price =explode(" ",$input);
 
if($age_price[0]>=13){
	echo $age_price[1];
}elseif($age_price[0]<=12 && $age_price[0]>=6){
echo $age_price[1]/2;
}else{
  echo 0;
}


Measured memory_bytes: 15824
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N; cin>>N;
    vector<vector<int>> A(2, vector<int>(N));
    for (int i = 0; i < N; ++i) {
        cin>>A[0][i];
    }
    for (int i = 0; i < N; ++i) {
        cin>>A[1][i];
    }

    int ans=0;
    for (int i = 0; i < N; ++i) {
        int tmp = accumulate(A[0].begin(),A[0].begin()+i+1,0)+
                accumulate(A[1].begin()+i, A[1].end(), 0);
        if(tmp>ans) ans = tmp;
    }

    cout<<ans<<endl;

    return 0;
}

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

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

  int A[210];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int ans = 0;

  while (true) {
    bool odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 1) {
        odd = true;
      }
    }

    if (odd) {
      break;
    }

    ans++;
    for (int i = 0; i < N; i++) {
      A[i] /= 2;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
const int maxn = 3e6; 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	ll answer = 0;
	ll g2 = g;
	debug(g);
	for (ll i = 2;i * i <= g2;++i) {
		if (g % i == 0) {
			debug(i);
			++answer;
			while (g % i == 0) {
				g /= i;
			}
			//~ if (t != i) {
				//~ ++answer;
				//~ while (g % t == 0) {
					//~ g /= t;
				//~ }
			//~ }
		}
	}
	if (g != 1) {
		++answer;
	}
	cout << answer + 1 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
char s[5];
int main(){
	int i,cnta=0,cntb=0;
	scanf("%s",s);
	for(i=0;i<3;i++)
		if(s[i]=='A')cnta++;
		else cntb++;
	if(cnta==3||cntb==3)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	// if(n == 1){
	// 	cout << "Yes" << endl;
	// 	cout << 1  << " " << 1 << endl;
	// 	cout << 1  << " " << 1 << endl;
	// }
	int nn = n;
	int s = 0;
	for(int i = 1; i <= n; i++){
		nn -= i;
		if(nn < 0){
			cout << "No" << endl;
			return 0;
		}
		if(nn == 0){
			s = i;
			break;
		}
	}

	int k = 2*n/ s;
	int ss = s;
	// cout << "k = " << k << endl;
	// cout << "s = " << s << endl;

	vector<vector<int> > ans(k+1);
	vector<int> cnt(n+1,0);
	int now = 1;
	for(int i = 1; i <= k; i++){
		//cout << "now = " << now  <<endl;
		for(int j = now; j <= now+s-1; j++){
			ans[i].push_back(j);
		}
		for(int j = i+1; j <= k; j++){
			ans[j].push_back(now);
			now++;
		}
		s--;
	}

	cout << "Yes" << endl;
	cout << k << endl;
	for(int i = 1; i <= k; i++){
		cout << ss << " ";
		for(int j = 0; j < ss; j++){
			if(j != ss-1) cout << ans[i][j] << " ";
			else cout << ans[i][j] << endl;;
		}
	}

	return 0;
}

Measured memory_bytes: 2688
a = []
while true
  num = gets.split(" ").map(&:to_i)
  break if(num[0] == 0 && num[1] == 0)
  a.push(num)
end

a.each do |i|
  height = i[0]
  width = i[1]
  height.downto(1) do |h|
    case h
    when height, 1 then
      width.downto(1) do |w|
        printf "#" unless w == 1
        printf "#\n" if w == 1
      end
    else
      width.downto(1) do |w|
        printf "#" if w == width
        printf "#\n" if w == 1
        printf "." unless w == 1 || w == width
      end
    end
  end
  printf "\n"
end

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

int n;
ll arr[401];
ll dp[401][401];
ll prefix[401];

int main() {
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> arr[i];
        prefix[i]=prefix[i-1]+arr[i];
    }

    for (int L=n;L>=1;L--) {
        for (int R=L+1;R<=n;R++) {
            dp[L][R]=LLONG_MAX;
            for (int M=L;M<R;M++) {
                dp[L][R]=min(dp[L][R],dp[L][M]+dp[M+1][R]+prefix[R]-prefix[L-1]);
            }
        }
    }
    cout << dp[1][n] << endl;
}



Measured memory_bytes: 4840
N = int(input())
mod = 10 ** 9 + 7

table = [0,0,1]
if N >= 4:
  for i in range(3, N):
    table.append((table[i-1] + table[i-3]) % mod)
  print(table[-1] % mod)
elif N == 3:
  print(1)
else:
  print(0)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
inline int re(){
	char c;
	int w=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')w=-1;
	int res = c-'0';
	while((c=getchar())>='0'&&c<='9')res = res*10+c-'0';
	return res*w;
}
const int maxn = 6e5+5;
int n,k,a[maxn],dp[maxn];
int maxx[maxn<<2];
inline void update(int k,int l,int r,int pos,int v){
	if(l == r)return maxx[k] = max(maxx[k],v),void();
	int mid = l+r>>1;
	if(pos <= mid)update(k<<1,l,mid,pos,v);
	else update(k<<1|1,mid+1,r,pos,v);
	maxx[k] = max(maxx[k<<1],maxx[k<<1|1]);
}
inline int query(int k,int l,int r,int x,int y){
	if(l>y||r<x)return 0;
	if(l>=x&&r<=y)return maxx[k];
	int mid = l+r>>1;
	return max(query(k<<1,l,mid,x,y),query(k<<1|1,mid+1,r,x,y));
}
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	int ans = 0;
	for(int i=1;i<=n;++i){
		dp[i] = query(1,0,6e5,max(0,a[i]-k),a[i]+k)+1;
		update(1,0,6e5,a[i],dp[i]);
		ans = max(ans,dp[i]);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 10268
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n , m , a , b , ans=0;
  priority_queue<int> w;
  vector<int> d[100005];
  
  w.push(0);//無　を　働　く
  
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a <= m){
      d[m-a].push_back(b);
    }
  }
  
  for(int i=m-1;i>=0;i--){
    for(int j=0;j<d[i].size();j++){
      w.push(d[i][j]);
    }
    if(w.top() != 0){
      ans+=w.top();
      w.pop();
    }
  }
  
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 5632
H,W = map(int,input().split())
ans = float('inf')
for h in range(1,H):
  if (H-h)%2 == 0:
    k = max(h*W,(H-h)*W//2)-min(h*W,(H-h)*W//2)
    if ans > k:
      ans = k
  else:
    k = max(h*W,((H-h)//2)*W,((H-h)-(H-h)//2)*W)-min(h*W,((H-h)//2)*W,((H-h)-(H-h)//2)*W)
    if ans > k:
      ans = k
for w in range(1,W):
  if (W-w)%2 == 0:
    k = max(w*H,(W-w)*H//2)-min(w*H,(W-w)*H//2)
    if ans > k:
      ans = k
  else:
    k = max(w*H,((W-w)//2)*H,((W-w)-(W-w)//2)*H)-min(w*H,((W-w)//2)*H,((W-w)-(W-w)//2)*H)
    if ans > k:
      ans = k
for w in range(1,W):
  if H%2 == 0:
    l = max(w*H,(W-w)*H//2)-min(w*H,(W-w)*H//2)
    if ans > l:
      ans = l
  else:
    l = max(w*H,(W-w)*(H//2),(W-w)*(H-H//2))-min(w*H,(W-w)*(H//2),(W-w)*(H-H//2))
    if ans > l:
      ans = l
for h in range(1,H):
  if W%2 == 0:
    l = max(h*W,(H-h)*W//2)-min(h*W,(H-h)*W//2)
    if ans > l:
      ans = l
  else:
    l = max(h*W,(H-h)*(W//2),(H-h)*(W-W//2))-min(h*W,(H-h)*(W-W//2),(H-h)*(W//2))
    if ans > l:
      ans = l
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>

int main( void ) {
	int n1, n2, n3, max = 0;

	for ( ; ~scanf( "%*[^J]" );  ) {
		n1 = n2 = n3 = 0;
		scanf( "%*[J]%n%*[O]%n%*[I]%n", &n1, &n2, &n3 );

		n3 -= n2;
		n2 -= n1;

		if ( n1 >= n2 && n2 <= n3 )
			if ( max < n2 )
				max = n2;
	}

	printf( "%d\n", max );

	return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct Book
{
  int read,write;
  Book(int read=inf,int write=inf):read(read),write(write){}
  bool operator < (const Book& a)const
  {
    if(read != a.read)return read < a.read;
    return write < a.write;
  }
};

int main()
{
  int N;
  while(scanf("%d",&N),N)
    {
      Book array[N];
      int sum_r = 0;
      int sum_w = 0;
      rep(i,N)
	{
	  scanf("%d %d",&array[i].read,&array[i].write);
	  sum_r += array[i].read;
	  sum_w += array[i].write;
	}

      sort(array,array+N);

      if(sum_r-array[N-1].read < array[N-1].read)
	{
	  int limit = array[N-1].read - (sum_r-array[N-1].read);
	  bool dp[limit+1];
	  rep(i,limit+1)dp[i] = false;
	  dp[0] = true;
	  int mex = 0;
	  rep(i,N-1)for(int j=limit;j>=0;j--)
	    {
	      if(!dp[j] || j+array[i].write > limit)continue;
	      dp[j+array[i].write] = true;
	      mex = max(mex,j+array[i].write);
	    }
	  printf("%d\n",sum_r+sum_w+(limit-mex));
	}
      else
	{
	  printf("%d\n",sum_r+sum_w);
	}

    }
  return 0;
}

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

int main(){
  int h = 0;
  int w = 0;
  scanf("%d %d",&h,&w);//cin >> よりも早いらしい
  string s[h];
  for (int i = 0 ;i < h;i++){
    cin >> s[i];
  }
  for (int i = 0;i < w+2;i++){
    cout << '#';
  }
  cout << '\n';
  
  for (int i = 0;i < h;i++){
    cout << '#' << s[i] << '#' << '\n';//文字列の連結（出力）
  }
  for (int i = 0;i < w+2;i++){
    cout << '#';
  }
  cout << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
#define min(a, b) (a > b ? b : a)

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

    int n, k;
    std::vector<int> xs;

    std::cin >> n >> k;
    std::cin.ignore();

    std::string s;
    std::getline(std::cin, s);
    std::stringstream ss(s);
    std::copy(std::istream_iterator<int>(ss), {}, std::back_inserter(xs));

    int total = 0;
    for (int i = 0; i < n; i++) { total += min(xs[i], k - xs[i]); }
    std::cout << 2 * total << std::endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=2e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int a[N],z,c2,c1;

ll l1[N],l2[N],r1[N],r2[N];//1-come back

ll p[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    ll mn1=0,mn2=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        p[i]=p[i-1]+a[i];
        if(!a[i])z++;
        if(a[i]&1)c1++;
        else c2++;
        mn1=min(p[i]-z-z-c1,mn1);
        l1[i]=z+z+c1+mn1;

        mn2=min(l1[i]-c2,mn2);
        l2[i]=c2+mn2;
    }
    z=c1=c2=mn1=mn2=0;
    ll ans=INF;
    for(int i=n;i>=0;i--){
        p[i]=p[i+1]+a[i];
        if(!a[i])z++;
        if(a[i]&1)c1++;
        else c2++;
        mn1=min(p[i]-z-z-c1,mn1);
        r1[i]=z+z+c1+mn1;

        mn2=min(r1[i]-c2,mn2);
        r2[i]=c2+mn2;
        ans=min(ans,min(l1[i]+r2[i],l2[i]+r1[i]));
    }
    for(int i=1;i<=n;i++){
        ans=min(ans,min(l1[i-1]+r2[i],l2[i-1]+r1[i]));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>

int main(){
	int N;
	int K;
	scanf("%d",&N);
	scanf("%d",&K);
	char s[51];
	int i;
	char dummy;
	scanf("%c",&dummy);
	for(i=1;i<=N;i++){
		scanf("%c",&s[i]);
	}
	if(s[K]=='A'){
		s[K]='a';
	}else if(s[K]=='B'){
		s[K]='b';
	}else{
		s[K]='c';
	}
	for(i=1;i<=N;i++){
		printf("%c",s[i]);
	}
}

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

int main(){
    while(true){
        string a;
        getline(cin, a);
        if( a[0] == '0') break;
        int sum = 0;
        for(int i = 0; i < a.size(); i++){
            sum += a[i] -'0';
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> h(N);
  for (size_t i = 0; i < N; ++i) {
    scanf("%d", &h[i]);
  }

  int INF = 2e9;
  std::vector<int> dp(N+2, INF);
  dp[0] = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 1; j <= 2; ++j)
      dp[i+j] = std::min(dp[i+j], dp[i]+std::abs(h[i]-h[i+j]));

  printf("%d\n", dp[N-1]);
}


Measured memory_bytes: 1024
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n;
string s1, s2;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n;
	cin >> s1 >> s2;
	
	if (sz(s1) == 1) {
		cout << 3;
		return 0;
	}
	
	ll ans;
	int tar, pre;
	if (s1[0] == s1[1]) {
		ans = 6;
		tar = 2;
		pre = 0;
	}
	else {
		ans = 3;
		tar = 1;
		pre = 1;
	}

	for (int i=tar; i<n;) {
		if (i + 1 < n) {
			if (s1[i] == s1[i + 1]) {
				if (pre) ans = ans * 2ll % MOD;
				else ans = ans * 3ll % MOD;
				i += 2;
				pre = 0;
			}
			else {
				if (pre) ans = ans * 2ll % MOD;
				i++;
				pre = 1;
			}
		}
		else {
			if (pre) ans = ans * 2ll % MOD;
			i++;
			pre = 1;
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

g = [[] for _ in range(N+1)]
ig = [[] for _ in range(N+1)]
for _ in range(M):
    x, y = map(int, input().split())
    g[x].append(y)
    ig[y].append(x)

dp1 = [0] * (N+1)
dp2 = [0] * (N+1)
dp1[1] = 1

for i in range(1, N+1):
    for j in ig[i]:
        dp1[i] += dp1[j]/len(g[j])
df = 0
for i in range(N, 0, -1):
    t = 0
    for v in g[i]:
        t += (dp2[v]+1)
    if len(g[i]) > 0:
        dp2[i] = t/len(g[i])
    if len(g[i]) == 1:
        continue
    for v in g[i]:
        pv = (t-dp2[v]-1)/(len(g[i])-1)
        df = max(df, dp1[i]*(dp2[i]-pv))
print(dp2[1]-df)


Measured memory_bytes: 61532
use std::cmp::min;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let abcde: Vec<i32> = (0..5).map(|_| read()).collect();

    let mut min_i = std::i32::MAX;

    for &x in &abcde {
        if x % 10 != 0 {
            min_i = min(x % 10, min_i);
        }
    }
    let ans = abcde
        .iter()
        .fold(0, |a, &x| a + if x % 10 == 0 { x } else { x + 10 - x % 10 })
        - if min_i == std::i32::MAX {
            0
        } else {
            10 - min_i % 10
        };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int arr[7]={1,2,4,8,16,32,64};
    int N;
    int temp;
    
    cin >> N;
    
    for(int i=0; i < N; i++){
        temp = arr[i];
        if(temp > N){
          temp = arr[i-1];
          break;
        }
    }
    
    cout << temp;
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int V[MAX_N], C[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> V[i];
	rep(i, 0, N) cin >> C[i];
	ll sum = 0;
	rep(i, 0, N) {
		sum += max(V[i] - C[i], 0);
	}
	cout << sum << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,s=0;
int main(){
  scanf("%d%d",&n,&m);
  int x;
  for(int i=1;i<=m;i++){
    scanf("%d",&x);
    s+=x;
  }
  if(s>=n) printf("Yes\n");
  else printf("No\n");
}

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

int main(){
  vector<int> a(5), b(5);
  
  for(int i = 0; i < 5; i++){
  	cin >> a.at(i);
    b.at(i) = a.at(i)%10;
  }
  
  int m = 9;
  
  for(int i = 0; i < 5; i++){
  if(a.at(i)%10!=0){
  	m = min(m, a.at(i)%10);
    a.at(i) = (a.at(i)/10)*10+10;
  }
  }
  int sum = a.at(0)+a.at(1)+a.at(2)+a.at(3)+a.at(4);
  
  if(b.at(0)==0&&b.at(2)==0&&b.at(3)==0&&b.at(4)==0&&b.at(1) == 0){
  	cout << sum << endl;
  }
  else{
  	cout << sum - 10 + m << endl;
  }
  
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  s.at(3) = '8';
  cout << s <<endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N,n,a[500000],id[500000][2],ans=0;
inline bool cmp(int x,int y){
    return a[x]<a[y];
}
int main(){
    scanf("%d",&N);
    n=1<<N;
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    a[n]=0;
    id[0][0]=0,id[0][1]=n;
    for (int i=1;i<n;i++){
        id[i][0]=i,id[i][1]=n;
        int x[4];
        for(int j=0;j<N;j++){
            if(i&(1<<j)){
                int t=i^(1<<j);
                x[0]=id[i][0],x[1]=id[i][1],x[2]=id[t][0],x[3]=id[t][1];
                sort(x,x+4,cmp);
                id[i][0]=x[3];
                if(x[2]==x[3]) id[i][1]=x[1];
                else id[i][1]=x[2];
            }
        }
    }
    for(int i=1;i<n;i++){
        ans=max(ans,a[id[i][0]]+a[id[i][1]]);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 7936
using System;
using System.Linq;
using System.Collections.Generic;
class P{
    static void Main(){
        var d=Console.ReadLine().Split().Select(long.Parse).ToArray();
        var B=Console.ReadLine().Split().Select(long.Parse).ToArray();
        int ans=0;
        for(int i=0;i<d[0];i++)if(Console.ReadLine().Split().Select(int.Parse).Zip(B,(x,y)=>x*y).Sum() + d[2]>0)ans++;
        Console.WriteLine(ans);
    }
}

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

using namespace std;
typedef long long int ll;
const ll INF=1e18L+5;
int main(){
ll n,W;
cin>>n>>W;

vector<ll> weight(n),val(n);
for(int i=0;i<n;i++){
    cin>>weight[i]>>val[i];
}
int sum_val=0;
for(auto v:val){
   sum_val+=v;
}

vector<ll> dp(sum_val+1,INF);//0..W

dp[0]=0;
for(int item=0;item<n;item++){
     
     for(int value_already=sum_val-val[item];value_already>=0;value_already--){
         /* 
            
         */
         dp[value_already+val[item]]=min(dp[value_already+val[item]],dp[value_already]+weight[item]);
     }
     /*cout<<"\n";

     for(auto val:dp){
        cout<<val<<" ";
     }
     cout<<"\n";*/	
}
ll ans=0;
for(int i=0;i<=sum_val;i++){
   if(dp[i]<=W){
      ans=max(ans,(ll)i);  
   }
   
}
cout<<ans<<"\n";
}

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

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

    int current_min = N;
    int ans = 0;
    for (int i = 0; i < N; i++){
        int c;
        cin >> c;
        if (i == 0 or c < current_min){
            ans += 1;
        }
        current_min = min(current_min, c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc091/tasks/abc091_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b,c;
    cin >> a >> b >> c;
    cout << (a + b >= c ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long int a,b,k, res1, res2;
    cin>>a>>b>>k;
    if(k > a){
        res1 = 0;
        res2 = b-(k - a) < 0? 0 : b-(k - a);
    }else{
        res1 = a-k;
        res2 = b;
    }
    cout<<res1<<" "<<res2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;
using boost::algorithm::join;
// TOP

void	Main()
{
	int n;
	cin >> n;
	int	cnt;
	cnt = 0;
	rep(i, n)
	{
		int x;
		cin >> x;
		while (x % 2 == 0)
		{
			x /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
}
// END
















int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import sys
from operator import itemgetter
from collections import deque

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, d, a = na()
ms = []
for i in range(n):
    ms.append(na())

ms.sort(key=itemgetter(0))
pq = deque()
dmg = 0
ans = 0
for i in range(n):
    while len(pq) > 0 and pq[0][0] <= ms[i][0]:
        dmg -= pq[0][1]
        pq.popleft()

    h = ms[i][1]
    x = ms[i][0]
    h -= dmg
    if h > 0:
        nu = (h+a-1)//a
        ans += nu
        dmg += a*nu
        pq.append((x+2*d+1, a*nu))

print(ans)


Measured memory_bytes: 85852
#include<stdio.h>
#define X 1000000000

int minim(int a,int b){if(a > b){return b;}return a;}

int main(void){
	int dp[128][128]={0};
	int n,m,a[1024],b[1024],c[1024];
	int i,j,k,r=0;
	scanf("%d%d",&n,&m);
	for(i = 1;i <= m;i++){scanf("%d%d%d",&a[i],&b[i],&c[i]);}
	for(i = 0;i <= 127;i++){
		for(j = 0;j <= 127;j++){dp[i][j] = X;if(i == j){dp[i][j]=0;}}
	}
	for(k = 1;k <= m;k++){
		dp[(a[k])][(b[k])] = c[k];
		dp[(b[k])][(a[k])] = c[k];
	}
	for(k = 1;k <= n;k++){
		for(i = 1;i <= n;i++){
			for(j = 1;j <= n;j++){dp[i][j] = minim(dp[i][j],dp[i][k]+dp[k][j]);}
		}
	}
	for(k = 1;k <= m;k++){
		if(dp[(a[k])][(b[k])] < c[k]){r++;}
	}
	printf("%d\n",r);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define bin(x,b) bitset<b> vb(x); cout << vb << '\n';

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ll;
typedef pair <int,int> pi;

const long double EPS = 1e-10;
const ll MOD = 1e9 + 7;
const long double PI = 3.1415926535897932384626433832795028841;

ll powmod(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}


const int maxn = 1e5 + 5;
const int maxm = 1e5 + 5;
const int maxk = 1e5 + 5;

int main(){
	ll X,Y; cin >> X >> Y;
	ll el = X;
	int cnt = 0;
	do{
		el *= 2;
		cnt ++;
	}while (el <= Y);
	cout << cnt << '\n';
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemD solver = new ProblemD();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemD {
		long min1;
		long min2;
		boolean ans = true;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int height = in.nextInt();
			int width = in.nextInt();
			int n = in.nextInt();
			List<Edge>[] edges = new List[height + width];
			for (int i = 0; i < edges.length; i++) {
				edges[i] = new ArrayList<>();
			}
			for (int i = 0; i < n; i++) {
				int r = in.nextInt() - 1;
				int c = in.nextInt() - 1;
				int a = in.nextInt();
				edges[r].add(new Edge(height + c, a));
				edges[height + c].add(new Edge(r, a));
			}
			boolean[] was = new boolean[edges.length];
			long[] val = new long[edges.length];
			for (int i = 0; i < edges.length; i++) {
				if (!was[i]) {
					min1 = Long.MAX_VALUE / 2;
					min2 = Long.MAX_VALUE / 2;
					dfs(i, height, edges, was, val);
					if (min1 + min2 < 0) {
						ans = false;
					}
				}
			}
			out.println(ans ? "Yes" : "No");
		}

		private void dfs(int v, int height, List<Edge>[] edges, boolean[] was, long[] val) {
			was[v] = true;
			if (v < height) {
				min1 = Math.min(min1, val[v]);
			} else {
				min2 = Math.min(min2, val[v]);
			}
			for (Edge e : edges[v]) {
				int u = e.dst;
				if (was[u] && val[u] + val[v] != e.w) {
					ans = false;
				}
				if (!was[u]) {
					val[u] = e.w - val[v];
					dfs(u, height, edges, was, val);
				}
			}
		}

		class Edge {
			int dst;
			long w;

			Edge(int dst, long w) {
				this.dst = dst;
				this.w = w;
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 74884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main(){
  int l, r;
  cin >> l >> r;
  int ans = 0;
  if (r-l < 2019 && (l%2019) < (r%2019)) {
    ans = 2019;
    l %= 2019;
    r %= 2019;
    for (int i = l;i < r;i++) {
      for (int j = l+1;j < r+1;j++) {
        ans = min(ans, (i*j)%2019);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) a[i]=0;
  for(int i=0;i<n-1;i++){
    int x;
    cin>>x;
    a[x-1]++;
  }
  for(int i=0;i<n;i++) cout<<a[i]<<endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

using std::vector;
using std::printf;
using std::cout;
using std::endl;
using std::string;
using std::cin;
using std::pair;
using std::sort;
using std::priority_queue;
using std::sqrt;

#define i64t long long int
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

template<typename T>
void dump(vector<T> vec) {
    for (auto x : vec) {
        std::cout << x << " ";
    }
    std::cout << std::endl;
}

// ---------------------------

const i64t MOD = 1000000007;

vector<i64t> prime;
i64t maxCheck;

void createPrimeTable() {
    prime = vector<i64t>(maxCheck+1, -1);
    prime[1] = 0;
    // dump<int>(prime);
    for (i64t i = 2; i <= maxCheck; ++i) {
        if (prime[i] == -1) {
            prime[i] = 1;
            for (i64t j = i + i; j <= maxCheck; j += i) {
                prime[j] = 0;
            }
        }
        else if (prime[i] == 0) {
            // do nothing
        }
        else {
            printf("Something is wrong!");
        }
    }
}

bool isPrime(i64t num) {
    return (prime[num] == 1);
}

i64t getGCD(i64t a, i64t b) {
    i64t aa = a, bb = b;
    i64t cc = 1;
    while (cc != 0) {
        // printf("getGCD: %lld %lld\n", aa, bb);
        cc = aa % bb;
        aa = bb;
        bb = cc;
    }
    return aa;
}

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

    maxCheck = 2000000;
    i64t gcd = getGCD(A, B);

    createPrimeTable();

    // 公約数の素因数分解表現を得る
    i64t tgcd = gcd;
    vector<i64t> youso;
    vector<i64t> kazu;
    for (i64t i = 2; i < maxCheck; ++i) {
        i64t cnt = 0;
        if (isPrime(i)) {
            // printf("%d is Prime!\n", i);
            while (1) {
                if (tgcd % i == 0) {
                    cnt++;
                    tgcd /= i;
                }
                else {
                    break;
                }
            }
            if (cnt != 0) {
                youso.push_back(i);
                kazu.push_back(cnt);
            }
        }
    }
    if (tgcd != 1) {
        youso.push_back(tgcd);
        kazu.push_back(1);
    }

    // printf("gcd: %lld\n", gcd);
    // dump<i64t>(youso);
    // dump<i64t>(kazu);

    i64t nnn = youso.size();
    printf("%lld", nnn+1);

}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    if(h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }

    cout << (h*w+1)/2 << endl;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    string S, T;
    cin >> S >> T;
    int ans = INF;
    rep(i,S.size()-T.size()+1){
        int t = 0;
        rep(j,T.size()){
            if(S[i+j] != T[j]) t++;
        }
        chmin(ans, t);
    }
    cout << ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3636
h, w = map(int, input().split())
a = []
for i in range(h):
    line = input()
    if line != "." * w:
        a.append(list(line))

h = len(a)

w_pass =[]
for i in range(w):
    for j in range(h):
        if a[j][i] != ".":
            break
    else:
        w_pass.append(i)

for i in range(h):
    line = ""
    for j in range(w):
        if j in w_pass:
            pass
        else:
            line += a[i][j]
    print(line)


Measured memory_bytes: 9000
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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 dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
vector<int> a(101);


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,mx=0,mn=0,in;
    cin >> n;
    cin >> in;
    mx = in;
    mn = in;
    for (int i = 1; i < n; ++i) {
        cin >> in;
        mx = max(mx, in);
        mn = min(mn, in);
    }
    cout << mx - mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a,b;
char ch;
int main()
{
    long long n;
    while (~scanf("%lld",&n)){
        long long l =0, r = 0;
        for (long long i = 0; i < n; i++){
            scanf("%lld %c %lld",&a,&ch,&b);
            if (ch == '(')
                l += b;
            else
                r += b;

        if (l == r)puts("Yes");
        else puts("No");
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    int k,a,b;
    cin >> k >> a >> b;
    for (int i = 1; i <= 1001;i++)
    {
        if(i*k>=a && i*k<=b)
        {
            cout << "OK\n";
            return;
        }
    }
    cout << "NG\n";
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
 long a,b,k,c,d;
 scanf("%ld %ld",&a,&b);
 if(a!=b){
    k=(a+b)/2;
    c=abs(a-k);
    d=abs(b-k);}
 if(c==d)
        printf("%ld\n",k);
   else
        printf("IMPOSSIBLE\n");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ini(x0,y0,x1,y1);
		string tmp;
		int tmp1 = 0;
		tmp1+=y1-y0;
		while(tmp1--)tmp+='U';
		tmp1=x1-x0;
		//out(1,tmp1);
		while(tmp1--)tmp+='R';
		tmp1=y1-y0;
		while(tmp1--)tmp+='D';
		tmp1=x1-x0;
		while(tmp1--)tmp+='L';
		tmp+='L';
		tmp1=y1-y0;
		tmp1++;
		//out(2,tmp1);
		while(tmp1--)tmp+='U';
		tmp1=x1-x0;
		tmp1++;
		while(tmp1--)tmp+='R';
		tmp+='D';
		tmp+='R';
		tmp1=y1-y0;
		tmp1++;
		while(tmp1--)tmp+='D';
		tmp1=x1-x0;
		tmp1++;
		while(tmp1--)tmp+='L';
		tmp+='U';
	out(tmp);







	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (sx, sy, tx, ty) = intList()

    buildString {
        val x = tx - sx
        val y = ty - sy
        repeat(y) {
            append('U')
        }
        repeat(x) {
            append('R')
        }
        repeat(y) {
            append('D')
        }
        repeat(x) {
            append('L')
        }
        append('L')
        repeat(y) {
            append('U')
        }
        append('U')
        repeat(x) {
            append('R')
        }
        append('R')
        append('D')
        append('R')
        repeat(y) {
            append('D')
        }
        append('D')
        repeat(x) {
            append('L')
        }
        append('L')
        append('U')
    }.let {
        println(it)
    }
}

Measured memory_bytes: 36208
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long		
int a[214514];
int b[214514];
signed main(){
	ic(n)
	rep(0,i,n+1)cin>>a[i];
	rep(0,i,n)cin>>b[i];
	int sum=0;
	rep(0,i,n){
		if(b[i]<a[i]){
			sum+=b[i]; 
		}
		else{
			if(a[i]+a[i+1]>=b[i]){
				sum+=b[i];
				a[i+1]=a[i+1]-b[i]+a[i];
			}
			else{
				sum+=a[i]+a[i+1];
				a[i+1]=0;
			}	
			a[i]=0;
		}
	}
	c(sum)
}			

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

int main() {
	cin >> m >> n;
	vector <ll> ans(m);
	rep(i, n) cin >> ans[i];
	rep(i, n) {
		m = m - ans[i];
	}
	if (m >= 0) {
		cout << m;
	}
	else {
		cout << "-1";
	}
	return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

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

    for (int i = M / N; i >= 1; i--)
    {

        if (M % i == 0)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 3644