akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x;
int main(void)
{
    cin>>a>>b>>c>>x;
    x/=50;
    int cnt=0;
    for(int i=0;(i<=x/10)&&(i<=a);i++)
    {
        for(int j=0;(j<=(x-i*10)/2)&&(j<=b);++j)
        {
            if((x-10*i-2*j)>=0&&(x-10*i-2*j)<=c)
            {
                cnt++;
            }
        }
    }
    cout <<cnt<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
int n,a[MAXN+5],b[MAXN+5];
int lsh[MAXN+5],lcnt;
int vis[MAXN+5],setfa[MAXN+5];
int ru[MAXN+5],chu[MAXN+5];
bool sp[MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		setfa[i]=i;
}
int Findfa(int x)
{
	if(x==setfa[x])
		return x;
	return setfa[x]=Findfa(setfa[x]);
}
void Union(int x,int y)
{
	int fx=Findfa(x),fy=Findfa(y);
	if(fx==fy)	return;
	setfa[fx]=fy;
}
int main()
{
	Init();
	scanf("%d",&n);
	int x=0;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),x^=a[i];
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
		lsh[++lcnt]=a[i],lsh[++lcnt]=b[i];
	lsh[++lcnt]=x;
	sort(lsh+1,lsh+1+lcnt);
	lcnt=unique(lsh+1,lsh+1+lcnt)-lsh-1;
	x=lower_bound(lsh+1,lsh+1+lcnt,x)-lsh;
	for(int i=1;i<=n;i++)
	{
		a[i]=lower_bound(lsh+1,lsh+1+lcnt,a[i])-lsh;
		b[i]=lower_bound(lsh+1,lsh+1+lcnt,b[i])-lsh;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])
		{
			ru[a[i]]++,chu[b[i]]++;
			Union(a[i],b[i]);
			sp[a[i]]=sp[b[i]]=true;
			ans++;
		}
	if(ans==0)
	{
		printf("0\n");
		return 0;
	}
	int exist=false;
	for(int i=1;i<=lcnt;i++)
	{
		if(ru[i]==chu[i]-1)
		{
			if(i!=x)
			{
				printf("-1\n");
				return 0;
			}
		}
		else if(ru[i]==chu[i]+1)
		{
			if(exist==true)
			{
				printf("-1\n");
				return 0;
			}
			exist=true;
		}
		else if(ru[i]!=chu[i])
		{
			printf("-1\n");
			return 0;
		}
	}
	int cnt=0;
	for(int i=1;i<=lcnt;i++)
		if(Findfa(i)==i&&sp[i]==true)
			cnt++;
	if(cnt>=1)
		cnt--;
	if(ru[x]==0&&chu[x]==0)
		cnt++;
	ans+=cnt;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
// #define rep(i,n) for(int i=0;i<n;++i)
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ALL(x) (x).begin(),(x).end()
#define pb = push_back;
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int H,W;
int cost[10][10];

void warshall_floyd() {
    int V = 10;
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
}

