akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <set>

using namespace std;

int main() {
    // 展望台の数
    int n;
    // 展望台同士を結ぶ道の数
    int m;
    cin >> n >> m;

    // 各展望台の標高
    int h[n];
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    bool relation[n];
    for (int i = 0; i < n; ++i) {
        relation[i] = true;
    }

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        if (h[a] > h[b]) {
            relation[b] = false;
        } else if (h[a] < h[b]) {
            relation[a] = false;
        } else {
            relation[a] = relation[b] = false;
        }
    }

    int count = 0;

    for (int i = 0; i < n; ++i) {
        if (relation[i]) count++;
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll X, A;
    cin >> X >> A;

    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int i,t=0;
    char s[3];
    scanf("%s",s);
    for(i=0;i<3;i++)
    {
        if(s[i]=='o'||s[i]=='O')
            t=t+100;
    }
    t=t+700;
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll n;
    string s;
    cin  >> n >>  s;

    rep(i, n){
        rep(j, s.size()){
            if(s[j] == 'Z') s[j] = 'A';
            else s[j]++;
        }
    }

    cout << s << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

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

ll mod = 1000000007;

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

    string L;
    cin>>L;
    int n = L.size();
    vector<vector<ll>> dp(n, vector<ll>(2));
    dp[0][0] = 2;
    dp[0][1] = 1;
    rep(i, n - 1) {
        if (L[i + 1] == '0') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = (3 * dp[i][1]) % mod;
        }
        else {
            dp[i + 1][0] = (2 * dp[i][0]) % mod;
            dp[i + 1][1] = (dp[i][0] + 3 * dp[i][1]) % mod;
        }
    }
    cout<<(dp[n - 1][0] + dp[n - 1][1]) % mod<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (auto &i : d) {
		cin >> i;
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int person_number,item_number,person_have_item;
  cin >> person_number >> item_number;
  set<int> item_have_number;
  for (int i=0; i < item_number; i++){
    int item_number=0,habe_person=0;
    		cin >> item_number;
    for (int j=0;j < item_number; j++){
       		cin >> habe_person;
      		item_have_number.insert(habe_person);
      }
    }
  cout << (person_number - item_have_number.size() ) << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
#define INF 1000000000000000000LL

ll dp[1<<12];

int main() {
  rep(i,0,1<<12)dp[i] = INF;
  dp[0] = 0;
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll> > v;
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    ll c = 0;
    rep(j,0,b){
      ll d;
      cin>>d;
      d--;
      c |= 1<<d;
    }
    v.pb(mp(c,a));
  }
  sort(all(v));
  rep(i,0,1<<n){
    rep(j,0,v.sz){
      ll b = v[j].fi;
      ll c = v[j].se;
      dp[i|b]=min(dp[i|b],dp[i]+c);
    }
  }
  if(dp[(1<<n)-1]==INF){
    cout << -1 << endl;
  }
  else{
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a.at(i);
    int now = 1;
    rep(i,n){
        if(a[now-1] == 2){
            cout << i+1 << endl;
            return 0;
        }else{
            now = a[now-1];
        }
    }
    cout << -1 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  string S, T;
  int ans=0;
  cin >> S >> T;
  REP(i,3) {
    if(S.at(i) == T.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int c[3][3];
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      cin >> c[i][j];
    }
  }
  
  int x,y;
  bool chk = true;
  for(int i=0; i<3; i++) {
    if(i==0) {
      x = c[i][1]-c[i][0];
      y = c[i][2]-c[i][1];    
    }
    if(i>0) {
      if(x!=c[i][1]-c[i][0]) chk = false;
      if(y!=c[i][2]-c[i][1]) chk = false;    
    }
  }
  
  cout << ( chk ? "Yes" : "No" ) << endl; 
  return 0;
}

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

using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    vector<string> field(n);
    for(auto& v:field){
        cin >> v;
    }
    int ans = 0;
    for(int k=0; k<n; k++){
        bool ok = true;
        for(int i=0; i<n; i++){
            for(int j=1+i; j<n; j++){
                if(field[i][(j+k) % n] != field[j][(i+k) % n]){
                    ok = false;
                    break;
                }
            }
            if(!ok){
                break;
            }
        }
        if(ok){
            ans += n;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> vr(r);
    for(int i = 0; i < r; i++)
    {
        cin >> vr[i];
    }
    sort(vr.begin(), vr.end());
    vector<vector<int>> vp(n+1, vector<int>(n+1));
    int INF = 1e9;
    for(int i = 0; i < n+1; i++)
    {
        for(int j = 0; j < n+1; j++)
        {
            vp[i][j] = INF;
        }
    }
    for(int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        vp[a][b] = c;
        vp[b][a] = c;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                vp[j][k] = min(vp[j][k], vp[j][i] + vp[i][k]);
            }
        }
    }
    int ans = INF;
    do
    {
        int tmpans = 0;
        for(int i = 0; i < r-1; i++)
        {
            tmpans += vp[vr[i]][vr[i+1]];
        }
        ans = min(ans, tmpans);
    } while(next_permutation(vr.begin(), vr.end()));
    cout << ans << endl;
}


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

