akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K;
    R(N,K);
    VI A(N);
    REP(i,N)R(A[i]);
    sort(ALL(A));
    VI d;
    for(int i=0,j;i<N;i=j){
        for(j=i+1;j<N&&A[j]==A[i];j++);
        d.PB(j-i);
    }
    sort(ALL(d));
    if(SZ(d)<=K)W(0);
    else{
        int an=0;
        REP(i,SZ(d)-K)an+=d[i];
        W(an);
    }
    return 0;
}


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

int main() {
	const int n = 3;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = 0;
	rep(i, n - 1){
		ans += a[i+1] - a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 int f[366],m[366],sum;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
       ll n,k;
       cin>>n;
       ll ar[n+1];
       vector<ll>v;
       for(ll i=0;i<n;i++)
       {
           cin>>ar[i];
       }

        ll m=1000,t;
        ar[n]=ar[n+1];
        for(int i=0;i+1<n;i++)
        {
            if(ar[i]>=ar[i+1])continue;
            else{
            t=m/ar[i];
            m%=ar[i];
            m+=(ar[i+1]*t);
            }
        }
        cout<<m;


}


Measured memory_bytes: 3644
def atc_136a(input_v: str) -> int:
    ABC = input_v.split(" ")
    A = int(ABC[0])
    B = int(ABC[1])
    C = int(ABC[2])

    D = C - (A - B)

    if D < 0:
        return 0
    else:
        return D

abc = input()
print(atc_136a(abc))


Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<float> mountains;
  float tmp;
  while(cin >> tmp){
    mountains.push_back(tmp);
  }
  float max, min;
  max = *max_element(mountains.begin(), mountains.end());
  min = *min_element(mountains.begin(), mountains.end());
  cout << max - min << endl;
}

Measured memory_bytes: 1296
#include <iostream>

using namespace std;

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

    int h, m;
    h = s / (60 * 60);
    s = s % (60 * 60);

    m = s / 60;
    s = s % 60;

    cout << h << ':' << m << ':' << s << '\n';
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <iomanip> 
#include <stack>
#include <stdlib.h>	
#include <stdio.h>
#define INF 0x3f3f3f3f
#include <set> 
#include <map>  
#include <queue>
#define maxn 300
using namespace std;
typedef long long ll;
struct node {
	int x,y;
}a[205],b[160];
int girl[160],line[160][160];
bool used[160];
int n,x,y;

