akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    ll n,a;
    ll c[200010],jp[200010];
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,200010) {
        c[i] = -1;
        jp[i] = -1;
    }
    rep(i,n) {
        cin >> a;
        if(c[a] == -1) {
            c[a] = i;
        } else {
            jp[i] = c[a];
            c[a] = i;
        }
    }
    c[0] = 1;
    for(int i = 1; i < n; i++) {
        c[i] = c[i-1];
        c[i] %= (ll)1e9 + 7;
        if(jp[i] != -1 && jp[i] != i-1) {
            c[i] += c[jp[i]];
        }
        c[i] %= (ll)1e9 + 7;
    }
    cout << c[n-1] << endl;
}

Measured memory_bytes: 3456
I=lambda:list(map(int,input().split()));n,m=I();l=[I()[::-1]+[i]for i in range(m)];c=[0]*-~n;a=[0]*m
for y,p,i in sorted(l):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]
for t in a:print(t)

Measured memory_bytes: 32516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int gcd(int n,int m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int g = -1;
    cin >> N;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        g = (g==-1? a:gcd(g,a));
    }
    cout << g << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (abs(A - B) >= 2)
        ans += 2 * max(A, B) - 1;
    else
        ans += A + B;

    cout << ans << endl;

    return 0;
}

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}

int g[15][15];

