akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, m; cin >> n >> m;

	int a[1000], b[1000], c[1000], dist[100][100];

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				dist[i][j] = 0;
			}
			else {
				dist[i][j] = INF;
			}
		}
	}

	for (int i = 0; i < m; i++) {
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = m;
	for (int i = 0; i < m; i++) {
		bool shortest = false;

		if (dist[a[i]][b[i]] == c[i])shortest = true;

		if (shortest == true) {
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define tam 301024
#define F first
#define pb push_back
#define mp make_pair
#define S second
#define INF 1E9 +7
#define ll long long 
#define offset tam/2
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define fore(i, b, e) forr(i,b,e)
using namespace std;
typedef pair<ll,ll> ii;
ll fact[tam],inv[tam];
ll pot(ll base,ll exp)
{
    ll tot=1;
    base%=MOD;
    while(exp>0)
    {
        if (exp&1)
            tot*=base,tot%=MOD;
        base*=base,base%=MOD;
        exp/=2;
    }
    return tot;
}
ll C(ll y,ll x)
{
    if (x<0|| x>y)
        return 0;
    return (((fact[y]*inv[y-x])%MOD)*inv[x])%MOD;
}
ll val[tam];
int main()
{

    fact[0]=1;
    forr(i,1,tam)
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
    ll auxinv=pot(fact[tam-1],MOD-2);
    inv[tam-1]=auxinv;
    for(ll j=tam-1;j>=1;j--)
    {
        inv[j-1]=(inv[j]*j)%MOD;
    }

    
    ll n,k;
    cin>>n>>k;
    forr(i,0,n)
    {
        cin>>val[i];
    }
    sort(val,val+n);
    ll answer=0;
    forr(i,k-1,n)
    {
        answer+=(C(i,k-1)*val[i])%MOD;
        answer%=MOD;
    }
    forr(i,0,n)
    {
        if (n-i>=k)
        {
            answer-=(C(n-i-1,k-1)*val[i])%MOD;
            answer%=MOD;
        }
    }
    answer+=MOD;answer%=MOD;
    cout<<answer<<endl;
}   

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int N;
		cin >> N;
	int a,maxs=0,wa=0;
	for(int i=0;i<N;i++){
		cin >> a;
		wa+=a;
		maxs=max(maxs,a);
	}
	wa-=maxs;
	cout << (wa>maxs?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>





using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());
const int MOD = 1000000007;
const int INF = INT_MAX;
const double PI = 3.14159265358979323846;



int main(int argc, char const *argv[])
{



    string s;
    cin >> s;

    int a;
    for (int i=0; i < s.size(); i++){
        if (s[i] == 'A'){
            a = i;
            break;
        }
    }

    int z;
    for (int i=s.size(); i > 0; i--){
        if (s[i] == 'Z'){
            z = i;
            break;
        }
    }

    cout << z-a+1 << endl;
    






    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 832
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        ans += i;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a) << endl;
}


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

using namespace std;
int main(){
  int N,W;
  int temp1;
  long long int temp2;
  cin >> N >> W;
  vector <pair<int,long long int>> val;
  val.push_back(make_pair(0,0));
  for (int i=0;i<N;i++){
    cin >> temp1 >> temp2;
    val.push_back(make_pair(temp1,temp2));
    
  }
  sort(val.begin(),val.end());
  long long int dp[N+1][W+1];
  for(int i=0;i<N+1;i++){
  	for(int w=0;w<W+1;w++){
      if(i==0 || w==0){
        dp[i][w] = 0;
        
      }
      else{
        if(w-val[i].first>=0) dp[i][w] = max(dp[i-1][w],dp[i-1][w-val[i].first]+val[i].second);
        else dp[i][w] = dp[i-1][w];
        
        
      }
      
    }
    
  }
  cout << dp[N][W];
    return 0;
}  

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

int main()
{
    cout.precision(10);
    int n; cin>>n;
    double a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    double ans=0;
    for(int i=1;i<n;i++)
    {
        ans=(a[i]+a[i-1])/2.0;
        a[i-1]=0;
        a[i]=ans;
        sort(a+i,a+n);
    }
    cout<<a[n-1];
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 1e5 + 5;
const double Pi = acos(-1.0);
const int maxn = 2e5 + 5;
vector<int>G[maxn];
int d[maxn];
int n;
void init(){
    cin>>n;
    for(int i = 2; i <= n ; i++){
        int v;
        cin>>v;
        G[v].PB(i);
    }
}
int dfs(int u){
    int res = 0;
    vector<int>k;
    for(int i = 0; i < (int)G[u].size(); i++){
        int v = G[u][i];
        k.push_back(dfs(v));
    }
    sort(k.begin(),k.end());
    for(int i = 0 ; i < k.size() ; i ++){
        res = max(res , k[i] + (int)k.size() - i);
    }
    return res;
}
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    cout<<dfs(1)<<"\n";
}


Measured memory_bytes: 17408
from collections import defaultdict


def main():
    N, K, Q = map(int, input().split())
    d = defaultdict(int)
    for i in range(Q):
        a = int(input())
        d[a-1] += 1

    for i in range(N):
        if Q - d[i] < K:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 16156
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

void solve(){
  long long n; cin >> n;
  vector<long long> x(n), y(n), a(n);
  //set<long long> x2, y2;
  map<long long, long long> y2;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    x[i] = i + 1 - a[i];
    //x2.insert(x[i]);
    y[i] = a[i] + i + 1;
    y2[y[i]]++;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += y2[x[i]];
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 30600
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MOD = 1e9 + 7;;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

inline int ksm(int x, LL k) {
    int ret = 1;
    for (; k; k >>= 1) {
        if (k & 1) ret = Mul(ret, x);
        x = Mul(x, x);
    }
    return ret;
}

struct Matrix {
	int a[2][2];
} F;

Matrix operator * (Matrix a, Matrix b) {
	Matrix ret;
	ret.a[0][0] = Add(Mul(a.a[0][0], b.a[0][0]), Mul(a.a[0][1], b.a[1][0]));
	ret.a[0][1] = Add(Mul(a.a[0][0], b.a[0][1]), Mul(a.a[0][1], b.a[1][1]));
	ret.a[1][0] = Add(Mul(a.a[1][0], b.a[0][0]), Mul(a.a[1][1], b.a[1][0]));
	ret.a[1][1] = Add(Mul(a.a[1][0], b.a[0][1]), Mul(a.a[1][1], b.a[1][1]));
	return ret;
}

Matrix Ksm(Matrix x, LL k) {
	Matrix ret = x; --k;
	for (; k; k >>= 1) {
		if (k & 1) ret = ret * x;;
		x = x * x;
	}
	return ret;
}

char s[MAXN][MAXN];
int n, m; LL K;

void init() {
	read(n); read(m); read(K);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
	}
}

void solve() {
	if (K <= 1) {
		printf("1\n");
		return;
	}
	int lr = 0, ud = 0;
	for (int i = 1; i <= n; ++i) {
		lr += (s[i][1] == '#' && s[i][m] == '#');
	}
	for (int i = 1; i <= m; ++i) {
		ud += (s[1][i] == '#' && s[n][i] == '#');
	}
	if (lr && ud) {
		printf("1\n");
		return;
	}
	int blk = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			blk += (s[i][j] == '#');
		}
	}
	if (!lr && !ud) {
		printf("%d\n", ksm(blk, K - 1));
		return;
	}
	int ans = 0, cnt1 = 0, cnt2 = 0;
	if (lr) {
		cnt1 = lr;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				ans += (s[i][j] == '#' && s[i][j - 1] != '#');
				cnt2 += (s[i][j] == '#' && s[i][j - 1] == '#');
			}
		}
	} else {
		cnt1 = ud;
		for (int i = 1; i <= m; ++i) {
			for (int j = 1; j <= n; ++j) {
				ans += (s[j][i] == '#' && s[j - 1][i] != '#');
				cnt2 += (s[j][i] == '#' && s[j - 1][i] == '#');
			}
		}
	}
	if (K == 2) {
		printf("%d\n", ans);
		return;
	}
	F.a[0][0] = blk; F.a[0][1] = MOD - cnt2;
	F.a[1][0] = 0;   F.a[1][1] = cnt1;
	if (K > 3) F = Ksm(F, K - 2);
	ans = Add(Mul(ans, F.a[0][0]), Mul(cnt1, F.a[0][1]));
	printf("%d\n", ans);
}

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


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=305;
const ll mod=1e9+7;
ll n,vis[N<<1],f[2][N<<1][N<<1],cnt;
signed main(){
	n=read();
	for(ll i=1;i<=n;i++){
		ll a=read(),b=read();
		if(~a&&~b)vis[a]=2,vis[b]=2;
		else if(~a)vis[a]=1;
		else if(~b)vis[b]=1;
		else cnt++;
	}f[((n<<1)+1)&1][0][0]=1;
	for(ll i=n<<1,now=0,pre=1;i;i--,swap(now,pre)){
		for(ll j=0;j<=n<<1;j++)for(ll k=0;k<=n<<1;k++)f[now][j][k]=0;
		for(ll j=0;j<=n<<1;j++)for(ll k=0;k<=n<<1;k++)if(f[pre][j][k]){
			if(vis[i]==2)f[now][j][k]=(f[now][j][k]+f[pre][j][k])%mod;
			if(vis[i]==1){
				f[now][j][k+1]=(f[now][j][k+1]+f[pre][j][k])%mod;
				if(j)f[now][j-1][k]=(f[now][j-1][k]+f[pre][j][k])%mod;
			}
			if(vis[i]==0){
				f[now][j+1][k]=(f[now][j+1][k]+f[pre][j][k])%mod;
				if(j)f[now][j-1][k]=(f[now][j-1][k]+f[pre][j][k])%mod;
				if(k)f[now][j][k-1]=(f[now][j][k-1]+f[pre][j][k]*k%mod)%mod;
			}
		}
	}
	for(ll i=1;i<=cnt;i++)f[1][0][0]=f[1][0][0]*i%mod;
	return cout<<f[1][0][0],signed();
}

