akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

vector<vector<int>> dp(13, vector<int>(13, -1));

int dfs(int from, set<int> &route, int max_cost, int current_cost) {
    int ans = min(max_cost, current_cost + dp[from][1]);
    for (int i = 0; i <= 9; i++) {
        if (i == 1) continue;
        if (i == from)continue;
        if (route.find(i) != route.end()) continue;
        int next_cost = dp[from][i];
        if (current_cost + next_cost >= max_cost) continue;

        route.insert(i);
        int now = dfs(i, route, max_cost, current_cost + dp[from][i]);
        cmin(ans, now);
        route.erase(i);
    }
    return ans;
}

int main() {
    int h, w;
    cin >> h >> w;

    for (int y = 0; y <= 9; y++) {
        for (int x = 0; x <= 9; x++) {
            cin >> dp[y][x];
        }
    }
    set<int> route;

    for (int k = 0; k <= 9; k++) {
        for (int l = 0; l <= 9; l++) {
            for (int m = 0; m <= 9; m++) {
                dp[l][m] = min(dp[l][m], dp[l][k] + dp[k][m]);
            }
        }
    }

    int ans = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int i;
            cin >> i;
            if (i == -1 || i == 1)continue;
            ans += dp[i][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll mod=1e9+7;

ll X,Y;

ll fact[1000005];
ll fact_inv[1000005];

class Comb{
public:
    Comb(ll N){
        fact[0]=1;
        fact_inv[0]=1;
        for(ll i=1;i<=N;++i){
            fact[i]=fact[i-1]*i%mod;
            fact_inv[i]=modPow(fact[i],mod-2);
        }
    }

    ll modPow(ll a, ll n) {
        if(n==1)return a%mod;
        if (n%2==1)return(a*modPow(a,n-1))%mod;
        ll t=modPow(a,n/2);
        return (t*t)%mod;
    }

    ll comb(ll n,ll r){
        return (((fact[n]*fact_inv[r])%mod)*fact_inv[n-r])%mod;
    }
};

int main(){
    cin>>X>>Y;
    Comb C(1000000);
    ll ans=0;
    for(ll n=0;n<X;++n){
        ll m=X-2*n;
        if(m<0)continue;
        if(n+2*m==Y)ans+=C.comb(n+m,m)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

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

class Shape {
public:
    int H;
    int W;
    Shape(int H, int W) {
        this->H = H;
        this->W = W;
    }
};

int main(void) {
    int H, W;
    vector<Shape> shapeList;
    while(true) {
        cin >> H >> W;
        if((H == 0) && (W == 0)) break;
        shapeList.push_back(Shape(H, W));
    }

for(int s=0; s < shapeList.size(); s++) {
    for(int i=0; i < shapeList[s].H; i++) {
        for(int j=0; j < shapeList[s].W; j++) {
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
}

    return 0;
}

Measured memory_bytes: 3108
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 1
temp = a[0]
for i in range(n - 1):
    if a[i + 1] <= temp * 2:
        temp += a[i + 1]
        ans += 1
    else:
        ans = 1
        temp += a[i + 1]
print(ans)

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>ans(n,-1),s(m),c(m);
    rep(i,m){
        cin>>s[i]>>c[i];
        s[i]--;
    }
    rep(i,m){
        if(ans[s[i]]==c[i]||ans[s[i]]==-1)ans[s[i]]=c[i];
        else{cout<<-1<<endl; return 0;}  
    }
    if(n==1){
        if(ans[0]!=-1)cout<<ans[0]<<endl;
        else cout<<0<<endl;
    }
    if(n==2){
        if(ans[0]==0)cout<<-1<<endl;
        else{
            if(ans[0]==-1)ans[0]=1;
            if(ans[1]==-1)ans[1]=0;
            cout<<ans[0]<<ans[1]<<endl;
        }
    }
    if(n==3){
        if(ans[0]==0)cout<<-1<<endl;
        else{
            if(ans[0]==-1)ans[0]=1;
            if(ans[1]==-1)ans[1]=0;
            if(ans[2]==-1)ans[2]=0;
            cout<<ans[0]<<ans[1]<<ans[2]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
const LL mod=1e9+7;
LL arr[N],ans[N];

LL fac[N],opp[N],op_fa[N];

LL mul(LL a,LL b){
	LL base=a;
	LL ans=1;
	while(b){
		if(b&1)ans=(ans*base)%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans%mod;
	
	
}
void preWork(){
	
	fac[0]=fac[1]=1;
	opp[0]=opp[1]=1;
	op_fa[0]=op_fa[1]=1;
	for(int i=2;i<=1e5+1;i++){
		
		fac[i]=((LL)fac[i-1]*i)%mod;
		opp[i]=mul(i,mod-2);
		op_fa[i]=(LL)opp[i]*op_fa[i-1]%mod;
	}

}
LL C(LL n,LL m){
	if(n<m)return 0;   //
	int ans=(LL)fac[n]%mod*(LL)op_fa[n-m]%mod*(LL)op_fa[m]%mod;
	return ans%mod;
}
int mak[N];
int main(){
	
	int n;
	preWork();
	while(cin>>n){
		memset(mak,0,sizeof(mak));
		
		int x,pos1=1,pos2=1,tmp1,tmp2,tmp;
		for(int i=1;i<=n+1;i++){
			cin>>x;
			if(mak[x])tmp=n-i+mak[x];
			mak[x]=i;	
		}
		ans[1]=n;
		for(int i=1;i<=n+1;i++){
	
			ans[i]=((LL)C(n+1,i)-(LL)C(tmp,i-1)+mod)%mod;
			
			
		}
		for(int i=1;i<=n+1;i++){
			
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}

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

#define MOD 1000000007
//#define MOD 998244353
struct mint {
	int i;
	mint() : i(0) {}
	mint(int x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	template<class T> mint(T x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	mint operator+(const mint x) const {return i + x.i;}
	mint operator-(const mint x) const {return i - x.i;}
	mint operator*(const mint x) const {return (long long)i * x.i;}
	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}
	mint inv() {return pow(MOD - 2);}
	template<class T> mint pow(T p) const {
		long long r = 1;
		long long t = i;
		for(; p > 0; p >>= 1) {
			if (p & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	template<class T1, class T2> static mint pow(T1 a, T2 b) {
		long long r = 1;
		long long t = (long long)(a % MOD);
		for(; b > 0; b >>= 1) {
			if (b & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	mint& operator+=(const mint x) {
		i = (i + x.i) % MOD;
		return *this;
	}
	mint& operator-=(const mint x) {
		i = i - x.i;
		if (i < 0) i += MOD;
		return *this;
	}
	mint& operator*=(const mint x) {
		i = (int)((long long)i * x.i % MOD);
		return *this;
	}
	mint& operator/=(const mint x) {
		i = (long long)i * x.pow(MOD - 2).i % MOD;
		return *this;
	}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}


using vvmi = vector<vector<mint>>;
vvmi matmul(const vvmi& a, const vvmi& b) {
    int rsz = a.size();
    int csz = b[0].size();
    int ksz = b.size();
    vvmi res(rsz, vector<mint>(csz));
    rep(i, rsz) rep(j, csz) rep(k, ksz) {
        res[i][j] += a[i][k] * b[k][j];
    }
    return res;
}



int main() {
    int n;
    ll k;
    cin >> n >> k;
    vvmi a(n, vector<mint>(n));
    rep(i, n) rep(j, n) {
        int t;
        cin >> t;
        a[i][j] = t;
    }
    vvmi m(n, vector<mint>(n));
    rep(i, n) m[i][i] = 1;
    for(; k; k >>= 1) {
        if (k & 1) m = matmul(m, a);
        a = matmul(a, a);
    }
    mint ans = 0;
    rep(i, n) rep(j, n) ans += m[i][j];
    cout << ans << endl;
}


Measured memory_bytes: 3608
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = [0] * (n + 1)
    c = [0] * (n + 1)

    for i, x in enumerate(a, 1):
        b[i] = b[i - 1] + max(x, 0)
        c[i] = c[i - 1] + x

    ans = 0
    for i in range(n - k + 1):
        score = b[i] + max(0, c[i + k] - c[i]) + (b[n] - b[i + k])
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86128
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m;    cin >> n >> m;
	if(n&1)     for(int i = 1; i <= m; i++)     cout << i << ' ' << n - i << '\n';
    else{
		int mid = ( n - 1 ) / 2;
		int begin1 = 1,begin2 = mid + 2;
		int num = 0;
		for(int i = mid; i > 0; i -= 2){
			if(num == m)   break;
			cout << begin1 << ' ' << begin1 + i << '\n';
			begin1 ++;
			num ++;	
		}
		for(int i = mid - 1;i > 0;i -= 2){
			if(num == m) break;
			cout << begin2 << ' ' << begin2 + i << '\n';
			begin2++;
		}
	}
	return 0;
}


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

using namespace std;

const double pi = 3.1415926535897;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> f(n);
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    f[x - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << f[i] << '\n';
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll INF = numeric_limits<ll>::max() / 4;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	while (true) {
		ll n, m, s, g1, g2; cin >> n >> m >> s >> g1 >> g2;
		s--; g1--; g2--;
		if (n == 0) break;
		VVI dis(n, vector<ll>(n, INF));
		for (int i = 0; i < n; i++) dis[i][i] = 0;
		for (int i = 0; i < m; i++) {
			ll b1, b2, c; cin >> b1 >> b2 >> c;
			b1--; b2--;
			dis[b1][b2] = c;
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
				}
			}
		}
		ll res = INF;
		for (int i = 0; i < n; i++) {
			ll tmp = dis[s][i] + dis[i][g1] + dis[i][g2];
			res = min(res, tmp);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int temp=i,sum=0;
		while(temp!=0)
		{
			sum+=temp%10;
			temp/=10;
		}
		if(sum>=a&&sum<=b)
		{
			ans+=i;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 1e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[N];
int sum[26][N];
int sum2[N];

int32_t main(){
	fast;

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

  int ans = 1;
  int freq[26] = {0};
  FOR(i,0,n-1){
    freq[s[i] - 'a']++;
  }

  FOR(i,0,25){
    if(freq[i]){
      // cout << i << " " << freq[i] << "\n";
      ans = mul(ans,1 + freq[i]);
    }
  }
  cout << ((ans - 1)%mod + mod)%mod;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

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

	int ans1 = 0;
	if (s[0] == 'B') {
		bool x = false;
		for (int i = 1; i < s.size(); i++) {
			if (s[i] == 'B' && x == true) {
				x = false;
				ans1++;
			}
			else if (s[i] == 'W' && x == false) {
				x = true;
				ans1++;
			}
		}
	}
	else {
		bool x = false;
		for (int i = 1; i < s.size(); i++) {
			if (s[i] == 'W' && x == true) {
				x = false;
				ans1++;
			}
			else if (s[i] == 'B' && x == false) {
				x = true;
				ans1++;
			}
		}
	}

	int ans2 = 0;
	if (s[s.size() - 1] == 'B') {
		bool x = false;
		for (int i = s.size() - 2; i >= 0; i--) {
			if (s[i] == 'B' && x == true) {
				x = false;
				ans2++;
			}
			else if (s[i] == 'W' && x == false) {
				x = true;
				ans2++;
			}
		}
	}
	else {
		bool x = false;
		for (int i = s.size() - 2; i >= 0; i--) {
			if (s[i] == 'W' && x == true) {
				x = false;
				ans2++;
			}
			else if (s[i] == 'B' && x == false) {
				x = true;
				ans2++;
			}
		}
	}
	cout << max(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    long x, y;
    cin >> x >> y;
    long res = 0;
    res += abs(abs(x) - abs(y));
    if (x < y) {
        if (x < 0 && y > 0)
            res++;
    }
    else if (x > y) {
        if (x < 0 && y < 0 || x > 0 && y > 0)
            res += 2;
        else if (x > 0 && y <= 0)
            res++;
        else if (x == 0 && y < 0)
            res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

int arr[200000];

int main(){
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> arr[i];
    }
    if(std::find(arr,arr+n,1) == arr+n){
        std::cout << -1;
        return 0;
    }
    int last = 0;
    for (int i = 0; i < n; ++i) {
        if(arr[i] - last == 1)last = arr[i];
    }
    std::cout << n-last;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a>b){
	cout<<"a > b"<<endl;
}
else if(a<b){
	cout<<"a < b"<<endl;
}
else if(a==b){
	cout<<"a == b"<<endl;
}
return 0;
}


Measured memory_bytes: 3080
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>

int main()
{   int n,i,j,a,x,b=0,m,y;
    scanf("%d",&n);
    while(n>0){
        if(n%10==2)b++;
        n/=10;
    }
    printf("%d",b);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, w[maxn], c[maxn], dp[N], M = N - 12;

main () {
	cin >> n >> m;
	forn (i, 1, n)
		cin >> w[i] >> c[i];


	dp[0] = 0;
	forn (i, 1, M)
		dp[i] = INF;


	forn (i, 1, n)
		forev (j, M, c[i])
			dp[j] = min(dp[j], dp[j - c[i]] + w[i]);

	forev (i, M, 0)
		if (dp[i] <= m)  {
			cout << i << endl;
			return 0;
		}
}                       

Measured memory_bytes: 1024
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    print((N-1 + K-1 -1) / (K-1));
    return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

po = [0 for i in range(5*(10**5)+1)]
if n-1-a[0] >= 0:
    po[n-1-a[0]] = 1
ans = 0
for i in range(1,n):
    ppo = n-1-i + a[i]
    if ppo > 5*(10**5):
        if n-i-1 - a[i] >= 0:
            po[n-i-1 - a[i]] += 1
        continue
    if ppo >= 0:
        ans += po[ppo]
    if n-i-1 - a[i] >= 0:
        po[n-i-1 - a[i]] += 1
print(ans)







Measured memory_bytes: 124968
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

void solve()
{
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+')
	{
		cout << A + B << endl;
	}
	else if (op == '-')
	{
		cout << A - B << endl;
	}
}

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

Measured memory_bytes: 256
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
V = [-1]*N
W = [-1]*N
x = 0
V[0] = 0
W[0] = 0
for i in range(1, K+1):
    x = A[x] - 1
    W[i] = x
    if V[x] == -1:
        V[x] = i
    else:
        x = W[V[x] + (K-i) % (i -V[x])]
        break
print(x+1)

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

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) b[i] = a[i];
    sort(a.begin(),a.end(),greater<int>());
    rep(i,n){
        if(b[i]==a[0]) cout << a[1] << endl;
        else cout << a[0] << endl;
    }
}

Measured memory_bytes: 3200
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println("ABC"*readline())
end
main()

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

#define INF 1 << 28
#define SQUARE(n) ((n)*(n))
typedef long INT;
typedef vector <int> VI;
typedef vector <VI> VVI;

int main( void )
{
	int n, m; // N: üÍM, M: R[hubNÌ·³
	while ( cin >> n >> m && n && m )
	{
		// üÍ
		VI C(m);
		for ( int i = 0; i < m; i++ )
		{
			cin >> C[i];
		}
		VI x(n);
		for ( int i = 0; i < n; i++ )
		{
			cin >> x[i];
		}

		VVI  dp = VVI( n+1, VI( 256, INF ) );
		dp[0][128] = 0;

		for ( int k = 1; k <= n; k++ )
		{
			for ( int i = 0; i < 256; i++ )
			{
				for ( int j = 0; j < m; j++ )
				{
					int next = i + C[j];
					next = next < 0 ? 0 : next;
					next = next > 255 ? 255 : next;
					dp[k][next] = min( dp[k][next], dp[k-1][i] + SQUARE( next - x[k-1] ) );
				}
			}
		}

		int answer = INF;
		for ( int i = 0; i < 256; i++ ) answer = min( answer, dp[n][i] );
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 20000
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
    sort(a,a+5);
    int k;
    cin>>k;
    if(a[4]-a[0]>k)
        cout<<":(";
    else
        cout<<"Yay!";

}

Measured memory_bytes: 256
import collections
L = [input() for x in range(int(input()))]
L = collections.Counter(L)
LMC = L.most_common()
max_N = L.most_common()[0][1]
R = []
for x in LMC:
    if x[1] == max_N:
        R.append(x[0])
R.sort()
print("\n".join(R))

Measured memory_bytes: 57812
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()
tmp = [0]*40
for a in A:  # tmpに各ビット毎の1の出現回数を保存
    for i in range(40):
        if a&(1<<i):
            tmp[i]+=1
# print(tmp)
a = 0  # K をこえないように管理する
for i in range(39,-1,-1):
	if a + (1<<i) <= K and tmp[i] < (N+1)//2:
		a += (1<<i)

# print(tmp2)

ans = 0
for i in A:
	ans += i^a
print(ans)


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


int main(){
	
	string S;
	cin>>S;
	int len, count=0, max=0, key=0;
	
	len = S.length();

	for(int i=0; i<len; i++){
		if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T' ){
			key = 1;
			count++;
		}
		if(key==1 && !(S[i+1]=='A' || S[i+1]=='C' || S[i+1]=='G' || S[i+1]=='T')){
			key = 0;
			if(max < count)
				max = count;
			count = 0;
		
		}
	}
	cout << max;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin());  // 先頭文字削除
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    vector<ll> c(N);
    rep(i, N - 1) {
        ll a;
        cin >> a;
        c[a - 1]++;
    }
    rep(i, N) { COUT(c[i]); }
    return 0;
}

Measured memory_bytes: 4820
def main():
    n,x,y = map(int,input().split())
    ans = [0 for i in range(n+1)]
    Map = [[0 for j in range(n+1)] for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,n+1):
            if j>i:
                dis = min(j-i,abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))
                ans[dis] +=1
    
    for i in range(1,n):
        print(ans[i])
main()

Measured memory_bytes: 41536
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());
            args = reader.readLine().split(" ");
            int[] D = new int[N];
            for (int i = 0; i < N; i++) {
                D[i] = Integer.parseInt(args[i]);
            }

            long sum = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    sum += D[i] * D[j];
                }
            }

            System.out.println(sum);
        }
    }

}


Measured memory_bytes: 23252
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

std::pair<int,int> Solve(int b){
  int front=1,back=1;
  int cost=1;
  while(1){
    if(cost==b){
      return std::make_pair(front,back-front+1);
    }else if(cost<b){
      back++;
      cost+=back;
    }else{
      cost-=front;
      front++;
    }
  }
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while(1){
    int b;
    cin>>b;
    if(b==0) break;
    std::pair<int,int> result=Solve(b);
    cout<<result.first<<" "<<result.second<<endl;
  }

  return 0;
}





Measured memory_bytes: 3152
#include<iostream>
#include<cstring>
#include<cstdio>
#define max_n 100001
using namespace std;
struct edge{
	int u,v,w,next;
}e[max_n*2];
int g[max_n];
int n;
bool vis[max_n];
int dp[max_n][3];
int dfs(int u){
	vis[u]=true;
	for(int i=g[u];i>0;i=e[i].next){
		int v=e[i].v,w=e[i].w;
		if(!vis[v]){
			int now=dfs(v)+w;
			if(now>dp[u][1]){
				dp[u][2]=dp[u][1];
				dp[u][1]=now;
			}else{
				if(now>dp[u][2])
					dp[u][2]=now;
			}
		}
	}
	
	return max(dp[u][1],dp[u][2]);
}
int main(){
	scanf("%d",&n);
	int x,y,w;
	for(int i=1;i<n;i++){
		scanf("%d%d%d",&x,&y,&w);
		e[i*2-1]=(edge){x,y,w,g[x]}; g[x]=i*2-1;
		e[i*2]=(edge){y,x,w,g[y]}; g[y]=i*2;
	}
	memset(vis,0,sizeof(vis));
	dfs(0);
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dp[i][1]+dp[i][2]);
	}
	printf("%d\n",ans);
	return 0;
}	

Measured memory_bytes: 12664
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 998244353
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	fast
//	ll a,b,c,d,n,k,p;
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	ll a[m];
	forn(i,m){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)	cout<<-1;
	else	cout<<n-sum;
}
//cout<<"Case #"<<x<<": "<<ans<<endl;
//x++;

Measured memory_bytes: 3676
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        String ans="",acl="ACL";
        for(int i=0;i<n;i++)    ans+=acl;
        System.out.println(ans);
    }
}

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

int main() {
	int n, k, m;
	while (cin >> n >> k >> m, n) {
		vector<int> v(n);
		iota(begin(v), end(v), 1);
		int i = m - 1;
		while (v.size() > 1) {
			v.erase(begin(v) + i);
			i = (i + k - 1) % v.size();
		}
		cout << v[0] << endl;
	};
	return 0;
}

Measured memory_bytes: 3092
n = int(input())
if n == 0:
  print('0')
else:
  s = ''
  while n != 0:
    if -(n % 2) == 0:
      s = '0' + s
    else:
      s = '1' + s
    n = -(n // 2)
  s.lstrip('0')
  print(s)


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

int main(){
    string s; cin >> s;
    int q; cin >> q;
    int t[q], f[q], flag = 1;
    string c[q], top="";
    for(int i=0; i<q; i++){
        cin >> t[i];
        if(t[i] == 1) continue;
        cin >> f[i] >> c[i];
        if(f[i] == 2) f[i] = -1;
    }
    for(int i=0; i<q; i++){
        if(t[i] == 1){
            flag *= -1;
        }else{
            if(flag * f[i] == 1) top.append(c[i]);
            else s.append(c[i]);
        }
    }
    reverse(top.begin(), top.end());
    top.append(s);
    if(flag == -1) reverse(top.begin(), top.end());
    cout << top << endl;
    return 0;
}

Measured memory_bytes: 13664
#include<iostream>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	if(x==2 || y==2)cout<<"No";
	else if((x-4 && x-6 && x-9 && x-11)==(y-4 && y-6 && y-9 && y-11))cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x,y,h = [0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i] = map(int,input().split())
for a in range(101):
  for b in range(101):
    p = -1
    q = 2000000000
    f = 0
    for i in range(n):
      t = h[i] + abs(x[i]-a) + abs(y[i]-b)
      if h[i]>0:
        if p == -1:
          p = t
        elif not p == t:
          f = 1
          break         
      else:
        q = min(q,t)
    if f == 0 and p<=q:
      print(a,b,p)
      exit()

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for(int i = 0;i < m;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n) {
        cout << -1 << endl;
        return 0;
    }
    cout << n - sum << endl;
    return 0;

}

Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
  int a, b, c;
  int i, count = 0;
  scanf("%d%d%d", &a, &b, &c);
  for (i = a; i <= b; i++)
  {
    if (c % i == 0)
    {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define int long long
using namespace std;

vector<int>v;
int32_t main()
{
    int n,k; cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        int p; cin >> p;
        v.push_back(p);
    }
	int sm = 0;
	for(int i=0;i<k;i++)
    {
        sm+=v[i];
    }
    int q = sm;
    for(int i=0,j=k;j<n;i++,j++)
    {
        q+=v[j];
        q-=v[i];
        sm = max(sm,q);
    }
    int l = ((k-1)*k)/2;
    int r = (sm*(sm+1))/2;
    double t = (double)(r-l);
    double d = (double)(sm-k+1);
    //cout << t << " * " << d << endl;
    double ans = t/d;
    cout << fixed << setprecision(12);
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 3444
use itertools_num::ItertoolsNum as _;
use proconio::input;
use proconio::marker::Chars;

#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        q: usize,
        s: Chars,
        lr: [(usize,usize);q],
    }
    let mut v = Vec::new();
    if s[0] == 'A' && s[1] == 'C' {
        v.push(1);
    } else {
        v.push(0);
    }
    for i in 1..n {
        if s[i - 1] == 'A' && s[i] == 'C' {
            v.push(1);
        } else {
            v.push(0);
        }
    }
    let cumsum = v.iter().cumsum().collect::<Vec<u32>>();
    //println!("{:?}", cumsum);
    for i in lr.iter() {
        println!("{}", cumsum[i.1 - 1] - cumsum[i.0 - 1]);
    }
}


Measured memory_bytes: 6140
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n, m, l, i, j, k;
            long subTotal = 0;
            long total = 0;

            //整数受け取り
            string[] str1 = Console.ReadLine().Split(' ');
            n = int.Parse(str1[0]);
            m = int.Parse(str1[1]);
            l = int.Parse(str1[2]);


            //2次元配列数値受け取り(n * m)
            int[,] array1 = new int[n, m];

            for (i = 0; i < n; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');

                for (j = 0; j < m; j++)
                {
                    array1[i, j] = int.Parse(str2[j]);        
                }
            }

            //2次元配列数値受け取り(m * l)
            int[,] array2 = new int[m, l];
            

            for (i = 0; i < m; i++)
            {
                string[] str3 = Console.ReadLine().Split(' ');

                for (j = 0; j < l; j++)
                {   
                    array2[i, j] = int.Parse(str3[j]);
                }
            }

            //計算&出力
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < l; j++)
                {
                    for (k = 0; k < m; k++)
                    {
                        subTotal = array1[i, k] * array2[k, j];
                        total += subTotal;
                        subTotal = 0;
                    }
                    Console.Write(total);
                    total = 0;

                    if (j < l - 1)
                    {
                        Console.Write(" ");
                    }
                    

                }
                Console.WriteLine("");
            }
        }
    }



Measured memory_bytes: 9400
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N; cin >> N;
    ll m = LNF;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            ll tmp=i+N/i-2;
            if(m>tmp) m= tmp;
        }
    }
    cout << m << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    h, w = LI()
    x = h & 1 and w & 1
    a = SR(h)
    d = defaultdict(int)
    for i in range(h):
        for j in range(w):
            d[a[i][j]] += 1
    one = 0
    two = 0
    for i in d.values():
        one += i & 1
        two += (i >> 1) & 1
    if x:
        if one == 1:
            if h + w - 2 >= two << 1:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        if one:
            print("No")
        else:
            x = (h & 1) * (w >> 1) + (w & 1) * (h >> 1)
            if x:
                if x >= two:
                    print("Yes")
                else:
                    print("No")
            else:
                if two:
                    print("No")
                else:
                    print("Yes")

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39536
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
np_a=np.array(a)
np_at=np_a.T
at=np_at.tolist()

