akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int n,m; //n:ID,m:gate
    cin >> n >> m;
    P gate;
    P range; //first:min,last:max;
    range.first = 1; range.second = n;
    //cout << "range " << range.first << " " << range.second << endl;
    rep(i,m){
        cin >> gate.first >> gate.second;
        //cout << "gate " << gate.first << " " << gate.second << endl;
        if(range.first <= gate.first) range.first = gate.first;
        if(range.second >= gate.second) range.second = gate.second;
        if(range.second < range.first){
            cout << 0 << endl;
            return 0;
        }
        //cout << "range " << range.first << " " << range.second << endl;
    }
    
    
    int  ans = range.second - range.first + 1;
    cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())

def solve():
    if N == 1:
        print(0)
        return 0
    
    ans = 0
    lst = factorization(N)
    for ps in lst:
        es = ps[1]

        tmp = 1
        while es >= tmp:
            es -= tmp
            ans += 1
            tmp += 1
    
    print(ans)
    return 0




solve()

Measured memory_bytes: 9492
import sys
n,m=map(int,input().split())
a=set(map(int,sys.stdin))
dp=[0]*(n+1)
dp[0]=1
if 1 not in a:dp[1]=1
for i in range(2,n+1):
    if i in a:continue
    if dp[i-1]==dp[i-2]==0:break
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[-1])

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

int main(){
    int N;
    cin >> N;
    map<int, int> cnt_map;//素数、約数の個数
    //iが数、jが約数,cnt_mapに約数とその個数が確保される
    for(int i=2; i<=N; i++){
        int tmp=i;
        for(int j=2; j<=i; j++){
            while(tmp%j == 0){
                cnt_map[j]++;
                tmp /= j;
            }
            //cout << cnt_map[2] << endl;
        }
    }
    long long pro=1, devide = ((long long)pow(10, 9) + 7);
    for(int i=2; i<=N; i++){
        pro *= (cnt_map[i] + 1);
        while(pro >= devide){
            pro -= devide;
        }
    }
    //long long result = pro % ((long long)pow(10, 9) + 7);
    cout << pro << endl;
}

Measured memory_bytes: 256
import sys

N = int(input())
place_info_list = list()

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    place_info_list.append({
        't': t,
        'x': x,
        'y': y,
    })

place_info_list.sort(key=lambda place: place["t"])

current_place_info = {
    't': 0,
    'x': 0,
    'y': 0,
}

for place_info in place_info_list:
    distance = abs(place_info['x'] - current_place_info['x']) +\
               abs(place_info['y'] - current_place_info['y']) 
    necessary_time = distance / 1.0
    remained_time = place_info['t'] - current_place_info['t']

    if remained_time < necessary_time:
        print("No")
        sys.exit()

    if (remained_time - necessary_time) % 2 == 1:
        print("No")
        sys.exit()
    
    current_place_info['t'] = place_info['t']
    current_place_info['x'] = place_info['x']
    current_place_info['y'] = place_info['y']

print("Yes")


Measured memory_bytes: 40788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// 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;
//     }
// }

int main(){
    ll a, b; cin >> a >> b;
    if((a+b)%2 == 0) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int X = s.nextInt();
        int T = s.nextInt();

        int a = N%X == 0 ? 0 : T;

        System.out.println((N / X) * T + a);
    }
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3e3+2;
int N, M, dp[MAXN][MAXN];
string s, t, ans;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> s >> t;
	N = s.size(); M = t.size();
	for(int i = 1;i<=N;i++){
		for(int j = 1;j<=M;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			}else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	int r = N, c = M;
	while(r>0&&c>0){
		if(dp[r][c]==dp[r-1][c]){
			r--;
		}else if(dp[r][c]==dp[r][c-1]){
			c--;
		}else{
			ans+=s[r-1];
			r--; c--;
		}
	}
	for(int i = ans.size()-1;i>=0;i--)cout << ans[i];
	cout << '\n';
	return 0;
}

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

