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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int
int main()
{
	int a,b,c,d,e,k=0,s,a1,b1,c1,d1,e1,z[5];
	cin>>a>>b>>c>>d>>e;
	if (a%10==0)
	k=k+a;
	else
	{
		a1=a%10;
		a=a/10;
		a=(a+1)*10;
		k=k+a;
	}
	if (b%10==0)
	k=k+b;
	else
	{
		b1=b%10;
		b=b/10;
		b=(b+1)*10;
		k=k+b;
	}
	if (c%10==0)
	k=k+c;
	else
	{
		c1=c%10;
		c=c/10;
		c=(c+1)*10;
		k=k+c;
	}
	if (d%10==0)
	k=k+d;
	else
	{
		d1=d%10;
		d=d/10;
		d=(d+1)*10;
		k=k+d;
	}
	if (e%10==0)
	k=k+e;
	else
	{
		e1=e%10;
		e=e/10;
		e=(e+1)*10;
		k=k+e;
	}
	if (a1!=0)
	z[0]=a1;
	else
	z[0]=10;
	if (b1!=0)
	z[1]=b1;
	else
	z[1]=10;
	if (c1!=0)
	z[2]=c1;
	else
	z[2]=10;
	if (d1!=0)
	z[3]=d1;
	else
	z[3]=10;
	if (e1!=0)
	z[4]=e1;
	else
	z[4]=10;
	sort(z,z+5);
	s=z[0];
	cout<<k-10+s;
}

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

namespace B
{
	class Program
	{

		static void Main()
		{
			List<int> a = new List<int>();
			for (int i = 0; i < 5; i++) {
				a.Add(int.Parse(Console.ReadLine()));
			}

			Console.WriteLine(order(0, a));
		}

		static int order(int t, List<int> a)
		{
			// Console.Write("t: " + t + ", ");
			// foreach (var _ in a) Console.Write(_ + ", ");
			// Console.WriteLine();
			
			if (a.Count == 0) return t;
			var times = new List<int>();
			for (int i = 0; i < a.Count; i++) {
				var _ = ((int[])a.ToArray().Clone()).ToList();
				_.RemoveAt(i);
				if (t % 10 == 0)
					times.Add(order(t + a[i], _));
				else
					times.Add(order(t + 10 - (t % 10) + a[i], _));
			}
			return times.Min();
		}
	}
}

