akhauriyash/Code-Regression huggingface dataset:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char a[100007];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int sum=0;
    for(int i=1;i<n;++i)
        if(a[i]==a[i+1])
            ++sum;
    cout<<min(n-1,sum+2*k);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+4;
const int mod=1e9+7;
void solve(){
    int n; cin>>n;
    std::vector<int> stick(n);
    for(auto &i:stick)cin>>i;
    sort(stick.begin(),stick.end());
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int sum=stick[i]+stick[j];
            int small=upper_bound(stick.begin(),stick.end(),sum-1)-stick.begin();
            ans+=(small-1-j);
        }
    }   
    cout<<ans<<endl;
}   
int32_t main(){
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tt; 
    tt=1;
    // cin>>tt;
    for(int t=1;t<=tt;t++){
        solve();
    }
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    ll n;
    cin>>n;
    ll a[5]={};
    rep(i,5)cin>>a[i];
    ll b[5]={};
    rep(i,5){
        ll s=n%a[i];
        ll t=n/a[i];
        if(s!=0)b[i]=t+1+4;
        else b[i]=t+4;
    }
    ll ans=0;
    rep(i,5){
        ans=max(ans,b[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}}; constexpr Factorial<1010> fact;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	long h, w, n; cin >> h >> w >> n; std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++){
		long a, b; cin >> a >> b; a--; b--;
		
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				int nx = a - j, ny = b - k;
				if(nx<0||ny<0) continue;
				vec.push_back({nx, ny});
			}
		}
	}
	sort(begin(vec), end(vec));
	std::vector<std::pair<int, int>> pos = vec;
	pos.erase(unique(begin(pos), end(pos)), end(pos));
	
	long li[10] = {}; li[0] = (h - 2) * (w - 2);
	for(int i = 0; i < pos.size(); i++){
		if(pos[i].first >= h - 2 or pos[i].second >= w - 2) continue;
		int c = upper_bound(begin(vec), end(vec), pos[i])
			  - lower_bound(begin(vec), end(vec), pos[i]);
			  
		li[c]++; li[0]--;
	}
	
	for(int i = 0; i < 10; i++) cout << li[i] << endl;
	return 0;
}


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

char a[53][53], b[53][53];

int main(){

    int m, n;
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; ++i){
        scanf("%s", a[i]);
    }
    for(int i=0; i<m; ++i){
        scanf("%s", b[i]);
    }


    for(int i=0; i<=n-m; ++i){
        for(int j=0; j<=n-m; ++j){
            bool found=true;
            for(int k=i, k2=0; k<m+i; ++k, ++k2){
                for(int l=j, l2=0; l<m+j; ++l, ++l2){
                    if(a[k][l]!=b[k2][l2])
                        found=false;
                }
            }
            if(found){
                puts("Yes");
                return 0;
            }
        }
    }

    puts("No");




    return 0;
}


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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}


void solve(){ 
    ll n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vector<ll> a,b;
    for(ll i=0;i<n;i++){
        if(s[i]=='o'){
            a.pb(i);
            i += c;
        }
    }
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='o'){
            b.pb(i);
            i -= c;
        }
    }
    //reverse(b.begin(),b.end());
    vector<ll> ANS;
    for(ll i=0;i<k;i++){
        if(a[i] == b[k-i-1]){
            ANS.pb(a[i]+1);
        }
    }

    for(auto it : ANS)
        cout << it << endl;

}

