akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
struct square
{
    int x;
    int y;
};
int main(void)
{
    string s;
    cin >> s;
    bool Nf = false, Sf = false, Ef = false, Wf = false;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'N')
        {
            Nf = true;
        }
        if (s[i] == 'S')
        {
            Sf = true;
        }
        if (s[i] == 'E')
        {
            Ef = true;
        }
        if (s[i] == 'W')
        {
            Wf = true;
        }
    }
    if (Nf == true && Sf == true && (Wf == false && Ef == false))
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (Wf == true && Ef == true && (Nf == false && Sf == false))
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (Wf == true && Ef == true && Nf == true && Sf == true)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

double dist(pii p1, pii p2) {
  return sqrt((p1.first - p2.first) * (p1.first - p2.first) +
              (p1.second - p2.second) * (p1.second - p2.second));
}

int main(int argc, char const *argv[]) {
  int n;
  double base = 1, result = 0;
  double tmp;
  ll x, y;

  cin >> n;
  vector<pair<ll,ll>> xy(n);
  std::vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    xy[i] = make_pair(x, y);
    v[i] = i;
    base *= (i + 1);
  }

  do {
    tmp = 0;
    for (int i = 1; i < n; i++) {
      tmp += dist(xy[v[i - 1]], xy[v[i]]);
    }
    result += tmp / base;
  } while (std::next_permutation(v.begin(), v.end()));

  cout << std::setprecision(15) << result << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  const int max_n = 200000;
  const long long mod = 1000000000 + 7;
  int n, k;
  cin >> n >> k;

  long long s[max_n+1];
  s[0] = 0;
  for(int i = 1; i <= n; i++){
    s[i] = s[i-1] + i;
  }

  long long ans = 0;
  for(int i = k; i <= n+1; i++){
    if(i != n+1){
      long long max = s[n] - s[n - (i - 1) - 1];
      long long min = s[i - 1];
      long long res = max - min + 1;
      ans = (ans + res) % mod;
    }else{
      long long max = s[n];
      long long min = s[i - 1];
      long long res = max - min + 1;
      ans = (ans + res) % mod;
    }
    
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 5196
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        int H = cin.nextint;
        var Q = new PriorityQueue<int>();
        int max = 0;
        for (int i = 0; i < N; i++)
        {
            max = Math.Max(cin.nextint, max);
            Q.Enqueue(cin.nextint);
        }
        int cnt = 0;
        while (Q.Any() && max < Q.Peek() && H > 0)
        {
            H -= Q.Dequeue();
            cnt++;
        }
        if (H > 0) cnt += (H + max - 1) / max;
        WriteLine(cnt);
    }
}

class PriorityQueue<T> where T : IComparable<T>
{
    List<T> heap; int size;
    int Compare(T x, T y) { return y.CompareTo(x); }
    public PriorityQueue() { heap = new List<T>(); }
    public void Enqueue(T x)
    {
        heap.Add(x);
        int i = size++;
        while (i > 0)
        {
            int p = (i - 1) >> 1;
            if (Compare(heap[p], x) <= 0) break;
            heap[i] = heap[p]; i = p;
        }
        heap[i] = x;
    }
    public T Dequeue()
    {
        T ret = heap[0]; T x = heap[--size];
        int i = 0;
        while ((i << 1) + 1 < size)
        {
            int a = (i << 1) + 1; int b = (i << 1) + 2;
            if (b < size && Compare(heap[b], heap[a]) < 0) a = b;
            if (Compare(heap[a], x) >= 0) break;
            heap[i] = heap[a]; i = a;
        }
        heap[i] = x; heap.RemoveAt(size);
        return ret;
    }
    public int Count { get { return size; } }
    public bool Any() { return size > 0; }
    public T Peek() { return heap[0]; }
}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
using namespace std;
int main(){ 
for (int k = 0; k < 114514; ++k){
int H, W; 
cin >> H >> W; 
  if(H == 0 && W == 0){
   break; 
  }
for (int i = 0; i < H; ++i) {
  for (int j = 0; j < W; ++j) { 
    if(i == 0 || i == H-1 || j == 0 || j == W-1 ) cout << "#"; 
    else cout << "."; 
   }
  cout << endl; 
  }
  cout << endl; 
}
}


