akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a;cin >> a;
    string str;cin >> str;

    cout << (a >= 3200 ? str : "red") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = INF;
    for (char i = 'a'; i <= 'z'; i++) {
        ll right = 0;
        ll tmp = 0;
        for (ll left = 0; left < n; left++) {

            while(right<n and s[right]!=i){
                right++;
            }
            chmax(tmp, right - left);
            if (right == left) right++;
        }
        chmin(ans, tmp);
    }
        cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin>>n;
    int p[n];
    vector<int>c[n];
    rep(i,1,n-1){
        cin>>p[i];
        p[i]--;
        c[p[i]].pb(i);
    }
    ll ans[n];rep(i,0,n-1)cin>>ans[i];
    vector<int>d[1000];
    d[0].pb(0);
    int lastd=-1;
    for(int i=0;d[i].size()!=0;i++){
        for(auto x:d[i]){
            for(auto y:c[x]){
                d[i+1].pb(y);
            }
        }
        lastd=i;
    }
    ll dp[n];
    for(int k=lastd;k>=0;k--){
        for(auto x:d[k]){
            if(c[x].size()==0){
                dp[x]=0;
            }else{
                ll sum=0;
                int siz=c[x].size();
                
                    vector<ll>v[2];v[0].pb(0);
                    rep(i,0,siz-1){
                        for(auto val:v[i&1]){
                            v[(i+1)&1].pb(val+ans[c[x][i]]);
                            v[(i+1)&1].pb(val+dp[c[x][i]]);
                        }
                        sum+=ans[c[x][i]];
                        sum+=dp[c[x][i]];
                        v[i&1].clear();
                        sort(v[(i+1)&1].begin(),v[(i+1)&1].end());
                        v[(i+1)&1].erase(unique(v[(i+1)&1].begin(),v[(i+1)&1].end()),v[(i+1)&1].end());
                    }
                
                ll mipos=upper_bound(v[siz&1].begin(),v[siz&1].end(),ans[x])-v[siz&1].begin();
                if(mipos<=0){
                    //cout<<x<<" ";
                    cout<<"IMPOSSIBLE"<<endl;
                    return 0;
                }
                dp[x]=sum-v[siz&1][mipos-1];
            }
        }
    }
    /*rep(i,0,n-1){
        cout<<i<<" "<<dp[i]<<endl;
     }*/
    
    cout<<"POSSIBLE"<<endl;
    
    return 0;
    
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 100000000007ll; 

int main(void)
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for(ll&x:a) cin >> x;
  double dprod=1.0;
  for(ll x:a) dprod*=x;
  if(dprod>2e18) {
    cout << -1 << endl;
    return 0;
  }
  ll prod = 1;
  for(ll x:a) prod*=x;
  if(prod>1000000000000000000ll) prod = -1ll;
  cout << prod << endl;
  return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	char s[15],t[15];
	while(~scanf("%s%s",s,t)){
		int l=strlen(s);
		bool ok=1;
		F(i,0,l) if(s[i]!=t[i]) ok=0;
		puts(ok==1?"Yes":"No");
	}
}


Measured memory_bytes: 3764
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    S = Scanner.string()
    T = Scanner.string()
    ma = len(S) - len(T) + 1
    ans = len(T)
    for i in range(0, ma):
        cnt = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') {
      cnt++;
    }
  }
  if (cnt + 15 - s.size() >= 8) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//@editor aokabi
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
const int INF = 1e9;
typedef long long LL;
typedef pair<LL, LL> P;
int main() {
    LL N, H;
    cin >> N >> H;
    vector<LL> a(N), b(N);
    for(int i=0; i<N; i++) cin >> a[i] >> b[i];
 
    // 振り最強剣
    LL a_max = *max_element(all(a));
    // 強いものから投げる
    sort(all(b));
    reverse(all(b));
    LL ans = 0;
    for(int i=0; i<N; i++){
        if(a_max < b[i]){
            H -= b[i];
            ans++;
            // 投げで倒した
            if(H <= 0) break;
        }
    }
    // 剣を振りまくって倒す
    if(H > 0) ans += (H + (a_max-1)) / a_max;
    cout << ans << endl;
}