Measured memory_bytes: 9336
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] v = new int[5005];
        for(int i = 0;i < 5005;i++){
            v[i] = 1;
        }
        int p = 3;
        while(true){
            if(p*p > 10010){
                break;
            }else{
                if(v[(p-1)/2] == 0){
                    p += 2;
                }else{
                    int t = p*p;
                    while(t < 10010){
                        v[(t-1)/2] = 0;
                        t += 2*p;
                    }
                    p += 2;
                }
            }
        }
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	if(n == 0){
        		break;
        	}else if(n%2 == 0){
        		n--;
        	}
        	for(int i = n/2;i > 1;i--){
        		if(v[i] * v[i-1] == 1){
        			System.out.println(2*(i-1)+1 + " " + (2*i+1));
        			break;
        		}
        	}
        }
	}
}

Measured memory_bytes: 33552
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int l,r,d,ans;
  cin >> l >> r >> d;
  ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ans++;
   }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3544
<?php

fscanf(STDIN, '%d', $N);
for ($i = 0; $i < $N; $i++) {
    $a = fscanf(STDIN, '%d %d %d');
    sort($a);
    echo ($a[0] * $a[0] + $a[1] * $a[1]) === $a[2] * $a[2] ? 'YES' : 'NO';
    echo PHP_EOL;
}

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007