int main() {
    cin >> H >> W;
    rep(i,0,10) rep(j,0,10) cin >> cost[i][j];
    int A[H][W];
    rep(i,0,H) rep(j,0,W) cin >> A[i][j];
    warshall_floyd();
    // printf("cost of 8 to 1:%d\n",cost[8][1]);
    int ans = 0;
    rep(i,0,H) {
        rep(j,0,W) {
            int src = A[i][j];
            int dst = 1;
            int skip = -1;
            if(src == skip) continue;
            ans += cost[src][dst];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,x,c_point=0,count=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    a.at(i)--;
  }
  while(c_point!=1){
    if(a.at(c_point)==n){
      count=-1;
      c_point=1;
    }
    else{
      x=c_point;
      c_point=a.at(c_point);
      a.at(x)=n;
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0 )break;
			else calc(n);
			
		}
	}
	public void calc(int n){
		int[] Is = new int[n];
		for(int i = 0; i < n; i++){
			Is[i] = sc.nextInt();
		}
		int m = 256;
		
		int s = 16;
		int a = 16;
		int c = 16;
		double minH = 1000000000;
		for(int ns = 0; ns < 16; ns++){			
			for(int na = 0; na < 16; na++){
				for(int nc = 0; nc < 16; nc++){
					int[] count = new int[257];
					int r = ns;
					for(int i = 0; i < n; i++){
						r = (na * r + nc) % m;
						int o = (Is[i] + r) % m; 
						count[o] += 1;
					}
					double h = 0;
					for(int i = 0; i < 257; i++){
						if(count[i] != 0){
							double t = ((double)count[i]) /((double) n);
							h += -1 * t * Math.log(t);
						}
					}
					if(h+1e-10 < minH){
						s = ns;
						a = na;
						c = nc;
						minH = h;
					}
					else if(h == minH && (ns < s || (s == ns && na < a) || (s == ns && a == na && nc < c))){
						s = ns;
						a = na;
						c = nc;
					}
				}
			}
		}
		System.out.println(s+ " " + a + " " + c);
	}

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

Measured memory_bytes: 86208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> m;
    rep(i,n){
        cin>>a[i];
        m[i+1-a[i]]++;
    }

    ll ans=0;
    rep(i,n){
        ans+=m[i+1+a[i]];
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 21032
#include <bits/stdc++.h>
using namespace std;
#define SPACE << " " <<
#define EXCEPTERROR cout << "-1" << endl;
#define rep(k,n)    for(int i=k; i<n;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define _for(a,b,c) for(ll  i=a; i<b;  i+=c)
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return (a+(b-1)/b);}
int main(void){
    string s;
    cin >> s;
    cout << (s=="ABC"? "ARC":"ABC") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int dp[1005][1005];
int main(){
	cin>>s1>>s2;
	for(int i=1;i<=s1.length();i++)dp[i][0]=i;
	for(int i=1;i<=s2.length();i++)dp[0][i]=i;
	for(int i=0;i<s1.length();i++){
		for(int j=0;j<s2.length();j++){
			dp[i+1][j+1]=dp[i][j]+(s1[i]!=s2[j]);
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j+1]+1);
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i+1][j]+1);
		}
	}
	cout<<dp[s1.length()][s2.length()]<<"\n";
	return 0;
}


