akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n;ll d,a;
  cin>>n>>d>>a;
  v(pll) x(n);
  cin>>x;
  sort(rng(x));
  vi ri(n,0);
  int r = 0;
  rep(l,n){
    while(r<n and (x[l].fi+2*d>=x[r].fi) ){
      r++;
    };
    ri[l] = r;
    if(r==l) r++;
  }
  vl dmg(n+1,0);
  ll ans = 0;
  rep(i,n){
    if(x[i].se>dmg[i]){
      ll bom = dup(x[i].se - dmg[i] ,a) ;
      ans += bom;
      bom *= a;
      dmg[i] += bom;
      dmg[ri[i]] -= bom;
    }
    dmg[i+1] += dmg[i];
  }
  cout<<ans<<endl;

} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> food(m);
    for(int i = 0; i < m; i++){
        food[i] = 0;
    }
    for(int i = 0; i < n; i++){
        int num; cin >> num;
        for(int j = 0; j < num; j++){
            int tmp; cin >> tmp;
            food[tmp-1]++;
        }
    }
    int count = 0;
    for(int i = 0; i < m; i++){
        if(food[i] == n) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
# 料理を最速で届くようにするには、最後に頼む料理に注目する
# 注文して届いた後から次の注文までのインターバルが
# 最も大きいものを最後に注文するべき

cook_time = [int(input()) for _ in range(5)]
interval_time = [0]*5

for i in range(len(cook_time)):
    interval_time[i] = (10 - (cook_time[i]%10))%10
    
print(sum(cook_time)+sum(interval_time)-max(interval_time))

Measured memory_bytes: 2940
import math
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(
            math.floor(a/b)
            )
    elif op=='?':
        break




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

int main(){
  int a, b, k;

  cin >> a >> b >> k;

  for(int i=0;i<k;i++){
    if(a+i <= b){
      cout << a+i << endl;
    }
  }
  for(int j=k-1;j>=0;j--){
    if(b-j > a+(k-1)){
      cout << b-j << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdint>
#include <algorithm>

int main() {
	int n, t;
	std::cin >> n >> t;

	std::int64_t ans = t;
	int prev;
	std::cin >> prev;

	for (int i = 1; i < n; ++i) {
		int a;
		std::cin >> a;

		ans += std::min(a - prev, t);
		prev = a;
	}

	std::cout << ans << std::endl;
}

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

void print_array(int N, int* array)
{
    for (int i = 0; i < N - 1; i++)
        printf("%d ", array[i]);
    printf("%d\n", array[N - 1]);
}

int bubble_sort(int N, int* array)
{
    int flag = 1;
    int counter = 0;
    while(flag)
    {
        flag = 0;
        for(int j=N-1; j>0; j--)
        {
            if(array[j] < array[j-1])
            {
                std::swap(array[j], array[j-1]);
                counter++;
                flag = 1;
            }
        }
    }
    return counter;
}

int main()
{
    /* input process */
    int N;
    scanf("%d", &N);
    int *array = new int[N];
    for (int i = 0; i < N; i++)
        scanf("%d", &array[i]);

    /* sort */
    int counter = bubble_sort(N, array);

    /* print */
    print_array(N, array);
    printf("%d\n", counter);
}


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

#define INF 100000000

using namespace std;

int graph[400][400],n,d[400];
bool visited[400];
vector<int>L;

void Visit(int v){
  
  visited[v]=true;
  for(int i=0;i<n;i++){
    if(graph[v][i]>0 && !visited[i])Visit(i);
  }
  L.push_back(v);
}

int main(void){

  int m,a,b,c;

  cin >> n >> m;

  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    graph[a][b]=c;
  }
  
  Visit(0);
  reverse(L.begin(),L.end());

  fill(d,d+400,0);
  d[0]=0;

  for(int i=1;i<L.size();i++){
    int sum=0;
    for(int j=0;j<L.size();j++)
      if(graph[L[j]][L[i]]>0)
	d[L[i]]=max(d[L[i]],d[L[j]]+graph[L[j]][L[i]]);
  }

  cout << d[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<int, int>P;

int main() {
	string s; cin >> s; bool flag; int ans = 0;
	for (int len = 1; len <= s.length(); len++) {
		for (int i = 0; i < s.length() - len+1; i++) {
			flag = true;
			string t = s.substr(i, len);
			for (int j = 0; j < t.length(); j++) {
				if (t[j] != 'A'&&t[j] != 'C'&&t[j] != 'G'&&t[j] != 'T') {
					flag = false;
					break;
				}
			}
			if (flag == true) {
				ans = max(int(t.length()), ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> P;
const double PI = acos(-1);
const double EPS = 1e-9;

int cmp(double a, double b) {
    const double d = a-b;
    if(abs(d) < EPS) return 0;
    else if(d < 0) return -1;
    return 1;
}

inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

struct line/*{{{*/
{
  P a, b;
  line() {}
  line(const P& p, const P& q) : a(p), b(q) {}

  // AOJ 1171 Laser Beam Reflections
  inline P perpendicular(const P& p) const
  {
    // 点 p から直線上に下ろした垂線の足
    const double t = dot(p-a, a-b) / dot(b-a, b-a);
    return a + t*(a-b);
  }

  inline double distance(const P& p) const {
      return abs(p - this->perpendicular(p));
  }
};/*}}}*/

struct circle/*{{{*/
{
  P o;
  double r;
  circle() {}
  circle(const P& p, double x) : o(p), r(x) {}

  inline bool intersects(const line& ln) const
  {
    return abs(ln.distance(o)) <= r;
  }

  pair<P,P> intersection(const line& ln) const
  {
    // assert(intersects(ln))
    const P h = ln.perpendicular(o);
    const double d = abs(h - o);
    P ab = ln.b - ln.a;
    ab /= abs(ab);
    const double l = sqrt(r*r - d*d);
    return make_pair(h + l*ab, h - l*ab);
  }
};/*}}}*/

struct UFO {
    P pos, dv;
    double r;

    UFO() {}
    UFO(const P &p, double r, double v) : pos(p), r(r) {
        dv = pos * v / abs(pos);
    }

    void move() {
        if(cmp(abs(dv), abs(pos)) >= 0) {
            pos = P(0, 0);
        } else {
            pos -= dv;
        }
    }
};

bool check(const P &p, const P &dir, double R) {
    if(dot(p, dir) < 0) return false;
    return cmp(abs(p), R) > 0;
}

bool solve() {
    int R, N;
    cin >> R >> N;
    if(!R && !N) return false;

    vector<UFO> ufos;
    for(int i = 0; i < N; ++i) {
        double x, y, r, v;
        cin >> x >> y >> r >> v;
        ufos.push_back(UFO(P(x, y), r, v));
    }
    int ans = 0;
    while(true) {
        const int M = ufos.size();
        double min_dist = 1e10;
        int min_idx = -1;
        for(int i = 0; i < M; ++i) {
            UFO &u = ufos[i];
            u.move();
            const double d = abs(u.pos);
            if(cmp(d, R) > 0 && d < min_dist) {
                min_dist = d;
                min_idx = i;
            }
        }
        if(min_idx == -1) break;
        //cout << ufos[min_idx].pos << endl;
        const line l(P(0, 0), ufos[min_idx].pos);
        auto pend = remove_if(ufos.begin(), ufos.end(), [&](const UFO &u) {
                const circle c(u.pos, u.r);
                if(cmp(abs(u.pos), R) <= 0) return false;
                if(!c.intersects(l)) return false;
                const auto tmp = c.intersection(l);
                return check(tmp.first, l.b, R) || check(tmp.second, l.b, R);
                });
        //cout << distance(pend, ufos.end()) << endl;
        ufos.erase(pend, ufos.end());
    }
    cout << ufos.size() << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 500001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pb push_back
#define db double
#define pu puts(" ")
using namespace std;

int read()
{
	int x=0,f=1;
	char ch=gc;
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(char x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int qp(int a,int b,int mod)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}
ll ans;
int main()
{
    int n=rd;
    fo(i,1,n)
    {
    	if(i%3!=0&&i%5!=0)ans+=i;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 1003
#define MOD 1000000007
#define MAXV 500
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

ll n, s[111], ret, c = INFL;

int main () {
	scanf("%lld",&n);
	for(int i=0;i<n;i++) {	
		scanf("%lld",s+i), ret += s[i];
		if(s[i] % 10LL != 0)	c = min(c, s[i]);
	}
	if(ret % 10LL != 0)	printf("%lld\n",ret),exit(0);
	if(c == INFL)		printf("0\n"),exit(0);
	printf("%lld\n",ret - c);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>

using namespace std;

const int maxN = 1e5 + 10;

int n, a[maxN], s[maxN], res;
map < long long, int > mmap;
long long t[maxN];

void update(int x) {
    for (; x <= 1e5; x += (x & (-x)))
        ++t[x];
}

long long get(int x) {
    long long tmp = 0;
    for (; x; x -= (x & (-x)))
        tmp += t[x];
    return tmp;
}


int main() {
    cin >> n;
    int l = 1, r = 1;
    for (int i = 0; i < n; ++i)
        cin >> a[i], r = max(r, a[i]);
    long long req = (1ll * n * (n + 1)) / 2;
    req = (req % 2) ? (req / 2) + 1 : req / 2;
    while (l <= r) {
        int mid = (l + r) >> 1;
        mmap.clear();
        for (int i = 0; i < n; ++i) {
            s[i] = ((i == 0) ? 0 : s[i - 1]) +
                ((a[i] < mid) ? -1 : 1);
            mmap[s[i]] = 0;
        }
        memset(t, 0, sizeof(t));
        int val = 1;
        long long cnt = 0;
        for (auto p : mmap) mmap[p.first] = val++;
        for (int i = 0; i < n; ++i) {
            int v = mmap[s[i]];
            cnt += get(v) + (s[i] >= 0);
            update(v);
        }
        if (cnt >= req) l = mid + 1, res = mid;
        else r = mid - 1;
    }
    cout << res;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


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

  for(i=0;i<q;i++){
    b[a[i]-1]++;
  }

  int lim = q-k;

  for(i=0;i<n;i++){
    if(b[i]>lim){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int y = stoi(s.substr(0, 4));
	int m = stoi(s.substr(5, 2));
	int d = stoi(s.substr(8, 2));

	if(m >= 5) {
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool same(int a, int b){
    return root(a) == root(b);
  }
};

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  ll n,m,k; cin >> n >> m >> k;
  UnionFind uni(n);
  vi deg(n);
  rep(i,m) {
    int a,b; cin >> a >> b;
    a--; b--;
    uni.merge(a,b);
    deg[a]++; deg[b]++;
  }
  vi block(n);
  rep(i,k) {
    int c,d; cin >> c >> d;
    c--; d--;
    if(uni.same(c,d)){
      block[c]++; block[d]++;
    }
  }
  
  rep(i,n) {
    if(i < n-1) cout << uni.size(i) - deg[i] - 1 - block[i] << " ";
    else cout << uni.size(i) - deg[i] - 1 - block[i] << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  auto f = [&](int k) { return abs(sum - a[k] * N); };
  for (int i = 1; i < N; i++) {
    if (f(ans) > f(i)) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    int n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    if (a&1 && b&1){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct UnionFind {
    parent: Vec<i32>,
}

#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: vec![-1; n],
        }
    }
    fn root(&mut self, x: usize) -> usize {
        let p = self.parent[x];
        return if p < 0 {
            x
        } else {
            self.parent[x] = self.root(p as usize) as i32;
            self.parent[x] as usize
        };
    }
    fn union_set(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.root(x);
        let mut y = self.root(y);
        if x == y {
            return false;
        }
        if self.parent[y] < self.parent[x] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent[x] += self.parent[y];
        self.parent[y] = x as i32;
        true
    }
    fn find_set(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
    fn size(&mut self, x: usize) -> usize {
        let r = self.root(x);
        -self.parent[r] as usize
    }
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut pseq = vec![0; n];
    for i in 0..n {
        pseq[i] = read::<usize>() - 1;
    }
    let mut ufind = UnionFind::new(n);
    for _ in 0..m {
        let x = read::<usize>() - 1;
        let y = read::<usize>() - 1;
        ufind.union_set(x, y);
    }
    let mut ans = 0;
    for i in 0..n {
        if ufind.find_set(pseq[i], i) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n,*t=map(int,open(0).read().split());A=t[:n];B=t[n:];r=0
while True:
    c=0
    for i in range(n):
        b=B[(i-1)%n]+B[(i+1)%n]
        if 0<b<B[i] and A[i]<B[i]:
            t=(B[i]-A[i])//b
            c+=t
            B[i]-=t*b
    r+=c
    if c==0:break
    
print([-1,r][A==B])


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

size_t N, W;
vector<int64_t> w, v;

auto dp = make_v(-1LL, 110, int(1e5) + 10);

int64_t rec(size_t idx, int64_t weight) {
    if (idx >= N) return 0;
    if (~dp[idx][weight]) return dp[idx][weight];
    if (weight + w[idx] > W) return rec(idx + 1, weight);
    return dp[idx][weight] = max(rec(idx + 1, weight + w[idx]) + v[idx], rec(idx + 1, weight));
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> W;
    w.resize(N), v.resize(N);

    for (size_t i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    cout << rec(0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 87296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author G. Guarnieri
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] prices = new int[3];
            prices[0] = in.nextInt();
            prices[1] = in.nextInt();
            prices[2] = in.nextInt();

            Arrays.sort(prices);

            System.out.println(prices[0] + prices[1]);
        }

    }
}



Measured memory_bytes: 21844
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val t = sc.nextInt()
    println(problem125a(a, b, t))
}

fun problem125a(a: Int, b: Int, t: Int): Int {
    return b * (t / a)
}

Measured memory_bytes: 31256
x,n=map(int,input().split())
if n!=0: #空行の読み込みを回避、処理を高速化するためにpiを集合型で管理する
 s=set(list(map(int,input().split())))
else:
 s=[]
diff=10**18
ans=10**18
for i in range(-10000,10000): #十分大きな範囲の整数について確かめる
 if i in s: #{pi}に含まれる場合は計算を行わない
   continue
 else:
   if abs(x-i)<diff: #Xとの差の絶対値が最小になるものを求める
     ans=i
     diff=abs(x-i)
print(ans)

Measured memory_bytes: 64704
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 100000000;

int dis[500][500];
int pre[500][500];  //iからjへ行く最短ルートでjの1個前に通るところ
int der[500];

int go(int k, int l){  //kからl
    int res = 0;
    int now = k;
    while(pre[l][now] != -1){
        res += dis[now][pre[l][now]];
        for(int i = 0; i < dis[now][pre[l][now]]; i++) cout << pre[l][now] + 1 << endl;
        now = pre[l][now];
    }
    return res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int u[1000], v[1000], d[1000];
    vector<P> g[500];
    for(int i = 0; i < m; i++){
        cin >> u[i] >> v[i] >> d[i];
        u[i]--;
        v[i]--;
        g[u[i]].push_back(P(v[i], d[i]));
        g[v[i]].push_back(P(u[i], d[i]));
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) dis[i][j] = INF;
    }
    for(int i = 0; i < n; i++){
        priority_queue<P, vector<P>, greater<P>> que;
        dis[i][i] = 0;
        pre[i][i] = -1;
        que.push(P(0, i));
        while(que.size()){
            P nowp = que.top();
            que.pop();
            int now = nowp.second;
            if(dis[i][now] < nowp.first) continue;
            for(P nextp : g[now]){
                int next = nextp.first;
                int cost = nextp.second;
                if(dis[i][next] > dis[i][now] + cost){
                    dis[i][next] = dis[i][now] + cost;
                    pre[i][next] = now;
                    que.push(P(dis[i][next], next));
                }
            }
        }
    }
    int t;
    cin >> t;
    int b[10002];
    fill(b, b + t + 1, -1);
    for(int i = 0; i < t; i++){
        int nw;
        cin >> nw;
        if(nw == 1){
            int id, dst;
            cin >> id >> dst;
            b[i] = dst - 1;
        }
    }
    int lastt = 0;
    int nowt = 0;
    int nowp = 0;
    while(true){
        if(nowp == 0 && b[nowt] != -1) der[b[nowt]]++;
        int near = INF;
        int argnear = -1;
        for(int i = 0; i < n; i++){
            if(der[i] != 0 && dis[nowp][i] < near){
                near = dis[nowp][i];
                argnear = i;
            }
        }
        if(argnear == -1){
            if(nowp != 0){
                int r = dis[nowp][0];
                if(r > t - nowt){
                    for(int i = 0; i < t - nowt; i++) cout << -1 << endl;
                    break;
                }
                nowt += go(nowp, 0);
                for(int i = lastt + 1; i < nowt; i++){
                    if(b[i] != -1) der[b[i]]++;
                }
                nowp = 0;
            }
            else{
                if(t == nowt) break;
                cout << -1 << endl;
                nowt++;
            }
            lastt = nowt;
        }
        else{
            int r = dis[nowp][argnear];
            if(r > t - nowt){
                for(int i = 0; i < t - nowt; i++) cout << -1 << endl;
                break;
            }
            nowt += go(nowp, argnear);
            der[argnear] = 0;
            nowp = argnear;
        }
    }
}

Measured memory_bytes: 1920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximalValue solver = new CMaximalValue();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximalValue {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int b[] = new int[n + 1];
            b[0] = Integer.MAX_VALUE;
            b[n] = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) b[i] = in.nextInt();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += Math.min(b[i], b[i + 1]);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        std::cout << "Possible" << std::endl;
    } else {
        std::cout << "Impossible" << std::endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int i=0;
  int stack[100];
  char s[100];
  
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      stack[i-2] += stack[i-1];
      i--;
    }
	else if(s[0] == '-'){
      stack[i-2] -= stack[i-1];
      i--;
    }
	else if(s[0] == '*'){
      stack[i-2] *= stack[i-1];
      i--;
    }
	else{
      stack[i++] = atoi(s);
    }
  }

  printf("%d\n", stack[0]);
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	string S; cin >> S; 
	long long A[1000010] = {};
	long long B[1000010] = {}; 
	long long sum = 0LL;  
	bool even = true; 
	for(int i = 0; i < N; i++){
		A[i] = S.at(i) - '0'; 
		if((i | (N - 1 - i)) == N-1) sum += A[i]; 
	}
	for(int i = 0; i < N-1; i++){
		B[i] = A[i+1] - A[i]; 
		if(B[i] == 1) even = false; 
	}
	if(sum % 2){
		cout << 1 << endl; return 0; 
	}
	if(!even){
		cout << sum % 2 << endl; return 0; 
	}
	long long sum2 = 0LL; 
	for(int i = 0; i < N-1; i++){
		if((i | (N - 2 - i)) == N-2) sum2 += B[i] / 2; 
	}
	if(sum2 % 2) cout << 2 << endl; 
	else cout << 0 << endl; 
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
typedef long long ll;

int main()
{
	while (1)
	{
		string A, B, C;
		cin >> A;
		if (A.length() == 1 && A[0] == '0') return 0;
		cin >> B >> C;

		ll ans = 1;
		ll plus1 = 0;
		rrep(i, A.length() - 1, 0)
		{
			ll n_ans = 0, n_plus1 = 0;

			rep(a, 0, 10)
			{
				int aa;
				if (i != 0)
				{
					if (A[i] != '?')
					{
						if (a > 0) break;
						aa = A[i] - '0';
					}
					else
					{
						aa = a;
					}
				}
				else
				{
					if (a == 0) continue;
					if (A[i] != '?')
					{
						if (a > 1) break;
						aa = A[i] - '0';
					}
					else
					{
						aa = a;
					}
				}

				rep(b, 0, 10)
				{
					int bb;
					if(i != 0)
					{
						if (B[i] != '?')
						{
							if (b > 0) break;
							bb = B[i] - '0';
						}
						else
						{
							bb = b;
						}
					}
					else
					{
						if (b == 0) continue;
						if (B[i] != '?')
						{
							if (b > 1) break;
							bb = B[i] - '0';
						}
						else
						{
							bb = b;
						}
					}

					rep(ii, 0, 2)
					{
						int sum = aa + bb + ii;
						
						int cc = sum % 10;
						if (C[i] != '?')
						{
							int c = C[i] - '0';
							if (c != cc) continue;
						}

						if (ii == 0)
						{
							if (10 <= sum)
								n_plus1 += ans;
							else
								n_ans += ans;
						}
						else
						{
							if (10 <= sum)
								n_plus1 += plus1;
							else
								n_ans += plus1;
						}
					}
				}
			}

			ans = n_ans % MOD;
			plus1 = n_plus1 % MOD;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3064
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(x)
else:
    for i in range(0,101):
        if x-i not in p:
            print(x-i)
            break
        elif x+i not in p:
            print(x+i)
            break

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

using namespace std;

int main(void) {
  int n, x;
  cin >> n >> x;

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

  long long ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] + a[i] > x) {
      int b = max(0, a[i - 1] + a[i] - x);
      a[i] = max(0, a[i] - b);
      ans += b;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int k; cin >> k;
    int rem = 0;
    for(int i=1; i<=1e7; ++i) {
        rem = (rem * 10 + 7) % k;
        if(rem == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;


int main()
{
    HS
    int n,k;
    cin>>n>>k;
    int arr[n+5];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int dp[k+1]={0};
    for(int i=0;i<=k;i++)
        for(int j=0;j<n;j++)
        if(i>=arr[j] && !dp[i-arr[j]])
            dp[i]=1;

if(dp[k]==1)
    cout << "First";
else
    cout << "Second";


    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define WHITE -1
#define  GRAY  0
#define BRACK  1

typedef struct{
  int key;
  int d;
} edge;

typedef struct{
  int k;
  char color;
  int d;
  edge *A;
} Point;

void heapIN(int,edge);
void insert(int, int);
edge extract(void);
void Mheap(int);

int H=0;
edge *Q;

int main(){
  Point *p;
  edge mind;
  int i,j,n,v,u,id,qsize=0;

  scanf("%d",&n);
  p=(Point *)malloc(sizeof(Point)*n);

  for(i=0;i<n;i++){
    //   printf("test1\n");
      
    scanf("%d%d",&id,&p[i].k);
    
    p[i].A=(edge *)malloc(sizeof(edge)*p[i].k);
    qsize+=p[i].k;

    //printf("==%d\n",sizeof(edge));

    for(j=0;j<p[i].k;j++){
      scanf("%d%d",&p[i].A[j].key,&p[i].A[j].d);
      //printf("A=%d C=%d\n",p[i].A[j].key,p[i].A[j].d);
    }

    p[i].color=WHITE;
    p[i].d=INT_MAX;
  }

  Q=(edge *)malloc(sizeof(edge)*qsize);
    
  p[0].d=0;
  insert(0,0);

  while(H != 0){
    mind = extract();
    u=mind.key;

    //printf("u=%d\n",u);
    p[u].color = BRACK;
    if(p[u].d < mind.d) continue;
    
    for(i=0;i<p[u].k;i++){
      v = p[u].A[i].key;
;
      if(p[v].color != BRACK && p[u].d + p[u].A[i].d < p[v].d){
	//printf("v=%d,p[u].A[v].key=%d \n",v,p[u].A[i].key);
	p[v].d = p[u].d + p[u].A[i].d;
	p[v].color=GRAY;
	insert(v,p[v].d);
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i,p[i].d == INT_MAX ? -1 : p[i].d);
    //printf("color[%d]=%d\n",i,p[i].color);
  }

  return 0;
}

void insert(int key, int d){
  edge in;

  //printf("key=%d,d=%d ",key,d);

  in.key=key;
  in.d=d;
  
  H++;
  Q[H].d=INT_MAX;
  heapIN(H,in);
}

void heapIN(int i,edge in){
    edge swap;

    //printf("in.d=%d ",in.d);
    
    if (in.d>Q[i].d) return;
    Q[i]=in;

    //for(i=0;i<=H;i++){ printf("insert Q[%d].key=%d,Q[%d].d=%d  ",i,Q[i].key,i,Q[i].d);} printf("\n");
    
    while(i>1 && Q[i/2].d > Q[i].d){
        swap=Q[i/2];
        Q[i/2]=Q[i];
        Q[i]=swap;
        i/=2;
    }
    //for(i=0;i<=H;i++){ printf("insert H=%d,Q[%d].key=%d,Q[%d].d=%d  ",H,i,Q[i].key,i,Q[i].d);} printf("\n");
}

edge extract(){
    edge min;
    int i;
    
    if(H<1) return Q[0];
    min=Q[1];
    Q[1]=Q[H];
    H--;
    Mheap(1);
    //for(i=0;i<=H;i++) printf("extract Q[%d]=%d ",i,Q[i].key); printf("\n");
   
    return min;
}

void Mheap(int i){
    int l,r,small;
    edge swap;
    
    l = i*2;
    r = i*2+1;
    
    if(l <= H && Q[l].d < Q[i].d) small = l;
    else small=i;
    if(r <= H && Q[r].d < Q[small].d) small = r;
    
    if(small != i){
        swap=Q[small];
        Q[small]=Q[i];
        Q[i]=swap;
        
        Mheap(small);
    }
}






Measured memory_bytes: 2104
N = int(input())
A = input()
B = input()

def f(horizontal_flag):
    if horizontal_flag[0]:
        if horizontal_flag[1]:
            return 3
        else:
            return 1
    else:
        return 2

if N == 1:
    print(3)    
else:
    if A[0] == A[1]:
        counter = 6
        initial_num = 2
        horizontal_flag = [1,0]
    else:
        counter = 3
        initial_num = 1
        horizontal_flag = [0,0]

    for i in range(initial_num,N):
        if i == N-1:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
        elif A[i] == A[i+1]:
            horizontal_flag[1] = 2
        else:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
            horizontal_flag[0] = horizontal_flag[1]
    print(counter % 1000000007)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
vector<vector<ll> >g;
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while (t--)  
{
ll n,k;
cin>>n>>k;
ll a[n+1];
for(ll i=1;i<=n;i++)
cin>>a[i];
ll tt;
tt=1;
ll fg=0;
for(ll i=1;i<=n;i++)
{
    // cout<<"i="<<i;
    // cout<<"k="<<k+1;
    // cout<<a[3]<<"\n";
    if(i>=(k+1))
    {
        if(a[i]>a[tt])
        {
            tt++;
            cout<<"Yes"<<"\n";
            continue;
        }
        else
        {
           tt++;
            cout<<"No"<<"\n";
            continue; 
           
        }
    }
}
 
}
 

 return 0;
}

Measured memory_bytes: 5200
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

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

  if(s.find("N") != std::string::npos){
    if(s.find("S") == std::string::npos){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.find("S") != std::string::npos){
    if(s.find("N") == std::string::npos){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.find("W") != std::string::npos){
    if(s.find("E") == std::string::npos){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.find("E") != std::string::npos){
    if(s.find("W") == std::string::npos){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
	return 0;
}


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

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

#define MAX_N 100
#define INF (1<<20)

int N;
int x[MAX_N], y[MAX_N], z[MAX_N], m[MAX_N];

bool input(){
  cin>>N;
  int a[3];
  REP(i, N) {
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    x[i] = a[0];
    y[i] = a[1];
    z[i] = a[2];
    m[i] = x[i]*y[i]*z[i];
  }
  return N!=0;
}

#define MAX_V 204
struct edge { int to, cap, cost, rev; };
int V; // ????????°
vector<edge> G[MAX_V]; // ??°???????????£??\???????????¨???
int h[MAX_V]; // ??????????????£???
int dist[MAX_V]; // ???????????¢
int prevv[MAX_V], preve[MAX_V]; // ??´??????????????¨???
// from??????to??????????????????cap????????????cost???????????°?????????????????????
void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].push_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}
// s??????t????????????f???????°??????¨???????±???????
// ??????????????´??????-1?????????
int min_cost_flow(int s, int t, int f) {
    int res = 0;
    fill(h, h + V, 0); // h????????????
    while (f > 0) {
        // ??????????????????????????¨??????h?????´??°??????
        priority_queue<P, vector<P>, greater<P> > que;
        fill(dist, dist + V, INF);
        dist[s] = 0;
        que.push(P(0, s));
        while (!que.empty()) {
            P p = que.top(); que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (int i = 0; i < G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }
        if (dist[t] == INF) {
            // ????????\???????????????
            return -1;
        }
        for (int v = 0; v < V; v++) h[v] += dist[v];
        // s-t????????????????????£??????????????????
        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

void resetG(int ver){
  V = ver;
  REP(i,V)G[i].clear();//while(!G[i].empty()) G[i].pop_back();
}

void solve(){
 resetG(N * 2 + 2);
 REP(i,N){
   REP(j,N){
     if(i == j)
       continue;
     if(x[i] > x[j] && y[i] > y[j] && z[i] > z[j])
       add_edge(j,i + N, 1, 0);
   }
   add_edge(V-2, i, 1, 0);
   add_edge(i+N, V-1, 1, 0);
   add_edge(i, V-1, 1, m[i]);
 }
 cout<<min_cost_flow(V-2, V-1,N)<<endl;
}

int main(){
  cin.tie(0);

  while (input()){
    solve();
  }

  return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <set>

int main()
{
    std::multiset< int, std::greater<int> > s;
    for (int i = 0; i < 10; ++i) {
        int h;
        std::cin >> h;
        s.insert(h);
    }
    std::multiset< int, std::greater<int> >::iterator it = s.begin();
    for (int i = 0; i < 3; ++i)
        std::cout << *it++ << std::endl;
}

Measured memory_bytes: 1192
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int n, q;
        cin >> n;
        vector<int> S(n);
        rep(i, n) cin >> S[i];
        cin >> q;
        vector<int> T(n);
        rep(i, q) cin >> T[i];
        int ans = 0;

        rep(i, q)
        {
                rep(j, n)
                {
                        if (T[i] == S[j])
                        {
                                ans++;
                                break;
                        }
                }
        }

        cout << ans << endl;

        return 0;
}



Measured memory_bytes: 3140
from bisect import bisect_left
import sys
input = sys.stdin.readline

W, H = map(int, input().split())
P = [int(input()) for _ in range(W)]
Q = [int(input()) for _ in range(H)]

P.sort()
Q.sort(reverse=True)

sP = [0]
a = 0
for p in P:
    a += p
    sP.append(a)

ans = sP[-1]
for q in Q:
    ip = bisect_left(P, q)
    ans += q*(W+1-ip) + sP[ip]
print(ans)

Measured memory_bytes: 16204
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
	return x * f;
}
int main()
{
	int a = read(), b = read(), c = read();
	if(a+b+c >= 22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n-1)
ans[0] = fractions.gcd(a[0],a[1])
for i in range(1,n-1):
  ans[i] = fractions.gcd(ans[i-1],a[i+1])
print(ans[n-2])

Measured memory_bytes: 88428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c,x,sum=0,ans=0;
  cin>>a>>b>>c>>x;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        sum=500*i+100*j+50*k;
        if (sum==x) {
          ans+=1;
        }
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256