int main()
{
	
	
	
	int T,i,j,s,n;
	
	
	{
		int mn,mx,cnt=0;
		cin>>mn>>mx;

		string str1,str2;

		for(int i=mn;i<=mx;i++)
		{
			str1=to_string(i);
			str2=str1;
			reverse(begin(str2),end(str2));
			if(str2==str1)
				cnt++;
		}
		cout<<cnt<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mod 1000000007LL
#define lowbit(x) ((x)&(-(x)))

pii h[200010];

int num[200010],cnt[200010],c[200010],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

const ll inv2=ksm(2,mod-2);

inline void add(int x) { for (;x<=n;x+=lowbit(x)) c[x]++; }

inline int getsum(int x)
{
	int res=0;
	for (;x;x-=lowbit(x)) res+=c[x];
	return res;
}

ll sum[800010],tag[800010];

inline void gao(const int &o,const ll &hh) { sum[o]=sum[o]*hh%mod;tag[o]=tag[o]*hh%mod; }

inline void pushup(const int &o) { sum[o]=pls(sum[o<<1],sum[o<<1|1]); }

inline void pushdown(const int &o)
{
	if (tag[o]==1) return;
	gao(o<<1,tag[o]);gao(o<<1|1,tag[o]);
	tag[o]=1;
}

inline void build(int o,int l,int r)
{
	sum[o]=0;tag[o]=1;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(o<<1,l,mid);
	build(o<<1|1,mid+1,r);
}

inline void modify(int o,int l,int r,int x,ll y)
{
	if (l==r) { sum[o]=y;return; }
	pushdown(o);
	int mid=(l+r)>>1;
	if (x<=mid) modify(o<<1,l,mid,x,y);
	else modify(o<<1|1,mid+1,r,x,y);
	pushup(o);
}

inline ll query(int o,int l,int r,int x,int y)
{
	if (l>=x&&r<=y) return sum[o];
	pushdown(o);
	int mid=(l+r)>>1;ll res=0;
	if (x<=mid) res=pls(res,query(o<<1,l,mid,x,y));
	if (y>mid) res=pls(res,query(o<<1|1,mid+1,r,x,y));
	return res;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	for (int i=1;i<=n;i++) cnt[num[i]]++;
	for (int i=n-1;i;i--) cnt[i]+=cnt[i+1];
	ll all=1;
	for (int i=n;i;i--) all=all*(cnt[i]-n+i)%mod;
	if (!all) { puts("0");return 0; }
	for (int i=1;i<=n;i++) h[i]=pii(num[i],i);
	sort(h+1,h+n+1);
	build(1,1,n);
	ll ans=0;int lst=n;
	for (int i=n;i;i--)
	{
		int x=h[i].first,id=h[i].second;
		ans=pls(ans,getsum(id-1)*all%mod);
		if (i<n) for (;lst>x;lst--) gao(1,ksm(cnt[lst]-n+lst,mod-2)%mod*(cnt[lst]-n+lst-1)%mod);
		if (id>1) ans=mns(ans,query(1,1,n,1,id-1)*inv2%mod);
		if (id<n) ans=pls(ans,query(1,1,n,id+1,n)*inv2%mod);
		modify(1,1,n,id,all);add(id);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int x;
    cin >> x;
    if(x / 100 <= 12 && x / 100 >= 1 && x % 100 > 0 && x % 100 <= 12 && x % 100 >= 1) 
       cout << "AMBIGUOUS" << endl;
    else if(x / 100 <= 12 && x / 100 >= 1 ){
        cout << "MMYY" << endl;
    }
    else if(x % 100 <= 12 && x % 100 >= 1){
        cout << "YYMM" << endl;
    }
    else
        cout << "NA" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};
int ac[100006], pe[100006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int p; cin >> p;
		string s; cin >> s;
		if (!ac[p]) {
			if (s == "AC")ac[p]++;
			else pe[p]++;
		}
	}
	int A = 0, P = 0;
	rep(i, n + 1)if(ac[i])A += ac[i], P += pe[i];
	cout << A << ' ' << P << endl;
}


Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,M=map(int,input().split())
x=tuple(map(int,input().split()))
y=tuple(map(int,input().split()))
ans=1
tmp=0
for i in range(N):
    tmp+=x[i]*(i-(N-1-i))
    tmp%=MOD
ans*=tmp
tmp=0
for i in range(M):
    tmp+=y[i]*(i-(M-1-i))
    tmp%=MOD
ans*=tmp
ans%=MOD
print(ans)

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var h = r1[0].ToLong();
            var n = r1[1].ToLong();
            var dmg = new long[n];
            var mp = new long[n];
            var dp = new long[20100];
            var INF = 9999999999;
            for (int i = 0; i < n; i++)
            {
                var r2 = ReadSplit();
                dmg[i] = r2[0].ToLong();
                mp[i] = r2[1].ToLong();
            }

            for (int i = 0; i < 20100; i++)
            {
                dp[i] = INF;
            }
            dp[0] = 0;
            for (int i = 0; i < 20100; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i - dmg[j] >= 0)
                    {
                        ChangeMin(ref dp[i], dp[i - dmg[j]] + mp[j]);
                    }
                }
            }
            long ans = INF;
            for (long i = h; i < 20100; i++)
            {
                for (long j = 0; j < n; j++)
                {
                    if (ans >= dp[i]) ans = dp[i];
                }
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 17340
import sys
readline = sys.stdin.readline
n, k = map(int, input().split())
v = [int(readline()) for _ in range(n)]
lo = max(v) - 1
hi = int(1e10)
while hi - lo > 1:
    p = P = (lo + hi) // 2
    m = 1
    for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
    if m <= k:
        hi = P
    else:
        lo = P
print(hi)



Measured memory_bytes: 9576
k,s = map(int,input().split())
k=k+1
count=0
for i in range(k):
    for j in range(k):
        if i+j > s:
            break
        m = s - (i+j)
        if m >= 0 and m < k:
            count = count+1
        #print(i," ",j," ",m)

print(count)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
T getSum(std::vector<T>& v) {
	T ret = 0;
	for (T& x : v) ret += x;
	return ret;
}

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	int R, B;
	R = B = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') R++;
		else B++;
	}

	Yn(R > B);

	return 0;
}

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