Measured memory_bytes: 7124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> vec(n, 0);
  for(int i = 0; i < n; ++i)cin>>vec[i];
  int r = vec[0];
  int res = 0;
  for(int i = 0; i < n; ++i){
    r = min(r, vec[i]);
    if(vec[i] <= r){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for (ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define be begin
#define sz(a) (ll)(a.size())
#define INF 1e18
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

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

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }


void solve(ll T){
	ll k;
	cin>>k;
	ve<ll>ar(k);
	lr(k) cin>>ar[i];
	if(ar[k-1]!=2){
		cout << "-1\n";
		return;
	}
	ll mn=ar[k-1], mx=2*ar[k-1]-1;
	for(ll i=k-2;i>=0;i--){
		ll a=mn/ar[i]+(mn%ar[i]!=0);
		if(a*ar[i]>mx){
			cout << "-1\n";
			return;
		}
		ll b=mx/ar[i];
		mn=a*ar[i];
		mx=b*ar[i]+ar[i]-1;
	}
	cout << mn << " " << mx << "\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}

Measured memory_bytes: 3944
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var l = Console.ReadLine().Split(' ')
        .Select(x => long.Parse(x)).ToArray();
        var n = l[0]; var k = l[1]; var q = l[2];
        var jo = new long[n].Select(x => k).ToArray();
        var al = new List<int>();
        for (var i = 0; q > i; i++) {
            var per = int.Parse(Console.ReadLine());
            jo[--per]++;
        }
        jo = jo.Select(x => x - q).ToArray();
        for (var i = 0; n > i; i++) {
            if (jo[i] > 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 32600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.emplace_back(tmp);
	}
	int x = 1;
	int cnt = 0;
	REP(i, n) {
		if (a[i] == x) {
			x++;
			cnt++;
		}
	}
	if (cnt == 0)cnt = n + 1;
	cout << n - cnt;
}

Measured memory_bytes: 1400
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(auto &x : a){
        cin >> x;
    }
    for(auto &x : b){
        cin >> x;
    }
    vector<pair<ll, int>> ok, nk;
    for(int i = 0; i < n; i++){
        if(a[i] >= b[i]){
            ok.PB(MP(a[i], i));
        }else{
            nk.PB(MP(a[i], i));
        }
    }
    ll ans = SZ(nk);
    if(SZ(nk) == 0){
        cout << 0;
        return 0;
    }
    sort(ALL(ok), [&](pair<ll, int> p1, pair<ll, int> p2){
        return abs(p1.F - b[p1.S]) > abs(p2.F - b[p2.S]);
    });
    sort(ALL(nk), [&](pair<ll, int> p1, pair<ll, int> p2){
        return abs(p1.F - b[p1.S]) < abs(p2.F - b[p2.S]);
    });
    ll sum = 0;
    for(auto &x : nk){
        ll extra = abs(x.F - b[x.S]);
        sum += extra;
    }
    ll csum = 0;
    int cnt = 0;
    for(auto &x : ok){
        csum += abs(x.F - b[x.S]);
        cnt++;
        if(csum >= sum){
            break;
        }
    }
    if(csum >= sum){
        cout << ans + cnt;
    }else{
        cout << -1;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
const int mod=1e9+7;
int n,m,dp[N][N];
char c[N][N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>c[i][j];
		}
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(c[i][j]=='#')continue;
			dp[i][j]+=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, p, N);
  vi a(N);
  rep(i, 0, N) a[i] = i + 1;
  int ans = 0;
  rep(i, 0, N - 1) {
    if (p[i] == a[i]) {
      swap(a[i], a[i + 1]);
      ans++;
    }
  }
  rrep(i, N, 1) {
    if (p[i] == a[i]) {
      swap(a[i], a[i - 1]);
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 1024
MOD = int(1e9+7)
def add(x, y):
    return ((x%MOD + MOD) % MOD + (y%MOD + MOD) % MOD) % MOD

s = input()
dp = [[0] * 13 for _ in range(len(s)+1)]
dp[0][0] = 1 
mul = 1
for i in range(len(s)):
    if s[-(i+1)] == "?":
        for k in range(10):
            for j in range(13):
                idx = (mul*k + j)%13
                dp[i+1][idx] = add(dp[i+1][idx], dp[i][j])
    else:
        k = int(s[-(i+1)])
        for j in range(13):
            idx = (mul*k + j)%13
            dp[i+1][idx] = add(dp[i+1][idx], dp[i][j])
    mul = mul * 10 % 13 
print(dp[len(s)][5])


Measured memory_bytes: 62428
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

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

void sieve(vector<bool> &isPrime, int n) {
    isPrime.resize(n + 1, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i * i <= n; ++i) {
        if (isPrime[i]) {
            for (int j = i * i; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int &x : a)
        cin >> x;
    for (int &x : b)
        cin >> x;
    vector<int> perm(n);
    for (int i = 0; i < n; ++i) {
        perm[i] = i + 1;
    }

    int A, B, i = 1;
    do {
        bool f = true;
        for (int i = 0; i < n; ++i) {
            if (perm[i] != a[i]) {
                f = false;
                break;
            }
        }
        if (f)
            A = i;
        f = true;
        for (int i = 0; i < n; ++i) {
            if (perm[i] != b[i]) {
                f = false;
                break;
            }
        }
        if (f)
            B = i;
        ++i;
    } while(next_permutation(perm.begin(), perm.end()));

    cout << abs(A - B) << '\n';
}

Measured memory_bytes: 256
N = int(input())
S = input()

# 長さが奇数ならFalse
if len(S)%2 != 0:
    print("No")
    exit()

#print(S[0:int(len(S)/2)], S[int(len(S)/2):len(S)])
if S[0:int(len(S)/2)] == S[int(len(S)/2):len(S)]: print("Yes")
else: print("No")

Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A < C && C < B) || (B < C && C < A))cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import Data.Functor( (<$>))
import Control.Monad( replicateM)
import Data.List( transpose)

main = do
    let
	readLine = (read <$>) . words <$> getLine

    [n,m,l] <- readLine
    matrixA <- replicateM n readLine
    matrixB <- replicateM m readLine
    let
	rowXcolumn row transCol = sum $ zipWith (*) row transCol

	rowCalc rowA = (rowXcolumn rowA) <$> (transpose matrixB)

	matrixC = rowCalc <$> matrixA

	printListLn list = do
		putStr . unwords $ show <$> list
		putStrLn ""

    printListLn `mapM_` matrixC



Measured memory_bytes: 12360
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int cnt=0,two=0;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if(x%4==0)cnt++;
    if(x%2==0 && x%4!=0)two++;
  }
  two--;
  if(two>0)n-=two;
  if(cnt>=n/2)puts("Yes");
  else puts("No");
}


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

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

  
  for(int i=0;i<(int)(s.size()-1);i++){
    if(s[i]=='C'){
      for(int j=i+1;j<(int)s.size();j++){
        if(s[j]=='F'){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  
  cout<<"No"<<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++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

int main(){
  int A, B;
  cin >> A >> B;

  if (A > 12){
    cout << B << endl;
  }
  else if (A > 5){
    cout << B / 2 << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  
}

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

int main(void) {
 while(1) {
   int H {};
   int W {};
   cin >> H >> W;

   if (H == 0 && W == 0) {
       break;
   }

   for(int i = 0; i < H; i++){
     for(int j = 0; j < W; j++){
       cout << "#";
     }
     cout << "\n";
   }
   cout << "\n";
 }
 return 0;
}


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

char arr[10][10];

char brr[10][10];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 1;i <= a;i ++) {
        for(int j = 1;j <= b;j ++) {
            cin >> arr[i][j];
        }
    }
    int ans = 0;
    for(int i = 0;i <= (1<<a)-1;i ++) {
        for(int j = 0;j <= (1<<b)-1;j ++) {
            for(int ii = 1;ii <= a;ii ++)
                for(int jj = 1;jj <= b;jj ++)
                    brr[ii][jj] = arr[ii][jj];
            for(int ii = 1;ii <= a;ii ++) {
                for(int jj = 1;jj <= b;jj ++) {
                    if((i>>(ii-1))&1 || (j>>(jj-1))&1) brr[ii][jj]='.';
                }
            }
            int cnt = 0;
            for(int ii = 1;ii <= a;ii ++)
                for(int jj = 1;jj <= b;jj ++)
                    if(brr[ii][jj] == '#') cnt ++;
            if(cnt == c) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = input()
r = b = 0
for i in s:
    if i == '1':
        b += 1
    else:
        r += 1
print(min(r, b)*2)


Measured memory_bytes: 5332
#include <iostream>
#include <algorithm>
using namespace std;
const int num = 1001,num1 = 10000, INF = 2000000000;
int n, a[num], b[num], c[num1], tf[num], s = INF;
inline int mini() {
    int an = 0;
    int cu = 0;
    for (int i = 0; i < n; i++) {
        if (tf[i]) continue;
        cu = i;
        int m = INF;
        int sum = 0;
        int cnt = 0;
        while (true) {
            tf[cu] = 1;
            int v = a[cu];
            cnt++;
            m = min(v, m);
            sum += v;
            cu = c[v];
            if (tf[cu]) break;
        }
        an += min(sum + m*(cnt - 2), sum + m*(cnt - 2) + 2 * (m + s) - (m - s)*(cnt - 1));
    }
    return an;
}
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s = min(a[i], s);
        b[i] = a[i];
        tf[i] = 0;
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++) 
        c[b[i]] = i;
    int ans = mini();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3180
N = gets
A = gets.split.map(&:to_i)
if A.include?(0)
  puts 0
else
  m = 1
  A.each do |a|
    m *= a.to_i
    if m > 1_000_000_000_000_000_000
      m = -1
      break
    end
  end
  puts m
end

Measured memory_bytes: 21664
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e5+9;
const int mod=10000;
const double ep=1e-7;
using namespace std;
const double pi=acos(-1);
int main()
{
	double n;
	scanf("%lf",&n);
	printf("%.10f\n",2*pi*n);
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef pair<string, int> P;

void solve(void){
	int N, Q;
	cin >> N >> Q;
	queue <P> q;
	rep(N, i) {
		string name; int t;
		cin >> name >> t;
		q.push(P(name, t));
	}
	int acct = 0;
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		if (p.snd <= Q) {
			acct += p.snd;
			cout << p.fst << ' ' << acct << endl;
			continue;
		}
		p.second -= Q;
		acct += Q;
		q.push(p);
	}
}

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



Measured memory_bytes: 6204
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>

using namespace std;
using ull = unsigned long long;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


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


int main() {
	ll N, M;
	cin >> N >> M;

#if 1
	map<ll, ll>A;
	for (size_t i = 0; i < N; i++) {
		ll a = 0;
		cin >> a;
		A[a]++;
	}

	for (size_t i = 0; i < M; i++) {
		ll b, c;
		cin >> b >> c;
		A[c]+= b;
	}

	ll sum = 0;
	auto it = rbegin(A);
	for (size_t i = 0; i <= N;) {
		auto kvp = *it;
		if (kvp.second + i <= N) {
			sum += kvp.first * kvp.second;
			i += kvp.second;
			it++;
		} else {
			auto kosu = N - i;
			sum += kvp.first * kosu;
			break;
		}
	}
	cout << sum << endl;

#endif

#if 0
	deque<ll> A(N);
	for (size_t i = 0; i < N; i++) {
		cin >> A[i];
	}


	vector<ll> B(M), C(M);
	for (size_t i = 0; i < M; i++) {
		cin >> B[i] >> C[i];
	}
	sort(ALL(A));


	for (size_t i = 0; i < M; i++) {
		auto it = lower_bound(begin(A), end(A), C[i]);

		auto dist = it - begin(A);

		if (dist == 0) {
			continue;
		}
		auto kosu = min((ll)dist , B[i]);
		
		// kosuだけ追加する　追加してもソート済みのままとなっている
		for (size_t j = 0; j < kosu; j++) {
			it = A.insert(it, C[i]);
		}
		for (size_t j = 0; j < kosu; j++) {
			A.pop_front();
		}

	}
	const ll ans = accumulate(ALL(A), 0LL);
	cout << ans << endl;
#endif


	return 0;
}

Measured memory_bytes: 12800
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>

#define INF 2000000000
#define MOD
using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("inout.txt", "w", stdout);
    int n;
    int arr[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int ans = INF;
    for (int i = arr[0]; i <= arr[n - 1]; i++) {
        int curAns = 0;
        for (int j = 0; j < n; j++) {
            curAns += (arr[j] - i) * (arr[j] - i);
        }
        ans = min(ans, curAns);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    H, W, D = map(int, input().split())
    A = [None] * (H*W)
    for i in range(H):
        s = list(map(int, input().split()))
        for j in range(W):
            A[s[j]-1] = (i,j)

    # print(A)
    costs = [0]*(H*W)
    for i in range(D):
        j = H*W-1-i
        while j-D >= 0:
            costs[j-D] = costs[j] + abs(A[j][0]-A[j-D][0]) + abs(A[j][1]-A[j-D][1])
            j -= D
    
    Q = int(input())
    for i in range(Q):
        L, R = map(lambda x: int(x)-1, input().split())
        print(costs[L]-costs[R])

if __name__ == "__main__":
    main()


Measured memory_bytes: 19664
#include "iostream"
#include "algorithm"
#include "string"
#include "set"
#include "vector"
#include "queue"
#include "iomanip"
using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;
	vector<long long int>v(N+1);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	vector<vector<long long int>>dp(M + 1, vector<long long int>(N + 2));
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		vector<vector<long long int>>ddp(M + 1, vector<long long int>(N + 2));
		for (int j = 0; j <= M; j++) {
			for (int k = 0; k <= N + 1; k++) {
				if (k) {
					if (j + v[i] <= M) {
						ddp[j + v[i]][k] += dp[j][k];
					}
					ddp[j][k] += dp[j][k];
				}
				else {
					if (j + v[i] <= M) {
						ddp[j + v[i]][k] += dp[j][k];
					}
					ddp[j][i] += dp[j][k];
				}
			}
		}
		dp = ddp;
		for (int j = 0; j <= M; j++) {
			for (int k = 0; k <= N + 1; k++) {
				dp[j][k] %= MOD;
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j < N + 1; j++) {
			if (i + v[j] > M||!j) {
				ans += dp[i][j];
				ans %= MOD;
			}
		}
	}

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


Measured memory_bytes: 35276
def sum_solve(d):
    result = 0
    for k, v in d.items():
        result += v * (v-1) / 2
    return int(result)


def solve(sum_d, d, except_num):
    num = d[except_num]
    result = sum_d - num * (num-1)/2 + (num-1) * (num-2) / 2
    return int(result)


N = int(input())
A = list(map(int, input().split()))

d = {}

for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

sum_d = sum_solve(d)
# print(sum_d)

for i, a in enumerate(A):
    print(solve(sum_d, d, a))


Measured memory_bytes: 86348
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    ll a[n];
    ll ans = 0;
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
        if(((i+1) & 1) && (a[i] & 1))
        {
            ans++;
        }
    }
    cout<<ans<<'\n';   
}

Measured memory_bytes: 3608
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int n; cin >> n;
  int v[n], c[n];
  rep(i, n) cin >> v[i]; rep(i, n) cin >> c[i];

  int ans = 0;
  rep(i, n){
    if (v[i] > c[i]) ans += (v[i] - c[i]);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
p_list = []
s_list = []
ac_list = [0] * (n + 1)
ac, wa = 0, 0
if m == 0:
    print(0, 0)
else:
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        p_list.append(p)
        s_list.append(s)
        if s == "WA":
            if ac_list[p] == 0:
                wa += 1
            else:
                continue
        elif s == "AC":
            if ac_list[p] == 0:
                ac += 1
                ac_list[p] = 1
            else:
                continue
    for i in reversed(p_list):
        if ac_list[i] == 0:
            wa -= 1
    print(ac, wa)

Measured memory_bytes: 14236
//Bismillahir rahmanir Rahim
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long int n,x,s,i,sum=0;

    string st;
    cin >> st;
    s=st.size();
    if(st[0]=='48' && s==1)
    {
        cout << "Yes\n";
        return 0;
    }
    for(i=0;i<s;i++)
    {
       sum=sum+(st[i]-48);
    }
    if(sum%9==0)
    {
        cout << "Yes\n";
    }
    else if(sum%9!=0)
    {
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3720
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
  long long int n;cin>>n;
  if((n%10)==3)
    cout<<"bon"<<"\n";
  else if((n%10)==0 || (n%10)==1 || (n%10)==6 || (n%10)==8)
    cout<<"pon"<<"\n";
  else
     cout<<"hon"<<"\n";
}  

Measured memory_bytes: 3664
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  input()
  v = input().strip()
  s = 1

  for a, b in zip(v[:-1], v[1:]):
    if a != b:
      s += 1

  print(s)


if __name__ == '__main__':
  main()


Measured memory_bytes: 40944
#include<iostream>
 
 
using namespace std;
 
int cnt;
 
#define MAX 1000000
 
void insertionSort(int A[],int n,int g){
    int v,j;
    for(int i=g;i<n;i++){
        v=A[i];
        j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}
 
void shellSort(int A[],int n){
    cnt=0;
    int G[MAX];
    int m=0;
    int h;
 
    for(h=1;h<n;h=3*h+1);
    h=(h-1)/3;
 
    while(h>1){
        G[m]=h;
        m++;
        h=(h-1)/3;
    }
    G[m]=1;
    m++;
 
    cout<<m<<endl;
    for(int i=0;i<m-1;i++){
        cout<<G[i]<<" ";
    }
    cout<<G[m-1]<<endl;
 
    for(int i=0;i<m;i++){
        insertionSort(A,n,G[i]);
    }
}
 
int main(){

    std::ios_base::sync_with_stdio(false);

    int n;
    int A[MAX];
 
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
 
    shellSort(A,n);
    cout<<cnt<<endl;
 
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 5108
import sys
def input(): return sys.stdin.readline().strip()

def main():
    c = input()
    if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':
        print("vowel")
    else:
        print("consonant")



if __name__ == "__main__":
    main()


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 3e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e12;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes";
    }
    else cout << "No";
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  string s; cin >> s;
  int k = s.size();
  int t = 0;
  REP(i, s.size()) {
    if (s[i] == 'o') t++;
  }

  if (t + (15 - k) >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

typedef pair<int,int> pii;
typedef pair<double,double > pdd;
typedef pair<int,pii > pipdd;
typedef pair<int,double> pid;
typedef pair<pii,pdd> ppiipdd;

typedef pair<double,int> pdi;

vector<ppiipdd> V;
vector<pid> G[1010];

int N;
double sx,sy,gx,gy;
double D[1010];

int main()
{
    scanf("%lf%lf%lf%lf",&sx,&sy,&gx,&gy);
    scanf("%d",&N);
    for(int i = 0; i < N + 2; i++)
    {
        D[i] = -1;
    }
    V.push_back(make_pair(make_pair(N,0),make_pair(sx,sy)));
    V.push_back(make_pair(make_pair(N + 1,0),make_pair(gx,gy)));
    for(int i = 0; i < N; i++)
    {
        double x,y;
        int r;
        scanf("%lf%lf%d",&x,&y,&r);
        V.push_back(make_pair(make_pair(i,r),make_pair(x,y)));
    }
    for(int i = 0; i < V.size(); i++)
    {
        for(int j = i; j < V.size(); j++)
        {
            double x = (V[i].second.first - V[j].second.first) * (V[i].second.first - V[j].second.first);
            double y = (V[i].second.second - V[j].second.second) * (V[i].second.second - V[j].second.second);
            double length = max(0.0,sqrt(x + y) - (double)V[i].first.second - (double)V[j].first.second);
            G[V[i].first.first].push_back(make_pair(V[j].first.first,length));
            G[V[j].first.first].push_back(make_pair(V[i].first.first,length));
        }
    }
    priority_queue<pdi ,vector<pdi>,greater<pdi> >  Q;
    Q.push(make_pair(0,N));
    while(Q.size())
    {
        pdi now = Q.top();
        Q.pop();
        if(D[now.second] != -1)
        {
            continue;
        }
        D[now.second] = now.first;
        for(int i = 0; i < G[now.second].size(); i++)
        {
            Q.push(make_pair(now.first + G[now.second][i].second,G[now.second][i].first));
        }
    }
    printf("%.10lf\n",D[N + 1]);
    return 0;
}


Measured memory_bytes: 35048
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N;
	cin >> N;
	for (int i = N; i < 1000; i++) {
		string S = to_string(i);
		bool ans = true;
		for (int j = 0; j < S.size() - 1; j++) {
			if (S[j] != S[j + 1]) {
				ans = false;
				break;
			}
		}
		if (ans) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int N, T, A;
	cin >> N >> T >> A;
	vector<int>H(N);
	double ans = A + 100000;
	int num = 0;
	rep(i, N) {
		cin >> H[i];
		double temp = T - 0.006 * H[i];
		if (abs(ans - A) >= abs(temp - A)) {
			ans = temp;
			num = i+1;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	map<int, int>mp;
	vector<int>A(N);
	rep(i, 0, N) {
		cin >> A[i];
		mp[A[i]] = i + 1;
	}
	int ans = 0;
	sort(all(A));
	rep(i, 0, N) {
		if ((i + 1) % 2 != mp[A[i]] % 2)++ans;
	}
	cout << ans / 2 << "\n";

	return 0;
}

Measured memory_bytes: 8296
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll N, D, X, Y;
  double d;
  int ans=0;
  cin >> N >> D;
  
  for(int i = 0; i < N; i++){
    cin >> X >> Y;
    d = sqrt(X*X + Y*Y);
    if(D >= d){
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
import java.util.*;

public class Main{
    static int[] HASH_BASE = {40320, 5040, 720, 120, 24, 6, 2, 1, 1};
    static int hashOfNextPerm = 0;
    static int[] n = new int[9];


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int T = sc.nextInt();

        for (int t=0; t<T; t++) {
            hashOfNextPerm = 0;
            for (int i=0; i<9; i++) n[i] = sc.nextInt();
            for (int i=0; i<9; i++) {
                char c = sc.next().toCharArray()[0];
                if (c == 'G') n[i] += 10;
                else if (c == 'B') n[i] += 20;
            }
            
            Arrays.sort(n);

            int[] perm;
            while ((perm = nextPermutation()) != null) {
                if (judge(perm)) {
                    System.out.println("1");
                    break;
                }
            }
            if (perm == null) System.out.println("0");
        }
    }

    static boolean judge(int[] p) {
        return isSet(n[p[0]], n[p[1]], n[p[2]])
                && isSet(n[p[3]], n[p[4]], n[p[5]])
                && isSet(n[p[6]], n[p[7]], n[p[8]]);
    }

    static int tmp;
    static boolean isSet(int a, int b, int c) {
        if (a == b && b == c) return true;
        else if (a+1 == b && b+1 == c) return true;
        else return false;
    }

    static int[] nextPermutation() {
        int[] ret = new int[9];

        List<Integer> list = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8));
        int n = hashOfNextPerm++;

        if (n == 362880) return null;

        for (int i=0; i<9; i++) {
            ret[i] = list.get(n / HASH_BASE[i]);
            list.remove(n / HASH_BASE[i]);
            n %= HASH_BASE[i];
        }

        return ret;
    }
}

Measured memory_bytes: 284208
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int mod = 998244353;

ll power(ll a,ll n){
    if(n == 0) return 1;
    ll s = power(a,n/2);
    s = (s * s) % mod;
    if(n % 2) s = (s * a) % mod;
    return s;
}
int main() 
{
    i_os;
    ll n,m,k;
    cin>>n>>m>>k;
    ll fact[n+1],modinv[n+1];
    fact[0] = 1,modinv[0] = 1;
    REP(i,1,n+1){
        fact[i] = (fact[i-1] * i) % mod;
    }
    REP(i,1,n+1){
        modinv[i] = (modinv[i-1] * power(i,mod-2)) % mod;
    }

    ll ans = 0;
    ll val = 1;
    REP(i,0,n-1){
        val = (val * (m-1)) % mod;
    }
    ll val1 = power(m-1,mod-2);

    REP(i,0,k+1){
        if(n-1-k < 0) continue;

        ll p1 = (((fact[n-1]*modinv[i]) % mod)* modinv[n-1-i]) % mod;

        ll p = (((m*p1) % mod) * val) % mod;
        ans = (ans + p) % mod;
        val = (val * val1) % mod;
    }
    if(m == 1){
        if(n-1-k == 0){
            ans = 1;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6784
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static class Period {
        int s;
        int e;

        public Period(int s, int e) {
            this.s = s;
            this.e = e;
        }
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), H = scanner.nextInt();
        scanner.nextLine();
        int[][] attack = new int[N][2];
        int max = 0;
        for (int i = 0; i < N; i++) {
            attack[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            max = Math.max(max, attack[i][0]);
        }

        Arrays.sort(attack, Comparator.comparingInt(x -> -x[1]));
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (attack[i][1] < max) {
                break;
            }
            cnt++;
            H -= attack[i][1];
            if (H <= 0) {
                break;
            }
        }

        if (H > 0) {
            cnt += H % max == 0 ? H / max : H / max + 1;
        }

        System.out.println(cnt);
    }

}

Measured memory_bytes: 150116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    int ans = 10005;
    rep(i, s.size() - t.size() + 1)
    {
        int cost = 0;
        rep(j, t.size())
        {
            // cout << s[i + j] << "," << t[j] << " ";
            if (s[i + j] != t[j])
                cost++;
        }
        // cout << endl;
        ans = min(ans, cost);
    }

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

Measured memory_bytes: 3600