typedef long long ll;
int main() {
  int a, b;
  int ans;
  cin >> a;
  cin >> b;
  ans = a - (b*2);
  if(ans <= 0) printf("0\n");
  else printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define MaxN 100000+100
using namespace std;
struct node
{
	int damage;
	int flag;
}Node[2*MaxN];
int len=0;
bool cmp(struct node a,struct node b)
{
	return a.damage>b.damage;
}
int main()
{
	int N;
	int H;
	scanf("%d %d",&N,&H);
	for(int i=0;i<N;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		Node[len].damage=a;
		Node[len++].flag=0;
		Node[len].damage=b;
		Node[len++].flag=1;
	}
	sort(Node,Node+len,cmp);
	int attack=0;
	for(int i=0;i<len && H>0;i++)
	{
		if(Node[i].flag==1)
		{
			H-=Node[i].damage;
			attack++;
		}
		else
		{
				int num=H/Node[i].damage;
				if(H%Node[i].damage!=0)
					num++;
				attack+=num;
				break;
		}
	}
	printf("%d\n",attack);
	return 0;
 } 

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )
    A_list = list(map(int, sys.stdin.readline().split()))

    prev = A_list[0]
    sum_diff = 0

    for i in range(1, len(A_list)):
        if prev > A_list[i]:
            sum_diff += (prev - A_list[i])
        else:
            prev = A_list[i]
    
    print(sum_diff)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31464
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      k: usize
   }

   if k == 0 {
      println!("{}", n * n);
      return;
   }

   let mut ans = 0;
   for b in k + 1..=n {
      ans += (b - k) * (n / b);
      ans += max(n % b, k - 1) - (k - 1);
   }
   println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


struct UnionFind {
    vector<ll> par; 
    vector<ll> rank;
    UnionFind(ll N) : par(N), rank(N, 1LL) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    void init(ll N){
        par.resize(N);
        rank.assign(N, 1LL);
        for(ll i = 0; i < N; i++) par[i] = i;
    }
    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (rank[rx] < rank[ry]){
            par[rx]=ry;
        }else{
            par[ry]=rx;
            if(rank[rx]==rank[ry])rank[rx]++;
        }
        
        return;
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
  ll N, M;
  cin>>N>>M;
  UnionFind uf=UnionFind(N);
  vector<ll> A(M), B(M);
  rep(i, M){
    cin>>A[i]>>B[i];
    A[i]--; B[i]--;
    uf.unite(A[i], B[i]);
  }
  vector<ll> S(N, 0);
  rep(i, N){
    //cout<<uf.root(i)<<endl;
    S[uf.root(i)]++;
  }
  sort(ALL(S));
  cout<<S[N-1]<<endl;

}