Measured memory_bytes: 13268
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[100001],b[100001];
int main()
{
	int n,l,r,i,j;
	a[0]=a[1]=1;
	for(i=2;i<=100000;i++)
	{
		if(!a[i])
		for(j=i+i;j<=100000;j+=i)
		a[j]=1;
	}
	for(i=3;i<=100000;i++)
	{
		if(!a[i]&&!a[(i+1)/2])
		{
			b[i]=b[i-1]+1;
		}
		else
		b[i]=b[i-1];
	}
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&l,&r);
		printf("%d\n",b[r]-b[l-1]);
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int X;
    cin >> X;
    vector<bool> expo(X+1);

    expo[1] = 1;
    for(int b = 2; b <= X; b++){
        int v = b*b;
        while(v <= X){
            expo[v] = 1;
            v *= b;
        }
    }

    for(int i = X; i >= 1; i--){
        if(expo[i]){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
	x=0;char c=getchar();bool flag=false;
	while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	if(flag) x=-x;
}
ll n;
ll a,b,c;
int main()
{
	read(n);
	for(ll i=1;i<=3500;++i)
	{
		for(ll j=1;j<=3500;++j)
		{
			ll p=n*i*j,q=4*i*j-i*n-j*n;
			if(p<1||q<1) continue;
			if(p%q==0&&p/q>0)
			{
				a=i,b=j,c=p/q;
				break;
			}
		}
	}
	printf("%lld %lld %lld",a,b,c);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s,t;cin >> s;
	cin >> t;
	int n = s.size();
	int m = t.size();
	int ret = 1e18;
	for(int i = 0;i + m <= n;i++){
		int tmp = 0;
		for(int j = i;j <i+m;j++){
			// trace(s[j],t[j-i],i,j);
			tmp += (s[j] != t[j-i]);
		}
		ret = min(ret,tmp);
	}
	cout << ret << endl;
	return 0;
}

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

int x;

int main() {
  rep (i, 5) {
    cin >> x;
    if (x == 0) cout << i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
N,M = map(int,input().split())
ans = [10]*N
for i in range(M):
    si,ci = map(int,input().split())
    if ans[si-1] == 10:
        ans[si-1] = ci
    elif ans[si-1] != ci:
        ans[0] = -1

for i in range(1,N):
    if ans[i] == 10:
        ans[i] = 0
if ans[0] == 10:
    if N != 1:
        ans[0] = 1
    else:
        ans[0] = 0

if ans[0] > 0:
    res = 0
    for i in range(N):
        res += ans[i]*10**(N-i-1)
elif ans[0] == -1:
    res = -1
else:
    if N == 1:
        res = 0
    else:
        res = -1

print(res)





Measured memory_bytes: 3316
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BGreedyTakahashi {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int a, b, k;
        cin >> a >> b >> k;

        int resa = max(a - k, 0LL);
        k -= a;

        int resb = b;
        if (k > 0) {
            resb = max(b - k, 0LL);
        }
        cout << resa << " " << resb;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BGreedyTakahashi solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
// ABC_139_B

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

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

	int counter = 0;

	while(a * counter -(counter - 1) < b) ++counter;

	cout << counter << "\n";

	return 0;
}

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

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

int dfs(vector<vector<int> >& p, vector<vector<bool> >& visited, int x, int y, int color) {
  int ret = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx < 0 || w <= nx || ny < 0 || h <= ny || visited[ny][nx]) {
      continue;
    }
    visited[ny][nx] = true;
    if (p[ny][nx] == p[y][x]) {
      ret += dfs(p, visited, nx, ny, color);
    }
  }
  p[y][x] = color;
  return ret;
}

int change(vector<vector<int> >& p, int color) {
  vector<vector<bool> > visited(h, vector<bool>(w));
  visited[0][0] = true;
  return dfs(p, visited, 0, 0, color);
}

int dfs_change(int times, vector<vector<int> >& p) {
  if (times == 4) {
    vector<vector<int> > copy = p;
    change(copy, c);
    // 表示
    /* for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cout << copy[i][j];
      }
      cout << endl;
    }
    cout << "-----" << endl;*/
    
    return change(copy, c);
  }
  int ret = 0;
  for (int i = 1; i <= 6; i++) {
    if (i == p[0][0]) {
      continue;
    }
    vector<vector<int> > copy = p;
    change(copy, i);
    ret = max(ret, dfs_change(times+1, copy));
  }
  return ret;
}

int solve() {
  vector<vector<int> > p(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> p[i][j];
    }
  }
  int ans = dfs_change(0, p);
  cout << ans << endl;
}

