akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*n
for i in range(m):
    x,y=map(int,input().split())
    a[x-1]=max(l[y-1],a[x-1])
    a[y-1]=max(l[x-1],a[y-1])
ans=0
for i in range(n):
    if l[i]>a[i]:
        ans+=1 
print(ans)        
    
    
    

Measured memory_bytes: 20048
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, d;
    cin >> n >> d;
    lint k = 2 * d + 1;
    lint ans = n / k + ((n % k == 0) ? 0 : 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
    int N, K;
    cin >> N >> K;
    int min, max;
    min = K-N+1;
    max = K+N-1;
    for(int i = min; i <= max; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	priority_queue<ll> q;
	ans += 0;
	q.push(a[0]);
	REP1(i, n-1){
		ans += q.top();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6164
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
typedef long long ll;
const int mod=1e9+7;
#define lol(i,n) for(int i=0;i<n;i++)

using namespace std;
string n;
int main() {
    cin >>n;
    if(n=="ani")cout <<"square1001"<< endl;
    else cout <<"e869120"<< endl;
}



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

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

  vector<int> ll;

  char a,b;
  cin>>a;
  bool wb=true;
  if(a=='.')wb=false;
  
  int l=1;
  for(int i=1; i<n; i++){
    cin>>b;
    if(a!=b){
      ll.push_back(l);
      l=1;
    }else l++;
    a=b;
  }
  ll.push_back(l);

  n=ll.size();
  if(wb){
    int sum=0;
    for(int i=1; i<n; i+=2)sum+=ll[i];
    int ans=sum;
    for(int i=0; i<n-1; i+=2){
      sum=sum+ll[i]-ll[i+1];
      ans=min(ans,sum);
    }
    cout<<ans<<endl;
  }else{
    int sum=0;
    for(int i=0; i<n; i+=2)sum+=ll[i];
    sum-=ll[0];
    int ans=sum;
    for(int i=1; i<n-1; i+=2){
      sum=sum+ll[i]-ll[i+1];
      ans=min(ans,sum);
    }
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 1400
import std.stdio, std.string, std.conv;
int n, x, k;
int[300999] C, U;
void main(){
	readf("%d\n", &n);
	foreach(a; readln.split.to!(int[])) ++C[a];
	foreach(c; C) for(x = 0; c; ) U[x++] += c--;
	for(x = n, k = 1; k <= n; k ++){
		while(k * x > n - U[x]) --x;
		x.writeln;
	}
}


Measured memory_bytes: 13668
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << ' ' << b << endl;
    } else {
        k -= a;
        a = 0;
        b = std::max(b - k, 0ll);
        cout << a << ' ' << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 105;
bool a[NMAX][NMAX];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      char x;
      cin >> x;
      if (x == '#')
        a[i][j] = 1;
    }
  }
  vector<vector<int>> dp(n, vector<int>(m, (int)1e9));
  auto inside = [&](int i, int j){
    if (i < 0 || i >= n || j < 0 || j >= m)
      return 0;
    return 1;
  };
  dp[0][0] = a[0][0];
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      if (inside(i, j-1))
        dp[i][j] = min(dp[i][j], dp[i][j-1] + (a[i][j] ? a[i][j-1] == 0 : 0));
      if (inside(i-1, j))
        dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i][j] ? a[i-1][j] == 0 : 0));
    }
  }
  cout << dp[n-1][m-1] << '\n';

  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
int main() {
#define int long long
	long long n;
	cin >> n;
	vector<int> a;
	long long sum = 0;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		sum += tmp;
		a.push_back(tmp);
	}
	long long sousa = n*(n + 1);
	sousa /= 2;
	if (sum%sousa != 0) {
		cout << "NO" << endl;
		return 0;
	}
	sousa = sum / sousa;
	vector<int> d;
	for (int i = 1;i < n;++i) {
		d.push_back(a[i] - a[i-1]);
	}
	d.push_back(a[0] - a[n-1]);
	for (int i = 0;i < n;++i) {
		d[i] -= sousa;
		if (d[i] > 0) {
			cout << "NO" << endl;
			return 0;
		}
		d[i] *= -1;
		if (d[i] % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n<k){
    cout<<n*x<<endl;
  }else{
    cout<<k*x+(n-k)*y<<endl;
  }
}


