akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  if(x==y){
    cout<<"Yes"<<'\n';
  }
  else if((x==4 ||x==6 ||x==9 ||x==11) && (y==4 || y==6 || y==9 || y==11)){
    cout<<"Yes"<<'\n';
  }
  else if((x==1 ||x==3 ||x==5 ||x==7 ||x==8 ||x==10 ||x==12) && (y==1 ||y==3 ||y==5 ||y==7 ||y==8 ||y==10 ||y==1)){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){

    string a, b;
    int count = 0;

    getline(cin,a);
    getline(cin,b);

    for(int i = 0; i<a.length(); i++){
        if(a[i] != b[i]){
            count ++;
        }
    }

    cout<<count;

    return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n;
    cin >> n;
    vector<ll> v;
    ll ans=0;
    while(n--)

    {

        ll x;
        cin >> x;
        ans+=x;
        if(x%10) v.pb(x);
    }
    if(ans%10==0)
    {

        if(v.size()==0)
        {

            cout << 0;
            return 0;
        }
        sort(all(v));
        ans-=v[0];
    }
    cout << ans;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    n <- readLn
    putStrLn $ unwords $ map show $ solve n

solve :: Int -> [Int]
solve n = head
    [ [h, k, (n * h * k) `div` d]
    | h <- [1 .. 3500]
    , k <- [1 .. h]
    , let d = 4 * h * k - n * (k + h)
    , d > 0
    , (n * h * k) `mod` d == 0
    ]

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k,s;
    std::cin >> k >>s;
    int cnt=0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j<=k; j++) {
                if(i+j<=s && i+j+k>=s)cnt++;
            
        }
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int x, n;
bool exclude[210];

