akhauriyash/Code-Regression huggingface dataset:
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N = int(input())
A = list(map(int, input().split()))

I = list(range(N))
I.sort(key=lambda i: A[i], reverse=True)

V = set()
tree = UnionFind(N)

ans = 0
for i in I:
    a = A[i]
    L = tree.sizeOfSameRoot(i - 1) if (i - 1) in V else 0
    R = tree.sizeOfSameRoot(i + 1) if (i + 1) in V else 0
    ans += a * ((L + 1) * (R + 1))

    if i - 1 in V:
        tree.union(i - 1, i)
    if i + 1 in V:
        tree.union(i + 1, i)
    V.add(i)

print(ans)


Measured memory_bytes: 43604
let _ = Scanf.sscanf (read_line ()) "%d %d" (fun a b ->
  match a with
  | a when a >= 13 -> print_endline (string_of_int b)
  | a when a >= 6 -> print_endline (string_of_int (b/2))
  | a -> print_endline "0"
)

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <algorithm>
#include <climits>
#include <stack>
#include <vector>
#include <random>
#include <string.h>
#include <stdio.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef pair<int, int> ii;
typedef pair<long double, int> id;
typedef pair<long long, long long> llp;
const int N = 1e5+1;
int n, m, k, t;
long long dp[101][N+1];
int main() {
    //freopen("ee.inp", "r", stdin);
    //freopen("ee.OUT", "w", stdout);
    fastIO;
    cin>>n>>m;
    int w, v;
    int ans = 0;
    for(int i=0;i<=n;i++) for(int j=1;j<=1e5;j++)
            dp[i][j] = 1e15;
    for(int i=1;i<=n&&cin>>w>>v;i++)
        for(int j=1;j<=1e5;j++) {
            if (j-v>=0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w);
            else dp[i][j] = dp[i-1][j];
            if (dp[i][j]<=m) ans = max(ans, j);
        }
    cout << ans;
}


Measured memory_bytes: 82568
#include <stdio.h>
int main(void){

int m,f,r;

while(1){
scanf("%d %d %d",&m,&f,&r);

	if(m==-1&&f==-1&&r==-1){
	break;
	}
	else{
		if(m==-1||f==-1){
		printf("F\n");
		}
		else{
			if(m+f>=80){
			printf("A\n");
			}
			else{
				if(m+f>=65){
				printf("B\n");
				}
				else{
					if(m+f>=50){
					printf("C\n");
					}
					else{
						if(r>=50){
						printf("C\n");
						}
						else{
							if(m+f>=30){
							printf("D\n");
							}
							else{
							printf("F\n");
							}
						}
					}
				}
			}
		}
	}
}

return 0;
}

Measured memory_bytes: 584
N, K, L = map(int, input().split())
#Parent List(PL)
road = [i for i in range(N)]
rail = [i for i in range(N)]

def fp(x,P): #findParent
    if x == P[x]:
        return x
    else:
        P[x] = fp(P[x],P)
        return P[x]

for i in range(K+L):
    PL = (lambda x:road if x < K else rail)(i)
    p, q = map(lambda x:int(x)-1, input().split())
    p, q = fp(p,PL), fp(q,PL)
    PL[p] = PL[q] = min(p,q)

from collections import defaultdict as dd
Wconnected = dd(lambda:0)
for i in range(N):
    Wconnected[fp(i,road),fp(i,rail)] += 1
print(*[Wconnected[fp(i,road),fp(i,rail)] for i in range(N)])

