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

#define ll long long
#define inf 100000000

using namespace std;

int n;


int toInt(char a){
		char b[8]={'2','3','4','5','6','7','8','9'};
		for(int i=0;i<8;i++){
				if(a==b[i]){
						return 2+i;
				}
		}
}

bool isint(char a){
		char b[8]={'2','3','4','5','6','7','8','9'};
		for(int i=0;i<8;i++){
				if(a==b[i])return true;
		}
		return false;
}

int is(string a){
		char o,p,q,r;
		int b=inf,c=inf,d=inf,e=inf;
		for(int i=0;i<a.length();i++){
				if(a[i]=='m'){
						b=i;	
				}
				if(a[i]=='c'){
						c=i;
				}
				if(a[i]=='x'){
						d=i;
				}
				if(a[i]=='i'){
						e=i;
				}
		}
		int ans=0;
		if(b==0){
				ans+=1000;
		}else if(b==1){
				ans+=toInt(a[0])*1000;
		}
		if(c!=inf){
				if(c==0){ans+=100;}
				else if(isint(a[c-1])){
						ans+=toInt(a[c-1])*100;
				}else{
						ans+=100;
				}
		}
		if(d!=inf){
				if(d==0){ans+=10;}
				else if(isint(a[d-1])){
						ans+=toInt(a[d-1])*10;
				}else{
						ans+=10;
				}
		}
		if(e!=inf){
				if(e==0){ans+=1;}
				else if(isint(a[e-1])){
						ans+=toInt(a[e-1]);
				}else{
						ans+=1;
				}
		}
		return ans;
}

char toChar(int a){
		if(a==2)return '2';
		if(a==3)return '3';
		if(a==4)return '4';
		if(a==5)return '5';
		if(a==6)return '6';
		if(a==7)return '7';
		if(a==8)return '8';
		if(a==9)return '9';
}

int main(){
		cin>>n;
		int cont=0;
		while(cont<n){
				string s;
				string t;
				cin>>s>>t;
				int m=is(s)+is(t);
				//cout<<m<<endl;
				int a=m/1000;
				m%=1000;
				int b=m/100;
				m%=100;
				int c=m/10;
				m%=10;
				int d=m;
				string ans;
				if(a==1){
						ans+="m";
				}else if(a>1){
						ans+=toChar(a);
						ans+="m";
				}
				if(b==1){
						ans+="c";
				}else if(b>1){
						ans+=toChar(b);
						ans+="c";
				}
				if(c==1){
						ans+="x";
				}else if(c>1){
						ans+=toChar(c);
						ans+="x";
				}
				if(d==1){
						ans+="i";
				}else if(d>1){
						ans+=toChar(d);
						ans+="i";
				}
				cout<<ans<<endl;
				cont++;
		}
}

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

