akhauriyash/Code-Regression huggingface dataset:
def get_array(proc)
    gets.strip.split(' ').map(&proc)
end

def get_int_array
    get_array(:to_i)
end

def get_float_array
    get_array(:to_f)
end


n = gets.strip.to_i
as = get_int_array

puts as.reduce(Array.new(n, 0)){|res, a| res[a-1] += 1; res }


Measured memory_bytes: 35704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      int[] seqA = new int[nHalf];
      int[] seqB = new int[nHalf];

      Integer num;
      List<Integer> listA = new ArrayList<>();
      List<Integer> listB = new ArrayList<>();
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      int offset=0,next=0;
      char regx = ' ';
      for(int i=0, j=0; i<n; i++, j= i >> 1) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        if((i & 1) == 0) {
          seqA[j] = num;
          if(mapA.containsKey(num)) {
            mapA.replace(num, mapA.get(num) + 1);
          } else {
            mapA.put(num, 1);
            listA.add(num);
          }
        }
        else {
          seqB[j] = num;
          if(mapB.containsKey(num)) {
            mapB.replace(num, mapB.get(num) + 1);
          } else {
            mapB.put(num, 1);
            listB.add(num);
          }
        }
      }

      int vma,vmb,xa,xb;
      vma = vmb = xa = xb =0;
      for (Integer var : listA) {
        int ma = mapA.get(var);
        if(vma < ma) {
          vma = ma;
          xa = var;
        }
      }
      for (Integer var : listB) {
        int mb = mapB.get(var);
        if(vmb < mb) {
          vmb = mb;
          xb = var;
        }
      }

      int cca = nHalf - vma;
      int ccb = nHalf - vmb;

      int vma2,vmb2;
      vma2 = vmb2 = 0;
      int ans = 0;
      if(xa == xb) {
        for (Integer var : listA) {
          int ma = mapA.get(var);
          if(var != xa && vma2 < ma) {
            vma2 = ma;
          }
        }
        for (Integer var : listB) {
          int mb = mapB.get(var);
          if(var != xb && vmb2 < mb) {
            vmb2 = mb;
          }
        }
      
        int cca2 = nHalf -vma2;
        int ccb2 = nHalf -vmb2;

        ans = cca2 > ccb2 ? cca + ccb2 : cca2 + ccb;
      }
      else {
        ans = cca + ccb;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 47828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int> p;
    int N, K;
    cin >> N >> K;

    for(int i = 0; i < N; ++i){
        int price;
        cin >> price;
        p.push_back(price);
    }
    std::sort(p.begin(), p.end());
    int sum = 0;
    for(int i=0; i < K; ++i){
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = [0]+list(map(int,input().split()))
for i in range(1,N+1):
  A[i] = A[i]+A[i-1]
ans = float('inf')
for i in range(1,N):
  ans = min(ans, abs(A[N]-2*A[i]))
print(ans)

Measured memory_bytes: 30820
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// quoted from beet-aizu
template <typename T, typename E, typename F, typename G>
struct SegmentTree{
    // using F = function<T(T, T)>
    // using G = function<T(T, E)>
    int n;
    F f;
    G g;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,G g,T ti):f(f),g(g),ti(ti){}
    void init(int n_){    
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void update(int k,const E &x){
        k += n;
        dat[k] = g(dat[k], x);
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
    }
    T operator [](int k) const { return dat[k+n]; }
    T query(int a,int b) const {
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

    /* TODO わからない 聞く 
    template<typename C>
    int find(int a,int b,C &check,int k,int l,int r){
        if(!check(dat[k])||r<=a||b<=l) return -1;
        if(k>=n) return k-n;
        int m=(l+r)>>1;
        int vl=find(a,b,check,(k<<1)|0,l,m);
        if(~vl) return vl;
        return find(a,b,check,(k<<1)|1,m,r);
    }
    template<typename C>
    int find(int a,int b,C &check){
        return find(a,b,check,1,0,n);
    }*/
    
};


/**  テンプレ
int main(){
}
**/

int main() {
  
  lint n, k; cin >> n >> k;
  vector<double> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n; i++) v[i] = (v[i] + 1.0) / 2.0;

  using T = double;  // type T
  using E = double;  // type E
  auto f = [](T a, T b){ // return type T value
    return a + b;
  };
  auto g = [](T a, E b){ // return type T value
    return b;  // return b;
  };
  T ti = 0.0;  // identify element
  SegmentTree<T, E, decltype(f), decltype(g)> sg(f, g, ti);  // don't change
  sg.build(v);   // 初期配列を代入

  double ans = 0.0;
  for(int i = 0; i + k <= n; i++) {
    ans = max(ans, sg.query(i, i + k));
  }

  printf("%.10f\n", ans);
  return 0;
}


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

vector<int> v(3);
ll n,k,m,x,y,a,b,c;
string s,t;
bool dp[101010];

int main() {
  int o=0,e=0;
  rep(i,3){
    cin >> v[i];
    v[i]&1 ? o++ : e++;
  }
  int ans=0;
  if(o==2){
    ans++;
    rep(i,3)if(v[i]&1) v[i]++;
  }else if(e==2){
    ans++;
    rep(i,3)if(!(v[i]&1)) v[i]++;
  }
  sort(all(v));
  ans+=(v[2]-v[0])/2+(v[2]-v[1])/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int a,b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    
}
    
    






Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
long long n;
int ans;

void su(long long x, long long y, long long k){
	if (y >= k){
		if (x <= n){
			bool a3, a5, a7;
			a3 = false;
			a5 = false;
			a7 = false;
			long long x2 = x;
			while (x2 > 0){
				if (x2 % 10 == 3)a3 = true;
				else if (x2 % 10 == 5)a5 = true;
				else if (x2 % 10 == 7)a7 = true;
				x2 = x2 / 10;
			}
			if (a3&&a5&&a7)ans++;
		}
		return;
	}
	x += (y * 3);
	su(x, y * 10, k);
	x -= (y * 3);
	x += (y * 5);
	su(x, y * 10, k);
	x -= (y * 5);
	x += (y * 7);
	su(x, y * 10, k);
	x -= (y * 7);
	return;
}




int main(){
	int k;
	long long x, y, z;
	long long s;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	f(i, 9){
		x = 1;
		f(j, i + 1)x = x * 10;
		su(0, 1, x);
	}

	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, k;
    cin >> n >> k;
    bool x = true;
    if(k > (n-1)*(n-2)/2) {
        x = false;
    }
    vector<P> edge(n-1);
    rep(i, n-1) {
        edge[i] = P(n-1, i);
    }

    int ii = (n-1)*(n-2)/2-k;
    if(ii < 0) ii = 0;
    int i = 0;
    int j = 1;
    while(ii) {
        edge.push_back(P(i, j));
        if(j<n-2) {
            j++;
        } else {
            i++;
            j = i+1;
        }
        --ii;
    }
    if(!x) cout << -1 << endl;
    else {
        int m = edge.size();
        cout << m << endl;
        rep(i, m) {
            cout << edge[i].first+1 << ' ' << edge[i].second+1 << endl;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#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 <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	int A = (S[0]-'0')*10 + S[1]-'0';
	int B = (S[2]-'0')*10 + S[3]-'0';
	if(1 <= A && A <= 12 && 1 <= B && B <= 12){
		cout << "AMBIGUOUS" << endl;
	}
	else if(1 <= A && A <= 12){
		cout << "MMYY" <<endl;
	}
	else if(1 <= B && B <= 12){
		cout << "YYMM" << endl;
	}
	else{
		cout << "NA" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int N, M;
	cin >> N >> M;
	int s[31][31] = {};
	for (int i = 0; i < N; i++) {
		int k = 0;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int b;
			cin >> b;
			s[i][b] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 0; j < N; j++) {
			if (s[j][i] != 1) {
				break;
			}
			if (j == N - 1) {
				ans++;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main()
{
	char str[101];
	int a[26]={0};
	int flag=0;
	gets(str);
	int k=0;
	for(int i=0;str[i];i++)
	{
		k=str[i]-'a';
		a[k]++;
	}
	for(int i=0;i<26;i++)
	{
		if(a[i]%2!=0)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  int n = read<int>();
  int t = read<int>();
  vector<int> A(n);
  rep(i, n) A[i] = read<int>();

  map<int, int> hi;
  int ma = -1e9;
  int mi = 1e9;
  forr(a, A) {
    mi = min(a, mi);
    hi[a - mi]++;
    ma = max(ma, a - mi);
  }
  cout << hi[ma] << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 5376
x0,y0,x1,y1 = map(int,input().split(" "))
x3 = x1 - (y1-y0)
x4 = x0 - (y1-y0)
y3 = y1 + (x1-x0)
y4 = y0 + (x1-x0)
print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  string s;
  string substr;
  long long int n;
  long long int ans = 999999;
  cin >> s;
  for(int i=0;i<s.length()-2;i++){
    substr = s.substr(i,3);
    n = stoi(substr);
    if(abs(753 - n) < ans) ans = abs(753 - n);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [str(input()) for _ in range(h)]
dp = [[0] * 1050 for _ in range(1050)]
MOD = int(1e9+7)
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if i + 1 < h and grid[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
        if j + 1 < w and grid[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
        dp[i][j] %= MOD
print(dp[h-1][w-1])

Measured memory_bytes: 50260
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 272727;

int main(){
    lint a, v, b, w, t;
    scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
    puts(t*(v-w) >= abs(a-b) ? "YES" : "NO");
}

Measured memory_bytes: 3672
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		long count = Arrays.stream(next().split("")).filter(i -> i.equals("o")).count();
		out.println(700 + count * 100);
	}

	private void solveB() {
		String wk = "";
		for (int i = 0; i < 3; i++) {
			String tmp = next();
			for (int j = 0; j < 3; j++) {
				if (i == j) {
					wk += tmp.charAt(j);
				}
			}
		}

		out.println(wk);
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22484
N, M = map(int, input().split())
H = list(map(int, input().split()))
A, B = [], []
ans = [1]*N
for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = 0
    elif H[a-1] > H[b-1]:
        ans[b-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))


Measured memory_bytes: 19984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    s.pop_back();
    if (s.size()%2==1) {
        s.pop_back();
    }
    
    while (s.size()) {
        bool ok = true;
        rep(i, s.size()/2) {
            if (s[i]!=s[i+s.size()/2]) ok = false;
        }
        if (ok) {
            cout << s.size() << endl;
            return 0;
        }
        s.pop_back();
        s.pop_back();
    }
    
    
    return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

H = list(map(int,input().split()))

a = [True for i in range(N)]

for i in range(M):
  A,B = map(int, input().split())
  if H[A-1] < H[B-1]:
    a[A-1] = False
  elif H[A-1] > H[B-1]:
    a[B-1] = False
  elif H[A-1]== H[B-1]:
    a[A-1] = False
    a[B-1] = False

print(len([0 for i in a if i == True]))

Measured memory_bytes: 20088
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,1,-1};
//////////////////////////////////


int main() {
    int m, d;
    cin >> m >> d;
    int cnt = 0;
    for(int i=1; i<=m; i++) {
        for(int j=0; j<=d; j++) {
            int d1 = j%10;
            int d2 = j/10;
            if(d1 >= 2 && d2 >= 2 && d1*d2 == i) cnt++;
        }
    }
    cout << cnt << endl;
    
    return 0;
}




// EOF


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# problem D
MAX = 9999 # c_i <= 1000 より.

n, m = map(int, input().split())
cost = []

dist = [[MAX] * n for _ in range(n)]
for i in range(n):
    dist[i][i] = 0
    
for _ in range(m):
    cost.append(list(map(int, input().split())))

for a, b, c in cost:
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c

# Warshall-Floyd Algorithm
for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

ans = 0
for a, b, c in cost:
    if dist[a-1][b-1] < c:
        ans += 1
        
print(ans)

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, dp[MAX_N][2]{};
    vector<int> ls[26];
    string s, ans="";
    cin >> s;
    n = s.size();
    REP(i,n){
        ls[s[i]-'a'].push_back(i+1);
    }
    REP(i,26) ls[i].push_back(n+1);
    REPR(i,n+2)fill(dp[i],dp[i]+2,IINF);
    dp[n+1][0] = 0;
    REPR(i,n){
        REP(j,26){
            int k = *upper_bound(ALL(ls[j]),i);
            if(dp[i][0] > (dp[k][0]/100+1)*100+j){
                dp[i][0] = (dp[k][0]/100+1)*100+j;
                dp[i][1] = k;
            }
        }
    }
    for(int i=0;i<=n;i=dp[i][1]){
        ans.push_back('a'+dp[i][0]%100);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int vec_find(vector<int> vec, int number) {
    vector<int>::iterator itr = find(vec.begin(), vec.end(), number);
    if (itr != vec.end()) {
        return 1;
    } else {
        return 0;
    }
}

int main() {
    int n, m, x, tmp;
    cin >> n >> m >> x;
    vector<int> a(m);

    for (int i = 0; i < m; i++) {
        cin >> tmp;
        a.push_back(tmp);
    }

    int cost_left = 0;
    for (int i = 1; i < x; i++) {
        if (vec_find(a, i)) {
            cost_left++;
        }
    }

    int cost_right = 0;
    for (int i = x; i < n; i++) {
        if(vec_find(a, i)) {
            cost_right++;
        }
    }
    cout << (cost_right >= cost_left ? cost_left : cost_right);
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

surplus = []
short = 0
cnt = 0

for i in range(n):
    if a[i] > b[i]:
        surplus.append(a[i]-b[i])
    elif b[i] > a[i]:
        short += b[i]-a[i]
        cnt += 1

surplus = sorted(surplus)
s = 0

while s < short:
    if len(surplus) == 0:
        print(-1)
        exit()

    s += surplus.pop()
    cnt += 1

print(cnt)

Measured memory_bytes: 24240
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    n--;
    d = d-c;
    for(ll i=0;i<=n;i++){
        ll ret = a + i*c - (n-i)*c;
        // + (0~i)*d - (0 ~ (n-i))*d
        if(b <= ret+i*d && b>= ret-(n-i)*d){
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";


}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (to_string(i).size() % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vecapital_in_tor<(type)> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vecapital_in_tor< int > p ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            p.pb(i);
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}


ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}


ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}

void solve(){
    int index = -1,temp;
    f(i,5){
        cin>>temp;
        if(temp == 0)   index = i+1;
    }
    out(index);
}

int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;

int main(){
    int n=0,m=0,p=0,Asum=0,Nsum=0;
    string s;
    map<int,int>  res;
    set<int>      solved;
    cin >> n>>m ;
    while(m--){
        cin >> p >> s;
        if(s == "WA"){
            res[p]++;
        }else{
             if(solved.count(p) == 0){
                // First AC
                solved.insert(p);
                Nsum+=res[p];
             }
        }
    }

    cout << solved.size() << " " << Nsum<< endl;
    return 0;
}


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

int main() {
  char a[4], i, ans = 0;
  scanf("%s ", &a);
  if(a[0] == 'A') {
    ans++;
  }
  if(a[1] == 'A') {
    ans++;
  }
  if(a[2] == 'A') {
    ans++;
  }
  if(ans == 0 || ans == 3) {
    printf("No");
  } else {
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=2147483647;
const int MAX=2500;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct SegmentTree {
private:
    ll n;
    vector<ll> node;

public:
    
    SegmentTree(vector<ll> v) {
        ll sz = v.size(); 
        n = 1; while(n < sz) n *= 2; 
        node.resize(2*n-1, INF); 
        for(ll i=0; i<sz; i++) node[i+n-1] = v.at(i); 
        for(ll i=n-2; i>=0; i--) node[i] = min(node[2*i+1],node[2*i+2]); 
    }

    void update(ll x, ll val) {
        
        x += (n - 1); 
        node[x] = val; 
        while(x > 0) { 
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1],node[2*x+2]); 
        }
    }

    ll getor(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        
        if(r < 0) r = n; 
        if(r <= a || b <= l) return INF; 
        if(a <= l && r <= b) return node[k];
        

        ll vl = getor(a, b, 2*k+1, l, (l+r)/2);
        
        ll vr = getor(a, b, 2*k+2, (l+r)/2, r);
        
        return min(vl,vr); 
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,q;
  cin >> n >> q;
  vl a(n,INF);
  
  SegmentTree tree(a);
  
  rep(i,q){
    bool type; cin >> type;
    if(!type){
      ll first,second; cin >> first >> second;
      tree.update(first,second);
    }
    else{
      ll first,second; cin >> first >> second;
      cout << tree.getor(first , second+1) << endl;
    }
    
  }
  return 0;   
  
}



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

int main() {
  int a[3];
  for (int i{}; i < 3; ++i) cin >> a[i];
  sort(a, a+3);
  cout << a[0];
  for (int i{1}; i < 3; ++i) cout << ' ' << a[i];
  cout << endl;

  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

	int ans = n + pow(n, 2) + pow(n, 3);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4040
#include<iostream>
using namespace std;
int N;
int A[210];

int main(){
  // 整数の入力
  cin>>N;
  bool exist_odd = false;
  for(int i=0;i<N;i++)
    cin>>A[i];
  int count  = 0;
  while(true){
    for(int i=0;i<N;i++){
      if(A[i]%2 == 0){
        A[i] /= 2;        
      }else exist_odd = true;
    }
    if(exist_odd)break;
  	count++;
  }

  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long long
#define ld long double
#define loopi(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopj(j,intial,n) for(int j=int(intial);j<n;j++)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 1e13;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");
int main()
{  
	afify();
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()){cout<<"GREATER"<<endl;}
	else if(b.length()>a.length()){cout<<"LESS"<<endl;}
	else {
		loopi(i,0,a.length()){
			if(a[i]>b[i]){cout<<"GREATER"<<endl;return 0;}
			else if(a[i]<b[i]){cout<<"LESS"<<endl;return 0;}
		}
		cout<<"EQUAL"<<endl;
	}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{
	ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	int *a, *b;
	cin >> n;
	a = new int[n + 1];
	b = new int[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		++c[a[i]];
	}
	int i;
	for (i = 0; i <= MAX; ++i)
	{
		if (c[i])
		{
			--c[i];
			cout << i;
			break;
		}
	}
	for (i = 0; i <= MAX; ++i)
	{
		while (c[i])
		{
			--c[i];
			cout << ' ' << i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 10992
import sys
import math
from collections import deque
import copy
INF = float("inf")
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    tempW, tempV = map(int, input().split())
    weight.append(tempW)
    value.append(tempV)

dp = [[INF for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for l in range(N * 1000 + 1):
        if l - value[i - 1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - value[i - 1]] + weight[i - 1])
        else:
            dp[i][l] = dp[i - 1][l]
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}
ll n, x;
ll sum = 0;
vector<ll>  p, num; //レベルiバーガーに含まれるパティの枚数 / 全体

void dfs(int depth, ll cur) {
	if(depth == 1){
	//	cerr << sum << endl;
		if(cur == 2)sum += 1;
		if(cur == 3)sum += 2;
		if(cur >= 4)sum += 3;
		return;
	}
	if(cur <= (num[depth] / 2)) {
		dfs(depth - 1, max(0LL, cur - 1) );
	} else {
		sum += p[depth - 1] + 1;
		dfs(depth - 1, cur - max(num[depth - 1] + 2, 0LL) );	
	}
}

int main()
{
	cin >> n >> x;
	p.resize(n + 1), num.resize(n + 1);
	p[0] = num[0] = 1;
	for(int i = 1; i < n + 1; i++) {
		p[i] = p[i - 1] * 2 + 1;
		num[i] = num[i - 1] * 2 + 3;
		//cerr << p[i] << endl;
	}
	dfs(n, x);
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int w,  a, b;
int main() {
  while (cin >> w >> a >> b) {
	if (a > b) swap(a, b);
	if (a + w >= b) cout << 0 << endl;
	else cout << b - (a+w) << endl;
  }
}
																				   


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

string random_string( size_t length )
{
    auto randchar = []() -> char
    {
        const char charset[] =
        "NEWS";
        const size_t max_index = (sizeof(charset) - 1);
        return charset[ rand() % max_index ];
    };
    string str(length,0);
    generate_n( str.begin(), length, randchar );
    return str;
}


int face[7];
int face2[7];
void roll(int tmp, int a, int b, int c) {
    face[1] = face[a];
    face[a] = face[b];
    face[b] = face[c];
    face[c] = tmp;
}
int main() {
    rrep(i, 1, 7) cin >> face[i];
    rrep(i, 1, 7) cin >> face2[i];
    int c = 0;
    while (c++ < 1000) {
        string ch = random_string(1);
        int tmp = face[1];
        if (ch == "N") {
            roll(tmp, 2, 6, 5);
        } else if (ch == "E") {
            roll(tmp, 4, 6, 3);
        } else if (ch == "W") {
            roll(tmp, 3, 6, 4);
        } else {
            roll(tmp, 5, 6, 2);
        }
        rrep(i, 1, 7) {
            if (face[i] != face2[i]) break;
            if (i == 6) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
}



Measured memory_bytes: 3172
a, b, c, x, y = list(map(int, input().split()))
#b = list(map(int, input().split()))
x2 = x
y2 = y
total = 0
m = x
if a+b > c*2:
    total += m*c*2
    x -= m
    y -= m

if x > 0:
    total += x*a
if y > 0:
    total += y*b



total2 = 0
m = y2
if a+b > c*2:
    total2 += m*c*2
    x2 -= m
    y2 -= m

if x2 > 0:
    total2 += x2*a
if y2 > 0:
    total2 += y2*b


print(min(total,total2))    

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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> a(N, 0);
    long long allXorSum = 0;
    for (long long i = 0; i < N; ++i) {
        cin >> a[i];
        allXorSum ^= a[i];
    }

    for (long long i = 0; i < N; ++i) {
        if (i > 0) {
            cout << " ";
        }
        cout << (allXorSum ^ a[i]);
    }
    cout << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4792
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		char[] c=s.toCharArray();
		int cnt=1;
		for(int i=1;i<c.length;i++) {
			if(Character.getNumericValue(c[i-1])==Character.getNumericValue(c[i])) {
				cnt++;
				if(cnt==3)break;
			}else {
				cnt=1;
			}
		}
		System.out.println((cnt==3)? "Yes":"No");
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int c=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(i%2==0&&a%2==1)
      c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 11 14:41:22 2020

@author: Kanaru Sato
"""

N = int(input())
s = list(input())

loop = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2)

for i in range(len(s)):
    s[i] = loop[loop.index(s[i])+N]

print("".join(s))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if(0 <= s-i-j && s-i-j <= k){
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

bool isPrime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;

  ll ans = 1LL << 60;

  // 素数
  if (isPrime(N)) {
    ans = N - 1;
  } else {
    for (ll i = 1; i < (ll)sqrt(N) + 1; i++) {
      if (N % i != 0) {
        continue;
      }

      ll x = i;
      ll y = N / i;

      // cout << x << " " << y << endl;

      ans = min(ans, (x - 1) + (y - 1));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q;cin >> n >> m >> q;
    vector<vector<int>> c(n+1,vector<int>(n+1));
    rep(i,m){
        int l,r;cin >> l >> r;
        c[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            c[i][j]+=c[i][j-1];
        }
    }
    for(int j=1;j<=n;j++){
        for(int i=1;i<=n;i++){
            c[i][j]+=c[i-1][j];
        }
    }
    rep(i,q){
        int s,t;cin >> s >> t;
        cout << c[t][t]-c[t][s-1]-c[s-1][t]+c[s-1][s-1] << endl;
    }
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String N_scan = scan.nextLine();
    var N = Integer.parseInt(N_scan);
    String[] S = new String[N];
    int AC  = 0;
    int WA  = 0;
    int TLE = 0;
    int RE  = 0;

    for (var i = 0; i < N; i++) {
      S[i] = scan.nextLine();
    }

    for (var j = 0; j < N; j++) {
      switch (S[j]) {
        case "AC" :
	  AC++;
	  break;
        case "WA" :
	  WA++;
	  break;
        case "TLE" :
	  TLE++;
	  break;
        case "RE" :
	  RE++;
	  break;
      }
    }

    System.out.println("AC x " + AC);
    System.out.println("WA x " + WA);
    System.out.println("TLE x " + TLE);
    System.out.println("RE x " + RE);
    scan.close();
  }
}

Measured memory_bytes: 65080
using System;
using System.Linq;

namespace atcoder.abc174.c
{
    class Program
    {
        static void Main(string[] args)
        {
            long MAGIC_NUM = 7;

            long K = getLongParam();
            long p = MAGIC_NUM;

            long ret = 0;
            long mod = 0;
            for (long c = 0; c < K; c++)
            {
                mod = p % K;
                ret++;

                if (mod == 0)
                {
                    Console.WriteLine(ret);
                    return;
                }
                p = ((mod * 10) + MAGIC_NUM) % K;
            }
            Console.WriteLine(-1);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 27536
from sys import stdin

class B:
	def __init__(self,N,L):
		self.N = int(N)
		self.L = int(L)
		self.taste = list()
		self.taste_abs = list() #絶対値


	def CollectTaste(self):
		for i in range(1,self.N+1):
			i = self.CulTasteFirst(i)
			self.taste.append(i)
			self.taste_abs.append(abs(i)) #絶対値リストの作成

		#絶対値の小さい要素を削除して計算する味リストの決定
		min_num = min(self.taste_abs)
		try:
			self.taste.remove(min_num)
		except ValueError:
			min_num *= -1
			self.taste.remove(min_num)

		ans = 0
		for i in self.taste:
			ans += i
		print(ans)
	def CulTasteFirst(self,i):
		i = int(i)
		return self.L+i-1


Inp = stdin.readline()
Inp = Inp.replace('\n','')
Inp = Inp.split()

do = B(Inp[0],Inp[1])
do.CollectTaste()



Measured memory_bytes: 3064