Measured memory_bytes: 3084
#include<cstdlib>
#include<map>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include <iostream>
#define ll long long
using namespace std;
int main()
{
    int num;
    int k=-1;
    int a[100010];
    cin>>num;
    if(num==0)
    {
        cout<<num<<endl;
        return 0;
    }
    while(num)
    {
        a[++k]=num%(-2);
        num/=-2;
        if(a[k]==-1)
        {
            a[k]=1;
            num++;
        }
    }
    for(int i=k; i>=0; i--)
        cout<<a[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  vector<vector<int> > a(n,vector<int> (m,0));
  vector<int> b(m);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    int now = 0;
    for(int j = 0; j < m; j++){
      now += a[i][j] * b[j];
    }
    cout << now << endl;
  }
  return 0;
}



Measured memory_bytes: 3184
A = int(input())
B = int(input())
C = int(input())
X = int(input())
Y = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                Y += 1
print(Y)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define lin puts("");
ll n,x,y,a[300000],b[300000],c=0,t=0,sum=0,z=0,i,j,f=0;
char ch[101],cr,ss[101];
string s;
int main()
{
    cin>>n;
    while(n)
    {
        if(n%10==7)
        {
            t=1;
            break;
        }
        n/=10;
    }
    if(t)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, c;
    cin >> n >> c;

    int d[35][35];
    for(int i = 1; i <= c; ++i) {
        for(int j = 1; j <= c; ++j) {
            cin >> d[i][j];

        }
    }

    vector<int> v[3];
    map<P, int> mp;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            int a;
            cin >> a;
            v[(i + j) % 3].pb(a);
            mp[MP((i + j) % 3, a)]++;

        }
    }
    for(int i = 0; i < 3; ++i) {
        sort(all(v[i]));
        v[i].erase(unique(all(v[i])), v[i].end());

    }

    int res = INF;
    for(int i = 1; i <= c; ++i) {
        int sum_i = 0;
        for(int l = 0; l < v[0].size(); ++l) {
            sum_i += d[v[0][l]][i] * mp[MP(0, v[0][l])];

        }

        for(int j = 1; j <= c; ++j) {
            if(i == j) {
                continue;

            }
            int sum_j = 0;
            for(int l = 0; l < v[1].size(); ++l) {
                sum_j += d[v[1][l]][j] * mp[MP(1, v[1][l])];

            }

            for(int k = 1; k <= c; ++k) {
                if(j == k || i == k) {
                    continue;

                }
                int sum_k = 0;
                for(int l = 0; l < v[2].size(); ++l) {
                    sum_k += d[v[2][l]][k] * mp[MP(2, v[2][l])];

                }
                res = min(res, sum_i + sum_j + sum_k);
                /*
                cout << i << " " << j << " " << k << endl;
                cout << sum_i << " " << sum_j << " " << sum_k << endl << endl;
                cout << res << endl;
                */

            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1520
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,ans="";
	cin>>s;
	rep(i,s.size()){
		ans+=s[s.size()-i-1];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2] && S[1] == 'R') {
        cout << 3 << endl;
    } else if (S[1] == 'R' && S[0] == S[1]) {
        cout << 2 << endl;
    } else if (S[1] == 'R' && S[1] == S[2]) {
        cout << 2 << endl;
    } else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

const int MAX = 6;

int d[MAX];

int main()
{
    int n;
    cin >> n;
    double h;
    REP(n) 
    {
        cin >> h;
        if(h<165.0) {d[0]++; continue;}
        if(h<170) {d[1]++; continue;}
        if(h<175) {d[2]++; continue;}
        if(h<180) {d[3]++; continue;}
        if(h<185) {d[4]++; continue;}
        d[5]++;
    }

    REP(MAX)
    {
        cout << i+1 << ":";
        rep(j,d[i]) cout << "*";

        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  V<P> a,b;
  for(int i=0;i<n;i++){
    ll h=0,mi=0;
    string s;cin>>s;
    for(int j=0;j<s.size();j++){
      if(s[j]=='(')h++;
      else h--;
      chmin(mi,h);
       }
       if(h>0)a.emplace_back(mi,h);
       else b.emplace_back(mi-h,-h);
  }
  sort(all(a),greater<P>());
  sort(all(b),greater<P>());
  int now=0;
  bool ok=true;
  for(int i=0;i<a.size();i++){
    if(now+a[i].fi<0)ok=false;
    now+=a[i].se;
  }
  int l=now;
  now=0;
  for(int i=0;i<b.size();i++){
    if(now+b[i].fi<0)ok=false;
    now+=b[i].se;
  }
cout<<(l==now&&ok?"Yes":"No")<<"\n";
}


Measured memory_bytes: 19060
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string o,e;
  cin>>o>>e;

  string ans="";

  rep(i,e.length()){
    ans+=o[i];
    ans+=e[i];
  }

  if(o.length()-e.length()) ans+=o[o.length()-1];

  cout<< ans<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

void printstring(vector<vector<int>> dp, string a, string b) {
    string s = "";
    int ans = dp[a.length()][b.length()];
    for(int i = a.length(); i > 0; --i)
        for(int j = b.length(); j > 0; --j) {
            if(a[i-1] == b[j-1] && dp[i][j] == ans) {
                --ans;
                s += a[i-1];
                break;
            }
        }
    reverse(begin(s), end(s));
    cout << s;

}
int main() {
    string a, b;
    cin >> a >> b;
    vector<vector<int>> dp(a.length() + 1,  vector<int>(b.length() + 1, 0));
    for(int i = 0; i < a.length(); ++i) {
        for(int j = 0; j < b.length(); ++j) {
            if(a[i] == b[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]);
            }
        }
    }
    printstring(dp, a, b);
    // for(int i = 0; i <= a.length(); ++i) {
    //     for(int j = 0; j <= b.length(); ++j)
    //         cout << dp[i][j] << " ";
    //     cout << "\n";
    // }
    

}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using pint = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    unordered_map<int, int> table;
    rep(i, n)++ table[a[i]];

    ll sum = 0;
    for (auto i : table)
        sum += ll(i.second) * (i.second - 1) / 2;

    rep(i, n) cout << sum - (table[a[i]] - 1) << endl;
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif


//
int main()
{
	GO
	//fioe();
	ll n;
	cin>>n;
	ll arr[n+2];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	ll dp[n+2];
	dp[0]=dp[1]=0;
	dp[2]=abs(arr[1]-arr[0]);
	for(ll i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-3]-arr[i-1]));
	}
	cout<<dp[n]<<endl;
	time();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int A, B, K;
	cin >> A >> B >> K;

	if (A <= K) {
		K -= A;
		A = 0;
	} else {
		A -= K;
		K = 0;
	}
	B = max(Int(0), B - K);

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(a+n);i++)
#define var auto
using namespace std;
using ll = long long;