int main() {
   int n,m;
   cin >> n >> m;
   vector<int> a(n);
   float line = 0;
   rep(i,n) {
       cin >> a[i];
       line+=a[i];
   }
   line /= 4*float(m);
   int cnt = 0;
   rep(i,n){
       if(a[i] >= line)cnt++;
   }
   if(cnt >= m) cout << "Yes" << endl;
   else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int const inf = 1<<28;
int H,W,S;
int a[33][33];

int T;
int sum[35][35];
pii dp[33][33][33][33];

int s(int x, int y, int w, int h){
    return sum[y+h][x+w]-sum[y][x+w]-sum[y+h][x]+sum[y][x];
}

// x,y,w,hの長方形でできる分割の数の最大、分割の最小
pii f(int x, int y, int w, int h){
    auto & res = dp[x][y][w][h];
    if(res!=mp(-1,-1)) return res;
    if(s(x,y,w,h) < T) return res = mp(-inf,inf);
    res = mp(1,s(x,y,w,h));
    for(int i=1;i<w;i++){
        int a1,b1,a2,b2;
        tie(a1,b1)=f(x,y,i,h);
        tie(a2,b2)=f(x+i,y,w-i,h);
        res = max(res,mp(a1+a2,min(b1,b2)));
    }
    for(int i=1;i<h;i++){
        int a1,b1,a2,b2;
        tie(a1,b1)=f(x,y,w,i);
        tie(a2,b2)=f(x,y+i,w,h-i);
        res = max(res,mp(a1+a2,min(b1,b2)));
    }
    return res;
}

int main(){
    while(cin >> H >> W >> S && H){
        rep(i,33)rep(j,33)rep(k,33)rep(l,33)dp[i][j][k][l] = mp(-1,-1);
        rep(i,H)rep(j,W)cin >> a[i][j];
        memset(sum,0,sizeof(sum));
        rep(i,H)rep(j,W) sum[i+1][j+1] = a[i][j];
        rep(i,H+1)rep(j,W+1) sum[i][j+1] += sum[i][j];
        rep(i,H+1)rep(j,W+1) sum[i+1][j] += sum[i][j];
        T = sum[H][W]-S;
        int p,q;
        tie(p,q) = f(0,0,W,H);
        cout << p << " " << q-sum[H][W]+S << endl;
    }
}

Measured memory_bytes: 10440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String s = sc.next();
        String t = sc.next();

        if ((s + t.charAt(t.length() - 1)).equals(t)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        System.exit(0);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 37212
#include <bits/stdc++.h>
#define SIZE 100005
#define SQR 512
#define MOD 998244353
#define INF 1000000000000000000LL
using namespace std;
typedef long long int ll;

int n;
vector <int> vec[SIZE];
int grundy[SIZE];
ll sum[3][SQR];

void solve(int t)
{
	int m;
	scanf("%d",&m);
	for(int i=0;i<n;i++) vec[i].clear();
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		a--,b--;
		if(a>b) swap(a,b);
		vec[a].push_back(b);
	}
	for(int i=n-1;i>=0;i--)
	{
		set <int> st;
		for(int j=0;j<vec[i].size();j++) st.insert(grundy[vec[i][j]]);
		grundy[i]=0;
		while(st.count(grundy[i])) grundy[i]++;
	}
	ll mul=1;
	for(int i=0;i<n;i++)
	{
		mul*=INF%MOD;
		mul%=MOD;
		sum[t][grundy[i]]+=mul;
		if(sum[t][grundy[i]]>=MOD) sum[t][grundy[i]]-=MOD;
	}
}
int main()
{
	scanf("%d",&n);
	for(int t=0;t<3;t++) solve(t);
	ll ret=0;
	for(int i=0;i<SQR;i++)
	{
		for(int j=0;j<SQR;j++)
		{
			ret+=sum[0][i]*sum[1][j]%MOD*sum[2][i^j]%MOD;
			if(ret>=MOD) ret-=MOD;
		}
	}
	printf("%lld\n",ret);
	return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    print((int)(n % k != 0));

    return 0;
}


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


int res = 1000000;
int n, A, B, C;
vector<int> l;

void dfs(int i, int a, int b, int c, int point)
{
    if (i == n)
    {
        if (a == 0 or b == 0 or c == 0) return;
        point += abs(A - a);
        point += abs(B - b);
        point += abs(C - c);
        point -= 30;
        res = min(res, point);
        return;
    } 
    dfs(i + 1, a + l[i], b, c, point + 10);
    dfs(i + 1, a, b + l[i], c, point + 10);
    dfs(i + 1, a, b, c + l[i], point + 10);
    dfs(i + 1, a, b, c, point);
    return;
}

int main()
{
    cin >> n >> A >> B >> C;
    rep(i, 0, n)
    {
        int len;
        cin >> len;
        l.push_back(len);
    }

    dfs(0, 0, 0, 0, 0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

type Whites = [Coord]
type Coord  = (Int, Int)
type Mode   = Int

main :: IO ()
main = do
    [w,h,n] <- getInts
    xyas <- replicateM n getInts
    print $ whiteArea (w,h) xyas

getInts :: IO [Int]
getInts = map read . words <$> getLine

whiteArea :: Coord -> [[Int]] -> Int
whiteArea (w,h) xyas = length $ paintAll whites paintInfos
  where
    whites     = [(x,y) | x <- [1..w], y <- [1..h]]
    paintInfos = [((xi,yi),ai) | [xi,yi,ai] <- xyas]

paintAll :: Whites -> [(Coord, Mode)] -> Whites
paintAll = foldr paint
  where
    paint ((xi,_),1) = filter (\(x,_) -> x >  xi)
    paint ((xi,_),2) = filter (\(x,_) -> x <= xi)
    paint ((_,yi),3) = filter (\(_,y) -> y >  yi)
    paint ((_,yi),4) = filter (\(_,y) -> y <= yi)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d, e, f;
  d = a - b;
  e = b - c;
  f = a - c;

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


Measured memory_bytes: 256
moji = []
ans=""
s = str(input())
s = list(s)

def keyboard(key,list):
    if key == "0":
        list.append("0")
    elif key == "1":
        list.append("1")
    elif key == "B" and len(list) != 0:
        list.pop(-1)

for i in range(len(s)):
    keyboard(s[i],moji)

for x in moji:
    ans += x

print(ans)

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


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

  if (x) {
    cout << 0 << endl;
    return 0;
  } else {
    cout << 1 << endl;
  }

  return 0;
}
/*
*/


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var Alphabet = Console.ReadLine();
            var isUpper = Regex.IsMatch(Alphabet, "[A-Z]+$");
            
            Console.WriteLine(isUpper?"A":"a");
        }
    }
}