int main() {
    int a;
    cin >> x >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        exclude[a] = true;
    }

    int i = 0;
    while (true) {
        if (x - i >= 0 && !exclude[x - i]) {
            cout << x - i << endl;
            return 0;
        }
        if (!exclude[x + i]) {
            cout << x + i << endl;
            return 0;
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 3596
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    cin >> S;
    string a = "0";
    veci res(S.size()+1,0);
    REP(i,S.size()) {
        if(S[i] == '<') {res[i+1] = res[i] + 1;
        a += '<' + to_string(res[i+1]);}
        else a += '>' + to_string(res[i+1]);
    }
    //cout << a << endl;
    for(int i = S.size()-1; i >= 0; i--) {
        if(S[i] == '>' && res[i] <= res[i+1]) res[i] = res[i+1] + 1; 
    }
    ll ans = 0;
    REP(i,res.size()) ans += res[i];
    cout << ans << endl;
}

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

namespace B.Time_Limit_Exceeded
{
    class Program
    {
        static void Main(string[] args)
        {
            var NT = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var Ci = new List<int>();
            var Ti = new List<int>();
            var min = int.MaxValue;

            for (int i = 0; i < NT[0]; i++)
            {
                var CiTi = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Ci.Add(CiTi[0]);
                Ti.Add(CiTi[1]);
            }

            foreach (var item in Ti.Where(x => x <= NT[1]))
                min = Math.Min(min, Ci[Array.IndexOf(Ti.ToArray(), item)]);

            if (min != int.MaxValue)
                Console.WriteLine(min);
            else
                Console.WriteLine("TLE");
        }
    }
}

Measured memory_bytes: 13280
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll A[3], B[3],flag[4],cnt[4];

int main(void) {
	FOR(i, 0, 3) {
		cin >> A[i] >> B[i];
		flag[A[i]-1] = true;
		flag[B[i] - 1] = true;
		cnt[A[i] - 1]++;
		cnt[B[i] - 1]++;
	}
	FOR(i, 0, 4)if (flag[i] == false) { ct("NO"); return 0; };
	FOR(i, 0, 4)if (cnt[i] == 3) { ct("NO"); return 0; }
	ct("YES");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    if(N/100 == 7 || (N%100)/10 == 7 || N%10 == 7){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3624
fun main(args:Array<String>) {
	var z=1L
	for(i in 0..50){
		size[i] = z
		z = z*2+3
	}
	
	val (n,x)= readLine()!!.split(" ").map {it.toLong()}
	println(runrun(n.toInt(),x))
}

val size = LongArray(51)

fun runrun(n:Int,x:Long): Long{
	return when(x){
		0L -> 0L
		size[n] -> 1L.shl(n+1)-1
		1L -> 0L
		in 2L..1+size[n-1] -> runrun(n-1,x-1)
		2+size[n-1] -> 1+runrun(n-1,size[n-1])
		else -> 1+runrun(n-1,size[n-1])+runrun(n-1,x-size[n-1]-2)
	}
}

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

int main() {
  ll k,a,b,ans=1;
  cin >> k >> a >> b;
  if(b-a<=2){
    cout << k+1 << endl;
    return 0;
  }
  
  ans+=a-1;
  k-=a-1;
  ans+=k%2;
  k-=k%2;
  ans+=(b-a)*k/2;
  

  cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,K,X,Y;
    scanf("%d\n%d\n%d\n%d",&N,&K,&X,&Y);
    if (N>K)
        printf("%d\n", K*X+(N-K)*Y);
    else
        printf("%d\n", N*X);
    return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);

    vector<int> dp(n,1e9);
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(0) - h.at(1));
    for(int i = 2; i < n; i++){
        dp.at(i) = min(dp.at(i-2)+abs(h.at(i)-h.at(i-2)),dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    }
    cout << dp.at(n-1) << endl;
    return 0;   
}


Measured memory_bytes: 1024
#include <iostream>

int main() {
  unsigned int seconds;
  std::cin >> seconds;
  unsigned int hours = seconds / 3600;
  seconds = seconds % 3600;
  unsigned int minutes = seconds / 60;
  seconds = seconds % 60;
  std::cout << hours << ":" << minutes << ":"<< seconds << std::endl;		
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    long long int H, count = 1, ans;
    cin >> H;

    if (H == 1) { ans = 1; goto end; }

    while (H / 2 != 1) {
        H /= 2;
        count++;
    }
    
    ans = pow(2, count + 1) - 1;

    end:

    cout << ans;
}

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

int main()
{
  int k,a,b, c ,d;
    cin >> k;
  a=k/1000;
  b=k/100%10;
  c=k/10%10;
  d=k%10;
  if (a!=b && b!=c && c!=d){
    cout << "Good";
  }
  else {
    cout << "Bad";
  }
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 2005;
char G[maxn][maxn];
int row[maxn][maxn];
int col[maxn][maxn];

int H,W;

int main()
{
    cin >> H >> W;
    getchar();
    _rep(i,1,H){
        fgets(&G[i][1],maxn,stdin);
    }

    _rep(i,0,H+1){
        G[i][0] = '#';
        G[i][W+1] = '#';
    }
    _rep(i,0,W+1){
        G[0][i] = '#';
        G[H+1][i] = '#';
    }

    _rep(i,1,H){
        int inw = 0;
        int l,r;
        _rep(j,0,W+1){
            if(G[i][j] == '#' && inw){
                _rep(k,l,r){
                    row[i][k] = (r-l+1);
                }
                inw = 0;
            }
            else if(G[i][j] == '.' && !inw){
                l = (r = j);
                inw = 1;
            }
            else if(G[i][j] == '.' && inw){
                r++;
            }
        }
    }

    _rep(i,1,W){
        int inw = 0;
        int l,r;
        _rep(j,0,H+1){
            if(G[j][i] == '#' && inw){
                _rep(k,l,r){
                    col[k][i] = (r-l+1);
                }
                inw = 0;
            }
            else if(G[j][i] == '.' && !inw){
                l = (r = j);
                inw = 1;
            }
            else if(G[j][i] == '.' && inw){
                r++;
            }
        }
    }

    int ans = 0;
    _rep(i,1,H){
        _rep(j,1,W){
            ans = max(ans,row[i][j] + col[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    while(n-- > 0){
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double ab = sqrt(pow(xa-xb, 2.0) + pow(ya-yb, 2.0));
 
        if(ab > ra + rb)
            cout << 0 << endl;
        else if(ab >= fabs(ra - rb))
            cout << 1 << endl;
        else if(ra > rb)
            cout << 2 << endl;
        else
            cout << -2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <memory>

using namespace std;

struct node{
    int key;
    shared_ptr<node> prev;
    shared_ptr<node> next;
    /*
    node *prev;
    node *next;
    */
};

shared_ptr<node> head;
//node *head;

void insert(int x)
{
    auto n=make_shared<node>();
    //auto n=new node();
    n->key=x; n->prev=head; n->next=head->next;
    head->next->prev=n;
    head->next=n;
}

void delete_(int x)
{
    auto n=head->next;
    while(n != head && n->key != x){
        n=n->next;
    }
    if(n != head){
        n->prev->next=n->next;
        n->next->prev=n->prev;
    }
    //delete n;
}

void deleteFirst()
{
    auto n=head->next;
    if(n != head){
        head->next=n->next;
        n->next->prev=head;
    }
    //delete n;
}

void deleteLast()
{
    auto n=head->prev;
    if(n != head){
        head->prev=n->prev;
        n->prev->next=head;
    }
    //delete n;
}

int main()
{
    int n;
    char command[16];

    auto print=[]{
        auto nn=head->next;
        bool flag=false;
        while(nn!=head){
            if(flag){
                printf(" ");
            }
            printf("%d", nn->key);
            flag=true;
            nn=nn->next;
        }
        printf("\n");
    };

    head=make_shared<node>();
    //head=new node();
    head->key=-1;
    head->prev=head->next=head;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%s", command);
        if(!strcmp(command, "insert")){
            int x;
            scanf("%d", &x);
            insert(x);
        } else if(!strcmp(command, "delete")){
            int x;
            scanf("%d", &x);
            delete_(x);
        } else if(!strcmp(command, "deleteFirst")){
            deleteFirst();
        } else if(!strcmp(command, "deleteLast")){
            deleteLast();
        }
    }

    print();
    return 0;
}

Measured memory_bytes: 65216
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <sstream>

using namespace std;

int main()
{
	long i, j, k, l;

	int n;

	cin >> n;

	double num = 0;
	float p;
	string str;

	for (i = 0; i < n; i++)
	{
		cin >> p >> str;
		if (str[0] == 'B')
		{
			num += 380000.0f * p;
		}
		else
		{
			num += p;
		}
	}

	cout << num;

	return 0;
}


Measured memory_bytes: 888
#include"bits/stdc++.h"

int INF = 2000000000;
int n;
int m;
int l;
int q;

long int d[300][300];
int ll[300][300];

void Main() {
  std::cin >> n >> m >> l;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = INF;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (d[i][j] <= l) {
        ll[i][j] = 1;
      } else {
        ll[i][j] = n;
      }
    }
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ll[i][j] = std::min(ll[i][j], ll[i][k] + ll[k][j]);
      }
    }
  }

  std::cin >> q;
  for (int i = 0; i < q; i++) {
    int s, t;
    std::cin >> s >> t;

    if (ll[s - 1][t - 1] == n) {
      std::cout << -1 << std::endl;
    } else {
      std::cout << ll[s - 1][t - 1] - 1 << std::endl;
    }
  }
}

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

Measured memory_bytes: 1664
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 int seq[12],n,m,q,ans=0;
 vi query[55];
 
 void ff(){
 	int sum=0,i,j,x;
 	fo(i,0,q){
 		if(seq[query[i][1]]-seq[query[i][0]]==query[i][2])sum+=query[i][3];
 	}
 	/*fo(i,1,n+1){
 		cout<<seq[i]<<" ";
 	}
 	cout<<endl;*/
 	ans=max(ans,sum);
 }



 void f(int num,int place){
	int i,j,x;
	if(place==n+1){
		ff();
		return;
	}
	fo(i,num,m+1){
		seq[place+1]=i;
		f(i,place+1);
	}
 }
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x;
   cin>>n>>m>>q;
   fo(i,0,q){
   		fo(j,0,4){
   			cin>>x;
   			query[i].pb(x);
   		}
   }
   f(1,0);
   cout<<ans<<endl;

   
   
   
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}



int main() {
    li m;
    cin >> m;

    li keta_num = 0;
    li total = 0;
    rep(i, m) {
        li d, c;
        cin >> d >> c;
        keta_num += c;
        total += d * c;
    }
    cout << keta_num - 1 + ((total - 1) / 9) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MAXN = 300000 + 10;
int N, M;
struct node {
	int l, r, x;
} A[MAXN];
int cnt[MAXN];
int tree[MAXN << 2];

inline bool operator < ( node x, node y ) {
	return x.x != y.x ? y.x < x.x : x.l != y.l ? x.l < y.l : x.r < y.r;
}

inline void update( int rt, int l, int r, int x, int y, int d ) {
	if( x <= l && r <= y )
		return void( tree[rt] += d );
	if( r < x || y < l )
		return void();
	int mid = ( l + r ) >> 1;
	if( x <= mid ) update( rt << 1, l, mid, x, y, d );
	if( mid < y ) update( rt << 1 | 1, mid + 1, r, x, y, d );
}

inline int query( int rt, int l, int r, int x ) {
	if( l == x && l == r )
		return tree[rt];
	if( r < x || x < l )
		return 0;
	int mid = ( l + r ) >> 1, res = 0;
	if( x <= mid ) res += query( rt << 1, l, mid, x );
	else res += query( rt << 1 | 1, mid + 1, r, x );
	res += tree[rt];
	return res;
}

int main() {
	register int i, j;
	int tail;
	scanf( "%d%d", &N, &M );
	for( i = 1; i <= N; ++i )
		scanf( "%d%d", &A[i].l, &A[i].r ), A[i].x = A[i].r - A[i].l + 1, update( 1, 0, M, A[i].l, A[i].r, 1 );
	std::sort( A + 1, A + N + 1 );
	tail = 0;
	for( i = M; i; --i ) {
		while( tail < N && A[tail + 1].x >= i )
			++tail, update( 1, 0, M, A[tail].l, A[tail].r, -1 );
		cnt[i] = tail;
		for( j = 0; j <= M; j += i )
			cnt[i] += query( 1, 0, M, j );
	}
	for( i = 1; i <= M; ++i )
		printf( "%d\n", cnt[i] );
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}
int main()
{
    int n,c=0,ans=0;
    string s;
    read(n);cin>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='R')
            c++;
    for(int i=0;i<c;i++)
    {
        if(s[i]=='W')
            ans++;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n;
  cin>>n;
  string ans="No";
  r(i,n/4+2){
    r(j,n/7+2){
      if(4*i+7*j==n){ans="Yes";break;}
    }
  }

  cout<<ans<<endl;





return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
int dp[1111111];
int n,m;
int main(){
  //  freopen("tt.in","r",stdin),freopen("tt.out","w",stdout);
    cin>>n>>m;
    for(int i=0;i<(1<<n);i++)dp[i]=inf;dp[0]=0;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        int st=0;
        for(int j=1,tt;j<=b;j++){
            cin>>tt;tt--;
            st|=(1<<tt);
        }
        for(int j=0;j<(1<<n);j++)dp[j|st]=min(dp[j|st],dp[j]+a);
    }
    if(dp[(1<<n)-1]==inf)cout<<-1<<endl;else
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	vector<int> n(3);
	for(int i=0; i<3; i++){
		cin >> n.at(i);
	}
	sort(n.begin(), n.end());

	int ans = n.at(0) + n.at(1) + n.at(2)*10;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    string s,t; cin >> s >> t;
    string ans;
    for(int i = 0;i < n;i++){
        cout << s[i] << t[i];
    }
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N;
	cin >> N;
	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	map<ll, ll> cnt;

	ll ans = 0;
	for (ll i = N; i >= 1; i--) {
		ans += cnt[i + A[i]];
		cnt[i - A[i]]++;
	}

	cout << ans << endl;
	
	system("PAUSE");
}


Measured memory_bytes: 27784
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll tc;cin>>tc;while(tc--)
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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...);
}
int main(){
    fastio;
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k){
    	cout<<s<<endl;
    }
    else{
    	cout<<s.substr(0,k)+"...\n";
    }
    return 0;
}    


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

int main() {
  int N;
  cin >> N;
  
  if (N <= 9) {
    cout << N;
  } else if (N <= 99) {
    cout << 9;
  } else if (N <= 999) {
    cout << 9 + (N - 99);
  } else if (N <= 9999) {
    cout << 9 + 900;
  } else if (N <= 99999) {
    cout << 9 + 900 + (N - 9999);
  } else {
    cout << 9 + 900 + 90000;
  }
}

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

using namespace std;

const int N = 1e5 + 10;

int n;
long long x, a[N];

int main (int argc, char const *argv[]) {
    scanf("%d %lld", &n, &x);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", a + i);
    }
    long long moves = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] > x) {
            moves += a[i] - x;
            a[i] = x;
        }
    }
    for (int i = 2; i <= n; ++i) {
        if (a[i] + a[i - 1] > x) {
            long long now = a[i] + a[i - 1] - x;
            moves += now;
            if (now <= a[i]) {
                a[i] -= now;
            } else {
                a[i - 1] -= now - a[i];
                a[i] = 0;
            }
        }
    }
    printf("%lld\n", moves);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <tuple>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