int numOfPages; 

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

    int numOfSheets = numOfPages / 2;

    if (numOfPages%2 == 1) {
        numOfSheets++; 
    } 

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

    return 0;
}

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

using namespace std;

void solve(){
    string str;
    cin >> str;
    sort(begin(str), end(str));
    if(str[0] == str[1] && str[2] == str[3] && str[0] != str[3]){
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
    ll n , y; cin >> n>> y;
    ll x=-1, yy=-1, z=-1;
    REP(i,n+1){
        REP(j,n+1){
            if((y-i*10000-j*5000)/1000 == n-i-j && n-i-j>=0){
                x=i;
                yy=j;
                z=n-i-j;
                break;
            }
        }
        if(x!=-1) break;
    }
    cout << x << " " << yy << " " << z << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll a[N];
bool cmp(ll x,ll y){
	return x>y;
}
int main(){
	int n;
	scanf("%d",&n);
	ll ans=0;
	
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1,cmp);
	int cnt=0;
	while(++cnt<=n){
		if(cnt==1) continue;
		if(cnt==2) ans+=a[1];
		if(cnt>=3) ans+=a[(cnt+1)/2];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n, m;
    cin >> n >> m;
    bool isout = false;
    vector<int> vs(n, -1);
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if (vs[s] >= 0 && vs[s] != c) isout = true; 
        else vs[s] = c;
    } 
    if (n > 1 && vs[0] == 0) isout = true; 
    if (isout) {
        cout << -1 << endl; 
        return 0;
    }
    int ret = 0;
    int keta = 1; 
    rep(i, n) {
        int idx = n-i-1;
        // cout << vs[idx] << endl;
        if (n > 1 && idx == 0) {
            ret += keta * max(vs[idx], 1); 
        } else {
            ret += keta * max(vs[idx], 0); 
        }
        keta *= 10;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_a

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

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, ans = 0;
    cin >> a >> b;
    for (int i = 0; i < 2; i++) {
        if (a > b) {
            ans += a;
            a--;
        } else {
            ans += b;
            b--;
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int r,d,x;
void cal(int a){
    cout<<r*a-d<<endl;
    x=r*a-d;
}

int main(){
    cin>>r>>d>>x;
    rep(i,10){
        cal(x);
    }

    return 0;
}

Measured memory_bytes: 256
word_list = ("dream", "dreamer", "erase", "eraser")

s = input()

i = 0
while i < len(s):
    if s[i:i+11] == "dreameraser":
        i += 11
    elif s[i:i+10] == "dreamerase":
        i += 10
    elif s[i:i+7] == word_list[1]:
        i += 7
    elif s[i:i+6] == word_list[3]:
        i += 6
    elif s[i:i+5] == word_list[0] or s[i:i+5] == word_list[2]:
        i += 5
    else:
        print("NO")
        exit()

print("YES")


Measured memory_bytes: 3188
from operator import itemgetter
n = int(input())
dic = {}
num = {}
dd = []
for i in range(n):
    data = input().split()
    a = str(data[0])
    b = str(data[1])
    y = a+b
    num[y] = i+1
    data[1] = int(data[1])
    dd.append(data)
dd = sorted(dd,key=lambda x:(x[0],x[1]),reverse = True)
x = sorted(dd,key = itemgetter(1),reverse=True)
x = sorted(x,key = itemgetter(0))

aa = []
for i in range(n):
    ans = str(x[i][0]) +str(x[i][1])
    aa.append(ans)

for i in range(n):
    print(num[aa[i]])

"""
for i in range(n):
    data = input().split()
    num.append(data[1])
    dic[i+1]= data[0]
    
dic = sorted(dic.items(),key = lambda x:x[1])
print(dic)
for i in range(n):

"""




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long inf=1e9+7;
int n,m;
int father[200005];
int find(int x){//找老大 
	if(father[x]==x){
		return x;
	}
	return father[x]=find(father[x]);
}
void unite(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy){
		father[fx]=fy;
	}
}
int siz[200005];
int main(){
	cin>>n>>m;
	int u,v;
	for(int i=0;i<200005;i++)father[i]=i; 
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		unite(u,v);
	}
	for(int i=1;i<=n;i++){
		siz[find(i)]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,siz[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10552
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = input[0]

  if (N[0] === '9' || N[1] === '9') {
    console.log('Yes')
  } else {
    console.log('No')
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29492
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int a,b,c;
  cin>>a>>b>>c;
  cout << max(0,c-(a-b)) << endl;
  return 0;
}


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

int N;

int64_t max_monster(vector<int> &A, vector<int> &B) {
    int64_t sum = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= B[i]) {
            sum += (int64_t)B[i];
        } else if (A[i] + A[i + 1] >= B[i]) {
            A[i + 1] -= B[i] - A[i];
            sum += (int64_t)B[i];
        } else {
            sum += (int64_t)A[i] + A[i + 1];
            A[i + 1] = 0;
        }
    }

    return sum;
}

int main() {
    //input
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    for (int i = 0; i < N + 1; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }

    int64_t ans = max_monster(A, B);

    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
S = input()
 
ans = 0
for n in range(N): 
    if n!=0 and S[n]=='L' and S[n-1]=='L':
        ans += 1
    if n!=N-1 and S[n]=='R' and S[n+1]=='R':
        ans += 1
ans = min(ans+2*K, N-1)

print(ans)

Measured memory_bytes: 3316
#include<stdio.h>

char s[200001];

int main(int argc, char const *argv[]){
	long n,k,d,f,i,c;
	scanf("%ld %ld",&n,&k);
	getchar();
	scanf("%s",s);
	d=0;
	c=0;
	while(d<n && c<k){
		if(s[d]==((d%2==0)?'B':'A')){
			c++;
		}else c+=2;
		d++;
	}
	if(c==k){
		f=0;
	}else if(c>k){
		d--;
		if(s[d]==((d%2==0)?'B':'A')){
			f=0;
		}else f=1;
	}else{
		f=2;
	}
	if(f==2){
		for(i=n-1;i>=0;i--){
			s[i]=((s[i+1]=='A')?'B':'A');
		}
		if(s[0]=='A' && (k-c)%2==1) s[0]='B';
	}else{
		for(i=0;i<n-d;i++){
			if(d%2==1){
				s[i]=((s[i+d]=='A')?'B':'A');
			}else s[i]=s[i+d];
		}
		for(i=n-1;i>=n-d;i--){
			s[i]=((s[i+1]=='A')?'B':'A');
		}
		if(f==1){
			s[0]='B';
		}
	}
	printf("%s\n",s);
	return 0;
}

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

using namespace std;
typedef long long ll;
int N, K;
ll a[100001];
ll sum_a [100001];
ll b[100001];
ll sum_b [100001];

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

  for(int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = max(0ll,a[i]);
  }
  for(int i = 1; i <= N; i++) {
    sum_a[i] = sum_a[i-1] + a[i-1];
    sum_b[i] = sum_b[i-1] + b[i-1];
  }

  ll ans = 0;

  for(int i = 0; i + K <= N; i++) {
    ans = max(ans,max(0LL,sum_a[i+K]-sum_a[i]) + sum_b[i] + sum_b[N] - sum_b[i+K]);
  }
  cout << ans <<endl;
}


 


Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
#include <stdio.h>
#include<cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}


int main() {
  string s; cin >> s;
  deque<ll> d; rep(i, s.size()) d.push_back(s[i]);
  ll q; cin >> q;
  bool f = 0;
  rep(_, q) {
    ll type; cin >> type;
    if(type == 1) {
      f ^= 1;
    } else {
      ll b; char c; cin >> b >> c; b--;
      if((f ^ b) == 0) {
        d.push_front(c);
      } else
      {
        d.push_back(c);
      }
    }
  }
  if (f) reverse(d.begin(), d.end());
  string ret; for(auto x: d) ret += (char)x; cout << ret << endl;
  return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long S, long long W){
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

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

    for(int i=1;i<10;i++){
        if(N%i==0 && N/i<10){
            cout<<"Yes"<<endl;
            return 0;
        }

    }
            cout<<"No"<<endl;

    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N){
    string str = to_string(N);
    rep(i,0,str.size()) {
        if (str[i] == '7') {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3760
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
string s;
int dp[200000][4];
signed main() {
	cin >> s;
	n = s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (s[i] != '?') dp[i + 1][j] = dp[i][j] % Mod;
			else dp[i + 1][j] = dp[i][j] * 3 % Mod;
		}
		if (s[i] == 'A' || s[i] == '?') dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % Mod;
		if (s[i] == 'B' || s[i] == '?') dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % Mod;
		if (s[i] == 'C' || s[i] == '?') dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % Mod;
	}
	cout << dp[n][3] % Mod << endl;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef complex <double> C;

class Point{
public:
  double x;
  double y;
  Point operator + (Point p)const{
    return (Point){x + p.x, y + p.y};
  }
  bool operator < (Point p)const{
    return x*x + y*y < p.x*p.x + p.y*p.y;
  }
};


bool throughO(Point p, Point v){
  //  if(abs(v.x) < 1e-7 ){
  //    return abs(p.y) < 1e-7;
  //  }

  return abs(p.x*v.y-p.y*v.x) < 1e-8;

  //  double a = v.y / v.x;
  //  return abs(p.y - a*p.x) < 0.0000001;
}


int main(void){
  double D;
  while(cin >> D){
    if(D==0)break;

    Point p, v;
    double ans = 0;

    cin >> p.x >> p.y >> v.x >> v.y;
    double len = sqrt(p.x * p.x + p.y * p.y);


    if(!throughO(p, v) ){
      cout << "impossible" << endl;
      //impossible
      continue;
    }

    double naiseki = -p.x * v.x + -p.y * v.y;
    if(abs(naiseki - len*sqrt(v.x*v.x + v.y*v.y)) > 0.000001){
      ans = 1 + (1 - len);
    }else{
      ans = len;
    }
    if(ans < D + 0.000001)
      printf("%.10f\n", ans);
    else
      cout << "impossible" << endl;
    //impossible
  }
}

Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

string s;
int memo[505][505];

bool dfs(int l, int r) {
	if(l > r) return true;
	if(memo[l][r] != -1) return memo[l][r];

	if(s[l] == 'm' && s[r] == 'w') {
		REP(i, l+1, r) {
			if(s[i] == 'e') {
				if(dfs(l+1, i-1) && dfs(i+1, r-1)) {
					return memo[l][r] = true;
				}
			}
		}
	}
	return memo[l][r] = false;
}

int main() {
	cin >> s;
	memset(memo, -1, sizeof(memo));

	if(dfs(0, s.size()-1)) {
		cout << "Cat" << endl;
	} else {
		cout << "Rabbit" << endl;
	}

	return 0;
}

Measured memory_bytes: 2196
#include<iostream>
#include<stdio.h>
using namespace std; 
int main()
{
	int n,i,j;
	cin>>n;
	int a[200]={0};
	for(i=0;i<n;i++)  cin>>a[i];
	for(j=0;j<n-1;j++)
	{
		printf("%d ",a[j]);
	}
	printf("%d",a[n-1]);
	printf("\n");
	for(i=1;i<n;i++)
	{
		int v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(j=0;j<n-1;j++)
		{
			printf("%d ",a[j]);
		}
		printf("%d",a[n-1]);
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 3116
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var n int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &n)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}
	sort.Sort(sort.IntSlice(as))
	m := as[len(as)-1]
	as = as[0 : len(as)-1]
	index := sort.SearchInts(as, m/2)

	if index == len(as) {
		fmt.Println(m, as[index-1])
		return
	}
	if index == 0 {
		fmt.Println(m, as[index])
		return
	}
	if float64(as[index])-float64(m)/2.0 < float64(m)/2.0-float64(as[index-1]) {
		fmt.Println(m, as[index])
	} else {
		fmt.Println(m, as[index-1])
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    str N;cin>>N;
    if(N[0]==N[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

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

int dp[1025][100001];
struct P{int w,v;};
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

int main(){
  int n;cin>>n;
  vector<int> v(n),w(n);
  REP(i,n)cin>>v[i]>>w[i];
  REP(i,min(n,1<<10))
    REP(j,100001){
      dp[i+1][j]=dp[(i+1)/2][j];
      if(j-w[i]>=0)chmax(dp[i+1][j],dp[(i+1)/2][j-w[i]]+v[i]);
      if(j>0)chmax(dp[i+1][j],dp[i+1][j-1]);
    }
  int q;cin>>q;
  while(q--){
    int a,l,ans=0;cin>>a>>l;
    vector<P> S;
    S.push_back({0,0});
    while(a>1024){
      int t=S.size();
      REP(i,t)if(S[i].w+w[a-1]<=l)S.push_back({S[i].w+w[a-1],S[i].v+v[a-1]});
      a>>=1;
    }
    for(P p:S)chmax(ans,dp[a][l-p.w]+p.v);
    cout<<ans<<endl;
  }
}

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

int main() {
  int r , D , x ; 
  cin >> r >> D >> x ; 
  int new_x = x ; 
  
  for( int i = 1 ; i <= 10 ; i++ ){
	new_x = r*new_x - D ; 
    cout << new_x << endl ;
  }

  
  
}

Measured memory_bytes: 3512
S = input()
N = len(S)
S = "!" + S + "!"
if N == 2:
    if S[1] == S[2]:
        print("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(1, N+1, 1):
    PrevAl = S[i-1]
    NowAl = S[i]
    NextAl = S[i+1]
    if PrevAl == NowAl or NowAl == NextAl or PrevAl == NextAl:
        AnsL = i-1
        AnsR = i+1
        if AnsL == 0:
            AnsL = 1
        print(AnsL, AnsR)
        exit()
print("-1 -1")


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

int main() {
  ll n;
  vector<ll> a(5);
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]; 
  ll m = n;
  ll ans = 4;
  rep(i,5){
    if(m > a[i])
      m = a[i];
  }
  ans += (n + m - 1) / m;
  
  cout << ans << endl;
}

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

using namespace std;

int32_t main() {
 //freopen("input.txt","r",stdin);
 int n;
 cin >> n;
 int ac = 0, re = 0 , wa = 0, tle = 0;
 for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
        ac++;
    }
    if (s == "RE") {
        re++;
    }
    if (s == "WA") {
        wa++;
    }
    if (s == "TLE") {
        tle++;
    }
 }
 cout << "AC x " << ac << "\n";
 cout << "WA x " << wa << "\n";
 cout << "TLE x " << tle << "\n";
 cout << "RE x " << re << "\n";
 return 0;
}



Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	scan.Scan()
	in := strings.Split(scan.Text(), " ")

	bubbleOut := BubbleSort(in)
	selectionOut := SelectionSort(in)

	trace(bubbleOut)
	fmt.Println("Stable")
	trace(selectionOut)
	if IsStable(selectionOut, bubbleOut) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func BubbleSort(in []string) []string {
	var _in []string = make([]string, len(in))
	copy(_in, in)
	for i := 0; i < len(_in); i++ {
		for j := len(_in) -1 ; j > i; j-- {
			if _in[j][1] < _in[j-1][1] {
				swap(&_in[j], &_in[j-1])
			}
		}
	}
	return _in
}

func SelectionSort(in []string) []string {
	var _in []string = make([]string, len(in))
	copy(_in, in)
	for i := 0; i < len(_in); i++ {
		min := i
		for j := i + 1; j < len(_in); j++ {
			if _in[j][1] < _in[min][1] {
				min = j
			}
		}
		if min != i {
			swap(&_in[min], &_in[i])
		}
	}
	return _in
}

func IsStable(tested []string, stable []string) bool {
	for index, value := range stable {
		if tested[index] != value {
			return false
		}
	}
	return true
}

func swap(a *string, b *string) {
	temp := *b
	*b = *a
	*a = temp
}

func trace(in []string)  {
	for index, value := range in {
		if index == 0 {
			fmt.Print(value)
		} else {
			fmt.Print(" ", value)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    string s;
    map<string,int>mp;
    while(n--)
    {
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
}


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

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

  int A = 0, ans = 0;

  for (int i = 0; i < N; i++) {
    cin >> H;
    if (A < H) ans += H - A;
    A = H;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
int main(){
    int a, b; cin >> a >> b;
    string s; cin >> s;
    bool ans = true;
    if (a+b+1!=s.size()) ans =false;
    else {
        for (int i=0;i<s.size();i++){
            if (i==a){
                if (s[i]=='-') continue;
                else {
                    ans = false; break;
                }
            }
            else if (s[i]=='-') {
                ans = false; break;
            }
        }
    }
    cout << ((ans) ? "Yes" : "No" )<< endl;
}

Measured memory_bytes: 384
n=int(input())
red=[[] for i in range(n)]
blue=[[] for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    red[i].append(a)
    red[i].append(b)
for i in range(n):
    a,b=map(int,input().split())
    blue[i].append(a)
    blue[i].append(b)
red=sorted(red)
blue=sorted(blue)
ans=0
for i in range(n):
    x=blue[i][0]
    y=blue[i][1]
    maxy=-1
    for j in range(n):
        if x>red[j][0] and y>red[j][1]:
            maxy=max(maxy,red[j][1])
    for j in range(n):
        if x>red[j][0] and maxy==red[j][1]:
            ans+=1
            red[j][0]=1000
            break
print(ans)


Measured memory_bytes: 68580
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 k = sc.nextInt();
      if(b-a+2 <= k*2){
      	for(int i = 0;i <= b-a;i++){
        	System.out.println(a+i);
        }
      }else{
      	for(int i = 0;i < k;i++){
      		System.out.println(a+i);
      	}
      	for(int i = 1;i <= k;i++){
      		System.out.println(b-k+i);
      	}
      }
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int m =a.size();
    int n =b.size();
    int i,j,k;
    int dp[m+1][n+1];
    for( i=0; i<=m; i++)
        dp[i][0]=1;
    for( i=0; i<=n; i++)
        dp[0][i]=1;
    for( i=1; i<=m; i++)
    {
        for( j=1; j<=n; j++)
        {
            if(a[i-1]==b[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    i=m;
    j=n;
    vector<char>v;
    while(i>0 && j>0)
    {
        if(dp[i][j]== 1 + dp[i-1][j-1] && a[i-1]==b[j-1])
        {
            v.push_back(a[i-1]);
            i--;
            j--;
            continue;
        }
        if(dp[i][j] == dp[i-1][j])
        {
            i--;
        }
        else
            j--;
    }
    for(int i=v.size()-1; i>=0; i--)
        cout<<v[i];
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007

int main(){
	int a, b , c , n;
	cin >> a >> b >> c >> n;
	int ans = 0;
	int cur = 0;
	for(int i = 0 ;i * a <= n;i++){
		for(int j = 0 ;(i * a) + (j * b) <= n;j++){
			cur = n - (i * a) - (j * b);
			if(cur % c == 0)
				ans++;
		}
	}
	cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>                                                                                                       
                                                                                                                          
using namespace std;                                                                                                      
                                                                                                                          
int main() {                                                                                                              
  string s;                                                                                                               
  while (cin >> s) {                                                                                                      
    for (int i = s.length() - 1; i >= 0; i--) {                                                                           
      cout << s[i];                                                                                                       
    }                                                                                                                     
    cout << endl;                                                                                                         
  }                                                                                                                       
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();

		int cnt = 0;
		while(N > 0)
		{
			cnt++;
			N /= K;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// English
// 2013/09/21
public class Main{
	Scanner sc=new Scanner(System.in);

	int n;
	String[] words;
	int[] scores;
	int m=4;
	char[][] cs;
	int maxT;

	void run(){
		n=sc.nextInt();
		words=new String[n];
		scores=new int[n];
		for(int i=0; i<n; i++){
			words[i]=sc.next();
			scores[i]=sc.nextInt();
		}
		cs=new char[m][];
		for(int i=0; i<m; i++){
			cs[i]=sc.next().toCharArray();
		}
		maxT=sc.nextInt();
		solve();
	}

	void solve(){
		visited=new boolean[m][m];
		long[] dp=new long[maxT+1];
		for(int j=0; j<n; j++){
			int num=0;
			for(int y=0; y<m; y++){
				for(int x=0; x<m; x++){
					num+=dfs(x, y, words[j], 0);
				}
			}
			int weight=words[j].length(), value=scores[j];
			for(int k=1; num>0; k<<=1){
				int mul=min(k, num);
				for(int i=maxT; i-weight*mul>=0; i--){
					dp[i]=max(dp[i], dp[i-weight*mul]+value*mul);
				}
				num-=mul;
			}
		}
		println(dp[maxT]+"");
	}

	boolean[][] visited;

	int dfs(int x, int y, String word, int at){
		if(x<0||x>=m||y<0||y>=m||cs[y][x]!=word.charAt(at)||visited[y][x]){
			return 0;
		}
		if(at==word.length()-1){
			return 1;
		}
		visited[y][x]=true;
		int sum=0;
		for(int i=-1; i<=1; i++){
			for(int j=-1; j<=1; j++){
				sum+=dfs(x+i, y+j, word, at+1);
			}
		}
		visited[y][x]=false;
		return sum;
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 22564
N = int(input())
A = list( map(int, input().split()))

d = sum(A) // 2

for i in range(1, N - 1, 2):
    d -= A[i]

for i in range(N):
    print(2 * d, end='')
    if i == N - 1:
        print('')
    else:
        print(' ', end='')
    d = A[i] - d






Measured memory_bytes: 14092
#include <iostream>

using namespace std;

int main()
{
	int n, price, sum = 0, ave = 0, cont = 0;
	double dave = 0;
	char c;

	while(cin >> price >> c >> n){
		sum += price * n;
		ave += n;
		dave += n;
		cont++;
	}

	ave /= cont;
	dave /= (double)cont;

	if(dave - (double)ave >= 0.5)    ave++;

	cout << sum << endl << ave << endl;

	return 0;
}

Measured memory_bytes: 1160