Measured memory_bytes: 26612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 h, w;
vector<string> a;

struct P {
  i64 i, j, c;
};

int main() {
  cin >> h >> w;
  read_n(a, h);

  set<pair<i64, i64>> s;
  for (i64 i = 0; i < h; ++i) {
    for (i64 j = 0; j < w; ++j) {
      if (a[i][j] == '#') {
	i64 vi = 1, vj = 0; 
	for (i64 d = 0; d < 4; ++d) {
	  i64 ti = i + vi, tj = j + vj;
	  if (0 <= ti && ti < h && 0 <= tj && tj < w && a[ti][tj] == '.') {
	    s.emplace(ti, tj);
            a[ti][tj] = '*';
	  }
	  i64 t = vi; vi = -vj; vj = t;
	}
      }
    }
  }

  queue<P> q;
  for (auto& p : s) q.push({p.first, p.second, 1});
  i64 ans = 0;
  while (!q.empty()) {
    auto p = q.front(); q.pop();
    ans = p.c;
    i64 i = p.i, j = p.j, vi = 1, vj = 0;
    for (i64 d = 0; d < 4; ++d) {
      i64 ti = i + vi, tj = j + vj;
      if (0 <= ti && ti < h && 0 <= tj && tj < w && a[ti][tj] == '.') {
	q.push({ti, tj, ans + 1});
        a[ti][tj] = '*';
      }
      i64 t = vi; vi = -vj; vj = t;
    }
    /*
    for (auto& s : a) cout << s << '\n';
    cout << '\n';
    */
  }
  cout << ans << '\n';

  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vec(n,-1);
    bool ans = true;
    rep(i,m) {
        int s, c;
        cin >> s >> c;
        s--;
        if(vec.at(s) == -1) vec.at(s) = c;
        else if(vec.at(s) != c) ans = false;
    }
    if(vec.at(0) == -1 && n != 1) vec.at(0) = 1; 
    rep(i,n) {
        if(i == 0) continue;
        if(vec.at(i) == -1) vec.at(i) = 0;
    }
    if(vec.at(0) == 0 && n != 1) ans = false;
    if(vec.at(0) == -1 && n == 1) vec.at(0) = 0;
    if(ans){
        rep(i,n) {
        cout << vec.at(i);
    }
    cout << endl;
    }
    else cout << -1 << endl;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string n;
    n = to_string(N);
    if((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var n = input.ReadInt;
            var aArr = input.ReadIntArray;

            var alice = 0;
            var bob = 0;
            var descend = aArr.OrderByDescending(a => a).ToArray();
            for (var i = 0; i < descend.Length; ++i)
            {
                alice += descend[i];
                ++i;
                if (descend.Length == i)
                    continue;
                bob += descend[i];
            }
            var diff = alice - bob;
            Console.WriteLine(diff);
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public int[] ReadIntArray => Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 13524
a, b, c, x, y = map(int, input().split())
money = 0

if a + b > 2 * c:
    num = min(x,y)
    money = 2 * c * num
    if x - y > 0:
        if a > 2 * c:
            money += 2 * c * (x - y)
        else:
            money += a * (x - y)
    else:
        if b > 2 * c:
            money += 2 * c * (y - x)
        else:
            money += b * (y - x)
else:
    money = a * x + b * y

print(money)

Measured memory_bytes: 3064
import math

def func(n):
    #check length
    q=int(math.log10(abs(n)))
    if n*(-1)**(q%2)>0:
        p=(-10)**(q)*(n/(-10)**(q))
    else:
        p=(-10)**(q+1)
    r=n-p
    return (abs(p), r)
    
def check_safe_oc(ans, ap):
    q=int(math.log10(ap))
    if ans==0 or q>int(math.log10(ans)): return [True , q]
    anq= ((ans%10**(q+1))/10**q)*10**q
    return [int(math.log10(ap+anq))==q , q]


def addans(ans,ap):
    coc,q=check_safe_oc(ans,ap)
    if coc:
        ans+=ap
    else:
        ans  = (ans/10**(q+1))*10**(q+1)+ans%10**q
        ans +=  9*10**(q+1)
        ans = addans(ans,10**(q+2))
    return ans

#for n in range(910,100000):
#    norg=n
#    ans=0
#    while(n!=0):
#        [ap,n]=func(n)
#        ans=addans(ans,ap)
#    if norg!=checkok(ans):
#        print norg,ans,checkok(ans)
#        break
#def checkok(ans):
#    ret=0
#    sa=str(ans)
#    lena=len(sa)
#    for i in range(lena):
#        ret+=int(sa[-i-1])*(-10)**(i)
#    return ret

while(1):
    n=int(raw_input())
    if n==0:
        break
    ans=0
    while(n!=0):
        [ap,n]=func(n)    
        ans=addans(ans,ap)
    print ans

Measured memory_bytes: 6668
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [k, n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a: number[] = tmp.shift().split(" ").map(int => int - 0);
    let m = 0;
    for (let i = 0; i < n; i++) {
      if (i < n - 1 && a[i + 1] - a[i] > m) {
        m = a[i + 1] - a[i];
      } else if (i == n - 1 && a[0] + (k - a[i]) > m) {
        m = a[0] + (k - a[i]);
      }
    }
    return `${k - m}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 22392
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

class Point {
public:
  int x, y;
};

int main() {

  string s;
  cin >> s;
  vector<bool> alp(26, false);
  for(int i=0; i<s.size(); i++){
    alp[s[i]-'a'] = true;
  }
  for(int i=0; i<26; i++){
    if(!alp[i]){
      char c = 'a' + i;
      s += c;
      cout << s << endl;
      return 0;
    }
  }
  if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
    return 0;
  }

  int n = s.size();
  string t = "";
  for(int i=n-1; i>=0; i--){
    if( s[i] > s[i-1] ){
      t += s[i];
      sort(t.begin(), t.end());
      for(int j=0; j<t.size(); j++){
        if( t[j] > s[i-1] ){
          string ans = s.substr(0, i-1);
          ans += t[j];
          cout << ans << endl;
          return 0;
        }
      }
      return 0;
    }else{
      t += s[i];
    }
  }

  cout << -1 << endl;
  return 0;
}


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

long long p, a, cnt;
long long x[100000];

int main() {
	while (cin >> p >> a) {
		cnt = 0;
		memset(x, 0, sizeof(x));
		while (true) {
			if (cnt >= 1) { cout << p / a; }
			if (p%a == 0) { break; }
			p *= 10;
			p %= (a * 10);
			x[cnt] = p;
			cnt++;
			for (int i = 0; i < cnt - 1; i++) {
				if (p == x[i]) {
					cout << endl;
					for (int j = 1; j <= i; j++) {
						cout << ' ';
					}
					for (int j = i + 1; j < cnt; j++) {
						cout << '^';
					}
					goto E;
				}
			}
		}
	E:;
		cout << endl;
	}
	return 0;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}

int main(void) 
{	
	int n, k; cin>> n >> k;
	cout<< n - k +1;
	return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;
typedef pair<string, string> PS;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v, w;
  REP(i, m) {
    ll a;
    cin >> a;
    v.pb(a);
  }
  sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
  if (v.size() <= n) {
    cout << 0 << endl;
    return 0;
  }

  ll cnt = 0;
  REP(i, v.size() - 1) { w.pb(v[i + 1] - v[i]); }
  sort(w.begin(), w.end());

  REP(i, w.size() - (n - 1)) { cnt += w[i]; }
  cout << cnt << endl;
}

Measured memory_bytes: 2548
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [10**10]*(N+1)
dp[1] = 0
dp[2] = abs(h[0] - h[1])

for i in range(3,N+1):
  Kl = max(1,i-K)
  dp[i] = min([dp[j]+abs(h[j-1] - h[i-1]) for j in range(Kl, i)])
print(dp[N])

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

vector<int> Bubble_Sort(vector<int> &A, int N, int &cnt){
  bool flag = 1;
  while(flag){
    flag = 0;
    for(int j = N - 1; j >= 1; j--){
      if(A.at(j) < A.at(j - 1)){
        int X = A.at(j - 1);
        A.at(j - 1) = A.at(j);
        A.at(j) = X;
        flag = 1;
        cnt++;
      }
    }
  }
  return A;
}

int main(){
  int N;
  int cnt = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  Bubble_Sort(A, N, cnt);
  for(int i = 0; i < N - 1; i++){
    cout << A.at(i) << " ";
  }
  cout << A.at(N - 1) << endl;
  cout << cnt << endl;
}



Measured memory_bytes: 3156
#include <stdio.h>

int main()
{
    int A,B;
    int small,diff,half,answer;

    scanf("%d %d\n",&A,&B);

    small=B;
    diff=A-B;
    
    if(diff<0){
        diff=-1*diff;
        small=A;
    }
    if(diff%2==1){
        printf("IMPOSSIBLE\n");
    }
    else{
        half=diff/2;
        answer=small+half;

        printf("%d\n",answer);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    vec<int> dp(X+1,0);
    dp[0] = 1;
    for(int i=0;i<=X;i++){
        for(int j=0;j<6;j++){
            int p = 100+j;
            if(i+p>X) continue;
            dp[i+p] |= dp[i];
        }
    }
    cout << (dp[X]? 1:0) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<bool> color(8, false);
  int free = 0;
  rep(i,n) {
    int a;
    cin >> a;
    if (a >= 3200) free++;
    else color[a/400] = true;
  }
  int nofree = 0;
  for (bool b : color) nofree += b;
  printf("%d %d\n", max(1, nofree), max(1, nofree+free));
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int N; cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  //compute
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;  
  for(int i=0;i<N;i++){
    sum+=vec[i];
  }
  
  
  //output
    cout<<sum-vec[0]/2<<endl;
  
}
  


Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';
int32_t main(){
    int n;
    cin>>n;
    vector< pair<int,int > >v;
    for(int i =  0; i <n ; i++ ){
        int a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
        
    }
    int cp=0;
    for(int i = 0 ; i< n- 2;  i++ ){
        if(v[i].fi == v[i].se && v[i+1].fi==v[i+1].se && v[i+2].fi==v[i+2].se){
            cp=1;
        }
    }
    if(cp)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3620
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=1005;
//Code begin....

int num[5];

int main ()
{
    int n=Scan();
    FOR(i,1,n) {
        int x=Scan();
        ++num[x%4];
    }
    int z=(num[1]+num[3]-1);
    if (num[2]) ++z;
    puts(z<=num[0]?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		for(int i=0; i<5; i++) {
			int x = sc.nextInt();
			if (x == 0 ) {
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	sort(ALL(ar));
	int res = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int l = ar[i];
			int r = ar[i]+ar[j];
			int itr = lower_bound(ALL(ar), r) - ar.begin();
			int itl = j+1;
			res += itr-itl;

		}
	}	
	cout << res;
	return 0;
}

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

using namespace std;

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

int main() {
    string w[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    string s;
    cin >> s;
    rep(i, 3){
        if(s == w[i]){
            cout << w[i+1] << endl;
        }
    }
}


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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);
int dp[100010];

void dfs(int v)
{
	visited[v] = true;
	for (int u : g[v])
	{
		if (visited[u])
		{
			dp[v] = max(dp[v], dp[u] + 1);
			continue;
		}
		dfs(u);
		dp[v] = max(dp[v], dp[u] + 1);
	}
}

int main()
{
	run_forrest_run;
	int n,m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u,v;
		cin >> u >> v;
		u--;
		v--;
		g[u].pb(v);
	}

	for (int i = 0; i < n; i++)
	{
		if (!visited[i])
			dfs(i);
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans = max(ans, dp[i]);

	cout << ans;
	
}


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

int compare(const void*a,const void*b) {
	return strcmp((char*)a,(char*)b);
}

int main() {
	int N, t = 0, T = 1;
	int num[200000];
	char S[200000][11];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s", S[i]);
		num[i] = 1;
	}
	qsort(S, N, 11, compare);
	char s[200000][11];

	for (int i = 0; i < N; i++) {
		if (strcmp(S[i], S[i + 1]) != 0) {
			strcpy(s[t], S[i]);
			t++;
		}
		else {
			num[t]++;
            if (T < num[t]) {
				T = num[t];
			}
		}
	}
	for (int i = 0; i < t;i++) {
		if (num[i]==T) {
			printf("%s\n",s[i]);
		}
	}

	return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

// 二項係数ライブラリ---------------------------------------------------------------------------------------//
const ll MAX_COM = 1000007;
ll fac[MAX_COM], finv[MAX_COM], inv[MAX_COM];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1ll;
    finv[0] = finv[1] = 1ll;
    inv[1] = 1ll;
    for (int i = 2; i < MAX_COM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] % MOD * finv[k] % MOD * finv[n - k] % MOD;
}
// 二項係数ライブラリここまで-----------------------------------------------------------------------------------//


int X, Y;

ll solve() {
    COMinit();
    if((X+Y) % 3 != 0) return 0;
    else {
        int n = (X+Y) / 3;
        int k = X - n;
        return COM(n, k);
    }
}
int main(){
    cin >> X >> Y;
    printf("%lld\n", solve());
    return 0;
}

Measured memory_bytes: 27164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstring>

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

ll INF = 1LL << 60;

int W, H;

void dfs(Graph& field, int h, int w) {
	field[h][w] = 0;
	for (int dh = -1; dh <= 1; dh++) {
		for (int dw = -1; dw <= 1; dw++) {
			if (dh == 0 && dw == 0) continue;
			int nh = h + dh;
			int nw = w + dw;
			if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
			if (field[nh][nw] == 0) continue;
			dfs(field, nh, nw);
		}
	}
}

int main() {
	while (cin >> W >> H) {
		if (W == 0 && H == 0) break;
		Graph field(H, vector<int>(W));
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) cin >> field[h][w];
		}
		int count = 0;
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (field[h][w] == 1) {
					dfs(field, h, w);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3316
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; cin>>N;
    string S; cin>>S;
    mat loc(10);
    rep(i,N){
        loc[S[i]-'0'].pb(i);
    }
    rep(i,10){
        loc[i].pb(INF);
    }
    ll ans=0;
    rep(i,10){
        ll ind1=loc[i][0];
        if(ind1==INF) continue;
        rep(j,10){
            ll ind2=*UB(loc[j],ind1);
            if(ind2==INF) continue;
            rep(k,10){
                ll ind3=*UB(loc[k],ind2);
                if(ind3 != INF){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int a[1010];
int main () {
  int n;
  bool flag = true;
  std::cin >> n;
  for (int i = 0; i < n ; i++ ) {
    std::cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    if(a[i] % 2 == 0) {
      if(!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
        flag = false;
      }
    }
  }

  if(flag) {
    std::cout << "APPROVED" << '\n';
  } else {
    std::cout << "DENIED" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k)cout<<"Yay!"<<endl;

    else cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	while (1) {
		int e;
		cin >> e;
		if (!e) break;
		int ans = inf;
		rep(i, 0, 1001) {
			rep(j, 0, 1001) {
				int l = 0;
				int r = 1000;
				int x = i*i*i + j*j;
				if (x > e) continue;
				rep(k, 0, 12) {
					int m = (l + r) / 2;
					if (x+m == e) {
						//printf("i=%d j=%d m=%d\n",i,j,m);
						ans = min(ans, i+j+m);
					}
					else if (x+m > e) r = m;
					else l = m;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
using namespace std;
 
int64_t N, K;
int64_t A[100001];
int64_t B[100001];

int64_t Check(int64_t n){
    int64_t m = 0;
    for(int j = 0; j < N; ++j){
        if(n == (n | A[j])){
            m += B[j];
        }
    }
    return m;
}

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

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

    int top = 0;
    for(int i = 0; 1 << i <= K; ++i) top = i;

    int64_t ans = Check(K);
    for(int i = 0; 1 << i <= K; ++i){
        int64_t n = K >> i;
        if((1 & n) == 0) continue;
        n >>= 1;
        n <<= 1;
        //cout << n << " ";
        int num = i;
        while(num > 0){
            n <<= 1;
            n = n | 1;
            num--;
        }
        //cout << n << endl;
        ans = max(ans, Check(n));
    }
    cout << ans << endl;
}

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

int main(){
    vector<int> last;
    char str[256];
    map<int,int> m;
    map<int,int>::iterator itm;
    char* tp;
    while(fgets(str,256,stdin)){
        if(strlen(str) == 1) break;
        tp = strtok(str,",");
        last.push_back(atoi(tp));
    }

    while(fgets(str,256,stdin)){
        if(str == "\0") break;
        tp = strtok(str,",");
        vector<int>::iterator it;
        for(it=last.begin();it!=last.end();++it){
            if(atoi(tp) == *it){
                if((itm = m.find(*it)) != m.end()){
                    itm -> second++;
                }else{
                    m.insert(pair<int,int>(*it,2));
                }
            }
        }
    }

    for(itm=m.begin(); itm != m.end(); ++itm){
        cout << itm->first << " " << itm->second << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int h,w,n;
  cin >> h >> w >> n;
  int Sy,Sx;
  cin >> Sy >> Sx;
  string s,t;
  cin >> s >> t;
  ll L = Sx,R = Sx,U = Sy,D = Sy;
  bool is = false;
  rep(i,n){
    if(s[i] == 'L'){
      L--;
      if(L <= 0)is = true;
    }else if(s[i] == 'R'){
      R++;
      if(R > w)is = true;
    }else if(s[i] == 'U'){
      U--;
      if(U <= 0)is = true;
    }else if(s[i] == 'D'){
      D++;
      if(D > h)is = true;
    }
    if(t[i] == 'L')R = max(1ll,R-1);
    else if(t[i] == 'R')L = min(w*1ll,L+1);
    else if(t[i] == 'U')D = max(1ll,D-1);
    else if(t[i] == 'D')U = min(h*1ll,U+1);
  }
  cout << (is ? "NO" : "YES") << endl;


  




  return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
	int n,a,b,mina=0,max=0;
	cin>>n>>a>>b;
	if(n-a-b<=0){
		mina=a+b-n;
	}
	max=min(a,b);
	cout<<max<<" "<<mina<<endl;
}

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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

long long GCD(long long a, long long b) {
    return b ? GCD(b, a%b) : a;
}

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N; cin >> N;

    SegTree<ll> seg(N, [](ll a, ll b) {return GCD(a, b);}, 0);
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        seg.set(i, A[i]);
    }
    seg.build();

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll l = seg.get(0, i);
        ll r = seg.get(i+1, N);
        ans = max(ans, GCD(l, r));
    }
    cout << ans << endl;
}



Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int A, B;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> A >> B;
  if (B % A == 0)
    cout << A + B << '\n';
  else
    cout << B - A << '\n';
}

Measured memory_bytes: 256
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int l[500005],r[500005];
int main() {
    string S;
    cin >> S;

    int i;
    LLI ans = 0;
    l[0] = 0;
    for (i = 0; i < S.size(); i++) {
        if (S[i] == '<') l[i+1] = l[i]+1;
        else l[i+1] = 0;
    }
    r[S.size()] = 0;
    for (i = S.size()-1; i >= 0; i--) {
        if (S[i] == '>') r[i] = r[i+1]+1;
        else r[i] = 0;
    }
    for (i = 0; i <= S.size(); i++) ans += max(l[i],r[i]);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(st==null || !st.hasMoreElements()){
                try{
                    st=new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt(){
            return Integer.parseInt(next());
        }

        Long nextLong(){
            return Long.parseLong(next());
        }

        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str="";
            try{
                str=br.readLine();
            }
            catch(IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) throws IOException {
       FastReader in = new FastReader();
      int n=in.nextInt();
      int b[]=new int [n+1];
      Arrays.fill(b,0);

      for(int i=1;i<n;i++){
          b[in.nextInt()]++;
      }
      for(int i=1;i<=n;i++){
          System.out.println(b[i]);
      }

    }
}


Measured memory_bytes: 57036