akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
    if(n<16){
        fill(ret, ret+n*2-1, 0);
        for(size_t i=0; i<n; ++i)
        for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
    }else
    if(n&1){
        go_karatsuba(a,b,ret,n-1);
        ret[n*2-3] = 0;
        for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
        ret[n*2-2] = a[n-1]*b[n-1];
    }else{
        auto ar = a, al = a+n/2, 
		     br = b, bl = b+n/2,
        	 asum = ret+n*5, bsum = asum+n/2,
        	 x1 = ret, x2 = x1+n, x3 = x2+n;
        for(size_t i=0; i<n/2; ++i){
            asum[i] = al[i] + ar[i];
            bsum[i] = bl[i] + br[i];
        }
        go_karatsuba(ar, br, x1, n/2);
        go_karatsuba(al, bl, x2, n/2);
        go_karatsuba(asum, bsum, x3, n/2);
        for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
        for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21924
N,A=map(int,input().split())

ans=N

for i in range(-10,10):
    x=int(N**.5)+i
    if x>0:
        test=x+A+(N-1)//x+1
        ans=min(ans,test)

for n in range(2,41):
    for i in range(2*n,int(N**(1/n))+1000):
        test=i+n*A
        q=i//n
        r=i%n
        prod=pow(q,n-r)*pow(q+1,r)
        test+=(N-1)//prod+1
        ans=min(ans,test)

print(ans)

Measured memory_bytes: 74524
n = int(input())
mod = 10**9+7
prime = [1 for _ in range(1000)]
for i in range(1,n+1):
  now = i
  div = 2
  while now > 1:
    if now % div == 0:
      now //= div
      prime[div-1] += 1
    else:
      div += 1
ans = 1
for i in range(n):
  ans *= prime[i]
  ans %= mod
print(ans)
#print(prime)

Measured memory_bytes: 3064
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

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

const int MAXN = 1e5+5;
ll N, M;
vi G[MAXN];
int vis[MAXN], s;
bool bip;
void dfs(int v, int col=1){
    s++;
    vis[v]=col;
    for(int u:G[v]){
        if(vis[u]==-1) dfs(u,1-col);
        else if(vis[u]==col) bip = false;
    }
}

int main(){
    scan(N, M);
    FOR(i,0,M){
        int v,u; scan(v,u); v--; u--;
        G[v].pb(u);
        G[u].pb(v);
    }
    ms(vis,-1);
    ll ans = 0, cnt1=0, cnt2=0, cnt3=0;
    FOR(v,0,N){
        if(vis[v]==-1){
            s = 0;
            bip = true;
            dfs(v);
            if(s==1){
                ans += 2*N - 1 - cnt3*2;
                cnt3++;
            }else{
                ans += bip+1;
                if(bip){
                    ans += cnt1*2 + cnt2*4;
                    cnt2++;
                }else{
                    ans += (cnt1+cnt2)*2;
                    cnt1++;
                }
            }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 9984
import java.io.*;
import java.util.*;
public class Main{
    static int cSize = 51;
    static long[][] C = new long[cSize][cSize];    
    static {
        for(int i = 0; i < cSize; i++)
            C[i][0] = C[i][i] = 1;        
    }
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int N, A, B;
        {int[] a = r.ii(); N = a[0]; A = a[1]; B = a[2];}
        long[] v = r.ll();
        
        Arrays.sort(v);
        long[][] array = new long[50][2];
        int end = 0;
        for(int i = N-1; i >= 0 ;){
            long w = v[i];
            int count = 0;
            while(i >= 0 && w == v[i]){
                i--;
                count++;
            }
            array[end++] = new long[]{w, count};
        }
        
        long mSum = 0;
        long mNum = A;
        long caseNum = 0;
        for(int i = A; i < B+1; i++){
            long sum = 0;
            long count = 0;
            for(int j = 0, k = 0; j < i; k++){
                int num = (int)array[k][1];
                if(j+num < i){
                    j += num;
                    sum += num*array[k][0];
                } else{
                    sum += (i-j)*array[k][0];
                    count = c(num, i-j);
                    break;
                }
            }
            if(i*mSum < mNum*sum){
                caseNum = count;
                mSum = sum;
                mNum = i;                
            } else if(i*mSum == mNum*sum)
                caseNum += count;
        }
        println((double)mSum/mNum);
        println(caseNum);
    }

    static long c(int n, int r){
        if(C[n][r] > 0)
            return C[n][r];
        else{
            return C[n][r] = c(n-1, r-1)+c(n-1, r);
        }
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int INF=1001001001;
const int mod=1000000007;
int main(){
    string s;cin>>s;
    int n=s.size()+1;
    vi v(n,-1);
    if(s[0]=='<')v[0]=0;
    if(s[n-2]=='>')v[n-1]=0;
    rep(i,n-2){
        if(s[i]=='>'&&s[i+1]=='<')v[i+1]=0;
    }
    rep(i,n){
        if(v[i]==0){
            int j=i-1;
            while(j>=0){
                if(s[j]=='<')break;
                chmax(v[j],v[j+1]+1);
              j--;
            }
            j=i+1;
            while(j<n){
                if(s[j-1]=='>')break;
                chmax(v[j],v[j-1]+1);
              j++;
            }
        }
    }
  ll ans=0;
  rep(i,n)ans+=v[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 4740
#include <iostream>
#include <cmath>
#include <sstream>

using namespace std;

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

    if(N % 1000 == 0){
        cout << 0;
    }else{
        l = N % 1000;
        cout << 1000 - l;
    }

}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
	public static final long mod = (long)1e9+7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), max = 0;;
		int[] a = new int[n];
		long lcm = 1, ans = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
		}
		int[] a2 = a.clone();
		int[] fact = new int[max+1];
		for (int i = 0; i < n; i++) {
			for (int j = 2; j*j <= a[i]; j++) {
				int count = 0;
				while(a[i]%j==0) {
					a[i] /= j;
					count++;
				}
				fact[j] = Math.max(fact[j], count);
			}
			if(a[i] != 1) fact[a[i]] = Math.max(fact[a[i]], 1);
		}
		for (int i = 2; i <= max; i++) {
			lcm *= pow(i, fact[i]);
			lcm %= mod;
		}
		for (int i = 0; i < n; i++) {
			ans += lcm*pow(a2[i], mod-2);
			ans %= mod;
		}
		System.out.println(ans);
	}
	public static long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum = sum * x % mod;
	        }
	        x = x*x%mod;
	        n >>= 1;
	    }
	    return sum;
	}
}