Measured memory_bytes: 1792
N, D = map(int, input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        t = 0
        for k in range(D):
            t += (X[i][k] - X[j][k]) ** 2
        t = t **(1/2)
        if t.is_integer():
            ans += 1
print(ans)
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 200005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int n;
int cap;
int w[N];
int v[N];
ll dp[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> n >> cap;
    for(int i=1;i<=n;i++)
        cin >> w[i] >> v[i];
    
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 100000; j - v[i] >= 0; j--)
            dp[j] = min(dp[j], w[i] + dp[j - v[i]]);

    int ans = 0;
    for(int j=0;j<=100000;j++)
        if (dp[j] <= cap)
            ans = j;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
const int mod=1e9+7;
char m[1005][1005];
int dp[2][10005];
int main() {
	
	int h,w;
	cin>>h>>w;
	dp[0][1]=1;
	int a=1,b=0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>m[i][j];
		

/*	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++)
			cout<<m[i][j];
	
		cout<<endl;
	}
	*/
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(m[i][j]=='#')
				dp[a][j]=0;
			else dp[a][j]=(dp[b][j]+dp[a][j-1])%mod;
		}
		swap(a,b);
	}
	cout<<dp[b][w];
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  ll N;
  cin>>N;

  ll keta=0;

  ll n=N;
  rep(i,9){
    keta+=n%10; n/=10;
  }

  cout<< ( N%keta==0 ? "Yes" : "No" )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
using namespace std;

using ll = long long;

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

  int r=0, l=0;
  for(int i=0; i<n; i++){
    if(s[i]=='E'){
      r++;
    }
    else{
      l++;
    }
  }

  int ans = l, m = 0;

  for(int i=0; i<n; i++){
    if(s[i] == 'E'){
      m = max(ans, m);
      ans++;
    }
    else{
      ans--;
      m = max(ans, m);
    }
  }

  cout << n-m-1 << endl;

  return 0;
}


Measured memory_bytes: 900
#include <iostream>

