akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const double PI = 3.14159265358979;

void solve()
{
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;

  bool type = (s1[0] == s2[0]);
  mint ans = type ? 3 : 6;
  for(int i = 1 + (!type); i < n; ++i)
  {
    // 縦向き
    if (s1[i] == s2[i])
    {
      ans *= type ? 2 : 1;
      type = true;
    }
    else
    {
      ans *= type ? 2 : 3;
      type = false;
      i++;
    }
  }
  cout << ans;
  /*
  map<char, int> seen;
  vector<ll> v1(n), v2(n);

  int num_d = 1;
  for(int i = 0; i < n; ++i)
  {
    if (seen[s1[i]] == 0)
    {
      seen[s1[i]] = num_d;
      num_d++;
    }
    if (seen[s2[i]] == 0)
    {
      seen[s2[i]] = num_d;
      num_d++;
    }
    v1[i] = seen[s1[i]] - 1;
    v2[i] = seen[s2[i]] - 1;
  }

  for(const auto& v : v1) cout << v << " ";
  cout << endl;
  for(const auto& v : v2) cout << v << " ";
  cout << endl;

  vector< vector<ll> > g(n, vector<ll>(0));
  for(int i = 0; i < n; ++i)
  {
    if (v1[i] != v2[i])
    {
      g[v2[i]].emplace_back(v1[i]);
    }
    if (i >= n - 1) continue;
    if (v1[i] != v1[i + 1])
    {
      g[v1[i + 1]].emplace_back(v1[i]);
    }
    if (v2[i] != v2[i + 1])
    {
      g[v2[i + 1]].emplace_back(v2[i]);
    }
  }
  for(int i = 0; i < n; ++i)
  {
    sort(ALL(g[i]));
    g[i].erase( unique(ALL(g[i])), g[i].end() );
    cout << i << " : " << g[i].size() << endl;
  }

  mint ans = 1;
  for(int i = 0; i < n; ++i)
  {
    ll c = 3 - g[i].size();
    ans *= c;
    cout << i << " * " << c << endl;
  }
  cout << ans;
  //*/
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 3e5 + 6;
const int M = 1e9+7;
int A[N];
int dp[N];
int n , k;

int alpha(int rem)
{
	if(rem <= 0)return 0;
	int &abs = dp[rem];
	if(abs != -1)return dp[rem];
	int ans = 0;
	loop(i ,0 ,n)
	{
		if(rem >= A[i])ans |= (1-alpha(rem - A[i]));
	}	
	return abs = ans;
}

void solve()
{
	cin >> n >> k;

	loop(i,0,n)cin >> A[i];

	sort(A , A+n);

	// int ans = alpha(k);

	loop(i,0,k+1)
	{
		loop(j,0,n)
		{
			if(i - A[j] >= 0)dp[i] = (dp[i]|(1-dp[i - A[j]]));
		}
	}

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

}		
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 4440
N,M = map(int,input().split())
H = list(map(int,input().split()))
ans = [1]*N

for m in range(M):
  A,B = map(int,input().split())
  if H[A-1] < H[B-1]:
    ans[A-1] = 0
  elif H[A-1] > H[B-1]:
    ans[B-1] = 0
  else:
    ans[A-1] = 0
    ans[B-1] = 0

print(sum(ans))


Measured memory_bytes: 19988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,j,k,m,n;
   cin>>n;
   ll arr[n];
   for(i=0;i<n;i++) cin>>arr[i];

    for(int i=1;i<n;i++)
	{
		if(arr[i]>arr[i-1])
			arr[i]--;
		else if(arr[i]<arr[i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";

	return 0;
}



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

static const int MAX_V = 200;
int V, E;
vector<int> G[MAX_V];
int match[MAX_V];
int used[MAX_V];

// u と v を結ぶ辺をグラフに追加する
void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

// 増加パスを DFS で探す
bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    int w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

// 二部グラフの最大マッチングを求める
int biparticle_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  for (int v = 0; v < V; v++) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) res++;
    }
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, Y, E;
  cin >> X >> Y >> E;
  V = X + Y;
  for (int i = 0; i < E; i++) {
    int x, y;
    cin >> x >> y;
    add_edge(x, y + 100);
  }
  int ans = biparticle_matching();
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3272
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int a[100010], b[100010];

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

	sort(a, a + n); sort(b, b + n);
	reverse(a, a + n);
	
	int *p = upper_bound(b,b+n,a[0]);
	int dis = distance(b, p);
	cnt += n - dis;

	int bcnt=0;
	for (int i = n-1; i >= dis; i--) {
		sum += b[i];
		bcnt++;
		if (sum >= h) {
			cout << bcnt << endl;
			return 0;
		}
	}

	int c = (h - sum + a[0] - 1) / a[0];
	cout << cnt + c << endl;

	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int count = 0;

  if (a == b && a != c) {
    cout << "Yes" << endl;
  } else if (a == c && a != b) {
    cout << "Yes" << endl;
  } else if (b == c && b != a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,cost;
     cin >> N >> cost;
     std::vector<int> v;
     for(int i=0;i<N;i+=1){
          int x;
          cin >> x;
          v.push_back(x);
     }
     sort(v.begin(),v.end());
     int i=0;
     int ans = 0;
     while(v[i]<=cost && i<N){
          if(i==N-1){
               if(v[i]==cost){
                    ans+=1;
               }
               break;
          }
          
          ans+=1;
          cost-=v[i];
          i+=1;
          
     }
     cout << ans;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[405][405];
ll s[405];

ll rec(ll i, ll j){
  if(dp[i][j]!=LINF) return dp[i][j];
  
  for(ll k=i+1; k<j; k++){
    chmin(dp[i][j],rec(i,k)+rec(k,j));
  }
  dp[i][j]+=s[j]-s[i];
  return dp[i][j];
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  rep(i,n) s[i+1]+=s[i]+a[i];
  
  rep(i,n+1) rep(j,n+1) dp[i][j]=LINF;
  rep(i,n+1){
    dp[i][i]=0;
    if(i!=n) dp[i][i+1]=0;
  }
  
  cout<<rec(0,n)<<endl;
}

Measured memory_bytes: 4956
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    string s;

    cin >> s;

    Int win = 0;
    Int lose = 0;

    Int p_count=0;

    rep(i,s.size()){
        if(p_count > 0){
            if(s[i]=='g'){
                win++;
            }
            p_count--;
        }else{
            if(s[i]=='p'){
                lose++;
            }
            p_count++;
        }
    }


    cout << win-lose << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)

  val a = cin.nextInt()
  val b = cin.nextInt()
  val c = cin.nextInt()

  if (c in a..b) {
    println("Yes")
  } else {
    println("No")
  }
  cin.close()
}