Measured memory_bytes: 40576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a - c) * (b - c) < 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    a = sorted([int(input()) for _ in range(N)])

    s = sum(a)

    if s % 10 != 0:
        return s

    for x in a:
        if (s-x)%10 != 0:
            return s - x
    return 0


def main():
    print(solve())


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define C(x) cout << x << endl //テスト出力

//関数
//nCkの計算の関数(呼び出しは[cbn])
ll cbn(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
// a^n mod を計算する
ll powmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//２つの最大公約数
int gcb(int a, int b){
    if(a < b){
        int x = a;
        a = b;
        b = x;
    }
    int amari = a % b;
    if(amari == 0) return b;

    return gcb(b, amari);
}
//３つの最大公約数
int gcb_3(int a, int b, int c){
    return gcb(gcb(a, b), c);
}

/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;
vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))*/

/*-----------------------------ここから-----------------------------*/

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n,k; cin>>n>>k;
vector<ll> data(n);
REP(i,n) cin>>data[i];
sort(data.begin(), data.end());
ll ans = 0;
REP(i,k) ans+=data[i];
cout<<ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
#define out(a) printf("%d",a)
#define writeln printf("\n")
const int N=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,cnt=0,x;
int a[N];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); 
	if (n==0) out(0);
	else {
	while (n){
	  x=n%(-2);
	  n/=(-2);
	  if (x<0) n++,x+=2;
	  a[++cnt]=x;
	}	
	for (int i=cnt;i>=1;i--)
	  out(a[i]);
	}	
	return 0;
}
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h = s.nextInt();
		int w = s.nextInt();
		
		String n = "", nn = "";
		for(int i = 0; i < w + 2; i++) n += "#";
		System.out.println(n);
		
		for(int i = 0; i < h; i++) {
			nn = s.next();
			System.out.println("#" + nn + "#");
		}
		System.out.println(n);
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int n;
LL a[100001];
LL b[100000];