using namespace std;

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

int const MAXN = 2e5 + 10;

vi g[MAXN];
int dis[MAXN];
int visited[MAXN];
int const INF = 1e9;


int main(){
    int n;
    cin >> n;
    int a,b;
    for(int i=0;i<n-1;++i){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    fill(&dis[0],&dis[0] + MAXN,INF);
    queue<int> q;
    q.push(1);
    dis[1] = 0;
    int maxDis = 0;
    int maxNode = 0;
    while(!q.empty()){
        int node = q.front();
        q.pop();
        for(int i=0;i<g[node].size();++i){
            int next = g[node][i];
            if(dis[next]==INF) {
                dis[next] = dis[node] + 1;
                if(dis[next] > maxDis){
                    maxDis = dis[next];
                    maxNode = next;
                }
                q.push(next);
            }
        }
    }

    fill(&dis[0],&dis[0] + MAXN,INF);
    q.push(maxNode);
    dis[maxNode] = 0;
    maxDis = 0;
    while(!q.empty()){
        int node = q.front();
        q.pop();
        for(int i=0;i<g[node].size();++i){
            int next = g[node][i];
            if(dis[next]==INF) {
                dis[next] = dis[node] + 1;
                if(dis[next] > maxDis){
                    maxDis = dis[next];
                }
                q.push(next);
            }
        }
    }
    maxDis++;
    cout << ((maxDis%3==2) ? "Second" : "First") << endl;
}

Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
bool used[10];
bool check(int n){
	int x=n;
	if(n==0){
		return used[0]==0;
	}
	while(x!=0){
		if(used[x%10])return false;
		x/=10;
	}
	return true;
}
int main(){
	int n,k;
	cin>>n>>k;
	int p[k];
	for(int i=0;i<k;i++){
		cin>>p[i];
		used[p[i]]=1;
	}
	int i=n;
	while(!check(i))i++;
	cout<<i;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  long double q,h,s,d;
  ll n;
  cin>>q>>h>>s>>d>>n;
  long double Q=q*4;
  long double H=h*2;
  long double D=d/2;
  long double mi=min(Q,H);
  mi=min(mi,s);
  mi=min(mi,D);
  if(mi==D&&n%2==1){
    long double mi2=min(Q,H);
    mi2=min(mi2,s);
    ll a=(ll)(mi*(n-1)+mi2);
    cout<<a<<endl;
  }else{
    ll a=(ll)(mi*n);
    cout<<a<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> a(n);
  rep(i, n) {
    double p;
    cin >> p;
    a[i] = p / 2 + 0.5;
  }
  double sum = 0;
  double ans = 0;
  rep(j, k) sum += a[j];
  if (ans < sum) ans = sum;
  repi(i, 1, n - k + 1) {
    sum = sum - a[i - 1] + a[i + k - 1];
    if (ans < sum) ans = sum;
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x[114514];
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>x[i];
	ll ans=0;
	for(int i=1;i<n;i++){
		if((x[i]-x[i-1])*a<=b)ans+=(x[i]-x[i-1])*a;
		else ans+=b;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4368
import math
Q = int(input())
for i in range(Q):
  a, b = map(int, input().split())
  sqrt = int(math.sqrt(a * b))
  sqrt2 = sqrt + 1 if sqrt * (sqrt + 1) < a * b else sqrt
  sub = 1 if sqrt == max(a, b) or sqrt2 == min(a, b) or sqrt * sqrt2 == a * b else 0
  add = min(max(sqrt2 - min(a, b) - 1, 0), max(max(a, b) - sqrt - 1, 0))
  print(min(a, b) - 1 + sqrt + add - sub)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	
	if((x+r<=w)&&(y+r<=h)&&x>0&&y>0) 
	{
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
   return 0;
}

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

int a[200005];
int n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	bool solved = true;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] >= i || (i >= 2 && a[i] > a[i - 1] + 1)) {
			solved = false;
			break;
		}
		if (i >= 2) {
			if (a[i] == a[i - 1] + 1) {
				ans += 1;
			}
			else {
				ans += a[i];
			}
		}
	}
	if (solved) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int min_cost_bottomup(int*,int);
int min_cost_topdown(int*,int);

#define index(n) n-1

int main()
{
    int N;
    cin >> N;
    int *h;
    h = new int[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

    //cout << min_cost_bottomup(h,N) <<endl;
    cout << min_cost_topdown(h,N) << endl;

    return 0;
}

int min_cost_bottomup(int *h, int n)
{
    int *m;
    m = new int[n];
    m[0]=0;
    m[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        m[i] = min(m[i-2]+abs(h[i]-h[i-2]),m[i-1]+abs(h[i]-h[i-1]));
    }
    return m[n-1];
}

int min_cost_culc(int *m, int *h, int n)
{
    if(m[n-1]>=0){
        return m[n-1];
    }
    m[n-1] = min(min_cost_culc(m,h,n-1)+abs(h[n-1]-h[n-2]), min_cost_culc(m,h,n-2)+abs(h[n-1]-h[n-3]));
    return m[n-1];
}

int min_cost_topdown(int *h, int n)
{
    int *m;
    m = new int[n];
    m[0]=0;
    m[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        m[i]=-1;
    }
    return min_cost_culc(m,h,n);
}

Measured memory_bytes: 4992
using System;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var result = new int[4];
        for (int i = 0; i < N; i++)
        {
            var S = Console.ReadLine();
            switch (S)
            {
                case "AC":
                    result[0]++;
                    break;
                case "WA":
                    result[1]++;
                    break;
                case "TLE":
                    result[2]++;
                    break;
                case "RE":
                    result[3]++;
                    break;
            }
        }
        Console.WriteLine($"AC x {result[0]}");
        Console.WriteLine($"WA x {result[1]}");
        Console.WriteLine($"TLE x {result[2]}");
        Console.WriteLine($"RE x {result[3]}");
    }
}


Measured memory_bytes: 30524
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int ma = 0, ans = 0;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        ans += p;
        ma = max(ma, p);
    }

    cout << ans - ma / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n,m; cin >> n >> m;
    map<int,vector<int>> ab;
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        ab[a].push_back(b);
    }
    
    priority_queue<pii> pq;
    ll ans = 0;
    FOR(i,1,m+1) {
        for(auto x:ab[i]) pq.push({x,i});
        if (!pq.empty()) {
            ans += pq.top().first;
            pq.pop();
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  vector<ll> lb,ub;
  UnionFind(int n) : v(n, -1),lb(n,0),ub(n,0) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    maxch(lb[x],lb[y]);
    minch(ub[x],ub[y]);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int N,M;
string S;
ll U[30];
ll lb[30][2],ub[30][2],num[30];
ll res;

void dfs(ll a){
  if(a<10){
    if(U[a]<10){
      lb[a][0]=0; ub[a][0]=U[a];
      num[a]=1;
      dfs(a+1);
    }else{
      lb[a][0]=0; ub[a][0]=9;
      lb[a][1]=0; ub[a][1]=0;
      num[a]=1;
      dfs(a+1);
      if(U[a]>=20){
        lb[a][0]=0; ub[a][0]=9;
        lb[a][1]=1; ub[a][1]=(U[a]/10)-1;
        num[a]=2;
        dfs(a+1);
      }
      lb[a][1]=ub[a][1]=U[a]/10;
      lb[a][0]=0; ub[a][0]=U[a]%10;
      num[a]=2;
      dfs(a+1);
    }
    return ;
  }


  UnionFind uf(30);
  rep(i,30){
    if(i<10){
      uf.lb[i]=i; uf.ub[i]=i;
    }else{
      ll j=i-10;
      uf.lb[i]=lb[j%10][j/10]; uf.ub[i]=ub[j%10][j/10];
    }
  }

  ll L=0;
  rep(i,N){
    if(isdigit(S[i])) L++;
    else L+=num[S[i]-'a'];
  }
  vector<ll> A(L);

  ll crt=0;
  rep(i,N){
    if(isdigit(S[i])){
      A[crt]=S[i]-'0';
      crt++;
    }else{
      int c=S[i]-'a';
      if(num[c]==1)A[crt]=c+10;
      else{
        A[crt]=c+20; A[crt+1]=c+10;
      }
      crt+=num[c];
    }
  }

  rep(i,L){
    assert(L-1-i>=0);
    assert(L-1-i<L);
    assert(A[i]>=0&&A[i]<30);
    uf.unite(A[i],A[L-1-i]);
  }

  vector<bool> done(31,false);
  ll cnt=1;
  rep(i,30){
    if(done[uf.find(i)])continue;
    done[uf.find(i)]=true;
    (cnt*=max(0LL,uf.ub[uf.find(i)]-uf.lb[uf.find(i)]+1))%=mod;
  }

  (res+=cnt)%=mod;
}

int main(){
  cin>>N>>M>>S;
  rep(i,M){
    char c;
    ll u;
    cin>>c>>u;
    c-='a';
    U[c]=u;
  }
  dfs(0);
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3184
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
char a;

int main(){
  cin >> a;
  if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;
int N,K,S,T,U,i;
vector<int>A;
long c[51][51],P[51],a,w;
main()
{
	for(cin>>N>>K>>S>>T;cin>>a;)if(!(~a&S|a&~T))A.push_back(a);
	for(;i<=N;i++)
	{
		c[i][a=0]=1;
		for(int j=0;j++<K;)P[i]+=c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	for(;U<1<<18;w=!++U)
	{
		map<int,int>M;
		for(int v:A)M[v&U]++;
		for(auto p:M)w+=P[p.second];
		if(!(~U&S|U&~T))a+=__builtin_parity(U&~S)?-w:w;
	}
	cout<<a;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

string S;

string solve(int N) {
    VI ks(N);
    rep(i, N) cin >> ks[i];
    string s;
    cin >> s;

    string ans(s);

    int M = S.size();

    rep(i, s.size()) {
        int p = i % (int)ks.size();
        int pos = find(ALL(S), s[i]) - S.begin();
        int pos2 = (pos - ks[p] + M) % M;
        ans[i] = S[pos2];
    }
    
    return ans;
}

int main(void) {
    rep(i, 26) S += 'a' + i;
    rep(i, 26) S += 'A' + i;

    int N;
    while (cin >> N, N) cout << solve(N) << endl;

    return 0;
}

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

int main()
{
   int A;
   int B;
   int Ans1;
   int Ans2;
   cin >> A;
   cin >> B;
   Ans1 = A*B;
   Ans2 = A*2+B*2;
   cout << Ans1 << " " << Ans2 << endl; 
   
   return 0;
}


Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==1&&b==2)
    cout<<"3";
  else if(a==1&&b==3)
    cout<<"2";
  else if(a==2&&b==1)
    cout<<"3";
  else if(a==2&&b==3)
    cout<<"1";
  else if(a==3&&b==1)
    cout<<"2";
  else
    cout<<"1";
   return 0;
}  
 

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {

        static long k;

        static long Kaijo(long s, long N)
        {

            for (int i = 2; i <= N; i++)
            {
                s *= i;
                if (s >= k)
                {
                    s %= k;
                }
            }

            return s;
        }
        
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);

            long ans = 1;
            k = (long)Math.Pow(10, 9) + 7;

            if(N == M)
            {

                ans = Kaijo(ans, N);

                ans = Kaijo(ans, N);

                ans *= 2;

                if(ans >= k)
                {
                    ans %= k;
                }

            }
            else if(N + 1 == M || N == M + 1)
            {

                ans = Kaijo(ans, N);

                ans = Kaijo(ans, M);
               
            }           
            else
            {
                Console.WriteLine("0");
                return;
            }

            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>

int main(void)
{
	using namespace std;
	int student[51][3];
	char grade[50];
	int i, j, score;
	for(i = 0; i < 51; i++)
	{
		cin >> student[i][0] >> student[i][1] >> student[i][2];
		if(student[i][0] == -1 && student[i][1] == -1 && student[i][2] == -1)
			break;
		score = student[i][0] + student[i][1];
		if(student[i][0] == -1 || student[i][1] == -1)
			grade[i] = 'F';
		else if(score >= 80)
			grade[i] = 'A';
		else if(score >= 65)
			grade[i] = 'B';
		else if(score >= 50)
			grade[i] = 'C';
		else if(score >= 30)
			{
				if(student[i][2] >= 50)
					grade[i] = 'C';
				else 
					grade[i] = 'D';
			}
		else
			grade[i] = 'F';
	}
	for(j = 0; j < i; j++)
	{
		cout << grade[j] << endl;
	}
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {

    int n; cin >> n;
    vector<int> as(n, 0);
    vector<int> dup(1000001, 0);    
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        dup[as[i]]++;
    }
    sort(as.begin(), as.end());
    int ans = 0;
    if (as[0] == 1) {
        if (n >= 2 && as[1] == 1) {
            ans = 0;
        } else {
            ans = 1;
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> visit(1000001, 0);
    for (int i = 0; i < (int)as.size(); i++) {
        int val = as[i];
        if (dup[val] < 2 && visit[val] == 0) {
            ans++;
        }
        for (int j = 1; ; j++) {
            int next = val * j;
            if (next > 1000000) {
                break;
            }
            visit[next] = 1;
        }
    }
    cout << ans << endl;
  
    return 0;
}

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

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

  for(int i = 1; i <= 9; i++){
    if(N <= 111 * i){
      cout << 111 * i << endl; 
      return 0;
    }
  }

  return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i,a,b) for (int i=a; i<(b); i++)
#define FOR(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b); i >= a; i--)
#define FORd(i,a) for (int i = (a); i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

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

    ll n;
    cin>>n;
    vl a(n);
    vl b(n);
    vl c(n);
    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    FOR(i,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1; i<n; i++)

    {
        for(int j=0; j<3; j++)
        {
            if(j==0)
            {
                dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i];
            }
            if(j==1)
            {
                dp[i][j]=max(dp[i-1][0],dp[i-1][2])+b[i];
            }
            if(j==2)
            {
                dp[i][j]=max(dp[i-1][1],dp[i-1][0])+c[i];
            }
        }
    }


  cout<<max(max(dp[n-1][0],dp[n-1][2]),dp[n-1][1]);


    return 0;
}


Measured memory_bytes: 7928
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
using namespace std;

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

long long mod = 1000000007;
long long N, A[1 << 18], B[1 << 18], power[1 << 18];
map<pair<long long, long long>, int> Map, V;

void init() {
	power[0] = 1;
	for (int i = 1; i <= 250000; i++) power[i] = (2LL * power[i - 1]) % mod;
}

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

	int addi = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
		if (A[i] == 0 && B[i] == 0) { addi++; continue; }
		if (A[i] == 0) {
			A[i] = 0; B[i] = 1;
		}
		else if (B[i] == 0) {
			A[i] = 1; B[i] = 0;
		}
		else {
			long long v = gcd(abs(A[i]), abs(B[i]));
			A[i] /= v; B[i] /= v;
			if (A[i] < 0) { A[i] *= -1LL; B[i] *= -1LL; }
		}
		Map[make_pair(A[i], B[i])] += 1;
	}

	long long sum = 1;
	for (int i = 1; i <= N; i++) {
		if (V[make_pair(A[i], B[i])] == 1) continue;
		if (A[i] == 0 && B[i] == 0) continue;

		long long r1 = B[i], r2 = -A[i];
		if (r1 < 0) { r1 *= -1LL; r2 *= -1LL; }
		if (r1 == 0 && r2 < 0) { r1 *= -1LL; r2 *= -1LL; }

		long long c1 = Map[make_pair(A[i], B[i])];
		long long c2 = Map[make_pair(r1, r2)];
		sum *= (power[c1] + power[c2] - 1LL + mod) % mod;
		sum %= mod;
		V[make_pair(A[i], B[i])] = 1;
		V[make_pair(r1, r2)] = 1;
	}
	sum += addi;

	cout << (sum + mod - 1LL) % mod << endl;
	return 0;
}

Measured memory_bytes: 58636
import bisect
N,M = map(int,input().split())
l = [0]*M
for i in range(M):
     l[i] = list(map(int,input().split()))
l.sort()
a = [0]*M
b = [0]*M
for i in range(M):
    a[i] = l[i][0]
    b[i] = -l[i][1]
ans = 0
while len(a)>0:
    min = -max(b)
    i = bisect.bisect(a,min-1)
    a = a[i:]
    b = b[i:]
    ans += 1
print(ans)


Measured memory_bytes: 33020
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

long long now,D,H,a,p,t,A,T,x[101],y[101],h[101],num, N, K, M, ans;
string S;
bool xy[100][100][100];
char cc;


int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) {
			p = i;
		}
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			now = abs(i - x[p]) + abs(j - y[p]);
			H = now + h[p];

			for (int k = 0; k <N; k++) {
				A = abs(i - x[k]) + abs(j - y[k]);
				if (h[k] != 0) {
					if (H - A != h[k]) {
						break;
					}
				}
				else {
					if (H > A) {
						break;
					}
				}
				if (k == N - 1) {
					cout << i <<" "<< j <<" "<< H<<endl;
					return 0;
				}
			}


		}
	}

	
}

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


