akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[100010],b[100010];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i] >> b[i];
	reverse(a,a+n); reverse(b,b+n);
	
	ll pos=0;
	REP(i,0,n){
		pos+=(b[i]-(a[i]+pos)%b[i])%b[i];
	}
	
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;

    int r = 0;
    ll s = 0;
    ll x = 0;
    rep(l,n){
        while(r < n && ((s + a[r]) == (x ^ a[r]))){
            s += a[r];
            x ^= a[r];
            r++;
        }
        ans += (r - l);
        if(r == l) r++;
        else{
            s -= a[l];
            x ^= a[l];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N=int(input())

def solve(n):
    tmp=0
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            if n==i**2:
                tmp+=1
            else:
                tmp+=2
    return tmp

ans=0
for i in range(1,N+1):
    if i%2==0:
        continue
    else:
        if solve(i)==8:
            ans+=1
print(ans)

Measured memory_bytes: 3060
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	int k=nextpint();
	int a=nextpint();
	int b=nextpint();
	if(a+2<=b){
		long ans;
		if(k>a-1){
			ans=(long)(k-a+1)/2*(b-a)+(k-a+1)%2+a;
		}else{
			ans=k+1;
		}
		printf("%ld\n", ans);
	}else{
		printf("%d\n", k+1);
	}
}


Measured memory_bytes: 128
#!/usr/bin/env python3

N, A, B = list(map(int, input().split()))
a_idx = A
b_idx = B
turn = "A"
while True:
    # 判定
    if turn == "A":
        if a_idx == 1 and b_idx == a_idx + 1:
            winner = "Borys"
            break
    else:
        if b_idx == N and a_idx == b_idx - 1:
            winner = "Alice"
            break

    if turn == "A":
        if b_idx == a_idx + 1:
            a_idx -= 1
        else:
            a_idx += 1
        turn = "B"
    else:
        if a_idx == b_idx - 1:
            b_idx += 1
        else:
            b_idx -= 1
        turn = "A"

ans = winner
print(ans)


Measured memory_bytes: 3064
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) cout << "Yes"<<endl;
	else cout << "No" <<endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <time.h>
#define INF 10000000
using namespace std;