Measured memory_bytes: 11108
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=105;
char str[maxn];
char s[maxn][maxn];
int n;
int work(char ch){
  for(int i=1;i<=n;++i){
    s[0][i]=str[i];
  }
  bool flag=true;
  for(int i=1;i<=n;++i){
    if(str[i]!=ch)flag=false;
  }
  if(flag)return 0;
  for(int i=1;i<=n;++i){
    int len=n-i+1;
    for(int j=1;j<len;++j){
      if(s[i-1][j]==ch||s[i-1][j+1]==ch){
	s[i][j]=ch;
      }else{
	s[i][j]='\0';
      }
    }
    bool flag=true;
    for(int j=1;j<len;++j){
      if(s[i][j]!=ch)flag=false;
    }
    if(flag)return i;
  }
}
int main(){
  scanf("%s",str+1);
  n=strlen(str+1);
  int ans=0x3f3f3f3f;
  for(int i='a';i<='z';++i){
    ans=min(ans,work(i));
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{
  
  static int ks[] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
  //static int lm[] = {0, 2, 4,  4,  8,   8,   16,  16,   32,   32,    64,    64};
  static int lm[] = {0, 6, 9,  6,  9,   6,    9,   6,    9,    6,     6,     9};
  //static int lm[] = {0, 2, 4,  4,  8,   6,    9,   6,    9,    6,     6,     9};
  static int mem[][] = new int[100001][12];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());
    
    Arrays.sort(ks);
    int ans = search(n, 11);

    System.out.println(ans);

  }
  
  public static int search(int m, int k)
  {
    if(m <= 5)
    {
      return m;
    }
    if(k < 0)
    {
      return 999999;
    }
    if(mem[m][k] > 0)
    {
      return mem[m][k];
    }
    int z = 999999;
    int v = m;
    for(int i = 0; m >= 0 && i < lm[k]; i++)
    {
      z = Math.min(z, i + search(m, k - 1));
      m -= ks[k];
    }
    mem[v][k] = z;
    return z;
  }

}


Measured memory_bytes: 29652
n = int(input())

l = [[0, 0, 0] for j in range(n)]

for i in range(n):
  s, p = input().split()
  s = str(s)
  p = int(p)
  l[i] = [i+1, s, p]

l.sort(key=lambda x: x[2], reverse=True)
#print(l)  
l.sort(key=lambda x: x[1])
#print(l)

for i in range(n):
  print(l[i][0])

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string code[256];
    code[' '] = "101";
    code['\''] = "000000";
    code[','] = "000011";
    code['-'] = "10010001";
    code['.'] = "010001";
    code['?'] = "000001";
    code['A'] = "100101";
    code['B'] = "10011010";
    code['C'] = "0101";
    code['D'] = "0001";
    code['E'] = "110";
    code['F'] = "01001";
    code['G'] = "10011011";
    code['H'] = "010000";
    code['I'] = "0111";
    code['J'] = "10011000";
    code['K'] = "0110";
    code['L'] = "00100";
    code['M'] = "10011001";
    code['N'] = "10011110";
    code['O'] = "00101";
    code['P'] = "111";
    code['Q'] = "10011111";
    code['R'] = "1000";
    code['S'] = "00110";
    code['T'] = "00111";
    code['U'] = "10011100";
    code['V'] = "10011101";
    code['W'] = "000010";
    code['X'] = "10010010";
    code['Y'] = "10010011";
    code['Z'] = "10010000";

    char restore[32];
    for(int i=0; i<26; ++i)
        restore[i] = i + 'A';
    restore[26] = ' ';
    restore[27] = '.';
    restore[28] = ',';
    restore[29] = '-';
    restore[30] = '\'';
    restore[31] = '?';


    for(;;){
        string s;
        if(!getline(cin, s))
            return 0;

        int n = s.size();
        string s1;
        for(int i=0; i<n; ++i)
            s1 += code[s[i]];
        while(s1.size() % 5 != 0)
            s1 += '0';

        n = s1.size();
        string ret;
        for(int i=0; i<n; i+=5){
            int a = bitset<5>(s1.substr(i, 5)).to_ulong();
            ret += restore[a];
        }

        cout << ret << endl;
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, M; cin >> N >> M;
	if (N > M)swap(N, M);

	if (N == 1 && M == 1) {
		ans = 1;
	}
	else if (N == 1) {
		ans = 0;
		if (M > 2)ans = M - 2;
	}
	else if (N == 2) {// 対称
		ans = 0;
	}
	else { // 中
		N -= 2;
		M -= 2;
		ans = N * M;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n, q = [int(i) for i in input().split()]
s = input()
m = [0] * (len(s) - 1)
for i in range(len(m)):
    if s[i:i+2] == "AC": m[i] = 1
a = [0] + list(accumulate(m))

for i in range(q):
    l,r = [int(i) for i in input().split()]
    print(a[r-1] - a[l-1])


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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; ++i) cin >> A[i];
  int max = 0, sum = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] > max) max = A[i];
    sum += A[i];
  }
  if (sum - max > max) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back 
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
int lim=1e12;
const   int  mod=1e9+7;
int foobar=0;
//freopen("filename","r", stdin);
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
//int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=power(b,p/2);return ((q)*(q));}else return ((b)*(power(b,p-1)));}
int  powerm(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=powerm(b,p/2);return ((q%mod)*(q%mod))%mod;}else return ((b%mod)*(powerm(b,p-1)%mod))%mod;}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 4 >( n ).to_string();return s;}