r=[]
c=[]

for i in range(h):
    if a[i].count('#')==0:
        r.append(i)
for i in range(w):
    if at[i].count('#')==0:
        c.append(i)

for i in range(len(r)):
    del a[r[i]-i]
for j in range(len(c)):
    for i in range(h-len(r)):
        del a[i][c[j]-j]

for i in range(h-len(r)):
    print(''.join(a[i]))

Measured memory_bytes: 12644
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007
#define Pi 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define IN(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printPI(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<VI>
#define vvl vector<VL>
#define vvvi vector<VVI>
#define vvvl vector<VVL>
#define vpi vector<PI>
#define vpl vector<PL>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
#define dbg(x, y) cout << x << " = " << y << endl

//namespace
using namespace std;

//const
const int Ntest = 1e5 + 5;

//useful function
ll gcd(ll a, ll b) {ll temp; while (b > 0) {temp = a % b; a = b; b = temp;} return a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll fpow(ll  b, ll exp, ll mod) {if (exp == 0) return 1; ll t = fpow(b, exp / 2, mod); if (exp & 1) return t * t % mod * b % mod; return t * t % mod;}
ll divmod(ll i, ll j, ll mod) {i %= mod, j %= mod; return i * fpow(j, mod - 2, mod) % mod;}
// --clock function
clock_t time_p = clock();
void TimeTaken()
{
	time_p = clock() - time_p;
	cerr << "Completion time : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}


void sol() {
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << 'A';
	}
	else {
		cout << 'a';
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--)
		sol();

	return 0;
}

Measured memory_bytes: 3652
def func(S, num):
    ret = 0
    if '3' in S and '5' in S and '7' in S and int(S) <= num:
        ret += 1
    if len(S) == 10:
        return 0
    ret += func(S + '3', num)
    ret += func(S + '5', num)
    ret += func(S + '7', num)
    return ret

print func('', input())

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int st = (n % 2) + 1;
	if (n % 2 && a[0] != 0) {cout << 0; return 0;}
	int i = (n % 2);
	for (; i < n; i += 2, st += 2) {
		if (a[i] != st || a[i+1] != st) {cout << 0; return 0;}
	}
	ll ans = 1;
	ll M = 1e9 + 7;
	for (i = 0; i < n/2; i++) {
		ans *= 2;
		ans %= M;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
const int maxn = 200010;

char s[maxn];
int n, flag;

int main () {
	scanf ("%s", s);
	n = strlen(s);
	if (s[0] == s[n-1]) {
        if (n&1) flag = true;
	} else {
		if(n&1);
		else flag = true;
	}

	if (flag) puts ("Second");
	else puts ("First");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int A[1000005], G[105], n, cnt, cur, an = 1;

void insertion_sort(int g) {
	for (int i = g; i < n; ++i) {
		int j = i - g, t = A[i];
		for (; j >= 0 && A[j] > t; j -= g, ++cnt) {
			A[j + g] = A[j];
		}
		A[j + g] = t;
	}
}

void shell_sort() {
	for (int i = cur; i > 0; --i)
		insertion_sort(G[i]);
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &A[i]);
	while (an <= n) {
		G[++cur] = an;
		an = an * 3 + 1;
	}
	printf("%d\n", cur);
	for (int i = cur; i > 0; --i)
		printf("%d ", G[i]);
	printf("\n");
	shell_sort();
	printf("%d\n", cnt);
	for (int i = 0; i < n; ++i)
		printf("%d\n", A[i]);
}


Measured memory_bytes: 6520
unittest
{
	assert( [ "100", "1" ].solve == 19 );
	assert( [ "25", "2" ].solve == 14 );
	assert( [ "314159", "2" ].solve == 937 );
	assert( [ "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", "3" ].solve == 117879300 );
	
	assert( [ "99", "3" ].solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.map!( ( a ) => ( a - '0' ).to!( long ) ).array;
	input.popFront;
	auto k = input.front.to!( long );
	
	// dp[ i桁目 ][ i桁目までのゼロ以外の個数 ][ n未満フラグ ] = パターン数
	auto dp = new long[][][]( n.length, 1 + k, 2 );
	dp[ 0 ][ 0 ][ 1 ] = 1;
	dp[ 0 ][ 1 ][ 0 ] = 1;
	dp[ 0 ][ 1 ][ 1 ] = n[ 0 ] - 1;
	foreach( i, d; n[ 1 .. $ ] )
	{
		foreach( j; 0L .. dp[ i ].length.signed )
		{
			// 同値⇒同値
			auto jj = j + ( 0 < d );
			if( jj < dp[ i ].length ) dp[ i + 1 ][ jj ][ 0 ] += dp[ i ][ j ][ 0 ];
			
			// 同値⇒未満
			if( 0 < d )
			{
				dp[ i + 1 ][ j ][ 1 ] += dp[ i ][ j ][ 0 ];														// 0
				if( j + 1 < dp[ i ].length ) dp[ i + 1 ][ j + 1 ][ 1 ] += dp[ i ][ j ][ 0 ] * ( d - 1 );		// [1,d)
			}
			
			// 未満⇒未満
			dp[ i + 1 ][ j ][ 1 ] += dp[ i ][ j ][ 1 ];												// 0
			if( j + 1 < dp[ i ].length ) dp[ i + 1 ][ j + 1 ][ 1 ] += dp[ i ][ j ][ 1 ] * 9;		// [1,10)
		}
	}
	return dp[ $ - 1 ][ $ - 1 ].sum;
}


Measured memory_bytes: 2776
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
using namespace std;
const int maxn=1010;
int n,m,vis[maxn][maxn],flag,sum,ans;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
char ch[maxn][maxn];
struct node{
	int x,y,step;
};
queue<node>qu;
bool check(int x,int y){
	if(x>=0&&x<n&&y>=0&&y<m)
		return 1;
	return 0;
}
void bfs1(int x,int y){
	node no,po;
	no.x=x;no.y=y;no.step=0;
	vis[x][y]=1;
	qu.push(no);
	while(!qu.empty()){
		no=qu.front();
		qu.pop();
		//printf("%d %d %d\n",no.x,no.y,no.step);
		//printf("%d %d\n",po.x,po.y);
		if(no.x==n-1&&no.y==m-1){
			ans=no.step;
			return ;
		}
		for(int i=0;i<4;i++){
			int xx=dx[i]+no.x;
			int yy=dy[i]+no.y;
			if(check(xx,yy)&&vis[xx][yy]==0&&ch[xx][yy]!='#'){
				vis[xx][yy]=1;
				po.x=xx;
				po.y=yy;
				po.step=no.step+1;
				qu.push(po);
			}
		}
	}
}
int main(){
	int i,j;
	memset(vis,0,sizeof(vis));
	flag=1;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",ch[i]);
	}
	sum=0;
	ans=-1;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)
			if(ch[i][j]=='.')
				sum++;
	}
	if(ch[0][0]=='#'){
		printf("-1\n");
		return 0;
	}
	bfs1(0,0);
	if(ans==-1){
		printf("-1\n");
		return 0;
	}
	printf("%d\n",sum-ans-1);
	return 0;
} 

Measured memory_bytes: 4224
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	void reverse(vector<T>& v){
		reverse(all(v));
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	template<typename T>
	inline set<T>& operator+=(set<T>& v, const T& e){
		v.insert(e);
		return v;
	}

	template<typename T1, typename T2>
	inline set<T1>& operator+=(set<T1>& v1, const set<T2>& v2){
		for(const auto& e : v2) v1.insert(e);
		return v1;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);
	
	int N,M;
	cin>>N>>M;

	int H[N+1];
	for(int i=1;i<=N;i++) cin>>H[i];

	boolv nogood(N);

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

		if(H[a] <= H[b]){
			nogood[a-1] = true;
		}
		if(H[a] >= H[b]){
			nogood[b-1] = true;
		}
	}
	
	int ans=0;
	for(auto b : nogood) if(!b)ans++;
	cout<<ans;
}


Measured memory_bytes: 4000