int main(){
  LL ret=0;
  cin>>n;
  REP(i,n+1)cin>>a[i];
  REP(i,n)cin>>b[i];

  REP(i,n){
    LL tmp=min(b[i],a[i]+a[i+1]);
    ret+=tmp;
    a[i+1]-=max(0LL,tmp-a[i]);
  }

  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
const LL mo=1e9+7;
char s[N];
int n;
LL f[N][3],pw[N];
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=pw[i-1]*3%mo;
	int cnt=0;
	LL ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='?'){
			cnt++;
			f[i][0]=(f[i-1][0]*3%mo+pw[cnt-1])%mo;
			f[i][1]=(f[i-1][0]+f[i-1][1]*3%mo)%mo;
			f[i][2]=(f[i-1][2]*3%mo+f[i-1][1])%mo;
//			ans+=f[i][2]; ans%=mo;
		}
		else{
			for(int j=0;j<3;j++) f[i][j]=f[i-1][j];
			if(s[i]=='A') f[i][0]=(f[i-1][0]+pw[cnt])%mo;
			if(s[i]=='B') f[i][1]=(f[i-1][0]+f[i-1][1])%mo;
			if(s[i]=='C') f[i][2]=(f[i-1][2]+f[i-1][1])%mo;
//			ans+=f[i][2],ans%=mo;
		}
//		cout<<f[i][0]<<' '<<f[i][1]<<' '<<f[i][2]<<' '<<ans<<endl;
	}
	cout<<f[n][2]<<endl;
	return 0;
}


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

int main(){

    long long int n;
    cin >> n;
    long long int ans = 1e12; 
    long long int m = n;

    for(long long int i = 1; i <= m; ++i){
        if(n%i == 0){
            ans = min((n/i-1) + (i-1), ans);
        }
        m = n/i;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#!python3

import sys
sys.setrecursionlimit(200000)


# input
N, M = list(map(int, input().split()))
LRD = [tuple(map(int, input().split())) for _ in range(M)]


def judge(W, D, visit, i):
    visit[i] = True
    for j, d in W[i]:
        if D[j] is None:
            D[j] = D[i] + d
        else:
            if D[i] + d != D[j]:
                return True
        if visit[j]:
            continue
        if judge(W, D, visit, j):
            return True
    
    return False


def main():
    W = [[] for _ in range(N)]
    for l, r, d in LRD:
        W[l - 1].append((r - 1, d))
        W[r - 1].append((l - 1, -d))
    
    D = [None] * N
    visit = [False] * N
    for i in range(N):
        if visit[i]:
            continue
        D[i] = 0
        if judge(W, D, visit, i):
            print("No")
            return
    
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 145708
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}

int main(){
  fastIO();
  ll a,b,n;
  cin>>a>>b>>n;
  ll c = min(n,b-1);
  cout<<((a*c)/b) - (a*(c/b));
  return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key))sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <set>
#include <map>
using namespace std;

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

    typedef set<int> Suit;
    typedef map<char,Suit> Deck;

    Deck d;

    char s;
    int card;
    while(n-- && cin >> s >> card)
        d[s].insert(card);

    /*cout << "\nFinished load\n" << endl;
    for(const auto &x : d) {
        for(const auto &y : x.second)
            cout << y << ' ';
        cout << endl;
    }*/

    const char suit_order[] = "SHCD";
    for(int so=0; so<4; ++so) {
        s = suit_order[so];
        Suit &suit = d[s]; // it is ok to create an empty set here
        for(int i=1; i<14; ++i)
            if(suit.find(i) == suit.end())
                cout << s << ' ' << i << '\n';
    }

    return 0;
}



Measured memory_bytes: 3104
N = int(input())

s = []
a = 26
tmp = 1
for i in range(20):
    s.append(tmp)
    tmp += a
    a *= 26
    if tmp > 100000000000000000:
        break

for i in range(len(s)):
    if N >= s[i]:
        continue
    else:
        size = i 
        break

b = N - s[size-1]

n2a = lambda c: chr(c+64)
a = 26 ** (size-1)