Measured memory_bytes: 256
<?php
while( fscanf( STDIN, "%d", $n ) ){
  $cnt=0;
  for($a=0;$a<10;$a++)
    for($b=0;$b<10;$b++)
      for($c=0;$c<10;$c++)
        for($d=0;$d<10;$d++) if($a+$b+$c+$d==$n) ++$cnt;
  printf("%d\n",$cnt);
}

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

#include <fstream>
using namespace std;

const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> c(N);
  vector<vector<int>> a(N, vector<int>(M));
  for(int i = 0; i < N; i++){
    cin >> c[i];
    for(int j = 0; j < M; j++){
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for(int i = 1; i < 1 << N; i++){
    int cost = 0;
    vector<int> d(M);
    for(int j = 0; j < N; j++){
      if(i>>j&1){
        cost += c[j];
        for(int k = 0; k < M; k++){
          d[k] += a[j][k];
        }
      }
    }
    bool ok = true;
    for(int j = 0; j < M; j++){
      if(d[j] < X) ok = false;
    }
    if(ok) ans = min(ans, cost);
  }
  if(ans == INF) cout << -1 <<endl;
  else cout << ans <<endl;
}


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

using llong = long long;

int main() {

    int N;
    cin >> N;
    vector<int> V, C, P;
    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        V.push_back(v);
    }
    for (int i = 0; i < N; i++) {
        int c;
        cin >> c;
        C.push_back(c);
        P.push_back(V[i] - C[i]);
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] > 0) {
            sum += P[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
#include <iostream>
#include <cmath>
using ll = long long;
using namespace std;
  
  
int main() { 
  int a,b,h,m; cin >> a>>b>>h>>m;
  double w = fabs(30*h-5.5*m);
  double pi =3.14159265358979;
  double x = cos(w/180*pi);
  double ans = sqrt(a*a + b*b -2*a*b*x);
  cout << fixed <<setprecision(20) <<ans <<endl;
}

Measured memory_bytes: 4100
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    X=0
    for j in range(M):
        X += A[i][j]*B[j]
    X += C
    if  0 < X:
        ans += 1
print(ans)
    


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll INF = 1e15;


int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

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

// ACL C
// https://atcoder.jp/contests/abl/tasks/abl_c

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

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.merge(a, b);
  }

  // int cnt = 0;
  // rep(i, n) if(uf.leader(i) == i) cnt++;
  int cnt = uf.groups().size();
  cout << cnt - 1;
}


Measured memory_bytes: 8844
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s.back() << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    ll dp[31];
    FILL(dp,0);
    dp[0] = 1;
    REP(i,31){
        REP(j,3) dp[i+j+1] += dp[i];
    }

    int n;
    while(cin >> n && n){
        cout << (dp[n]+3649)/3650 << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split(' ');
            var A = int.Parse(N[0]);
            var B = int.Parse(N[1]);
            var C = int.Parse(N[2]);
            if (((A<C && C<B) || (B < C && C < A)))
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = sx, y = sy;
    while (y < ty) {
        cout << "U";
        y++;
    }
    while (x < tx) {
        cout << "R";
        x++;
    }
    while (y > sy) {
        cout << "D";
        y--;
    }
    while (x > sx) {
        cout << "L";
        x--;
    }
    cout << "L";
    x--;
    while (y < ty + 1) {
        cout << "U";
        y++;
    }
    while (x < tx) {
        cout << "R";
        x++;
    }
    cout << "D";
    y--;
    cout << "R";
    x++;
    while (y > sy - 1) {
        cout << "D";
        y--;
    }
    while (x > sx) {
        cout << "L";
        x--;
    }
    cout << "U\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b){
        put("YES");
    }else{
        put("NO");
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())

S = set()

for i in range(N):
  A = list(map(int, input().split()))
  wS = set(A[1::])
  if i == 0:
    S = wS
  else:
    S = S & wS #S.intersection(wS)
    