Measured memory_bytes: 55756
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int gcd(int a, int b){
    if(a < b){
        swap(a, b);
    }
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int max = *max_element(a.begin(), a.end());
    int g = a[0];
    for(int i = 1; i < (int)a.size(); i++){
        g = gcd(g, a[i]);
    }

    if(k <= max && k % g == 0){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn f(mut n: usize) -> usize {
    let mut ans=0;
    while n % 2 == 0 {
            n/=2;
            ans+=1;
    }
    ans

}

fn main() {
    let n: usize;
    input!(n);
    let mut ans = (0, 0);
    for z in 1..n + 1 {
        ans = std::cmp::max((f(z), z), ans);
    }
    p(ans.1);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 998244353;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

inline lint invm(lint a, lint p = mod) { a %= p; return a == 1 ? 1 : -p / a * invm(p % a) % p; }

V<lint> fact, ifact, pow2;
void init_fact(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1), pow2.assign(n + 1, 1);
  for (int i = 2; i < n + 1; i++) fact[i] = i * fact[i - 1] % mod;
  ifact[n] = invm(fact[n]);
  for (int i = n; i > 2; i--) ifact[i - 1] = i * ifact[i] % mod;
  for (int i = 0; i < n; i++) pow2[i + 1] = 2 * pow2[i] % mod;
}

lint comb(lint n, lint r) {
  if (n < 0 or r < 0 or r > n) return 0;
  return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

lint mulcomb(lint n, lint r) {
  if (n < 1 or r < 0) return 0;
  return fact[r + n - 1] * ifact[r] % mod * ifact[n - 1] % mod;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint k, n; cin >> k >> n;
  init_fact(k + n);
  auto calc = [&](lint m, lint k, lint n) {
    lint res = 0;
    for (lint j = 0; j < m + 1; j++) {
      res = (res + comb(m, j) * pow2[j] % mod * mulcomb(k - 2 * m + j, n - j)) % mod;
    }
    return res;
  };
  V<> res(k);
  for (int i = 2; i < k + 2; i++) {
    if (i & 1) res[i - 2] = emod(calc(i / 2, k, n));
    else res[i - 2] = emod(calc(i / 2 - 1, k - 1, n) + calc(i / 2 - 1, k - 1, n - 1));
  }
  for (auto&& i : res) cout << i << '\n';
  for (int i = k - 2; i >= 0; i--) cout << res[i] << '\n';
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    
    int count = 0;
    
    cin >> a >> b >> c;
    
    for(int i=a; i<=b; i++){
        
        if(c % i == 0){
            count++;
    }
    }
    
    cout << count <<endl;
}


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

int main(){
	int a,b,t,ans=0;
	cin >>a>>b>>t;
	for (int i=1;i<(t+0.5);++i){
		if (i%a==0)
			ans+=b;
	}
	cout <<ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e2+5
#define W (int)1e5+5
#define f1 first
#define s2 second
#define INF 9999999
#define pb push_back
#define ll long long
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

ll wt[N],val[N],dp[N][W],n,w,ans,x,sum;

ll solve(int i,int j){

	if(dp[i][j] != -1)return dp[i][j];
	if(i == n && j>0)return INT_MAX;
	if(i == n && j==0)return 0;
	if(j <= 0)return 0;
	
	return dp[i][j]=min(solve(i+1,j),solve(i+1,j-val[i])+wt[i]);
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin >> n >> w;
	for(int i = 0; i < n; i++){
		cin >> wt[i] >> val[i];
		sum += val[i];
	}
	//cout << sum << endl;
	memset(dp,-1,sizeof dp);

	for(int i = sum; i > 0;i--){
		if(solve(0,i) <= w){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> a.at(i).at(j);
    }
  }
  bool ok = true;
  rep(i, h) {
    rep(j, w) {
      bool isStart = false;
      bool isGoal = false;
      if (i == h - 1 && j == w - 1) {
        isGoal = true;
      }
      if (i == 0 && j == 0) {
        isStart = true;
      }
      char cur = a.at(i).at(j);
      if (cur != '#') {
        continue;
      }
      bool rightOk = false;
      bool bottomOk = false;
      int ni = i + 1;
      int nj = j + 1;
      if (ni >= 0 && ni < h) {
        rightOk = a.at(ni).at(j) == '#';
      }
      if (nj >= 0 && nj < w) {
        bottomOk = a.at(i).at(nj) == '#';
      }
      // 右か下かどちらかにだけいける場合がOK
      if (!isGoal) {
        if ((rightOk && bottomOk) || (!rightOk && !bottomOk)) {
          ok = false;
        }
      }
      int ni2 = i - 1;
      int nj2 = j - 1;
      bool leftOk = false;
      bool upOk = false;
      if (ni2 >= 0 && ni2 < h) {
        leftOk = a.at(ni2).at(j) == '#';
      }
      if (nj2 >= 0 && nj2 < w) {
        upOk = a.at(i).at(nj2) == '#';
      }
      // 上か左かどちらかからだけこれる場合がOK
      if (!isStart) {
        if ((leftOk && upOk) || (!leftOk && !upOk)) {
          ok = false;
        }
      }
    }
  }
  cout << (ok ? "Possible" : "Impossible") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define N 606
#define p 1000000007
#define ll long long
inline int mod(int x){return x>=p?x-p:x;}
int a[N],b[N],f[2][N][N],i,j,k,m,n,o,q;
int main()
{
	scanf("%d",&n),m=n<<1,f[0][0][0]=1;
	for(i=0;i<m;i++)b[i]=-1;
	for(i=0;i<m;i++)scanf("%d",a+i),~a[i]?b[--a[i]]=i:0;
	for(i=0;i<m;i+=2)if(!~a[i]&&!~a[i|1])f[0][0][0]=(ll)f[0][0][0]*++j%p;
	for(i=m;i--;)
	if(!~b[i])
	{
		for(j=1;j<=q;j++)for(k=0;k<=q;k++)f[o^1][j-1][k]=mod(f[o^1][j-1][k]+f[o][j][k]);
		for(j=0;j<=q;j++)for(k=1;k<=q;k++)f[o^1][j][k-1]=(f[o^1][j][k-1]+(ll)k*f[o][j][k])%p;
		for(j=0;j<=q;j++)for(k=0;k<=q;f[o][j][k++]=0)f[o^1][j+1][k]=mod(f[o^1][j+1][k]+f[o][j][k]);
		o^=1,q++;
	}
	else if(!~a[b[i]^1])
	{
		for(j=1;j<=q;j++)for(k=0;k<=q;k++)f[o^1][j-1][k]=mod(f[o^1][j-1][k]+f[o][j][k]);
		for(j=0;j<=q;j++)for(k=0;k<=q;f[o][j][k++]=0)f[o^1][j][k+1]=mod(f[o^1][j][k+1]+f[o][j][k]);
		o^=1,q++;
	}
	return 0*printf("%d\n",f[0][0][0]);
}

Measured memory_bytes: 3072
#include <iostream>

int main()
{
  int a, b, c, x, y;
  std::cin >> a >> b >> c >> x >> y;
  long price = 0;
  if ( 2 * c < a + b ) {
    if ( x > y ) {
      price += 2 * c * y;
      x -= y;
      if ( 2 * c < a ) {
        price += 2 * c * x;
      } else {
        price += a * x;
      }
    } else {
      price += 2 * c * x;
      y -= x;
      if ( 2 * c < b ) {
        price += 2 * c * y;
      } else {
        price += b * y;
      }
    }
  } else {
    price = a * x + b * y;
  }
  std::cout << price << std::endl;
  return 0;
}


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

#define NUM 100

int main(){
  int n;
  cin >> n;
  int a[NUM] = {0};
  int m = n;
  int k = 0;
  int i = 0;
  while (m != 0){
    a[k] = m%10;
    //cout << a[k] << endl;
    m /= 10;
    k++;
    i++;
  }
  int s = 0;
  for (int j = 0; j < i; j++){
    s += a[j];
  }
  if (n%s == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  //cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
map<ll,int> mp; // 
typedef ll fuko[yuzu|10];
fuko sum;
int main(){
int i,n=read(),m=read();
for (i=1;i<=n;++i) sum[i]=(sum[i-1]+read())%m;
ll llx=0;
for (i=0;i<=n;++i) llx+=mp[sum[i]],mp[sum[i]]++; 
write(llx),pl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()


int main () {
  int n, m, x, a;

  cin >> n >> m >> x;

  int lower = 0;
  int upper = 0;

  REP(i,m) {
    cin >> a;

    if(a > x) {
      upper++;
    }
    else{
      lower++;
    }
  }

  cout << min(upper, lower) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,W,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x+r>W||y+r>H){
	cout<<"No"<<endl;
	}
	else if(x-r<0||y-r<0){
	cout<<"No"<<endl;
	}
	else{
	cout<<"Yes"<<endl;
	}
return 0;
}

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

int main() {
  string S;
  cin >> S;
  int cnt=0, max=0;
  rep(i, S.size()){
    for(int j=i; j<S.size(); j++){
      if(S.at(j)=='A' | S.at(j)=='C' | S.at(j)=='G' | S.at(j)=='T') cnt++;
      else break;
    }
    if(max<cnt) max=cnt;
    cnt=0;
  }
  cout << max << endl;
}

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

using ll = long long;

int a[200010];
int b[200010];

ll nCr(ll n, ll r)
{
    if(n<r)return 0;
    ll b=1;
    ll a=1;
    for(ll i=0;i<r;i++)
    {
        b*=(n-i);
        a*=(r-i);
    }
    ll ret=b/a;
    return ret;
}

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

    int n;cin>>n;

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

    ll sumall=0;

    for(int i=1;i<=n;i++)sumall+=nCr(b[i],2);

    for(int i=0;i<n;i++)
    {
        ll ans=sumall-nCr(b[a[i]],2)+nCr(b[a[i]]-1,2);
        cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 5236
#include <stdio.h>

int main(){

    int i;
    int a,b,c; //input
    int o = 0; //output: count the numbers of divisors

    scanf("%d %d %d",&a,&b,&c);

    while(1){

        if(c % a == 0){
            o++;

        }
        if(a == b){
            break;
        }

        a++;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    }


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

    return 0;
}

Measured memory_bytes: 1860
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 0, 1 },{ -1 ,1 },{ -1, 0 },
	{ -1 ,-1 },{ 0,-1 },{ 1 ,-1 },
	{ 1,0 },{ 1 ,1 }
};

signed main() {
	int n, m;

	scanf("%d %d", &n, &m);

	vector<vector<int>> tri(n, vector<int>(n,-1));

	REP(i, m) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);

		tri[a - 1][b - 1] = c;
	}
	int ans = m;
	REP(i, n-1) {
		REP(j, n-1) {
			if (tri[i][j]>0) {
				ans += (tri[i + 1][j + 1]<0) + (tri[i + 1][j]<0);
				tri[i + 1][j] = max(tri[i + 1][j], tri[i][j]-1);
				tri[i + 1][j + 1] = max(tri[i + 1][j + 1], tri[i][j]-1);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

void bigger(int &i, vector<int> a, int &ans) {
  while (a[i] <= a[i+1] && i < a.size()-1) {
    i++;
  }
  ans++;
}

void smaller(int &i, vector<int> a, int &ans) {
  while (a[i] >= a[i+1] && i < a.size()-1) {
    i++;
  }
  ans++;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  
  for (int i = 0; i < n; i++) {
    if (a[i] < a[i+1] && i < n-1) {
      bigger(i, a, ans);
      continue;
    }
    if (a[i] > a[i+1] && i < n-1) {
      smaller(i, a, ans);
      continue;
    }
    if (i == n-1) ans++;
  }
  cout << ans << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n;
  cin >> n;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;

  
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  ll sum = 0;
  for(i=0;i<n;i++)
    sum += a[i];
  ll buf = INF; 
  for(i=0;i<n;i++){
    if(buf>(abs(a[i]*n - sum))){
      buf = abs(a[i]*n - sum);
      result = i;
    }
  }  
  cout<<result<<endl;
  





  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  int ans=1;
  sort(d.begin(),d.end());
  for(int i=1;i<n;i++){
    int j=d.at(i-1);
    if(j!=d.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i, 26)
    {
        cin >> c[i];
    }
    vector<vector<int>> s(D, vector<int>(26));

    rep(i, D)
    {
        rep(j, 26)
        {
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    rep(i, D)
    {
        cin >> t[i];
        t[i]--;
    }

    vector<int> v(D);

    int last[26] = {0};

    rep(d, D)
    {
        v[d] = s[d][t[d]];
        if (d > 0)
        {
            v[d] += v[d - 1];
        }
        last[t[d]] = d + 1;
        int down = 0;
        rep(i, 26)
        {
            down += c[i] * ((d + 1) - last[i]);
        }
        v[d] -= down;
    }

    rep(i, D)
    {
        cout << v[i] << endl;
    }
}

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

m = []
A = []
for x in range(N):
  A = list(map(int, input().split()))
  m.append(A)

ans = 1000000007
for i in range(2**N):
  l = []
  total = 0
  for j in range(N):
    if ((i >> j) & 1):
      l.append(m[j])
  a = [0] * (M+1)
  for x in l:
    for i, k in enumerate(x):
      a[i] += k

  found = True
  for i, x in enumerate(a):
    if i >= 1:
      if x < X:
        found = False

  if found:
    ans = min(ans, a[0])

if ans == 1000000007:
  print(-1)
else:
  print(ans)



Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> pi(n), p(n), a(n), b(n);
    rep(i, 0, n) cin >> pi[i];
    rep(i, 0, n){
        p[pi[i] - 1] = i;
    }
    a[0] = 1;
    b[n - 1] = 1;
    rep(i, 1, n){
        if(p[i] - p[i - 1] > 0){
            a[i] = a[i - 1] + p[i] - p[i - 1] + 1;
        }else{
            a[i] = a[i - 1] + 1;
        }
    }
    repb(i, n - 2, 0){
        if(p[i + 1] < p[i]){
            b[i] = b[i + 1] + p[i] - p[i + 1] + 1;
        }else{
            b[i] = b[i + 1] + 1;
        }
    }
    rep(i, 0, n){
        cout << a[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
    rep(i, 0, n){
        cout << b[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1280
/*
 * @Author: Sky Dreamer 
 * @Date: 2020-02-16 20:19:11 
 * @Last Modified by: Sky Dreamer
 * @Last Modified time: 2020-02-16 20:28:49
 * @Problem Url: https://atcoder.jp/contests/abc155/tasks/abc155_c
 * @Status: 
 */
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

map < string,int > cnt;
map < string,bool > used;
string votes[200005];
int n,maxn;

int main() {
#ifndef ONLINE_JUDGE
#define register
#endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    cin >> n;
    for(register int i = 1;i <= n;i ++) cin >> votes[i],cnt[votes[i]] ++;
    for(register int i = 1;i <= n;i ++) 
        if(cnt[votes[i]] > maxn) maxn = cnt[votes[i]];
    sort(votes + 1,votes + n + 1);
    for(register int i = 1;i <= n;i ++) {
        if(used[votes[i]]) continue;
        used[votes[i]] = true;
        if(cnt[votes[i]] == maxn) puts(votes[i].c_str());
    }
    return 0;
}


Measured memory_bytes: 37888
#include <stdio.h>
int main(void)
{

	while (1) {
		int h, w;
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		int i, j;
		for (i = 1; i <= h; i++) {
			if (i % 2 == 0) {
				printf(".");
			}
			else {
				printf("#");
			}

			for (j = 1; j < w; j++) {
				if ((i + j) % 2 == 0 ) {
					printf(".");
				}
				else {
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <climits>
using namespace  std;

void fnInput(vector<int> &rvnBSort, int &rnMaxElm)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rnMaxElm = 0;
  rvnBSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
  {
    cin >> rvnBSort[i];
    rnMaxElm = max(rnMaxElm, rvnBSort[i]);
  }
}

void fnCntSort(const vector<int> &cnrvnBSort,vector<int> &rvnASort, int nMaxElm)
{
  vector<int> vnCnt;
  vnCnt.resize(nMaxElm);

  for (int i = 0; i < cnrvnBSort.size(); i++)
    vnCnt[cnrvnBSort[i]]++;

  for (int i = 1; i <= nMaxElm; i++)
    vnCnt[i] += vnCnt[i - 1];

  for (int i = cnrvnBSort.size() - 1; i >= 0; i--)
  {
    rvnASort[vnCnt[cnrvnBSort[i]] - 1] = cnrvnBSort[i];
    vnCnt[cnrvnBSort[i]]--;
  }
}

void fnResult(const vector<int> &cnrvnASort)
{
  for (int i = 0; i < cnrvnASort.size(); i++)
  {
    if (i)  cout << " ";
    cout << cnrvnASort[i];
  }
  cout << endl;
}

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

  int nMaxElm;
  vector<int> vnBSort, vnASort;

  fnInput(vnBSort, nMaxElm);
  vnASort.resize(vnBSort.size());

  fnCntSort(vnBSort, vnASort, nMaxElm);
  fnResult(vnASort);

  return 0;
}

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

typedef long long ll;
ll INF = 1LL << 60;

int 
main() 
{

  int n; cin >> n;
  vector<ll> arr(n);
  rep(i, 0, n)cin >> arr[i];
  vector<ll> acum(n);acum[0] = arr[0];
  rep(i, 1, n) acum[i] = acum[i -1] + arr[i];
  ll ans = INF;

  rep(i, 0, n - 1){
    
    ans =  min(ans,abs(acum[i] - (acum[n - 1] - acum[i])));
  }

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 3328
import Control.Monad
import Data.List

main = do
    n <- read <$> getLine
    w <- forM [1..n] $ \i -> getLine
    putStrLn $ if solve w then "Yes" else "No"

solve :: [String] -> Bool
solve w = length w == length (group $ sort w) && doit (last $ head w) (tail w)
  where
    doit _ []     = True
    doit c (w:ws) = c == head w && doit (last w) ws

Measured memory_bytes: 636
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

N,W = map(int,input().split())

w = [0 for i in range(N)]
v = [0 for i in range(N)]
for i in range(N):
    w[i],v[i] = map(int,input().split())

w_sum = [0 for i in range(N+1)]
v_sum = [0 for i in range(N+1)]

w.insert(0,0)
v.insert(0,0)

for i in range(N):
    w_sum[i+1] = w_sum[i]+w[i+1]
    v_sum[i+1] = v_sum[i]+v[i+1]


nap_memo = {}

def nap(i,W2):#i:count_pieces,W2:rest_weight
    key = str(i)+":"+str(W2)
    if key in nap_memo:
        return nap_memo[key]
    elif i == 0:#品物０個の時は価値０
        r = 0
    elif W2 < w[0]:
        r = 0
    elif W2 < w[i]:#i番目の荷物が残量を超えるなら入らない
        r = nap(i-1,W2)
    elif w_sum[i] <= W2:
        r = v_sum[i]
    else:
        r = max(nap(i-1,W2-w[i])+v[i], nap(i-1,W2))

    nap_memo[key] = r
    return r


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


Measured memory_bytes: 13172
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
      	String x = sc.next();
      	String c = sc.next();
      
      System.out.print("A" +x.charAt(0)+ "C");


      
    }
}

Measured memory_bytes: 21588
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    list<lint> que;
    lint n;
    cin>>n;
    rep(i,n){
        string s;
        lint k;
        cin>>s;
        if(s=="insert"){cin>>k;que.push_front(k);}
        if(s=="delete"){
            cin>>k;
            for(auto i=que.begin();i!=que.end();i++){
                if(*i==k){
                    que.erase(i);
                    break;
                }
            }
        }
        if(s=="deleteFirst")que.pop_front();
        if(s=="deleteLast")que.pop_back();
    }
    bool f=0;
    for(lint i:que){
        if(f)cout<<" ";
        f=1;
        cout<<i;
    }
    cout<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  ll X[N], Y[N], P[N]; rep(i,N) cin >> X[i] >> Y[i] >> P[i];
  ll xmin[N][1<<N], ymin[N][1<<N];
  rep(i,1<<N) rep(j,N) {
    xmin[j][i] = abs(X[j]); rep(k,N) if (i&1<<k) xmin[j][i] = min(xmin[j][i], abs(X[k]-X[j]));
    ymin[j][i] = abs(Y[j]); rep(k,N) if (i&1<<k) ymin[j][i] = min(ymin[j][i], abs(Y[k]-Y[j]));
  }
  // rep(i,N) debug(xmin[i],xmin[i]+(1<<N));

  vector<ll> result(N+1,LLINF);
  const int pw = pow(3,N);
  rep(i,pw) {
    ll ti = i, dx = 0, dy = 0, count = 0;
    rep(j,N) {
      if (ti%3==1) { dx += 1<<j; count++; }
      else if (ti%3==2) { dy += 1<<j; count++; }
      ti /= 3;
    }
    ll sum = 0; rep(j,N) sum += min(xmin[j][dx], ymin[j][dy]) * P[j];
    if (result[count]>sum) result[count] = sum;
  }
  rep(i,N+1) cout << result[i] << endl;
  return 0;
}


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

int main() {
	int a[105];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	cout<<a[0];
	for(int i=1;i<n;i++){
		cout<<" "<<a[i];
	}
	cout<<endl;
	
	for(int i=1;i<n;i++){
		int temp=a[i];
		int j=i-1;
		while (j>=0 && a[j]>temp){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=temp;
		
		cout<<a[0];
		for(int i=1;i<n;i++){
			cout<<" "<<a[i];
		}
		cout<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3088
import java.io.*;

public class Main{
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str = "";
		try {
			while((str = br.readLine()) != "") {
				for(int i=str.length(); i>0; i--) {
					sb.append(str.substring(i-1, i));
				}
				System.out.println(sb.toString());
			}
		} catch(Exception e) {
			e.getMessage();
		}
	}
}

Measured memory_bytes: 24056
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    char m[100],x[100],n[100];
    scanf("%s%s",&m,&n);
    scanf("%d%d",&a,&b);
    scanf("%s",&x);
    if(strcmp(x,m)==0)

        printf("%d %d\n",a-1,b);
    else if(strcmp(x,n)==0)
        printf("%d %d\n",a,b-1);
    return 0;

}


Measured memory_bytes: 128
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main()
{
    fast;
    int n,k;
    cin>>n>>k;
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>=k)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	string str;
	getline(cin, str);

	int n = stoi(str);

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		getline(cin, str);
		int A = stoi(str);
		getline(cin, str);
		int B = stoi(str);
		cout << A + B << endl;

	}

	return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		int[] bottle = new int[num.get(0)+1];

		for (int i = 2; i < num.size(); i++) {
			bottle[num.get(i)]++;
		}

		for (int i = 1; i < bottle.length; i++) {
			System.out.println(bottle[i]);
		}
	}
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	string s,t;
	cin>>s>>t;

	int ans = 0;

	for(int i=0;i<=s.size()-t.size();i++)
	{
		int l = 0;

		for(int j=0;j<t.size();j++)
		{
			if(s[i+j] == t[j])
				l++;
		}

		ans = max(ans,l);
	}

	cout<<t.size()-ans<<endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[55];
int M, m;
vector <Pii> ans;

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    cin >> A[i];

    if (A[i] >= A[M]) M = i;
    if (A[i] <= A[m]) m = i;
  }

  if (abs(A[M]) >= abs(A[m])){
    for (int i = 1; i <= N; i++){
      if (A[i] < 0) ans.push_back({M, i});
    }
    for (int i = 1; i < N; i++){
      ans.push_back({i, i+1});
    }
  }else{
    for (int i = 1; i <= N; i++){
      if (A[i] > 0) ans.push_back({m, i});
    }
    for (int i = N-1; i >= 1; i--){
      ans.push_back({i+1, i});
    }
  }

  cout << ans.size() << endl;
  for (Pii P:ans){
    cout << P.fi << " " << P.se << endl;
  }

  return 0;
}


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

int main() {
    int count [4][3][10] = {};

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        count[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << count[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) {
            cout << "####################" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int n,ans;
map<int,int>m;
int main(){
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){cin>>a[i];m[a[i]]++;}
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    ans=a[0]^a[1];
    ans=ans^a[2];
    if(a.size()==1&&a[0]==0){cout<<"Yes"<<endl;return 0;}
    if(n%3!=0){cout<<"No"<<endl;return 0;}
    if(a.size()==2&&a[0]==0&&m[0]==n/3){cout<<"Yes"<<endl;return 0;}
    if(a.size()==3&&ans==0&&m[a[0]]==m[a[1]]&&m[a[1]]==m[a[2]])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>

int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	
	if ((100 * a + 10 * b + c) % 4 == 0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;

}

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

bool f[128];

string str;

static void append(string &str) {
	bool f[128];

	memset(f, 0x00, sizeof f);
	for (auto ch: str)
		f[ch] = true;
	for (char ch = 'a'; ch <= 'z'; ++ch) if (f[ch] == false) {
		str.push_back(ch);
		break; } }

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string init;

	cin >> str;

	if (str == "zyxwvutsrqponmlkjihgfedcba") {
		cout << "-1" << endl;
		return 0; }

	if (str.size() == 26) {
		init = str;
		next_permutation(begin(str), end(str));
		for (int i = 0; i < 26; ++i) {
			if (init[i] != str[i]) {
				str.resize(i + 1);
				break; } } }
	else
		append(str);

	cout << str << endl;

	return 0; }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1204;
int h,w,n;
int ma[MAXN][MAXN],a[20001];
void solve(){
	cin >> h >> w >> n;
	for(int i = 1;i <= n;i ++)
		cin >> a[i];
	int tot = n;
	for(int i = 1;i <= h;i ++){
		if(i % 2){
			for(int j = 1;j <= w;j ++){
				ma[i][j] = tot,a[tot] --;
				if(a[tot] == 0) tot --;
			}
		}
		else{
			for(int j = w;j >= 1;j --){
				ma[i][j] = tot,a[tot] --;
				if(a[tot] == 0) tot --;
			}
		} 
	}
	for(int i = 1;i <= h;i ++){
		for(int j = 1;j <= w;j ++){
			cout << ma[i][j] << " ";
		}
		cout << endl;
	}
	return;
}

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

Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

int digit_sums(int n){
    int sum = 0;
    while (n > 0){
        sum += n%10;
        n /= 10;
    }

    return sum;
}


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

    string ans = "Yes";
    if (n%digit_sums(n)){
        ans = "No";
    }

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

Measured memory_bytes: 256
a,b,c = map(int,input().split())
"""
if a**0.5 + b**0.5 < c**0.5:
    print("Yes")
else:
    print("No")

print(a**0.5)
print(b**0.5)
print(a**0.5+b**0.5,c**0.5)
"""

if c-a-b < 0:
    print("No")
else:
    if 4*a*b < (c-a-b)**2:
        print("Yes")
    else:
        print("No")

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

/*
Aiは
任意のAjで割り切れない
sortすれば自分より小さいものだけ見ればよい
小さい方からみて、エラトステネスの篩をする
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	vector<bool> is_prime(1e6 + 1, true);
	vector<bool> is_used(1e6 + 1, false);
	for (int i = 0; i < n; i++)
	{
		if (is_used[a[i]])
		{
			is_prime[a[i]] = false;
			for (int j = 2; a[i] * j <= 1e6; j++) is_prime[a[i]] = false;
		}
		else
		{
			is_used[a[i]] = true;
			for (int j = 2; a[i] * j <= 1e6; j++) is_prime[a[i] * j] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans += is_prime[a[i]];
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 4288
/*
stable or not stableの判定法は
ソート済みのCの0番目の要素を軸にoriginalを探索。

アイデアのキモ：
｛もしCの次の数字が違えば、探索添え字を０に戻す。
もし同じなら、探索添え字はそのまま。
｝
stableならこれですべて探せるはず
最後まで見つからなかったらnotstable

*/

#include <iostream>
#include <string>

using namespace std;




//多重ループをうまく抜けられなかったので関数にすることに
//goto使ってもよかったんだけど、まあ・・・。
/*
stableかかを文字列で返してくれる。
引数は比較するstring配列二つと大きさN
*/

//check stable
string check_stable(string *C, string *original, int N){
	int i,j;

	j=0;
	for(i=0;i<N; i++){
		for( ; ; j++){
			if(C[i]==original[j]) break;
			if(j>=N) return "Not stable"; //最後までいったのに同じのが見つからない?＞開始探索添え字以前にある。
		}
		//今回のキモ　探索開始添え字の場合分け
		if(i<N-1 && C[i][1]==C[i+1][1]) j++;
		else j=0;
	}
	return "Stable";
}



int main() {
    int i, j;
    int N;
	int mini_sub;
	//arrayとかvectorとかわからないのでそのままの配列。　よってコピーするときもそのまま配列代入。memcpyとかは内部構造がわからないので使わない。
    string original[36], C[36];
   
	//input
    cin >> N;
    for(i=0;i<N;i++) cin >> original[i];
    
	//copy
	for(i=0;i<N;i++)  C[i] = original[i];

//bubble sort
	for(i=0; i<N; i++){
		for(j=N-1; j>i; j--){
			if(C[j][1] < C[j-1][1]) swap(C[j] , C[j-1]);
		}
	}
    
	//sequence output
	for(i=0;i<N;i++){
		cout << C[i];
		if(i!=N-1) cout << ' ';
		else cout << endl;
	}
	//output check stable
	cout << check_stable(C, original, N) << endl;


	//copy
	for(i=0;i<N;i++)  C[i] = original[i];
    
//Selecion sort
	for(i=0; i<N; i++){
		mini_sub=i;
		for(j=i; j<N; j++){
			if(C[j][1] < C[mini_sub][1]) mini_sub=j;
		}
		swap(C[i] , C[mini_sub]);
	}
    
	//sequence output
	for(i=0;i<N;i++){
		cout << C[i];
		if(i!=N-1) cout << ' ';
		else cout << endl;
	}
	//output check stable
	cout << check_stable(C, original, N) << endl;
    

	return 0;
}

Measured memory_bytes: 1212