ans = []
while(a >= 1):
    ans.append(n2a(b // a + 1).lower())
    b %= a
    a //= 26

print(*ans, sep="")

Measured memory_bytes: 9216
from collections import deque

INF = float("inf")

# 入力
H, W = map(int, input().split())

maze = [input() for i in range(H)]

# 移動4方向のベクトル
dx = [1,0,-1,0]
dy = [0,1,0,-1]

# (sx,sy)から(gx,gy)への最短距離を求める
# たどりつけないとINF

def bfs():
    que = deque([])
    # 全ての点をINFで初期化
    d = [[INF]*W for i in range(H)]

    # スタート地点をキューに入れ、その点の距離を0にする
    que.append([0,0])
    d[0][0]= 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        #取り出してきた状態がゴールなら探索をやめる
        if p[0] == H-1 and p[1] == W-1:
            break
        # 移動4方向をループ
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能化の判定とすでに訪れたことがあるかの判定
            if 0<=nx and nx<H and 0<=ny and ny<W and maze[nx][ny] != '#' and d[nx][ny] == INF:
                # 移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
                que.append([nx,ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    
    return d[H-1][W-1]

white = 0

for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            white += 1
res = bfs()
if 0 < res < INF:
    print(white - bfs() - 1)
else:
    print(-1)
    

Measured memory_bytes: 3316
#include<stdio.h>

int main(){
  int j=0;
  char S[11];
  char ans[11];
  scanf("%s",S);

  for (int i = 0; i < 11; i++)
  {
    if (S[i]=='B'){ 
      if (j>0)
      {
        j--;
      }else{
        j=0;
      }
    }else{
      ans[j++]=S[i];
      if(S[i]=='\0'){ break; }
    }
  }

  printf("%s",ans);

  return 0;
}

Measured memory_bytes: 1704
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;

signed main(){

    int x,k;
    cin >> k >> x;

    cout << max({k+x,k-x,k*x}) << endl;
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc137.contest.atcoder.jp/tasks/abc137_b


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H, A := sc.nextInt(), sc.nextInt()

	fmt.Fprintln(wtr, ceil(H, A))
	wtr.Flush()
}


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

using namespace std;

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

    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }

    int flag[n];
    for(int i=0; i<n; i++){
        flag[i] = 1;
    }

    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;

        if(h[a-1] < h[b-1]){
            flag[a-1] = 0;
        }
        else if(h[a-1] > h[b-1]){
            flag[b-1] = 0;
        }
        else if(h[a-1] == h[b-1]){
            flag[a-1] = 0;
            flag[b-1] = 0;
        }
    }
    int count=0;
    for(int i=0; i<n; i++){
        if(flag[i]==1){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
 
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long ,long long > pll;
typedef unsigned long long ull; 

bool ok(int a,int b,int c)
{
	if(a==b || a==c || b==c) return false;
	if(a+b<=c || b+c<=a || a+c<=b) return false;
	return true;
}

const ll INF=5*1e18;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,k;
		cin>>n>>k;
		ll p[n+1];
		for(int i=1;i<=n;i++) cin>>p[i];
		ll c[n+1];
		for(int i=1;i<=n;i++) cin>>c[i];
		ll suma=0;
		for(int i=1;i<=n;i++) suma+=c[i];
		ll mx=-INF;
		for(int start=1;start<=n;start++)
		{
			ll velicina=1;
			ll psuma=c[start];
			ll ind=p[start];
			ll mt=psuma;
			while(start!=ind && velicina<k)
			{
				psuma+=c[ind];
				ind=p[ind];
				velicina++;
				mt=max(mt,psuma);
			}
			if(psuma<0)
			{
				mx=max(mx,mt);
			}
			else
			{
				ll prva,druga;
				prva=(k/velicina-1)*psuma+mt;
				ll pom=k/velicina;
				druga=pom*psuma;
				pom=k-pom*velicina;
				ll koji=start;
				ll malol=0;
				ll pomcina=0;
				for(int i=0;i<pom;i++)
				{
					pomcina+=c[koji];
					koji=p[koji];
					malol=max(pomcina,malol);
				}
				mx=max(max(prva,druga+malol),mx);
			}
		}
		cout<<mx<<endl;
	}	
 	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    int n;
    cin >> n;
    vector<int> v, vv;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        vv.push_back(t);
        if (t != 1) v.push_back(t);
    }
    n = v.size();
    vector<int> p;
    for (int i = 2; i <= 1000; i++) {
        int flag = 1;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) p.push_back(i);
    }
    vector<int> vc(1001, 0);
    for (auto num : p) {
        for (int i = 0; i < n; i++) {
            int flagg = 0;
            while (v[i] % num == 0) {
                flagg = 1;
                v[i] /= num;

            }
            vc[num] += flagg;
            if (vc[num] > 1) {
                break;
            }
        }
    }
    int flag = 1;
    sort(v.begin(), v.end());
    for (int i = 1 ; i < n; i++) {
        if (v[i] == v[i - 1] && v[i] != 1) {
            flag = 0;
            break;
        }
    }
    for (int i = 0; i <= 1000; i++) {
        if (vc[i] > 1) {
            flag = 0;
            break;
        }
    }
    if (flag == 1) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    v = vv;
    int g = v[0];
    for (int i = 1; i < n; i++) {
        g = gcd(g, v[i]);
    }
    if (g == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    } else {
        cout << "not coprime" << endl;
    }
}