double eps = 1e-8;

struct point {
    double x, y;
    point operator+(const point &p) {
        return {x + p.x, y + p.y};
    }
    point operator-(const point &p) {
        return {x - p.x, y - p.y};
    }
};

struct line {
    // ax + by + c = 0
    double a, b, c;
};

struct circle {
    point p;
    double r;
};

double distance(point A, point B, int deg) {
    point C = B - A;
    return pow(C.x*C.x + C.y*C.y, 0.5 * deg);
}

line line_2points(point P, point Q) {
    return {P.y - Q.y, Q.x - P.x, P.x*Q.y - P.y*Q.x};
}

bool line_intersection(line l, line m) {

}

vector<point> circle_intersection(circle A, circle B) {
    vector<point> ret;
    point X = A.p;
    B.p = B.p - A.p;
    A.p = {0, 0};

    if (distance(A.p, B.p, 2) - pow(A.r + B.r, 2) > eps) return ret;

    double K = (B.p.x*B.p.x + B.p.y*B.p.y + A.r*A.r - B.r*B.r) / 2;
    double SQ = (B.p.x*B.p.x + B.p.y*B.p.y)*A.r*A.r - K * K;
    double DS = distance(A.p, B.p, 2);
    //cerr << K _ SQ _ DS << endl;
    if (abs(SQ) < eps) {
        ret.push_back({K*B.p.x / DS + X.x, K*B.p.y / DS + X.y});
        return ret;
    }
    ret.push_back({(K*B.p.x + B.p.y*sqrt(SQ)) / DS + X.x,
                   (K*B.p.y - B.p.x*sqrt(SQ)) / DS + X.y});
    ret.push_back({(K*B.p.x - B.p.y*sqrt(SQ)) / DS + X.x,
                   (K*B.p.y + B.p.x*sqrt(SQ)) / DS + X.y});
    return ret;
}
 
