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

using namespace std;
using namespace atcoder;

//素因数分解(関数ver)
map<int64_t,int64_t> prime_fact(int64_t n){
  int64_t a = 2;
  map<int64_t,int64_t> mp;
  while(n >= a*a){
    if(n %a == 0){
      if(mp.count(a)){
        mp[a]++;
      }
      else{
        mp[a] = 1;
      }
      n /= a;
    }
    else{
      a++;
    }
  }
  if(mp.count(n)){
    mp[n]++;
  }
  else{
    mp[n] = 1;
  }
  return mp;
}

//bit全探索改
vector<string> bit_all_search(int n){
  vector<string> use(0);
  queue<string> Q;
  Q.push("");
  while(Q.size()){
    string S = Q.front();
    Q.pop();
    string T = S;
    T += '0';
    if(T.size() == n){
      use.push_back(T);
    }
    else{
      Q.push(T);
    }
    T = S;
    T += '1';
    if(T.size() == n){
      use.push_back(T);
    }
    else{
      Q.push(T);
    }
  }
  return use;
}

int64_t extGCD(int64_t a, int64_t b, int64_t &x, int64_t &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int64_t d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}

int main(){
  int64_t N;
  cin >> N;
  
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  if(N == 2){
    cout << 3 << endl;
    return 0;
  }
  
  //Nを素因数分解しよう
  map<int64_t, int64_t> M = prime_fact(N);
  M[2]++;
  int m = M.size();
  vector<string> vec = bit_all_search(m);
  
  
  //拡張ユークリッドの利用
  //ax * by = Mz で、　ax - by = 1であれば良い。
  
  int64_t ans = N-1;
  
  for(int i=0; i<vec.size(); i++){
    int64_t a = 1;
    int64_t b = 1;
    string T = vec[i];
    int cnt = 0;
    for(auto itr = M.begin(); itr != M.end(); itr++){
      if(T[cnt] == '0'){
        a *= pow(itr->first, itr->second);
      }
      else{
        b *= pow(itr->first, itr->second);
      }
      cnt++;
    }
    int64_t x, y;
    extGCD(a,-b,x,y);
    //cout << a << " " << b << " " << x << " " << y << endl;
    if(x > 0 && y > 0){
      if(x*a - y*b == 1){
        ans = min(ans,y*b);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 4212
#include <iostream>

using namespace std;

int main()
{
    int a1, a2 ,a3;
    int sum;

    cin >> a1 >> a2 >> a3;
    sum = a1 + a2 + a3;
    if (sum >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# C - Skill Up
N,M,X = map(int,input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))
ans = 10**9
for x in range(1,1<<N):
    C = [0]*M
    cost = 0
    for i in range(N):
        if x>>i&1==1:
            for j in range(M):
                C[j] += A[i][j+1]
            cost += A[i][0]
    if all([c>=X for c in C]):
        ans = min(ans,cost)
if ans==10**9:
    ans = -1
print(ans)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
string S;
int main() {
  cin >> S;
    
    if (S == "SUN") cout << 7 << endl;
  else if (S == "MON") cout << 6 << endl;
  else if (S == "TUE") cout << 5 << endl;
  else if (S == "WED") cout << 4 << endl;
  else if (S == "THU") cout << 3 << endl;
  else if (S == "FRI") cout << 2 << endl;
  else if (S == "SAT") cout << 1 << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int time;
  int h, m, s;

  scanf("%d", &time);

  h = time / 3600;
  m = (time - h*3600) / 60;
  s = time - h*3600 - m*60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
N = int(input())
T, A = map(int, input().split())
Hlist = list(map(int, input().split()))
sbn = 10**9 + 7
for i in range(N):
    temp = T - Hlist[i]*0.006
    nowsbn = abs(A - temp)
    if nowsbn < sbn:
        ans = i + 1
        sbn = nowsbn
print(ans)

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

using namespace std;

void solve()
{
	double n, m, d, ans;
	cin >> n >> m >> d;
	if (d > 1e-12)
	{
		ans = 2 * (n - d) * (m - 1) / n / n;
	}
	else
	{
		ans = (m - 1) / n;
	}
	cout << fixed << setprecision(9) << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;

int N, X, Y;

int flg[10000] = {};
int f = 0;
int sum;

int min_len[2010][2010];

void set_len(int from, int to, int l)
{
	if (to <= from)
	{
		return;
	}

	if (to > N)
	{
		return;
	}

	min_len[from][to] = min(min_len[from][to], l);
}



signed main()
{
	cin >> N >> X >> Y;

	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			min_len[i][j] = INT_MAX;
		}
	}

	for (int start = 1; start <= N; start++)
	{
		for (int l = 1; l <= N - 1; l++)
		{
			if (N - start >= l)
			{
				set_len(start, start + l, l);
			}

			if (X >= start)
			{
				int dx = l - (X - start);
				if (dx > 0)
				{
					dx--;
					int y1 = Y + dx;
					set_len(start, y1, l);

					int y2 = Y - dx;
					set_len(start, y2, l);
				}
			}

			if (X < start)
			{
				int dx = l - (start - X);
				if (dx > 0)
				{
					dx--;
					int y1 = Y + dx;
					set_len(start, y1, l);

					int y2 = Y - dx;
					set_len(start, y2, l);
				}
			}
		}
	}



	int ans[2010] = {};
	for (int i = 1; i < N; i++)
	{
		for (int j = i + 1; j <= N; j++)
		{
			ans[min_len[i][j]]++;
		}
	}


	for (int i = 1; i <= N - 1; i++)
	{
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 31616
from collections import deque
p = input()
s = input()

d = deque([s for s in p])

for i in range(len(s)):
    str_d = "".join(d)
    if s in str_d:
        print("Yes")
        break
    d.append(d.popleft())
    if i == len(s) - 1:
        print("No")


Measured memory_bytes: 5972
#include<iostream>

using namespace std;

int min(int a,int b)
{
    return a<b? a:b;
}

int main()
{
    int n, a[100],t=0;

    cin>>n;

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

    t+=a[0]+a[n-2];

    for(int j=0;j<n-2;j++){
        t+=min(a[j],a[j+1]);
    }
    cout<<t;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll arr[501];
ll dp[501][501];
ll prefix[501];
ll solve(int l, int r){
    if(l == r) return 0;
    if(dp[l][r] != -1) return dp[l][r];
    ll mina = 1e18;
    for(int x=1;x<=r-l;x++){
        ll pre = prefix[l+x-1] -  prefix[l-1];
        ll suf = prefix[r] - prefix[l+x-1];
        mina = min(mina, pre + suf + solve(l, l+x-1) + solve(l+x, r));
    }
    return dp[l][r] = mina;
}
int main(){
    memset(dp, -1, sizeof dp);
    cin>>n;
    for(int x=1;x<=n;x++){
        cin>>arr[x];
        prefix[x] += arr[x] + prefix[x-1];
    }
    cout<<solve(1, n);


}


Measured memory_bytes: 5584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, a;
    std::cin>>n>>a;

    std::cout<<(n * n - a)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=4e6+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
ll f[maxn];
inline ll binpow(ll a,ll n) {
	ll res=1;
	while(n>=1){
		if(n & 1ll){
            res=res*a%mod;
		}
		a=a*a%mod;
		n>>=1ll;
	}
	return res;
}
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    f[0]=1;
    f[1]=1;
    for(int i=2;i<=maxn-100;i++){
        f[i]=f[i-1]*i%mod;
    }
    ll x,y;
    cin>>x>>y;
    if((x+y)%3!=0) {
    	cout<<"0";
    	return 0;
    }
    ll n=(x+y)/3;
    ll k=(x-y+n)/2;
    if(n<0 || k<0 || (n-k)<0){
    	cout<<"0";
    	return 0;
    }
	cout<<(((f[n]*binpow(f[k],mod-2))%mod)*binpow(f[n-k],mod-2))%mod;
	exit(0);
}


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

int main() {
  int x, n;
  cin >> x >> n;
  bool p[100];
  rep(i, 100) p[i] = true;
  rep(i, n) {
    int t;
    cin >> t;
    p[t - 1] = false;
  }
  x--;
  int m = -100;
  for (int id = 0; id < 100; id++) {
    if (x - id >= 0 && p[x - id]) {
      m = x - id;
      break;
    }
    if (x + id < 100 && p[x + id]) {
      m = x + id;
      break;
    }
  }
  //if ((m == INT_MIN && x <= 49) || m - x == x + 1) m = -1;
  //if (m == INT_MIN && x > 49) m = 100;
  if (abs(m - x) >= x + 1)
    m = -1;
  if (abs(m - x) > 100 - x)
    m = 100;
  cout << m + 1 << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n, k;
	bool flag[100001];
	while(cin >> n >> k, n || k)
	{
		fill(flag, flag + n + 1, false);
		int temp;
		bool blank_flag = false;
		for(int i = 0; i < k; ++i)
		{
			cin >> temp;
			if(temp == 0)
			{
				blank_flag = true;
			}
			else
			{
				flag[temp] = true;
			}
		}
		if(k == 1)
		{
			cout << 1 << endl;
			continue;
		}
		
		if(!blank_flag)
		{
			vector<int> Dp(n + 1);
			Dp[0] = 0;
			int count = 0;
			for(int i = 1; i <= n; ++i)
			{
				if(flag[i] == true)
				{
					++count;
					Dp[i] = max(Dp[i - 1], count);
				}
				else
				{
					Dp[i] = Dp[i - 1];
					count = 0;
				}
			}
			cout << Dp[n] << endl;
		}
		else
		{
			vector< vector<int> > Dp(2, vector<int>(n + 1));
			Dp[0][0] = Dp[1][0] = 0;
			int count = 0;
			bool used = false;
			int pos = 99999999;
			for(int i = 1; i <= n; ++i)
			{
				if(flag[i] == true && used == false)
				{
					++count;
					Dp[0][i] = max(Dp[0][i - 1], count);
				}
				else if(flag[i] == true && used == true)
				{
					++count;
					Dp[1][i] = max(Dp[1][i - 1], count);
				}
				else if(flag[i] == false && used == false)
				{
					used = true;
					pos = i;
					++count;
					Dp[1][i] = max(Dp[0][i - 1], count);
				}
				else if(flag[i] == false && used == true)
				{
					count = i - pos;
					Dp[1][i] = max(Dp[1][i - 1], count);
					pos = i;
				}
			}
			cout << max(Dp[0][n], Dp[1][n]) << endl;
		}
	}
}

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

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

int main() {
  int n, m;
  cin >> n >> m;
  bool ng = false;
  map<int, int> s_c;
  for(int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    map<int, int>::iterator it = s_c.find(s);
    if(it == s_c.end()) s_c[s] = c;
    else if(it->second != c) ng = true;
    if((n>1) && (s==1) && (c==0)) ng = true;
  }

  if(ng) {
      cout << -1 << endl;
      return 0;
  }

  char ans[n+1] = {'\0'};
  for(int s = 1; s <= n; ++s) {
      map<int, int>::iterator it = s_c.find(s);
      if(it == s_c.end()) ans[s-1] = ((s==1) && (n!=1) ? '1' : '0');
      else ans[s-1] = '0' + it->second;
  }

  cout << stoi(ans) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < (int)n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int M = 3e5 + 1;
const int N = 310;

ll a[N][N];

bool used[N];

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n)
        fr(j, n) {
            cin >> a[i][j];
            if (i == j)
                a[i][j] = INF;
        }

    fr(k, n)
        fr(i, n)
            fr(j, n) if (i != j && i != k && j != k)
                if (a[i][j] > a[i][k] + a[k][j]) {
                    cout << -1;
                    return 0;
                }


    fr(k, n)
        fr(i, n)
            fr(j, n) if (i != j && i != k && j != k)
                if (a[i][j] == a[i][k] + a[k][j])
                    a[i][j] = INF;

    ll sum = 0;
    fr(i, n)
        frab(j, i + 1, n)
            if (a[i][j] != INF)
                sum += a[i][j];

    cout << sum;
}


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

int BSearch(int x,int A[],int N){
  int left=0;
  int right=N;

  while(left<right){
    int mid=(left+right)/2;

    if(A[mid]==x){
      return mid;
    }else if(x<A[mid]){
      right=mid;
    }else{
      left=mid+1;
    }
  }
  return -1;
}

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

  int q;
  cin >> q;
  int T[q];
  for(int i=0;i<q;i++){
    cin >> T[i];
  }

  int ans=0;

  for(int i=0;i<q;i++){
    if(BSearch(T[i],S,n)!=-1){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    i64 n,k,ans=0;
    cin>>n>>k;
    for(i64 i=0;i<n;i++){
        i64 a;
        cin>>a;
        if(a>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  int ans = (1000 - n % 1000) % 1000;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int s,w;

void solve(){
    cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3608
N, Q = map(int, input().split())
S = input()
L = [0 for _ in range(len(S)+3)]
cnt = 0
for i in range(len(S)-1):
    if S[i] + S[i+1] == "AC":
        cnt += 1
    L[i] = cnt
L = [0] +L
#print(L)
for _ in range(Q):
    x , y = map(int, input().split())
    x -= 1
    y -= 1
    print(L[y] - L[x])


Measured memory_bytes: 6376
#include <cstdio>

int hand[3], result[5];

int main(){
	while(scanf("%d", &result[0]),result[0]){
		bool d = 0;
		for(int i = 0; i < 3; i++) hand[i] = 0;
		for(int i = 1; i < 5; i++) scanf("%d", &result[i]);
		for(int i = 0; i < 5; i++) hand[result[i]-1]++;
		if(hand[0]==0&&hand[1]==0) d = 1;
		else if(hand[1]==0&&hand[2]==0) d = 1;
		else if(hand[0]==0&&hand[2]==0) d = 1;
		if((hand[0]>0&&hand[1]>0&&hand[2]>0)||d==1){
			for(int i = 0; i < 5; i++) printf("3\n");
			continue;
		}
		if(hand[0]==0){
			for(int i = 0; i < 5; i++){
				if(result[i]==2) printf("1\n");
				else printf("2\n");
			}
		} else if(hand[1] == 0){
			for(int i = 0; i < 5; i++){
				if(result[i]==3) printf("1\n");
				else printf("2\n");
			}
		} else if(hand[2] == 0){
			for(int i = 0; i < 5; i++){
				if(result[i]==1) printf("1\n");
				else printf("2\n");
			}
		}
	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

string change_to_s(int n){
    stringstream ss; string s;
    ss << n; ss >> s;
    return s;
}

signed main(){
    int n;
    cin >> n;
    string s = "", t;
    rep(i, 0, n){
        cin >> t;
        s += t;
    }
    rep(i, 0, 10000){
        string r = change_to_s(i);
        if(s.find(r) == string::npos){
            cout << r << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1232
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x,y;
    int z;
    cin>>x>>y;
     z=x*y;
    if(1<=x,y<=3){
 
      if(z%2==1 ){cout<<"Yes";}
      else
      {cout<<"No";}
                 }
    
    
    
    
    
    
    
 
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

#define INF (1e9)

vvvi G;
vector<bool> visited;
vi ans;

void dfs(int v) {
    visited[v] = true;
    for (auto nv : G[v]) {
        if (visited[nv[0]]) continue;
        if (nv[1] == 0) {
            ans[nv[0]] = ans[v];
        } else {
            ans[nv[0]] = 1 - ans[v];
        }
        dfs(nv[0]);
    }
}

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

    int N;
    cin >> N;

    G = vvvi(N, vvi(0));
    visited = vector<bool>(N);

    int u, v, w;

    for (int i = 0; i < N - 1; i++) {
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(vi{v, w % 2});
        G[v].push_back(vi{u, w % 2});
    }

    ans = vi(N);
    dfs(0);

    for (int a : ans) cout << a << "\n";
    return 0;
}


Measured memory_bytes: 18432
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

void solve(){

}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vi a(n);
    vi b(n);
    forn(i,n){
        cin >> a[i];
        b[a[i]-1] = i + 1;
    }
    for(auto i : b){
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int sum = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      sum += a;
    }
    String ans = "No";
    if(sum >= h) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 46960
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	list<int> l;
	int n, x;
	cin >> n;

	string cmd;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> x;
			l.push_front(x);
		}
		else if (cmd == "delete") {
			cin >> x;
			for (list<int>::iterator itr = l.begin(); itr != l.end(); itr++) {
				if (*itr == x) {
					l.erase(itr);
					break;
				}
			}
		}
		else if (cmd == "deleteFirst") {
			l.pop_front();
		}
		else if (cmd == "deleteLast") {
			l.pop_back();
		}
	}

	for (list<int>::iterator itr = l.begin(); itr != l.end(); itr++) {
		if (itr != l.begin()) cout << " ";
		cout << *itr;
	}
	cout << "\n";
}



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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    cout << fixed << setprecision(16);

    ll n;
    cin >> n;
    vector<pair<ll,ll>> p(n);
    for(ll i=0; i<n; i++)
        cin >> p[i].first, p[i].second = i;
    sort(p.begin(), p.end(), greater<>());

    set<ll> pos, sop;
    pos.insert(n);
    sop.insert(1);

    ll res = 0;
    for(ll i=0; i<n; i++) {
        ll t, j;
        tie(t, j) = p[i];
        ll r = *pos.upper_bound(j);
        ll rr = r == n ? n : *pos.upper_bound(r);
        ll l = -*sop.upper_bound(-j);
        ll ll = l == -1 ? -1 : -*sop.upper_bound(-l);
        res += t * ((l - ll) * (r - j) + (rr - r) * (j - l));

        pos.insert(j);
        sop.insert(-j);
    }
    cout << res << endl;
}


Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> L(n);
    for(int i=0;i<n;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end(),greater<int>());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += L[i];
    }
    cout << ans << endl;
}

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


const ll MOD = (ll)998244353;
struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
/* dp[i][j][k]: 配列をi個見て、和がjで、
右端も決まってない(0), 
右端は決まっているが左端は決まっていない(1), 
両方決まっている(2)
*/
mint dp[3010][3010][3];
int N, S;
void debug(){
    rep(k,3){
        cerr <<"["<<k << "]" << endl;
        rep(i,N+1){
            rep(j,S+1){
                cerr << dp[i][j][k] <<" ";
            }
            cerr << endl;
        }
        cerr << endl;
    }
    cerr << endl;
}
int main() {
    cin >> N >> S;
    vector<int> A(N);
    rep(i,N)cin>>A[i];
    dp[0][0][0] = 1;
    //debug();
    rep(i,N)rep(j,S+1){
        //from 0
        {
            //to 0 まだ始まってすらないよ！
            dp[i+1][j][0] += dp[i][j][0];
            //to 1 iから始めるぜ
            dp[i+1][j][1] += dp[i][j][0];
            dp[i+1][min(S+1, j+A[i])][1] += dp[i][j][0];
            //to 2 iから始めた瞬間に終わるぜ
            dp[i+1][min(S+1, j+A[i])][2] += dp[i][j][0];
        }
        //from 1
        {
            //to 1  今までのやつを反映させるぜ
            dp[i+1][j][1] += dp[i][j][1];
            //      引き続き区間を伸ばすぜ    
            dp[i+1][min(S+1, j+A[i])][1] += dp[i][j][1];
            //to 2  
            dp[i+1][j][2] += dp[i][j][1];
            //       ここで使って終わるぜ
            dp[i+1][min(S+1, j+A[i])][2] += dp[i][j][1];
        }
        //from 2
        {
            //to 2 単純に反映させるぜ
            dp[i+1][j][2] += dp[i][j][2];
        }
    }
    //debug();
    cout << dp[N][S][2] << endl;
}


Measured memory_bytes: 212608
A, B, C, X, Y = map(int, input().split())

ab = A * X + B * Y
Ab = C * X * 2 + B * (Y-X if Y > X else 0)
aB = C * Y * 2 + A * (X -Y if X > Y else 0)
print(min(ab, Ab, aB))

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))
c = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if L[i] == L[j]:
            continue
        for k in range(j + 1, N):
            if L[j] == L[k] or L[i] == L[k]:
                continue
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                c += 1

print(c)

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

int main(){
   int n;
   cin >> n;
   priority_queue<pair<int,int>> pq;
   int input;
   for(int i=0;i<n;i++){
       cin >> input;
       pq.push(make_pair(-input,i+1));
   }
   int a,b;
   pair<int,int> output;
   for(int i=0;i<n;i++){
    output = pq.top();
    pq.pop();
    tie(a,b)= output;
    cout << b << " ";
   }

}

Measured memory_bytes: 1780
#include <stdio.h>

int main(void)
{
	int a, b, c, 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: 596
def cut(S,H,W,K):
    cnt,h = 0,0
    OP = [[0 for _ in range(W)] for _ in range(H)]

    while "#" not in S[h]:
        h += 1

    burst = False
    for i in range(h,H):
        if "#" not in S[i]:
            OP[i] = [OP[i-1][j] for j in range(W)]
            burst = False
        else:
            cnt += 1
            cnt_h = 1
            for j in range(W):
                OP[i][j] = cnt
                if S[i][j] == "#" and cnt_h < S[i].count("#"):
                    cnt += 1
                    cnt_h += 1

    for i in reversed(range(h)):
        for j in range(W):
            OP[i][j] = OP[i+1][j]
    
    for i in range(H):
        OP[i] = " ".join(map(str,OP[i]))

    return OP

def main():
    H,W,K = map(int,input().split())
    S = [input() for _ in range(H)]

    ans = cut(S,H,W,K)

    for i in range(H):
        print(ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  int l=1, r=100000;
  for(int i=0; i<m; i++) {
	int a,b;
    cin >> a >> b;
    l=max(a,l); r=min(b,r);
  }
  cout << max(0, r-l+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int n; 
 cin >> n;
 string s ;
 cin >> s ;
 ll kaisuu = 0;
 rep2(i,1,n-1) if(s[i]=='E') kaisuu ++ ;
 ll ans= kaisuu ;
 rep(i,n-1){
   if(s[i]=='E'&&s[i+1]=='E')
   kaisuu--;
   if(s[i]=='W'&& s[i+1]=='W')
   kaisuu ++ ;
   ans=min(ans,kaisuu) ;
 } 
 cout <<ans<<endl ;
     return 0;
}


Measured memory_bytes: 900
char s[65536],t[65536];
int n,i,r,w,c,a;
int main()
{
	while(scanf("%d",&n),n){
		scanf("%s",s);
		for(i=0;i<n;++i){
			r=w=0;
			while(r<strlen(s)){
				a=s[r];
				for(c=0;s[r+c]==a;++c);
				sprintf(t+w,"%d\0",c);
				while(t[++w]);
				t[w++]=a;
				r+=c;
			}
			t[w]=0;
			strcpy(s,t);
		}
		puts(s);
	}
	exit(0);
}

Measured memory_bytes: 500
import java.util.*;

// Iroha's Strings
public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // String params = scanner.nextLine();
        int numStrings = scanner.nextInt();
        int stringLen = scanner.nextInt(); 
        scanner.nextLine();
        // scanner.next() reads up until \n it won't consume it. You need next Line to pusition the 
        // System.out.println(scanner.nextLine()); // handle of first line \n that is

        List<String> strings = new ArrayList<>();
        for (int i=0; i<numStrings; i++) {
            String curr = scanner.nextLine();
            // System.out.println("curr" + curr);
            strings.add(curr);
        }
        // I have the strings now simply sort them and concatenate
        Collections.sort(strings);
        StringBuilder sb = new StringBuilder();
        for (String s : strings) {
            // System.out.printf("String:%s, numStrings:%d, stringLen:%d %n", s, numStrings, stringLen);
            sb.append(s);
        }                       
        scanner.close();            
        System.out.println(sb.toString());
    }
    
}

Measured memory_bytes: 36160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n,k; cin >> n >> k;
    int x[n]; inarray(x,n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += min(2*x[i], 2*(abs(k-x[i])));
    }
    cout << sum << endl;
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ", "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


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

	int n; ll m;
	cin >>n >>m;
	VL a(n), sm(n+1);
	rep(i, n) cin >>a[i];
	sort(all(a));
	partial_sum(all(a), sm.begin()+1);
	for(auto x :sm) cerr<<x<<" "; cerr<<"\n";
	auto f =[&](ll mid) ->ll{
		ll rt =0;
		rep(i, n){
			int ps = lower_bound(all(a), mid - a[i]) - a.begin();
			rt += n - ps;
		}
		return rt;
	};

	ll lo=0, hi=200001; 
	while(hi - lo >1){
		ll mid = (hi + lo) >> 1;
		if( f(mid) >= m){ lo = mid;}else hi = mid; 
	}
	ll zsm = f(lo);
	//dbg(lo,  zsm, "lo&zsm");
	
	ll ans = 0;
	rep(i, n){
		int ps = lower_bound(all(a), lo - a[i]) - a.begin();

		ans += a[i] * (n - ps);
		ans += sm[n] - sm[ps];
	}
	ans -= (zsm - m) * lo;
	cout << ans <<"\n";
	return 0;
}



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


def solve(L, X):
    if L == 0 and X == 1:
        return 1
    if X == 1:
        return 0
    l = 2**(L + 1) - 3
    if 2 <= X <= l + 1:
        return solve(L - 1, X - 1)
    elif X == l + 2:
        return solve(L - 1, l) + 1
    elif l + 2 <= X <= 2 * l + 2:
        return solve(L - 1, l) + solve(L - 1, X - l - 2) + 1
    else:
        return 2 * solve(L - 1, l) + 1


print(solve(N, X))


Measured memory_bytes: 3064
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

// 問題概要: 品物が N 個ある。i 番目の品物の種類は t で、価値は d である。品物を K 個選んだ。選ばれた品物の種類数を x とし、価値の総和を s とするとき、スコア (s + x^2) の値が (選びかたの中で) 最大だった。この最大スコアを求めよ。

fn main() {
    let (N, K) = read!(usize, usize);
    let T = read![usize, i64; N];

    let mut T = T.into_iter().map(|(t, d)| (d, t - 1)).collect::<Vec<_>>();
    T.sort();
    T.reverse();

    debug!(T);

    let mut s = 0_i64;
    let mut x = 0_i64;
    let mut Q = vec![];

    // done[t] = true : 種類 t の品物を選んでいる
    let mut done = vec![false; N + 1];

    for i in 0..K {
        let (d, t) = T[i];

        if done[t] {
            // 同じ種類の2個目以降の品物は選ばないほうがいい可能性がある
            Q.push(d);
        } else {
            // この種類で価値が最大の品物は必ず選ぶべきなので Q には入れない
            done[t] = true;
            x += 1;
        }

        s += d;
    }

    let mut max_score = s + x * x;
    debug!(s, x, max_score);

    for i in K..N {
        let (d, t) = T[i];

        if done[t] {
            continue;
        }

        // この品物はまだ選んでいない。

        // 同じ種類の品物で2つ以上選んでいるもののうち、価値が最も低いものを選ばないことにする。
        if let Some(d) = Q.pop() {
            s -= d;
        } else {
            // 除去できる品物がないなら終了。
            break;
        }

        // この品物を選ぶ。価値の合計は減るが、種類数が増えるので、スコアが大きくなる可能性がある。
        x += 1;
        s += d;
        done[t] = true;
        let score = s + x * x;

        max_score = max(max_score, score);
        debug!(d, x, s, x * x, score, max_score);
    }

    println!("{}", max_score);
}


Measured memory_bytes: 8444
import sys
import math


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, h, m = _ia()
    ad = 30*h + .5*m
    bd = 6 * m
    dd = math.radians(ad-bd)
    return (a**2+b**2-2*a*b*math.cos(dd))**.5


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


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

int main() {
    long long n, k, res = 0;
    cin >> n >> k;
    if (k == 0)
        cout << n * n;
    else {
        for (long long i = k + 1; i <= n; i++) {
            long long d = n / i;
            long long x = n % i;
            if(x >= k) res += x - k + 1;
            res += d * (i - k);
        }
        cout << res;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;

int main(){
    int N, T, A;
    cin >> N;
    cin >> T >> A;
    int H[N];
    for(int i=0; i<N; i++) cin >> H[i];
    int index=0;
    double delta = 10000000;
    for(int i=0; i<N; i++){
        double temp = abs((T-H[i]*0.006)-A);
        if(delta>temp){
            delta = temp;
            index = i;
        }
    }
    cout << index+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;
    bool flag=true;
    if(V<W){
        flag=false;
    }
    else if(V==W){
        if(A!=B){
            flag=false;
        }
    }
    else if(abs(A-B)>T*(V-W)){
        flag=false;
    }
    if(flag){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3632
import scala.io.StdIn._

object Main extends App {


  val x = readInt()

  def solve(): Int = {
    val limit = 100010
    val primeNums = Array.fill(limit+1)(true)
    (0 to Math.sqrt(limit).toInt).foreach { i =>
      if(i == 0 || i == 1) primeNums(i) = false
      else if(primeNums(i)) {
        for(j <- i * 2 to limit by i) primeNums(j) = false
      }
    }
    (x to limit).foreach { i =>
      if(primeNums(i)) return i
    }
    0
  }

  println(solve())

}



Measured memory_bytes: 54948
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define MO 1000000007
#define LL long long
int a[MAXN],n,vis[MAXN],du[MAXN],pre[MAXN],cnt[MAXN];
LL fac[MAXN],inv[MAXN],Pow2[MAXN],P[MAXN],ans=1;
LL PowMod(LL a,int b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
LL C(int n,int m)
{
	return fac[n]*inv[m]%MO*inv[n-m]%MO;
}
void Pre()
{
	fac[0]=1;
	for(int i=1;i<MAXN;i++)
		fac[i]=fac[i-1]*i%MO;
	inv[MAXN-1]=PowMod(fac[MAXN-1],MO-2);
	for(int i=MAXN-2;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%MO;
	Pow2[0]=1;
	for(int i=1;i<MAXN;i++)
		Pow2[i]=2*Pow2[i-1]%MO;
	P[1]=1;
	for(int i=2;i<MAXN;i++)
		P[i]=P[i-1]*(2*i-1)%MO;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		du[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(du[i]>2)
		{
			printf("0\n");
			return 0;
		}
		if(du[i]<2||vis[i]) continue;
		int p=i;
		do
		{
			if(vis[p])
			{
				printf("0\n");
				return 0;
			}
			vis[p]=1,pre[a[p]]=p;p=a[p];
		}while(p!=i);
	}
	for(int i=1;i<=n;i++)
		if(!du[i])
		{
			int l1=0,l2=0,p=i;
			while(!vis[p])
			{
				vis[p]=1,p=a[p],l1++;
			}
			do
			{
				p=pre[p];l2++;
			}while(du[p]!=2);
			if(l1<l2) ans=ans*2%MO;
			else if(l1>l2)
			{
				printf("0\n");
				return 0;
			}
		}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int p=i,c=0;
			while(!vis[p])
			{
				c++;vis[p]=1;
				p=a[p];
			}
			cnt[c]++;
		}
	Pre();
	for(int i=1;i<=n;i++)
		if(cnt[i])
		{
			if((i&1)&&i!=1)
			{
				LL tmp=Pow2[cnt[i]];
				LL x=i;
				for(int j=1;2*j<=cnt[i];(x*=i)%=MO,j++)
					(tmp+=C(cnt[i],2*j)*P[j]%MO*x%MO*Pow2[cnt[i]-2*j]%MO)%=MO;
				ans*=tmp;
				ans%=MO;
			}
			else
			{
				LL tmp=1;
				LL x=i;
				for(int j=1;2*j<=cnt[i];(x*=i)%=MO,j++)
					(tmp+=C(cnt[i],2*j)*P[j]%MO*x%MO)%=MO;
				ans*=tmp;
				ans%=MO;
			}
		}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5248
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A, B = [None] * M, [None] * M
for i in range(M):
    A[i], B[i] = list(map(int, input().split()))

s = set()
for i in range(M):
    if H[A[i] - 1] - H[B[i] - 1] <= 0:
        s.add(A[i])
    if H[B[i] - 1] - H[A[i] - 1] <= 0:
        s.add(B[i])
ans = N - len(s)
print(ans)

Measured memory_bytes: 23560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin>>n;
  vector<int> e(n+1,0),w(n+1,0);
  char c;
  for(int i=0;i<n;++i){
    cin>>c;
    if(c=='W')w[i+1]=w[i]+1,e[i+1]=e[i];
    if(c=='E')e[i+1]=e[i]+1,w[i+1]=w[i];
  }

  ll m=300010,cnt;
  for(int i=1;i<n+1;++i){
    ll we=e[n]-e[i];
    ll ea=w[i-1];
    cnt=we+ea;
    m=min(m,cnt);
  }
  cout<<m;
}

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

int main() {
  int in;
  cin >> in;
  int digit3=in/100;
  int digit2=in/10-10*digit3;
  int digit1=in-100*digit3-10*digit2;
  cout << digit1+digit2+digit3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define all(a) (a.begin(),a.end())
#define fi first
#define sc second
#define ort(x,y) (x+y)/2
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d2(x,y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d3(x,y,z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define N (int) (705)
#define M (int) ()
#define inf (int) (1e7)
#define p (1000000007)
#define heap priority_queue
#define mem(a,val) memset(a,val,sizeof(a))
#define y1 asdassa
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		int ww=b+c;
		if(ww>a || (a-ww)%2)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	ll n = s.size();
	if((s[0] == s[n-1] && n%2 == 0) || (s[0] != s[n-1] && n%2 == 1)){
		print("First")
	}
	else{
		print("Second")
	}
	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

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; }

int K, N;
int A[200001];

int main() {
    cin >> K >> N;
    int max = 0;
    REP (i, N) {
        cin >> A[i];
        if (i > 0) {
            int d = A[i] - A[i - 1];
            if (d > max) {
                max = d;
            }
        }
    }
    int d = K + A[0] - A[N - 1];
    if (d > max) {
        max = d;
    }
    cout << K - max << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> p = new HashSet<>();

        int X = sc.nextInt();
        int N = sc.nextInt();
        int ans = X;
        for(int i=0;i<N;i++){
            p.add(sc.nextInt());

        }

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

            if(i % 2 == 0){
                ans = ans + i;
            } else {
                ans = ans - i;
            }

            if(p.contains(ans)){

            } else {
                break;
            }
        }

        System.out.println(ans);


    }

}


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

int main(void){
	int stack[200];
	int top = 0;

	char a[30];
	while(cin >> a){
		if(a[0] == '+'){
			int x1 = stack[--top];
			int x2 = stack[--top];
			stack[top] = x2 + x1;
			top++;
		}else if(a[0] == '-'){
			int x1 = stack[--top];
			int x2 = stack[--top];
			stack[top] = x2 - x1;
			top++;
		}else if(a[0] == '*'){
			int x1 = stack[--top];
			int x2 = stack[--top];
			stack[top] = x2 * x1;
			top++;
		}else{
			stack[top] = atoi(a);
			top++;
		}

		//puts("");
	}
	printf("%d\n", stack[0]);

	return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

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

    map<int, int> mp;
    int a;
    for(int i=0; i<n; i++){
        cin >> a;
        if(mp.count(a) == 0){
            mp[a] = 1;
        }else{
            mp[a]++;
        }
    }

    int ans = 0, dif = mp.size() - k;
    if(dif > 0){
        vector<int> v;
        for(auto itr = mp.begin(); itr != mp.end(); itr++){
            v.push_back(itr->second);
        }
        sort(v.begin(), v.end());
        for(int i=0; i<dif; i++){
            ans += v[i];
        }
    }
    cout << ans << endl;
  
    return 0;
}


Measured memory_bytes: 10748
#include <stdio.h>
int binarysearch(int*, int);

int n;

int main(){
  int i,j,q, cnt = 0;
 
  scanf("%d", &n);
  int s[n];
  for(i = 0; i < n; i ++)
    scanf("%d", &s[i]);
 
  scanf("%d", &q);
  int t[q];
  for(i = 0; i < q; i ++)
    scanf("%d", &t[i]);

  for(i = 0; i < q; i++)
    cnt += binarysearch(s, t[i]);

  printf("%d\n", cnt);
  return 0;
}

int binarysearch(int *s, int key){
  int left = 0, right = n, mid;
  while(left < right){
    mid = (left + right) / 2;
    if(s[mid] == key)
      return 1;
    else if (key < s[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program {
	static void Main(string[] args) {




		const int INPUT_COUNT = 1;
		var lstInput = new List<string>();
		for (int i = 0; i < INPUT_COUNT; i++) {
			lstInput.Add(Console.ReadLine());
		}

		Console.WriteLine("{0} {1}", lstInput[0].Substring(0, 4), lstInput[0].Substring(4));	



	
	}
}

Measured memory_bytes: 2904
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{



   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n;

      vector<pll>v;

      for(i=0; i<n; i++)
      {
          cin>>a>>b;
         v.eb(a,b);
      }

      for(i=2; i<n; i++)
      {
          if(v[i].F==v[i].S && v[i-1].F==v[i-1].S && v[i-2].F==v[i-2].S)
          {
              ans=3;
              break;
          }
      }


     if(ans>=3)cout<<"Yes"<<endl;

     else cout<<"No"<<endl;










}



Measured memory_bytes: 3652
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
sum = K ** 2
for a in range(2,K+1) :
    for b in range(1,K+1) :
        if gcd(a,b) == 1 :
            sum += K
        else :
            for c in range(1,K+1) :            
                sum += gcd(a, b, c)
            
print(sum)

Measured memory_bytes: 9632