Measured memory_bytes: 11212
#include <stdio.h>

int main() {
  int x[5];
  scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
  for(int i=0;i<5;i++) {
    if(x[i]==0) {
      printf("%d",i+1);
    }
  }
  return 0;
}
  

Measured memory_bytes: 1724
N = int(input()) #1行目のNを取得する
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
  word=input()
  if(word=='AC'):
    AC+=1
  elif(word=='WA'):
    WA+=1
  elif(word=='TLE'):
    TLE+=1
  else:
    RE+=1
print('AC x %d' %AC )
print('WA x %d' %WA )
print('TLE x %d' %TLE )
print('RE x %d' %RE )


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

int main(){
  string s;
  cin>>s;
  int a=0;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
        a++;
      }
    }
  }
  if(a==0){
    cout << "yes" << endl;
  }
  else{
    cout<<"no"<<endl;
  }
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val r, c = scanner.nextInt
    val sum_c = Array.fill(c)(0)
    val mat = Array.fill(r)(new Array[Int](c))
    for(i <- 0 until r) {
      for(j <- 0 until c) {
        val n = scanner.nextInt
        mat(i)(j) = n
        sum_c(j) = sum_c(j) + n
      }
    }

    for(i <- 0 until r) {
      print(mat(i).mkString(" "))
      print(" ")
      println(mat(i).sum)
    }
    print(sum_c.mkString(" "))
    print(" ")
    println(sum_c.sum)
  }
}



Measured memory_bytes: 59376
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>

using namespace std;


int main() {
    int n,x;
    cin>>n>>x;
    
    vector<int>l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }
    
    int d=0,count=0;
    for(int i=0;i<n;i++){
        d+=l.at(i);
        count+=(d<=x)?1:0;
    }
    cout<<count+1<<endl;
    return 0;
}


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


void solve(){
	

	int x ;
	cin>>x ;

	if(x>=30)
		cout<<"Yes" ;
	else
		cout<<"No" ; 

}	

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

using namespace std;

int main(){
    long long h; cin >> h;
    long long count = 0, ans = 0;
    
    while (h > 1)
    {
        ++count;
        h /= 2;
        ans += pow(2, count);
    }
    cout << ans + 1 << endl;
}



Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

long long inv2(){
    long long b = PRIME, u = 1, v = 0;
    long long a = 2;

    while(b){
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }

    u %= PRIME;
    if(u < 0)u += PRIME;
    return u;
}