Measured memory_bytes: 31512
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    cin >> S;
    int len = (int)S.size();
    rep(i, len) cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# D. Partition
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 約数列挙

def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors

n, m = map(int, input().split())

box = make_divisors(m)

for i in range(len(box)):
  if box[i] >= n:
    print(m // box[i])
    exit()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 200100;
int A[MAX_N], N;

int main()
{
    scanf("%d", &N);
    for (size_t i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    sort(A, A + N);
    auto p = unique(A, A + N);
    if(p - A < N) printf("NO\n");
    else printf("YES\n");
    return 0;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
LR = []
for _ in range(K): LR.append(list(map(int,input().split())))
MOD = 998244353
dp = [0]*(N+1)
dp[0] = 1
for i in range(N):
  for L,R in LR:
    if i+L<N: dp[i+L] += dp[i]
    if i+R+1<N: dp[i+R+1] -= dp[i]
  if i>0: dp[i+1] = (dp[i+1]+dp[i])%MOD
print(dp[-1])

Measured memory_bytes: 16844
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/


signed main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll sum=0;
    For(i,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    For(i,n-k)sum+=a[i];
    cout<<sum<<endl;
      
}

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

int main(){
  int n;
  cin >> n;
  while(n != 0){
    vector<pair<int, int> > v;
    int x, y;
    for(int i = 0; i < n; i++){
      cin >> x >> y;
      v.push_back(make_pair(x, y));
    }

    int m;
    cin >> m;

    bool visited[21][21];
    for(int i = 0; i < 21; i++){
      for(int j = 0; j < 21; j++){
        visited[i][j] = false;
      }
    }

    char c;
    int d;
    int rx = 10;
    int ry = 10;
    visited[10][10];
    for(int i = 0; i < m; i++){
      cin >> c >> d;

      for(int j = 0; j < d; j++){
        if(c == 'N'){
          visited[rx][++ry] = true;
        }else if(c == 'E'){
          visited[++rx][ry] = true;
        }else if(c == 'S'){
          visited[rx][--ry] = true;
        }else{
          visited[--rx][ry] = true;
        }
      }
    }
    
    int cnt = 0;
    for(int i = 0; i < n; i++){
      if(visited[v[i].first][v[i].second])cnt++;
    }
    cout << (cnt == n ? "Yes" : "No") << endl;
    cin >> n;
  }
}

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

double mysqrt(double x){
	double l = 0 , r = x ;
	for(int i = 0 ; i < 64 ; i++){
		double m = (l+r)/2.0;
		if(m * m < x){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}


int main(){
	int p,n;
	while(cin >> p >> n , n){
		double sp = mysqrt(p);
		int a1 = 0 , b1 = 1 , a2 = p , b2 = 1;
		
		for(int i = 1 ; i <= n ; i++){
			int o = (int)(sp * i);
			for(int j = 0 ; j <= 1 ; j++){
				int w = o + j;
				if(__gcd(i,w) == 1 && w >= 0 && w <= n){
					if( (double)w/i < sp &&  a1*i < w*b1){
						a1 = w;
						b1 = i;
					}
					if((double)w/i > sp && a2*i > w*b2){
						a2 = w;
						b2 = i;
					}
				}
			}
		}

		cout << a2<< "/" << b2 << " " << a1 << "/" << b1 << endl;
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 2000000000
#define llong long long

using namespace std;


int main()
{
    int n, q;
    llong t;
    array<llong, 10002> s;

    cin >> n;
    REP(i, n) {
        cin >> s.at(i);
    }

    cin >> q;
    int cnt = 0;

    REP(i, q) {
        cin >> t;
        s.at(n) = t;
        int search = 0;


        while (s.at(search) != t)   search++;
        if (search != n) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7)
        cout<<"YES";
    else if(a==7&&b==5&&c==5)
        cout<<"YES";
    else if(a==5&&b==7&&c==5)
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    string S;
    cin >> S;
    int ans = 700;
    REP(i, 3) {
        if (S[i] == 'o')ans += 100;
    }
    cout << ans << endl;
    return 0;
}

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

a = []
n = N
while len(b):
    index = -1
    for i in range(n):
        if i+1 == b[i]:
            index = i
    if index > -1:
        a.insert(0, b.pop(index))
        n -= 1
    elif index == -1:
        print(index)
        quit()

for e in a:
    print(e)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k[100];
    bool ans=false;
    for(int i=0;i<b;i++){
        k[i]=((a%b)*(i+1))%b;
        if(k[i]==c)ans=true;
    }
    if(ans==true)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans = 1.1529215e+18;
    for (int i=0; i+k-1 < n; ++i) {
        ll x=a[i],y=a[i+k-1];
        ll h=min(abs(x), abs(y))+y-x;
        ans = min(ans,h );
    }
    cout << ans;
}

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

using namespace std;

#define fastio                          ios::sync_with_stdio(false);   cin.tie(0);   cout.tie(0);
#define input(arr, n)                   for(int i=1; i<=n; i++) cin >> arr[i];
#define output(arr, n)                  for(int i=1; i<=n; i++) {cout << arr[i] << " "; } cout << endl;
#define print(cont)                     for(auto it : cont) {cout << it << " "; } cout << endl;
#define printpair(cont)                 for(auto it : cont) cout << it.first << " " << it.second << endl;

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

const int M = 1e5 + 6;
const ll MOD = 1e9 + 7;
int cnt[M];

ll bigmod(ll x, ll p, ll m){

    ll res = 1;

    while(p){
        if(p & 1) res *= x%m, res %= m;
        x = ((x%m) * (x%m))%m;
        p >>= 1;
    }

    return res;

}

int main(){

    fastio;

    ll n, ans;
    cin >> n;

    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        cnt[x]++;
    }

    bool ok = true;

    if(n % 2){
        if(cnt[0] != 1) ok = false;
        for(int i=2; i<=n; i+=2) if(cnt[i] != 2) ok = false;
    }
    else{
        for(int i=1; i<=n; i+=2) if(cnt[i] != 2) ok = false;
    }

    if(ok) ans = bigmod(2, n/2, MOD);
    else ans = 0;

    cout << ans;



}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			BigInteger a = BigInteger.valueOf(s.nextInt());
			BigInteger b = BigInteger.valueOf(s.nextInt());
			BigInteger g = a.gcd(b);
			BigInteger l = a.multiply(b).divide(g);
			System.out.println(g+" "+l);
		}	
	}	
}

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

using namespace std;

constexpr int INF = 0x3f3f3f3f;

vector<int> edges[100001];

struct Range {
	int lowerBound, upperBound;

	Range(int lb = -INF, int ub = INF): lowerBound(lb), upperBound(ub) {}

	bool have(int v) const {
		return lowerBound <= v && v <= upperBound;
	}

	void intersectWith(const Range &other) {
		lowerBound = max(lowerBound, other.lowerBound);
		upperBound = min(upperBound, other.upperBound);
	}

	Range extend() const {
		return {lowerBound - 1, upperBound + 1};
	}

	bool isValid() const {
		return lowerBound <= upperBound;
	}
} ranges[100001];

bool qinDing[100001];
int value[100001];

bool checkValidity(int x, int parent, int parity) {
	if (qinDing[x] && ranges[x].lowerBound % 2 != parity) return false;
	for (int child: edges[x])
		if (child != parent) {
			if (!checkValidity(child, x, 1 - parity)) return false;
			ranges[x].intersectWith(ranges[child].extend());
		}
	return ranges[x].isValid();
}

void fill(int x, int parent) {
	for (int child: edges[x])
		if (child != parent) {
			if (ranges[child].have(value[x] + 1)) value[child] = value[x] + 1; else value[child] = value[x] - 1;
			fill(child, x);
		}
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	int k, r;
	cin >> k;
	for (int i = 0; i < k; ++i) {
		int v, p;
		cin >> v >> p;
		qinDing[v] = true;
		ranges[v] = Range(p, p);
		r = v;
	}

	if (!checkValidity(r, 0, ranges[r].lowerBound % 2)) {
		cout << "No" << endl;
		return 0;
	}
	
	value[r] = ranges[r].lowerBound;
	fill(r, 0);

	cout << "Yes" << endl;
	for (int i = 1; i <= n; ++i) cout << value[i] << '\n';

	return 0;
}

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

int main() {
	// your code goes here
	string s;
	cin >> s;
	bool ans = true;
	for(int i=0; i<s.size(); i+=2)
	{
		if(s.at(i) == 'L')
		{
			ans = false;
		}
	}
	for(int i=1; i<s.size(); i+=2)
	{
		if(s.at(i) == 'R')
		{
			ans = false;
		}
	}
	
	if(ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, t[100010], a[100010];

signed main() {
	cin >> n;
	rep(i, n)cin >> t[i];
	rep(i, n)cin >> a[i];
	if (t[n - 1] != a[0]) {
		cout << 0 << endl;
		ggr

	}
	long long ta = 1;
	for (int i = 1; i < n - 1; i++) {
		if (t[i - 1]<t[i] && a[i]>a[i*+1] && t[i] != a[i]) {
			cout << 0 << endl;
			ggr
		}
		if ((t[i - 1]<t[i] && t[i]>a[i]) || (a[i] > a[i + 1] && a[i] > t[i])) {
			cout << 0 << endl;
			ggr
		}
		if (t[i - 1] == t[i] && a[i] == a[i + 1]) {
			ta *= min(t[i], a[i]);
			ta %= mod;
		}
	}
	cout << ta << endl;
	ggr
}


Measured memory_bytes: 1024
n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }

abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# graph及びreverse_graphの構築

graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << [b,c]
  r_graph[b] << [a,c]
end

def reachable(g, s)
  result = []
  q = [s]
  until q.empty?
    current = q.shift
    result << current
    g[current].each do |to, cost|
      next if result.include?(to)
      q << to
      result << to
    end
  end
  result
end

# 到達可能なノードの洗い出し
retrenched_nodes = reachable(graph, 1) & reachable(r_graph, n)
retrenched_roads = abc.select {|a, b, _| retrenched_nodes.include?(a) && retrenched_nodes.include?(b) }

INF = 10**12
dist = Array.new(n+1, INF)
dist[1]=0
updated = false

# 到達可能ノードに対するBF
# BFの中でdistを更新していく
retrenched_nodes.each do
  updated = false
  retrenched_roads.each do |a, b, c|
    if dist[a] != INF && dist[b] > dist[a] + c
      dist[b] = dist[a] + c
      updated = true
    end
  end

  break unless updated
end

#p dist

if updated
  p -1
  exit
end

# 求まった最初コストに対してマイナスをかけて0と比較、大きい方を提出

#p retrenched_nodes
#p dist
p [-1*dist[n], 0].max




Measured memory_bytes: 5372
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,K; cin >> N >> K;
    vector<int> l(N);
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());
    int out=0;
    for(int i=0;i<K;i++){
        out += l[i];
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3544
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a - 1 + (a <= b);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

int main()
{
	int ret;
	int N, K;
	int d;
	int sunuke[100];
	int A;
	int i, j;
	int count;
	
	ret = scanf("%d %d\n", &N, &K);
	
	for (i = 0; i < N; i++) {
		sunuke[i] = 0;
	}
	
	for (i = 0; i < K; i++) {
		ret = scanf("%d\n", &d);
		for (j = 0; j < d; j++) {
			ret = scanf(" %d", &A);
			sunuke[A-1]++;
		}
	}

	count = 0;
	for (i = 0; i < N; i++){
		fprintf(stderr, "i: %d\n", i);
		if (sunuke[i] == 0) {
			count++;
		}
	}
	
	printf("%d\n",count);
	fflush(stdout);
	return EXIT_SUCCESS;
}


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


void solve(long long N){
    string str;
    int r=N%10;
    if (r==2 || r==4|| r==5||r==7||r==9) {
        str="hon";
    }else if(r==0||r==1||r==6||r==8){
        str="pon";
    }else{
        str="bon";
    }
    cout << str << endl;
    
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3700
S=input()
check=S
flg=0
check.rstrip()
check.rstrip()
P=list(check)
while True:
    P.pop(-1)
    P.pop(-1)
    naga=int(len(P)/2)
    for i in range(0,naga):
        if P[i]==P[naga+i]:
            flg=1
        else:
            flg=0
            break
    if flg==1:
        break
print(len(P))

Measured memory_bytes: 3064
// AGCは質が高くていいな〜〜
// 枯渇しない限りは拡散できる
// 最初1-indexedにしてたのに0に赤を置いてて無限時間バグった

package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	Balls := make([]int, N+1)
	PossibilityRed := make([]bool, N+1)
	for i := 1; i <= N; i++ {
		Balls[i] = 1
		PossibilityRed[i] = false // いらんけど
	}
	PossibilityRed[1] = true
	for i := 0; i < M; i++ {
		var A, B int
		fmt.Scan(&A, &B)
		if Balls[A] == 0 {
			continue // あるかどうかしらんけど
		}
		if PossibilityRed[A] {
			PossibilityRed[B] = true
			if Balls[A] == 1 {
				PossibilityRed[A] = false
			}
		}
		Balls[A]--
		Balls[B]++
	}
	ans := 0
	for _, p := range PossibilityRed {
		if p {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
// 標準入力一行を読み取り，指定の型に変換する関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_splited<T: std::str::FromStr>() -> Vec<T>{

    let mut s = String::new();

    std::io::stdin().read_line(&mut s).ok();

    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()

}




fn main(){

    let s: String = read();
    let mut v = Vec::new();

    for c in s.chars() {
        match c {
        '0' => {
            v.push(c);
        },
        '1' => {
            v.push(c);
        }
        'B' => {
            if v.len() > 0{
                v.pop();
            }
        }
        _ => println!("ERROR!")

        }

    }


    for i in v {
        print!("{}", i);
    }
    print!("\n");
    //let f = format!("{}", s);


    //println!("{}", f);
}



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

using namespace std;

void dfs(int n,vector<int> g[],vector<int> &dp,vector<bool> &visited){
    visited[n] = true;
    for(int i : g[n]){
        
        if(!visited[i])
            dfs(i,g,dp,visited);
        dp[n] = max(dp[n],dp[i] + 1);
    }
}

int main(){
    int v,e; cin >> v >> e;

    vector<int> g[v+1]; 

    for(int i=0;i<e;i++){
        int a,b; cin >> a >> b;
        g[a].push_back(b);
    }

    vector<int> dp(v+1,0);
    vector<bool> visited(v+1,false);

    for(int i=1;i<=v;i++){
        if(!visited[i]){
            dfs(i,g,dp,visited);
        }
    }

    int r = 0;

    for(int i=1;i<=v;i++){
        r = max(r,dp[i]);
    }

    cout << r << endl;
}

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

int main(void){
    int n, q, cur, cnt;
    std::cin >> n;
    std::vector<int> s(n);
    cnt = 0;
    for(int i = 0; i < n; i++){
	std::cin >> s[i];
    }
    std::cin >> q;

    for(int i = 0; i < q; i++){
	std::cin >> cur;
	int left, right, mid;
	left = 0;
	right = n;
	// std::cout << "cur:" << cur << std::endl;
	while(left <= right){
	    // std::cout << "left:" << left << " " << "right:" << right << std::endl;
	    mid = (left + right) / 2;
	    // std::cout << "mid:" << mid << std::endl;
	    // std::cout << "s[mid]:" << s[mid] << std::endl;
	    if(s[mid] == cur){
		cnt++;
		break;
	    }else if(s[mid] > cur){
		right = mid - 1;
	    }else{
		left = mid + 1;
	    }
	}
    }

    std::cout << cnt << std::endl;


    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>

using namespace std;

int main(void){

  int number;
  int A=0,B=0;
  cin >> number;

  for(int i=0; i<number; i++){
     string str1,str2;
     cin >> str1 >> str2;

     if(str1 > str2) A+= 3;
     else if(str1 == str2){
          A++;
          B++;
     }else
         B+=3;
  }

  cout << A << " " << B << endl;

  return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<pair<int, int>> data (n);
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    data[i] = make_pair (a, i+1);
  }
  
  sort (data.begin(), data.end());
  
  for (pair<int, int> c : data) {
    int d;
    tie (ignore, d) = c;
    cout << d << " ";
  }
  
}

Measured memory_bytes: 1536
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split(); if (line.length < args.length) return;foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
//------------------------------
const coin = [10,50,100,500];
void main(){
	int total;
	for(read(total); total ; read(total), write(total ? "\n":"")){
		auto have = new int[4];
		readArray(have);
		int howMany = int.max; 
		auto uses = new int[4];
		auto hia = have.map!("iota(a+1).array"); 
		foreach (I;cartesianProduct(hia[0],hia[1],hia[2],hia[3])){
			auto tmpuses = I.array;
			auto pay = coin.dotProduct(tmpuses);	
			if (pay < total) continue;
			int tmpHowMany = have.sum + howManyCoins(pay - total) - tmpuses.sum;
			if (tmpHowMany < howMany ){
				howMany = tmpHowMany;
				uses = tmpuses;
			}
		}
		foreach(i,u;uses){if(u >0)writeln(coin[i]," ",u);}
	}
}
int howManyCoins(int pay){
	int res;
	foreach_reverse(c;coin){
		while(pay >= c){ 
			pay -= c;res ++;
		}
	} 
	return res;
}

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

int main(){
    int N;
    cin >> N;
    int X_list[200000];
    int Y_list[200000];
    for(int i=0; i<N; i++){
        cin >> X_list[i];
        Y_list[i] = X_list[i];
    } 
    sort(Y_list, Y_list+N);
    int med1 = Y_list[N/2-1];
    int med2 = Y_list[N/2];
    for(int i=0; i<N; i++){
        if(X_list[i] <= med1){
            cout << med2 << endl;
        }else{
            cout << med1 << endl;
        }
    }
    return EXIT_SUCCESS;
}

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

typedef struct fox{ int val; fox *left, *right; } fox_n;

fox_n* init()
{
    fox_n* root = new fox_n;
    root->val = -1;
    root->left = NULL;
    root->right = NULL;
    return root;
}

void insert(fox_n* root, int key)
{
    static bool first = true;
    static bool add_leaf = true;  // true:left, false:right.
    if(first){ first = false; root->val = key; return; }  // initialize.
    fox_n* canis;
    fox_n* water = root;  // water from root to leaf.
    do{
        canis = water;
        if(key < canis->val){  // canis chases water.
            water = canis->left;
            add_leaf = true;
        }else{
            water = canis->right;
            add_leaf = false;
        }
    }while(water != NULL);

    fox_n* leaf = new fox_n;  // add new leaf.
    leaf->val = key;
    leaf->left = NULL;
    leaf->right = NULL;
    if(add_leaf){ canis->left = leaf; }else{ canis->right = leaf; }
    return;
}

void inorder(fox_n* root)
{
    if(!root) return;
    inorder(root->left);
    printf(" %d", root->val);
    inorder(root->right);
    return;
}

void preorder(fox_n* root)
{
    if(!root) return;
    printf(" %d", root->val);
    preorder(root->left);
    preorder(root->right);
    return;
}

int main()
{
    fox_n* root = init();
    int i, n, key;
    char cmd[6];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s", cmd);
        if(cmd[0] == 'i'){ cin >> key; insert(root, key); }
        else{ inorder(root); printf("\n"); preorder(root); printf("\n"); }
    }
    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<P> cb(m);
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    cb.at(i) = make_pair(c, b);
  }
  // ソート
  sort(a.begin(), a.end());
  sort(cb.rbegin(), cb.rend());
  int ai = 0;
  for (auto ccbb : cb) {
    rep(i, ccbb.second) {
      if (a.at(ai) < ccbb.first) {
        a.at(ai) = ccbb.first;
        ai++;
      } else {
        break;
      }
      if (ai >= n) {
        break;
      }
    }
    if (ai >= n) {
      break;
    }
  }

  ll res = 0;
  rep(i, n) {
    res += a.at(i);
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int ns = s.size(), nt = t.size();
  vector<vector<int>> dp(ns+1, vector<int>(nt+1,0));
  for(int i=0; i<ns; ++i) for(int j=0; j<nt; ++j){
    if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] +1;
    else{
      dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    }
  }
  string ans;
  int x = ns, y=nt;
  while(dp[x][y] > 0){
    while(dp[x][y] == dp[x-1][y]) --x;
    while(dp[x][y] == dp[x][y-1]) --y;
    ans = s[x-1] + ans;
    --x; --y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 38784
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define REP(i,N) for(ll i=0;i<N;++i)
using namespace std;
using ll = long long;

pair<ll, ll> search(vector<ll> &A, ll left, ll right) {
	if (right - left <= 2) return make_pair(left, right);
	ll first_third = left + (right - left)/3;
	ll second_third = left + 2*(right - left)/3;

	ll first_sum, second_sum;
	first_sum = second_sum = 0;
	REP(i,A.size()) first_sum += abs(A[i] - first_third);
	REP(i,A.size()) second_sum += abs(A[i] - second_third);
	//cout << "left = " << left << ", right = " << right << ", first_sum = " << first_sum << ", second_sum = " << second_sum << endl;
	// finding the minimal	
	if (first_sum < second_sum) {
		return search(A, left, second_third);
	} 
	else if (first_sum > second_sum) {
		return search(A, first_third, right);
	}
	return search(A, first_third, second_third);
}

int main () {
	ll N;
	cin >> N;
	vector<ll> A(N);
	// 0-base
	REP(i,N) {
		scanf("%lld", &A[i]);
		A[i] -= (i+1);
	}
	/// searching by ternary search
	//REP(i,N) cout << " " << A[i];
	//cout << endl;
	pair<ll,ll> bounds = search(A, -1000000000, 1000000000);
	//cout << "b = " << b << endl;
	ll sum = 0;
	REP(i,A.size()) sum += abs(A[i] - bounds.first);
	for (ll b = bounds.first+1; b<=bounds.second; ++b) {
		ll temp = 0;
		REP(i,A.size()) temp += abs(A[i] - b);
		sum = min(sum, temp);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
from collections import Counter
N = int(input())
a = [int(input()) for i in range(N)]

c = Counter(a)

#偶数回表れていれば消えている、奇数回であれば紙に掛かれている状態
ans = 0
for n, count in c.items():
  if count % 2 == 1:
    ans += 1

print(ans)

Measured memory_bytes: 16612
N, K = map(int, input().split())
*p, = map(int, input().split())

a = sum([(v+1) for v in p[:K]])
m = a
for i in range(1, N-K+1):
    t = a+(p[i+K-1]+1)-(p[i-1]+1)
    if t > m:
        m = t
    a = t
print(m/2)


Measured memory_bytes: 81544
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

mod = 10 ** 9 + 7

dp = [-1] * (n + 1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
print(dp[n])


Measured memory_bytes: 7848
#include<stdio.h>

int main(void) {
    int n, flag = 1, exchange = 0;
    
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    for(int i = 0; flag; i++) {
        flag = 0;
        for(int j = n-1; j>=i+1; j--) {
            if(a[j] < a[j-1]) {
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp; 
                flag = 1;
                exchange++;
            }
        }
    }

    for(int i = 0; i < n-1; i++) printf("%d ", a[i]);
    printf("%d\n%d\n", a[n-1], exchange);

    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <deque>

int main(int argc, char const *argv[]){
	
	int N;
	std::deque<int> que;
	std::cin >> N;
	std::string cmd;
	int key;

	for (int i = 0; i < N; ++i){
		if(std::cin >> cmd){
			if(cmd=="insert"){
				std::cin >> key;
				que.push_front(key);
			}else if(cmd=="delete"){
				std::cin >> key;
				for (int j = 0; j < que.size(); ++j){
					if(que[j]==key){
						que.erase(que.begin()+j);
						break;
					}
				}
			}else if(cmd=="deleteFirst"){
				que.pop_front();
			}else if(cmd=="deleteLast"){
				que.pop_back();
			}else{
				// exception
			}
		}
	}
	
	for (int i = 0; i < que.size(); ++i){
		std::cout << que[i];
		if(i<que.size()-1) std::cout << " ";
	}
		std::cout << std::endl;
	
	return 0;
}


Measured memory_bytes: 7108
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    String out = "";
    for (int ii = 0; ii < n; ii++) {
      String str = scanner.next();
      List<String> ascs = new ArrayList<String>();
      List<String> descs = new ArrayList<String>();
      String ascStr = "";
      String descStr = "";
      for (int jj = 0; jj < str.length(); jj++) {
        ascs.add(str.substring(jj, jj + 1));
        descs.add(str.substring(jj, jj + 1));
      }
      Collections.sort(ascs);
      Collections.sort(descs);
      Collections.reverse(descs);
      for (int jj = 0; jj < ascs.size(); jj++) {
        ascStr += ascs.get(jj);
        descStr += descs.get(jj);
      }
      out += (Integer.parseInt(descStr) - Integer.parseInt(ascStr)) + "\n";
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 17188
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include <list>
using namespace std;
int flag[10000],a[100000];
bool check(int x){
	while(x>0){
		int t=x%10;
		if(flag[t]){
			return false; 
		}
		x/=10;
	}
	return true;
}
int main()
{       
    int n,k;
    scanf("%d %d",&n,&k);
     for(int i=1;i<=k;++i){
     	int u;
     	scanf("%d",&u);
     	flag[u]=1;
	 }
	 for(int i=n;i;i++){
	 	if(check(i)){
	 		printf("%d\n",i);
	 		break;
		 }
	 }
		return 0;
}

Measured memory_bytes: 256
nums = [int(e) for e in input().split()]
a = nums[0]
b = nums[1]
c = nums[2]
d = nums[3]
while a > 0 and c > 0:
    c -= b
    if c <= 0:
        break
    a -= d

if a > 0:
    print('Yes')
elif c > 0:
    print('No')

Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef int_fast64_t ll;

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    constexpr ModFact() : fact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, M, ans = 1, cnt = 1;
constexpr ll th = 1LL<<45;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    M = N << 1;
    fread_unlocked(S, 1, M, stdin);
    if(S[0] == 'B' && S[M-1] == 'B') {
        bool f = false;
        for(size_t i = 0; i < M-1;) {
            if(S[i++] == S[i]) f ^= true;
            if(f) {
                ans *= (cnt << 1) - i;
                if(ans > th) ans %= MOD;
            }
            else if(++cnt > N) break;
        }
        if(cnt != N) ans = 0;
        else ans = ((ans % MOD) * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384