akhauriyash/Code-Regression huggingface dataset:
// B - Resistors in Parallel

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

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

	double A[100];
	for (int i=0; i<N; i++) {
		cin >> A[i];
	}

	double deno = 0;
	for (int i=0; i<N; i++) {
		deno += 1/A[i];
	}

	cout << fixed << setprecision(10);
	cout << 1.0 / deno << endl;

	return 0;
}

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

int	main()
{
	int N;
	unordered_map<int, int>	cnt_map;
	int	A;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		if (cnt_map.count(A))
			++cnt_map[A];
		else
			cnt_map[A] = 1;
	}
	int	cnt = 0;
	for (auto pr : cnt_map) {
		if (pr.second % 2 == 1)
			++cnt;
	}
	cout << cnt << endl;
}



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

vector<int> to[100010];
vector<int> group;
vector<int> block;

void dfs(int i, int gr, vector<int> &vec){
  if(group[i]!=-1) return;
  vec[gr]++;
  group[i]=gr;
  for(auto x : to[i]){
    dfs(x,gr,vec);
  }
}

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  group.resize(n,-1);
  block.resize(n,0);
  vector<int> group_cnt;
  int tmp=0;
  rep(i,n){
    if(group[i]==-1){
      group_cnt.push_back(0);
      dfs(i,tmp,group_cnt);
      tmp++;
    }
  }
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--; d--;
    if(group[c]==group[d]){
      block[c]++;
      block[d]++;
    }
  }
  rep(i,n){
    cout<<group_cnt[group[i]]-to[i].size()-block[i]-1<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 10604
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader rd = new MyReader();        
        String S = rd.s();
        int N = S.length();
        int[] ans = new int[N];
        for(int i = 0; i < N;){
            int j = i;
            while(S.charAt(j) == 'R')
                j++;            
            int r = j-1;
            int l = j;
            while(j < N && S.charAt(j) == 'L')
                j++;            
            int rn = r-i+1;
            int ln = j-l;
            ans[r] = ((rn+1)>>1)+(ln>>1);
            ans[l] = (rn>>1)+((ln+1)>>1);            
            i = j;
        }
        StringBuilder sb = new StringBuilder();
        for(int a : ans)
            sb.append(a).append(" ");
        println(sb);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 25428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_144
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            if (ab[0] <= 9 && ab[1] <= 9)
            {
                WriteLine(ab[0] * ab[1]);
            }
            else
            {
                WriteLine(-1);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<long long> Divisor(long long n) {
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(void) {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    map<long long, int> colors;
    for (int i = 0; i < N; i++) {
        auto itr = colors.lower_bound(a[i]);
        if (itr == colors.begin() || colors.size() == 0) {
            if (colors.count(a[i])) colors[a[i]]++;
            else colors[a[i]] = 1;
        } else {
            itr--;
            itr->second--;
            if (itr->second == 0) {
                colors.erase(itr);
            }
            if (colors.count(a[i])) colors[a[i]]++;
            else colors[a[i]] = 1;
        }
    }
    long long ans = 0;
    for (auto &itr : colors) {
        ans += itr.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, k, c = 100005, d = 100005, a[100005] = {}, b[100005] = {}, u, v, w, z;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i], c = min(c, a[i]);
    for (int i = 1; i <= m; i++) cin >> b[i], d = min(d, b[i]);
    z = c + d;
    while (k--) cin >> u >> v >> w, z = min(z, a[u] + b[v] - w);
    cout << z;
}

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

int cnt[11];

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	if (cnt[5] == 2 && cnt[7] == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	var S, T string
	fmt.Scan(&N, &S, &T)

	for i := 0; i < N; i++ {
		fmt.Printf("%s%s", string(S[i]), string(T[i]))
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;    
#define int long long        
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
const int N= 1e5+ 10;
int st[N]={0};
const int INF = 1e16;
void update(int ss, int se, int i, int diff, int si)  
{  
    // Base Case: If the input index lies outside the range of  
    // this segment  
    if (i < ss || i > se)  
        return;  
  
    // If the input index is in range of this node, then update  
    // the value of the node and its children  
    st[si] = st[si] + diff;  
    if (se != ss)  
    {  
        int mid = (ss+se)/2;  
        update(ss, mid, i, diff, 2*si);  
        update(mid+1, se, i, diff, 2*si + 1);  
    }  
}  
int get_sum(int ss, int se, int qs, int qe, int si)  
{  
    // If segment of this node is a part of given range, then return  
    // the sum of the segment  
    if (qs <= ss && qe >= se)  
        return st[si];  
  
    // If segment of this node is outside the given range  
    if (se < qs || ss > qe)  
        return 0;  
  
    // If a part of this segment overlaps with the given range  
    int mid = (ss+se)/2;
    return get_sum(ss, mid, qs, qe, 2*si) +  
        get_sum(mid+1, se, qs, qe, 2*si+1);  
}
double dp[3000][3000];
// double fun(int head, int tail, int idx,double ans, double ar[])
// {
//     if(idx<0 && head>tail)
//     {
//      //   cout<<ans<<endl;
//         return ans;
//     }
//     else if(idx<0)
//     {
//         return 0;
//     }
//     double x=ar[idx];
//    // cout<<x<<endl;
//     double y=1-x;
//     if(dp[idx][head+1]==-1)
//     dp[idx][head+1]=fun(head+1,tail,idx-1,ans*x,ar);

//     if(dp[idx][head]==-1)
//     dp[idx][head]=fun(head,tail+1,idx-1,ans*y,ar);
//     //return fun(head+1,tail,idx-1,ans*x,ar) + fun(head,tail+1,idx-1,ans*y,ar);

//     return dp[idx][head+1] + dp[idx][head];    
// }
signed main()
{
    fastio;
    int n;
    cin>>n;
    double ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    
    for(int i=0;i<3000;i++){
        for(int j=0;j<3000;j++)
        dp[i][j]=0;
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i+1;j++){
            double x=ar[i];
            double y=1-x;
            if(i==0 && j==0){
                dp[i][j]=y;
            }
            else if(i==0 && j==1){
                dp[i][j]=x;
            }
            else if(j==0){
                dp[i][j]=dp[i-1][0]*y; 
            }
            else
            {
                dp[i][j]=dp[i-1][j]*y + dp[i-1][j-1]*x;
            }
        }
    }
    double ans=0;
    for(int j=n/2+1;j<=n;j++){
        ans+=dp[n-1][j];
    }
    cout<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

signed main() {
  ll s, e, k;
  {
    ll h, m;
    cin >> h >> m;
    s = 60 * h + m;
  }
  {
    ll h, m;
    cin >> h >> m;
    e = 60 * h + m;
  }
  cin >> k;
  e -= k;
  cout << max(0LL, e-s) << endl;
  return 0;
}


Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
	
	int n; cin >> n;
	
	vector<int> a(n);

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

	sort(a.begin(), a.end());

	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}

	for (int i = 0; i < n; i++) {
		if (a[i] % 10 != 0) {
			sum -= a[i];
			cout << sum << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;

    rep(i, 3) if(s[i]==t[i]) ans++;

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    int k;

    while(cin >> n >> k, n != 0 || k != 0){
        vector<int> data;
        int sum = 0;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            data.push_back(tmp);
        }
        for(int i=0; i<k; i++){
            sum += data[i];
        }
        int max = sum;
        for(int i=k; i<data.size(); i++){
            sum -= data[i-k];
            sum += data[i];
            if(sum > max) max = sum;
        }
        cout << max << endl;
    }
    return 0;
}

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


int main(){   
    int n; cin >> n;
    int ac=0 , wa=0, tle=0, re=0;
    for(int i=0;i<n;++i){
        string s; cin >> s;
        if(s == "AC") ac++;
        if(s == "WA") wa++;
        if(s == "TLE") tle++;
        if(s == "RE") re++;
    }
    cout << "AC" << " " << "x" << " " << ac << endl;
    cout << "WA" << " " << "x" << " " << wa << endl;
    cout << "TLE" << " " << "x" << " " << tle << endl;
    cout << "RE" << " " << "x" << " " << re << endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a * b >= c * d){
    cout << a * b << endl;
  }else{
    cout << c * d << endl;
  }
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define INFTY (1<<30)
#define MAX 100010

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

  deque<pair<int,int>> DQ;
  int d[k+1]={};
  for(int i=0;i<k;i++) d[i]=INFTY;
  DQ.push_back(make_pair(1,0));

  while(!DQ.empty()){
    pair<int,int> p=DQ.front();
    DQ.pop_front();
    int f=p.first;
    if(d[f]!=INFTY) continue;
    d[f]=p.second;

    DQ.push_front(make_pair((f*10)%k,d[f]));
    DQ.push_back(make_pair((f+1)%k,d[f]+1));
  }

  cout<<d[0]+1<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
int H,W,i,j,w=0;
	while(cin>>H){	
		cin>>W;
		w=0;
		j=0;
		if(H==0&&W==0){
			break;
		}
		for(j=0;j<H;j++){
			if(w+1<=H){
				for(i=0;i<W;i++){
					cout<<'#';
					if(i+1<W){
						cout<<'.';
						i++;
					}
				}
			}	
				w++;
				cout<<endl;
			if(w+1<=H){
				for(i=0;i<W;i++){
					cout<<'.';
					if(i+1<W){
						cout<<'#';
						i++;
					}		
				}
			
				w++;				
				j++;
				cout<<endl;		
		}	

		}
	cout<<endl;
	}	
return 0;
}

Measured memory_bytes: 1152
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

from collections import Counter
dc = Counter(d)
tc = Counter(t)

ans = 'YES'
for dif, num in tc.items():
    if dc[dif] < num:
        # 足りない
        ans = 'NO'
        break

print(ans)

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

int main(){
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  long long E=lcm(C,D);
  //cout<<B-A+1<<endl;
  //cout<<B/C-(A-1)/C<<endl;
  //cout<<B/D-(A-1)/D<<endl;
  //cout<<B/E-(A-1)/E<<endl;
  cout<<B-A+1-(B/C-(A-1)/C)-(B/D-(A-1)/D)+B/E-(A-1)/E<<endl; 
  return 0;
}



Measured memory_bytes: 3500
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

int nextInt()
{
    int y = 0;
    char c = getchar();
    while ('0' <= c && c <= '9')
    {
        y = 10 * y + c - '0';
        c = getchar();
    }
    return y;
}

long long max(long long a, long long b)
{
    if (a > b) return a;
    return b;
}

long long min(long long a, long long b)
{
    if (a < b) return a;
    return b;
}

S s;
int cnt[4000];

signed main()
{
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++) cnt[s[i]]++;
    if (cnt['N'] && !cnt['S']) {cout << "No"; return 0;}
    if (!cnt['N'] && cnt['S']) {cout << "No"; return 0;}
    if (cnt['E'] && !cnt['W']) {cout << "No"; return 0;}
    if (!cnt['E'] && cnt['W']) {cout << "No"; return 0;}
    cout << "Yes";
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using pii=pair<int,int>;
pii ary[100010];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> ary[i].first,ary[i].second=i;
	sort(ary,ary+n);

	int ans=0;
	rep(i,n) if(i%2!=ary[i].second%2) ans++;
	cout << ans/2 << endl;
	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vec a = ivec(n);

    int lim = (sum_(a) + (4 * m) - 1) / (4 * m);
    int cnt = 0;
    repall (e, a) {
        if (e >= lim) cnt++;
    }
    yn(cnt >= m);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> a(N); rep(i, N) cin >> a[i];

  int ans = 0;
  for (int i = 1; i <= N; ++i){
    if (i % 2 != 0 && a[i - 1] % 2 != 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] input = new int[M];
		int left = 0;
		int right = 0;
		for (int i = 0; i < input.length; i++) {
			int tmp = sc.nextInt();
			input[i] = tmp;
			if (X < tmp) {
				right++;
			} else {
				left++;
			}
		}
		System.out.println(Math.min(left, right));

	}
}


Measured memory_bytes: 35804
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x)cout<<"NO";
	else
	{
		if(b>=x-a)cout<<"YES";
		else cout<<"NO";
	}
	return 0;
 } 
 

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   int n;
   ll d;
   cin >> n >> d;
   vector<pll>a(n);
   rep(i, 0, n)cin >> a[i].first >> a[i].second;
   int cnt=0;
   rep(i, 0, n){
       if(a[i].first*a[i].first + a[i].second*a[i].second <= d*d)cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 6424
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))