int main() {
    int n;
    cin >> n;
    rep(i, n) rep(j, n) g[i][j] = -1;
    rep(i, n) {
        int m;
        cin >> m;
        rep(j, m) {
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }

    int ans = 0;
    rep(i, 1 << n) {
        vi d(n);
        rep(j, n) {
            if(i >> j & 1) {
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j, n) {
            if(d[j]) {
                rep(k, n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define Rep(i,a,b) for(int i=a;i<=b;++i)
#define Rrep(i,a,b) for(int i=a;i>b;--i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
#define pb push_back
#define pv(x) for(auto y:x)    cout<<y<<" ";    cout<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
#define ri(X) scanf("%lld", &(X))
#define rii(X, Y) scanf("%lld%lld", &(X), &(Y))
#define riii(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define dri(X) ll (X); scanf("%lld", &X)
#define drii(X, Y) ll X, Y; scanf("%lld%lld", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define rs(X) scanf("%s", (X))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
typedef long long ll;
typedef std::vector< ll > vi;
typedef std::pair<ll, ll> pi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        pbds;
const double pie = 3.14159265358979323846;
auto _C=clock();
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;         ;;    ;;     ;;;;;;;     ;;     ;;  ;;;;     ;;
 ;;       ;;   ;;  ;;   ;;    ;;    ;;     ;;  ;; ;;    ;;
  ;;     ;;   ;;    ;;  ;;    ;;    ;;     ;;  ;;  ;;   ;;
   ;;   ;;    ;;;;;;;;  ;;;;;;;     ;;     ;;  ;;   ;;  ;;
    ;; ;;     ;;    ;;  ;;   ;;      ;;   ;;   ;;    ;; ;;
     ;;;      ;;    ;;  ;;    ;;       ;;;     ;;     ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
*/
int binpow(int base,int e,int mod=U)
{
	int res=1;
	while(e)
	{
		if(e&1) res=(base*res)%mod;
		base=(base*base)%mod;
		e>>=1;
	}
	return res;
}
signed main()
{		
	nitro;
	int CASE=1;
	//ri (CASE);
	//cin>>CASE;
	while(CASE--)
	{
		int n;
		cin>>n;
		//cout<<(n*(n-1))%U<<endl;
		cout<<(binpow(10,n)-2*binpow(9,n)+binpow(8,n)+2*U)%U<<endl;
		
		
	}
	
	
	
	

//cerr<<"\n\n\nTime elapsed: "<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";		

	return 0;
}



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



int main() {
    int N;
    cin >> N;
    vi C(N-1), S(N-1), F(N-1);
    rep(i, N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    vi tim;
    rep(i, N-1) {
        tim.push_back(0);
        rep(j, i+1) {
            if(tim[j] <= S[i]) {
                tim[j] = S[i] + C[i];    
            } else { 
                int t;
                t = (tim[j] + F[i] - 1)/F[i];
                tim[j] = F[i] * t;
                tim[j] += C[i];
            }
        }
    }
    rep(i, N-1) {
        cout << tim[i] << '\n';
    }
    cout << 0 << '\n';
}

Measured memory_bytes: 256
// n using Sieve of Eratosthenes 
#include <bits/stdc++.h> 
#include <iostream>
#include <cmath>
using namespace std;
# define M_PI 3.14159265358979323846 
#define ll long long int
 
int main(){
ll n,m;cin>>n>>m;
ll sum=0;
while(m--){
    ll x;cin>>x;
    sum=sum+x;
}
if(sum>n) cout<<"-1";
else cout<<n-sum;
return 0;	
}

Measured memory_bytes: 3624
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=5e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int x=min(a,k),ans=0;
    ans+=x;
    k-=x;
    x=min(b,k);
    k-=x;
    x=min(c,k);
    ans-=x;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15


def main():
    N,M = map(int,input().split())
    MAXN = M + 2
    fact = [1]
    for i in range(1,MAXN + 1):
        fact.append(fact[-1]*i%MOD)
    inv_fact = [-1] * (MAXN + 1)
    inv_fact[-1] = pow(fact[-1],MOD - 2,MOD)
    for i in range(MAXN - 1,-1,-1):
        inv_fact[i] = inv_fact[i + 1]*(i + 1)%MOD
    
    nck = lambda N,K: 0 if K > N or K < 0 else fact[N]*inv_fact[N - K]*inv_fact[K]%MOD
    npk = lambda N,K: 0 if  K > N or K< 0 else fact[N]*inv_fact[N - K]%MOD

    ans = npk(M,N)*npk(M,N)%MOD
    cum = 0
    for i in range(N,0,-1):
        ret = nck(N,i)*npk(M,i)%MOD*npk(M-i,N-i)*npk(M-i,N-i)%MOD
        ret -= 2*cum
        ans -= ret
        ans %= MOD
        cum += ret
        cum %= MOD
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 108028
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	
	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		// 3倍操作は何回でもいいが、と2で割る操作は1回は行う必要があります。
		// A[i]に対して2で割る操作を何回行うことができるのかの回数を計算する
		while(A[i] % 2 == 0)
		{
			A[i] /= 2;
			answer++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt();
    int S = 0;
    if(A <= B){
      S += A; 
    }
    else{
      S += B;
    }
    int C = sc.nextInt(), D = sc.nextInt();
    if(C <= D){
      S += C; 
    }
    else{
      S += D;
    }
    System.out.println(S);
  }
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	bool can=true;
	ll tmp=0;
	while(true){
		if(tmp==0){
		    c=c-b;
		    if(c<=0){
		    	can=true;
		    	break;
		    }

		}
		else{
			a=a-d;
			if(a<=0){
				can=false;
				break;
			}

		}
		tmp=tmp^1;


	}
	if(can) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;




	

}




Measured memory_bytes: 3624
#include <iostream>
#include <string> //文字列を使う
using namespace std;

int main(void){
   string s;
   while(true){
       cin >> s;
       if(s == "0"){
           break;
       }
       int sum=0;
       for(int i=0; i<s.size() ; i++){
           int n=s[i]-48;
           //TODO:文字コードを数値に変換する
           sum += n;
       }
       cout << sum << endl;
   }
}




Measured memory_bytes: 3180
#include<stdio.h>
int gcd(int x, int y){
  if(y==0) return x;

  return gcd(y, x%y);
}

int main(){
  int unused __attribute__((unused));
  int K, a, b, c, tmp;
  long long sum = 0;
  unused = scanf("%d", &K);

  for(a=1; a<=K; a++){
    for(b=1; b<=K; b++){
      for(c=1; c<=K; c++){
        tmp = gcd(a, b);
        sum += gcd(tmp, c);
      }
      c--;
    }
    b--;
  }

  printf("%lld", sum);

  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin>>N;
    long long U[1005],V[1005];
    char d[4] = {'L','D','U','R'};
    int X,Y;
    for(int i = 0;i < N;i++){
        cin>>X>>Y;
        U[i]=X+Y;
        V[i]=X-Y;
    }
    bool flag = 1;
    int oe = abs(U[0])%2;
    for(int x = 0;x < N;x++){
        if(oe!=abs(U[x])%2||oe!=abs(V[x])%2){
            flag = 0;
            break;
        }
    }
    if(!flag){
        cout<<-1<<endl;
        return 0;
    }if(oe==1){
        //d出力
        cout<<31<<endl;
        for(int i = 30;i >= 1;i--){
            cout<<(1<<i)<<" ";
        }
        cout<<1<<endl;
        
        for(int x = 0;x < N;x++){
            long long u= 1-((long long)1<<31);
            long long v= u;
            for(int i = 30;i >= 0;i--){
                int ans = 0;
                long long plus =(long long)1<<(i+1);
                if(u+plus<=U[x]){
                    u+=plus;
                    ans += 2;
                }
                if(v+plus<=V[x]){
                    v+=plus;
                    ans += 1;
                }
                cout<<d[ans];
            }
            cout<<endl;
        }
    }else{
        //d出力
        cout<<32<<endl;
        for(int i = 30;i >= 0;i--){
            cout<<(1<<i)<<" ";
        }
        cout<<1<<endl;
        
        for(int x = 0;x < N;x++){
            long long u= -(long long)1<<31;
            long long v= u;
            for(int i = 30;i >= 0;i--){
                long long plus =(long long)1<<(i+1);
                int ans = 0;
                if(u+plus<=U[x]){
                    u+=plus;
                    ans += 2;
                }
                if(v+plus<=V[x]){
                    v+=plus;
                    ans += 1;
                }
                cout<<d[ans];
            }
            int ans = 0;
            ans += U[x]-u;
            ans += (V[x]-v)/2;
            if(ans<0||ans>3){
                cout<<"ans "<<ans<<endl;
            }
            cout<<d[ans];
            cout<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 2e5 + 5;

vector<int> adj [MAX_N];

pair<int, int> farthest (int u, int p) {
  auto ans = make_pair(0, u);
  for (int nxt : adj[u]) {
    if (nxt != p) {
      auto pr = farthest(nxt, u);
      pr.first++;
      ans = max(ans, pr);
    }
  }
  return ans;
}

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

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int r = farthest(1, 0).second;
  int diam = farthest(r, 0).first;
  diam++;

  if (diam % 3 == 2) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}


Measured memory_bytes: 30072
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll const MAX = 200005;
ll a[MAX];

int main() {
	ll n, l;
	cin >> n >> l;
	ll v = -1;
	REP(i, 1, n) {
		cin >> a[i];
		if (i >= 2) {
			if (a[i] + a[i - 1] >= l) {
				v = i - 1;
			}
		}
	}
	if (v == -1) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		REP(i, 1, v-1) {
			cout << i << endl;
		}
		PER(i, n - 1, v) {
			cout << i << endl;
		}
	}
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int a, b; cin >> a >> b;
  int cnt = 0;
  FOR(i, a, b+1) {
    string s = to_string(i);
    string t = s;
    reverse(ALL(s));
    if(t == s) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin>>O;
  cin>>E;
  int o=0;
  int e=0;
  
  for(int i=0;i<O.size()+E.size();i++){
    if(i%2==0){
      cout<<O.at(o);
      o++;
      
    }
    else{
      cout<<E.at(e);
      e++;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll a, b, c,k;
  cin >> a >> b >> c>>k;
  if(k<=a)cout << k << "\n";
  else if (k <= a + b) cout << a << "\n";
  else cout << a-(k-a-b) << "\n";
  return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

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

        int result = t.length;
        for (int i = 0; i <= s.length - t.length; i++) {
            int diff = 0;
            for (int j = 0; j < t.length; j++) {
                if (!t[j].equals(s[i+j])) diff++;
            }
            result = Math.min(result, diff);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 37072
S=gets.chomp.codepoints
a,b,c="abc".codepoints
as=Array.new(3,0)
S.each do |i|
  as[0]+=1 if i==a
  as[1]+=1 if i==b
  as[2]+=1 if i==c
end
puts as.max-as.min<=1 ? "YES" : "NO"

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

int main()
{
	int64_t n, m, l, inf = (1LL << 60);
	cin >> n >> m >> l;
	vector<int64_t> as(m), bs(m), cs(m);
	for (int64_t i = 0; i < m; i++)
	{
		cin >> as[i] >> bs[i] >> cs[i];
		as[i]--;
		bs[i]--;
	}

	vector<vector<int64_t>> g(n, vector<int64_t>(n, inf));
	for (int64_t i = 0; i < n; i++)
	{
		g[i][i] = 0;
	}
	for (int64_t i = 0; i < m; i++)
	{
		g[as[i]][bs[i]] = g[bs[i]][as[i]] = cs[i];
	}
	for (int64_t k = 0; k < n; k++)
	{
		for (int64_t i = 0; i < n; i++)
		{
			for (int64_t j = 0; j < n; j++)
			{
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = 0; j < n; j++)
		{
			g[i][j] = (g[i][j] <= l) ? 1 : inf;
		}
	}
	for (int64_t k = 0; k < n; k++)
	{
		for (int64_t i = 0; i < n; i++)
		{
			for (int64_t j = 0; j < n; j++)
			{
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int64_t q;
	cin >> q;
	for (int64_t _ = 0; _ < q; _++)
	{
		int64_t s, t;
		cin >> s >> t;
		s--;
		t--;

		cout << ((g[s][t] == inf) ? -1 : (g[s][t] - 1)) << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;
ll lv[51];
ll cntL(ll level){
  if(level == 0){
    lv[0] = 1;
    return 1;
  }
  if(lv[level] != 0) return lv[level] ;
  lv[level] = 3 + 2*cntL(level - 1);
  return lv[level];
}

ll pati(ll level,ll index){
  //cout << "cntL ," << level << ", "<< cntL(level) << endl;
  if(level == 0 && index == 0){
    return 1;
  }
  if(index == 0) return 0;//ban
  else if(index <= cntL(level-1)){
    //cout << "level =" << level << " index = "<< index << " pat " << 0 << endl;
    return pati(level-1,index-1);
  }else if(index == cntL(level-1) + 1){
    //cout << "level =" << level << " index = "<< index << " pat " << 1 << endl;
    return pati(level-1,cntL(level-1)-1) + 1;
  }else if(index < cntL(level) - 1){
    //cout << "level =" << level << " index = "<< index << " pat " << 2 << endl;
    return pati(level-1,cntL(level-1)-1) + 1 + pati(level - 1, index - cntL(level-1) - 2);
  }else if(index == cntL(level) - 1){
    //cout << "level =" << level << " index = "<< index << " pat " << 3 << endl;
    return 1+ 2*pati(level-1,cntL(level-1)-1);
  }
  cout << "error"<< endl;
  return 0;
}

int main(){
  ll n,x;
  cin >> n >> x;
  ll ans = pati(n,x-1);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<cstdio>
#include<queue>
#define PI 3.1415927
using namespace std;
int main() {
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}


Measured memory_bytes: 2936
from math import factorial

n, k = map(int, input().split())
def fac(n, r):
    return factorial(n) // (factorial(max(0, n - r)) * factorial(r))
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))


Measured memory_bytes: 9396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)
    cin >> a[i] >> b[i];
  vector<pair<int,int>> ab(n);
  for(int i=0;i<n;i++){
    ab[i]=make_pair(a[i],b[i]);
  }
  sort(ab.begin(),ab.end());
  long long ans=0;
  for(int i=0;i<n;i++){
    int buy=min(m,ab[i].second);
    ans+=(long long)buy*ab[i].first;
    m-=buy;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#ifndef ___Class_RSQ
#define ___Class_RSQ

#include <vector>
#include <algorithm>

using namespace std;

template <typename Type> class RSQ
{
private:

	int size;

	vector<Type> sumvalue;

	Type _query(int a, int b, int k, int l, int r)
	{
		if (r <= a || b <= l) { return 0; }
		if (a <= l && r <= b) { return sumvalue[k]; }

		Type vl = _query(a, b, 2 * k, l, (l + r) / 2);
		Type vr = _query(a, b, 2 * k + 1, (l + r) / 2, r);

		return vl + vr;
	}

public:

	RSQ(int size_)
	{
		for (size = 1; size < size_;) { size <<= 1; }

		sumvalue = vector<Type>(size * 2, 0);
	}

	void update(int i, const Type& x)
	{
		i += size;

		sumvalue[i] += x;

		while (i > 1)
		{
			i = i / 2;

			sumvalue[i] = sumvalue[i * 2] + sumvalue[i * 2 + 1];
		}
	}

	Type query(int s, int t)
	{
		return _query(s, t, 1, 0, size);
	}
};

#endif


// ------ main ------ //

#include <cstdio>

int n, q, com, x, y;

int main()
{
	scanf("%d", &n);
	scanf("%d", &q);

	RSQ<long long> r(n);

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &com);
		scanf("%d", &x);
		scanf("%d", &y);

		if (com == 0)
		{
			r.update(x - 1, y);
		}
		if (com == 1)
		{
			printf("%lld\n", r.query(x - 1, y));
		}
	}

	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int h,w;
ll cnt[161000][2];

bool inside(int y, int x)
{
    return (0<=y && y<h && 0<=x && x<w);
}

int category(char c)
{
    if(c=='#') return 0;
    else return 1;
}

int main(){
    cin>>h>>w;
    ll ans =0;
    vector<string> stage(h);
    int groups[410][410];
    ll cnt[161000][2];
    int nowgroup = 0;
    
    for(int i = 0; i < 161000; i++)
    {
        
        for(int j = 0; j < 2; j++)
        {
            cnt[i][j]=0;
        }
        
    }
    
    
    for(int i = 0; i < h; i++)
    {
        cin>>stage[i];
    }
    
    for(int y = 0; y < h; y++)
    {
        for(int x = 0; x < w; x++)
        {
            if(groups[y][x]!=0) continue;
            nowgroup++;
            groups[y][x]=nowgroup;
            cnt[nowgroup][category(stage[y][x])]++;
            queue<int> qy,qx;
            qy.push(y);
            qx.push(x);
            while(qy.size()>0)
            {
                int nowy=qy.front();
                int nowx=qx.front();
                qy.pop();
                qx.pop();
                
                for(int i = 0; i < 4; i++)
                {
                    int nexty=nowy+dy4[i];
                    int nextx=nowx+dx4[i];
                    if(inside(nexty,nextx) && groups[nexty][nextx]==0
                        && stage[nowy][nowx]!=stage[nexty][nextx])
                    {
                        groups[nexty][nextx]=nowgroup;
                        cnt[nowgroup][category(stage[nexty][nextx])]++;
                        qy.push(nexty);
                        qx.push(nextx);
                    }
                }
                
            }
        }
    }
    
    
    for(int i = 1; i <= nowgroup; i++)
    {
        ans += cnt[i][0]*cnt[i][1];
    }
    

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

Measured memory_bytes: 3712
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int n;
int x[200];
int y[200];
int h[200];

int main(){
  cin >> n;
  int f1 = 0;
  int fff;
  REP(i,n){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]>0&&f1==0){
      f1 = 1;
      fff = i;
    }

  }
  REP(i,101){
    REP(j,101){
      int rh = h[fff]+abs(x[fff]-i)+abs(y[fff]-j);
      int f = 0;
      REP(k,n){
        int t = rh - abs(x[k]-i)-abs(y[k]-j);
        if(max(0,t)!=h[k]){
          f = 1;
        }
      }
      if(f==0&&rh>0){
        cout << i << " " << j << " " << rh << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	rep(i, N){
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int ans = 0;
	rep(i, N){
		if (i >= K){	
			break;
		}
		else{
			ans += p[i];
		}
	}
	cout << ans << endl;
	return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol a, b; cin >> a >> b;
    lol n; cin >> n;
    lol x;
    //lol k; cin >> k;
    /*
    vector<lol> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
    if(b-1 <= n)
    {
        x = b-1;
    }
    else
    {
        x = n;
    }
    result = floor(a*x/b)-a*floor(x/b) + 0.01;
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =5e2+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld k,n,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
ld dp[M][M];
lld t[M],v[M];
ld check(lld v1,lld v2,lld ctime,lld lim)
{
  if(abs(v1-v2)>ctime)return -1; 
  if(v1<v2)swap(v1,v2);
  
    if(2*lim-v1-v2<=ctime)
    {
      ctime-=(2*lim-v1-v2);
      ld fans=(lim-v1)*(lim+v1)+(lim-v2)*(lim+v2);
      fans/=2;
      fans=fans+lim*ctime;
      return fans;
    }
    else
    {
        ld x=ctime+v1+v2;
        x/=2;
        ld fans=(x-v2)*(x+v2)+(x-v1)*(x+v1);
        fans/=2;
        return fans;
    }
}
int main()
{
      lld i,j,v1,v2;
        is(n);
        up(1,n+1,i)is(t[i]);
        up(1,n+1,i)is(v[i]);
        up(0,M,i)
        {
          up(0,M,j)
          dp[i][j]=INT_MIN;
        }
        dp[0][0]=0;
        v[0]=0;
        ld ans=0;
        up(1,n+1,i)
        {
          up(0,v[i]+1,v1)
          {
            up(0,min(v[i-1]+1,v[i]+1),v2)
            {
              ld x=check(v1,v2,t[i],v[i]);
              if(x!=-1)
              {
               ld y=dp[i][v1];
               dp[i][v1]=max(dp[i][v1],dp[i-1][v2]+x); 
               if(dp[i][v1]!=y){
                dg4(i,v1,v2,x)
               }
              }
            }
            
          }
        }
        cout<<fixed<<dp[n][0]<<endl;
        return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

void call(int n);
int main(){
	int n;
	scanf("%d", &n);
	call(n);
	return 0;
}
void call(int n){
	int i = 1, x;
	do{
		x = i;
		if (x % 3 == 0)

			printf(" %d", i);

		else
		{
			do
			{
				
				if (x % 10 == 3)
				{
					printf(" %d", i);
					break;
				}

				x /= 10;
			} while (x);
		}
	} while (++i <= n);
	puts("");
	return;

}

Measured memory_bytes: 608
use proconio::input;

fn main() {
    input! {
        mut n: u64,
    }

    let mut x = 2;
    let mut count_list = vec![];

    while x * x <= n {
        let mut c = 0;
        while n % x == 0 {
            n /= x;
            c += 1;
        }
        count_list.push(c);
        x += 1;
    }

    if n != 1 {
        count_list.push(1);
    }

    let mut m = 0;
    for p in count_list {
        let mut c = p;
        let mut i = 1;
        while c >= i {
            m += 1;
            c -= i;
            i += 1;
        }
    }
    println!("{}", m);
}


Measured memory_bytes: 6072
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 1300031;

int h,w,n,am[N];
int ans[500][500];

vector<int> order;

void process(int a,int b)
{
	int id=order.back();
	order.pop_back();
	ans[a][b]=id;
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>h>>w;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>am[i];
		for (int j=1;j<=am[i];j++)
		{
			order.push_back(i);
		}
	}

	for (int i=1;i<=h;i++)
	{
		if (i%2)
		{
			for (int j=1;j<=w;j++)
			{
				process(i,j);
			}
		}
		else
		{
			for (int j=w;j>=1;--j)
			{
				process(i,j);
			}
		}
	}

	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
		{
			if (j>1)
				cout<<" ";
			cout<<ans[i][j];
		}
		cout<<endl;
	}

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll v[N];
ll n, k;

void solve(){
    cin >> n;
    for(ll i = 1; i<= n; i++)
        cin >> v[i];
    ll ans = INT_MAX;
    for(ll p = 0; p <= 101; p++){
        ll dist = 0;
        for(ll i = 1; i <= n; i++)
            dist += (v[i] - p) * (v[i] - p);
        ans = min(ans, dist);
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
use std::f64::consts::PI;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: f64 = sc.read();
    let b: f64 = sc.read();
    let x: f64 = sc.read();
    let radian: f64 = if a*a*b / 2. <= x {
        ((a*a*b-x)*2. / (a*a*a)).atan()
    } else {
        PI / 2. - (2.*x / (a*b*b)).atan()
    };

    let ans: f64 = radian*180. / PI;
    println!("{}", ans);

}
// cited from https://kenkoooo.hatenablog.com/entry/2019/05/07/101033
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4476
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

daplus = a + v*t
daminus = a - v*t

if daplus < daminus:
    tmp = daplus
    daplus = daminus
    daminus = tmp

dbplus = b + w*t
dbminus = b - w*t

if dbplus < dbminus:
    tmp = dbplus
    dbplus = dbminus
    dbminus = tmp


flag = 0

#aが鬼

if(daminus <= dbplus & dbplus <= daplus):
    flag += 1
if(daminus <= dbminus & dbminus <= daplus):
    flag += 1

if flag == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <cmath>
#include <limits>
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

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

    double ans = 0;
    for (ll i = 1; i < n + 1; i++)
    {
        if (i >= k)
        {
            ans += 1.0 / n;
        }
        else
        {
            double temp;
            temp = log2(k) - log2(i);
            int tos = ceil(temp);
            ans += (1.0 / n) * pow(0.5, tos);
        }
    }
    cout << setprecision(15) << fixed << ans << endl;
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005;
int n, m, h[MX], res;
vi adj[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> h[i];

	while (m--) {
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	for (int u = 1; u <= n; u++) {
		int f = 1;
		for (int v : adj[u])
			if (h[v] >= h[u])
				f = 0;
		res += f;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 9900
#include<stdio.h>
int n,A[2000];

/*is it possible to make m by adding A's element whose indexs are more than i*/
int solve(int i,int m){
    if (m==0) return 1;
    if(i>=n) return 0;
    int res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}

int main(){
    int i;
    int cur,M;
    
    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&A[i]);
    
    scanf("%d",&M);
    for (i=0;i<M;i++){
        scanf("%d",&cur);
        if(solve(0,cur)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	int count = 0;
	for(int i = 0 ; i < S.size() ; ++i) {
		switch(S[i]) {
		case '(':
			++count;
			break;

		case ')':
			if(count) {
				--count;
			} else {
				S = '(' + S;
				++i;
			}
			break;
		}
	}

	cout << (S + string(count, ')')) << endl;
}


Measured memory_bytes: 256
import math

n = int(input())
XY = [list(map(int,input().split())) for i in range(n)]

XY.sort(key=lambda x: math.atan2(x[1],x[0]))
XY += XY

ans = 0
for i in range(n):
    x = 0
    y = 0
    for j in range(n):
        nx,ny = XY[i+j]
        x += nx
        y += ny
        ans = max(ans,(x**2+y**2)**0.5)
print(ans)

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, m, x; cin >> n >> m >> x;
    vector<ll> lis(n);
    vector<vector<ll> > alis(n, vector<ll>(m, 0));
    ll ans = 2e11;
    REP(i, 0, n){
        cin >> lis[i];
        REP(l, 0, m){
            cin >> alis[i][l];
        }
    }
    REP(i, 0, (1 << n)){
        vector<ll> mid(m, 0);
        ll sum = 0;
        ll c = i;
        REP(l, 0, n){
            if(c & 1 == 1){
                sum += lis[l];
                REP(j, 0, m){
                    mid[j] += alis[l][j];
                }
            }
           c = (c >> 1);
        }
        int f = 1;
        REP(l, 0, m){
            if(x > mid[l]){
                f = 0;
            }
        }
        if(f == 0){
            continue;
        }else{
            ans = min(ans, sum);
        }
    }
    if(ans == 2e11){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int n[4];
    n[0]=N/1000;
    n[1]=(N/100)%10;
    n[2]=(N/10)%10;
    n[3]=N%10;
    if((n[0]==n[1])&&(n[1]==n[2])){
      printf("Yes");
    }else if((n[1]==n[2])&&(n[2]==n[3])){
      printf("Yes");
    }else{
      printf("No");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()

using namespace std;

int main(){


  int N;
  vector<vector<int>> coords;
  vector<long> h;

  cin >> N;

  rep(i,N){
    int x_,y_;
    long h_;
    scanf("%d %d %ld",&x_,&y_,&h_);
    vector<int> c;
    c.push_back(x_);
    c.push_back(y_);

    coords.push_back(c);
    h.push_back(h_);
  }

  const long min_h = *min_element(h.begin(), h.end());
  const long max_h = *max_element(h.begin(), h.end());

  rep(x,101){
    rep(y,101){

      for(long height=min_h; height<max_h+101; height++){
        bool ok = true;

        rep(i,coords.size()){
            long height_at_coord = height-abs(x-coords[i][0])-abs(y-coords[i][1]);
            if(height_at_coord < 0){
              height_at_coord = 0;
            }
            if(height_at_coord != h[i]){
              ok = false;
              break;
            }
        }

        if(ok){
          cout << x << ' ' << y << ' ' << height << endl;
          return 0;
        }

      }

    }
  }

  return 0;

}

Measured memory_bytes: 888
a = 1
b = 1

while 2>1:
    print(str(a)+"x"+str(b)+"="+str(a*b))
    if a == 9 and b == 9:
        break
    if b != 9:
        b = b + 1
    else:
        a = a + 1
        b = 1

Measured memory_bytes: 7344
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int x, y;
	cin >> x >> y;
	int a = 4 * x - y;
	int b = y - 2 * x;
	bool flag1 = false, flag2 = false;
	for (int i = 0; i <= 100; i++) {
		if (2 * i == a) flag1 = true;
		if (2 * i == b) flag2 = true;
		if (flag1 && flag2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  char c='8';
  s[3]=c;
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

vector<ll> powten{1,10,100,1000,10000};
vector<ll> D(10,0);

ll check(ll N){
  string sN = to_string(N);
  REP(i,sN.length()){
    if (D[sN[i]-'0']==1){
      return sN.length()-i-1;
    }
  }
  return -1;
}

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

  ll N, K;
  cin >> N >> K;
  REP(i,K){
    ll di;
    cin >> di;
    D[di] = 1;
  }

  ll res = N;
  ll c;
  while ((c=check(res))>=0){
    res = (res / powten[c] + 1) * powten[c];
  }

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,d;
    scanf("%d%d",&n,&d);
    int a,b;
    b=(2*d)+1;
    a=n/b;
    if(n%b==0){printf("%d\n",a);}
    else{printf("%d\n",a+1);}
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector< VC > VCC;
typedef std::vector<int>  VI;
typedef std::vector< VI > VII;
typedef std::vector<long> VL;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

int N, M;
VII g;
std::vector< PII > data;

int dfs(int i, int d, int p) {
    if(data[i].fst != -1) {
        return data[i].snd;
    }

    data[i].fst = d;
    data[i].snd = d;
    EACH(it, g[i]) {
        if(*it == p) continue;
        int res = dfs(*it, d+1, i);
        data[i].snd = std::min(data[i].snd, res);
    }
    return data[i].snd;
}

int main() {
    std::cin >> N >> M;
    g.resize(N);
    data.resize(N);
    REP(i, N) {
        data[i].fst = -1;
        data[i].snd = -1;
    }

    int a, b;
    REP(i, M) {
        std::cin >> a >> b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0,0,-1);

    int ans = 0;
    REP(i, N) if(data[i].fst == data[i].snd) ans++;
    std::cout << std::max(0, ans-1) << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,j;
    scanf("%d",&n);
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            if(i*j==n){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128