int ways(int n)
{
	if (n==1) return 1;
	else if (n==2) return 2;
	else {
		int* DP = new int[n+1];
		DP[0] = 1; DP[1] = 1; DP[2] = 2;
		for (int i=3; i<=n; i++) {
			DP[i] = DP[i-1] + DP[i-2] + DP[i-3];
		}
		int res = DP[n];
		delete[] DP;
		return res;
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int w = ways(n);
		int d = w / 10;
		if (w%10>0) d++;
		int y = d / 365;
		if (d%365>0) y++;
		std::cout << y << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a[2001],v[2001];
    int n,x;
    cin>>n>>x;
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        v[i]=a[i];
        ans+=a[i];
    }
    for(int i=1;i<n;i++){
        ll now=1LL*i*x;
        for(int j=0;j<n;j++)
            now+=(v[(j+i)%n]=min(v[(j+i)%n],a[j]));
        ans=min(ans,now);
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    string ans;
    while(n) {
        --n;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
using namespace std;
int main(void){
    string in;
    string hyou="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
    string kkk=" .",sen="th",sen1="eisat";
    while(getline(cin,in)){
        for(int s=1;s<=26;s++){
            string out="";
            for(int i=0;i<in.length();i++){
                if(in[i]==kkk[0]||in[i]==kkk[1]){
                    out+=in[i];
                }
                for(int k=0;k<26;k++){
                    if(in[i]==hyou[k]){
                        out+=hyou[k+s];
                        break;
                    }
                }
            }
            bool sw=0;
            for(int i=0;i<out.length();i++){
                if(out[i]==sen[0]&&out[i+1]==sen[1]){
                    if(out[i+2]==sen1[0]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }else if(out[i+2]==sen1[1]&&out[i+3]==sen1[2]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }else if(out[i+2]==sen1[3]&&out[i+3]==sen1[4]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }
                }
            }
            if(sw==1)break;
        }
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int main(void)
{
    int n;
    int a[200];

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 0;
    while (1) {
        ans++;
        for (int i = 0; i < n; i++) {
            a[i] /= 2;
            if (a[i] % 2 != 0) {
              cout << ans << endl; 
              return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(x >= r && y >= r && x <= w - r && y <= h - r) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1820
#include<stdio.h>
int main(void){
int x,a,b;
scanf("%d %d %d",&x,&a,&b);
a=x-a;
b=x-b;
if(a<0) a=-a;
if(b<0) b=-b;
if(a<b) printf("A");
else printf("B");
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> d(N);
  REP(i, N) cin >> d[i];
  sort(ALL(d));
  const ll M1 = N / 2 - 1;
  const ll M2 = M1 + 1;
  cout << d[M2] - d[M1] << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

ll solve(ll N, ll P, string S)
{
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}


int main()
{
    ll N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    ll cnt = 0;
    if(P == 2 || P == 5) {
        REP(i,0,N) {
            if((S[N-i-1] - '0') % P == 0) cnt += N - i;
        }
    }
    else {
        vec C(N+1, 0);
        ll d = 1;
        REP(i,0,N) {
            C[i+1] = (C[i] + (S[N-i-1] - '0') * d) % P;
            d = (d * 10) % P;
        }
        map<ll,ll> V;
        REP(i,0,N+1) ++V[C[i]];
        FORR(v,V) cnt += v.second * (v.second-1) / 2;
    }

    PR(cnt);

    return 0;
}

/*


*/

Measured memory_bytes: 5416
#include <iostream>
#define MAX_CARD_NUM 40
// #include <bits/stdc++.h>
using namespace std;

struct Card { char suit, value; };

void print(Card A[], int N) {
    cout << A[0].suit << A[0].value;
    for (int i=1; i < N; i++) {
        cout << " " << A[i].suit << A[i].value;
    }
    cout << endl;
}

void bubbleSort(Card A[], int N) {
    bool flag = 1;
    for (int i=0; flag; i++) {
        flag = 0;
        for (int j=N-1; j > i; j--) {
            if (A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
    return;
}

void selectionSort(Card A[], int N) {
    int minj;
    for (int i=0; i < N-1; i++) {
        minj = i;
        for (int j=i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        if (i != minj) {
            swap(A[i], A[minj]);
        }
    }
    return;
}

bool isMatch(Card C1[], Card C2[], int N) {
    for (int i=0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    int n;
    Card C1[MAX_CARD_NUM], C2[MAX_CARD_NUM];

    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }
    bubbleSort(C1, n);
    selectionSort(C2, n);

    print(C1, n);
    cout << "Stable" << endl;
    print(C2, n);
    if (isMatch(C1, C2, n)) {
       cout << "Stable" << endl; 
    } else {
       cout << "Not stable" << endl;  
    }
} 


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<int>A(2*M);
  for(int i=0;i<2*M;i++)
    cin>>A.at(i);
  for(int i=1;i<=N;i++){
  int sum=0;
    for(int j=0;j<2*M;j++){
    if(i==A.at(j)) sum++;
    } cout<<sum<<endl;
  
  }
  
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

vector<pii> g[20];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   f(i,0,n){
      int a;
      cin >> a;
      f(j,0,a){
         int x,y;
         cin >> x >> y;
         x--;
         g[i].pb({x,y});
      }
   }
   int ans = 0;
   f(i,0,(1<<n)){
      set<int> chk[n+5];
      vector<int> vis(n+5,0);
      int c = 1;
      int cnt = 0;
      queue<int> q;
      f(j,0,n){
         if(i&(1<<j)){
            chk[j].insert(1);
            q.push(j);
         }
      }
      while(!q.empty()){
         int tp = q.front();
         q.pop();
         if(vis[tp]) continue;
         cnt++;
         vis[tp] = 1;
         for(auto &v : g[tp]){
            chk[v.F].insert(v.S);
            if(v.S == 1){
               q.push(v.F);
            }
         }
      }
      f(j,0,n){
         if((int)chk[j].size() >= 2){
            c = 0;
            break;
         }
      }
      if(c){
         ans = max(ans,cnt);
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    sort(a, a + N);
    ll ans = 0;
    if (a[0] % 2 == 1) {
        ans = N;
    }
    REP(i, 1, N) {
        if ((a[i] - a[i - 1]) % 2 == 1) {
            ans ^= N - i;
        }
    }
    if (ans != 0) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
}


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

using namespace std;
typedef long long LL;

int main(){
  int D, N;
  cin >> D >> N;
  int ans;
  if(N==100) ans=101*pow(100,D);
  else ans=N*pow(100,D);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			int n = scanner.nextInt();
			
			int count = 0;
			for(int i=0; i<10000; i++)
			{
				int sum = 0;
				for(int j=0, m=i; j<4; j++, m/=10)
				{
					sum += m%10;
				}
				if(sum == n)
				{
					count ++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26676
#include "stdio.h"
#include "math.h"

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem0146 : Lupin The 4th **/
typedef pair<double, vector<int> > P;

int kura[16];
int dis[16];
int weight[16];
P dp[1<<16][16];
P ans;
int N;


P check(int S, int n, int w)
{
	P res(INF, vector<int>());
	
	if (dp[S][n].first<INF) {
		return dp[S][n];
	}
	
	if (S == (1<<N)-1) {
		res.second.push_back(n);
		res.first = 0;
		return dp[S][n] = res;
	}
	
	P min(INF, vector<int>());
	rep(i, N) {
		if (!((S>>i)&1)) {
			P time = check(S|(1<<i), i, w+weight[i]);
			time.first += double(abs(dis[i]-dis[n]))/(2000/(double)(70 + w));

			if (min.first>time.first) {
				min = time;
			}
		}
	}
	res=min;
	res.second.push_back(n);

	return dp[S][n] = res;
}

int main()
{
	cin>>N;
	rep(i, N) {
		cin>>kura[i]>>dis[i]>>weight[i];
		weight[i]*=20;
	}
	rep(i, N) {
		rep(j, 1<<16) {
			dp[j][i].first = INF;
			dp[j][i].second.clear();
		}
	}
	
	double min=INF;
	rep(i, N) {
		P time = check(1<<i, i, weight[i]);
		time.first += (double)dis[i]/((double)2000/(70));
		if (min>time.first) {
			min = time.first;
			ans = time;
		}
	}
	
	reverse(ans.second.begin(), ans.second.end());
	rep(i, N-1) {
		cout << kura[ans.second[i]] << " ";
	}
	cout << kura[ans.second[N-1]] << endl;
	return 0;
}

Measured memory_bytes: 45036
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9+7;
unordered_map<int,int> mapa;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	for(int i = 1;i<=n;i++){
		int atual=i;
		for(int j = 2;j*j<=atual;j++){
			while(atual%j == 0){
				mapa[j]++;
				atual/=j;
			}
		}
		if(atual!=1)
			mapa[atual]++;
	}
	ll ans = 1;
	for(auto it: mapa){
		if(it.first!=1){
			ans*=(it.second+1);
			ans%=M;
		}
	
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int m,f,r;
  int sum;
  while(1) {
    cin >> m >> f >> r;
    if(m==-1&&f==-1&&r==-1) break;
    sum = m + f;
    if(m==-1||f==-1) {
      cout << "F" << endl;
    } else if(sum>=80) {
      cout << "A" << endl;
    } else if(sum<80&&sum>=65) {
      cout << "B" << endl;
    } else if(sum<65&&sum>=50) {
      cout << "C" << endl;
    } else if(sum<50&&sum>=30) {
      if(r>=50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else {
      cout << "F" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3096
let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
  Array.init h (fun i -> 
    Array.to_list @@ Array.init w (fun j -> (i, j)))
  |> Array.to_list
  |> List.concat
  |> List.for_all (fun (i, j) ->
      ss.(i).[j] = '.' || 
        List.exists (fun (i, j) ->
          try ss.(i).[j] = '#' with _ -> false)
        [(i + 1, j); (i - 1, j); (i, j + 1); (i, j - 1) ])
  |> function
    | true -> print_endline "Yes"
    | false -> print_endline "No"

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n)
    {
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
(function() {
	var S = parseInt(require('fs').readFileSync('/dev/stdin').toString());
	var str = String(S % 60);
	S = Math.floor(S / 60);
	str = String(S % 60) + ":" + str;
	str = String(Math.floor(S / 60)) + ":" + str;
	console.log(str);
}) ();

Measured memory_bytes: 15492
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 0; i <= b; i++) {
        if((a * i) % b == c) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

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

int n;
char s1[55], s2[55];
const int MOD = 1000000007;
int main()
{
//    freopen("ciorna.in", "r", stdin);
    scanf("%d", &n); scanf("%s", s1 + 1); scanf("%s", s2 + 1);
    if(n == 1) {printf("3"); return 0;}
    if(n == 2) {printf("6"); return 0;}
    long long Sol = 1;
    int i = 1, ok = 0;
    while(i <= n){
        if(s1[i] == s2[i]){
            if(i == 1) Sol = Sol * 3;
            else if(ok == 0)Sol = (Sol * 2) % MOD;
            ok = 0;
            ++i;
        }
        else{
            if(i == 1) Sol = 6;
            else if(ok == 1)Sol = (Sol * 3) % MOD;
            else Sol = (Sol * 2) % MOD;
            ok = 1;
            i += 2;
        }
    }
    printf("%lld", Sol);
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int count = 0;
        count = x / y;
        count += x % y;
        System.out.println(count);
    }
}

Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(int p=2;p*p<=10000000;p++){
        if(prime[p]){
            if(p%5==1) v.push_back(p);
            for(int q=p*p;q<=10000000;q+=p){
                prime[q]=false;
            }
        }
    }
    return;
}


ll dif(string s,string p){
    ll a=(s[0]-'0')*100+(s[1]-'0')*10+(s[2]-'0');
    ll b=(p[0]-'0')*100+(p[1]-'0')*10+(p[2]-'0');
    return(abs(a-b));
}
bool is357(ll i){
    bool a=false,b=false,c=false;
    while(i){
        if(i%10==3) a=true;
        else if(i%10==5) b=true;
        else if(i%10==7) c=true;
        else return(false);
        i/=10;
    }
    return(a&b&c);
}
ll N,ans=0;
void dfs(ll i,bool a,bool b,bool c){
    if(i>N) return;
    if(a&& b&&c) ans++;
    dfs(i*10+3,true,b,c);
    dfs(i*10+5,a,true,c);
    dfs(i*10+7,a,b,true);
    return;
}
int main(){
    IO

    ll power[11];
    power[0]=1;
    for(int i=1;i<=10;i++) power[i]=power[i-1]*10;
    cin>>N;
    //N=999999999;
    /*
    queue<ll> q;
    int dp[11];
    memset(dp,0,sizeof dp);
    dp[0]=0;dp[1]=0;dp[2]=0;dp[3]=6;dp[4]=36;dp[5]=150;dp[6]=540;dp[7]=1806,dp[8]=5796,dp[9]=18150;
    //for(ll i=100000000;i<=999999999;i++) if(is357(i)) cout<<i<<endl;
    //cout<<dp[9];
    ll p=log10(N);

    for(ll i=0;i<=p+1;i++) ans+=dp[i];
    if(N%2==0) N++;
    else N+=2;
    for(ll i=N;i<=power[p+1]-3;i+=2) if(is357(i)) ans--;
    */
    dfs(0,false,false,false);
    cout<<ans;
    return(0);
}


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string param = getStringParam();

            int ret = 0;
            if (param.Contains("RRR"))
            {
                ret = 3;
            }
            else if (param.Contains("RR"))
            {
                ret = 2;
            }
            else if (param.Contains("R"))
            {
                ret = 1;
            }
            Console.WriteLine(ret);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }

    }
}


Measured memory_bytes: 25872
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

class union_find_tree
{
private:
	int N;
	vector<int> parents, rank, node_cnt;

public:
	// n要素で初期化
	void init(int n)
	{
		parents.resize(n);
		for (int i = 0; i < n; i++)
			parents[i] = i;
		rank.resize(n, 0);
		node_cnt.resize(n, 1);
		N = n;
	}

	// 木の根を求める
	int find(int x)
	{
		if (parents[x] == x) {
			return x;
		} else {
			parents[x] = find(parents[x]);
			return parents[x];
		}
	}

	// xとyの属する集合を併合
	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
			return;

		if (rank[x] < rank[y]) {
			parents[x] = y;
			node_cnt[y] += node_cnt[x];
		} else {
			parents[y] = x;
			node_cnt[x] += node_cnt[y];
			if (rank[x] == rank[y])
				rank[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}

	// 親を取得
	int get_parent(int x)
	{
		return parents[x];
	}

	// ルートかどうか
	bool is_root(int x)
	{
		return parents[x] == x;
	}

	// グループの総数
	int number_of_groups()
	{
		int cnt = 0;
		for (int i = 0; i < N; i++)
			if (is_root(i))
				cnt++;
		return cnt;
	}

	// グループ内のノードの数
	int group_size(int x)
	{
		return node_cnt[find(x)];
	}
};

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	int p[100000];
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}

	union_find_tree tree;
	tree.init(N);
	for (int i = 0; i < M; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		tree.unite(x, y);
	}

	int res = 0;
	for (int i = 0; i < N; i++)
		if (tree.same(i, p[i]))
			res++;

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

	return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String[] lines=br.readLine().split(" ");
       double[] list=new double[4];
       int n=4;
       while(n-->0){
           list[n]=Double.parseDouble(lines[n]);
       }
       System.out.println(Math.sqrt((list[0]-list[2])*(list[0]-list[2])+(list[1]-list[3])*(list[1]-list[3])));
       
    }
}

Measured memory_bytes: 24484
#include <stdio.h>
#include <math.h>
int primes[10001];
int buf2[10001];

int main()
{
	int len, res, len_primes, len_buf2;
	scanf("%d", &len);
	primes[0] = 2;
	buf2[0] = 0;
	len_primes = 1;
	len_buf2 = 0;
	res = 0;

	for (int k = 2; k <= 10000; k++)
	{
		int is_prime = 2;
		for (int j = 0; (j < len_primes) && is_prime; j++)
		{
			is_prime = k % primes[j];
		}
		if (is_prime) {
			primes[len_primes] = k;
			len_primes++;
		}
	}


	for (int i = 0; i < len; i++)
	{
		int p = 0, already = 0;
		scanf("%d", &p);

		for (int j = 0; j < len_buf2 && !already; j++) {
			if (buf2[j] == p) {
				already = 1;
			}
		}

		if (!already) {
			int maxp = (int)sqrt((double)p) + 1;
			int is_prime = 1;
			for (int k = 0; (primes[k] < maxp) && k < len_primes && is_prime; k++) {
				is_prime = p % primes[k];
			}
			if (is_prime) {
				buf2[len_buf2] = p;
				len_buf2++;
				res++;
			}
		}
	}

	// for (int i = 0; i < len_buf2; i++) printf("nakami: %d\n", buf2[i]);

	printf("%d\n", res);
	return 0;
}



Measured memory_bytes: 2048
# __name__宣言が無いと300msほど？遅くなってTLEになるらしい。今後気をつけよう。。。

import itertools

def main():
  n, m, r = map(int, input().split())
  list_r = [one_r-1 for one_r in map(int, input().split())]

  dist = [[float("inf")] * n for _ in range(n)]
  for i in range(n):
    dist[i][i] = 0
  for i in range(m):
    a, b, c = map(int, input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if dist[i][j] > dist[i][k] + dist[k][j]:
          dist[i][j] = dist[i][k] + dist[k][j]

  result = float("inf")
  for one_cand in itertools.permutations(list_r):
    temp = 0
    for i in range(r-1):
      temp += dist[one_cand[i]][one_cand[i+1]]
    if temp < result:
      result = temp
  print(result)
  

if __name__ == "__main__":
  main()

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

int d[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

signed main(){
    int n,m;
    cin >> n >> m;
    bool use[10] = {};
    REP(i,m){
        int a;
        cin >> a;
        use[a] = true;
    }
    vector<int> dp(n + 1, -INF);
    int prev[n + 1];
    dp[0] = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 9; j >= 1; j--){
            if(!use[j]) continue;
            if(i - d[j] < 0) continue;
            if(dp[i - d[j]] + 1 > dp[i]){
                dp[i] = dp[i - d[j]] + 1;
                prev[i] = j;
            }
        }
    }
    string ans;
    int i = n;
    while(i != 0){
        ans.push_back('0' + prev[i]);
        i -= d[prev[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)
long long binpow(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
long long mod(long long x){
return ((x%M+M)%M);
}

long long add(long long a, long long b){
return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b){
return mod(mod(a)*mod(b));
}

int main()
{
   string s,t;
   cin>>s>>t;
   ll min=1e5;
   inc(i,0,s.length()-t.length()+1)
   {
      ll temp=0;
      inc(j,0,t.length())
      {
         if(s[i+j]!=t[j])temp++;

      }
      if(temp<min)
      {
         min=temp;
      }
   }
   cout<<min<<endl;
   
  
   return 0;
}

Measured memory_bytes: 3628
import sys
import numpy as np
# from numba import njit

# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

# @njit(cache=False)
def main(N,K,P,C,ans):


	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = np.full( N, -1, dtype=np.int64 )
	cycleInfs = []


	# print(P)

	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			currentCycleItemCnt, currentCycleTotal = cycleInfs[ cycleIDs[v] ]
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleInfs.append( (currentCycleItemCnt, currentCycleTotal) )
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = int(( K - procCnt ) // currentCycleItemCnt)

			# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, procCnt)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( int(ans), int(tmp) )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(int(ans))

if sys.argv[-1]=='ONLINE_JUDGE':
	# from numba import njit
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('main','void(i8,i8,i8[:],i8[:],i8)')(main)
	# main=njit(main, cache=True)
	cc.compile()
	exit(0)
from my_module import main



if __name__ == "__main__":
	N,K = map(int,input().split())
	P = np.array( input().split(), np.int64 )
	P -= 1
	C = np.array( input().split(), np.int64 )

	ans = -1e18	# NOTES: 2020/08/17 numba関数内でこれをやっていたら、データによってはWAになってしまっていた。詳細は、いまだに不明。
	main(N,K,P,C,ans)
	#print(ans)




Measured memory_bytes: 28056
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 200002
int dp[26][MAX_N]={};
bool d[MAX_N]={};
int pa[MAX_N];
vector<edge> G[MAX_N];
P1 cost[MAX_N]={};
vector<int> child[MAX_N];
vector<int> ra[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;
ll a[100005]={};
ll b[100005]={};
int main() {
	int n;
	int a[100]={};
	cin>>n;
	int total=0;
	rep(i,n){
		cin>>a[i];
		total+=a[i];
	}
	int r=0;
	int mr=10000;
	rep(i,n){
		if(abs(a[i]*n-total)<mr){
			mr=abs(a[i]*n-total);
			r=i;
		}
	}

	cout<<r<<endl;
	return 0;
}





Measured memory_bytes: 17152
#include<bits/stdc++.h>
#define intt long long 
using namespace std;
intt n,x;
intt read(){intt k;cin>>k;return k;}
intt dfs(intt a,intt b){
	if(a==0)return -b;
	return b/a*a*2+dfs(b%a,a);
}	
int main(){
	n=read();x=read();
	cout<<n+dfs(x,n-x)<<endl;
	return 0;
}

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

int main() {
  int n;
  int *a_heap;
  cin >> n;
  a_heap = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a_heap[i];
  }
  int min = 1000000;
  int max = -1000000;
  long sum = 0;
  for (int i = 0; i < n; i++) {
    if (a_heap[i] > max) {
      max = a_heap[i];
    }
    if (a_heap[i] < min) {
      min = a_heap[i];
    }
    sum += a_heap[i];
  }
  cout << min << " " << max << " " << sum << endl;
  delete[] a_heap;
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    
    long long K=a*c;
    long long L=a*d;
    long long M=b*c;
    long long N=b*d;
    
    long long ans=max(K, max(L,max(M,N)));
    
    cout << ans << endl;
    
    return 0;
  
}
 

Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[100]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    
    int f=0,g=0;
    for(int i=0;i<n;i++){
        if((i%2)==0){
            f+=a[i];
        }else{
            g+=a[i];
        }
    }
    int ans=f-g;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;

int h,w,k;
vector<string>grid;

bool chek(int r, int c){
     int cnt = 0;
     for(int i = 0; i<h; i++){
          for(int j = 0; j<w; j++){
               if(!(r & (1<<i)) or !(c& (1<<j))){
                         continue;
               }
               if(grid[i][j]=='#')cnt++;
          }
     }
     return cnt==k;
}

void task(){
    cin >> h >> w >> k;
    grid.resize(h);

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

    int ans = 0;
    for(int r = 0; r<(1<<h); r++){
     for(int c = 0; c<(1<<w); c++){
          if(chek(r,c))ans++;
     }
    }

    cout << ans << endl;
}

int main(){
        _
        int T = 1; //cin >> T;
        while(T--){
            task();
        }
return 0;
}



Measured memory_bytes: 3644
from queue import Queue

k = int(input())

q = Queue()
for i in range(1, 10):
    q.put(i)

for _ in range(k):
    x = q.get()
    if x % 10 != 0:
        q.put(x*10 + x%10 - 1)
    q.put(x*10 + x%10)
    if x % 10 != 9:
        q.put(x*10 + x%10 + 1)

print(x)


Measured memory_bytes: 12452
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,k){
        vector<int> base(n,0);
        rep(j,0,n){
            base[max(j-a[j],0)]++;
            if (j+a[j]+1<n){
                base[j+a[j]+1]--;
            }
        }
        vector<int> b(n,0);
        b[0] = base[0];
        rep(i,1,n){
            b[i]=b[i-1]+base[i];
        }
        if (a==b) break;
        a = b;
    }
    rep(i,0,n){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 5632