isLower :: Char -> Bool
isLower x = 'a' <= x && x <= 'z'

query :: String -> Bool
query ('A':xs) = query2 xs
query _ = False

query2 (x:xs) = isLower x && query3 xs
query2 _ = False

query3 ('C':xs) = query4 xs
query3 (x:xs) = isLower x && query3 xs
query3 _ = False

query4 [] = False
query4 xs = all isLower xs

main :: IO ()
main = do
  xs <- getLine
  putStrLn $ if query xs then "AC" else "WA"

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

using namespace std;

typedef long long ll;

ll a[6], cnt[6], res, x, mn = 1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> cnt[0];
	for (ll i = 1; i <= 5; ++i) {
		cin >> a[i];
		mn = min(mn, a[i]);
	}
	
	x = 0;
	while (true) {
		for (ll i = 0; i <= 4; ++i) {
			if (cnt[i] != 0) goto lap;
		}
		cout << res;
		return 0;
		
		lap:;
		cnt[5] = 0;
		for (ll i = 5; i >= 1; --i) {
			ll tmp = a[i] - cnt[i];
			tmp = min(tmp, cnt[i-1]);
			cnt[i] += tmp;
			cnt[i-1] -= tmp;
		}
		++res;
		
		if (++x == 5) {
			res += cnt[0] / mn;
			cnt[0] %= mn;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var A = Sarray();
            var B = Sarray();
            var ba = 0L;//(b-a)/2の総数 b>a
            var ab = 0L;//a-bの総数 a>b
            for(var i=0;i<N;++i)
            {
                var a = A[i];
                var b = B[i];
                if (b > a) ba += (b - a) / 2;
                else ab += a - b;
            }
            WriteLine(ba >= ab ? "Yes" : "No");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15584
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll n,m,p; cin >> n >> m >> p;
        if(!n && !m && !p) break;
        ll haitou = 100 - p;
        ll sum = 0;
        vl a(n);
        rep(i,n){
            cin >> a[i];
            sum += a[i];
        }
        if(a[m-1]==0) puts("0");
        else cout << haitou*sum / a[m-1] << endl;
    }
}


