akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a;
    string s;
    cin>>a;
    cin>>s;

    a<3200?cout<<"red\n":cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,m; cin >> n >> m;
  cout << (m-1)*(n-1) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
Time = list(map(int, input().split(' ')))
M = int(input())
Drink = []
for i in range(M):
    p, x = map(int, input().split(' '))
    tmp = Time[::]
    tmp.pop(p-1)
    s = sum(tmp) + x
    Drink.append(s)
for i in Drink:
    print(i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IO std::ios::sync_with_stdio(false);std::cin.tie(0)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define mk make_pair
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<'\n';
}



Measured memory_bytes: 3636
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::pair<std::pair<int32_t, int32_t>, int32_t> map[200];
std::multiset<int32_t> H;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		in >> map[i].first.first >> map[i].first.second;
		map[i].second = 0;
	}
	for (int32_t i = N; i < N*2; i++)
	{
		in >> map[i].first.first >> map[i].first.second;
		map[i].second = 1;
	}

	std::sort(map, map + N * 2);
	int32_t count = 0;
	for (int32_t i = 0; i < 2*N; i++)
	{
		if (map[i].second == 0) {
			H.insert(map[i].first.second);
		}
		else {
			auto iter = H.lower_bound(map[i].first.second);
			if (iter == H.begin()) { continue; }
			--iter;
			H.erase(iter);
			++count;
		}
	}
	out << count << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String b = sc.next();
        char res = ' ';
        switch (b.charAt(0)) {
            case 'A':
                res = 'T';
                break;
            case 'C':
                res = 'G';
                break;
            case 'G':
                res = 'C';
                break;
            case 'T':
                res = 'A';
                break;
        }

        System.out.println(res);
    }
}


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

int main() {
  string str; int q;

  cin >> str; cin >> q;

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

    if (cmd == "replace") {
      string p;
      cin >> p;

      str.replace(a, b-a+1, p);
    } else if (cmd == "reverse") {
      string sub = str.substr(a, b-a+1);
      reverse(sub.begin(), sub.end());
      str.replace(a, b-a+1, sub);
    } else if (cmd == "print") {
      cout << str.substr(a, b-a+1) << endl;
    }
  }

  return 0;
}



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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}


void solve(void)
{
  int n,m,l;
  cin>>n>>m>>l;
  Matrix<int> mat(n,vector<int>(n,INF));
  for (int i = 0; i < m; i++)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    if(c > l)continue;
    mat[a][b] = c;
    mat[b][a] = c;
  }
  for (int i = 0; i < n; i++)
  {
    mat[i][i] = 0;
  }
  warshall_floyd(mat);
  
  Matrix<int> mat2(n,vector<int>(n,INF));
  for (int i = 0; i < n; i++)
  {
    mat2[i][i] = 0;
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if(i == j) continue;
      if(mat[i][j] <= l)
      {
        mat2[i][j] = 1;
      }
    }
  }
  
   
  warshall_floyd(mat2);
  int q;cin>>q;
  for (int i = 0; i < q; i++)
  {
    int s,t;
    cin>>s>>t;
    s--;t--;
    int dist = mat2[s][t];
    if(dist >= INF)
    {
      cout<<-1<<endl;
      continue;
    }
    cout<<dist -1<<endl;
  }
  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int V, E;
std::vector< int > graph[112345];

const int INF = (1 << 30);

int dfnum[112345];

std::vector<int> res;

const uint32_t FLAG_ROOT = 0x00000001;
template<uint32_t flags = 0>
int dfs(int prev, int id, int depth) {
  dfnum[id] = depth;
  bool isArtPoint = false;
  int L = dfnum[id];
  int Nc = 0;
  for(int next : graph[id]) {
    if( next == prev ) continue;
    if( dfnum[next] != INF ) {
      L = std::min(L, dfnum[next]);
      continue;
    }
    int Lc = dfs<>(id, next, depth + 1);
    L = std::min(L, Lc);
    if( not ( flags & FLAG_ROOT ) and dfnum[id] <= Lc ) {
      isArtPoint = true;
    }
    Nc += 1;
  }
  if( ( flags & FLAG_ROOT ) and Nc >= 2 ) {
    isArtPoint = true;
  }
  if( isArtPoint ) {
    res.push_back(id);
  }
  return L;  
}