print(len(S))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int M = ((int)1 << 20);
	int N, i, x;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * (N + 1));
	int *s = (int *)malloc(sizeof(int) * (N + 1));
	s[0] = 0;
	int *Onum = (int *)malloc(sizeof(int) * (N + 1));
	Onum[0] = 0;
	for(i = 1; i <= N; i++){
		scanf("%lld", &a[i]);
		s[i] = (s[i - 1] ^ a[i]);
		Onum[i] = Onum[i - 1] + (s[i] == 0 ? 1 : 0);
	}
/*	printf("s:\n");
	for(i = 0; i <= N; i++){
		printf("%lld ", s[i]);
	}
	printf("\n");
	printf("Onum:\n");
	for(i = 0; i <= N; i++){
		printf("%lld ", Onum[i]);
	}
	printf("\n");
*/	int *prev = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		prev[i] = 0;
	}
	int *dp = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		dp[i] = 0;
	}
	int *sum = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		sum[i] = 0;
	}
	int *Osum = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		Osum[i] = 1;
	}
	for(i = 1; i <= N; i++){
		x = s[i];
		dp[x] = MOD(sum[x] * (Onum[i] - Onum[prev[x]]) + Osum[x]);
		Osum[x] = MOD(Osum[x] + sum[x] * (Onum[i] - Onum[prev[x]]));
		sum[x] = MOD(sum[x] + dp[x]);
/*		if(prev[x] == -1){
			dp[x] = 1;
			sum[x] = 1;
		}
		else{
			dp[x] = MOD(sum[x] * (Onum[i] - Onum[prev[x]]) + 1);
			sum[x] = MOD(sum[x] + dp[x]);
		}
*/		prev[x] = i;
//		printf("i = %lld\n", i);
//		printf("dp[%lld] = %lld\n", x, dp[x]);
//		printf("sum[%lld] = %lld\n", x, sum[x]);
	}
	int ans = 0;
	if(s[N] == 0){
		ans = power(2, Onum[N] - 1);
		for(i = 1; i < M; i++){
			ans = MOD(ans + sum[i]);
		}
	}
	else{
		ans = dp[s[N]];
	}