Measured memory_bytes: 3100
s=input()
T=input()

s=''.join([x if x!='?' else '1' for x in list(s)])

start=[]
for i in range(len(s)-len(T)+1):
    tmp=0
    for j in range(len(T)):
        if s[i+j]==T[j] or s[i+j]=='1': tmp+=1
    if tmp==len(T): start.append(i)

candidates=[]
t=len(T)
ans=''
if len(start):
    for st in start:
        tmp=s[:st]+T+s[st+t:]
        candidates.append(tmp)
    candidates.sort()
    ans=candidates[0].replace('1','a')
else:
    ans='UNRESTORABLE'

print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
 
#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	int n;
	cin>> n;
	if(n%2)
		return cout<< "No", 0;
	string s;
	cin>> s;
	string a = s.substr(0, n/2);
	string b = s.substr(n/2, n/2);
	if(a == b)
		cout<< "Yes";
	else
		cout<< "No";
	return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]):Unit = {
    val n = for{
      i<-stdin.getLines.drop(1)
      if isPrime(i.toInt)
    } yield i
    println(n.length)
  }
}

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

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long H;
        H = sc.nextLong();
        long N;
        N = sc.nextLong();
        List<Long> A = new ArrayList<>();
        for(int i = 0 ; i < N ; i++){
                A.add(sc.nextLong());
        }

        final Solver solver = new Solver();
        solver.solve(H, N, A);
    }
}