int main(){
  clock_t start=clock();
  int n,x[302][302]={},y[302][302]={};
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>y[i][j],x[i][j]=y[i][j];
  /*
  n=300;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) x[i][j]=y[i][j]=-1;
  */

  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }
  
  int ans=y[0][n-1],sum,K[302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[i][j],nk=a;
	sum=-INF;
	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum<=X+Y)sum=X+Y,nk=k;
	}
	ans=max(ans,sum);
	
	if(nk<n-1)f=1;
	for(int k=a+1;k<nk;k++){//tate
	  sum+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum);
	}
	if(a+1==nk&&j-i!=1) nk=n-1;
	K[i][j]=nk;
      }
  }
  clock_t end=clock();
  //  cout << (double)(end-start)/CLOCKS_PER_SEC <<endl;
  cout <<ans<<endl;
	  
  return 0; 
}

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

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine().ToLong();
            var ais = Console.ReadLine().ToLongArray();
            var bis = Console.ReadLine().ToLongArray();

            long cnt = 0;
            for (int i = 0; i < n; i++)
            {
                var min = Math.Min(ais[i], bis[i]);
                cnt += min;
                var next = Math.Min(ais[i + 1], bis[i] - min);
                cnt += next;
                ais[i + 1] -= next;
            }

            Console.WriteLine(cnt);
        }
    }

    public static partial class Program
    {
        //テンプレここから
        private static long GCD(long aaa, long bbb) => bbb == 0 ? aaa : GCD(bbb, aaa % bbb);
        private static long LCM(long aaa, long bbb) => aaa * bbb / GCD(aaa, bbb);
        private static long ToLong(this double ddd) => (long) ddd;
        private static long ToLong(this string str) => long.Parse(str);
        private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        private static long[] ToLongArray(this string str, char opr = ' ') => str.Split(opr).ToLong();
        private static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        private static long Sign(this long iii) => Math.Sign(iii);
        private static bool IsEven(this long iii) => iii % 2 == 0;
        private static readonly int[] Dx = {0, -1, 0, 1};
        private static readonly int[] Dy = {-1, 0, 1, 0};
        public const int MOD = 1000000007;
        public const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string alphabet = "abcdefghijklmnopqrstuvwxyz";
        public static long ToLong(this char ccc) => ccc.ToString().ToLong();
        public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        public static string JoinToStr(this IEnumerable<long> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        public static string JoinToStr(this IEnumerable<int> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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



int main(){
    int n; cin >> n;
    vector<string> s(n);
    for(auto &x: s) cin >> x;

    map<vi, ll> mp;
    for(int i=0; i<n; i++){
        vi cnt(26, 0);
        for(int j=0; j<10; j++) cnt[s[i][j]-'a']++;
        mp[cnt]++;
    }
    ll ans=0;
    for(auto p: mp){
        ans+=p.second*(p.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25112
#include <stdio.h>
#include <math.h>
int main(void)
{
  int N = 0;
   
  scanf("%d", &N);
 
  int A[N];
  
  for(int i=0; i < N; i++){
  scanf("%d", &A[i]);
  }
  
  for(int i=0; i < N; i++){
  if(A[i] % 2 != 0){
    A[i] = 0;
    }  
  }
    
  int ans = 0;
  
  for(int i=0; i < N; i++){
    if(A[i] % 3 != 0 && A[i] % 5 != 0){
      ans ++;
    }
  }
    
  if(ans != 0){
    printf("DENIED");
  }else{
    printf("APPROVED");
  }
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t x,ans;
	cin>>x;
	if(x<=6)ans=1;
	else if(x<=11)ans=2;
	else{
		ans=x/11*2;
		if(x%11>6)ans+=2;
		else if(x%11!=0)++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
// ABC 079 D Wall  ワーシャルフロイド
// https://atcoder.jp/contests/abc079/tasks/abc079_d
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int H, W;
    cin >> H >> W;
    int cost[10][10];
    for(int i = 0; i <= 9; i++) {
        for(int j = 0; j <= 9; j++) {
            cin >> cost[i][j];
        }
    }

    for(int k = 0; k <= 9; ++k) {
        for(int i = 0; i <= 9; ++i) {
            for(int j = 0; j <= 9; ++j) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
  
    int count=0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int input;
            cin >> input;
            if(input>=0){
                count+=cost[input][1];
            }
        }
    }
    cout << count <<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def func():
    while True:
        N = int(input())
        if N == 0: break
        W = [int(i) for i in input().split()]
        
        dp = [[0]*(N+1) for j in range(N+1)]

        for s in range(2, N+1):
            for l in range(N-s+1):
                r = l + s
                if (s - 2) % 2 == 0:
                    if dp[l+1][r-1] == s-2 and abs(W[l] - W[r-1]) <= 1:
                        dp[l][r] = s
                        continue
                for i in range(l, r+1):
                    if dp[l][r] < dp[l][i] + dp[i][r]:
                        dp[l][r] = dp[l][i] + dp[i][r]

        print(dp[0][N])

if __name__ == "__main__":
    func()


Measured memory_bytes: 7120
from bisect import bisect_right
        
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b_accum = [0 for _ in range(n)]
c_accum = [0 for _ in range(n)]
a.sort()
b.sort()
c.sort()
for i in range(n):
    index = bisect_right(b, a[i])
    try:
        b_accum[index] += 1
    except IndexError:
        pass
for i in range(1, n):
    b_accum[i] += b_accum[i-1]
for i in range(n):
    index = bisect_right(c, b[i])
    try:
        c_accum[index] += b_accum[i]
    except IndexError:
        pass
for i in range(1, n):
    c_accum[i] += c_accum[i-1]
for i in range(1, n):
    c_accum[i] += c_accum[i-1]
print(c_accum[n-1])

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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 1e19;
	if(labs(a - b) % 2 == 0)
	{
		ans = min(ans, (ll)(labs(a - b) / 2ll));	
	}
	ll A = a, B = b;
	ll res = a - 1;
	b -= res;
	a = 1;
	if(labs(a - b) % 2 != 0)
		b --, res ++;
	ans = min(ans, (ll)(res + labs(a - b)/2ll));
	a = A; b = B;
	res = n - b;
	a += res;
	b = n;
	if(labs(a - b) % 2 != 0)
		a ++, res ++;
	ans = min(ans, (ll)(res + labs(a - b)/2ll));
	cout << ans;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
n = gets.chomp.to_i
d = gets.chomp.split(' ').map(&:to_i)
n -= 1
a = 0
b = 0
(0..n).each do |i|
  (1..n).each do |j|
    a = a + d[i] *d[j] 
  end
end
(0..n).each do |i|
  (1..i).each do |j|
    b = b + d[i] *d[j] 
  end
end
ans = a - b
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;
string s;
int32_t main()
{
    cin >> s;
    if (s.length()==1)
    {
        cout << 1 << '\n';
        return 0;
    }
    int ans = s.length();
    for (int i = 1; i<s.length(); i++)
        if (s[i]!=s[i-1])
            ans = min(ans, max(i, (ll)s.length()-i));
    cout << ans << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	ll n, a[100010], ma = 0, mi = INF;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	if (ma - mi > 1) {
		cout << "No" << endl;
	}
	else if (ma - mi == 0) {
		if (a[0] <= n / 2 || a[0] == n - 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		int cnt = 0;
		for (int i = 0;i < n;i++) {
			if (a[i] == mi)cnt++;
		}
		if (cnt > mi)cout << "No" << endl;
		else if (n - cnt == 1)cout << "No" << endl;
		else if ((n - cnt) / 2 + cnt < ma)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
import bisect

ans = 0
N = int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()


#A<B<Cの組み合わせの数が答え
for i in range(N):
    #Bを1つ決めた時、AがB未満の場合の総数
    B_miman = bisect.bisect_left(A,B[i])
    #Bを1つ決めた時、CがB以上の場合の総数
    B_ijou = N - bisect.bisect_right(C, B[i])

    ans+= B_miman*B_ijou

print(ans)

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

using namespace std;

int main(void)
{
        int n;
        cin >> n;
        int a[n];

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

        sort(a,a+n);

        int count = 0;
        int now = 0;

        for(int i=1;i<=n;i++)
        {
                if(a[i-1]!=now)
                {
                        count++;
                        now=a[i-1];
                }
        }

        cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n;
	string s;
	cin>>n>>s;
	if(n>=s.size())cout<<s;
	else
	{
		for(ll i=0;i<n;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}	
}

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

using namespace std;
typedef long long ll;

int main(){
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x == y){ans = 0;}
    else if(abs(x) == abs(y)){ans = 1;}
    else if(abs(x) > abs(y) && x > y){
        if(y<=0){ans = x - abs(y) + 1;}
        else{ans = x - y + 2;}
    }
    else if(abs(x) > abs(y) && x < y){
        if(y<=0){ans = abs(x) - abs(y);}
        else{ans = abs(x) - y + 1;}
    }
    else if(abs(x) < abs(y) && x > y){
        if(x>=0){ans = abs(y) - x + 1;}
        else{ans = abs(y) - abs(x) + 2;}
    }
    else if(abs(x) < abs(y) && x < y){
        if(x>=0){ans = y - x;}
        else{ans = y - abs(x) + 1;}
    }

    cout << ans << endl;

}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    vector<int> V(N);
    REP0 (i, N)
    {
        cin >> V[i];
    }

    vector<int> C(N);
    REP0 (i, N)
    {
        cin >> C[i];
    }

    int ans = 0;

    for (int bit = 0; bit < (1 << N); bit++)
    {
        int X = 0, Y = 0;
        for (int d = 0; d < N; d++)
        {
            if (bit & (1 << d))
            {
                X += V[d];
                Y += C[d];
            }
        }
        ans = max(ans, X - Y);
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
p =  list(map(int,input().split()))
ans = 0
for i in p[0:k]:
    ans += (i+1)/2
c = ans
for i in range(n-k):
    c += (p[i+k]+1)/2  -(p[i]+1)/2
    ans = max(ans,c)
print(ans) 


Measured memory_bytes: 25060
from collections import Counter

N = int(input())
S = list(input())

c = Counter(S)
ans = c["R"] * c["G"] * c["B"]

if ans == 0:
    print(0)
    exit()

for n_skip in range(1, N):
    for i in range(N):
        try:
            if set(["R", "G", "B"]) == set([S[i], S[i+n_skip], S[i + 2*n_skip]]):
                ans -= 1
        except IndexError:
            break

print(ans)

Measured memory_bytes: 74752
#include<iostream>
using namespace std;
int main() {
	int a;
	cin >> a;

	switch (a)
	{
	case 111:
		cout << 999;
		break;
	case 119:
		cout << 991;
		break;
	case 191:
		cout << 919;
		break;
	case 911:
		cout << 199;
		break;
	case 991:
		cout << 119;
		break;
	case 919:
		cout << 191;
		break;
	case 199:
		cout << 911;
		break;
	case 999:
		cout << 111;
		break;
	default:
		break;

	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int mod = 1e9 + 7;

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

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

	// for (int i = 0; i < n; i++) {
	// 	printf("%2d: %2d\n", i, diff[i]);
	// }

	long long ans = 1;
	if (n % 2 == 0) {
		for (int i = 1; i < n; i+= 2) {
			if (diff[i] == 2) {
				ans = ans * 2 % mod;
			} else {
				ans = 0;
				break;
			}
		}
		for (int i = 0; i < n; i+= 2) {
			if (diff[i] == 0) {
			} else {
				ans = 0;
				break;
			}
		}
	} else {
		if (diff[0] != 1) {
			ans = 0;
		}
		for (int i = 2; i < n; i+= 2) {
			if (diff[i] == 2) {
				ans = ans * 2 % mod;
			} else {
				ans = 0;
				break;
			}
		}
		for (int i = 1; i < n; i+= 2) {
			if (diff[i] == 0) {
			} else {
				ans = 0;
				break;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var aa string
	if sc.Scan() {
		aa = sc.Text()
	}

	if len(aa) == 2 {
		fmt.Println(aa)
	} else if len(aa) == 3 {
		fmt.Println(reverse(aa))
	}
}


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

using namespace std;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef pair<int, int> Pii;
typedef struct{ int x, y; } Point;

int main(void)
{
    string t = "CODEFESTIVAL2016";
    string s;
    cin >> s;

    int c = 0;
    for(int i = 0; i < t.size(); i++){
        if(t[i] != s[i]){
            c++;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];

    }

    int res = INF;
    for(int i = K - 1; i < N; ++i) {
        int mn = v[i - (K - 1)];
        int mx = v[i];
        int sum = 0;
        if(mn >= 0) sum = mx;
        else if(mx <= 0) sum = abs(mn);
        else sum = mx - mn + min(abs(mx), abs(mn));
        res = min(res, sum);

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



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
long long n;
long long m,tem;
long long minn=1000;
inline long long myabs(long long a){
    return a>0ll?a:-a;
}
int main(){
    cin>>n;
    tem=1000;m=n%1000;
    while(m>=100){
        if(myabs(m-753)<minn) minn=myabs(m-753);
        tem*=10;
        m=n%tem/(tem/1000);
    }
    printf("%lld\n",minn);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

long long pow2[43];

long long solve(long long N){
    if(N<=0) return 0;
    long long ret=0;
    if(N%4==1 || N%4==2){
        ret=1;
    }
    for(int i=1;i<41;i++){
        long long napp=0;
        long long amari = N%pow2[i+1];
        if(amari>=pow2[i]){
            napp=amari-pow2[i]+1;
        }
        if(napp%2==1){
            ret += pow2[i];
        }
    }
    return ret;
}

int main(){
    long long A,B;
    cin>>A>>B;
    pow2[0]=1;
    for(int i=1;i<43;i++){
        pow2[i]=2*pow2[i-1];
    }
    
    long long ans=solve(B) xor solve(A-1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const int N=1e4+5;
int h,n,a[N],b[N],dp[N*10],ans,all;

int main()
{
	memset(dp,0x7f,sizeof(dp));
	ans=0x7fffffff;
	h=read();n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		b[i]=read();
		all+=a[i];
	}
	dp[0]=0;
	for(int i=1;i<=n;++i)
		for(int j=a[i];j<=h*10;++j)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
			if(j>=h)
				ans=min(ans,dp[j]);
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

class Combination(maxNum: Int, private val mod: Int) {
    private val fac = LongArray(maxNum + 1).apply { this[0] = 1L; this[1] = 1L }
    private val fInv = LongArray(maxNum + 1).apply { this[0] = 1L; this[1] = 1L }
    private val inv = LongArray(maxNum + 1).apply { this[1] = 1L }

    init {
        for (i in 2..maxNum) {
            fac[i] = fac[i - 1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod / i) % mod
            fInv[i] = fInv[i - 1] * inv[i] % mod
        }
    }

    fun get(n: Int, k: Int): Long {
        if (n < k) return 0
        if (n < 0 || k < 0) return 0
        return fac[n] * (fInv[k] * fInv[n - k] % mod) % mod
    }
}

fun main(args: Array<String>) {
    val (X, Y) = readIntList()

    if ((X + Y) % 3 != 0) {
        println(0)
        return
    }

    val n = (2 * Y - X) / 3
    val m = (2 * X - Y) / 3

    if (n < 0 || m < 0) {
        println(0)
        return
    }

    val comb = Combination(n+m, 1000000007)
    println(comb.get(n+m, n))
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  vector<pair<int,int>> v;
  
  rep(i,n) {
    int x, y;
    cin>>x>>y;
    auto p = make_pair(x, y);
    
    v.push_back(p);
  }
  
  vector<int> perm(n);
  rep(i,n) perm[i] = i;
  
  vector<double> diss;
  
  do {
    double dist = 0;
    
    rep(i,n) {
      if(i!=0) {
        auto t = v[perm[i]];
        auto pt = v[perm[i-1]];
        
        double dx = pow(pt.first - t.first, 2);
        double dy = pow(pt.second - t.second, 2);
        dist += pow(dx + dy, 0.5);        
      }
      
      if (i == n-1) {
        diss.push_back(dist);
      }
    }
    
  } while( next_permutation(perm.begin(), perm.end()) );
  
  double sum = 0;
  double ans = 0;
  
  rep(i, diss.size()) {
    sum += diss[i];
  }
  
  ans = sum/diss.size();
  
  
  cout<<fixed<<setprecision(7)<<ans;
}

Measured memory_bytes: 4340
import sys
from collections import defaultdict, deque
readline = sys.stdin.readline

inf = 10 ** 5
n = int(readline())
G = defaultdict(list)
deg = [0] * n
for _ in range(n-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

q = deque([0])
depth = [-1] * n
depth[0] = 0
d = 1
while q:
    x = q.popleft()
    d = depth[x] + 1
    for y in G[x]:
        if depth[y] == -1:
            q.append(y)
            depth[y] = d
r0 = list(range(3, n + 1, 3))
r1 = list(range(1, n + 1, 3))
r2 = list(range(2, n + 1, 3))
odd = [i for i in range(n) if depth[i] % 2]
even = [i for i in range(n) if not depth[i] % 2]
if len(even) <= n // 3:
    odd, even = even, odd
if len(odd) <= n // 3:
    r = r2 + r1 + r0
else:
    r = r1 + r0 + r2
ans = [0] * n
for i in odd:
    ans[i] = r.pop()
for i in even:
    ans[i] = r.pop()
# print(f'{even=}{odd=}{num=}')
print(*ans)


Measured memory_bytes: 79636
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'

res=[]
def search(seq,k,n):
    global N
    
    if k==N+1:

        tmp=[ascii_lowercase[s-1] for s in seq[1:]]
        res.append("".join(tmp))
        return 
    
    seq[k]=n
    search(seq,k+1,n+1)
    
    for l in range(1,n):
        seq[k] = l
        search(seq, k+1,n)
    

N=int(input())
seq=[-1]*(N+1)
seq[1]=1
search(seq,2,2)


res=sorted(res)

for rr in res:
    print(rr)

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;
ll s,t;
vector<bool> used(500010,0);

ll dfs(ll now, ll parent, vector<bool> &mdl){
    if(parent == now) return -1;
    //if(used.at(now)) return 0;
    used.at(now) = true;
    if(parent == -1) parent = now;
    if(mdl.at(now)) {
        ll temp = dfs((now + t) % s, parent, mdl);
        if(temp == -1) return temp;
        else return temp+1;
    }
    return 0;
}

int main() {
    string S, T;
    cin >> S >> T;
    s = S.size(), t = T.size();
    if(t == 1){
        ll ans = 0, temp = 0;
        rep(i,s*2){
            if(S[i%s] == T[0]){
                ++temp;
                ans = max(ans,temp);
            }else{
                temp = 0;
            }
        }
        cout<<(ans == s*2 ? -1 : ans)<<endl;
        return 0;
    }
    vec table(t, 0);
    table[0] = -1;
    table[1] = 0;
    ll I = 2, J = 0;
    while(I < t){
        if(T.at(I-1) == T.at(J)){
            table.at(I) = J+1;
            ++I;
            ++J;
        }else if(J > 0){
            J = table.at(J);
        }else{
            table.at(I) = 0;
            ++I;
        }
    }
    I = 0; J = 0;
    vector<bool> mdl(s,false);
    while(I < s){
        if(S.at((I+J)%s) == T.at(J)){
            if(J == t-1){
                mdl.at(I) = true;
                I = I + J - table.at(J);
                J = table.at(J);
            }else{
                ++J;
            }
        }else{
            I = I + J - table.at(J);
            if(J > 0) {
                J = table.at(J);
            }else{
                J = 0;
            }
        }
    }
    ll ans = 0;
    rep(i,s){
        if(used.at(i)) continue;
        ll temp = dfs(i,-1,mdl);
        if(temp == -1){
            ans = -1;
            break;
        }else{
            ans = max(ans,temp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13192
#include <iostream>
#include <cmath>
using namespace std;
#define pi 3.14159265358979
int main(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	long double hour=(long double)h/12.0+((long double)m/60.0)/12.0;
    long double mini=(long double)m/60.0;
    long double diff=2*pi*(hour-mini);
    long double result=sqrt((long double)(a*a+b*b)-(long double)(2*a*b*cosl(diff)));
    cout.precision(9);
    cout << fixed << result << '\n';
    return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int s, t;
  int v;
};
bool operator<(const ST& a, const ST& b){
  return a.v < b.v;
}

int main(){
  int N;
  vector<int> t, v;
  cin >> N;

  int allt = 0;
  rep(i,N){
    int a;
    cin >> a;
    t.push_back(a);
    allt += a;
  }
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  vector<ST> stv;
  int base = 0;
  rep(i,N){
    ST st;
    st.s = base;
    st.t = base + t[i];
    st.v = v[i];
    stv.push_back(st);
    base += t[i];
  }
  sort(ALLOF(stv));

  int M = allt * 2 + 1;
  vector<int> memo(M,0);
  rep(i,M){
    if(i > M-1-i) break;
    memo[i] = i;
    memo[M-1-i] = i;
  }
  
  rep(i,stv.size()){
    int ss = 2*stv[i].s;
    int tt = 2*stv[i].t;
    int vv = 2*stv[i].v;

    REP(i,ss,tt+1){
      if(memo[i] > vv){
        memo[i] = vv;
      }
    }
    int x = memo[ss];
    while(ss>0){
      ss--;
      x++;
      if(memo[ss] > x){
        memo[ss] = x;
      }else{
        break;
      }
    }
    x = memo[tt];
    while(tt<M){
      tt++;
      x++;
      if(memo[tt] > x){
        memo[tt] = x;
      }else{
        break;
      }
    }
  }


  double ret = 0;
  rep(i,M-1){
    //cout << i << " " << memo[i] << endl;
    int a = memo[i], b = memo[i+1];
    double h = min(a,b) / 2.0;
    
    if(a==b){
      ret += 0.5 * h;
    }else{
      ret += 0.5 * (h + 0.25);
    }
  }

  printf("%.16lf\n", ret);
  
  return 0;
}


Measured memory_bytes: 384
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1e9+7;
ll power(ll a, ll b)
{
    ll ret = 1;
    if(b == 0) return ret;
    while(b>0)
    {
        if(b%2==1)
        {
            ret = (ret*a) % mod;
        }
        b /= 2;
        a = (a*a) % mod;
    }
    return ret;
}
ll fact[200200];
ll comb(ll x, ll y)
{
    if(y == 0 || y == x) return 1LL;
    ll sum = 1;
    ll i;
    for(i=x;i>x-y;i--)
    {
        sum *= i;
        sum %= mod;
    }
    ll sum2 = 1;
    for(i=1;i<=y;i++)
    {
        sum2 *= i;
        sum2 %= mod;
    }
    sum *= power(sum2, mod-2);
    sum %= mod;
    return sum;
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    fact[0] = 1LL;
    for(i=1;i<=200000;i++)
    {
        fact[i] = 1LL*fact[i-1]*(ll)i;
        fact[i] %= mod;
    }
    ll a,b,c;
    cin >> a >> b >> c;
    ll chaeng = power(1LL*2, a) - 1;
    if(chaeng < 0) chaeng += mod;
    chaeng -= comb(a,b);
    while(chaeng < 0) chaeng += mod;
    chaeng -= comb(a,c);
    while(chaeng < 0) chaeng += mod;
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 1792
function main(input) {
  let args = input.split('\n');
  let a = 0;
  let [x, n] = args[a++].split(' ').map((e) => +e);
  if (n == 0) {
    console.log(x);
    return;
  }
  let arr = args[a++].split(' ');
  let map = {};
  for (let i = 0; i < n; ++i) {
    const e = +arr[i];
    if (!map[e]) {
      map[e] = 1;
    }
  }
  let min = null;
  let max = null;
  for (let i = x; x > -1; --i) {
    if (!map[i]) {
      min = i;
      break;
    }
  }
  for (let i = x; x < 101; ++i) {
    if (!map[i]) {
      max = i;
      break;
    }
  }
  let diffA = x - min;
  let diffB = max - x;
  if (diffA == diffB) {
    console.log(Math.min(min, max));
  } else if (diffA < diffB) {
    console.log(min);
  } else {
    console.log(max);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29648
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

//#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 53, MOD = 1e9 + 7;
int n;
ll k;

struct Mat {
    int a[N][N];
    Mat() {
        memset(a, 0, sizeof(a));
    }
    void one() {
        for (int i = 0; i < n; i++) {
            a[i][i] = 1;
        }
    }
    Mat operator * (const Mat & m) const {
        Mat res;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    res.a[i][k] += (ll)a[i][j] * m.a[j][k] % MOD;
                    if (res.a[i][k] >= MOD) {
                        res.a[i][k] -= MOD;
                    }
                }
            }
        }
        return res;
    }
    Mat binpow(ll x) {
        Mat res, num = * this;
        res.one();
        while (x > 0) {
            if (x & 1) {
                res = res * num;
            }
            x /= 2;
            num = num * num;
        }
        return res;
    }
};

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> k;
    Mat m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> m.a[i][j];
        }
    }
    m = m.binpow(k);
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res += m.a[i][j];
            if (res >= MOD) {
                res -= MOD;
            }
        }
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 384
N,M = map(int,input().split())
lis = [tuple(map(str,input().split())) for i in range(M)]
ans = [0]*N
answ = [0]*N
ansin = [0]*N
for i in range(0,M):
    an = lis[i][1]
    if an == 'AC':
        ans[int(lis[i][0])-1] = 1
    elif an == 'WA' and ans[int(lis[i][0])-1] == 0:
        answ[int(lis[i][0])-1] += 1
for i in range(N):
    if ans[i] == 1:
        ansin[i] = answ[i]
print(sum(ans),end=' ')
print(sum(ansin))

Measured memory_bytes: 25820
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef complex<double> P;
typedef pair<P,P> L;
const double pi=3.14159265358979323846264;
const double EPS=1e-10;
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}

bool intersectLS(const L &l, const L &s){return cross(l.S-l.F,s.F-l.F)*cross(l.S-l.F,s.S-l.F)<EPS;}
double toRad(double agl){return agl*pi/180.0;}
P rotate(P a, double r){return P(a.real()*cos(r)-a.imag()*sin(r),a.real()*sin(r)+a.imag()*cos(r));}
P crosspoint(const L &l, const L &m) {
  double A=cross(l.S-l.F,m.S-m.F);
  double B=cross(l.S-l.F,l.S-m.F);
  if(fabs(A)<EPS&&fabs(B)<EPS) return m.F;
  return m.F+B/A*(m.S-m.F);
}

double area(vector<P> p) {
  double a=0;
  for(int i=0;i<(int)p.size();i++)a+=cross(p[i],p[(i+1)%p.size()]);
  return fabs(a)/2;
}

void Main() {
  double a,b,x;
  cin >> a >> b >> x;
  x/=a;
  double l=0,r=90;
  rep(t,100) {
    double m=(l+r)/2;
    vector<P> v;
    v.pb(P(0,0));
    v.pb(P(a,0));
    v.pb(P(a,b));
    v.pb(P(0,b));
    rep(i,v.size()) v[i]=rotate(v[i],toRad(-m));
    L e=L(v[2],P(-MAX,v[2].imag()));
    vector<P> p;
    if(intersectLS(e,L(v[0],v[3]))) {
      p.pb(v[0]);
      p.pb(v[1]);
      p.pb(v[2]);
      p.pb(crosspoint(e,L(v[0],v[3])));
    } else if(intersectLS(e,L(v[0],v[1]))){
      p.pb(crosspoint(e,L(v[0],v[1])));
      p.pb(v[1]);
      p.pb(v[2]);
    } else {
      r=m;
      continue;
    }
    double d=area(p);
    if(d>=x) l=m;
    else r=m;
  }
  pd(l);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 512
import java.util.*;
// import java.io.*;
// import java.time.*;

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

        int num = sc.nextInt();

        ArrayList<Item> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(new Item(sc.nextInt()
                , sc.nextInt()
                , sc.next()
                , sc.nextLong()
                , sc.next()));
        }

        Collections.sort(array, Comparator.comparing(Item::getV)
            .thenComparing(Item::getW)
            .thenComparing(Item::getT)
            .thenComparing(Item::getD)
            .thenComparing(Item::getS));

        for (int i = 0; i < array.size(); i++) {
            Item tmp = array.get(i);
            sb.append(tmp.v).append(" ");
            sb.append(tmp.w).append(" ");
            sb.append(tmp.t).append(" ");
            sb.append(tmp.d).append(" ");
            sb.append(tmp.s).append("\n");
            // if (i != array.size() - 1) sb.append(' ');
        }

        System.out.print(sb);
        
        sc.close();
    }

    static class Item {
        int v;
        int w;
        String t;
        long d;
        String s;

        Item(int a, int b, String c, long f, String e) {
            v = a;
            w = b;
            t = c;
            d = f;
            s = e;
        }

        int getV() { return v; }
        int getW() { return w; }
        String getT() { return t; }
        long getD() { return d; }
        String getS() { return s; }
    }
}



Measured memory_bytes: 191276
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
a0=[]
b0=[]
for i in range(n):
    if i%2==0:
        a0.append(a[i])
        b0.append(b[i])
print(len(a0)-len(list(set(a0) & set(b0))))

Measured memory_bytes: 15692
import java.util.Arrays;
import java.util.Scanner;

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        Integer[] a = {1,3,5,7,8,10,12};
        Integer[] b = {4,6,9,11};
        Integer[] c = {2};

        if ((Arrays.asList(a).contains(x) && Arrays.asList(a).contains(y)) || (Arrays.asList(b).contains(x) && Arrays.asList(b).contains(y)) || (Arrays.asList(c).contains(x) && Arrays.asList(c).contains(y))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) { cin >> h.at(i); }

    int ans = 0;
    REP(i, N) {
        if (h[i] >= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
const int Maxn=1e5+5;
int px[Maxn],py[Maxn],par[Maxn];
pair <int,int> sx[Maxn],sy[Maxn];
int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
bool union_(int u,int v)
{
	u=find(u);
	v=find(v);
	if (u==v) return false;
	par[u]=v;
	return true;
}
int dist(int x,int y)
{
	return min(abs(px[x]-px[y]),abs(py[x]-py[y]));
}
int n;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie();cout.tie();
	cin>>n;
	rep(i,n)
	{
		cin>>px[i]>>py[i];
		par[i]=i;
		sx[i]={px[i],i};
		sy[i]={py[i],i};
	}
	sort(sx,sx+n);
	sort(sy,sy+n);
	set <pair <int,pair <int,int> > > st;
	for (int j=0;j<n-1;++j)
	{
		st.insert({dist(sx[j].second,sx[j+1].second),{sx[j].second,sx[j+1].second}});
		st.insert({dist(sy[j].second,sy[j+1].second),{sy[j].second,sy[j+1].second}});
	}
	long long ans=0;
	while (!st.empty())
	{
		auto cur=*st.begin();
		st.erase(cur);
		int u=cur.second.first,v=cur.second.second;
		ans+=(long long)union_(u,v)*dist(u,v);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15488
#include <stdio.h>
int main(void){
  int N,a,b,i;
  char S[N];
  scanf("%d%s",&N,S);
  a=0;
  b=0;
  for(i=0;i<N;i++){
   if(S[i]=='I')
     a++;
    else a--;
    if(b<a)
      b=a;
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<string> w(n);
    for(int i=0;i<n;i++){
        cin >> w[i];
    }
    bool check=true;
    for(int i=1;i<n;i++){
        int j = w[i-1].size();
        if(w[i-1][j-1] != w[i][0]){
           check = false;
           break;
        }
        for(int j=0;j<i;j++){
            if(w[i]==w[j]){
                check = false;
                break;
            }
        }
    }
    if(check){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(void){
    map<int, int> m;
    for(int i = 0; i < 3; i++){
        int a, b;
        cin >> a >> b;
        m[a]++;
        m[b]++;
    }
    for(auto itr = m.begin(); itr != m.end(); itr++){
        if(itr -> second > 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256