akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	void doIt(){
		Scanner sc = new Scanner(System.in);
		Record round[] = new Record[24]; //??????
		Record qualified[] = new Record[6]; //?±??????????????£????(3, 4???)
		Record finalist[] = new Record[8]; //?±?????????????
		int m = 0, n = 0;
		for(int i = 0; i < 24; i++){
			round[i] =  new Record(sc.nextInt(), sc.nextDouble());
		}
		/*for(int i = 0; i < 24; i += 8){
			int k = i + 8;
			Arrays.sort(round, i, k);
		}*/
		for(int i = 0; i < 24; i += 8){
			Arrays.sort(round, i, i + 8);
			finalist[m] = round[i]; m++;
			finalist[m] = round[i + 1]; m++;
			qualified[n] = round[i + 2]; n++;
			qualified[n] = round[i + 3]; n++;
		}
		Arrays.sort(qualified, 0, 6);
		finalist[m] = qualified[0]; m++;
		finalist[m] = qualified[1];
		/*for(int i = 0; i < 24; i++){
			System.out.printf("%d %.2f\n", round[i].number, round[i].time);
		}*/
		//System.out.println(Arrays.toString(round).replaceAll("\\[|\\]|,", ""));
		for(int i = 0; i < 8; i++){
			System.out.printf("%d %.2f\n", finalist[i].number, finalist[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
	class Record implements Comparable<Record>{ //Record???????????????
		int number;
		double time;
		Record(int number, double time){
			this.number = number;
			this.time = time;
		}
		/*@Override
		public String toString(){
			return number + " " + time;
		}*/
		@Override
		public int compareTo(Record r){
			return new Double(time).compareTo(r.time);
		}
	}
}

Measured memory_bytes: 28372
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
priority_queue<double, vector<double>, greater<double> > que;
int main() {
    int N, j;
    while (cin >> N) {
        double t;
        for (j = 1; j <= N; j++) {
            cin >> t;
            que.push(t);
        }
        double ans, t1;
        for (j = 1; j <= N - 1; j++) {
            t = que.top();
            que.pop();
            t1 = que.top();
            que.pop();
            ans = (t + t1) / 2.0;
            que.push(ans);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int INF = 1e9 + 7;
int n, m;
int c[21];
int dp[50010];//dp[i]でi円を支払う時の最小枚数
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i)cin >> c[i];
	for (int i = 0; i < 50010; ++i) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i <= 50000; ++i) {
		for (int j = 0; j<m; ++j) {
			if (i + c[j] <= n) {
				dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3312
#include <stdio.h>
#include <string.h>

int main(){
  char s[3];
  scanf("%s", s);
  char *s2 = "ABC";
  if(strcmp(s, s2) == 0){
    printf("ARC\n");
  }else{
    printf("ABC\n");
  }
  
  return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
using Long = long long;

bool isPrime[2000002];
vector<Long> P;
Long dp[1010];
void Sieve() {
    for(Long i = 2; i <= 1010; i++) {
        if(!isPrime[i]) {
            P.push_back(i);
            for(Long j = i + i; j <= 1010; j += i) {
                isPrime[j] = true;
            }
        } }
}
Long mod = 1000000007LL;
int main() {
    Long n;
    cin >> n;
    memset(dp,0,sizeof(dp));
    Sieve();
    for(int i = 1; i <= n; i++) {
        int x = i;
        for(int j = 0; j < P.size(); j++) {
            while(x % P[j] == 0) {
                x /= P[j];
                dp[j]++;
            }
        }
    }
    Long ans = 1LL;
    for(int i = 0; i <= P.size(); i++) {
        if (dp[i]) ans *= (dp[i] + 1LL);
        ans %= mod;
    }
    cout << (ans  % mod)<< endl;
}

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

using namespace std;
using ll = long long;

ll mod = 1e9 + 7;
ll dp[100007][2];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string l;
    cin >> l;
    int n = l.size();
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        dp[i + 1][1] += 3 * dp[i][1];
        if (l[i] == '1') {
            dp[i + 1][0] += dp[i][0] * 2;
            dp[i + 1][1] += dp[i][0];
        } else {
            dp[i + 1][0] += dp[i][0];
        }
        dp[i + 1][0] %= mod;
        dp[i + 1][1] %= mod;
    }

    ll ans = (dp[n][0] + dp[n][1]) % mod;
    cout << ans << '\n';
    return 0;
}



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

int main() {
	char b;
	cin >> b;
	char ans;
	if (b == 'A') ans = 'T';	
	if (b == 'T') ans = 'A';
	if (b == 'C') ans = 'G';
	if (b == 'G') ans = 'C';
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int num = 0;
  
  for (int i=A; i< B+1 ;i++) {
    if(i/10000==i%10 && i/1000%10==i%100/10){
      num++;
    }
  }
  
  cout << num << endl;
  

}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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 dp[55][2555];

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

    int N,A; cin >> N >> A;
    int X[N]; rep(i,N) cin >> X[i];
    dp[0][0]=1;
    rep(i,N) {
        per(j,N) {
            per(k,2501) {
                dp[j+1][k+X[i]]+=dp[j][k];
            }
        }
    }
    int ans=0;
    rep(i,N) {
        ans+=dp[i+1][(i+1)*A];
    }
    cout << ans << endl;
}

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

int a,b;

int main() {
  while (scanf("%d %d" ,&a ,&b) != EOF) {
    int i  = 0;
    a = a + b;
    while(a > 0) {
      a = a / 10;
      ++i;
    }
    
    cout << i << endl;
    
  }
}

Measured memory_bytes: 3116
N = int(input())
S = [input(), input()]
mod = 10**9+7
i = 1 + (S[0][0] != S[1][0])
ans = 3 * i

while i < N:
    p = S[0][i-1] == S[1][i-1]
    if S[0][i] == S[1][i]:
        ans *= 1 + p
        i += 1
    else:
        ans *= 3 - p
        i += 2
    ans %= mod

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  cout<<(n>=30?"Yes":"No");
  
  return 0;
}
//2020.08.02 20:00:34


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
	b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
void solve()
{
// Dont apply return before taking all the input of particular test case
/* carry operation
int cr=1;
int y=k-1;
while(cr)
{
char op=str[y];
op++;
if(op<='9') cr=0;
else op='0';
str[y]=op;
y--;
}
return;
}
*/
void solve()
{
int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
int p[a],q[b],r[c];
ll sum=0;
rep(l,0,a)
cin>>p[l];
rep(l,0,b)
cin>>q[l];
rep(l,0,c)
cin>>r[l];
sort(p,p+a,greater<int>());
sort(q,q+b,greater<int>());
vector<int>v;
for(int i=0;i<x;i++)
v.pb(p[i]);
for(int i=0;i<y;i++)
v.pb(q[i]);
for(int i=0;i<c;i++)
v.pb(r[i]);
sort(v.begin(),v.end(),greater<int>());
for(int i=0;i<(x+y);i++)
{
	sum+=v[i];
}
cout<<sum;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

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

string s;
int p, o0, o1, e0, e1, a, b;

int main() {
	cin >> s;
	p = s.length();
	for (int i=0; i<p; i++) {
		if (i%2==0) {
			if (s[i]=='0') {e0++;}
			else {e1++;}
		}
		else {
			if (s[i]=='0') {o0++;}
			else {o1++;}
		}
	}
	a=e1+o0;
	b=e0+o1;
	if (a>b) {cout << b << endl;}
	else {cout << a << endl;}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>

using namespace std;

const int MAXN = 10010;

int f[MAXN];
int n, W;

int main()
{
	ios::sync_with_stdio(false);
	
	cin >> n >> W;
	memset(f, 0, sizeof(f));
	for(int i = 1; i <= n; ++i)
	{
		int v, w;
		cin >> v >> w;
		for(int j = W; j >= w; --j)
			f[j] = max(f[j], f[j - w] + v);
	}
	
	cout << f[W] << endl;
	
	return 0;
}

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

int A[100005][3], dp[100005][3];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++)
        for(int j=0; j<3; j++)
            cin >> A[i][j];
    
    for(int i=1; i<=N; i++)
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
                if(j != k)
                    dp[i][j] = max(dp[i][j], A[i][j] + dp[i-1][k]);
        }
    
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << "\n";
    return 0;
}

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

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
  ll res=1;
  while(b)
  {
    if(b&1LL)
      res=(res*a)%c;
    a=(a*a)%c;
    b>>=1;
  }
  return res;
}

int main()
{
  FASTIO;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  
  string s;
     cin>>s;

      int len=s.length();


      ll sum=0;
      for(int i=0;i<len;i++)
      {
        sum+=(s[i]-'0');
        sum%=9;
      }

      if(!sum)
      {
        cout<<"Yes\n";
      }
      else
      {
        cout<<"No\n";
      }

  
  return 0;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int sum = 0;
    int[] x = new int[n];
    for(int i = 0; i < n; i++) {
      x[i] = Integer.parseInt(sc.next());
    }
    for(int i = 0; i < n - 1; i++) {
      for(int j = i + 1; j < n; j++) {
        sum += x[i] * x[j];
      }
    }
    System.out.println(sum);
  }
}


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

int main()
{
    string S, S1, S2;
    bool ym, my;
    int a, b;
    cin >> S;
    S1 = S.substr(0, 2);
    S2 = S.substr(2, 2);
    a = atoi(S1.c_str());
    b = atoi(S2.c_str());
    ym = false;
    my = false;
    if (1 <= b && b <= 12)
    {
        ym = true;
    }
    if (1 <= a && a <= 12)
    {
        my = true;
    }
    if (ym && my)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (ym)
    {
        cout << "YYMM" << endl;
    }
    else if (my)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){

    char str[5];

    cin >> str;

    sort(str, str + 4);

    if(str[0] == str[1] && str[2] == str[3] && str[1] != str[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;

int main() {
	cin >> n >> m;
	cout << (1900 * m + (n - m) * 100)*pow(2,m) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/*long long int MOD =1e9+7;
long long int MAX=2001;
long long int dp[2001][2001];

void fill(){
	for(int i(0);i<MAX;++i){
		dp[i][0]=1;
	}
	for(int i(1);i<MAX;++i){
		for(int j(1);j<MAX;++i){
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
			dp[i][j]%=MOD;
		}
	}
}

int main(){
	int n,k;
	cin >> n >> k;
	fill();
	for(int i(1);i<=k;++i){
		long long  a=dp[n-k+1][i];
		long long  b=dp[k-1][i-1];
		cout << (a*b)%MOD << '\n';
	}
}*/

long long int dp[2001][2001];

int main(){
	for(int i(0);i<2001;++i){
		dp[i][0]=1;
	}
	for(int i(1);i<2001;++i){
		for(int j(1);j<2001;j++){
			dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%1000000007;
		}
	}
	int n,k;
	cin >> n >> k;
	for(int i(1);i<=k;++i){
		cout << ((dp[n-k+1][i]%1000000007)*(dp[k-1][i-1])%1000000007) % 1000000007<< endl;
	}


}

Measured memory_bytes: 31488
import pprint
h,w = map(int,input().split())
s = [["!"]*(w+2)] + [list("!" + input() + "!") for _ in range(h)] + [["!"]*(w+2)]
next = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "#":
            continue
        count = 0
        for d1,d2 in next:
            count += (s[i + d1][j+d2] == "#")
        s[i][j] = str(count)
ans = []
for k in s:
    k = [x for x in k if not x =="!"]
    if k:
        ans.append(k)
for adf in ans:
    print("".join(adf))


Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int a[1001];
int dp[1001];
const int INF=1000000000;
int main(){
  int n,w;
  int cnt=1;
  while(cin>>n>>w&&(n|w)){
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n;i>=0;i--){
      int res=INF;
      if(i!=n){
	int sum=0;
	// 今回の場所からいくつ取るか
	for(int j=i;j<n;j++){
	  sum+=a[j];
	  if(j!=n-1)res=min(res,dp[j+1]+abs(sum-w));
	  else res=min(res,dp[j+1]+max(0,sum-w));
	}
      }
      else res=0;
      dp[i]=res;
    }
    int ans=dp[0];
    cout<<"Case "<<cnt<<": "<<ans<<endl;
    cnt++;
  }
  
  return 0;
}

Measured memory_bytes: 876
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    cout<<setprecision(16);
    ll a,b,c;

    cin>>a>>b>>c;
    ll d = (c-a-b);
    if(d<=0){
        cout<<"No"<<endl;
        return 0;
    }
    d=d*d;
    ll dd = 4*(a*b);


    if(dd<d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;

bool is(int x){
	for(int i = 2;i <= sqrt(x);++i){
		if(x % i == 0) return 0;
	}
	return x == 1 ?0 :1;
}

int main()
{
	int x;
	scanf("%d",&x);
	for(;;++x){
		if(is(x)){
			printf("%d\n",x);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll n, q, u, v, p, x, a[MAXN];
vector<ll> g[MAXN];
void dfs(ll idx, ll val)
{
	a[idx] += val;
	for (auto i : g[idx])
		if (i > idx)
			dfs(i, a[idx]);
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> q)
	{
		for (ll i = 1; i <= n; ++i)
			vector<ll>().swap(g[i]), a[i] = 0;
		for (ll i = 2; i <= n&&cin >> u >> v; ++i)
			g[u].emplace_back(v), g[v].emplace_back(u);
		while (q--&&cin >> p >> x)
			a[p] += x;
		dfs(1, 0);
		for (ll i = 1; i <= n; ++i)
			cout << a[i] << ' ';
		cout << endl;
	}
}
/*
4 3
1 2
2 3
2 4
2 10
1 100
3 1

6 2
1 2
1 3
2 4
3 6
2 5
1 10
1 10
*/

Measured memory_bytes: 21120
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
unordered_map<ll,vector<ll> >v;
unordered_set<ll> st;
#define N 100010
ll n,m,p[N],y[N];
string F(ll x){
    string s="abcdef";
    lol(i,6){
	s[5-i]='0'+x%10;
	x/=10;
    }
    return s;
}
int main(){
    cin>>n>>m;
    lol(i,m){
	cin>>p[i]>>y[i];
	v[p[i]].push_back(y[i]);
    }
    lol(i,m){
	if(st.find(p[i])!=st.end())continue;
	st.insert(p[i]);
	sort(v[p[i]].begin(),v[p[i]].end());
    }
    lol(i,m){
	ll d=lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin();
	cout<<F(p[i])<<F(d+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 15908
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 27 02:46:15 2020

@author: liang
"""

from collections import deque

n = int(input())
A = [int(x) for x in input().split()]

res = deque()

for i in range(n):
    if i % 2 == 0:
        res.append(A[i])
    else:
        res.appendleft(A[i])
        
if n % 2 == 1:
    print(" ".join(map(str,reversed(res))))
else:
    print(" ".join(map(str,res)))

Measured memory_bytes: 36104
#include <iostream>
#include <numeric>
using namespace std;
 
int main()
{
	int n, m;
    int* l;
    int* r;
    int* f;
    int a;
 
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> n >> m;
    l = new int[m];
    r = new int[m];
    f = new int[n];
    for(int i = 0; i < n; i++) {
        f[i] = 1;
    }
    for(int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
    }

    for(int g = 0; g < m; g++){
        for(int h = 0; h < l[g] - 1; h++) {
            f[h] = 0;
        }
        for(int h = r[g]; h < n; h++) {
            f[h] = 0;
        }
    }
 
    a = 0;
    for(int i = 0; i < n; i++) {
        a += f[i];
    }
    cout << a << endl;
 
	return 0;
}

Measured memory_bytes: 1408
#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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

void myswap(int &x,int &y){
	int tmp;
	tmp=x;
	x=y;
	y=tmp;
	return;
}

int main(void){
	int x,y;
	while(1){
		cin >> x >> y;
		if(x==0&&y==0) break;
		if(y<x) myswap(x,y);
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int a,b,v,w,t,dis;

int main() {
	read(a),read(v),read(b),read(w),read(t);
	dis=abs(a-b);
	if(v<=w&&dis!=0) puts("NO");
	else if(1ll*(v-w)*t>=dis) puts("YES");
	else puts("NO");
	return 0;
}

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

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=2e5+35;
  const int M=2e4;
  
  int dp[3003][3003];
 int ct[3003];
 void fft()           
 {
   int n,s; cin>>n>>s; vi v(n+1); rep(i,1,n+1) cin>>v[i];
   
   dp[1][v[1]]=1; ct[v[1]]+=1;
   
   for(int i=2;i<=n;++i){
        dp[i][v[i]]=i;
     for(int j=v[i]+1;j<=s;++j){
         dp[i][j]=ct[j-v[i]];

     }
     
      for(int j=v[i];j<=s;++j) (ct[j]+=dp[i][j])%=mod2;    
   }
   
  
   int ans=0;
   for(int i=1;i<=n;++i) (ans+=(n-i+1)*dp[i][s])%=mod2;
   
   cout<<ans;
   
 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   
   int t=1;                         
 //  cin>>t;

  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<t)
   cout<<nl;
  }
  
 
 return 0; 
}

Measured memory_bytes: 70656
#include <stdio.h>

void d_islands(int[64][64], int, int);//inc counter, call islands()

int main(void){

  char scan[128], give[4];
  int w, h, loop1, loop2, loop3, map[64][64];


  while(1){

    for(loop1 = 0; loop1 < 128; loop1++){
      scan[loop1] = '\0';
    }
    for(loop1 = 0; loop1 < 64; loop1++){
      for(loop2 = 0; loop2 < 64; loop2++){
	map[loop1][loop2] = 0;
      }
    }
    
    fgets(scan, 8, stdin);
    for(loop1 = 0; scan[loop1] != ' '; loop1++){
      give[loop1] = scan[loop1];
    }
    w = atoi(give);
    loop1++;    
    for(loop2 = 0; loop2 < 4; loop2++){
      give[loop2] = '\0';
    }
    for(loop2 = 0; scan[loop1] != '\n'; loop1++, loop2++){
      give[loop2] = scan[loop1];
    }
    h = atoi(give);   // get w h
    
    if((w == 0) && (h == 0)) break;

    for(loop1 = 0; loop1 < 4; loop1++){
      give[loop2] = '\0';
    }
    for(loop1 = 0; loop1 < 128; loop1++){
      scan[loop1] = '\0';
    }
    
    
    for(loop1 = 1; loop1 <= h; loop1++){
      fgets(scan, 128, stdin);
      for(loop2 = 0, loop3 = 1; scan[loop2] != '\n'; loop2++){
	if(scan[loop2] == '0'){
	  loop3++;
	}
	if(scan[loop2] == '1'){
	  map[loop1][loop3] = 1;
	  loop3++;
	}
      }
    }  // load the map

    /*    for(loop1 = 0; loop1 < 10; loop1++){
      for(loop2 = 0; loop2 < 10; loop2++){
	printf("%d ", map[loop1][loop2]);
      }
      printf("\n");
      }*/

    loop3 = 0;
    for(loop1 = 1; loop1 <= h; loop1++){
      for(loop2 = 1; loop2 <= w; loop2++){
	if(map[loop1][loop2] != 0){
	  d_islands(map, loop1, loop2);
	  loop3++;
	}
      }
    }
    printf("%d\n", loop3);

    
  }
  return 0;
    
}


void d_islands(int map[64][64], int h, int w){
  int loop1, loop2;
  map[h][w] = 0;
  /*    for(loop1 = 0; loop1 < 10; loop1++){
      for(loop2 = 0; loop2 < 10; loop2++){
	printf("%d ", map[loop1][loop2]);
      }
      printf("\n");
      }*/
  //  printf("checking %d %d\n", h, w);
  for(loop1 = h - 1; loop1 < h + 2; loop1++){
    for(loop2 = w - 1; loop2 < w + 2; loop2++){ 
      if(map[loop1][loop2] == 1) d_islands(map, loop1, loop2);//printf("1 ");
      //      else printf("0 ");

    }    
  }
}

Measured memory_bytes: 724
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, T, A) );
    }

    private static int solve(int N, int T, int[] A) {
        int[] saleAt = new int[N];
        saleAt[N-1] = -1;
        int maxIndex = N-1;
        int maxDiff = 0;
        for (int i = N-2; i >=0 ; i--) {
            if( A[i] > A[maxIndex] ) {
                maxIndex = i;
                saleAt[i] = -1;
            } else {
                saleAt[i] = maxIndex;
                maxDiff = Math.max(A[maxIndex] -A[i], maxDiff);
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if( saleAt[i] != -1 && A[saleAt[i]] - A[i] == maxDiff ) ans++;
        }

        return ans;
    }

    private static void show(int[] array) {
        StringJoiner j = new StringJoiner(" ");
        for (int i : array) {
            j.add(String.valueOf(i));
        }
        System.err.println( j.toString() );
    }
}

Measured memory_bytes: 51304
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

char
judge(char table[3][3])
{
	int x, y;
	char c;

	for (y = 0; y < 3; ++y)
	{
		c = table[y][0];
		if (c == 'o' || c == 'x')
		{
			for (x = 1; x < 3; ++x)
			{
				if (table[y][x] != c)
					break;
			}

			if (x >= 3)
				return c;
		}
	}

	for (x = 0; x < 3; ++x)
	{
		c = table[0][x];
		if (c == 'o' || c == 'x')
		{
			for (y = 1; y < 3; ++y)
			{
				if (table[y][x] != c)
					break;
			}

			if (y >= 3)
				return c;
		}
	}

	c = table[1][1];
	if (c == 'o' || c == 'x')
	{
		if (table[0][0] == c && table[2][2] == c)
			return c;

		if (table[2][0] == c && table[0][2] == c)
			return c;
	}

	return 'd';
}

int
main(int argc, char **argv)
{
	char table[3][3];
	char c;
	int x, y;

	while (true)
	{
		for (y = 0; y < 3; ++y)
		{
			for (x = 0; x < 3; ++x)
				 if (scanf("%c", &table[y][x]) == EOF)
				 	goto l_end;
		}

		printf("%c\n", judge(table));
		scanf("%c", &c);
		if (c != '\n')
			break;
	}

l_end:
	return 0;
}

Measured memory_bytes: 540
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    int ans = 100, x;
    cin >> x;
    int cnt = 0;
    while(ans + ans/100 < x){
    	ans += ans/100;
    	cnt++;
    }
    cout << cnt+1;
}

int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tst=1;
//cin>>tst;
while(tst--)
{
	solve();
}
}

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

using namespace std;
typedef long long ll;
const int N = 2010;
const ll mod = 1e9 + 7;
ll f[N];

int main() {
    int s;
    cin >> s;
    f[0] = 1;
    for (int i = 3; i <= s; i++)
        for (int j = 3; j <= i; j++)
            f[i] = (f[i] + f[i - j]) % mod;
    cout << f[s] << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const int MAXN = 1e5+5;

int a, b, c, n, m, k;
string s, s1, s2, t;

int32_t main() {
	cin >> a >> b;
	int kappa = __gcd(a, b);
	cout << (a*b)/kappa << endl;
}
		
			




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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  ll N, K;
  cin >> N >> K;

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

  ll dp[N + 1];
  for (ll i = 0; i < N + 1; i++) {
    dp[i] = LLONG_MAX;
  }

  dp[0] = 0;
  for (ll i = 1; i < N; i++) {
    for (ll k = 1; k <= K; k++) {
      ll r = i;
      ll l = i - k;

      if (0 <= l) {
        dp[i] = min(dp[i], abs(h[r] - h[l]) + dp[l]);
        // cout << "r:" << r << " l:" << l << " dp:" << abs(h[r] - h[l]) << " l:" << dp[l] << endl;
      }
    }
    // cout << dp[i] << endl;
  }

  cout << dp[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    ll flag=0;
    ll height;
    for(ll i=0;i<1000;++i){
        flag += i;
        if(i+1 == b-a){
            height = flag-a;
            break;
        }
    }
    cout<<height<<endl;
    return 0;
}

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

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

    if(d==0 && n<100) cout<<n<<endl;
    else if(d==0 && n==100) cout<<101<<endl;
    else if(d==1 && n<100) cout<<100*n<<endl;
    else if(d==1 && n==100) cout<<10100<<endl;
    else if(d==2 && n<100) cout<<10000*n<<endl;
    else cout<<1010000<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int t, x; cin >> t >> x;
    cout << (double)t / (double)x << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

ll convertCharToInt(char* str){
    ll sum=-1;
    for(int i=0;str[i]!='\0';i++){
        switch(str[i]){ 
            case 'A':
                sum+=pow(4,i);
                break;
            case 'C':
                sum+=2*pow(4,i);
                break;
            case 'G':
                sum+=3*pow(4,i);
                break;
            case 'T':
                sum+=4*pow(4,i);
                break;
            default:
                break;
        }
    }
    return sum;
}
int main(){
    ll n;
    cin>>n;
    char* s=new char[16777216];
    char com[6]={};
    char str[12]={};
    for(ll i=0;i<n;i++){
        cin>>com>>str;
        if(com[0]=='i'){
            ll index=convertCharToInt(str);
            s[index]='T';
        }else{
            ll index=convertCharToInt(str);
            if(s[index]=='T'){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define N 109
using namespace std;

int n,a[N],ans[N];
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int main(){
	scanf("%d",&n);
	int i;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (i=n; i; i--){
		int j;
		for (j=i; j; j--) if (a[j]==j){
			ans[i]=j;
			for (; j<i; j++) a[j]=a[j+1];
			break;
		}
		if (!j){ puts("-1"); return 0; }
	}
	for (i=1; i<=n; i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    int l = n / 2;
    if (d[l - 1] == d[l]) {
        cout << 0 << endl;
    } else {
        cout << d[l] - d[l - 1] << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N; cin>>N;
	vector<ll> A(N);
	ll ans=0;
	rep(i,N) cin>>A[i];
	ll mem=A[0],cnt=1;
	rep1(i,N-1){
		if(A[i]==mem) cnt++;
		else{
			ans+=cnt/2;
			cnt=1;
			mem=A[i];
		}
	}
	ans+=cnt/2;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll sum=0;
    ll mini=0;
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1){
        if(mini<=a[i]){
            mini=a[i];
        }else{
            sum+=(mini-a[i]);
        }
    }
    cout<<sum<<endl;
    
}



Measured memory_bytes: 5216
#include "iostream"
#include "vector"

using namespace std;

int main(){
	int N,L,R;
	cin>>N>>R>>L;
	vector<int>v(N);
	for(auto &i:v)cin>>i;
	vector<int>place(N+1);
	for(int i=0;i<N;i++){
		place[v[i]]=i;
	}
	vector<vector<long long int>>dp(2,vector<long long int>(N+2));
	for(int i=1;i<=N;i++){
		int index =i&1;
		long long int box=dp[index^1][0];
		for(int j=0;j<=N+1;j++){
			box=min(box,dp[index^1][j]);
			if(place[i]+1>j)dp[index][j]=box+L;
			else if(place[i]+1==j)dp[index][j]=box;
			else dp[index][j]=box+R;
		}
	}
	long long int ans=1000000000000000000;
	for(int i=0;i<=N+1;i++)ans=min(ans,dp[N&1][i]);
	cout<<ans<<endl;
}

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

int main() {


  int n;
  cin >> n;
  double sumJ = 0;
  double sumB = 0;
  
  for(int i=0; i<n; i++){
  double x;
  string u;
    cin >> x >> u;
    if(u=="JPY"){
      sumJ += x;
    }
    else{
    sumB += x;
    }
  }

  cout << sumJ + sumB*380000.0 <<endl; 
} 

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

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


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

    int n; cin >> n;
    string ans;
    if(n == 25) ans = "Christmas";
    if(n == 24) ans = "Christmas Eve";
    if(n == 23) ans = "Christmas Eve Eve";
    if(n == 22) ans = "Christmas Eve Eve Eve";
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n;
	cin>>n;
	fill(int,a,n);

	int sum=0;
	vector<vector<int>> dp(n,vector<int> (n));

	rep(len,1,n+1){
		rep(i,0,n-len+1){
			int j=i+len-1;
			if(len==1){
				dp[i][j]=a[i];
				sum+=a[i];
			}
			else if(len==2)
				dp[i][j]=max(a[i],a[j]);
			else
				dp[i][j]=max(a[i]+min(dp[i+1][j-1],dp[i+2][j]),a[j]+min(dp[i+1][j-1],dp[i][j-2]));
		}
	}

	cout<<2*dp[0][n-1]-sum;
}	
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 73684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> a(n);
    rep(i,n) {
        a[i] = s[i] - '0';
        a[i]--;
    }

    vector<int> cnt(3);
    rep(i,n) cnt[a[i]]++;

    int type = -1;
    if(cnt[0] == n || cnt[1] == n || cnt[2] == n){
        cout << 0 << endl;
        return 0;
    }
    else if(cnt[0] == 0 ){
        type = 0;
        rep(i,n) a[i]--;
    }
    else if(cnt[1] == 0){
        type = 1;
        rep(i,n) a[i] /= 2;
    }
    else if(cnt[2] == 0){
        type = 2;
    }
    else{
        type = 3;
        rep(i,n) if(a[i] == 2) a[i] = 0;
    }

    int ans = 0;

    rep(i,n) if(((n-1) & i) == i) ans ^= a[i];

    if(type == 1) ans *= 2;
    cout << ans << endl;
}


Measured memory_bytes: 8184
#include<bits/stdc++.h>
using namespace std;
int arr[3];
int main()
{
	int i,a,b;
	scanf("%d\n%d",&a,&b);
	arr[a-1]=1;
	arr[b-1]=1;
	for(i=0;i<3;i++)
	{
		if(arr[i]==0)
		{
			printf("%d",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n,k;
    char s[n];

    scanf("%d %d",&n,&k);
    scanf("%s",s);

    if(s[k-1]=='A')
    {
        s[k-1]='a';
    }
    else if(s[k-1]=='B')
    {
        s[k-1]='b';
    }
    else
    {
        s[k-1]='c';
    }
    
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	h := nextInt()
	w := nextInt()

	if h == 1 || w == 1 {
		fmt.Println(1)
		return
	}

	if h%2 == 0 && w%2 == 0 {
		fmt.Println((h * w) / 2)
		return
	}
	if h%2 == 1 && w%2 == 0 {
		fmt.Println(h * (w / 2))
		return
	}
	if h%2 == 0 && w%2 == 1 {
		fmt.Println((h / 2) * w)
		return
	}
	//fmt.Println(h*(w/2) + int(math.Ceil(float64(h)/2)))
	fmt.Println(h*(w/2) + (h / 2) + 1)
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    int n; cin>>n;
    vector<int>v(n); rep(i,n)cin>>v[i];
    bool mid=true;
    bool up;
    int cnt=1;
    rep(i,n){
        if(mid){
            if(v[i]==v[i-1]||i==0)continue;
            else if(v[i]>v[i-1])up=true;
            else up=false;
            mid=false;
        }else{
            if(up&&v[i]<v[i-1]){
                mid=true;
                cnt++;
                continue;
            }else if(up==false&&v[i]>v[i-1]){
                mid=true;
                cnt++;
                continue;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static final String OK = "Yay!";
	public static final String NO = ":(";
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcde = new int[5];
		abcde[0] = sc.nextInt();
		abcde[1] = sc.nextInt();
		abcde[2] = sc.nextInt();
		abcde[3] = sc.nextInt();
		abcde[4] = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		for(int i = 0; i < 5; i++) {
			int idx = i;
			for(int j = 0; j < 5; j++) {
				int p = abcde[idx];
				int q = abcde[j];
				if(i != j && Math.abs(p - q) > k) {
					System.out.println(NO);
					return;
				}
			}
		}
		System.out.println(OK);
	}
}

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



int main() {
    int n, a, b;
    cin >> n >> a >> b;
    
    cout << min(n*a, b) << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3604
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
   
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1,  x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1    
    print(result)

Measured memory_bytes: 7616