class Solver {
    public void solve(long H, long N, List<Long> A) {
        A.sort(Collections.reverseOrder());

        long life = H;
        for (int i = 0; i < N; i++) {
            H -= A.get(i);
            if (H <= 0) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}



Measured memory_bytes: 50852
import math

N = int(input())

if N < 10:
    print(N)
else:
    ketasu = int(math.log10(N)//1 + 1)
    ans = 9*(ketasu - 1)

    start = [str(4) , str(5)]
    start += [str(9) for _ in range(ketasu - 2)]
    start = int(''.join(map(str, start)))

    if start > N:
        start = [str(9) for _ in range(ketasu-1)]
        start = int(''.join(map(str, start)))

    #print(start)

    for i in range(start,N+1,10**(ketasu - 2)):
        temp_ans = 0
        for j in list(str(i)):
            temp_ans += int(j)

        if temp_ans > ans:
            ans = temp_ans

    print(ans)

Measured memory_bytes: 3188
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }

    println!("{}", if a + b + c > 21 { "bust" } else { "win" });
}


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

int main(void)
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int a,b,c;;
    int count = 0;
    for( a = 0; a <= A; a++){
        for(b=0;b<=B;b++){
            for(c=0;c<=C;c++){
                if(500*a + 100*b + 50*c == X) count++;
            }
        }
    }
    