int main(){
    int N, K;

    cin >> N >> K;
    vector<int> As(N);

    for(int i = 0; i < N; ++i){
        cin >> As.at(i);
    }

    long long num_l, num_r;
    long long ret = 0;

    long long inv_2 = inv2();

    long long coeff_r = ((K + 1) * ((K * inv_2) % PRIME)) % PRIME;
    long long coeff_l = ((K - 1) * ((K * inv_2) % PRIME)) % PRIME;

    for(int i = 0; i < N; ++i){
        int right = 0;
        int left = 0;

        for(int j = 0; j <= i - 1; ++j){
            if(As[i] > As[j]){
                ++left;
            }
        }
        for(int j = i + 1; j < N; ++j){
            if(As[i] > As[j]){
                ++right;
            }
        }

        num_r = (coeff_r * right) % PRIME;
        num_l = (coeff_l * left) % PRIME;

        ret += (num_r + num_l) % PRIME;
        ret %= PRIME;
    }

    cout << ret % PRIME;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

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

int main() {
    
    int N, T;
    cin >> N >> T;
    
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    
    vector<ll> dp1(T+1), dp2(T+1);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int t = T-1; t >= 0; t--) {
            if (t + A[i] < T) {
                dp1[t + A[i]] = std::max(dp1[t + A[i]], dp1[t] + B[i]);
                ans = std::max(ans, dp1[t + A[i]]);
            }
        }
        for (int t = 0; t < T ; t++) {
            dp1[t] = std::max(dp1[t], dp2[t] + B[i]);
            ans = std::max(ans, dp1[t]);
        }
        for (int t = T-1; t >= 0; t--) {
            if (t + A[i] < T) {
                dp2[t + A[i]] = std::max(dp2[t + A[i]], dp2[t] + B[i]);
            }
        }
        //cerr << ans << endl;
    }
    cout << ans << endl;
    
    return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int n;
    cin>>n;
    string s;
    cin>>s;

    f1(i,0,s.size())
    {
    	int m=s[i];
    	//cout<<m<<endl;
    	m-='A';
    	//cout<<m<<endl;
    	m+=n;
    	//cout<<m<<endl;
    	m%=26;
    	m+='A';
    	s[i]=char(m);
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp
a = gets.chomp.split(" ").map(&:to_i)

inc = 0
dec = 0
count = 1

for i in 0..n.to_i-2
    if ((a[i] - a[i+1]) == 0)
        
    elsif ((a[i] - a[i+1]) > 0)
        dec = 1
        if(inc == 1)
            count += 1
            dec = 0
        end
        inc = 0
    elsif ((a[i] - a[i+1]) < 0)
        inc = 1
        if(dec == 1)
            count += 1
            inc = 0
        end
        dec = 0
    end
end

print(count)
print("\n")

Measured memory_bytes: 11532
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 110000;

int n, size[N];
ll d[N], g[N];
vector<int> to[N];
map<ll, int> rev;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void dfs(int now) {
	for (auto &v : to[now]) {
		printf("%d %d\n", now, v);
		dfs(v);
	}
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i)
		read(d[i]), rev[d[i]] = i;
	while (rev.size() > 1) {
		auto it = prev(rev.end());
		size[it->second] += 1;
		ll w = 2 * size[it->second] - n + it->first;
		auto f = rev.find(w);
		if (f == it || f == rev.end())
			return printf("-1\n"), 0;
		to[f->second].push_back(it->second);
		size[f->second] += size[it->second];
		g[f->second] += g[it->second] + size[it->second];
		rev.erase(it);
	}
	int rt = rev.begin()->second;
	if (g[rt] != d[rt]) return printf("-1\n"), 0;
	dfs(rt);
	return 0;
}

Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
int main()
{
	ios;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
	{
		c-=b;
		if(c<=0)
			break;
		a-=d;
	}
	if(a<=0)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
using namespace std;
int gcd(int a, int b) {
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
signed main() {
	int a, b; cin >> a >> b; a = gcd(a, b); b = a;
	vector<int>p;
	for (int i = 2; i <= sqrt(a); i++) {
		bool b00l = 1;
		for (int j : p)if (i%j == 0) { b00l = 0; break; }
		if (b00l && b%i == 0) {
			p.push_back(i);
			while (b%i == 0)b /= i;
		}
	}
	int ans = p.size() + 1; if (b > 1)ans++;
	cout << ans << endl;
}

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

const int MOD = 1000000007;

int main() {
    int n,ct;
    ct = 0;
    cin >> n;
    P a[110];
    rep(i, n) {
        cin >> a[i].first;
        cin >> a[i].second;
    }
    rep(j, n - 2) {
        if (a[j].first == a[j].second && a[j + 1].first == a[j + 1].second && a[j + 2].first == a[j + 2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(){
    int x,y;
    cin>>x>>y;

    int num[13]={0,1,0,1,2,1,2,1,1,2,1,2,1};

    if(num[x]==num[y])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();

    Pattern p = Pattern.compile("^[^A]*(A.*Z)[^Z]*$");
    Matcher m = p.matcher(a);
    if (m.find()) {
      System.out.println(m.group(1).length());
    }
  }
}


Measured memory_bytes: 26464
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int x=sc.nextInt();
        if(500*k>=x){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }



}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  lint x;
  cin >> x;
  
  lint ans = 0;
  lint money = 100;
  
  while(1){
    money = money * 1.01;
    ans++;
    if(money>=x){
      cout << ans << endl;
      return 0;
    }
  }
  
}



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

using namespace std;

int main() {
    vector<pair<int, int>> X(5);
    int a;
    for(int i = 0; i < 5; ++i)
    {
        cin >> a;
        X[i].first = a % 10 == 0 ? 0 : 10 - a % 10;
        X[i].second = a;
    }
    sort(X.begin(), X.end());

    int ans = X[4].second;
    for(int i = 0; i < 4; ++i)
        ans += X[i].first + X[i].second;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        if(A<B*2)System.out.printf("0");
        else System.out.printf("%d",A-B*2);
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int N,M;
vint G[111111];

bool used[111111];
int out[111111];
int dep[111111];
vpint ans;
void dfs(int v,int d){
	used[v]=true;
	dep[v]=d;
	for(auto u:G[v]){
		if(used[u]){
			if(dep[u]>=dep[v]-1)continue;
			ans.eb(v,u);
			out[v]^=1;
		}
		else{
			dfs(u,d+1);
			if(out[u]){
				ans.eb(u,v);
				out[u]^=1;
			}
			else{
				ans.eb(v,u);
				out[v]^=1;
			}
		}
	}
}

signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);G[b].pb(a);
	}


	if(M&1){
		cout<<-1<<endl;
	}
	else{
		dfs(0,0);
		rep(i,ans.size())cout<<ans[i].fi+1<<" "<<ans[i].se+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 16752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  vector<ll> h(n);
  rep(i,n){
    cin>>h[i];
  }
  vector<ll> dp(n+k,LLONG_MAX);
  dp[0]=0;
  rep(i,n){
    fori(j,1,k+1){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>
#include <math.h>

using namespace std;

int main(){
    int P,Q,R;
    scanf("%d %d %d", &P, &Q, &R);
    int ret = min(min(P+Q,Q+R), P+R);
    printf("%d\r\n", ret);
    fflush(stdout);
    
    return 0;
}

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

int main()
{
    int k,x,i;
    int a[1000];
    cin>>k>>x;
    int j=0;
    for(i=x;i>x-k;i--){
        a[j]=i;
        j++;
    }
       int m=j;
       for(i=x;i<x+k;i++){
           a[m]=i;
           m++;
    }
    sort(a,a+(k+k));
int jj=0,cnt=0;
int tmp[1000];

    for(i=0;i<(k+k)-1;i++)
    {
        if(a[i]!=a[i+1])
        {
            cnt++;
            tmp[jj]=a[i];
            jj++;
        }
    }
   tmp[jj]=a[k+k-1];
      for(i=0;i<cnt;i++)
    {
        cout<<tmp[i]<<" ";

    }
    cout<<tmp[jj]<<" ";

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(aa):
        if len(aa)==n+1:
            res=0
            for a,b,c,d in ad:
                if aa[b]-aa[a]==c:res+=d
            return res

        res=-1
        for a in range(aa[-1],m+1):
            res=max(dfs(aa+[a]),res)
        return res

    n,m,q=MI()
    ad=LLI(q)
    print(dfs([1]))

main()

Measured memory_bytes: 9136
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

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

  cin >> S;

  int win = 0;
  int k = len(S);
  for (int i = 0; i < k; ++i) {
    if (S[i] == 'o') ++win;
  }

  win += 15 - k;

  if (win >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,l,i;
  cin>>n;
  string s;
  cin>>s;
  if(s.size()<=n)
    cout<<s;
  else
  {
    for(i=0; i<n; i++)
        {
          cout<<s[i];
        }
        cout<<"...";
   }
  
  
}

Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
ll ans;
ll ma(int a)
{
  if(a==1)
  {
    ans=ans+300000;
  }
  else if(a==2)
  {
    ans=ans+200000;
  }
  else if(a==3)
  {
    ans=ans+100000;
  }
return 0;
}

int main()
{
  int x;
  int y;
  cin>>x>>y;
  ll a1=300000;
  ll a2=200000;
  ll a3=100000;
  ll a4=400000;
  if(x==1&&y==1)
  {
    cout<<a4+a1*2<<endl;
    return 0;
  }
  ma(x);
  ma(y);
  cout<<ans<<endl;


}

Measured memory_bytes: 256