bool found(int x){
	for(int i=1;i<=n;i++){
		if(line[x][i]&&!used[i]){
			used[i]=1;
			if((girl[i]==0)||found(girl[i])){
				girl[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		a[i].x=x;
		a[i].y=y;
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		b[i].x=x;
		b[i].y=y;
	}
	memset(line,0,sizeof(line));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if((a[i].x<b[j].x)&&(a[i].y<b[j].y)){
				line[i][j]=1;
			}
		}
	}
	memset(girl,0,sizeof(girl));
	int sum=0;
	for(int i=1;i<=n;i++){
		memset(used,0,sizeof(used));
		if(found(i)) sum++;
	}
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

const int maxn=60;
typedef long long LL;

struct Point
{
	int x, y;

	bool operator < (const Point tmp) const
	{
		return x<tmp.x;
	}
};

int n, m;
Point p[maxn];
int h[maxn];
LL ans;

void read()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; ++i)
		scanf("%d%d", &p[i].x, &p[i].y);
	sort(p+1, p+1+n);
}
void solve()
{
	h[1]=1;
	for (int i=2; i<=n; ++i)
		if (p[i].x==p[i-1].x) h[i]=h[i-1];
		else h[i]=i;

	ans=LL(1e19);
	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j)
			for (int k=1; k<=n; ++k) 
			{
				int s=0;
				for (int o=h[k]; o<=n; ++o)
				{
					if (p[i].y<=p[o].y && p[o].y<=p[j].y) ++s;
					if (s>=m)
					{
						ans=min(ans, (LL(p[j].y-p[i].y))*(LL(p[o].x-p[k].x)));
						break;
					}
				}
			}
	printf("%lld\n", ans);
}
int main()
{
	read();
	solve();
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
int n;
while(1==scanf("%d",&n))
{
	int sum=0,i;
	char a[n],b[n],c[n];
	scanf("%s%s%s",a,b,c);
	for(i=0;i<n;i++)
	{
		if((a[i]==b[i])&&(b[i]==c[i]));
		else
		if((a[i]==b[i])||(b[i]==c[i])||(a[i]==c[i]))
		sum++;
		else
		sum+=2; 
	}
	printf("%d",sum);
}
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<int>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll MOD = 1e9+7;
ll power(ll num,ll g,ll mod)
{
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

 ll fac[2000000];
int main() { 
	int x, y;
	cin >> x >> y;
	int n=(2*x-y)/3;
	int m=(2*y-x)/3;
	if(2*x<y || 2*y<x || (x+y)%3){
		cout << 0;
		return 0;
	}
 
	fac[0]=1;
	for(int i=1;i<=n+m;i++)
		fac[i]=(i*fac[i-1])%MOD;
	cout<<(fac[n+m]*power(fac[n],MOD-2, MOD)%MOD)*power(fac[m],MOD-2, MOD)%MOD;
	// a+b C a

} 

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,W;cin>>n>>W;
  vector<int> w(n),v(n);
  rep(i,n)cin>>w[i]>>v[i];
  int mxv=100001;
  vector<vector<ll>> sumw(n+1,(vector<ll>(mxv,1e12)));
  sumw[0][0]=0;
  rep(i,n){
    for(int sumv=0;sumv<mxv;sumv++){
      if(sumv-v[i]>=0){
        sumw[i+1][sumv]=min(sumw[i+1][sumv],sumw[i][sumv-v[i]]+w[i]);
      }
      sumw[i+1][sumv]=min(sumw[i+1][sumv],sumw[i][sumv]);
     }
  }
  int mx;
  rep(i,mxv){
    if(sumw[n][i]<=W){
      mx=max(mx,i);
    }
  }
  cout<<mx<<endl;
}

Measured memory_bytes: 80256
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l, M, N;
int ans;

int main() {
	//freopen("x.in", "r", stdin);

	cin >> M >> N >> m >> n;

	ll sum = 0;
	ll e = 4000;
	ll B = (m * n - 1) * e + 1;
	F0(i, M) F0(j, N) if ((i + 1) % m == 0 && (j + 1) % n == 0) {
		sum -= B;
	}
	else sum += e;


	if (sum > 0) {
		cout << "Yes" << endl;
		F0(i, M) {
			F0(j, N) if ((i + 1) % m == 0 && (j + 1) % n == 0) {
				printf("%d ", -B);
			}
			else printf("%d ", e);
			puts("");
		}
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1536
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())






def main():
	n,m=MI()
	UF=UnionFind(n)

	for _ in range(m):
		a,b=MI()
		UF.union(a-1,b-1)

	ans=0
	for i in range(n):
		ans=max(ans,UF.size(i))
	print(ans)








if __name__ == "__main__":
	main()


Measured memory_bytes: 73132
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    S = sum(A)
    A = sorted(A, reverse=True)
    if A[M-1] < S / (4 * M):
        print(NO)
    else:
        print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,  int> > adj[MAX];

void dijkstra(){
priority_queue<pair<int, int> > PQ;
int color[MAX];
int d[MAX];
for(int i=0; i<n; i++){
d[i] = INFTY;
color[i] = WHITE;
}

d[0] = 0;
PQ.push(make_pair(0, 0));
color[0] = GRAY;

while( !PQ.empty() ) {
pair<int, int> f = PQ.top(); PQ.pop();
int u = f.second;

color[u] = BLACK;

if(d[u] < f.first * (-1) ) continue;

for(int j=0; j<adj[u].size(); j++) {
int v = adj[u][j].first;
if(color[v] == BLACK) continue;
if(d[v] > d[u] + adj[u][j].second){
d[v] = d[u] + adj[u][j].second;

PQ.push(make_pair(d[v] * (-1), v));
color[v] = GRAY;
}
}
}

for(int i=0; i<n; i++){
cout << i << " " << (d[i] == INFTY ? - 1 : d[i]) << endl;
}
}

int main(){
int k, u, v, c;

cin >> n;
for(int i=0; i<n; i++){
cin >> u >> k;
for(int j=0; j<k; j++){
cin >> v >> c;
adj[u].push_back(make_pair(v, c));
}
}

dijkstra();

return 0;
}

Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1001001001;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n, k;

int main(){
  cin >> n >> k;
  int x[100000];
  rep(i, n) cin >> x[i];
  int ans = INF;
  for(int i = 0; i < n - k + 1; i++){
    if(x[i] < 0 && x[i+k-1] > 0){
      ans = min(ans, min(2 * x[i+k-1]-x[i], x[i+k-1] - 2 * x[i]));
    }else{
      if(x[i+k-1]<=0) ans = min(ans, -1*x[i]);
      else ans = min(ans, x[i+k-1]);
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, q, D[200008], s, t, x, d, ans[200008];
string str;

int main(){
	cin >> n >> q;
	
	vector<tuple<ll, bool, ll>> event;
	for(ll i = 1; i <= n; i++){
		cin >> s >> t >> x;
		event.push_back(make_tuple(-(x-s), true, x));
		event.push_back(make_tuple(-(x-t), false, x)); 
	}
	event.push_back(make_tuple(2e9+8, true, 0));
	sort(event.begin(), event.end());
	
	for(ll j = 0; j < q; j++){cin >> D[j];}

	ll itr = 0;
	ll ei = 0;
	set<ll> stop;
	while(itr < q){
		auto tpl = event[ei];
		if(-get<0>(tpl) >= -D[itr]){
			if(get<1>(tpl)){stop.insert(get<2>(tpl));}// cout << get<2>(tpl) << endl;}
			else{stop.erase(get<2>(tpl));}
			ei++;
		}
		else{
			ans[itr] = (stop.empty())? -1 : *stop.begin();
			itr++;
		}
	}
	for(ll j = 0; j < q; j++){cout << ans[j] << endl;}
	return 0;
}

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

int main() {
  int n;
  long double a, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ans += 1.0 / a;
  }
  cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

int main() {
    int n, m, ans;

    scanf("%d %d", &n, &m);

    ans = (n - 1) * (m - 1);

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

Measured memory_bytes: 1696
#include <iostream>
#include <stdio.h>
using namespace std;

class seiseki{
	public:
		int m;
		int f;
		int r;
		char result;
	public:
		seiseki() {m=f=r=result=0;}
		void input();
		void disp() {cout << result;}
};

void seiseki::input()
{
	cin >> m >> f >> r;
	int sum = m+f;
	
	if(m==-1 || f==-1)
		result = 'F';
	else if(sum >=80)
		result = 'A';
	else if(sum >=65)
		result = 'B';
	else if(sum >=50)
		result = 'C';
	else if(sum >= 30){
		if(r >= 50)
			result = 'C';
		else
			result = 'D';
	}
	else
		result = 'F';
}

int main()
{
	seiseki dt[100];
	
	int n=0;
	while(1){
		dt[n].input();
		if(dt[n].m == -1 && dt[n].f == -1)	break;
		n++;
	}
	for(int i=0; i<=n-1; i++){
		dt[i].disp();
		cout << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
////////////////////////////////////////////////////////////////////
int main(){
    ll N;
    cin >> N;
    VL a,b;
    VSCLLD(a,N);
    VSCLLD(b,N);

    ll acount = 0;
    ll bcount = 0;

    REP(i,N){
        if (a[i] < b[i]){
            acount += ((b[i]-a[i]) + (2 - 1)) / 2;
            
        }else if (a[i] > b[i]){
            bcount += (ll)(a[i] - b[i]);
        }
    }

    ll sa,sb;
    sa = 0; sb = 0;
    REP(i,N){
        sa += a[i];
        sb += b[i];
    }

    if (sb - sa >= max(acount , bcount)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
}


Measured memory_bytes: 512
s;n,k,i,y;d['   '];c(int*z){i=*1[&z]-*z;}main(x){for(scanf("%*d");~scanf("%d%d%d",&n,&k,&y);printf("%d\n",s)){for(i=--n;s=i;y=x)scanf("%d",&x),d[--i]=x-y;qsort(d,n,4,c);for(;n>=k;s+=d[--n]);}}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    string n;
    cin >> n;
    if(n.at(0)=='7' || n.at(1)=='7' || n.at(2)=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    w_tmp,v_tmp=map(int,input().split())
    w.append(w_tmp)
    v.append(v_tmp)

dp=[{} for _  in range(N+1)]
def rec(i,j):
    if j in dp[i] :
        return dp[i][j]
    if i==N:
         res=0
    elif j<w[i]:
        res=rec(i+1,j)
    else:
        res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i])
    dp[i][j]=res
    
    return res

print(rec(0,W))
    


Measured memory_bytes: 10852
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var str [3]string

	for i := 0; i < 3; i++ {
		fmt.Scan(&str[i])
	}
	num, _ := strconv.Atoi(strings.Join(str[:], ""))
	if num%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {

	for {
		var a, b, c, d, e, f float64
		var x, y float64
		i, _ := fmt.Scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)
		if i != 6 {
			return
		}

		// x = ((e * c) - (b * f)) / ((a * e) - (b * d))
		y = ((a * f) - (d * c)) / ((a * e) - (b * d))
		x = (c - b*y) / a

		fmt.Printf("%.3f %.3f\n", x, y)
	}
}



Measured memory_bytes: 1168
N,A,B = map(int,input().split())
s = input()
a = 0
b = 0
for i in s:
  if i == 'a' and a+b < A+B:
    print('Yes')
    a += 1
  elif i == 'b' and a+b < A+B and b  < B:
    print('Yes')
    b += 1
  else:
    print('No')


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, ans = 0;
    cin >> n;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        ans = __gcd(ans, x);
    }
    cout << ans;
}


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

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> p(105);
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		p[a] = 1;
	}
	int res = 1000;
	for (int i = 0; i < 105; i++) {
		if (!p[i]) {
			if (abs(i-x) < abs(res-x)) {
				res = i;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3624
'use strict';
(function(stdin) {
    var inputs = stdin.toString().split(' ').map(Number);
    var a = inputs[0];
    var b = inputs[1];
    var c = inputs[2];
    var count = 0;
    for (var i = a; i <= b; i++) {
        if (c % i === 0)
            count++;
    }
    console.log(count);

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

Measured memory_bytes: 15688
N, M = map(int, input().split())
H = list(map(int, input().split()))
connected_li = [None] * N
is_alone_li = [True] * N
ans = 0

for _ in range(M):
    A, B = map(int, input().split())
    if connected_li[A - 1] is None:
        connected_li[A - 1] = [B - 1]
        connected_li[A - 1] = set(connected_li[A - 1])
    else:
        connected_li[A - 1].add(B - 1)

    if connected_li[B - 1] is None:
        connected_li[B - 1] = [A - 1]
        connected_li[B - 1] = set(connected_li[B - 1])
    else:
        connected_li[B - 1].add(A - 1)

for i in range(N):
    if connected_li[i] is None:
        ans += 1
    else:
        flg = True
        for idx in connected_li[i]:
            if H[i] <= H[idx]:
                flg = False
                break
        if flg:
            ans += 1

print(ans)


Measured memory_bytes: 105176
import string
def main():
    s = input()
    if len(s) < 26:
        print(s + sorted(list(set(string.ascii_lowercase) - set(s)))[0])
    else:
        t = []
        for i in range(len(s)):
            te = []
            for j in range(i+1, len(s)):
                if s[i] < s[j]: te.append(s[j])
            te.sort()
            t.append(te)
        for i in range(len(s)):
            if t[-1-i]:
                print(s[:-1-i] + t[-1-i][0])
                break
        else: print(-1)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3768
#include<iostream>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    while(x!=0 || y!=0){
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
        cin >> x >> y;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<stdio.h>

int main(){
    char s[200000];
    int i, sum = 0;
    scanf("%s", s);
    if(s[1] == '\0'){
        if(s[0] == '?') s[0] = 'D';
    }
    else {
    for(i=0; s[i+1] != '\0'; i++){
        switch(s[i+1]){
            case '?':
                if(s[i] == 'P'){ //P?
                    sum += 2;
                    s[i+1] = 'D';
                }
                else if(s[i] == 'D'){ //D?
                    sum += 2;
                    s[i+1] = 'D';
                }
                else{
                    sum += 2; //??
                    s[i] = 'D';
                }
                break;
            case 'P': //PP, DP, ?P
                if(s[i] == '?') s[i] = 'D';
                break;
            case 'D':
                if(s[i] == 'P'){ //PD
                    sum += 1;
                }
                else if(s[i] == 'D'){ //DD
                    sum += 2; 
                }
                else{
                    sum += 2; //?D
                    s[i] = 'P';
                }
                break;
        }
    }
    if(s[i] == '?') s[i] = 'D';
    }
    for (i = 0; s[i] != '\0'; i++){
        printf("%c", s[i]);
    }
    //printf("%d", sum);
    return 0;
}

Measured memory_bytes: 1856
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = sum(B)-sum(A)

if k < 0:
    print('No')
else:
    cnt_a = cnt_b = 0
    for a, b in zip(A, B):
        if a < b:
            x, y = divmod((b-a), 2)
            cnt_a += x+y
            cnt_b += y
        elif b < a:
            cnt_b += b-a
    if max(cnt_a, cnt_b) <= k:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4600
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    cout << fixed << setprecision(6);

    string s; cin >> s;
    int n = s.size();
    int out = 0;
    for (int i = 0; i <n/2; i++)
    {
        if(s[i]!=s[n-1-i]){
            out++;
        }
    }
    cout << out << endl;
    
    return 0;
}

Measured memory_bytes: 3164
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main implements Runnable{
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        long T[] = new long[N];

        for(int i = 0; i < N; i++) {
            T[i] = scan.nextLong();
        }

        scan.close();


        long result = T[0];

        for (int i = 1; i < N; i++) {
            result = lcm(result, T[i]);
        }


        os.println(result);
    }

    static public long lcm(long a, long b) {
        if(a == b)
            return a;

        if(a > b) {
            long tmp = a;
            a = b;
            b = tmp;
        }

        long answer =  a*(b/(gcd(a, b)));
        return answer;
    }

    static public long gcd(long a, long b) {
        while(a > 0) {
            long tmpa = a;
            a = b % a;
            b = tmpa;
        }
        return b;
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int h[LIMIT2]={0};
  ll dp[LIMIT1]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d",&h[i]);
  for(i=1;i<n;i++){
    if(i>=2){
      dp[i] = min(dp[i-1]+(ll)abs(h[i]-h[i-1]),dp[i-2]+(ll)abs(h[i]-h[i-2]));
    }else{
      dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
    }
  }
  printf("%lld",dp[n-1]);
  return 0;
}



Measured memory_bytes: 3712
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#define MAXN 300006
using namespace std;
long long ans,ansl[MAXN],ansr[MAXN];
int X,Y,Z,n;
struct node
{
	long long x,y,z;
}a[MAXN];
priority_queue<long long> q;
bool cmp(node a,node b)
{
	return a.x-a.y>b.x-b.y;
}
int main()
{
	scanf("%d%d%d",&X,&Y,&Z);
	n=X+Y+Z;
	for(int i=1;i<=n;i++)
		scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].z);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=X+Z;i++)
	{
		q.push(a[i].z-a[i].x);
		ansl[i]=ansl[i-1]+a[i].x;
		if(i>X)
		{
			ansl[i]+=q.top();
			q.pop();
		}
	}
	while(!q.empty())
		q.pop();
	for(int i=X+Y+Z;i>X;i--)
	{
		q.push(a[i].z-a[i].y);
		ansr[i]=ansr[i+1]+a[i].y;
		if(i<=X+Z)
		{
			ansr[i]+=q.top();
			q.pop();
		}
	}
	for(int i=X;i<=X+Z;i++)
		ans=max(ans,ansl[i]+ansr[i+1]);
	printf("%lld",ans);
}

Measured memory_bytes: 7924
#include<stdio.h>
int main(void)
{
	int a, b, c, n;
	scanf("%d %d %d", &a, &b, &c);
	n = a;
	a = b;
	b = n;
	n = a;
	a = c;
	c = n;
	printf("%d %d %d", a, b, c);
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8

def printA(a, n):
    for i in range(n):
        print(a[i],end="")
        if i < n - 1:
            print(" ", end="")
        else:
            print()

def selectionSort(a, n):
    count = 0
    for i in range(n):
        minj = i
        for j in range(i,n):
            if a[j] < a[minj]:
                minj = j
        a[i],a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count

n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
c = selectionSort(a, n)
printA(a, n)
print(c)


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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;

int x, y, z, k;
vector<ll> a, b, c;
multiset<ll> sums;

bool valid(ll sum) {
	ll cnt = 0;
	
	for (int i = 0; i < z; ++i) {
		auto it = sums.rbegin();
		while (cnt < k && it != sums.rend() && *it + c[i] >= sum) {
			++cnt, ++it;
		}
	}
	
	return cnt >= k;
}

ll bsearch(ll l, ll r) {
	
	if (l == r) return l;
	if (l + 1 == r) {
		if (valid(r)) return r;
		else return l;
	} else {
		ll m = (l + r) / 2;
		if (valid(m)) return bsearch(m, r);
		else return bsearch(l, m - 1);
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> x >> y >> z >> k;
	a.resize(x), b.resize(y), c.resize(z);
	for (auto& i : a) cin >> i;
	for (auto& i : b) cin >> i;
	for (auto& i : c) cin >> i;
	
	for (int i = 0; i < x; ++i) {
		for (int j = 0; j < y; ++j) {
			sums.insert(a[i] + b[j]);
		}
	}
	
	ll minSum = bsearch(0, 3 * 1e10);
	vector<ll> res;
	
	for (int i = 0; i < z; ++i) {
		auto it = sums.rbegin();
		while (it != sums.rend() && *it + c[i] >= minSum) {
			res.push_back(*it + c[i]);
			++it;
		}
	}
	
	sort(all(res), greater<ll>());
	for (int i = 0; i < k; ++i) cout << res[i] << '\n';
}


Measured memory_bytes: 181356
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      //取得
      int[] c = new int[9];
      for(int i=0; i<9; ++i){
        c[i] = sc.nextInt();
      }
      int d1 = c[1]-c[0];
      int d2 = c[2]-c[1];
      String ans = "Yes";
      if(c[4]!=c[3]+d1){
        ans="No";
      } if(c[7]!=c[6]+d1){
        ans="No";
      } if(c[5]!=c[4]+d2){
        ans="No";
      } if(c[8]!=c[7]+d2){
        ans="No";
      }
      System.out.println(ans);
	}
}

Measured memory_bytes: 35660
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

int main()
{
	int n, sum;
	int m[11][11];
	while(cin >> n){
		if(n == 0) break;
		for(int i=0; i<n; i++){
			sum = 0;
			for(int j=0; j<n; j++){
				cin >> m[i][j];
				sum += m[i][j];
				printf("%5d", m[i][j]);
			}
			printf("%5d\n", sum);
		}
		for(int i=0; i<n; i++){
			sum = 0;
			for(int j=0; j<n; j++){
				sum += m[j][i];
			}
			m[n][i] = sum;
			printf("%5d", m[n][i]);
		}
		sum = 0;
		for(int i=0; i<n; i++) sum += m[n][i];
		printf("%5d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1160
import numpy as np

class SieveOfEratosthenes:
    def __init__(self, V):
        self.is_prime = np.ones(V + 1, dtype=bool)
        self.is_prime[4::2] = False
        self.is_prime[9::3] = False
        self.is_prime[25::5] = False
        self.primes = [2, 3, 5]
        for i in range(7, V + 1, 2):
            if self.is_prime[i]:
                self.primes.append(i)
                self.is_prime[i * i::i] = False
    
    def factorize(self, x):
        assert x >= 1
        if x == 1:
            return [(1, 1)]
        result = []
        for p in self.primes:
            exp = 0
            while x % p == 0:
                exp += 1
                x = x // p
            if exp > 0:
                result.append((p, exp))
            if p * p > x:
                break
        if x > 1:
            result.append((x, 1))
        return result


N = int(input())
M = 10**9 + 7
A = list(map(int, input().split()))

sieve = SieveOfEratosthenes(10**3)
F = [dict(sieve.factorize(a)) for a in A]

lcm = F[0]
for i in range(1, len(F)):
    for p, e in F[i].items():
        if p in lcm:
            lcm[p] = max(lcm[p], e)
        else:
            lcm[p] = e

val = 1
for p, e in lcm.items():
    val = val * pow(p, e, M) % M
# print(val)

B = [val * pow(a, M - 2, M) % M for a in A]
print(sum(B) % M)
    

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

int main(){
  
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  if (a+b > c+d){
    
    cout << "Left" << endl ;
  }
  else if (a+b == c+d){
    
    cout << "Balanced" << endl ;
  }
  else if (a+b < c+d){
    
    cout << "Right" << endl;
  }
}

    
  
  


Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H - 1:
            print('#' * W)
        else:
            print('#' + '.' * (W - 2) + '#')
    print()


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

int main() {

    ll n , k , i ;
    cin >> n >> k ;
    vector<ll>v(n) ;
    ll sum = 0 ;
    for (i =0 ; i< n ; i++) {
        cin >> v[i] ;
    }
    sort(v.begin(),v.end()) ;
    for (i =0 ; i< k ; i++) sum+=v[i] ;
    cout << sum ;

    return 0 ;
}


Measured memory_bytes: 3636
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int mod=1e9+7;
const int MAX=1e6+7;
int a[30]; 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
   string s;cin>>s;
   int n=s.size(),l=-1,r=-1;
   for(int i=1;i<n;i++){
   		if(s[i]==s[i-1]){
   			l=i;r=i+1;break;	
		}
   }
   if(l!=-1&&r!=-1){
   		cout<<l<<" "<<r;return 0;
   }
   for(int i=0;i<n-2;i++){
   		if(s[i]==s[i+2]){
   			l=i+1;r=i+3;break;	
		}
   }
   cout<<l<<" "<<r;
   return 0;
} 

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int count = 1;
	int kaigai = 1;
	rep(i,n){
		if(s[i] == 'a'){
			if(count <= a+b){
				cout <<  "Yes" << endl;
				count++;
			}else{
				cout << "No" << endl;
			}
		} else if (s[i] == 'b'){
			if(count <= a + b && kaigai <= b){
				cout << "Yes" << endl;
				count++;
				kaigai++;
			}else{
				cout << "No" << endl;
			}
		} else if (s[i] == 'c'){
			cout << "No" << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 896
N, S, *A = map(int, open(0).read().split())
mod = 998244353

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S + 1):
        dp[i + 1][j] += dp[i][j] * 2
        dp[i + 1][j] %= mod
        if j + A[i] <= S:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod

print(dp[-1][-1])


Measured memory_bytes: 138988
/**
*   @Author : MeGaCrazy
*   @InitTime : Sat Jan 05 03:27:58 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
map<pair<int,int>,bool>mp;

int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
  	int a,b;
  	cin>>a>>b;
  	mp[make_pair(a,b)]=1;
 
 }
 for(int i=0;i<n;i++){
 	if(mp[make_pair(1,i)] && mp[make_pair(i,n)]){
 		cout<<"POSSIBLE"<<endl;
 		return 0;
 	}
 }
 cout<<"IMPOSSIBLE"<<endl;



}

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

int main() {
  int DIV = 1e+9 + 7;
  string S; cin >> S;
  int N = S.size();
  long dp[N][13];
  for (int i = 0; i < 13; i++) dp[0][i] = ((S[0] == '?' && i < 10) || i == S[0] - '0');
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 13; j++) dp[i][j] = 0;
    for (int j = 0; j < 13; j++) {
      if (S[i] == '?') {
        for (int k = 0; k < 10; k++)
          dp[i][(j*10+k)%13] = (dp[i][(j*10+k)%13] + dp[i-1][j]) % DIV;
      }
      else
        dp[i][(j*10 + (S[i] - '0'))%13] = (dp[i][(j*10 + (S[i] - '0'))%13] + dp[i-1][j]) % DIV;
    }
  }
  cout << dp[N-1][5] << endl;
}

Measured memory_bytes: 13832
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a.begin(),a.end());
	int bef=-1;
	int count=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(bef==a[i])count++;
		else
		{
			if(count%2!=0)ans++;

			count=1;
			bef=a[i];
		}
	}
	if(count%2!=0)ans++;

	cout << ans << endl;




	
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef tuple<ll, ll, ll, ll> quad;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X);
  rep(i, X) {
    cin >> A[i];
  }
  vector<ll> B(Y);
  rep(i, Y) {
    cin >> B[i];
  }
  vector<ll> C(Z);
  rep(i, Z) {
    cin >> C[i];
  }
  sort(all(A), greater<ll>());
  sort(all(B), greater<ll>());
  sort(all(C), greater<ll>());

  // priority_queue<quad, vector<quad>, greater<quad> > q;
  priority_queue<quad> q;
  q.emplace(A[0] + B[0] + C[0], 0, 0, 0);
  set<triple> s;
  s.emplace(0, 0, 0);
  vector<ll> ans;
  while (!q.empty() && ans.size() < K) {
    ll x, i, j, k;
    tie(x, i, j, k) = q.top(); q.pop();
    ans.push_back(x);
    if (i+1 < X && s.count(make_tuple(i+1, j, k)) == 0) {
      s.emplace(i+1, j, k);
      q.emplace(A[i+1] + B[j] + C[k], i+1, j, k);
      // cout << "A[i+1] + B[j] + C[k]: " << A[i+1] + B[j] + C[k] << endl;
    }
    if (j+1 < Y && s.count(make_tuple(i, j+1, k)) == 0) {
      s.emplace(i, j+1, k);
      q.emplace(A[i] + B[j+1] + C[k], i, j+1, k);
      //cout << "A[i] + B[j+1] + C[k]: " << A[i] + B[j+1] + C[k] << endl;
    }
    if (k+1 < Z && s.count(make_tuple(i, j, k+1)) == 0) {
      s.emplace(i, j, k+1);
      q.emplace(A[i] + B[j] + C[k+1], i, j, k+1);
      // cout << "A[i] + B[j] + C[k+1]: " << A[i] + B[j] + C[k+1] << endl;
    }
  }

  rep(i, ans.size()) {
    cout << ans[i] << endl;
  }
}


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


int main()
{
	//freopen("input16.txt","r",stdin);freopen("output16.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,x,i,a[100000],x1,s=0;
	cin>>n>>x;
	for (i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	for (i=1;i<n;i++){
		if (a[i]+a[i-1]>x){
			x1=a[i]+a[i-1]-x;
			if (x1>a[i]){
				x1-=a[i];
				a[i]=0;
				a[i-1]-=x1;
			}
			else {
				a[i]-=x1;
			}
		}
	}
	for (i=0;i<n;i++){
		s-=a[i];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define MAX_N 60
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
pii students[MAX_N];
pii checkP[MAX_N];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i = 0;i < n;i++){
        cin >> students[i].F >> students[i].S;
    }
    for (int i= 0;i < m;i++){
        cin >> checkP[i].F >> checkP[i].S;

    }
    int cdist;
    for (int i= 0;i < n;i++){
        int mindist = 1e9,minin = -1;
        for (int j = 0;j < m;j++){
            cdist = (abs(students[i].F - checkP[j].F)) + (abs(students[i].S - checkP[j].S));
            if (cdist < mindist){
                mindist = cdist;
                minin = j;
            }
        }
        cout << minin + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;


ll solve(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    vector<vector<int> > adj(n);
    for(int &i:h) cin>>i;
    while(m--){
        int u,v;
        cin>>u>>v;u--,v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int x=1;
        for(int j:adj[i]) if(h[i]<=h[j]) x=0;
        ans+=x;
    }
    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


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

using namespace std;

int main(void){
	int n, x;
	int m[101];
	int mi = 1000000;
	scanf("%d %d", &n, &x);
	for(int i = 0;i < n;++i){
		scanf("%d", m + i);
		x -= m[i];
		mi = min(mi, m[i]);
	}
	printf("%d\n", n + (x/mi));
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [a for a in input().split()]

def chk(i):
    s = str(i)
    for a in s:
        if a in A:
            return 0
    return 1

i = N
while True:
    if chk(i):
        print(i)
        break
    i += 1

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n0, n) for (int i = n0; i < n; i++)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back
#define mp make_pair

signed main()
{
	int HH, WW;
	cin >> HH >> WW ;
	int maps[HH][WW],ary1[HH][WW],ary2[HH][WW];
	char temp ;
	rep(i,HH) {
		rep(j,WW) {
		cin >> temp;
		if(temp=='.') maps[i][j] = 1;
		else maps[i][j] = 0;
		}
	}
	vector <int> cat;
	cat.push_back(0);
	int catl = 1;
	int count = 0;
	rep(i,HH) {
		rep(j,WW) {
			if(maps[i][j] == 1) {
				count ++;
				ary1[i][j] = catl;
			} else {
				ary1[i][j] = 0;
				cat.push_back(count);
				count = 0;
				catl ++ ;
			}
		}
		if (count > 0) {
			cat.push_back(count);
			count = 0;
			catl ++ ;
		}
	}

	rep(j,WW) {
		rep(i,HH) {
			if(maps[i][j] == 1) {
				count ++;
				ary2[i][j] = catl;
			} else {
				ary2[i][j] = 0;
				cat.push_back(count);
				count = 0;
				catl ++ ;
			}
		}
		if (count > 0) {
			cat.push_back(count);
			count = 0;
			catl ++ ;
		}
	}

	int tm = 1;
	int max = 1;

	rep(i,HH) {
		rep(j,WW) {
			tm = cat[ary2[i][j]] + cat[ary1[i][j]];
			if (tm > max) {
				max = tm;
			}
		}
	}
	cout << max - 1 << endl;
	return 0;
}


Measured memory_bytes: 81380
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a<b) swap(a,b);
	if(a>b+1) cout<<a*2-1;
	else if(a==b+1)cout<<a+b;
	else    cout<<b*2;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
int a[MAXN];

bool check(int N, LL K, int A, int B) {
     LL ans = 0;
     int offs = A - B;
     for (int i = 0; i < N; i++) {
         LL tmp = a[i] - K * B;
         if (tmp > 0) {
             ans += tmp / offs;
             if (tmp % offs) ans++;
         }
     }
     return K >= ans;
}

int main() {
    int N, A, B;
    while (~scanf("%d %d %d", &N, &A, &B)) {
          for (int i = 0; i < N; i++) {
              scanf("%d", &a[i]);
          }
          int l = 1, r = (int)1e9 + 1;
          while (l < r) {
                int mid = (l + r) / 2;
                if (check(N, mid, A, B)) r = mid;
                else l = mid + 1;
          }
          printf("%d\n", l);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < n; ++i)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; ++i)
    {
        if ((c % i) == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
        cout << s << "\n";
    else
        cout << "red"
             << "\n";
    return 0;
}

Measured memory_bytes: 256