    cout << count << endl;

}

Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 100000;

int par[N_MAX]; // 親
int count_size[N_MAX];

void init(int n) {
  rep(i, n) {
    par[i] = i;
    count_size[i] = 1;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (count_size[x] < count_size[y]) {
    par[x] = y;
    count_size[y] += count_size[x];
  } else {
    par[y] = x;
    count_size[x] += count_size[y];
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int size(int x) {
  return count_size[find(x)];
}

int N, M;
int A[N_MAX + 1], B[N_MAX + 1];
vector<ll> answers;

int main() {
  scanf("%d %d", &N, &M);
  rep(i, M) scanf("%d %d", &A[i], &B[i]);

  ll total = 0;
  FOR(i, 1, N + 1) {
    total += i - 1;
  }
  answers.push_back(total);

  init(N + 1);
  FORR(i, M - 1, 0) {
    int a = A[i];
    int b = B[i];
    if (same(a, b)) {
      answers.push_back(answers.back());
      continue;
    }
    int a_size = size(a);
    int b_size = size(b);
    answers.push_back(answers.back() - a_size * b_size);
    unite(a, b);
  }

  FORR(i, M - 1, 0) {
    printf("%lld\n", answers[i]);
  }
}


Measured memory_bytes: 3828
#include <stdio.h>
int main(void){
 char a[101];
 long long int b;
 scanf("%s",a);
 scanf("%lld",&b);
 int c=0;
 while(a[c]=='1'){
  c++;
 }
 if(a[c]=='\0') printf("1");
 else if(c+1>b){
  puts("1");
 }else{
  printf("%c",a[c]);
 }
 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int a, b;
  cin >> a >> b;
  if(a%2==0 || b%2==0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll dp[128][1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, num[128], right;
  cin >> N; N--;
  REP(i, N) cin >> num[i];
  cin >> right;

  dp[0][num[0]] = 1;
  REP(i, N-1) {
    REP(j, 1000) {
      if (!dp[i][j]) continue;
      if (j + num[i+1] <= 20) dp[i+1][j+num[i+1]] += dp[i][j];
      if (j - num[i+1] >= 0) dp[i+1][j-num[i+1]] += dp[i][j];
    }
  }
  cout << dp[N-1][right] << endl;  
  return 0;
}

Measured memory_bytes: 1580
# Author: cr4zjh0bp
# Created: Sun Mar 22 17:06:57 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = na()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

g = a[0]
for i in range(n):
    g = gcd(g, a[i])

m = max(a)
if g == 1 and k <= m:
    print("POSSIBLE")
elif k % g == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14252
#include<stdio.h>

int main(){

int n[100001];
int N;
while(1){
scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++)
scanf("%d",&n[i]);

for(int i=0;i<N;i++)
if(i%2==1){
for(int j=i-1;j>=0;j--)
if(n[j]!=n[i])n[j]=n[i];
else if(n[j]==n[i])break;
}
int c=0;
for(int i=0;i<N;i++)
if(n[i]==0)c++;

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

Measured memory_bytes: 1416
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;


int main() {
	int n;
	char a[53];
	int b[53];	
	int s[53];
	int h[53];
	int c[53];
	int d[53];
	fill(s, s + 53, 0);
	fill(h, h + 53, 0);
	fill(c, c + 53, 0);
	fill(d, d + 53, 0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for(int i=1;i<=n;i++){
		if (a[i] == 'S') s[b[i]] = 1;
		else if (a[i] == 'H') h[b[i]] = 1;
		else if (a[i] == 'C') c[b[i]] = 1;
		else d[b[i]] = 1;
	}
	for (int i = 1; i <= 13;i++) {
		if (s[i] == 0) cout << "S " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (h[i] == 0) cout << "H " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (c[i] == 0) cout << "C " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (d[i] == 0) cout << "D " << i << endl;
	}
}

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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (1e9)

using namespace std;

int A[3];

signed main()
{
    REP(i, 3) cin >> A[i];
    sort(A, A+3);
    int ans = 0;
    ans += A[2] - A[1];

    A[0] = A[0] + ans;
    if ((A[2]- A[0]) % 2 != 0) ++ans, ++A[2];
    ans += (A[2] - A[0]) / 2;

    cout << ans << endl;

    return 0;
}

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


int main(){
  while(true){
  int m,f,c;cin>>m>>f>>c;
  char ans='D';
  int k=m+f;
  if(m==-1&&f==-1&&c==-1)break;
  if(m==-1||f==-1)ans='F';
  else if(k>=80)ans='A';
  else if(65<=k)ans='B';
  else if(50<=k)ans='C';
  else if(30>k)ans='F';
  else if(c>=50)ans='C';
  cout<<ans<<endl;
  }
}



Measured memory_bytes: 3092
def main():

    N = int(input())
    A = list(map(int, input().split()))
    visited = set()
    count = 0
    for i in range(N):
        if A[A[i]-1] == i+1:
            count += 1
    return count // 2


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


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

int main()
{
	int n, m;
	int bibs[100];

	int tmp;

	int i,j;

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &bibs[i]);
	}

	for (i = 1; i <= m; i++)
	{
		for (j = 0; j < n-1; j++)
		{
			if (bibs[j] % i > bibs[j + 1] % i)
			{
				tmp = bibs[j];
				bibs[j] = bibs[j + 1];
				bibs[j + 1] = tmp;
			}
		}
	}

	for (i = 0; i < n; i++)
	{
		printf("%d\n", bibs[i]);
	}

	return 0;
}


Measured memory_bytes: 3208
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	HashSet<Integer> set = new HashSet<Integer>();
	int cnt = 1;
	int s = sc.nextInt();
	int ns = (s%2 == 0)?s/2: 3*s+1;
	while(true) {
	    if(set.contains(s)) break;
	    set.add(s);
	    cnt++;
	    s = ns;
	    ns = (s%2 == 0)?s/2: 3*s+1;
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 212345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

map<int, int> mp;
vector<vector<ii>> g(1, vector<ii>());
vi ans;

int32_t main() {
    $
    int a, b, t;
    cin >> a >> b >> t;
    a *= 10;
    b *= 10;
    t *= 10;
    cout << (t + 5) / a * b / 10 << endl;
}   



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

using namespace std;

int main(int argc, char* argv[]) {
  int H, W;
  cin >> H >> W;

  vector<string> s(H);
  for (int i = 0; i < H; ++i)
    cin >> s[i];

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (s[i][j] == '#') {
        cout << '#';
        continue;
      }
      int count = 0;
      for (int m = -1; m < 2; ++m) {
        for (int l = -1; l < 2; ++l) {
          if (m == 0 && l == 0)
            continue;
          if (i + m >= 0 && i + m < H && j + l >= 0 && j + l < W) {
            if (s[i + m][j + l] == '#')
              ++count;
          }
        }
      }
      cout << count;
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 256