int main() {
  while (true) {
    cin >> h >> w >> c;
    if (h == 0 && w == 0) {
      break;
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n,mx,mn;
int main(){
    scanf("%d",&n);
    scanf("%d",A+0);
    mx=A[0];
    for(int i=1;i<n;++i){
        scanf("%d",A+i);
        if(A[i]<mx-1){
            puts("No");
            return 0;
        }
        mx=max(A[i],mx);
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > Pi;
int posy[1000005], posx[1000005];
short mas[4005][4005];
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

void bfs(int sy, int sx, vector < int > &Y, vector < int > &X)
{
    queue < Pi > que;
    que.push(Pi(sy, sx));
    mas[sy][sx] = 1;
    while(!que.empty()) {
        Pi d = que.front(); que.pop();
        for(int i = 0; i < 4; i++) {
            int ny = d.first + dy[i], nx = d.second + dx[i];
            if(0 <= ny && ny < Y.size() && 0 <= nx && nx <= X.size() && mas[ny][nx] == 0) {
                mas[ny][nx] = 1;
                que.push(Pi(ny, nx));
            }
        }
    }
}
int main()
{
    int H, W;
    int N;
    int SX[1005], SY[1005], GX[1005], GY[1005];
    while(cin >> W >> H, W || H) {
        vector < int > X, Y;
        memset(mas, 0, sizeof(mas));
        cin >> N;
        for(int i = 0; i < N; i++) {
            int sx, sy, gx, gy;
            cin >> sx >> sy >> gx >> gy;
            X.push_back(sx);
            X.push_back(gx - 1);
            if(sx > 0) X.push_back(sx - 1);
            if(gx < W) X.push_back(gx);

            Y.push_back(sy);
            Y.push_back(gy - 1);
            if(sy > 0) Y.push_back(sy - 1);
            if(gy < H) Y.push_back(gy);

            SX[i] = sx, SY[i] = sy, GX[i] = gx - 1, GY[i] = gy - 1;
        }
        sort(X.begin(), X.end());
        sort(Y.begin(), Y.end());
        X.erase(unique(X.begin(), X.end()), X.end());
        Y.erase(unique(Y.begin(), Y.end()), Y.end());
        for(int i = 0; i < X.size(); i++) posx[X[i]] = i;
        for(int i = 0; i < Y.size(); i++) posy[Y[i]] = i;
        for(int i = 0; i < N; i++) {
            int sy = posy[SY[i]], sx = posx[SX[i]], gy = posy[GY[i]], gx = posx[GX[i]];
            mas[sy][sx]++, mas[sy][gx + 1]--, mas[gy + 1][sx]--, mas[gy + 1][gx + 1]++;
        }
        for(int i = 0; i < Y.size(); i++) {
            for(int j = 0; j < X.size(); j++) {
                if(j > 0) mas[i][j] += mas[i][j - 1];
                if(i > 0) mas[i][j] += mas[i - 1][j];
                if(i > 0 && j > 0) mas[i][j] -= mas[i - 1][j - 1];
            }
        }

        int cnt = 0;
        for(int i = 0; i < Y.size(); i++) {
            for(int j = 0; j < X.size(); j++) {
                if(mas[i][j] == 0) {
                    cnt++;
                    bfs(i, j, Y, X);
                }
            }
        }
        cout << cnt << endl;
    }
    return (0);
}

Measured memory_bytes: 34416
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}
int main(){
    int n;cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        if(x==0){
            string t;
            int y;
            cin>>t;
            cin>>y;
            mp[t]=y;
        }else if(x==1){
            string t;
            cin>>t;
            if(mp[t]){
                cout<<mp[t]<<endl;
            }else{
                cout<<0<<endl;
            }
        }else{
            string t;cin>>t;
            mp.erase(t);
        }
    }
}


Measured memory_bytes: 27700
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {
	lli N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	for (int i = A - 1; i < min(max(C, D), N - 1); i++) {
		if (S[i] == '#' && S[i + 1] == '#') {
			COUT("No");
			return 0;
		}
	}

	if (C < D) {
		COUT("Yes");
	}
	else {
		bool through = false;
		for (int i = B - 2; i < D - 1; i++) {
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
				through = true;
			}
		}
		if (through) {
			COUT("Yes");
		}
		else {
			COUT("No");
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>

int n;

int main() {
	std::cin>>n;
	int cnt=0,in;
	for(int i=0;i<n;++i){
		std::cin>>in;
		cnt+=in%2;
	}
	if(cnt%2==0)
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long A = l[0], B = l[1];
            var gcd = Gcd(A, B);
            long i = 2;
            var count = 1L;

            var sqrt = (int)Math.Ceiling(Math.Sqrt(gcd));
            while (i <= sqrt)
            {
                if (gcd % i == 0)
                {
                    count++;
                    while (gcd % i == 0) gcd /= i;
                }
                i++;
            }

            if (gcd != 1) count++;
            Console.WriteLine(count);
        }

        static long Gcd(long a, long b)
        {
            if (b > a) return Gcd(b, a);
            if (b == 0) return a;
            return Gcd(b, (a % b));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, ans, cnt[2]{};
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        cnt[a%2]++;
    }
    ans = int(pow(3,n));
    ans -=int(pow(2,cnt[0]));
    cout << ans << endl;
    return 0;
}


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

int solve(int N, int b, int p) {
    if (__builtin_popcount(b) != __builtin_popcount(p)) return 1 << 24;
    int swp = 0;
    for (int i = 0; i < N && b != p; ++i) {
        if ((b >> i & 1) == (p >> i & 1)) continue;
        for (int j = i + 1; j < N; ++j) {
            if ((p >> i & 1) == (p >> j & 1)) continue;
            swp += j - i;
            p ^= 1 << i | 1 << j;
            break;
        }
    }
    return swp;
}

int main() {
    int N, M; cin >> N >> M;
    int b = 0, p = 0;
    rep(i, N) {
        int x; cin >> x;
        b <<= 1;
        b |= x;
    }
    rep(i, M) {
        int l = 0; cin >> l;
        p <<= l;
        if (i & 1) p |= (1 << l) - 1;
    }
    cout << min(solve(N, b, p), solve(N, b, p ^ ((1 << N) - 1))) << endl;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

int P,N[6],coin[6] = {1,5,10,50,100,500},work[6];

int calc(int NUM){
	int ret = 0;
	ret += NUM/500;
	work[5] -= NUM/500;
	NUM %= 500;
	ret += NUM/100;
	work[4] -= NUM/100;
	NUM %= 100;
	ret += NUM/50;
	work[3] -= NUM/50;
	NUM %= 50;
	ret += NUM/10;
	work[2] -= NUM/10;
	NUM %= 10;
	ret += NUM/5;
	work[1] -= NUM/5;
	NUM %= 5;
	ret += NUM;
	work[0] -= NUM;

	return ret;
}

void func(){

	int minimum = BIG_NUM,tmp,count;
	bool FLG;

	for(int div = 0; div <= 500;div++){
		for(int i = 0; i < 6; i++)work[i] = N[i];
		count = calc(div);	//???????????°
		FLG = true;
		for(int i = 0; i < 6; i++){
			if(work[i] < 0){
				FLG = false;
				break;
			}
		}
		if(!FLG)continue;

		tmp = P+div;
		for(int i = 5; i >= 0; i--){
			while(tmp >= coin[i] && work[i] > 0){
				count++;
				tmp -= coin[i];
				work[i]--;
			}
		}
		minimum = min(minimum,count);
	}


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

int main(){

	while(true){
		scanf("%d %d %d %d %d %d %d",&P,&N[0],&N[1],&N[2],&N[3],&N[4],&N[5]);
		if(P == 0)break;

		func();
	}

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<long long> a;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<long long> max;
	max.reserve(10000);
	max.push_back(a[0]);
	for (int i = 1; i < n; ++i) {
		if (a[i] <= max.back()) {
			max.push_back(a[i]);
		}
		else {
			for (int j = 0; j < max.size(); ++j) {
				if (max[j] < a[i]) {
					max[j] = a[i];
					break;
				}
			}
		}
	}

	cout << max.size() << endl;

	return 0;
}

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

int main(){
  ll n;
  cin>>n;
  int x=0,t=n;
  REP(i,8){
    x+=t%10,t/=10;
  }
  if (n%x==0)
  {
    /* code */
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  }

Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0;
for bj in b:
    ai = bisect.bisect_left(a, bj);
    ck = n - bisect.bisect_right(c, bj);
    ans += ai * ck;
print(ans)


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

int main(){
  int A,B,C,X,N;
  int sum = 0;
  cin >> A >> B >> C >> X;
  for(int n=0;n<=A;n++){
    for(int m=0;m<=B;m++){
      for(int k=0;k<=C;k++){
        if(n*500+m*100+k*50==X){
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 2e9 + 7;
//const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 998244353;
const int N = 2e5 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) { return lower_bound(C + 1, C + len, v) - C; }
void initC() { sort(C + 1, C + clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/



int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    string s, t; cin >> s >> t;
    int w1 = s.size(),w2 = t.size();
    int res = inf;
    f(i, 0, w1 - w2) {
        int tmp = 0; int k = 0;
        f(j, i, i + w2 - 1) {
            if (s[j] != t[k])tmp++; k++;
        }
        res = min(res, tmp);
        //cout << i << " " << tmp << '\n';
    }
    cout << res;
#ifdef local
    int end = clock();
    //cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
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++)
typedef int64_t Int;

Int power(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main() {
    Int N, M;
    cin >> N >> M;
    map<Int,Int> f;
    vector<Int> P(M), Y(M);
    vector<vector<Int>> G(N);

    rep(i,M) {
        cin >> P[i] >> Y[i];
        P[i]--;
        f[Y[i]] = i;
        G[P[i]].push_back(Y[i]);
    }

    vector<string> distnum(M, "");

    rep(i,N) {
        if (G[i].size() != 0) {
            sort(G[i].begin(),G[i].end());
            rep(j,G[i].size()) {
                rep(k,6) {
                    distnum[f[G[i][j]]] += ('0' + ((i+1)/power(10,5-k))%10);
                }
                rep(k,6) {
                    distnum[f[G[i][j]]] += ('0' + ((j+1)/power(10,5-k))%10);
                }
            }
        }
    }

    rep(i,M) cout << distnum[i] << endl;

}

Measured memory_bytes: 21760
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

bool isprime(int x){
    if(x==2){
        return true;
    } 
    else if(x%2==0){
        return false;
    }
    int i=3;
    while(i<=sqrt(x)){
        if(x%i==0){
            return false;
            break;
        }
        i=i+2;
    }
    return true;
}
int main(){
    int n,ans=0; cin>>n;
    vector<int>c(n,0);
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        if(isprime(c[i])){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, px = 0, py = 0, pt = 0;
	cin >> n;
	while(n--){
		int t, x, y; cin >> t >> x >> y;
		int d = abs(px - x) + abs(py - y);
		//dbg(d, t - pt);
		if(d > t - pt || d % 2 != (t - pt) % 2){
			cout << "No" << endl;
			return 0;
		}
		px = x; py = y; pt = t;
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
def inputlist():
    return [int(i) for i in input().split()]


def main():
    A, B, C, D = inputlist()
    boolTurnTaka = True
    while A > 0 and C > 0:
        if boolTurnTaka:
            C -= B
            boolTurnTaka = False
        else:
            A -= D
            boolTurnTaka = True

    if A <= 0:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


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

int main() {
    int n,w;
    cin>>n>>w;
    long long int val[n],weight[n];
    for(int i=0;i<n;++i)
    {
        cin>>weight[i]>>val[i];
    }
    long long int m[n+1][w+1]; //m[i][j] denotes the maximum value taking max weight limit of j and considering i elements  
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(i==0 || w==0)
            m[i][j]=0; 
            else if(weight[i-1] <= j)
            {
                m[i][j]=max(m[i-1][j-weight[i-1]] + val[i-1] , m[i-1][j]);
            }
            else
            m[i][j]=m[i-1][j];
            
            //cout<<m[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<m[n][w];
	return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>

int main(void){

  int r,g,b;
  scanf("%d %d %d", &r, &g, &b);
  if ((r*100+g*10+b)%4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a;
ll dp[103][4][2];

ll func(int x, int k, int m){
	if(k<0){
		return 0;
	}

	if(x==a.size()){
		if(!k){
			return 1;
		}
		else{
			return 0;
		}
	}
	
	if(dp[x][k][m]!=-1){
		return dp[x][k][m];
	}
	ll ans = 0;
	if(m==1){
		for(int i=0;i<10;i++){
		    ans+=func(x+1,k-(i!=0),1);
		}
	}
	else{
		for(int i=0;i<=a[x];i++){
		    ans+=func(x+1,k-(i!=0),(i!=a[x]));
		}
	}
	return dp[x][k][m] = ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m,k;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		a.pb(s[i]-'0');
	}
	MSET(dp,-1);
	cin>>k;
	cout<<func(0,k,0);
	return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rf(i,n) for(int i=0;i<(int)n;i++)
#define rff(i,a,n) for(int i=a;i<=(int)n;i++)
#define rv(i,a,n) for(int i=n;i>=a;i--)
#define ff first
#define ss second
#define PI acos(-1.0)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x) push_back(x)
#define eb(x) emplace_back(x) 
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define Sort(a) sort(a.begin(),a.end())
#define mem(arr,a) memset(arr,a,sizeof arr)
#define ins(a) insert(a)
#define max2(a,b) max(a,b)
#define max3(a,b,c) max(a,max(b,c));
#define min2(a,b) min(a,b)
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};
*/
ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;

int main()
{
    FIO;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin>>a>>b>>c;
    if((c-(a-b))<=0)cout<<0<<endl;
    else cout<<(c-(a-b))<<endl;




    return 0;
}
 

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n, a, b, c;
    static int A,B,C;
    public static void main(String[] args) {
        while(read()){

        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            solve();
        }
        return true;
    }

    static void solve(){
        if(a != 0 && b != 0 && c!= 0){
            A = a * a;
            B = b * b;
            C = c * c;
            if(A == B + C){
                System.out.println("YES");
            }else if(B == A + C){
                System.out.println("YES");
            }else if(C == A + B){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }

}

Measured memory_bytes: 34460
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll x;cin>>x;
    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3624
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- readInts
	let
		c' = min c $ a + b + 1
	print $ b + c'

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <numeric>

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

ll f(ll A, ll C, ll D)
{
    return A - (A / C) - (A / D) + A / lcm(C, D);
}

int main()
{
    ll A, B, C, D, ans;
    cin >> A >> B >> C >> D;

    cout << f(B, C, D) - f(A - 1, C, D) << endl;

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    long long dp[n][3];
    for( int i = 0; i < n;i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for( int i = 1; i < n; i++ ) {
        dp[i][0] = a[i] + max( dp[i-1][1], dp[i-1][2] );
        dp[i][1] = b[i] + max( dp[i-1][0], dp[i-1][2] );
        dp[i][2] = c[i] + max( dp[i-1][1], dp[i-1][0] );
    }
    cout << max(dp[n-1][0], max( dp[n-1][1], dp[n-1][2] )) << '\n';
    return 0;
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
int A[N], B[N], v[N], ans[N], rt;
vector <int> bn[N], bi[N];
int dfs(int t)
{
    int ls = 0; v[t] ^= bi[t].size();
    if ((!(bi[t].size() & 1))) ls = t;
    for (int i = 0; i < bi[t].size(); ++ i)
    {
        int nw = dfs(bi[t][i]);
        if (nw)
        {
            if (ls) bn[ls].push_back(nw), bn[nw].push_back(ls), ls = 0;
            else ls = nw;
        }
    }
    return ls;
}
void solve(int t, int v)
{
    ans[t] = v;
    for (int i = 0; i < bn[t].size(); ++ i)
        if (!ans[bn[t][i]]) solve(bn[t][i], -v);
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> A[i];
    for (int i = 1; i <= n; ++ i) cin >> B[i];
    for (int i = 1; i <= n; ++ i)
        if (A[i] == -1) rt = i; else bi[A[i]].push_back(i);
    dfs(rt);
    for (int i = 1; i <= n; ++ i) bi[i].clear();
    for (int i = 1; i <= n; ++ i)
        if (B[i] == -1) rt = i; else bi[B[i]].push_back(i);
    dfs(rt);

    for (int i = 1; i <= n; ++ i)
        if (v[i] & 1) return puts("IMPOSSIBLE"), 0;
    for (int i = 1; i <= n; ++ i)
        if (!ans[i] && (!(bi[i].size() & 1))) solve(i, 1);
    puts("POSSIBLE");
    for (int i = 1; i <= n; ++ i) cout << ans[i] << " "; cout << endl;
}


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

class UnionFind
{
    int par[100002], rank[100002];

public:
	UnionFind(int n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (x == par[x]) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main()
{
    int n, m;
    cin >> n >> m;
    int x[100002], y[100002], z[100002];
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i] >> z[i];
        x[i]--;
        y[i]--;
    }
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        uf.unite(x[i], y[i]);
    }
    set<int> s;
    for(int i = 0; i < n; i++){
        s.insert(uf.find(i));
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S, A;
	cin >> S;
	int N = S.size();
	A = "abcdefghijklmnopqrstuvwxyz";
	vector<int> t(26);
	REP(i, N){
		t.at(S.at(i) - 'a') += 1;
	}
  if(N == 26){
		REP(i, 26){
			int tmp = S.at(25-i) - 'a';
      t.at(tmp) = 0;
			while(tmp < 25){
        tmp++;
        if(t.at(tmp) == 0){
          cout << S.substr(0,25-i) << A.at(tmp) <<endl;
          return 0;
        }
			}
		}
		cout << -1 << endl;
	}else{
		int min_n = 26;
		REP(i, 26){
			if(t.at(i) == 0){
				min_n = min(min_n, i);
			}
		}
		cout << S << A.at(min_n) << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    string N,ans;
    
    cin >> N;
    
   
    if(N[0]==N[1]&N[1]==N[2]) ans ="Yes";
    
    else if (N[1]==N[2]&N[2]==N[3]) ans ="Yes";
   
    
    else ans = "No";

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll T = 26;

ll D;
vector<ll> C;
vector< vector<ll> > S;
vector<ll> A, B;
ll HighScore;

unsigned long xor128()
{
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123; 
    unsigned long t=(x^(x<<11));x=y;y=z;z=w;
    return (w=(w^(w>>19))^(t^(t>>8)));
}

void input()
{
    cin >> D;

    C.assign(D, 0);
    rep (t, T) { cin >> C[t]; }

    S.assign(D, vector<ll>(T, 0));
    rep (d, D) { rep (t, T) { cin >> S[d][t]; } }

    A.assign(D, 0);
    B.assign(D, 0);
}

void output()
{
    rep (d, D) { cout << A[d] + 1 << endl; }
}

ll solveImpl(bool isRandom = false)
{
    ll res = 0;
    vector<ll> L(T, 0);

    rep (d, D)
    {
        ll xx = 0, tt = 0;

        rep (t, T)
        {
            const ll r = isRandom ? (xor128() % 1000LL) : 0;
            const ll x = S[d][t] + (d + 1 - L[t]) * C[t] + r;
            if (xx <= x) { xx = x; tt = t; }
        }

        B[d] = tt;
        L[tt] = d + 1;

        res += S[d][tt];
        rep (t, T) { res -= C[t] * (d + 1 - L[t]); }
    }

    return res;
}

void solve()
{
    HighScore = solveImpl();
    rep (d, D) { A[d] = B[d]; }

    rep (i, 100)
    {
        const ll score = solveImpl(true);
        // cerr << "HighScore: " << HighScore << ", Score: " << score << endl;

        if (HighScore < score)
        {
            HighScore = score;
            rep (d, D) { A[d] = B[d]; }
        }
    }
}

int main()
{
    input();

    solve();

    output();

    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
using namespace std;
 
int main() {
    string N;
    cin >> 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;
    }
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(void){
  int n, l;
  cin >> n >> l;
  
  vector<int> a(n);
  rep(i, n) a[i] = l+i;
  int s = 0;
  rep(i, n) s += a[i];
  int ans = 1e9;
  rep(i, n) {
    int t = s - a[i];
    if (abs(t-s) < abs(ans-s)) ans = t;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  long int N,D;
  cin >> N >> D;
  long int X,Y,i,ans=0;
  
  for(i=0;i<N;i++){
    cin >> X >> Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  
  cout << ans << endl;
}

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

int main(){
  int N,K,a,answer;
  answer=0;
  cin>>N>>K;
  vector<int> ball(N,0);
  for (int i=0;i<N;i++){
    cin>>a;
    ball.at(a-1)++;
  }
  sort(ball.begin(),ball.end(),greater<int>());
  for (int i=0;i<K;i++){
    answer+=ball.at(i);
  }
  cout<<N-answer<<endl;
}


Measured memory_bytes: 1152
#include <stdio.h>

int gakuseki[1000];

int main(void)
{
	int seito;
	int i = 0;
	int j;
	double weight;
	double high;
	
	while (scanf("%d,%lf,%lf", &seito, &weight, &high) != EOF){
		if ((weight / (high * high)) >= 25){
			gakuseki[i] = seito;
			i++;
		}
	}
	for (j = 0; j < i; j++){
		printf("%d\n", gakuseki[j]);
	}
	
	return (0);
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
long long brr[1000000];
int main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin >>arr[i];
        brr[i] = arr[i] +brr[i-1];
    }
    for(int i=1;i<=n;i++){
        brr[i]=(brr[i] - i%k +k)%k;
    }
    map<long long ,int >mp;
    long long sum =0;
    for(int i=0;i<=n;i++){
        if(i>=k){
            mp[brr[i-k]]--;
        }
        sum+=mp[brr[i]];
        mp[brr[i]]++;
    }cout<<sum<<endl;
    return 0;

}



Measured memory_bytes: 18432
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL n, a[202020];
LL sum = 0;
int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    LL ans = HINF<LL>();
    LL nsum = 0;
    REP(i, n){
        ans = min(ans, abs((sum - nsum) - nsum));
        nsum += a[i];
    }
    ans = min(ans, abs((sum - nsum) - nsum));
    cout << ans << endl;
}

Measured memory_bytes: 1792
S = input()
N = len(S)
l = [0] * (N + 1)

for i in range(N):
    if S[i] == '<':
        l[i + 1] = max(l[i + 1], l[i] + 1)
for i in range(N)[::-1]:
    if S[i] == '>':
        l[i] = max(l[i], l[i + 1] + 1)

print(sum(l))
# print(l)


Measured memory_bytes: 23336
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
const int N = 1e5+20;
struct edge { int ver,next; } e[N*2];
int n,k,t,Head[N],val[N];
inline void insert(int x,int y) { e[++t] = (edge){y,Head[x]} , Head[x] = t; }
inline void input(void)
{
    scanf("%d",&n);
    for (int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        insert( y , x );
        insert( x , y );
    }
    scanf("%d",&k);
    for (int i=1;i<=k;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        val[x] = y;
    }
}
inline void solve(void)
{
    priority_queue < pii , vector< pii > , greater< pii > > Heap;
    for (int i=1;i<=n;i++)
        if ( val[i] != -1 )
            Heap.push( make_pair( val[i] , i ) );
    if ( Heap.empty() )
        Heap.push( make_pair( 1 , 1 ) ) , val[1] = 1;
    while ( !Heap.empty() )
    {
        int x = Heap.top().second; Heap.pop();
        for (int i=Head[x];i;i=e[i].next)
        {
            int y = e[i].ver;
            if ( val[y] == -1 )
            {
                val[y] = val[x] + 1;
                Heap.push( make_pair( val[y] , y ) );
            }
        }
    }
}
inline bool check(void)
{
    for (int i=1;i<=n;i++)
        for (int j=Head[i];j;j=e[j].next)
            if ( abs( val[e[j].ver] - val[i] ) != 1 )
                return false;
    return true;
}
int main(void)
{
    memset( val , 0xff , sizeof val );
    input();
    solve();
    if ( check() )
    {
        puts("Yes");
        for (int i=1;i<=n;i++)
            printf("%d\n",val[i]);
    }
    else puts("No");
    return 0;
}


Measured memory_bytes: 3704
<?php
/*
    Problem URL : http://agc004.contest.atcoder.jp/tasks/agc004_b
12-
    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $w);

$arr = array();
$str = str_split($w);
$len = count($str);

for ($i = 0; $i < $len; $i++) {
    $arr[$str[$i]]++;
}

foreach ($arr as $key => $val) {
    if ($val % 2 !== 0) {
        echo "No\n";
        exit;
    }
}
echo "Yes\n";


Measured memory_bytes: 3704