int main(){
    
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6664
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    ll max_P = 0;
    ll max_Q = 100 * A;

    for (ll a = 0; a * 100 <= F; a += A) for (ll b = 0; (a + b) * 100 <= F; b += B) {
        if (a == 0 && b == 0) continue;
        ll x = 100 * (a + b);
        for (ll c = 0; c + x <= F; c += C) for (ll d = 0; c + d + x <= F; d += D) {
            ll y = c + d;
            if ((a + b) * E < y) continue;
            if (max_P * (x + y) < max_Q * 100 * y) {
                max_P = 100 * y;
                max_Q = x + y;
            }
        }
    }

    printf("%lld %lld\n", max_Q, max_P / 100);
    
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
using namespace std;
long long factorial[21];
void init(){
	factorial[1] = 1;
	for(int i = 2;i < 21; i++){
		factorial[i] = factorial[i-1] * i;
	}
}
int main(){
	init();
	int n;
	while(cin >> n){
		cout << factorial[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
int main(){
  int a,b,c,x,y,ans=0;
  int i,j;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  j=(x>y?x:y);
  for(i=0;i<=j;i++){
    if(x-i>0&&y-i>0)
      ans+=((a+b>2*c)?2*c:a+b);
    else if(x-i<1&&y-i>0)
      ans+=((b>2*c)?2*c:b);
    else if(x-i>0&&y-i<1)
      ans+=((a>2*c)?2*c:a);
  }
    printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
	int a,b;
	int count=0;
	int s[110];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

		
	}
	 sort(s,s+a);
	for(int j=0;j<a-1;j++){
		if(s[j]<=b){
			count++;
			b=b-s[j];
		}
	}
	if(b==s[a-1]){
		count++;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
    
int n,k;
    
int s[2001][2001];
void add(int x1, int y1, int x2, int y2) {
    s[y1][x1]++;
    s[y1][x2]--;
    s[y2][x1]--;
    s[y2][x2]++;
}
    
int find() {
    int m = -1;
    for (int i = 0; i < 2*k; i++)
        for (int j = 0; j < 2*k; j++) {
            int top = i > 0 ? s[i-1][j] : 0;
            int bot = j > 0 ? s[i][j-1] : 0;
            int dia = i > 0 && j > 0 ? s[i-1][j-1] : 0;
            m = max(m, s[i][j] = s[i][j] + top + bot - dia);
        }
    return m;
}
    
int main() {
    ios::sync_with_stdio(0);
    cin>>n>>k;
    while (n--) {
        int x,y; string c; cin>>x>>y>>c;
    
        x %= 2*k; y %= 2*k;
        if ((c == "W" && ((x < k && y < k) || (x >= k && y>= k))) || (c == "B" && ((x >= k && y < k) || (x < k && y >= k)))) {
            x %= k, y %= k;
            add(0,0,k-x,k-y);
            add(2*k-x,0,2*k,k-y);
            add(k-x,k-y,2*k-x,2*k-y);
            add(0,2*k-y,k-x,2*k);
            add(2*k-x,2*k-y,2*k,2*k);
        } else {
            x %= k, y %= k;
            add(0,k-y,k-x,2*k-y);
            add(k-x,0,2*k-x,k-y);
            add(k-x,2*k-y,2*k-x,2*k);
            add(2*k-x,k-y,2*k,2*k-y);
        }
    }
    cout<<find()<<endl;
    
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll ans = 0;
    int n;
    cin >> n;
    int cnt[n + 5] = {};
    f(n-1) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    f1(n) {
        cout << cnt[i] << '\n';
    }
}


Measured memory_bytes: 4440
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	if(a[0]!=0){
		cout<<(a[0]==0?0:-1)<<endl;
		return 0;
	}

	ll now=0;
	ll ans=0;
	for(int i = 1; i < n; i++){
		if(now<a[i]){
			if(now+1!=a[i]){
				cout << -1 << endl;
				return 0;
			}
			ans -= now;
			now++;
			ans += now;
		}else if(now==a[i]){
			ans+=now;
		}else{
			now=a[i];
			ans+=now;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}



int n,a[5555],b[5555];
ll d[2525],c[5555];
bool visited[2525],pos[2525];
vector<int> g[2525];

bool dfs(int v){
	int i;
	if(visited[v]){
		return pos[v];
	}
	visited[v] = true;
	if(v==n){
		return pos[v] = true;
	}
	for(i=0; i<g[v].l_ength(); ++i){
		if(dfs(g[v][i])){
			return pos[v] = true;
		}
	}
	return pos[v] = false;
}

int main(void){
	int m,i,cnt=0,j;
	bool update,loop = false;
	ll p;
	fill(d,d+2525,INFLL);
	d[1] = 0ll;
	cin >> n >> m >> p;
	for(i=0; i<m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		c[i] = p - c[i];
		g[a[i]].push_back(b[i]);
	}
	dfs(1);
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			if(d[b[i]]>d[a[i]]+c[i]){
				update = true;
				d[b[i]] = d[a[i]]+c[i];
			}
		}
		if(!update){
			break;
		}
		if(cnt > n){
			break;
		}
		++cnt;
	}
	for(j=0; j<n; ++j){
		for(i=0; i<m; ++i){
			if(d[b[i]]>d[a[i]]+c[i]){
				d[b[i]] = d[a[i]]+c[i];
				if(pos[b[i]]){
					loop = true;
				}
			}
		}
	}
	if(loop){
		cout << -1 << endl;
		return 0;
	}
	cout << max(-d[n],0ll) << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long int dp[3010][3010];
long long int a[3001];
int n;

/*long long int solve(int i, int j){
      if(dp[i][j]!=-1)return dp[i][j];
      
      if(i==j)return dp[i][j]=a[i];
      if(i>j)return dp[i][j]=0;
      
      dp[i][j]=max(a[i]-solve(i+1, j), a[j]-solve(i, j-1));
      //cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
      return dp[i][j];
}*/

int main(){
      cin>>n;
      memset(dp, 0, sizeof(dp));
      for(int i=0; i<n; i++)
            cin>>a[i];
      //cout<<solve(0, n-1)<<'\n';
      for(int l=0; l<n; l++){
            for(int i=0; i<n; i++){
                  int j=i+l;
                  if(i==j)dp[i][j]=a[j];
                  else {
                        dp[i][j]=max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
                  }
            }
      }
      cout<<dp[0][n-1];
}

Measured memory_bytes: 74408
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int x, y, a, b, c, f, g, h,s;cin >> x >> y >> a >> b >> c;ll sum = 0;
	priority_queue<int> p, q, r;
	p.push(0);q.push(0);r.push(0);
	rep(i, a) {
		cin >> f;p.push(f);
	}
	rep(i, b) {
		cin >> f;q.push(f);
	}
	rep(i, c) {
		cin >> f;r.push(f);
	}
	s = x + y;int d = 0;
	while (s > 0) {
		if (x != 0) f = p.top();
		else f = 0;
		if (y != 0) g = q.top();
		else g = 0;
		h = r.top();
		if (f >= h && f >= g && x > 0) {
			sum += f;x--;p.pop();
		}
		else if (g >= h && g > f&& y > 0) {
			sum += g;y--;q.pop();
		}
		else {
			sum += h;r.pop();
			d++;
		}
		s = x + y - d;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;

LL mod = 1000000007;

LL mi (LL x, LL m) {
	// compute pow(x, m-2)
	LL acc = 1;
	LL p = m-2;
	while (p) {
		if (p%2 == 1) {
			acc *= x;
			acc %= m;
		}
		x *= x % m;
		x %= m;
		p >>= 1;
	}
	
	return acc;
}

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

	vector<LL> x(n);

	for (auto &e : x) {
		cin >> e;
	}

	vector<LL> mijs(n-1);

	mijs[0] = 1;
	for (LL i = 1; i < n-1; ++i) {
		mijs[i]=mijs[i-1]+mi(i+1, mod);
		mijs[i]%=mod;
	}

	LL sum = 0;
	for (LL i = 0; i < n-1; ++i) {
		sum += (x[i+1]-x[i])*mijs[i] % mod;
		sum %= mod;
	}

	for (LL i = 1; i <= n-1; ++i) {
		sum *= i;
		sum %= mod;
	}

	cout << sum << "\n";

}

Measured memory_bytes: 1792
# -*- coding:utf-8 -*-

def dfs(datas, b, c, count):
    if len(data) == count: return 1
    p = int(data[count])
    if p > b:
        q = dfs(data, p, c, count+1)
        if q==1:return 1
    if p > c:
        q = dfs(data, b, p, count+1)
        if q==1:return 1
    return 0

def solve():
    b=0
    c=0
    count = 0
    q = dfs(data, b, c, count)
    if q==1:
        print("YES")
    elif q==0:
        print("NO")

counter = 0
line = input()
if not " " in line:
    nums = line
while True:
    line = input()
    data = line.split(" ")
    q = solve()
    counter += 1
    if int(nums) == counter:
        break

Measured memory_bytes: 7636
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    map<string, int> s;
    rep(i,n) {
        vector<char> c(10);
        rep(j,10) cin>>c[j];
        sort(c.begin(), c.end());
        string t;
        rep(j,10) t.push_back(c[j]);
        s[t]++;
    }
    ll ans = 0ll;
    for (auto &&e: s) {
        ll m = e.second;
        ans += m*(m-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    set<ll>st;
    REP(i,1,10){
        REP(j,1,10){
            st.insert(i*j);
        }
    }
    ll n;cin>>n;
    if(st.find(n)==st.end())cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

using namespace std;

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c * e - b * f) / (a * e - b * d);
		double y = (c * d - a * f) / (b * d - a * e);
		if (-0.0005 <= x && x < 0.0005) x = 0;
		if (-0.0005 <= y && y < 0.0005) y = 0;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

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

		if (400 <= n && n <= 599) {
			System.out.println(8);
		} else if (600 <= n && n <= 799) {
			System.out.println(7);
		} else if (800 <= n && n <= 999) {
			System.out.println(6);
		} else if (1000 <= n && n <= 1199) {
			System.out.println(5);
		} else if (1200 <= n && n <= 1399) {
			System.out.println(4);
		} else if (1400 <= n && n <= 1599) {
			System.out.println(3);
		} else if (1600 <= n && n <= 1799) {
			System.out.println(2);
		} else if (1800 <= n && n <= 1999) {
			System.out.println(1);
		}


		sc.close();
	}

}


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

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    ll n,m;
    cin>>n>>m;

    pair<ll,ll> arr[m];
    for(ll i=0;i<m;i++)
        cin>>arr[i].first>>arr[i].second;

    ll r = arr[0].second;
    ll l = arr[0].first;

    for(ll i=1;i<m;i++)
    {
        r = min(r,arr[i].second);
        l = max(l,arr[i].first);
    }

    if(r<l)
        cout<<"0";
    else
        cout<<r-l+1;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "No" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,W,N; cin>>H>>W>>N;
    vector<ll> X(N);
    vector<ll> Y(N);
    rep(i,N) cin>>X[i]>>Y[i],--X[i],--Y[i]; 
    vector<P> A;
    rep(i,N) A.emplace_back(X[i],Y[i]);
    SORT(A);
    ll ct=0;
    set<ll> st;
    rep(i,A.size()){
        if(A[i].second<A[i].first and (st.find(A[i].first-A[i].second)==st.end())){
            cout<< A[i].first <<"\n"; return;
        }
        st.emplace(A[i].first-A[i].second+1);
    }
    cout<< H <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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


long long L[90];

int main() {
    string s;
    cin >> s;
    vector< int> v(4);
    for (int i = 0; i < 4; ++i) v[i] = s[i] - '0';

    for(int i = 0; i < 8; ++i) {
        int res = v[0];
        for(int j = 0; j < 3; ++j) 
            if((i >> j) & 1) res += v[j + 1];
            else res -= v[j + 1];

        if(res == 7) {
            cout << v[0];
            for(int j = 0; j < 3; ++j){ 
                if(i >> j & 1) cout << '+';
                else cout << '-';
                cout << v[j + 1];
            }
            cout << "=7";
            cout << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int N,M;
   cin>>N>>M;
   int acs=0,was=0;
   vector<int>ac(N),wa(N);
   for(int i=0;i<M;i++){
    int p;
    string S;
    cin>>p>>S;
    p--;
    if(ac[p]>0){continue;}
    if(S=="AC"){ac[p]++;acs++;}
    else if(S=="WA"){wa[p]++;}
   }
    for(int i=0;i<N;i++){
        if(ac[i]>0){was+=wa[i];}
    }
   cout<<acs<<" "<<was<<endl;
return 0;}

Measured memory_bytes: 1024
from sys import stdin
input = stdin.buffer.readline

def main():
    n = int(input())

    dp = [0, 0, 0]
    for _ in range(n):
        a, b, c = map(int, input().split())
        dp = [max(dp[1], dp[2]) + a,
            max(dp[2], dp[0]) + b,
            max(dp[0], dp[1]) + c]

    print(max(dp))

main()

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


using namespace std;

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

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

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

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int fromstart[200020];
int togoal[200020];


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

	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		
		if (a == 1) {
			fromstart[b] = 1;
		}

		if (b == n) {
			togoal[a] = 1;
		}
		
	}

	for (int i = 0; i <= n; i++) {
		if (fromstart[i] == 1 && togoal[i] == 1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

namespace AtCoder.Question
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var (n, k) = (int.Parse(input[0]), int.Parse(input[1]));
            var hash = new HashSet<int>(n);

            for (int i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var ak = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
                foreach (var akd in ak)
                {
                    if (!hash.Contains(akd))
                    {
                        hash.Add(akd);
                    }
                }
            }
            Console.WriteLine(Enumerable.Range(1, n).Except(hash).Count());
        }
    }
}


Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, W; cin >> N >> W;
    int w[N], v[N];
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    ll DP[W+1]; memset(DP, -1, sizeof(DP));
    DP[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = W; j >= w[i]; j--){
            if(DP[j - w[i]] != -1)
                DP[j] = max(DP[j], DP[j - w[i]] + v[i]);
        }
    }
    cout << *max_element(DP, DP+W+1);
}

Measured memory_bytes: 4412
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int A, P;

int main() {
    cin >> A;
    cin >> P;
    int a = A*3;
    int b = a + P;
    if ( b % 2 == 0 ) {
        cout << b/2;
    } else if (b  % 2 == 1 ) {
        cout << (b-1)/2;
    }
    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;
    int cnt=0;

    rep(i,6){
        if(s[i]=='1'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int m, c[4], r[4]; // money, coins, returned coins
  int d[4] = {10, 50, 100, 500};

  bool firstline = true;
  while (cin >> m, (m)) {
    if (!firstline) { cout << endl; }
    firstline = false;

    int sum = 0;
    for (int i=0; i<4; i++) {
      cin >> c[i];
      sum += d[i] * c[i];
      r[i] = 0;
    }

    sum -= m;
    for (int i=3; i>=0; i--) {
      while (sum >= d[i]) { sum -= d[i]; r[i]++; }
    }

    for (int i=0; i<4; i++) {
      int x = c[i] - r[i];
      if (x > 0) {
        cout << d[i] << " " << x << endl;
      }
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)	for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
	if(a.first==b.first)return a.second<b.second;
	else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
	for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
	for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
	int sum=0;
	// for(auto x: v)sum+=x;
	fr(i,0,v.size())sum+=v[i];
	return sum;
}





 void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	// int e= max(a,b) , f = max(c,d);
	// if(e>0)
	cout<<max(a*c,max(a*d,max(b*c,b*d)));
}

signed main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;	
} 	

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

typedef long long ll;
#define INF (1ll<<60)

int main(void){
	int n,cnt=1,i,ans=0;
	ll a[100100];
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	a[n]=INF;
	for(i=0; i<n; i++){
		if(a[i]==a[i+1]){
			cnt++;
		}else{
			if(cnt>a[i]){
				ans += (cnt-a[i]);
			}else if(cnt<a[i]){
				ans += cnt;
			}
			cnt=1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<pair<long long, long long>> vp;
        for(int i=0;i<N;i++){
            long long X, L; cin >> X >> L;
            vp.emplace_back(X+L, X-L);
        }
        sort(vp.begin(), vp.end());
        int res = 0;
        long long last = -(1LL << 60);
        for(auto& p : vp){
            if(p.second < last) continue;
            ++res;
            last = p.first;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 2420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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>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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  
  vector<int> L,ANS;
  REP(i,N){
    int a;
    cin>>a;
    L.push_back(a);
  }
  
  for(int j=0; j<150; ++j){
    bool CAN=true;
    for(int i=L.size()-1; i>=0; --i){
      if(L.at(i)==i+1 && CAN==true){
        ANS.push_back(i+1);
        L.erase(L.begin()+i);
        CAN=false;
      }
      if(L.size()==0) break;
    }
  }
  
  if(L.size()>=1) co(-1);
  else{
    REP(i,ANS.size()){
      co(ANS.at(ANS.size()-1-i));
    }
  }
  return 0;
}

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

using std::cout;
using std::cin;
using std::string;


int main()
{
  std::vector<string> result_str = {"YYMM", "MMYY", "AMBIGUOUS", "NA"};

  string s;
  cin >> s;
  int a,b;
  a = std::stoi(s.substr(0,2));
  b = std::stoi(s.substr(2,2));
  if((a >= 1 && a<= 12) && (b >= 1 && b <= 12))
  {
    cout << result_str[2] << "\n";
  }
  else if((a >= 0 && a<= 99) && (b >= 1 && b <= 12))
  {
    cout << result_str[0] << "\n";
  }
  else if((a >= 1 && a<= 12) && (b >= 0 && b <= 99))
  {
    cout << result_str[1] << "\n";
  }
  else
  {
    cout << result_str[3] << "\n";
  }
  return 0;

}


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

using namespace std;

int main(){
  int n, multicol;
  multicol = 0;
  int d[9] = {};
  
  cin >> n;
  for (int i=0;i<n;i++) {
    int point;
    cin >> point;
    if (point < 400) {
      d[0]++;
    } else if (point < 400) {
      d[1]++;
    } else if (point < 800) {
      d[2]++;
    } else if (point < 1200) {
      d[3]++;
    } else if (point < 1600) {
      d[4]++;
    } else if (point < 2000) {
      d[5]++;
    } else if (point < 2400) {
      d[6]++;
    } else if (point < 2800) {
      d[7]++;
    } else if (point < 3200) {
      d[8]++;
    } else {
      multicol++;
    }
  }
  int total_forced_color = 0;
  for (int i=0;i<9;i++) {
    if (d[i]>0) {
      total_forced_color++;
    }
  }
  int maxcol, mincol;
  if (total_forced_color==0){
    mincol=1;
  } else {
    mincol = total_forced_color;
  }
  maxcol = total_forced_color + multicol;
  cout << mincol << " " << maxcol << endl;
}


Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

colors = {
  'gray': 0,
  'blown': 0,
  'green': 0,
  'water': 0,
  'blue': 0,
  'yellow': 0,
  'orange': 0,
  'red': 0,
}
over_3200 = 0

for rate in a:
  if 1 <= rate <= 399:
    colors['gray'] += 1
  elif 400 <= rate <= 799:
    colors['blown'] += 1
  elif 800 <= rate <= 1199:
    colors['green'] += 1
  elif 1200 <= rate <= 1599:
    colors['water'] += 1
  elif 1600 <= rate <= 1999:
    colors['blue'] += 1
  elif 2000 <= rate <= 2399:
    colors['yellow'] += 1
  elif 2400 <= rate <= 2799:
    colors['orange'] += 1
  elif 2800 <= rate <= 3199:
    colors['red'] += 1
  elif rate >= 3200:
    over_3200 += 1

min_kinds = len([i for i in list(colors.values()) if i != 0]) 
max_kinds = min_kinds + over_3200
print(' '.join([str(max([1, min_kinds])), str(max_kinds)]))

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

using namespace std;

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

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

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

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	if (n % 1000 == 0) {
		cout << "0" << endl;
		return 0;
	}

	for (int i = 0; i < 10000; i++) {
		

		if (n < 1000) {
			cout << (1000-n) << endl;
			return 0;
		}

		n -= 1000;
	}
	return 0;
}

Measured memory_bytes: 3620
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a + b) % 2 == 0){
		    System.out.println((a + b) / 2);
		}
		else{
		    System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 21204
from collections import deque
S=input()
Q=int(input())
query=[list(map(str,input().split())) for _ in range(Q)]

d=deque(S)
reverse=False
for q in query:
  if len(q)==1:
    reverse=not reverse
  else:
    _,f,c=q
    if f=='1':
      d.append(c) if reverse else d.appendleft(c)
    else:
      d.appendleft(c) if reverse else d.append(c)
print(*reversed(d),sep='') if reverse else print(*d,sep='')

Measured memory_bytes: 48368
N, M = map(int, input().split())
a = list(map(int, input().split()))
mn = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

msort = lambda s: -s[0]

b = list(map(lambda i: [i, mn[i]], a))
b.sort(key = msort)
dp = [-100] * (N + 1)
dp[0] = 0
for i in range(2, N + 1):
  for n in b:
    if i >= n[1] and dp[i - n[1]] >= 0:
      dp[i] = max([dp[i], dp[i - n[1]] + 1])

match = N
ans = ''
while match > 0:
  for n in b:
    if match >= n[1] and dp[match] == dp[match - n[1]] + 1:
      ans += str(n[0])
      match -= n[1]
      break
    
print(ans)

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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int max = -1000001;
		int max_num = 0;
		int min = 1000001;
		int min_num = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(a[i] > max) {
				max = a[i];
				max_num = i;
			}
			if(a[i] < min) {
				min = a[i];
				min_num = i;
			}
		}
		int max_abs = Math.max(Math.abs(max), Math.abs(min));
		System.out.println((n-1)*2);
		int aa = 0;
		if(max_abs == Math.abs(max))aa=max;
		else if(max_abs == Math.abs(min))aa = min;
		
		if(max_abs == Math.abs(max)) {
			for(int i = 0; i < n; i++) {
				if(max_num == i)continue;
				System.out.println((max_num+1) + " " + (i+1));
			}	
		}else if(max_abs == Math.abs(min)) {
			for(int i = 0; i < n; i++) {
				if(min_num == i)continue;
				System.out.println((min_num+1) + " " + (i+1));
			}	
		}
		
		if(aa >= 0) {
			for(int i = 0; i < n-1; i++) {
				System.out.println((i+1) + " " + (i+2));
			}
		}else {
			for(int i = n-1; i > 0; i--) {
				System.out.println((i+1) + " " + i);
			}
		}
			
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

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

int main()
{
    int a,b;cin>>a>>b;
    int tmp = min(a,b);
    int p = max(a,b);
    for(int i=0;i<p;i++)
        cout<<tmp;
    cout<<endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#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 pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

struct edge {
	int to, cost;
};
vector<edge> G[1 << 19];
int dist[1 << 19];
void solve() {
	int x, y, z, n, m, s, t;
	cin >> x >> y >> z >> n >> m >> s >> t;
	s = (s - 1) + x + y + z;
	t = (t - 1) + x + y + z + n;
	rep(i, n) {
		int a, b; cin >> a >> b; a--; b--;
		G[i + x + y + z].push_back({ a,1 });
		G[a].push_back({ i + x + y + z,0 });
		G[i + x + y + z].push_back({ b+x,1 });
		G[b+x].push_back({ i + x + y + z,0 });
	}
	rep(i, m) {
		int c, d; cin >> c >> d; c--; d--;
		int id = i + x + y + z + n;
		G[id].push_back({ c + x,1 });
		G[c + x].push_back({ id,0 });
		G[id].push_back({ d + x + y,1 });
		G[d + x + y].push_back({ id,0 });
	}
	rep(i, x + y + z + n + m)dist[i] = mod;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push({ 0,s }); dist[s] = 0;
	while (!q.empty()) {
		P p = q.top(); q.pop();
		int id = p.second;
		if (dist[id] < p.first)continue;
		rep(j, G[id].size()) {
			int to = G[id][j].to;
			int nd = G[id][j].cost + p.first;
			if (nd < dist[to]) {
				dist[to] = nd;
				q.push({ nd,to });
			}
		}
	}
	if (dist[t] == mod)dist[t] = -1;
	cout << dist[t] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(8);
	//init();
	solve();
	stop
		return 0;
}



Measured memory_bytes: 33736
using System;

namespace ABC
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            ABC104_A();
        }

        static void ABC104_A()
        {
            var R = int.Parse(Console.ReadLine());
            if (R < 1200)
                Console.WriteLine("ABC");
            else if (R < 2800)
                Console.WriteLine("ARC");
            else
                Console.WriteLine("AGC");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x.at(i);
    int ans = 1e8;
    rep(p,101){
        int sum = 0;
        rep(i,n){
            sum += (p - x.at(i))*(p - x.at(i));
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#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 f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


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


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}*/
int n,neg_sum = 0,pos_sum = 0;
vector<int>pos,neg;

signed main()
{
    showoff;
    cin >> n;
    FOR(i,1,n+1){
        int x;
        cin >> x;
        if(x >= 0){pos.pb(x);pos_sum += x;}
        else if(x < 0){neg.pb(x);neg_sum -= x;}
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end(),greater<int>());
    if(sz(neg) == 0){cout << pos_sum-2*pos[0] << "\n";
    int ts = pos[0];
    FOR(i,1,sz(pos)-1){
        cout << ts << " " << pos[i] << "\n";
        ts -= pos[i]; 
    }
    cout << pos.back() << " " << ts << "\n";
    return 0;}
    if(sz(pos) == 0){cout << neg_sum+2*neg[0] << "\n";
    int ts = neg[0];
    FOR(i,1,sz(neg)){
        cout << ts << " " << neg[i] << "\n";
        ts -= neg[i]; 
    }
    return 0;}
    cout << neg_sum+pos_sum << "\n";
    int ts = neg[0];
    FOR(i,0,sz(pos)-1){cout << ts << " " << pos[i] << "\n";ts -= pos[i];}
    cout << pos.back() << " " << ts << "\n";
    ts = pos.back()-ts;
    FOR(i,1,sz(neg)){cout << ts << " " << neg[i] << "\n";ts -= neg[i];}
    return 0;     
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

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

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >>v[i];
  }
  
  vector<int> ans(n+2,0);
  for(int i=0;i<n;i++){
    ans[v[i]-1]=1;
  }
  
  int a,b;
  for(int i=0;;i++){
    a=x+i;
    b=x-i;
    if(ans[a-1]==1){
      if(ans[b-1]==1){
        continue;
      }
      else{
        cout << b <<endl;
        break;
      }
    }
    if(ans[b-1]==1){
      if(ans[a-1]!=1){
        cout << a <<endl;
        break;
      }
    }
    if(ans[a-1]!=1 || ans[b-1]!=1){
      cout << b <<endl;
      break;
    }
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

bool ok(vector<int> &a, double x, int k) {
	int k0;
	for (int d : a) {
		k0 = ceil(d / (x )) - 1;
		if (round(d / (k0 + 1)) > x) {
			k0++;
		}
		k -= k0;
	}

	return k >= 0;
}

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

    int l = 0;
    int r = 1000000001;
    int m;
    while (l < r - 1) {
    	m = l + (r - l) / 2;
    	if (ok(a, m, k)) {
    		r = m;
    	} else {
    		l = m;
    	}
    }
    cout << r << endl;
}


Measured memory_bytes: 4740
Module _20190421

    Sub Main()

        '文字列の長さ
        Dim iStrLength As Integer = CInt(Console.ReadLine())

        '文字列
        Dim sStr As String = Console.ReadLine()

        '整数
        Dim iNumber As Integer = CInt(Console.ReadLine())

        '文字列を分解
        Dim arrStr() As Char = sStr.ToCharArray

        '比較する文字を取得
        Dim sCompareStr As String = arrStr(iNumber - 1)

        '出力文字列
        Dim sOutput As String = ""

        For i As Integer = 0 To iStrLength - 1

            If arrStr(i) = sCompareStr Then

                sOutput = sOutput & arrStr(i)

            Else

                sOutput = sOutput & "*"

            End If

        Next

        Console.WriteLine(sOutput)

    End Sub

End Module

Measured memory_bytes: 19792
n=int(input())
a=list(map(int,input().split()))
ans=0
now=a[0]
cnt=1
i=1
for i in range(1,n):
    if(a[i]==now):
        cnt+=1
    else:
        ans+=cnt//2
        cnt=1
        now=a[i]
ans+=cnt//2
print(ans)

Measured memory_bytes: 3064