// Useful container manipulation / traversal macros
#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(a,b)       ( (b).find(a) != (b).end())
#define tr(c,i)       for(auto i = (c).begin(); i != (c).end(); i++)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb             push_back
#define fill(a,v)      memset(a, v, sizeof a)

typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    int n, m;
    cin>>n>>m;

    int a[m+1];

    fori(i, 1, m)
    cin>>a[i];


    if(n >= m){
        cout<<0;
    } else {
        sort(a+1, a+m+1);
        vi diff;

        fori(i, 1, m-1){
            diff.pb(abs(a[i]-a[i+1]));
        }

        int sum = 0;
        sort(diff.begin(), diff.end());

        fori(i, 0, m-n-1)
            sum += diff[i];
        cout<<sum;
    }

}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

int n, k;
vector<vector<int>> t(7, vector<int>(7, 0));
bool ng=false;

void dfs(int cnt, int val){
    if(cnt==n){
        if(val==0) ng=true;
        return;
    }

    rep(i, k) dfs(cnt+1, val^t[cnt][i]);
}


int main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n+1, 0);
    int minv=1e7, maxv=-1e7;
    int Mid, mid;
    repr(i, 1, n+1){
        cin >> a[i];
        if(minv > a[i]) { minv = a[i]; mid = i; }
        if(maxv < a[i]) { maxv = a[i]; Mid = i; }
    }

    auto print = [](auto x, auto y) { cout << x << " " << y << endl; };

    if(minv>=0) { cout << n-1 << endl; repr(i, 1, n) print(i, i+1); }
    else if(maxv<=0) { cout << n-1 << endl; reprrev(i, 2, n+1) print(i, i-1); }
    else if(abs(maxv) >= abs(minv)){
        cout << 2*n-2 << endl;
        repr(i, 1, n+1){
            if(i == Mid) continue;
            print(Mid, i);
        }
        repr(i, 1, n) print(i, i+1);
    }
    else{
        cout << 2*n - 2 << endl;
        repr(i, 1, n+1){
            if(i == mid) continue;
            print(mid, i);
        }
        reprrev(i, 2, n+1) print(i, i-1);
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 

int main(){
    int N;
    scanf("%d",&N);
    float T,A;
    scanf("%f %f",&T,&A);
    float H[N];
    int i;
    for(i=0;i<N;i++){
        scanf("%f",&H[i]);
    }
    int num=0;
    float x,tmp,ans=10000000000000;
    for(i=0;i<N;i++){
        tmp = T - H[i]*0.006;
        if(fabs(A-ans)>fabs(A-tmp)){
            ans = tmp;
            num = i+1;
        }
    }

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

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
s = sum(a)

r = 0
l = 0
k = 0
for i in range(len(a)):
    k = i
    if l+a[i] > s//2:break
    l += a[i]
r = s - a[k] - l

print(min(max(l+a[k],r)-min(l+a[k],r),max(l,r+a[k])-min(l,r+a[k])))

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

typedef long long int lli;

lli nlist[50];

int main(){
  int N;
  nlist[0]=nlist[1]=1;
  for(int i=2;i<50;i++) nlist[i]=nlist[i-1]+nlist[i-2];
  cin>>N;
  cout<<nlist[N]<<endl;
  return 0;
}

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

using namespace std;

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

    vector<int> a(N);

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

    int res = 0;
    for (int i = 0; i < N; i+= 2) {
        if (a[i] % 2 != 0) {
            res ++;
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vs grid(h);
    rep(i, h) cin >> grid[i];
    vvi sml(h, vi(w, 0));
    vvi smr(h, vi(w, 0));
    vvi smu(h, vi(w, 0));
    vvi smd(h, vi(w, 0));
    rep(i, h) {
        rep(j, w) {
            if (j == 0) sml[i][j] = (grid[i][j] == '.');
            else if (grid[i][j] == '.') sml[i][j] = sml[i][j-1] + 1;
            else sml[i][j] = 0;
        }
    }
    rep(i, h) {
        for (int j = w-1; j >= 0; --j) {
            if (j == w-1) smr[i][j] = (grid[i][j] == '.');
            else if (grid[i][j] == '.') smr[i][j] = smr[i][j+1] + 1;
            else smr[i][j] = 0;
        }
    }
    rep(j, w) {
        rep(i, h) {
            if (i == 0) smu[i][j] = (grid[i][j] == '.');
            else if (grid[i][j] == '.') smu[i][j] = smu[i-1][j] + 1;
            else smu[i][j] = 0;
        }
    }
    rep(j, w) {
        for (int i = h-1; i >= 0; --i) {
            if (i == h-1) smd[i][j] = (grid[i][j] == '.');
            else if (grid[i][j] == '.') smd[i][j] = smd[i+1][j] + 1;
            else smd[i][j] = 0;
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) if (grid[i][j] == '.') chmax(ans, sml[i][j] + smr[i][j] + smd[i][j] + smu[i][j] - 3);
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int N;
	set<int> l;
	int legend = 0;

	cin >> N;
	for(int i = 0 ; i < N ; ++i) {
		int c;
		cin >> c;
		if(c >= 3200) {
			++legend;
		} else {
			l.insert(c / 400);
		}
	}

	cout << (l.empty() ? 1 : l.size()) << " " << (l.size() + legend) << endl;
}


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

int main() {
    int n;
    cin >> n;
    list<int> ans;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (n % 2 != i % 2) ans.push_front(a); else ans.push_back(a);
    }
    for (auto& e : ans) cout << e << " ";
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <stdlib.h>
 
int main(){
 
	int S,W;
  	if(scanf("%d%d",&S,&W) < 2) {
    	fprintf(stderr, "error: ill-formed fraction.\n");
    	exit(1);
	}
  
	if(S > W){
    	printf("safe");
    } else {
    	printf("unsafe");
    }
  	return 0;
}

Measured memory_bytes: 1684
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int arr[200005];
ll sum_0[200005], sum_1[200005], sum_2[200005], sum[200005];
int main()
{
	// freopen("yahoo2019-D.in", "r", stdin);
	// freopen("yahoo2019-D.out", "wt", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		sum_0[i] = (i ? sum_0[i - 1] : 0) + arr[i];
		sum_1[i] = (i ? sum_1[i - 1] : 0) + (arr[i] & 1 ^ 1);
		sum_2[i] = (i ? sum_2[i - 1] : 0) + (arr[i] & 1) + (!arr[i] ? 2 : 0);
	}
	ll mn = 0, ans = sum_0[n - 1];
	for (int i = 0; i < n; i++)
	{
		sum[i] = -(i ? sum_1[i - 1] : 0) + (i ? sum_2[i - 1] : 0) + mn;
		mn = std::min(mn, sum_0[i] - sum_2[i]);
		sum[i] = std::min(sum[i], i ? sum[i - 1] : 0ll);
	}
	mn = 1e18;
	for (int i = n - 1; i >= 0; i--)
	{
		mn = std::min(mn, sum_2[i] - sum_0[i]);
		ll val = sum_1[i] + sum_0[n - 1] - sum_2[i] + mn;
		ans = std::min(ans, sum[i] + val);
	}
	mn = 0;
	for (int i = 0; i < n; i++)
	{
		ans = std::min(ans, sum_0[n - 1] - sum_0[i] + sum_2[i] + mn);
		mn = std::min(mn, -sum_2[i] + sum_0[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double Hat=0;
  double Mat=0;
  double deg=0;

  Hat=(30.0*H)+(0.5*M);
  Mat=6.0*M;

  deg=max(Hat, Mat)-min(Hat, Mat);
  cout << setprecision(21) << sqrt((A*A)+(B*B)-(2.0*A*B*cos(deg*(M_PI/180.0)))) << endl;
 
return 0;
}

Measured memory_bytes: 4200
double X[1010],Y[1010],R[1010],D[1010][1010],d;
j,k,N;main(i){
	scanf("%lf%lf%lf%lf%d",X,Y,X+1,Y+1,&N);N+=2;
	for(;++i<N;)scanf("%lf%lf%lf",X+i,Y+i,R+i);
	for(i=0;i<N;i++)for(j=i;j<N;j++)D[i][j]=D[j][i]=(d=hypot(X[i]-X[j],Y[i]-Y[j])-R[i]-R[j])>0?d:0;
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)if(D[i][j]>(d=D[i][k]+D[k][j]))D[i][j]=d;
	printf("%.9f\n",D[0][1]);
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll a, b, x;
  cin >> a >> b;
  x = ceil(max(a / 0.08, b / 0.10));
  if (x < min((a + 1) / 0.08, (b + 1) / 0.10))
	cout << x <<  endl;
  else
	cout << -1 << endl;
}

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

using namespace std;
#define ll long long int
int main()
{
  ll a,b;
  cin>>a>>b;
  ll x1,x2;
  x1=12.5*a;
  x2=10*a;
  ll max;
  max=x1>x2?x1:x2;
  ll flag=0;


  for( ll k=max;k<=max+13;k++){



  if((a==(k*8)/100)&&(b==(k*10)/100)) {
    cout<<k;
  flag=1;
    break;
  }
}


     if(!flag) cout<<"-1";


  return 0;

     }


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


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

  for(int i=0;i<X;i++){  bool prime=true;
   for(int j=2;j<X+i;j++){
     if((X+i)%j==0){
       prime=false;break;
     }
     
    
   } if(prime){cout<<X+i<<endl;break;}
    if(prime){break;}
  }
  
}

Measured memory_bytes: 256