signed main()
{
   ios;
  int n;
  cin>>n;
  double a[n];
  int i=0;
  double sum=0;
  while(i<n)
  {
    cin>>a[i];
    sum+=1/a[i];
    i++;
  }
  cout<<setprecision(6)<<fixed;
  cout<<1/sum;


}




Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "Yes"<< "\n"
#define N cout<< "No"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.sz,sum=0;
    for(ll i=0;i<n;i++)
    {
       sum+=(ll)(s[i]-'0');
    }
    if(sum%9==0)
        Y;
    else
        N;
    return 0;
}


Measured memory_bytes: 3772
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const MAX = 1000
const NIL = -1

type Node struct {
	id    int
	depth int
}

type Queue struct {
	head      int
	tail      int
	container [MAX]Node
}

func (q *Queue) inQueue(x Node) {
	q.container[q.tail] = x
	q.tail = (q.tail + 1) % MAX
}

func (q *Queue) deQueue() Node {
	x := q.container[q.head]
	q.head = (q.head + 1) % MAX
	return x
}

func (q *Queue) isEmpty() bool {
	return q.head == q.tail
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	route := make([][]int, n)
	for i := range route {
		u, k := scanInt(), scanInt()
		u--
		route[u] = make([]int, k)
		for j := range route[u] {
			num := scanInt()
			num--
			route[i][j] = num
		}
	}

	d := make([]int, n)
	for i := range d {
		d[i] = NIL
	}

	start := Node{0, 0}
	que := Queue{}
	que.inQueue(start)
	for !que.isEmpty() {
		node := que.deQueue()
		if d[node.id] != NIL {
			continue
		}
		d[node.id] = node.depth

		for _, nextId := range route[node.id] {
			next := Node{id: nextId, depth: node.depth + 1}
			que.inQueue(next)
		}
	}

	for i, depth := range d {
		fmt.Println(i+1, depth)
	}
}



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

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

	int n,a[1000*1000]; cin >> n;
	memset(a,0,sizeof(a));

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


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