int main() {
    int q;
    cin >> q;
    while (q--) {
        point p[4];
        for (int i = 0; i < 4; i++) {
            cin >> p[i].x >> p[i].y;
        }
        line s0 = line_2points(p[0], p[1]);
        line s1 = line_2points(p[2], p[3]);
        //cout << s0.a _ s0.b _ s0.c _ s1.a _ s1.b _ s1.c << endl;
        if (abs(s0.a * s1.b - s0.b * s1.a) == 0) {
            cout << 2 << endl;
        }
        else if (abs(s0.a * s1.a + s0.b * s1.b) == 0) {
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;



/*素数のみの配列を返す*/
vector<ll> Eratosthenes(ll n,vector<ll>& arr){
    
    for(ll i = 0; i < n;i++){
        arr[i] = 1;
    }
    arr[0] = arr[1] = 0;
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
               arr[i *(j + 2)] = 0;
            }
        }
    }
    vector<ll> prime;
    for(int i = 2;i < arr.size();i++){
        if(arr[i]){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){

    ll n;
    ll num = 55555LL;
    cin >> n;
    vector<ll> arr(num);
    vector<ll> ans;
    arr = Eratosthenes(num,arr);
    
    REP(i,arr.size()){
        if(arr[i] % 10 == 1){
            ans.push_back(arr[i]);
        }
    }

    REP(i,n){
        if(i == 0){
            cout << ans[i];
        }else{
            cout << " " << ans[i];
        }
    }
    cout << endl;



    return 0;
}

Measured memory_bytes: 768
from itertools import permutations

n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
x, y = 0, 0
perm = list(permutations(list(range(1, n+1))))
# print(perm)
for i in perm:
    if i == a:
        x = perm.index(i)
    if i == b:
        y = perm.index(i)
print(abs(x-y))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        int arr[n];
        ll sum[n];
        for(int i=0;i<n;i++)
        {
            sum[i] = 0;
            cin>>arr[i];
        }
        for(int i= n-1;i>=0;i--)
        {
            if(i==n-1)
            {
                sum[i] = arr[i];
            }
            else
            {
                sum[i] = (sum[i+1]+arr[i])%mod;
            }
        }
        ll ans = 0;
        for(int i=0;i<n-1;i++)
        {
            ans = (ans+(arr[i]*sum[i+1])%mod)%mod;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 5960
#include <bits/stdc++.h>
using namespace std;
int pr[7] = {2, 3, 5, 7, 11, 13, 17};
int main(){
	long long val = 1;
	vector<long long> divs;
	divs.push_back(1);
	for(int i = 0; i < 7; i++){
		long long p = 1;
		int crt = 0;
		while(p <= 300)
			p *= pr[i], crt++;
		p /= pr[i];
		crt--;
		val *= p;
		int len = divs.size();
		for(int j = crt; j >= 1; j--){
			for(int k = 0; k < len; k++){
				divs.push_back(divs[k] * p);
			}
			p /= pr[i];
		}
	}
	int q; cin >> q;
	vector<pair<int,int> > ops;
	for(int i = 0; i < q; i++){
		int m, x; cin >> m >> x;
		ops.push_back({m, x});
	}
	long long ans = 0;
	for(auto e : divs){
		assert(val % e == 0);
		map<int, long long> cnt;
		for(int j = 0; j < q; j++){
			bool ok = true;
			int m, x; tie(m, x) = ops[j];
			for(int k = 0; k < 7; k++){
				long long px = 1;
				while(m % pr[k] == 0){
					 m /= pr[k];
					 px *= pr[k];
				}
				if(e % px != 0) ok = false;
			}
			if(ok) cnt[m] += x;
		}
		long long sum = 0;
		for(auto g : cnt){
			if(g.second > 0 || g.first == 1){
				sum += g.second;
			}	
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <limits.h>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <string>
using namespace std;

int main(void){
  int n;
  long long max = 0,min = 1000000000;
  cin >> n;
  long long a[100];
  for(int i = 0; i < n ; ++i){
    cin >> a[i];
  }
  for(int i = 0;i < n;++i){
    if(max < a[i])
      max = a[i];
    if(min > a[i])
      min = a[i];
  }
  long long ans = abs(max - min);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<sstream>
using namespace std;

string J(string str){
    char tmp = str[str.size() - 1];
    for(int i = str.size() - 1; i > 0; i--) str[i] = str[i - 1];
    str[0] = tmp;
    return str;
}

string C(string str){
    char tmp = str[0];
    for(int i = 0; i < str.size() - 1; i++) str[i] = str[i + 1];
    str[str.size() - 1] = tmp;
    return str;
}
string E(string str){
    string s1, s2;
    int strSize = str.size() / 2;
    if(str.size() % 2 != 0) strSize++;
    s2 = str.substr(strSize);
    s1 = str.substr(0, s2.size());
    if(str.size() % 2 == 0) return s2 + s1;
    else return s2 + str[str.size() / 2] + s1;
}

string A(string str){
    reverse(str.begin(), str.end());
    return str;
}

string P(string str){
    stringstream ss;
    for(int i = 0; i < str.size(); i++){
        if(isalpha(str[i])){
            ss <<str[i];
        } else{
            int tmp = str[i] - '0';
            tmp--;
            if(tmp == -1) tmp = 9;
            ss <<tmp;
        }
    }
    return ss.str();
}

string M(string str){
    stringstream ss;
    for(int i = 0; i < str.size(); i++){
        if(isalpha(str[i])){
            ss <<str[i];
        } else{
            int tmp = str[i] - '0';
            tmp++;
            if(tmp == 10) tmp = 0;
            ss <<tmp;
        }
    }
    return ss.str();

}
int main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i++){
        string str, ser;
        cin >>ser >>str;
        reverse(ser.begin(), ser.end());
        for(int i = 0; i < ser.size(); i++){
            switch(ser[i]){
                case 'J':
                    str = J(str); break;
                case 'C':
                    str = C(str); break;
                case 'E':
                    str = E(str); break;
                case 'A':
                    str = A(str); break;
                case 'P':
                    str = P(str); break;
                case 'M':
                    str = M(str);
            }
        }
        cout <<str <<endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int ban,i,j;
	int date[4];
	char s[3];
	for(i=0;i<4;i++) date[i]=0;
	while(scanf("%d,%s",&ban,s)!=EOF) {
		if(strcmp(s,"A")==0) date[0]++;
		else if(strcmp(s,"B")==0) date[1]++;
		else if(strcmp(s,"AB")==0) date[2]++;
		else if(strcmp(s,"O")==0) date[3]++;
	}
	for(i=0;i<4;i++) printf("%d\n",date[i]);
	return 0;
}

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

namespace DifferentStrokes0130
{
    public struct happy
    {
        public long takahashi;
        public long aoki;
        public long sum;
    }
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            List<happy> dish = new List<happy>();
            happy tad = new happy();
            long happy_sum = 0;
            long happy_aoki_sum = 0;
            for (var i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                tad.takahashi = long.Parse(input[0]);
                tad.aoki = long.Parse(input[1]);
                tad.sum = long.Parse(input[0])+ long.Parse(input[1]);
                dish.Add(tad);
                happy_sum+= long.Parse(input[0]) + long.Parse(input[1]);
                happy_aoki_sum += long.Parse(input[1]);
            }
            //
            var sorted_dish = dish.OrderBy(x => -x.sum).ToList(); // 高橋くんと青木さんの幸福度の合計の降順
            //
            long happy_TA = 0;
            for(var i=0;i<dish.Count;i+=2)
            {
                happy_TA += sorted_dish[i].takahashi+ sorted_dish[i].aoki;
            }
            Console.WriteLine(happy_TA-happy_aoki_sum);
        }
    }
}


Measured memory_bytes: 32192
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

long long combi(long long n, long long k) {
  std::map<std::string, long long> memo;
  if (n == k || k == 0)
    return 1;
  else {
    std::string key = std::to_string(n) + std::to_string(k);
    if (memo.count(key) != 0) {
      return memo[key];
    } else {
      ll out = combi(n - 1, k - 1) + combi(n - 1, k);
      memo[key] = out;
      return out;
    }
  }
}

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


  int n,m; cin >> n >> m;
  if(n>=2 && m>=2) cout << combi(n,2) + combi(m,2) << endl;
  else{
    int tmpn,tmpm;
    if(n<2) tmpn = 0;
    else tmpn = combi(n,2);
    if(m<2) tmpm = 0;
    else tmpm = combi(m,2);
    cout << tmpn + tmpm << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.nextString().toCharArray();
            int n = s.length;
            if (n < 26) {
                outer:
                for (char ss = 'a'; ss <= 'z'; ++ss) {
                    for (char sss : s) if (sss == ss) continue outer;
                    out.println(new String(s) + "" + ss);
                    return;
                }
            } else {
                for (int i = n - 2; i >= 0; i--) {
                    if (s[i] < s[i + 1]) {
                        char best = s[i + 1];
                        for (int j = i + 1; j < n; j++) {
                            if (s[j] > s[i]) {
                                best = (char) Math.min(best, s[j]);
                            }
                        }
                        s[i] = best;
                        out.println(new String(s).substring(0, i + 1));
                        return;
                    }
                }
                out.println(-1);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23252
a = []
while True:
    m,n,o = input().split()
    m=int(m)
    o=int(o)
    if n == "?":
        break
    if n=="+":
    	a.append(m+o)
    elif n=="-":
    	a.append(m-o)
    elif n=="*":
    	a.append(m*o)
    elif n=="/":
    	a.append(int(m/o))
 

for i in a:
	print(i)

Measured memory_bytes: 7572
#include<cstdio>
int main(){
    int n,d,x,a;
    scanf("%d%d%d",&n,&d,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        x+=1+(d-1)/a;
    }
    printf("%d",x);
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c;
    cin >> a >> b >> c;

    // 処理
    int ans = (b / a);
    if (ans > c) {
        ans = c;
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int N;
  int R;
  scanf("%d %d", &N, &R);
  
  int min;
  if(N < 10){
    min = 100 * (10 - N);
    printf("%d\n", R + min);
  }else{
    printf("%d\n", R);
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

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];

    auto itr = std::max_element(a.begin(), a.end());
    long long max_a = *itr;
    a.erase(itr);


    long long pair_a = a[0];
    for(int i = 1 ; i < n-1 ; i ++){
        if(abs(max_a/2 - pair_a) > abs(max_a/2 - a[i]) )
            pair_a = a[i];
    }

    cout << max_a << " " << pair_a << endl;


    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(1 << N); for (auto &a : A) cin >> a;
    vector<array<pair<int, int>, 2>> B(1 << N);
    vector<pair<int, int>> K;
    for (int i = 0; i < (1 << N); i++) {
        if (i == 0) {
            B[i][0] = make_pair(A[0], 0);
            B[i][1] = make_pair(-1e9, -1);
        } else {
            K.clear();
            K.push_back(make_pair(A[i], i));
            for (int j = 0; j < N; j++) {
                if (i & (1 << j)) {
                    K.push_back(B[i ^ (1 << j)][0]);
                    K.push_back(B[i ^ (1 << j)][1]);
                }
            }
            sort(begin(K), end(K), greater<pair<int, int>>());
            B[i][0] = K[0];
            for (int j = 1; j < K.size(); j++) {
                if (K[0] != K[j]) {
                    B[i][1] = K[j];
                    break;
                }
            }
        }
    }
    for (int i = 1; i < (1 << N); i++) {
        int ans = B[i][0].first + B[i][1].first;
        for (int j = N-1; j >= 0; j--) {
            if (i & (1 << j)) {
                int k = (i ^ (1 << j)) | ((1 << j) - 1);
                ans = max(ans, B[k][0].first + B[k][1].first);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 8192