int main() {

  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (u == s) {
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np

N,D = (int(i) for i in input().split())

X = [[int(i) for i in input().split()] for i in range(N)] 

def Distanse_int(x,y,D):
    A=0
    for i in range(D):
        A = A + (x[i]-y[i])**2
       
    B = np.sqrt(A)
    if B == int(B):
        return(1)
    else:
        return(0)

count = 0

for i in range(N-1):
    for k in range(i+1,N):
        B = Distanse_int(X[i],X[k],D)
        if B == 1:
            count = count + 1

print(count)
        
        

Measured memory_bytes: 12448
import sys

N=int(input())
HP=list(map(int,input().split()))

a=HP[0]
b=HP[1]

(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
    q = a // b
    (a, b) = (b, a % b)
    (x, lastx) = (lastx - q * x, x)
    (y, lasty) = (lasty - q * y, y)
        
tmp=a

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    if tmp==1:
        print(tmp)
        sys.exit()
    
print(tmp)

Measured memory_bytes: 14428
#include <iostream>
#include <string>
using namespace std;

int main(){
  string a;
  cin >> a;
  int counter = 0;
  if(a[0] == '1') counter++;
  if(a[1] == '1') counter++;
  if(a[2] == '1') counter++;
  cout << counter << endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int N, a, b, res;
    cin >> N;
    a = 0;
    res = 0;

    for (int n = 0; n < N; n++) {
        cin >> b;
        res += max(0, b - a);
        a = b;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
N,K = list(map(int,input().split()))
pi = list(map(int,input().split()))
value = sum(pi[:K])
max_value = value
for i in range(N-K):
  value += pi[i+K] - pi[i]
  max_value = max(value, max_value)
print((max_value+K)/2)

Measured memory_bytes: 25060
n,a,b,c,d=map(int,input().split())
if n%a==0:
    x=n//a*b
else:
    x=(n//a+1)*b

if n%c==0:
    y=n//c*d
else:
    y=(n//c+1)*d

if x>=y:
    print(y)
else:
    print(x)


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

void
solver(int n, char *s)
{
    int i;
    int r=0;

    for(i=0; i<n-2; i++) {
        if (s[i]=='A') {
            if (strncmp(s+i, "ABC", 3)==0)
                r++;
        }
    }
    printf("%d\n", r);
}

int
main(int argc, char *argv[])
{
    int N;
    char S[51];

    scanf("%d", &N);
    scanf("%s", S);

    solver(N, S);
    return 0;
}


Measured memory_bytes: 128
import numpy as np
n, k = map(int, input().split())
p_seq = np.array(list(map(int, input().split())))
e_seq = (p_seq + 1) / 2
s_seq = [0]
for e in e_seq:
    s_seq.append(s_seq[-1] + e)
print(max(s_seq[i + k] - s_seq[i] for i in range(n - k + 1)))


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    
    int H,A,cnt,i;

    cin>>H>>A;

    if(H % A == 0){
		cnt = H / A;
    }
  	else{
		cnt = H / A + 1;
    }

    cout<<cnt<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=998244353;

int N;
int M;
map<pii, int> contra;
bool fail;
LL ans = 1;
LL dp[114514][2];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

int main() {
  scanf("%d%d", &N, &M);

  LL num_free = (LL(N-2)*(N-3)/2);
  rep(i, M) {
    int x, y, c;
    scanf("%d%d%d", &x, &y, &c);
    --x;
    --y;
    contra[pii(x, y)] = c;
    if (abs(x-y) <= 2) {
      //
    } else {
      if (contra.count(pii(y, x))) {
        if (contra[pii(y, x)] != c) fail = true;
      } else num_free--; 
    }
  }
  assert(num_free >= 0);

  LL ans = mypow(2, num_free);
  //printf("num_free: %lld, ans: %lld\n", num_free, ans);
  reps(x, 1, N-1) {
    pii l(x+1, x-1);
    pii r(x-1, x+1);
    pii c(x, x);

    int g = contra.count(l) + contra.count(r);
    if (g == 2) {
      int d = (contra[l] + contra[r])%2;
      if (contra.count(c) && contra[c] != d) fail = true;
      contra[c] = d;
    } else if (g == 0) {
      ans = ans*2 % MOD;
    }
  }

  if (fail) {
    puts("0");
    return 0;
  }

  rep(c, 2) {
    if (contra.count(pii(0, 0)) && contra[pii(0, 0)] != c) {
      //
    } else dp[0][c] = 1;
  }

  reps(x, 1, N) {
    pii cns[3] = {pii(x, x-1), pii(x, x), pii(x-1, x)};
    rep(k, 2) {
      rep(st, 8) {  
        bool invalid = false;
        int num = k;
        rep(i, 3) {
          int c = st >> i & 1;
          auto &p = cns[i];
          if (contra.count(p) && contra[p] != c) invalid = true;
          num += c;
        }

        if (invalid) continue;
        if (num%2) continue;

        int nk = st >> 1 & 1;
        (dp[x][nk] += dp[x-1][k]) %= MOD;
      }
    }
  }
  LL s = (dp[N-1][0] + dp[N-1][1]) % MOD;
  printf("%lld\n", (ans*s)%MOD);
}


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

map<long long int, int> prime_factor(long long int n) {
	map<long long int, int> ret;
	for (long long int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

int main() {
	long long int N;
	cin >> N;

	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}
	int output = 0;

	map<long long int, int> prime = prime_factor(N);

	vector<int> done;
	for (long long int i = 0; i < N + 1; i++) {
		if (prime[N] != 0) {  // N is prime
			output++;
			cout << output << endl;
			return 0;
		}
		int num = 1;
		while (1) {
			if (prime[i] == 0) {
				break;
			}
			if (prime[i] >= num) {
				if (find(done.begin(), done.end(), pow(i, num)) != done.end()) {  // if i^num is in done
					break;
				} else {
					N /= pow(i, num);
					output++;
					prime[i] -= num;
					num += 1;
					continue;
				}
			} else {
				N /= pow(i, prime[i]);
				break;
			}
		}
	}
	cout << output << endl;

	return 0;
}

Measured memory_bytes: 65992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(n, m, i) for (i32 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i32 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i32 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 n, a, b;
i64 x[100000];

i32 main()
{
    cin >> n >> a >> b;
    times(n, i) cin >> x[i];
    i64 ans = 0;
    range(0, n-1, i) {
        ans += min((x[i+1] - x[i]) * a, b);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a;
    map<int, int> mp;
    for (int i = 1; i < n+1; i++) {
        cin >> a;
        mp[a] = i;
    }
    for (int i = 1; i < n+1; i++) {
        cout << mp[i];
        if (i != n) cout << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 5504
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        s: chars,
    }

    let mut s = s;
    s.sort();

    if s[0] == s[1] && s[1] != s[2] && s[2] == s[3] {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
n,m=map(int,input().split())
v,r,ans=[float('inf') for i in range(n)],float('inf'),0
for i in range(m):
	a,b=map(lambda x:int(x)-1,input().split())
	v[a]=min(v[a],b)
for i in range(n-1):
	r=min(r,v[i])
	if r-i==1:
		ans+=1
		r=float('inf')
print(ans)

Measured memory_bytes: 9384
#include <iostream>

int main()
{
    unsigned y1, m1, d1, y2, m2, d2;
    std::cin >> y1 >> m1 >> d1;
    std::cin >> y2 >> m2 >> d2;
    if(y1 > y2 || (y1 == y2 && m1 > m2 || (m1 == m2 && d1 > d2)))
    {
        std::swap(y1, y2);
        std::swap(m1, m2);
        std::swap(d1, d2);
    }
    std::cout << (y2 - y1 + ((m2 > m1 || (m2 == m1 && d2 > d1)) ? 1 : 0))
              << '\n';
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b;
    cin>>a>>b;
    if(a>0) cout<<"Positive"<<endl;
    else if(b<0){
        if((b-a)%2==1) cout<<"Positive"<<endl;
        else cout<<"Negative"<<endl;
    }else cout<<"Zero"<<endl;
    return 0;
}


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

int h, n;
int a[110000];
string res = "Yes";

int main(){
  cin >> h >> n;
  int sum;
  rep(i, n){
    int tmp;
    cin >> tmp;
    sum += tmp;
  }
  if(h - sum > 0){
    res = "No";
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		int A, B; cin >> A >> B;
		if (B % A == 0) cout << (A + B) << endl;
		else cout << (B - A) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll a[n],b[n];
    rep(0,i,n)b[i]=0;
    rep(0,i,n){
        cin>>a[i];
        ++b[a[i]-1];
    }
    ll sum=0;
    rep(0,i,n){
        ll c=b[i];
        sum+=c*(c-1)/2;
    }
    rep(0,i,n){
        ll c=b[a[i]-1];
        cout<<sum-(c-1)<<endl;
    }
}

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

const int N=1005;
int n,m,a[N],b[N],c[N][30],print[N],q[105];
int f[70000];

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
   	if(c=='-')t=-1,c=getchar();
   	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
   	return s*t;
}

void work(int num){
	int p=num;
	print[0]=0;
	while(p){
		print[++print[0]]=p%2;
		p/=2;
	}
	memset(q,0,sizeof(q));
	for(int i=1;i<=n;i++)
	q[i]=print[n-i+1];
	for(int i=1;i<=m;i++){	
		for(int i=1;i<=n;i++)
		q[i]=print[n-i+1];
		for(int j=1;j<=b[i];j++)
		q[c[i][j]]=min(q[c[i][j]]+1,1);
		int s=0,two=1;
		for(int j=n;j>=1;j--)
		s=s+two*q[j],two*=2;
		f[s]=min(f[s],f[num]+a[i]);
	}
}

int main(void){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&a[i],&b[i]);
		for(int j=1;j<=b[i];j++)
		scanf("%d",&c[i][j]);
	}
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	int to=(1<<n)-1;
	for(int i=0;i<=to;i++){
		work(i);
	}
	if(f[to]==0x3f3f3f3f)printf("-1");
	else printf("%d\n",f[to]);
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main() {
	priority_queue<int> q;
	string s;
	int n;
	while (1) {
		cin >> s;
		if ( s == "end" ) break;
		else if ( s == "extract" ) {
			cout << q.top() << endl;
			q.pop();
		} else {
			cin >> n;
			q.push( n );
		}
	}
}

Measured memory_bytes: 7300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 || w == 0) {
				sc.close();
				break;
			}
			System.out.println(createFrame(h, w));
		}
	}

	static String createFrame(int h, int w) {
		StringBuilder sb = new StringBuilder();
		createLine(w, sb);
		createMiddle(h, w, sb);
		createLine(w, sb);
		return sb.toString();
	}

	static StringBuilder createLine(int w, StringBuilder sb) {
		for (int i = 0; i < w; i++) {
			sb.append('#');
		}
		sb.append("\n");
		return sb;
	}

	static StringBuilder createMiddle(int h, int w, StringBuilder sb) {

		for (int i = 0; i < h - 2; i++) {
			sb.append('#');
			for (int j = 0; j < w - 2; j++) {
				sb.append('.');
			}
			sb.append("#\n");
		}
		return sb;
	}
}

Measured memory_bytes: 26780
#include <iostream>
#include <string>
using namespace std;

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

	char ci = n[0];
	int i = atoi(&ci);
	char cj = n[1];
	int j = atoi(&cj);
	char ck = n[2];
	int k = atoi(&ck);

	int r = i*100+i*10+i;
	if (i < j) {
		r = (i + 1) * 100 + (i + 1) * 10 + (i + 1);
	}
	else if (i == j && j < k) {
		r = (i + 1) * 100 + (i + 1) * 10 + (i + 1);
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    set<int> s;
    int n,ans=0;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
        set<int>::iterator st=s.find(a.at(i));
        if (st==s.end()) {
            ans++;
            s.insert(a.at(i));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=101101;
ll a[N];
int T,n,k;
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	if (a[1]==0){
		printf("0\n");
		return 0;	
	}
	int can=0;
	ll cnt=1ll*1e9*1e9,sum=1;
	for (int i=1; i<=n; i++){
		if (cnt/sum<a[i]){
			can=1;
			break;	
		}
		sum=sum*a[i];		
	}
	if (can==1){
		printf("-1\n");
		return 0;	
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2516
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			int ap=0,bp=0;
			if(n==0)break;
			for(int i=0;i<n;i++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				if(a>b)ap+=a+b;
				if(a<b)bp+=a+b;
				if(a==b){
					ap+=a;
					bp+=b;
				}
			}
			System.out.println(ap+" "+bp);
		}
	}

}

Measured memory_bytes: 59860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int b;
    while(cin >>b,b){
        int n=1, l=b;
        for(int i=2; i<=b; ++i){
            int p = b - (i-1)*i/2;
            if(p<=0) break;
            if(p%i==0){
                l = p/i;
                n = i;
            }
        }
        printf("%d %d\n",l,n);
    }
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;
	void add(vector<int> &ans, int rep, int val) {
		if(rep <= 0) {
			return;
		}
		while(rep--) {
			ans.push_back(val);
		}
	}

public:
	void solveOne(int it){
		string s;
		cin >> s;
		int val = 0;
		for(char c : s) {
			val = (val + c - '0') % 9;
		}
		cout << (val == 0 ? "Yes":"No") << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <stack>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    int n;
    llong tmp;
    vector<llong > A;
    cin >> n;
    if (n == 2) {
        llong a, b;
        cin >> a >> b;
        cout << max(a, b) << " " << min(a, b) << endl;

        return 0;
    }
    rep(i, n) {
        cin >> tmp;
        A.push_back(tmp);
    }

    sort(A.begin(), A.end());

    llong max = A[A.size() - 1];

    vector<llong >::iterator itr;

    itr = lower_bound(A.begin(), A.end(), max / 2);


    if (max == *itr) {
        cout << max << " " << *(--itr) << endl;
    } else {
        llong c = *itr, r;
        if (abs(max / 2 - c) <= abs(*(--itr) - max / 2)) r = c;
        else r = *itr;
        cout << max << " " << r << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<stdlib.h>
#define T 100000
typedef struct data{
  int p;
  int c;
  int b;

} DATA;
void print(int );
int re(int,int);
int D[T];
DATA C[T];
int main(){
  int o,i,j,a,b,s,l,r;
 
  scanf("%d",&o);
  for(i=0;i<o;i++){
    C[i].p=-1;
    C[i].c=-1;
    C[i].b=-1;
  }
 
  for(i=0;i<o;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&s);
      if(j==0){
	C[a].c = s;
      }
      else {
	C[l].b = s;
      }
      l=s;
      C[s].p = a;
    }
  }
 
  for(i=0;i<o;i++){
    if(C[i].p == -1)
      r = i;
  }
  re(r,0);
  for(i=0;i<o;i++){
   

    print(i);
  }
  
  return 0;
}
int re(int r,int g){
  D[r]=g;
  if(C[r].b != -1)re(C[r].b,g);
  if(C[r].c != -1)re(C[r].c,g+1);

}
void print(int i){
  int a,b;
  printf("node %d: ",i);
  printf("parent = %d, ",C[i].p);
  printf("depth = %d, ",D[i]);

  if(C[i].p == -1)printf("root, ");
  else if(C[i].c == -1)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  
  for(a=0,b=C[i].c;b!=-1;a++,b=C[b].b)
    {
    if(a)printf(", ");
    printf("%d",b);
  }
  printf("]\n");
    }



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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 1001001001;


int main(){
    int n, m;
    cin >> n >> m;
    Graph G(n + 1, vector<int>());

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool ok = false;
    for (auto u: G[0]) {
        for (auto w: G[u]) {
            if (w == (n-1)) {
                ok = true;
                break;
            }
        }
        if (ok) break;
    }

    cout << ((ok) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 12016
l, r, d = map(int, input().split())
if l % d == 0 and r % d == 0:
  print(r//d-l//d+1)
elif l % d != 0 and r % d == 0:
  print(r//d-l//d)
elif l % d == 0 and r % d != 0:
  print(r//d-l//d+1)
else:
  print(r//d-l//d)
  

Measured memory_bytes: 9176
#include <stdio.h>

int abs(int a){
  if(a<0){
    return -a;
  }
  return a;
}

int min(int a, int b){
  if(a>b){
    return b;
  }
  return a;
}

int main(){
  int N;
  scanf("%d",&N);
  int h[100001];
  int i;
  for(i=1;i<=N;i++){
    scanf("%d",&h[i]);
  }
  int dp[100001];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(i=3;i<=N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d",dp[N]);
}


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

using namespace std;

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

    string s, t;
    int ctr = 0;
    cin >> s >> t;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i])
            ctr++;
    }
    cout << ctr;

    return 0;
}


Measured memory_bytes: 3816
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();   
	  System.out.println(c);
      System.out.println(a);
      System.out.println(b);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int MAXN = 1e5+100;
int n,m,ans,rt;
vii segment;

int main (void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> m;
    segment.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> segment[i].fi >> segment[i].se;
        if (segment[i].fi > segment[i].se)
            swap(segment[i].fi, segment[i].se);
    }

    sort(segment.begin(), segment.end());
    for (ii p : segment) {
        if (rt <= p.fi) {
            ans++;
            rt = p.se;
        }
        rt = min(rt, p.se);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import scala.io.StdIn.readLine
 
object Main {
  def search(a:Array[Int],len:Int,value:Int) = {
    def scan(l:Int,r:Int):Boolean = {
      val mid = (l+r)/2
      if(a(mid) == value) true
      else if(l>=r) false
      else if(a(mid)<value) scan(mid+1,r)
      else scan(l,mid-1)
    }
    scan(0,len)
  }
 
  def main(args:Array[String]) = {
    readLine
    val s = readLine.split(" ").map(_.toInt)
    readLine
    val t = readLine.split(" ").map(_.toInt)
    val len = s.length-1
    println(t.count(i=> search(s,len,i) ))
  }
}

Measured memory_bytes: 71552
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';

int main() {
	int n,m;
	cin >> n;
	cin >> m;
	if (n == 1 && m == 2) cout << 3;
	if (n == 1 && m == 3) cout << 2;
	if (n == 2 && m == 3) cout << 1;
	if (n == 2 && m == 1) cout << 3;
	if (n == 3 && m == 2) cout << 1;
	if (n == 3 && m == 1) cout << 2;
	
	}

	

Measured memory_bytes: 256
function main(input) {
  let inputs = input.split(/\n/);
  let args = inputs[1].split(/\s/);
  let result = 0;
  for (let i = 0;i <= args.length;i++) {
    if (i % 2 === 0 && args[i] % 2 === 1) {
      result++;
    }
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    int N;
    cin >> N;

    string ans = "No";
    rep(i, 30) {
        rep(j, 30) {
            if(i * 4 + j * 7 == N) {
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3616
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    N = i2n()
    H = i2nn()
    n = 0
    for h in H:
        if n > h:
            print('No')
            return
        n = max(n, h-1)
    print('Yes')

main()


Measured memory_bytes: 59808