int main(void) {
  vector<int> v = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  cout << (v[x] == v[y] ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int64_t ans=0;
  set<double> r,g,b;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r.insert((double)i);
    }else if(S.at(i)=='G'){
      g.insert((double)i);
    }else{
      b.insert((double)i);
    }
  }
  for(auto x:r){
    for(auto y:g){
      int count=0;
      if(b.count(2*x-y)){
        count++;
      }
      if(b.count(2*y-x)){
        count++;
      }
      if(b.count((x+y)/2.0)){
        count++;
      }
      ans+=b.size()-count;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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




int main() {

	ll A[6];
	repn(i, 5) cin >> A[i];

	ll B[6];
	ll C[6];

	repn(i, 5) {
		B[i] = (A[i] + 9) / 10;
		C[i] = 9-(A[i]+9) % 10;
	}

	ll ans = 0;

	repn(i, 5) {
		ans += B[i] * 10;
	}

	ans -= max({ C[1], C[2], C[3] ,C[4],C[5]});

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    int s[m];
    int c[m];
    rep(i,m)cin >> s[i] >> c[i];
    vector<int>ans(n);
    rep(i,n)ans[i] = 0;
    if(n != 1)ans[n-1] = 1;
    rep(i,m){
        rep(j,m){
            if(s[i] == s[j] && i != j && c[i] != c[j]){
                cout << -1 << endl;
                return 0;
            }
            if(n != 1 && s[i] == 1 && c[i] == 0){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i,m){
        ans.at(n-s[i]) = c[i];
    }
    for(int i = n-1;i >= 0;i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  int h = 100, w = 100;
  int A, B;
  cin >> A >> B;
  char x = '.', y = '#';
  if(A > B){
    swap(x,y);
    swap(A,B);
  }
  vector<string> S(h,string(w,x));
  --A;
  cout << h << " " << w << endl;
  for(int i = 1; i < h; i += 4){
    for(int j = 1; j < w; j += 4){
      if(!B) break;
      for(int k = 0; k < 3; ++k){
        for(int l = 0; l < 3; ++l){
          S[i+k][j+l] = y;
        }
      }
      --B;
      if(A){
        S[i+1][j+1] = x;
        --A;
      }
    }
  }
  for(int i = 0; i < h; ++i) cout << S[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0);  
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define int long long
long double distace(int x, int y){
	return sqrt(x * x + y * y);
}
void test_case(){
	int n, d; cin>>n>>d;
	int ans = 0;
	for(int i=0;i<n;i++){
		int a, b; cin>>a>>b;
		long double dist = distace(a, b);
		//cout<<dist<<endl;
		if(dist <= d) ans++;
	}
	cout<<ans<<endl;
}
		
 
signed main(){
	IOS;
	int i = 1;
	int t=1; //cin>>t;
	while(t--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 3588
n, m, l = map(int, input().split())

A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(m)] for j in range(l)]

# 行列の読み込み
for i in range(n):
    A[i] = list(map(int, input().split()))
    
for i in range(m):
    tmp = list(map(int, input().split()))
    for j in range(l):
        B[j][i] = tmp[j]
    
ANS = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for a, b in zip(A[i], B[j]):
            ANS[i][j] += (a * b)

# プリントする
for i in range(n):
    for j in range(l):
        if j == 0:
            print(ANS[i][j], sep="", end="")
        else:
            print(" ", ANS[i][j], sep="", end="")
    print("")


Measured memory_bytes: 7140
#include<bits/stdc++.h>
using namespace std;
int ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<pair<int, int> > items(N);
    for (auto & item : items) cin >> item.first >> item.second;
    vector<int> C[4];
    int base = items[0].first;
    for (const auto &item : items) C[item.first-base].push_back(item.second);
    for (auto & i : C) {
        if (i.empty()) {
            i.push_back(0);
        } else {
            i.push_back(i[0]);
            i[0] = 0;
            sort(i.rbegin(), i.rend()-1);
            for (int j = 1; j < (int)i.size(); ++j) i[j] += i[j-1];
        }
    }
    for (int i = 0; i < (int)C[0].size(); ++i) {
        for (int j = 0; j < (int)C[1].size(); ++j) {
            for (int k = 0; k < (int)C[2].size(); ++k) {
                long long cost = 1LL*i*(base+0)+1LL*j*(base+1)+1LL*k*(base+2);
                if (cost <= W) {
                    ans = max(ans, C[0][i]+C[1][j]+C[2][k]+C[3][min((int)(W-cost)/(base+3), (int)C[3].size()-1)]);
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def main():

    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        if A[i] % 2 == 0 and (A[i] % 3 != 0 and A[i] % 5 != 0):
            return "DENIED"
    return "APPROVED"


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 38256
N = int(input())
T = [];X = [];Y = []
for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
if N == 1:
    print('Yes' if T[0] == sum(X+Y) else 'No')
    exit()
for i in range(N):
    if i == 0: continue
    d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
    t = T[i] - T[i-1]
    if t >= d:
        t = t % 2
        d = d % 2
        if (t != 0 and d == 0) or (t == 0 and d != 0):
            print('No')
            exit()
    else:
        print('No')
        exit()
else:
    print('Yes')

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	ll n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	if(a[n - 1] == 0 && k % 2){
		cout << 0 << '\n';
		return 0;
	}
	int sol = 1;
	if(a[n - 1] <= 0 && k % 2){
		for(int i = n - 1;  i >= n - k; i--){
			sol = (sol * 1LL * a[i] + MOD) % MOD;
		}
		cout << sol << '\n';
		return 0;
	}

	ll i = 0, j = n - 1;
	if(k % 2){
		sol = (sol * 1LL *  a[j]) % MOD;
		j--;
		k--;
	}
	k /= 2;
	for(int p = 0; p < k; p++){
		ll neg = (a[i] * 1LL * a[i + 1]);
		ll pos = (a[j] * 1LL * a[j - 1]);
		if(neg >= pos){
			sol = (sol * 1LL * ((neg + MOD) % MOD)) % MOD;
			i += 2;
		}else{
			sol = (sol * 1LL * ((pos  + MOD) % MOD)) % MOD;
			j -= 2;
		}
	}
	cout << sol << '\n';
}


Measured memory_bytes: 4296
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=int(1e9);
const int maxn=1000020;
long long N,a[maxn],b[maxn],c[maxn];
void read(long long a[])
{
    for(int i=1;i<=N;i++)
        scanf("%lld",&a[i]);
}
int main()
{
    cin>>N;
    read(a),read(b),read(c);
    sort(a+1,a+1+N),sort(b+1,b+1+N),sort(c+1,c+1+N);
    long long ans=0;
    long long ai=0,ci=0;
    for(int i = 1;i<=N;i++)
	{
        while(a[ai+1]<b[i]&&ai+1<=N) ai++;
        while(c[ci+1]<=b[i]&&ci+1<=N) ci++;
        ans+=ai*(N-ci);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9848
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, t: usize,
        mut ab: [(usize, i64); n],
    }
    ab.sort();

    let mut dp = vec![vec![-1i64<<50; t + 1]; ab.len()];
    dp[0][0] = 0;
    let (a0, b0) = ab[0];
    dp[0][min(t, a0)] = b0;
    for i in 1..ab.len() {
        for j in 0..t+1 {
            dp[i][j] = dp[i-1][j];
        }
        let (a, b) = ab[i];
        for j in 0..t {
            dp[i][min(t, j+a)] = max(dp[i][min(t, j+a)], dp[i-1][j] + b);
        }
    }
    let ans = dp[ab.len()-1].iter().cloned().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 72528
MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
a = set([int(input()) for i in range(M)])

dp = [0]*(N + 1)
dp[0] = 1
for step in range(N):
    if step in a:
        continue
    for width in [1, 2]:
        to = step + width
        if to <= N and not to in a:
            dp[to] = (dp[to] + dp[step]) % MOD

print(dp[N])

Measured memory_bytes: 56664
n = int(input())
x, y = [list(map(int, input().split())) for _ in range(2)]
print(sum([abs(x[i] - y[i]) for i in range(n)]))
print(pow(sum([(x[i] - y[i]) ** 2 for i in range(n)]), 1/2))
print(pow(sum([abs(x[i] - y[i]) ** 3 for i in range(n)]), 1/3))
print(max([abs(x[i] - y[i]) for i in range(n)]))


Measured memory_bytes: 5652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	p := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		p[i], _ = strconv.Atoi(sc.Text())
	}

	count := 0
	for i := 2; i < N; i++ {
		if (p[i-1] > p[i-2] && p[i-1] <= p[i]) || (p[i-1] <= p[i-2] && p[i-1] > p[i]) {
			count += 1
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int i,j,ans;
  string s;
  cin >> s;
  ans=0;
  for(i=0;i<s.length();i++){
    if(s[i]=='A'|| s[i]=='C'|| s[i]=='G'|| s[i]=='T'){
      for(j=i;j<s.length();j++){
        if(s[j]!='A'&& s[j]!='C'&& s[j]!='G'&& s[j]!='T')break;
      }
      if(ans<j-i)ans=j-i;
      i=j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int k,a,b;
    cin >> k >> a >> b;
    if(k == 1) {
        cout << "OK";
    }
    else {
        if(a % k == 0) {
            cout << "OK";
        }
        else if(b % k == 0) {
            cout << "OK";
        }
        else {
           int temp = a/k;
            if((((temp+1) * k) <= b) && (((temp+1) * k) >= a)) {
                cout << "OK";
            }
            else {
                cout <<"NG";
            } 
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll n,i,j=0,h,w;
       std::cin >>h>>w;
       ll m,r[h]={0},c[w]={0};
       std::cin >> m;
       ll a[m],b[m];
       map<pair<ll,ll>,ll>mp;
       fr(i,0,m)
       {
           std::cin >> a[i]>>b[i];
           mp[{a[i]-1,b[i]-1}]=1;
           a[i]--;
           b[i]--;
           r[a[i]]++;
           c[b[i]]++;
       }
       ll d[h],e[w],k=0,maxir=*max_element(r,r+h),maxic=*max_element(c,c+w);
       fr(i,0,h)
       {
           if(r[i]==maxir)
           {
               d[k++]=i;
           }
       }
       fr(i,0,w)
       {
           if(c[i]==maxic)
           {
               e[j++]=i;
           }
       }
       ll y=0;
       fr(i,0,j)
       {
           fr(l,0,k)
           {
               if(mp[{d[l],e[i]}]==0)
               {
                   y=1;
                   cout<<maxir+maxic<<"\n";
                   break;
               }
           }
           if(y)
           break;
       }
       if(y==0)
       cout<<maxic+maxir-1<<"\n";
   }
}

Measured memory_bytes: 36404
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, c;
	cin >> n >> m >> c;
	vi b(m);
	REP(i, m) {
		cin >> b[i];
	}
	int cnt = 0;
	REP(i, n) {
		int p = c;
		REP(j, m) {
			int a; cin >> a;
			p += a * b[j];
		}
		if (p > 0)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
  int n,k;
  cin>>n>>k;
  if((n-2)*(n-1)/2<k){cout<<-1;return 0;}
  int l=(n-2)*(n-1)/2-k;
  cout<<n-1+l<<"\n";
  for(int i=2;i<=n;++i)cout<<"1 "<<i<<"\n";
  for(int i=2;i<n&&l;++i)for(int j=i+1;j<=n&&l;++j)cout<<i<<" "<<j<<"\n",l--;
}

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

int main() {
    string s; cin >> s;
    ll sl = 0;
    if(s.size()%2 == 0){
        sl = s.size()/2-1;
    }
    else{
        sl = s.size()/2-1;
    }
    int cnt = 0;
    for(int i=0; i<=sl; i++){
        if(s.at(i) == s.at(s.size()-1-i)) continue;
        else cnt++;
    }

    cout << cnt << endl;
}

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

int main() {
    cin >> s;
    int maxx = 0, act = 0;
    bool have = false;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') {
            if (have)
                act++;
            else
                have = true, act = 1;
        } else {
            have = false;
            maxx = max(maxx, act);
            act = 0;
        }
    }

    maxx = max(maxx, act);
    cout << maxx;
    return 0;
}


Measured memory_bytes: 3616
import math
from decimal import Decimal
import copy
N,A,B = (int(x) for x in input().split())
counter = 0

for x in range(1,N + 1):
    S = 0
    power = 0
    new_x = copy.deepcopy(x)
    for i in range(len(str(x))):
        S += x % 10
        x = math.floor(x / 10)
        
        power += 1        
    
    if A <= S and S <= B:

        counter += new_x
    

print(int(counter))


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

bool isPrime(int n){
	double sqrtN = sqrt(n);
	for(int i = 3; i <= sqrtN; i += 2){
		if(!(n%i))
			return false;
	}
	return true;
}
 
int main(){
  bool prime[999999] = {};
  prime[1] = true;
  for(int i = 3; i < 999999; i += 2){
  	if(isPrime(i))
  		prime[i-1] = true;
  }
  int n;
  while(cin >> n){
  	int count = 0;
  	if(n >= 2)
  		count++;
    for(int i = 3; i <= n; i += 2){
    	if(prime[i-1])
    		count++;
    }
    cout << count << endl;
  }
}


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

int main() {
    int N,K;
    cin >> N >> K;
    int ans=1;
    for(int i=0; i<N; i++) {
        if (ans*2>=ans+K){
            ans+=K;
        }
        else{
            ans*=2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	long long mod = 1e9 + 7;
	int s;
	cin >> s;

	vector<long long> dp(s + 10);

	dp[0] = 0;
	dp[1] = 0;
	dp[2] = 0;
	dp[3] = 1;

	for (int i = 4; i < s + 1; i++) {
		dp[i] = dp[i - 3] + dp[i - 1];
		dp[i] %= mod;
	}
	
	cout << dp[s] << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 2e5;

int n, m, a[55], sum, k;

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for(int i = n; k > 0; i--) {
		sum += a[i];
		k--;
	}
	printf("%d\n", sum);
	return 0;
}

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

int func(vector<bitset<11>> &v, unordered_map<bitset<128>, int> &mp, bitset<128> x, int n, int m){
	if(mp.count(x)) return mp[x];
	if(x.count() == 1) return mp[x] = 0;
	int res = 1e9;
	for(int i=0; i<m; ++i){
		bitset<128> y = x, z = x;
		for(int j=0; j<n; ++j){
			if(v[j][i] == 1) z[j] = 0;
			else y[j] = 0;
		}
		if(y.count() == 0 || z.count() == 0) continue;
//		cout << i << " " << y << " " << z << "\n";
		int t = 0;
		t = func(v, mp, y, n, m);
		t = max(t, func(v, mp, z, n, m));
		res = min(res, t + 1);
	}
	return mp[x] = res;
}

int solve(int m, int n){
	vector<bitset<11>> v;
	unordered_map<bitset<128>, int> mp;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		v.push_back(bitset<11>(s));
	}
	return func(v, mp, bitset<128>(string(n, '1')), n, m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, n;
	while(1){
		cin >> m >> n;
		if(m == 0) return 0;
		cout << solve(m, n) << "\n";
	}
}


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

int main() {
	string s;
  	cin>>s;
  	
  	int maxs=(s.size()-1)/2;
  	int ans=0;
  	//1.文字数のfor 2.位置のfor
  	for(int i=1;i<=maxs;i++){
    	for(int j=0;j<maxs;j++){
        	if(s.substr(j,i)==s.substr(j+i,i)){
            	ans=i;
              	
            }
        }
    }
  cout<<ans*2<<endl;
}



Measured memory_bytes: 256