int main() {
  for(int& I : dfnum) I = INF;
  scanf("%d %d", &V, &E);
  for(int i = 0; i < E; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);
    graph[s].push_back(t);
    graph[t].push_back(s);
  }

  dfs<FLAG_ROOT>(-1, 0, 1);

  std::sort(res.begin(), res.end());
  for(int I : res) {
    printf("%d\n", I);
  }
  
  return 0;
}

Measured memory_bytes: 7652
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int E;

int calc2(){
  int ans = 5000000;
  REP(z, 100){
    int y = (int)(floor(sqrt(E - z))), x = E - y - z;
    if(y >= 0 && x >= 0){
      cout <<x <<", " <<y <<", " <<z <<", " <<x + y + z <<endl;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int calc(){
  int ans = 5000000;
  for(int z = 100; z >= 0; --z){
    if((int)(pow(z, 3)) > E) continue;
    for(int y = 1000; y >= 0; --y){
      int tmp = ((int)(pow(z, 3)) + (int)(pow(y, 2)));
      if(tmp > E) continue;
      int x = E - tmp;
      //return x + y + z;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int calc1(){
  int ans = 1e9 + 7;
  REP(y, 1001){
    if(y * y > E) continue;
    REP(z, 101){
      int tmp = (z * z * z + y * y);
      if(tmp > E) break;
      int x = E - tmp;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int main() {
  while(cin >>E && E) cout <<calc1() <<endl;
  //while(cin >>E && E) cout <<calc() <<endl;
  //while(cin >>E && E) cout <<calc2() <<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define MN 21
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char st[1050005];
int n,f[1<<MN][MN+1],K,nxt0[1<<MN],nxt1[1<<MN],p[1<<MN],Len,from,sum,g[1<<MN][2];
void dfs(int x,int s,int v)
{
	if(v<K) return;
	if(x>Len) Len=x,from=s;
	else if(x==Len) from=min(from,s);
	dfs(x+1,s<<1,v-g[s|(1<<x-1)][0]);
	dfs(x+1,s<<1|1,v-g[s|(1<<x-1)][1]);
}
int main()
{
	n=read();K=read();
	for(int i=0;i<=n;++i)
	{
		scanf("%s",st);
		for(int j=0;j<1<<i;++j) 
		{
			p[j|(1<<i)]=j;
			if(st[j]=='1') ++f[j|(1<<i)][i],++sum;
		}
	}
	int tot=1<<n+1;
	for(int j=1,hbit=0;j<tot;++j)
	{
		if(j>=(1<<hbit+1)) ++hbit;
		int nx0=-1,nx1=-1;
		for(int k=hbit-1;k>=0;--k)
		{
			if(nx0<0&&!(j&(1<<k))) nx0=k;	
			if(nx1<0&& (j&(1<<k))) nx1=k;
		}
		nxt0[j]=nx0;nxt1[j]=nx1;
	}
	for(int i=tot;--i;) for(int j=n;~j;--j) if(f[i][j])
	{
		int r=(i&((1<<j)-1))|(1<<j);
		if(nxt0[r]>=0) f[((i>>j)<<nxt0[r]+1)|(i&((1<<nxt0[r]+1)-1))][nxt0[r]]+=f[i][j];
		else g[i>>j][0]+=f[i][j];
		if(nxt1[r]>=0) f[((i>>j)<<nxt1[r]+1)|(i&((1<<nxt1[r]+1)-1))][nxt1[r]]+=f[i][j];
		else g[i>>j][1]+=f[i][j];
	}
	dfs(1,0,sum);
	for(int i=Len-2;i>=0;--i) printf("%d",bool(from&(1<<i)));
	return 0;
}



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

typedef long long LL;

const int N=200,C=62;

int n;
char s[N+9];
LL a[N+9];
int id[C+9];

bool Insert(int x){
  for (int i=C-1;i>=0;--i)
	if (a[x]>>i&1){
	  if (!id[i]) {id[i]=x;return 1;}
	  a[x]^=a[id[i]];
	}
  return 0;
}

void work(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
  scanf("%s",s+1);
  for (int i=0;i<C;++i) id[i]=0;
  for (int i=n;i>=1;--i)
    if (Insert(i)&&s[i]-'0') {puts("1");return;}
  puts("0");
}

int main(){
  int T;
  scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int H,W;
    cin >> W >> H;
    while(H!=0 || W!=0){
        int c[H][W][2]; REP(i,H)REP(j,W)REP(k,2) c[i][j][k] = 1;
        REP(i,H-1){
            REP(j,W-1) cin >> c[i][j][0];
            REP(j,W) cin >> c[i][j][1];
        }
        REP(j,W-1) cin >> c[H-1][j][0];

        int d[H][W]; REP(i,H)REP(j,W) d[i][j] = INT_INF;
        queue<tpl> q; q.push(tpl(0,0,1));
        while(q.size()){
            tpl t = q.front(); q.pop();
            int x = get<0>(t), y = get<1>(t), cost = get<2>(t);
            if(chmin(d[x][y], cost)){
                if(x && c[x-1][y][1]==0) q.push(tpl(x-1,y,cost+1));
                if(y && c[x][y-1][0]==0) q.push(tpl(x,y-1,cost+1));
                if(x<H-1 && c[x][y][1]==0) q.push(tpl(x+1,y,cost+1));
                if(y<W-1 && c[x][y][0]==0) q.push(tpl(x,y+1,cost+1));
            }
        }
        int ans = d[H-1][W-1];
        cout << (ans!=INT_INF ? ans : 0) << en;
        cin >> W >> H;
    }
    return 0;
}


Measured memory_bytes: 3132
#include<cstdio>
#include<cstring>
#include<bitset>
#include<algorithm>
using namespace std;
const int N=1e5+88;
int p[N],tot,sum[N];
bool ok[N];
void init(){
	for(int i=2;i<N;++i) {
		if(!ok[i]) p[tot++]=i;
		for(int j=0;j<tot&&i*p[j]<N;++j) {
			ok[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}
int main(){
	init();
	sum[1]=0;
	ok[1]=1;
	for(int i=2;i<=100000;++i) sum[i]=sum[i-1]+((ok[i]==0&&ok[(i+1)/2]==0)?1:0);
	int q;
	scanf("%d",&q);
	int l,r;
	for(int i=1;i<=q;++i) {
		scanf("%d%d",&l,&r);
		printf("%d\n",sum[r]-sum[l-1]);
	}
}


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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define COUNT2(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll gcd(ll x, ll y) {
  if (x < y) swap(x, y);
  return y ? gcd(y, x%y) : x;
}

int main(void) {
  ll t, a, b, c, d;
  cin >> t;
  rep(i, t) {
	cin >> a >> b >> c >> d;
	if (a < b || b > d) {
	  cout << "No" << endl;
	  continue;
	}
	if (c >= b) {
	  cout << "Yes" << endl;
	  continue;
	}

	a %= b;
	ll g  = gcd(b, d);

	ans = a + ((c - a) / g + 1)*g;
	ans %= b;
	if (ans > c) cout << "No" << endl;
	else cout << "Yes" << endl;

  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,i,e,x,t,ans=0,mn=5e18,ix;
    ix=5; ll a[ix+2]={0};
    cin >> n;
    for(i=0;i<ix;i++){
        cin >> a[i];
        e = a[i];
        if(e<mn)mn = e;
        if(i<1){ans=n/e; if(n%e)ans++; }
        else{
            if(mn==e){
                x=n/e; if(n%e)x++;
                t = ans - i;
                t = n - (e*t);
                x = t/e; if(t%e)x++;
                ans+=x;
            }
            else ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  int h[n];

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

  for (int i = 0; i < n-1; i++) {
    //cout << h[i] << " " << h[i+1] << endl;
    if (h[i+1] > h[i]) {
      h[i+1] -= 1;
    }
    if (h[i+1] < h[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
line = readlines
numlines = line[1]

nums = numlines.split(' ')

ans = 1

if nums.length == 1
else
  min = nums[0].to_i
  nums.each do |num|
    if num.to_i < min
      ans += 1
      min = num.to_i
    end
  end
end

puts ans


Measured memory_bytes: 13700
#include <bits/stdc++.h>
#define fast_io                                                                \
    ios::sync_with_stdio(false);                                               \
    cin.tie(0)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = (int)1e3 + 5;
const int M = (int)1e5 + 5;
const int mod = (int)1e9 + 7;
const double esp = 1e-8;
int T;
//------------------------------
char s[N];
int main() {
    fast_io;
    cin >> s;
    int len = strlen(s);
    if (s[len - 1] == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << 's' << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int rick[256];

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	
	ini(n);
	vi morty(n+1);
	int one = 0;
	FOR(i,0,n){
		ini(x);
		if(x%2 == n%2)one = 1;
		morty[x]++;
	}
	if(morty[0] == 2)one =1;
	int tmp = 1;
	for(int i = n-1;i>=0;i-=2){
		if(morty[i] == 0 or morty[i] >2)one = 1;
		tmp*=morty[i];
		tmp%=1000000007;
	}
	tmp+=1000000007;
	tmp%=1000000007;
	if(one)out(0);
	else out(tmp);








	return 0;
}


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

void Main()
{
    // x * 0.08 = A
    // x * 0.1 = B

    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 20000; i++)
    {
        if(b == (int)(0.1*i) && a == (int)(0.08*i))
        {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

int main(void){
    int n;
    int a[100];
    int i,j,k;
    int tmp;
    
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    
    for(i=0;i<n-1;i++)cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    
    for(i=1;i<n;i++){
        tmp=a[i];
        j=i-1;
        while(j>=0&&a[j]>tmp){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=tmp;
        
        for(k=0;k<n-1;k++)cout<<a[k]<<" ";
        cout<<a[n-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int> vals(n);
	for (int i = 0;i<n; i++){
		char c;
		cin>>c;
		if (c=='R'){
			vals[i]=0;
		} else if (c=='G'){
			vals[i]=1;
		} else {
			vals[i]=2;
		}
	}
	vector<vector<ll>> sufsum(3,vector<ll>(n+1,0));
	for (int i = n-1; i>=0; i--){
		for (int j = 0; j<3; j++){
			sufsum[j][i]=sufsum[j][i+1];
			if (vals[i]==j){
				sufsum[j][i]++;
			}
		}
	}
	/*for (int i = 0; i<3; i++){
		for (int j = 0; j<n; j++){
			cout<<sufsum[i][j]<<" ";
		}cout<<endl;
	}*/
	ll s = 0;
	for (int a = 0; a<n-2; a++){
		for (int b = a+1; b<n-1; b++){
			if (vals[a]==vals[b]){continue;}
			//a!=b
			int valuse = 0;
			for (int c = 0; c<3; c++){
				if (vals[a]!=c&&vals[b]!=c){
					valuse=c;
					break;
				}
			}
			s+=sufsum[valuse][b+1];
			if (b+(b-a)<n&&vals[(b+(b-a))]==valuse){
				s--;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

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

int N;
vector<int> A, C;

void input_init(void) {
	cin >> N;
	A.resize(N + 1, 0);
	C.resize(N + 1, 0);
	for (int i = 2; i <= N; ++i)
		cin >> A[i];
}

void solve(void) {
	for (int i = 2; i <= N; ++i)
		++(C[A[i]]);
}

int main(void) {
	input_init();
	solve();
	for (int i = 1; i <= N; ++i)
		cout << C[i] << '\n';
	return 0;
}


Measured memory_bytes: 4780
//abc170_d.cpp
//Sun Jun 14 20:56:09 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	map<int,int> chofuku;
	for (int i=0;i<n;i++){
		cin >> a[i];
		auto itr = chofuku.find(a[i]);
		if (itr != chofuku.end()){
			chofuku[a[i]]++;
		}else {
			chofuku[a[i]] = 1;
		}
	}

	sort(a,a+n);

	int ans = 0;
	int is_prime[1000011];
	fill(is_prime,is_prime+1000010,1);
	for (int i=0;i<n;i++){
		int tmp = a[i];
		if(is_prime[tmp]){
			if (chofuku[tmp]!=INTINF){
				for (int j=2*tmp;j<=1000010;j+=tmp){
					is_prime[j] = 0;
				}
			}
			if (chofuku[tmp]==1){
				ans++;
			}else {
				chofuku[tmp] = INTINF;
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 17548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    string s;
    cin >> s;

    stack<char> st;
    int cnt = 0;
    for(auto c : s){
        if(c == 'S') st.push(c);
        else if(!st.empty()) st.pop();
        else ++cnt;
    }

    cout << cnt+st.size() << endl;



    return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc =new Scanner(System.in);
        
        String S = sc.nextLine();
        String P = sc.nextLine();
        int count=0,k=0,flag=0;
        
        for(int i=0;i<S.length();i++) {
        	
	     if(S.charAt(i) == P.charAt(0)) {
	    	 
	      for(int j=i;j<i+P.length();j++) {
	    	  
	       if(j<S.length())
		     if(S.charAt(j)==P.charAt(k)) count++;
		     else count+=0;
	       
		   else if(S.charAt(j-S.length())==P.charAt(k)) count++; 

	        k++;
	       }
	     
	      if(count==P.length()) flag=1;
	      
	      count=0;
	      k=0;
	     
	     }
	     
        }
	     
	    if(flag==1) System.out.println("Yes");
	    else System.out.println("No");
	     
        }
        
        
}


Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,s;
	cin>>n>>k>>s;
	vector<ll> a(n+1);
	FOR(i,1,k+1){
		a[i]=s;
	}
	FOR(i,k+1,n+1){
		if(s!=1e9) a[i]=s+1;
		else a[i]=1;
	}
	FOR(i,1,n+1){
		cout<<a[i]<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 2176
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_name,arg_index,arg_value):
        self.name = arg_name
        self.index = arg_index
        self.value = arg_value

    def __lt__(self,another):
        if self.value != another.value:
            return self.value > another.value
        else:
            return self.index < another.index

is_First = True

while True:
    N = int(input())
    if N == 0:
        break

    if is_First == False:
        print()

    table = []

    for i in range(N):
        tmp_name,win,lose,draw = map(str,input().split())
        table.append(Info(tmp_name,i,3*int(win)+int(draw)))

    table.sort()
    for i in range(N):
        print("%s,%d"%(table[i].name,table[i].value))


    is_First = False


Measured memory_bytes: 13888
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#define ll long long

const ll mod = (ll)1e9 + 7;

using namespace std;

signed main() {
	int n; cin >> n;

	ll ans = ((ll)n) * (n - 1) / 2;

	cout << ans << endl;

	return 0;
}

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)

Measured memory_bytes: 45244
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;





string S[2 * 10000];
int main() {
	cin >> N;

   unsigned long long sum = 0;
	for (ll i = 1; i * i < N; i++) {
		if (N % i == 0 && ((N / i) - 1) > i) {
			
			sum += (N / i) - 1;
		}
	}

	if (N == 2) {
		cout << 0 << endl;
		return 0;
	}

	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 384
a, b, k = map(int, input().split())
def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
A = cf(a, b)
A.sort(reverse = True)
print(A[k-1])

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,z,w;cin>>n>>z>>w;
  vector<int >a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(n==1)
    cout<<abs(a[0]-w)<<endl;
  else
    cout<<max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]))<<endl;
  return 0;
}

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

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::vector<unsigned> a(N);
  for(unsigned n=0; n<N; ++n)
  {
    std::cin >> a[n];
    --a[n];
  }
  
  unsigned c = 0;
  for(unsigned n=0; n<N; ++n)
  {
    if(a[a[n]] == n) ++c;
  }
  std::cout << (c >> 1) << std::endl;
  
  return 0;
}

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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main() {	
	int n;
	cin>>n;
	string s = to_string(n);
	if(cpresent(s, '7')) {
		cout<<"Yes";
	}
	else cout<<"No";
	
	return 0;
}


Measured memory_bytes: 3696
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[] cmd=s.split(" ");
		int n=Integer.valueOf(cmd[0]);
		int m=Integer.valueOf(cmd[1]);
		ArrayList<Integer>[] graph=new ArrayList[n+1];
		for(int i=0;i<=n;i++)
		{
			graph[i]=new ArrayList<>();
		}
		for(int i=0;i<m;i++)
		{
			cmd=br.readLine().split(" ");
			int x=Integer.valueOf(cmd[0]);
			int y=Integer.valueOf(cmd[1]);
			graph[x].add(y);
			graph[y].add(x);
		}
		Queue<Integer> q=new LinkedList<>();
		q.add(1);
		int[] bool=new int[n+1];
		bool[1]=1;
		int[] ans=new int[n+1];
		while(!q.isEmpty())
		{
			int x=q.poll();
			for(int i=0;i<graph[x].size();i++)
			{
				if(bool[graph[x].get(i)]==0)
				{
					bool[graph[x].get(i)]=1;
					ans[graph[x].get(i)]=x;
					q.add(graph[x].get(i));
				}
			}
		}
		System.out.println("Yes");
		for(int i=2;i<=n;i++)
		{
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 74636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int n;

	cin >> n;
	int ans = 0;
	if (n > 2)
	{
		vector<int> A(150000);
		for (int i=0; i<n; i++)
		{
			int in;
			cin >> in;
			A[in]++;
		}
		for (int i=0; i<n-2; i++)
		{
			int sum = A[i] + A[i+1] + A[i+2];
			ans = max(ans, sum);
		}
	}
	else if (n == 2)
	{
		int a, b;
		cin >> a >> b;
		abs(a-b) < 3 ? ans = 2 : ans = 1;
	}
	else
	{
		int a;
		cin >> a;
		ans = 1;
	}
	cout << ans << endl;
}


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

using namespace std;

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

  int arr[n][3];
  for(int i=0;i<n;i++)
  {
      for(int j=0;j<3;j++)
        cin>>arr[i][j];
  }

  int dp[n][3];
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];

  for(int i=1;i<n;i++)
  {
      for(int j=0;j<3;j++)
      {       if(j==1)
            dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
            else if(j==2)
                dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][0]);
            else
                dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
      }
  }

  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));





}


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


tot=0

for i in range(n):
	kl=min(a[i],b[i])

	b[i]-=kl
	tot+=kl
	a[i]-=kl

	kl=min(a[i+1],b[i])
	b[i]-=kl
	tot+=kl
	a[i+1]-=kl

print(tot)










Measured memory_bytes: 18624
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
public class Main {
	
	
	 
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
        
		long n = sc.nextLong();
		//long m = n;
		long ans = 0;
		long p = 2;
		long c = 1;
		long div;
		
		while(true) {
			div = (long)Math.pow(p, c);
			if(n%div == 0) {
				ans++;
				n /= div;
				c++;
				//System.out.println(n+" "+div);
				continue;
			}
			//System.out.println("Debug"+p);
			while(n%p == 0) {
				n/=p;
				//System.out.println("割った");
				//System.out.println(n);
			}
			
			p++;
			c = 1;
			
			if(p*p>n) {
				break;
			}
		}
		
		if(n!=1) {
			ans++;
		}
		
	    System.out.println(ans);
	}
}

Measured memory_bytes: 35624
#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 ll INF = 1000000000000000000;


int main() 
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	printf("%.10f ", (double)H * W / 2.0);
	if (x == (double)W / 2.0 && y == (double)H / 2.0) cout << 1 << endl;
	else cout << 0 << endl;

}


Measured memory_bytes: 3756
#include <iostream>

using namespace std;

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

  long long cnt1 = 0;
  long long sum1 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && sum1 + a[i] <= 0) {
      cnt1 += 1 - sum1 - a[i];
      sum1 = 1;
    } else if (i % 2 == 1 && sum1 + a[i] >= 0) {
      cnt1 += sum1 + a[i] + 1;
      sum1 = -1;
    } else {
      sum1 += a[i];
    }
  }

  long long cnt2 = 0;
  long long sum2 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && sum2 + a[i] >= 0) {
      cnt2 += sum2 + a[i] + 1;
      sum2 = -1;
    } else if (i % 2 == 1 && sum2 + a[i] <= 0) {
      cnt2 += 1 - sum2 - a[i];
      sum2 = 1;
    } else {
      sum2 += a[i];
    }
  }

  cout << min(cnt1, cnt2) << endl;
}


Measured memory_bytes: 1024
grs = 0 ; num = 0 ; tim = 0
while True:
	try:
		x = map(float,raw_input().split(','))
		a = x[0] * x[1]
		grs += int(a)
		num += x[1]
		tim += 1
		continue
	except: break
print grs
print int(round(float(num) / float(tim),0))

Measured memory_bytes: 4260
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int no=n,rev=0;
    while(n>0)
    {
        rev=rev*10+n%10;
        n/=10;
    }
    if(rev==no)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
def tentousu(a):
  ans=0
  for i in range(len(a)):
    for j in range(i+1,len(a)):
      if a[i]>a[j]:ans+=1
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
ini = lambda: int(input())
inl = lambda: list(map(int, input().split()))
ins = lambda: input().strip()
mod = 10**9 + 7

N = ini()
S = []
for i in range(N):
	S.append(ins())

import collections
cnt = collections.Counter(S)
max_c = max(cnt.values())
ans = []
for s, c in cnt.items():
	if c == max_c:
		ans.append(s)
for a in sorted(ans):
	print(a)


Measured memory_bytes: 35476
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = sc.nextInt();
        }
        for (int i = n-1; i >= 0; i--) {
            if (i == n-1) {
                System.out.printf("%d", ary[i]);
            } else {
                System.out.printf(" %d", ary[i]);
            }
        }
        System.out.printf("%n");
    }
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
string S[2200];
int l[2200][2200], r[2200][2200], u[2200][2200], d[2200][2200];
signed main() {
    cin >> H >> W;
    rep(i, H) { cin >> S[i]; }
    rep(i, H) {
        rep(j, W - 1) {
            if (S[i][j] == '#') { l[i][j + 1] = 0; }
            else { l[i][j + 1] = l[i][j] + 1; }
        }
        for (int j = W - 1; j > 0; j--) {
            if (S[i][j] == '#') { r[i][j - 1] = 0; }
            else { r[i][j - 1] = r[i][j] + 1; }
        }
    }

    rep(i, W) {
        rep(j, H - 1) {
            if (S[j][i] == '#') { u[j + 1][i] = 0; }
            else { u[j + 1][i] = u[j][i] + 1; }
        }
        for (int j = H - 1; j > 0; j--) {
            if (S[j][i] == '#') { d[j - 1][i] = 0; }
            else { d[j - 1][i] = d[j][i] + 1; }
        }
    }

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] != '#') { chmax(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1); }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 149760
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    const numbers = arg.slice(1, N+1);
    
    const map = [];
    
    for(let i in numbers) {
        let temp = numbers[i].split(" ").map(n=>parseInt(n));
        
        let number = temp[0];
        let amount = temp[1];
        
        map.push({number: number, amount: amount})
    }
    
    map.sort((a,b)=>a.number - b.number);
    
    let sum = 0;
    let i   = 0;
    
    while(sum < K) {
        sum += map[i].amount;
        i++;
    }
    
    console.log(map[i - 1].number);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 53544
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let a: Vec<usize> = parse!(it, n);
    let mut r = 0;
    let mut reds = std::collections::HashMap::<usize, usize>::new();
    let mut ret = 0usize;
    reds.insert(0, 1);
    for i in 0..n {
        let ri = (r + a[i]) % m;
        *reds.entry(ri).or_insert(0) += 1;
        ret += reds[&ri] - 1;
        r = ri;
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 14588
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u32> = procon_read();
	let k = v[0];
	let odd = k/2 + k%2;
	let even = k/2;
	println!("{}", odd*even);
}

Measured memory_bytes: 4352
#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 each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

#define bsf __builtin_ctzll
ll gcd(ll a, ll b) {
  // a = abs(a); b = abs(b);
  if (!a || !b) return a|b;
  int t = bsf(a|b); a >>= bsf(a);
  do { b >>= bsf(b); if (a > b) swap(a, b); b -= a;} while (b);
  return a << t;
}
ll lcm(ll x, ll y) { return x/gcd(x,y)*y;}


int main() {
  int n;
  scanf("%d",&n);
  ll ans = 1;
  rep(i,n) {
    ll x;
    scanf("%lld",&x);
    ans = lcm(ans,x);
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){

    int N;
    int pb[100001] = {};
    int temp = 0;
    scanf("%d", &N);
    for(int i=0; i < N; i++){
        scanf("%d", &temp);
        if(temp == i + 1){
            pb[i] = 1;
        }else{
            pb[i] = 0;
        }
    }
    pb[N] = 0;
    // printf("%d", N);
    // for(int i=0; i < N; i++){
    //     printf("%d", pb[i]);
    // }
    // printf("\n");

    int res = 0;
    int connTemp = 0;
    for(int i=0; i <= N; i++){
        if(pb[i] == 0){
            res += connTemp/2 + connTemp%2;
            connTemp = 0;
        }else{
            connTemp++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 512