/*	for(i = 1; i < M; i++){
		if(s[N] == 0){
			ans = MOD(ans + sum[i]);
		}
		else if(s[N] == i){
			ans = MOD(ans + dp[i]);
		}
	}
	if(s[N] == 0){
		ans = MOD(ans + power(2, Onum[N] - 1));
	}
*/	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 44672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define r(i,n) for(int i=0;i<n;i++)
int main(void){
  int n,t;
  cin>>n>>t;
  map<pair<string,string>,int>mp;
  while(n--){
    int p;
    cin>>p;
    string s[p];
    r(i,p)cin>>s[i];
    for(int i=0;i<p;i++){
      for(int j=i+1;j<p;j++){
	if(s[i]<s[j])mp[mk(s[i],s[j])]++;
	else mp[mk(s[j],s[i])]++;
      }
    }
  }vector<pair<string,string> >v;int c=0;
  for(map<pair<string,string>,int>::iterator i=mp.begin();i!=mp.end();i++){
    if((*i).second>=t){
      v.push_back((*i).first);
      c++;
    }
  }
  cout<<c<<endl;
  for(vector<pair<string,string> >::iterator i=v.begin();i!=v.end();i++){
    cout<<(*i).first<<' '<<(*i).second<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Read();
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.ReadLine;
            var w = cin.ReadInt;
            string result = "";

            for (int i = 0; i < S.Length; i=i+w)
            {
                result +=S[i];
            }
            Console.WriteLine(result);
            Console.Read();

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        ///
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
// https://atcoder.jp/contests/abc128/tasks/abc128_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<string, int> PSI;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int n, m;
vector<unsigned int> vi; // 入力値のビット列（例：1, 3なら101）
vector<unsigned int> vp; // ビット列の総和の偶数・奇数
bool check(unsigned int arg) {
    int ans = 0, cnt;
    bool flag = true;
    // スイッチが未接続なら点灯しない
    // if (arg == 0)
    //     return false;
    // 全部のスイッチで点灯するか確認
    REP(i, m) {
        cnt = __builtin_popcount(vi[i] & arg);
        if (cnt % 2 != vp[i]) {
            flag = false;
            break;
        }
    }
    return flag;
}
int dfs(int idx, unsigned int arg) {
    if (idx == n) {
        return check(arg);
    }
    int ans = dfs(idx + 1, arg);
    arg |= (1 << idx); // nビット目を1にする
    ans += dfs(idx + 1, arg);
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    vi.resize(m);
    vp.resize(m);
    REP(i, m) {
        int k, l;
        cin >> k;
        // 入力値をビット列にする（例：1, 3なら101）
        unsigned int t = 0;
        REP(j, k) {
            cin >> l;
            t |= (1 << (--l));
        }
        vi[i] = t;
    }
    REP(i, m) { cin >> vp[i]; }
    cout << dfs(0, 0) << endl;
    return 0;
}


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

using namespace std;


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

	vector<vector<int>> adj(n + 1);
	vector<int> in_deg(n + 1);

	for(int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;

		adj[x].push_back(y);
		in_deg[y]++;
	} 

	vector<int> dp(n + 1);
	queue<int> Q;
	int ans = 0;	
	for(int i = 1; i <= n; i++)
	{
		
		if(in_deg[i] != 0)
			continue;

		int s = i;
		Q.push(s);

		while(!Q.empty())
		{
			int u = Q.front(); Q.pop();
			in_deg[u] = -1;

			ans = max(ans, dp[u]);

			for(int v : adj[u])
			{
				dp[v] = max(dp[v], dp[u] + 1);
				in_deg[v]--;

				if(in_deg[v] == 0)
					Q.push(v);
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6528
package main

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

type Set struct {
	before int
	after  int
}

func main() {
	s := wordScanner()
	n, a := scanNAndInts(s)

	var bmax, amax int
	l := make([]Set, n)
	for i := 1; i < n; i++ {
		bmax = max(a[i-1], bmax)
		amax = max(a[n-i], amax)
		l[i].before = bmax
		l[n-i-1].after = amax
	}

	for i := range a {
		fmt.Println(max(l[i].before, l[i].after))
	}
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanNAndInts(s *bufio.Scanner) (int, []int) {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	vals := make([]int, n)
	for i := 0; i < n; i++ {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return n, vals
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 9624
use std::{cmp, io};

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n: usize = input.trim().parse().unwrap();
    let costs: Vec<Vec<usize>> = (0..n).map(|_| {
        input.clear();
        io::stdin().read_line(&mut input).unwrap();
        input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect()
    }).collect();

    let mut tmp = vec![[0; 3]; n];
    tmp[0][0] = costs[0][0];
    tmp[0][1] = costs[0][1];
    tmp[0][2] = costs[0][2];
    for i in 1..n {
        tmp[i][0] = costs[i][0] + cmp::max(tmp[i - 1][1], tmp[i - 1][2]);
        tmp[i][1] = costs[i][1] + cmp::max(tmp[i - 1][2], tmp[i - 1][0]);
        tmp[i][2] = costs[i][2] + cmp::max(tmp[i - 1][0], tmp[i - 1][1]);
    }
    println!("{}", tmp[n - 1].into_iter().max().unwrap());
}

Measured memory_bytes: 14588
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  string s;
  cin >> n >> s;

  if(n%2==1)cout << "No" << endl;
  else{
    bool ok=true;
    for(ll i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2])ok=false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
  }

}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007


int h, w;
string a[1000];
int dp[1000][1000];



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

	cin >> h >> w;
	rep(i, h)cin >> a[i];

	dp[0][0] = 1;
	rep(y,h)rep(x,w)if(a[y][x]!='#') {
		if (y+1<h) {
			(dp[y + 1][x] += dp[y][x]) %= MOD;
		}
		if (x + 1 < w) {
			(dp[y][x + 1] += dp[y][x]) %= MOD;
		}
	}
	cout << dp[h - 1][w - 1] << endl;


	
	return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string n; cin >> n;
    ll sum = 0;
    rep(i, n.size()) {
        sum += (n[i] - '0');
    }
    if(sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3696
#include <stdio.h>

int depth(int);
int get_height(int, int);
void retheight(int, int, int, int);

typedef struct {
  int parent, sibling, left, right, degree;
} Node;

Node tree[100001];
int n;
int count = 0, count_b = 0;
int count_c[100001];

int main(){

  int nownode, deg, left, right, i, j;

  scanf("%d", &n);

  for (i = 0; i < n; i++){
    tree[i].parent = tree[i].degree = tree[i].sibling = tree[i].left = tree[i].right = -1;
  }

  for (i = 0; i < n; i++){

    scanf("%d%d%d", &nownode, &left, &right);

    count = 0;
    if (left != -1){
      tree[left].parent = nownode;
      tree[left].sibling = right;
      tree[nownode].left = left;
      count++;
    }

    if (right != -1){
      tree[right].parent = nownode;
      tree[right].sibling = left;
      tree[nownode].right = right;
      count++;
    }

    tree[nownode].degree = count;
  }

  for(i = 0; i < n; i++){

    count = count_b = 0;

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i,tree[i].parent, tree[i].sibling, tree[i].degree, depth(i), get_height(i, depth(i)));

    if(tree[i].parent == -1){
      printf("root\n");
    } else if(tree[i].left == -1 && tree[i].right == -1){
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }

  return 0;
}


int depth(int id) {

  if (tree[id].parent == -1) {
    return count / 2;
  } else {
    count++;
    return depth(tree[id].parent);
  }

}

int get_height(int id, int depth) {

  int i, ret = 0;

  for(i = 0; i < n; i++){
    count_c[i] = 0;
  }

  retheight(id, 0, depth, depth);

  for(i = 0; i < count_b + 1; i++){

    if(ret < count_c[i]){
      ret = count_c[i];
    }

  }
  return ret;

}

void retheight(int id, int count_id, int startdepth, int depth) {

  int i, c;

  for (i = 1; i < n; i++) {
    if (count_c[i] == 0) {
      c = i;
      break;
    }
  }
  
  if (tree[id].left != -1 && tree[id].right != -1) {

    count_c[count_id]++;
    count_c[c] = depth - startdepth + 1;
    retheight(tree[id].left, count_id, startdepth, depth + 1);
    retheight(tree[id].right, c, startdepth, depth + 1);

  } else if (tree[id].left != -1) {
    
    count_c[count_id]++;
    retheight(tree[id].left, count_id, startdepth, depth + 1);

  } else if (tree[id].right != -1) {

    count_c[count_id]++;
    retheight(tree[id].right, count_id, startdepth, depth + 1);

  } else {
    count_b = count_id;
  }

}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string s, ans;
    cin >> s;
    for (int i = 0; i < (int)s.size(); i += 2) {
        ans.push_back(s[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//
//  main.cpp
//  AT
//
//  Created by 黄道煜 on 2018/7/7.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstring>
#define LL long long
using namespace std;

int w;
char s[1005];

int main()
{
    scanf("%s", s);
    scanf("%d", &w);
    int len=strlen(s);
    for(int i=0; i<len; i+=w)printf("%c", s[i]);
}


Measured memory_bytes: 256
//pulkit kapoor
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	int para[n];
	bool ss[n] = {false};
	bool nn1[n] = {false};
	int ctt = 0;
	for(int i=0;i<n;i++){
		cin >> para[i];
		if(i==para[i]-1){
			ss[i]=true;
			nn1[i+1]=true;
			if(nn1[i]==false) 
			    ctt ++;
			else if(ss[i]=true) 
			    nn1[i+1]=false;
		}
 
	}
 
	cout << ctt << endl;
 	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

ll get_num(string s, int m) {
    int l = s.size();
    ll dp[105][2][5]; // digit, smaller, not_zero_num
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i, l) {
        rep(j, 2) {
            rep(k, m + 1) {
                int d = s[i] - '0';
                rep(x, (j ? 9 : d) + 1) {
                    dp[i + 1][j || (x < d)][min(m + 1, (x == 0) ? k : k + 1)] += dp[i][j][k];
                }
                // debug(i);
                // debug(j);
                // debug(k);
                // debug(dp[i][j][k]);
            }
        }
    }

    return dp[l][0][m] + dp[l][1][m];
}

int main() {
    string s;
    int m;
    cin >> s >> m;
    out(get_num(s, m));
}



Measured memory_bytes: 256
#include <stdio.h>

#define N 10000
#define Q 500

int linearSearch();

int main() {
 
int n,q,S[N],T[Q];
int i,key,num,sum=0;

scanf("%d",&n);
for(i=0; i<n;i++)
  scanf("%d",&S[i]);

scanf("%d",&q); 
for(i=0; i<q;i++)
  scanf("%d",&T[i]);

for (i=0; i<q; i++){

num = linearSearch(n,S,T[i]);
sum += num;
}

printf("%d\n",sum);


return 0;
}

int linearSearch(int n,int S[],int t){

int i = 0;
S[n] = t;

while(S[i] != t){

  i++;
if (i==n)
  return 0;
}

return 1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string s;
    cin >> s;
    int ans = 999;

    for(int i = 2; i < s.size(); ++i){
        string sss;
        sss += s.at(i-2);
        sss += s.at(i-1);
        sss += s.at(i); 
        int ss = atoi(sss.c_str());
        if(ss > 753)ans = min(ans,ss-753);
        else ans = min(ans,753-ss);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>
using namespace std;
int w[100];
int sum(int s, int e)
{
    int res = 0;
    for (int i = s; i < e; i++)
    {
        res += w[i];
    }
    return res;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }

    int t1, t2, min=100;
    for (int i = 0; i < n-1; i++)
    {
        t1 = sum(0, i+1);
        t2 = sum(i+1, n);
        if(abs(t1-t2) < min)
        {
            min = abs(t1-t2);
        }
    }
    cout << min << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int max = (n-1) * (n-2) / 2;
    if (max < k) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> e;
    for (int i = 2; i <= n; i++) {
        e.emplace_back(1, i);
    }
    for (int i = 2; i < n; i++) {
        for (int j = i+1; j <= n; j++) {
            if (max == k) break;
            e.emplace_back(i, j); max--;
        }
    }
    cout << e.size() << endl;
    for (int i = 0; i < e.size(); i++) {
        cout << e[i].first << " " << e[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int a=0,b=n-1,ans=0;
    bool flag = true;
    while(b-a>0){
        if(s[a]==s[b]){
            a++;
            b--;
            continue;
        } 
        else{
            ans++;
            if(s[a] == 'x') a++;
            else if(s[b] == 'x') b--;
            else{
                flag = false;
                break;
            } 
        }
    }
    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 512
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))
ans = 10**18

for Y in set(A):
    L = []
    l = []
    
    for i in range(N):
        if A[i]<Y:
            L.append(l)
            l = []
        else:
            l.append(A[i])
    
    L.append(l)
    l2 = []
    
    for l in L:
        if len(l)<=K-1:
            continue
        
        l.sort()
        
        for i in range(len(l)-K+1):
            l2.append(l[i])
    
    if len(l2)<Q:
        continue
    
    l2.sort()
    X = l2[Q-1]
    ans = min(ans, X-Y)

print(ans)

Measured memory_bytes: 53084
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

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

        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextLong();
        }

        System.out.println(solve(N, A));
    }

    public static int solve(int N, long[] A) {
        if (N == 2) {
            return (int)Math.max(A[0], A[1]);
        }

        int i=0;
        long gcd=gcd(A[1], A[2]);
        if (gcd < gcd(A[2], A[0])) {
            i = 1;
            gcd = gcd(A[2], A[0]);
        }
        if (gcd < gcd(A[0], A[1])) {
            i = 2;
            gcd = gcd(A[0], A[1]);
        }

        if (N == 3) {
            return (int)gcd;
        }

        for (int k=3; k<N; k++) {
            if (gcd(gcd, A[k]) < gcd(gcd, A[i])) {
                gcd = gcd(gcd, A[i]);
                i = k;
            } else {
                gcd = gcd(gcd, A[k]);
            }
        }

        return (int)gcd;
    }

    private static long gcd(long a, long b, long c) {
        return gcd(gcd(a, b), c);
    }

    private static long gcd(long a, long b) {
        if (a > b) return gcd(b, a);

        if (b%a == 0) return a;

        return gcd(b%a, a);
    }

    private static Set<Integer> eratosthenes(int x) {
        Set<Integer> primeSet = new HashSet<>();

        IntStream.rangeClosed(2, x)
                .filter(i -> IntStream.rangeClosed(2, (int) Math.sqrt(i))
                        .allMatch(j -> i % j != 0))
                .forEach(n -> {
                    primeSet.add(n);
                });

        return primeSet;
    }
}

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

int main(){
  int N;
  
  cin >> N;
  
  int i=0;
  
  while (i<N){
    string Si;
    cin >> Si;
    
    if ( Si == "Y" ){
      break;
    }
    i++;
  }
  
  if ( i<N )
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	int n;
	cin >> n;
	int sum=0,t,sub;
	rep(i,n){
		sum += i+1;
		if(sum >= n){
			t = i+1;
			sub = sum - n;
			break;
		}
	}
	reps(i,1,t+1){
		if(i == sub)continue;
		cout << i << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

using pii = pair<int, int>;
int n, h[102], exist[102];
pii ord[100];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", h + i), exist[i] = true;
	for (int i = 1; i <= n; i++)
		ord[i - 1] = pii(h[i], i);

	int cost = 0, block = 1;
	sort(ord, ord + n);
	for (int i = 0, j = 0; i <= 100 && j < n; i++) {
		while (j < n && ord[j].first == i) {
			int bet = exist[ord[j].second - 1] + exist[ord[j].second + 1];
			if (bet == 0)
				block--;
			if (bet == 2)
				block++;
			exist[ord[j++].second] = false;
		}
		cost += block;
	}
	printf("%d\n", cost);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll unsigned long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define fom(n) for(ll m=0;m<n;m++)
#pragma GCC optimize("O3", "unroll-loops")
#define fixed(); cout << fixed << setprecision(20);
#define fast(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

/*****************************************************************************/


#define graph          vector<vector<int>>
#define V              vector
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef V<int>         vi;
typedef V<ll>          vll;
typedef V<string>      vs;
typedef V<double>      vd;
typedef V<pii>         vpii;             
typedef V<pll>         vpll;             
typedef pair<int,pii>  piii;             
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;   

/*****************************************************************************/

#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define ff                   first
#define ss                   second
#define lbpos(v,x)           (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(v,x)           (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB

//*****************UVAISH ZAFRI(Rush_For_AC)**********************
#define mod 1000000007

int32_t main() {
    fast();fixed();
    #ifndef ONLINE_JUDGE
    freopen("tad.txt","r",stdin);
    freopen("tada.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll a[n];
    foi(n)cin>>a[i];
    ll res=0;
    for(ll i=1;i<n;i++){
      if(a[i]<a[i-1]){
        res+=a[i-1]-a[i];
        a[i]=a[i-1];
      }
    }
    cout<<res<<endl;
  
    
}



Measured memory_bytes: 5216
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
// #include<unordered_map>
using namespace std;
int bin[40],lg[1<<21];
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MAX_N=5e5+10;
	const int MOD=1e9+7;
	void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

	int siz[MAX_N];bool v[MAX_N];
	void main()
	{
		int n=qread(),m=qread();
		v[1]=1;for(int i=1;i<=n;i++) siz[i]=1;
		while(m--)
		{
			int x=qread(),y=qread();siz[x]--;siz[y]++;
			if(v[x]) v[y]=1;
			if(siz[x]==0) v[x]=0;
		}
		int ans=0;for(int i=1;i<=n;i++) ans+=v[i];
		write(ans);
	}
};
int main()
{
	srand(time(0));
	bin[0]=1;for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	lg[1]=0;for(int i=2;i<(1<<21);i++) lg[i]=lg[i>>1]+1;
	mine::main();
}


Measured memory_bytes: 10496