akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

const double PI = acos(-1);

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

  double ans = 2 * PI * r;

  printf("%.10lf\n", ans);

  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  ll x,k,d;cin>>x>>k>>d;
  x=abs(x);
  ll ans;
  if(x/d>=k)ans=x-k*d;
  else {
    if((k-x/d)%2==0)ans=x%d;
    else ans=d-x%d;
  }
  cout<<ans<<endl;
}

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

int main() {  
  int N;
  int judge = 3;
  cin >> N;

  rep(i, N) {
    string S;
    cin >> S;
    
    if(S == "Y"){
      cout << "Four" << endl;
      judge = 4;
      break;
    }
  }
  
  if(judge == 3){
    cout << "Three" << endl;
  }
}


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

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x%mod;
    else return EX(x*x%mod,n/2)%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> bit(60,0);
    for(int j = 0; j < n; j++){
        for(int i = 0; i < 60; i++){
            if(a[j] & (1ll << i)) bit[i]++;
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll now = 1;
        for(int j = 0; j < 60; j++){
            if(a[i] & (1ll << j)){
                bit[j]--;
                ans += now*(n-i-1-bit[j])%mod;
                ans %= mod;
            } else ans += now*bit[j]%mod;
            now *= 2;
            now %= mod;
        }
    }

    cout << (ans+mod)%mod << endl;

    return 0;
}

Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int mod = 1e9+7;
/*
#define bigint __int128
__int128 abss(__int128 x){if(x>0)return x;
    return -x;
    }
*/
void solve() {ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans = max(max(max(b*d,a*c),a*d),b*c);
cout<<ans<<endl;
    
}
int main()
{boost;
int t;t = 1;//cin>>t;
while(t--){solve();}
}


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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if ( N <= K ) {
    cout << N*X << endl;
  }
  else {
    cout << K*X + (N-K)*Y << endl;
  }
     
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
 
const int maxn = 205;
vi g[maxn];
int dep[maxn], res[maxn];
 
void check(int u, int d, int p){
  dep[u] = d;
  for(int v : g[u]){
    if(v != p && dep[v] != -1 && (d - dep[v] + 1) % 2 == 1){
      cout << -1;
      exit(0);
    }
    if(dep[v] == -1){
      check(v, d + 1, u);
    }
  }
}
 
int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
 
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    for(int j = 0; j < n; j++){
      if(s[j] == '1'){
        g[i].push_back(j);
      }
    }
  }
  memset(dep, -1, sizeof dep);
  check(1, 0, -1);
  int ans = 0;
  for(int i = 0; i < n; i++){
    queue <int> q;
    q.push(i);
    memset(res, -1, sizeof res);
    res[i] = 1;
    while(!q.empty()){
      int u = q.front();
      q.pop();
      for(int v : g[u]){
        if(res[v] == -1){
          q.push(v);
          res[v] = res[u] + 1;
        }
      }
    }
    for(int j = 0; j < n; j++){
      ans = max(ans, res[j]);
    }  
  }
  cout << ans;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N,C;
	cin >> N >> C;
	int D[31][31];
	int Count[3][31];
	for(int i = 1; i <= C; i++){
		for(int j = 1; j <= C; j++){
			cin >> D[i][j];
		}
	}
	for(int i = 1; i <= 30; i++){
		Count[0][i] = 0;
		Count[1][i] = 0;
		Count[2][i] = 0;
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			int C;
			cin >> C;
			Count[(i+j)%3][C]++;
		}
	}
	
	ll ans = LLONG_MAX;
	for(int p = 1; p <= C; p++){
		for(int q = 1; q <= C; q++){
			for(int r = 1; r <= C; r++){
				if(p == q || q == r || r == p){
					continue;
				}
				ll discomfort = 0;
				for(int c = 1; c <= C; c++){
					discomfort += Count[0][c] * D[c][p];
					discomfort += Count[1][c] * D[c][q];
					discomfort += Count[2][c] * D[c][r];
				}
				ans = min(ans, discomfort);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main() {

  string a,b,c;
  cin >> a >> b >> c;
  
  char A = a.at(0)-32;
  char B = b.at(0)-32;
  char C = c.at(0)-32;
  
  cout << A << B << C;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = a + b;
        if (max < a - b)
            max = a - b;
        if (max < a * b)
            max = a * b;
        System.out.println(max);
    }
}

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

int euclid(int n,int m){
  if(m>n){
    swap(n,m);
  }
  if(n%m == 0){
    return m;
  }
  else{
    return euclid(m,n%m);
  }
}


int main(){
  int N;
  cin>>N;
  vector <int> num(N);
  int saisyo;
  int temp;
  cin>>saisyo;
  for(int i = 1;i<N;i++){
    cin>>temp;
    saisyo = euclid(saisyo,temp); 
  }
  cout << saisyo << endl;
  return 0;
}

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

int main(){
  string s;
  int a=0,b=0,c=0,ab=0,d;

  while(cin>>d){
    cin>>s;
    if(s==",A") a++;
    if(s==",B") b++;
    if(s==",O") c++;
    if(s==",AB") ab++;
  }
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<ab<<endl;
  cout<<c<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin >> x;
	long long s = 0;
	if(x >= 500){
		s = (x/500)*1000;
		x = x - x/500 * 500;
	}
	if(x >= 5){
		s+= (x/5)*5;
	}
	cout << s << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,d,x;
    d=0;
    scanf("%d %d %d",&a,&b,&c);
    for(x=a;x<=b;x++){
        if(c%x==0){
            d=d+1;
        }
        };
    printf("%d\n",d);
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A,B,Q;
ll s[(ll)(1e5+5)],t[(ll)(1e5+5)];
ll bisect(ll *to_search,ll l,ll r,ll r_max,ll num){
    if(num>to_search[r_max]) return r_max;
    if(num<to_search[0]) return 0;
    if(r-l<=5){
        ll ret=LLONG_MAX;
        for(int i=l;i<=r;i++){
            if(to_search[i]<=num) ret=i;
        }
        if(ret+1!=r_max+1)
            if(num-to_search[ret]>to_search[ret+1]-num){
                return ret+1;
            } 
        return ret;
    }
    if(num>=to_search[(l+r)/2]){
        return bisect(to_search,(l+r)/2,r,r_max,num);
    }
    else return bisect(to_search,l,(l+r)/2,r_max,num);
}
int main(){ 
    cin>>A>>B>>Q; getchar();
    for(int i=0;i<A;i++) {cin>>s[i]; getchar();}
    for(int i=0;i<B;i++) {cin>>t[i]; getchar();}
    for(int i=0;i<Q;i++){
        ll x;
        cin>>x; getchar();
        ll a=bisect(s,0,A-1,A-1,x);
        ll ans1=abs(s[a]-x)+abs(s[a]-t[bisect(t,0,B-1,B-1,s[a])]);

// cout<<"1."<<ans1<<endl;

        ll b=bisect(t,0,B-1,B-1,x);
        // cout<<ans1<<endl;
        ll bj=b;
        ll ans2=min(ans1,abs(t[(b)]-x)+abs(t[(b)]-s[bisect(s,0,A-1,A-1,t[b])]));
        if(s[a]==x){
            ll xyz=abs(t[b]-s[a]);
        } 
        //找s经过t
        //1.s
        if(s[a]<x){
            if(t[b]>x) b--;
            if(b==-1) b++;
            else if(t[b]>s[a]) ans2=min(ans2,x-min(s[a],t[b]));
        }
        // cout<<"b="<<b<<endl;
    else    if(s[a]>x){
            if(t[b]<x) b++;
            if(b==B) b--;
            else if(t[b]<s[a]) ans2=min(ans2,max(s[a],t[b])-x);
        } 

        b=bj;
        if(s[a]>=x)
        a--;
        else a++;
        if(a==-1) a++;
        if(a==A) a--;


ans2=min(ans2,abs(s[a]-x)+abs(s[a]-t[bisect(t,0,B-1,B-1,s[a])]));
// cout<<"4."<<ans2<<endl;
        if(s[b]>=x)
        b--;
        else b++;
        if(b==-1) b++;
        if(b==B) b--;

ans2=min(ans2,abs(t[(b)]-x)+abs(t[(b)]-s[bisect(s,0,A-1,A-1,t[b])]));
// cout<<"5."<<ans2<<endl;
b=bj;
if(s[a]<x){
            if(t[b]>x) b--;
            if(b==-1) b++;
            else if(t[b]>s[a]) ans2=min(ans2,x-min(s[a],t[b]));
        }
        // cout<<"b="<<b<<endl;
    else    if(s[a]>x){
            if(t[b]<x) b++;
            if(b==B) b--;
            else if(t[b]<s[a]) ans2=min(ans2,max(s[a],t[b])-x);
        } 
cout<<ans2<<endl;
    }
    return 0;
}


//////wa了好久，情况考虑不全！！！！！！！！！！！！！！！！！
/*
二分写得倒挺好的嘛！！！！！！！！！！

一开始只考虑了4（3）种情况！应该有8（6）种情况！！！！！！！！！！！！
*/

Measured memory_bytes: 2816
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	string S; cin >> S;
	REP(i, S.size())cout << "x";
	cout << endl;
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int cnt = 0;
  rep(i,n) {
    if(a[i] < 0) {
      cnt++;
      a[i] = abs(a[i]);
    }
  }
  ll ans = 0;
  sort(all(a));
  rep(i,n) ans += a[i];
  if(cnt % 2) ans -= a[0]*2;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vll vector<ll>
#define sorrt(a) sort(a.begin(), a.end())
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


int32_t main() {
  fastio;
  ll l,r,d;
  cin>>l>>r>>d;
  if(l%d == 0) l--;
  cout<<(r/d - l/d)<<endl;
}


Measured memory_bytes: 3608
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)


m = zombies[0]
for i in range(1, len(zombies)):
    m = gcd(m, zombies[i])

print(m)

Measured memory_bytes: 14224
m, k = gets.split.map(&:to_i)


if k == 0
  a = (0...(1 << m)).to_a
  b = a + a.reverse
  puts b.join(' ')
elsif m == 1 && k > 0
  puts "-1"
elsif k >= (1 << m)
  puts "-1"
elsif m == 0
  puts "0 0"
elsif k == 0
  a = (0...(1 << m)).to_a
  b = a + a.reverse
  puts b.join(' ')
else
  a = []

  hoge = 1 << m

  hoge.times do |i|
    a << i if i != k
  end

  a << k

  (hoge-1).downto(0) do |i|
    a << i if i != k
  end

  a << k

  puts a.join(' ')
end


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

signed main() {
	cin >> s;
	if (s[0]!='A') return cout << "WA" << ln, 0;
	int C = 0;
	reps(i,2,s.size()-1) if (s[i]=='C') C++;
	if (C!=1) return cout << "WA" << ln, 0;
	int b = 0;
	each(i,s) if ('A'<=i && i<='Z') b++;
	if (b!=2) return cout << "WA" << ln, 0;
	cout << "AC" << ln;
}

Measured memory_bytes: 256
/**
*	author: Shaurya Bagga
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long double ld;

#define endl "\n"

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 10;
const double PI = 3.1415926;
const ll INF = 1e18;
const double EPS = 1e-5;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x,y,z,k; cin >> x >> y >> z >> k;
	vector<ll> a(x, 0), b(y, 0), c(z, 0);
	for(int i = 0; i < x; ++i) {
		cin >> a[i];
	}
	for(int i = 0; i < y; ++i) {
		cin >> b[i];
	}
	for(int i = 0; i < z; ++i) {
		cin >> c[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());
	sort(c.begin(), c.end(), greater<ll>());
	vector<ll> all;
	for(int i = 0; i < x; ++i) {
		for(int j = 0; j < y; ++j) {
			for(int h = 0; h < z; ++h) {
				if ((i + 1) * (j + 1) * (h + 1) > k) break;
				all.push_back(a[i]+b[j]+c[h]);
			}
		}
	}
	sort(all.begin(), all.end(), greater<ll>());
	for(int i = 0; i < k; ++i) {
		cout << all[i] << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct PriorityQueue {

    PriorityQueue()
            : mLast(0) {
    }

    void push(ll x) {
        ll index = mLast;
        Q[mLast++] = x;
        while (index > 0) {
            ll parent = (index - 1) / 2;
            if (Q[parent] < Q[index])
                swap(Q[parent], Q[index]);
            index = parent;
        }
    }

    ll top() {
        if (mLast == 0)
            return INF;
        return Q[0];
    }

    void pop() {
        if (mLast == 0)
            return;
        Q[0] = Q[--mLast];
        ll index = 0;
        while (true) {
            ll left = index * 2 + 1, right = index * 2 + 2;
            if (left >= mLast)
                break;
            if (right >= mLast) {
                if (Q[index] < Q[left])
                    swap(Q[index], Q[left]);
                index = left;
                continue;
            }
            if (Q[left] < Q[right]) {
                if (Q[index] < Q[right])
                    swap(Q[index], Q[right]);
                index = right;
            }
            else {
                if (Q[index] < Q[left])
                    swap(Q[index], Q[left]);
                index = left;
            }
        }
    }

    void debug() {
        ll s = 0;
        ll p = 2;
        REP(i, mLast) {
            cout << Q[i] << " ";
            if (s == i) {
                cout << endl;
                s += p;
                p *= 2;
            }
        }
    }

    ll Q[200005];
    ll mLast = 0;
};

PriorityQueue PQ[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll t, x;
            cin >> t >> x;
            PQ[t].push(x);
        }
        else if (q == 1) {
            ll t;
            cin >> t;
            ll top = PQ[t].top();
            if (top == INF)
                continue;
            cout << top << endl;
        }
        else {
            ll t;
            cin >> t;
            PQ[t].pop();
        }
        
    }

    return 0;
}


Measured memory_bytes: 8676
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W,H,x,y,r;
        W = sc.nextInt();
        H = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        r = sc.nextInt();
        if( r <= x && x <= (W-r) && r <= y && y <= (H-r)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26404
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<map> 
using namespace std;
int a[100005];
map<int,int>mp;
string st="CODEFESTIVAL2016";
int main()
{
	char s[20];
	scanf("%s",s);
	int ans=0;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]!=st[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int x, y;
    cin>>x>>y;
    vector<int> v;
    while(x--){
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    int sum=0;
    for(int i=0; i<y; i++){
        sum+=v[i];
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d""%d""%d",&a,&b,&c);
  if(a==b&&b==c&&c==a)
  printf("No\n");
  else if(a!=b&&b!=c&&c!=a)
  printf("No\n");
  else
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

#define all(c) (c).begin(), (c).end()

template<typename T> T gcd(T a, T b){return b? gcd(b, a % b): a;}
template<typename T> T lcm(T a, T b){return a / gcd(a, b) * b;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& e: a)cin >> e;
    cout << accumulate(all(a), a[0], lcm<int>) << '\n';
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define int long long
using namespace std;

int N,Q;
int a[100010];

bool check(int i,int x)
{
    if(a[i]<x) return false;

    int first=N-i;
    int second=i-(lower_bound(a,a+N,2*x-a[i])-a)+1;
    return first<=second;
}

signed main()
{
    cin>>N>>Q;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
    vector<int> S(N+1),T(N+1);
    for(int i=0;i<N;i++){
        S[i+1]+=S[i]+a[i];
        T[i+1]=(i>=1? T[i-1]:0)+a[i];
    }
    
    while(Q--){
        int x; cin>>x;
        int ng=0,ok=N;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            if(check(mid,x)){
                ok=mid;
            }else{
                ng=mid;
            }
        }
        int ans=(S[N]-S[ok])+T[max(0LL,N-(N-ok)*2)];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

ll cnt(ll a, ll b,ll c){return b/c - a/c;}
int main(){
    LL(a,b,c,d);
    ll e = lcm(c,d);
    a--;
    cout << b - a - cnt(a,b,c) - cnt(a,b,d) + cnt(a,b,e) << endl; 
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    
    double sum, ans;

    for(int i=0; i<k; i++) sum += p[i];

    ans = sum;
    
    for(int i=0; i<n-k; i++){
        sum += p[i+k]-p[i];
        ans = max(ans, sum);
    }
    ans += k;

    ans /= 2.0;
    printf("%.10lf\n", ans);

    return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,A;
int ans,judge = 0;
  cin >> N;
  
  for(int i=0;i<N;i++){
  cin >> A;
  judge = 0;
    while(A%2 == 0){
     A /=2;
     judge++;
    }
    if(judge == 0){
     ans == 0;
     break;
    } else if(i == 0 || ans >= judge) {
     ans = judge; 
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextLong()
    val a = IntArray(n) { sc.nextInt() }

    val lastVisit = LongArray(n) { 0L }

    var cur = 1
    var i = 0L
    while (i < k) {
        if (lastVisit[cur - 1] != 0L) {
            //println("loop detected!")
            val loopStart = lastVisit[cur - 1]
            val loopSize = i - loopStart
            //println("loopStart: $loopStart")
            //println("loopSize: $loopSize")
            //println("cur: $cur")
            i = ((k - loopStart) / loopSize) * loopSize + loopStart
            break
        }
        lastVisit[cur - 1] = i
        cur = a[cur - 1]
        i++
    }
    //println("i: $i")
    while (i < k) {
        cur = a[cur - 1]
        i++
    }
    println(cur)
}


Measured memory_bytes: 60360
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int a;
  vector<int> rate(9);
  int min = 0;
  int max;
 
  for(int i = 0; i < N; i++){
    cin >> a;
    if(a < 3200){
      rate.at(a / 400)++;
    }
    else{
      rate.at(8)++;
    }
  }
 
  for(int i = 0; i < 8; i++){
    if(rate.at(i)){
      min++;
    }
  }
 
  max = min + rate.at(8);
 
  cout << (min==0?1:min) << " " << max << endl;
 
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
sum = 0
takoyakis = gets.split(' ').map(&:to_i)
(0...n).each do |i|
  tako1 = takoyakis[i]
  (0...n).each do |j|
    next if i == j
    tako2 = takoyakis[j]
    sum += tako1 * tako2
  end
end
puts sum/2

Measured memory_bytes: 1788
s = input()

ans = "Yes"

for i in range(len(s)):
        if i%2 == 0:
                if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
                        ans = "No"
        if i%2 == 1:
                if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
                        ans = "No"

print(ans)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  int ans;
  rep(i,n+1){
    if(i<10) ans++;
    else if(i<100);
    else if(i<1000) ans++;
    else if(i<10000);
    else if(i<100000) ans++;
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 384
def a():
    data_set=[]
    while True:
        s=input().split()
        data_set.append(s)
        if ["0","0"] in data_set:
            break
    data_set=data_set[:-1]
    import itertools
    for i in data_set:
        count=0
        n=int(i[0])
        x=int(i[1])
        num=list(itertools.combinations(range(1,n+1),3))
        for j in num:
            if sum(j)==x:
                count+=1
        print(count)
a()


Measured memory_bytes: 31432
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 1;
    for (int i = 0; i < N; i++) {
        if (ans*2 > N)break;
        ans*=2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
def dfs(root):
  dist = [-1]*(n+1)
  dist[root] = 0
  stack = [root]
  while stack:
    x = stack.pop()
    for y in graph[x]:
      if dist[y] == -1:
        dist[y] = dist[x]+1
        stack.append(y)
  return dist
d = dfs(1)
far = d.index(max(d))
diam = max(dfs(far))
if diam%3 in (0,2):
  print("First")
else:
  print("Second")

Measured memory_bytes: 118916
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main()
{
	string str;
	int q;
	bool reverse = false;
	cin >> str >> q;
	deque < char > dq;
	for(ll i=0, lim = str.length(); i < lim; i++)
		dq.pb(str[i]);
	while(q--)
	{
		int t;
		cin >> t;
		if(t==1)
		{
			reverse = !reverse;
		}
		else
		{
			int x;
			char c;
			cin >> x >> c;
			if(x == 1 && reverse)
				dq.pb(c);
			else if(x == 1 && !reverse)
				dq.push_front(c);
			else if(x == 2 && reverse)
				dq.push_front(c);
			else
				dq.pb(c);

		}
	}
	if(reverse)
	{
		while(!dq.empty())
		{
			cout << dq.back();
			dq.pop_back();
		}
		cout << endl;
	}
	else
	{
		while(!dq.empty())
		{
			cout << dq.front();
			dq.pop_front();
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

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

int dis, n, k, o;

int main(){
  while(scanf("%d", &dis) && dis){
    scanf("%d%d", &n, &o);
    vi d;
    int in;
    d.PB(0);
    rep(i, n-1){
      scanf("%d", &in);
      d.PB(in);
    }
    sort(d.begin(), d.end());

    int res = 0;
    rep(i, o){
      scanf("%d", &k);
      int l = 0, h = n, m;
      while(l <= h){
	m = (l+h)/2;
	if(d[m] == k) break;
	else if(d[m] > k) h = m - 1;
	else if(d[m] < k) l = m + 1;
      }
      res += min(abs(d[m]-k), min(abs(d[(m-1)<0?n-1:m-1]-k), (m+1)>=n?dis-k+d[0]:abs(d[m+1]-k)));
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
const int maxn=2e5+5;
const int inf=1e9+7;
int mx[maxn<<2], lazy[maxn<<2];
int n, m, t;
vector<int>g[maxn];
void build(int k, int lef, int rig){
    if(lef==rig){
        mx[k]=t-lef+1; return;
    }
    int mid=(lef+rig)>>1;
    build(k<<1,lef,mid); build(k<<1|1,mid+1,rig);
    mx[k]=max(mx[k<<1],mx[k<<1|1]);
}
void pushDown(int k){
    if(lazy[k]){
        mx[k<<1]+=lazy[k]; mx[k<<1|1]+=lazy[k];
        lazy[k<<1]+=lazy[k]; lazy[k<<1|1]+=lazy[k];
        lazy[k]=0;
    }
}
void update(int k, int lef, int rig, int l, int r, int c){
    if(l<=lef&&r>=rig){
        mx[k]+=c; lazy[k]+=c;
        return;
    }
    pushDown(k);
    int mid=(lef+rig)>>1;
    if(l<=mid) update(k<<1,lef,mid,l,r,c);
    if(r>mid) update(k<<1|1,mid+1,rig,l,r,c);
    mx[k]=max(mx[k<<1],mx[k<<1|1]);
}
int query(int k, int lef, int rig, int l, int r){
    if(l<=lef&&r>=rig){
        return mx[k];
    }
    pushDown(k); int ans=-inf; int mid=(lef+rig)>>1;
    if(l<=mid) ans=max(ans,query(k<<1,lef,mid,l,r));
    if(r>mid) ans=max(ans,query(k<<1|1,mid+1,rig,l,r));
    return ans;
}
int main(){
    scanf("%d%d",&n,&m); t=m; int l, r; build(1,1,t);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&l,&r), g[r].push_back(l);
        if(l) update(1,1,t,1,l,-1);
    }
    int ans=0; int sum=0;
    for(int i=1;i<=t;i++){
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]) update(1,1,t,1,g[i][j],1); sum++;
        }
        ans=max(ans,query(1,1,t,1,i)-(t-i)-sum);
    }
    printf("%d\n",n-(m-ans)); 
    return 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, z;
    cin >> n >> z;
    vector<pair<P, int> > a(n);
    REP(i,n){
        int s, t, c;
        cin >> s >> t >> c;
        a[i] = make_pair(P(s,t), c-1);
    }
    sort(ALL(a));
    VI s(n), t(n), c(n);
    REP(i,n){
        s[i] = a[i].first.first;
        t[i] = a[i].first.second;
        c[i] = a[i].second;
    }

    int ans = 0;
    VI en, ch;
    REP(i,n){
        bool found = false;
        REP(j,ans){
            if (ch[j] == c[i] || en[j] < s[i]){
                found = true;
                ch[j] = c[i];
                en[j] = t[i];
                break;
            }
        }
        if (!found){
            ans++;
            en.push_back(t[i]);
            ch.push_back(c[i]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    bool keyence=false;
    for(int i=0;i<s.size();++i) for(int j=i;j<s.size();++j){
        string t=s;
        t.erase(t.begin()+i,t.begin()+j);
        if(t=="keyence") keyence=true;
    }
    if(keyence) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< bool > ans(N, true);
    for(int i=0; i<K; i++){
        int d;
        std::cin >> d;
        for(int j=0; j<d; j++){
            int a;
            std::cin >> a;
            ans[a-1] = false;
        }
    }
    
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(ans[i]){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}



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

bool taken[26];

int main(){
	string s;
	cin >> s;
	if(s.size() < 26){
		for(int i = 0; i < s.size(); i++){
			taken[s[i]-'a'] = true;
		}
		for(int i = 0; i < 26; i++){
			if(!taken[i]) {
				s += (char)(i+'a');
				cout << s << endl;
				return 0;
			}
		}
	} else {
		if(s == "zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
			return 0;
		}
		string s2 = s;
		next_permutation(s2.begin(),s2.end());
		for(int i = 0; i < s2.size(); i++){
			cout << s2[i];
			if(s2[i] != s[i]) {
				cout << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

namespace ConsoleApplication1
{
    class Node
    {
        internal int key;
        internal int parentId;
        internal int leftId;
        internal int rightId;

        public Node(int i, int k)
        {
            key = k;
            parentId = i / 2;
            leftId = i * 2;
            rightId = i * 2 + 1;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int h = int.Parse(Console.ReadLine());
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Node[] A = new Node[h + 1];

            for (int i = 0; i < h; i++) A[i + 1] = new Node(i + 1, input[i]);

            StringBuilder sb;
            for (int i = 1; i <= h; i++)
            {
                sb = new StringBuilder();
                sb.Append("node " + i + ": key = " + A[i].key + ", ");
                if (A[i].parentId >= 1) sb.Append("parent key = " + A[A[i].parentId].key + ", ");
                if (A[i].leftId <= h) sb.Append("left key = " + A[A[i].leftId].key + ", ");
                if (A[i].rightId <= h) sb.Append("right key = " + A[A[i].rightId].key + ", ");
                Console.WriteLine(sb);
            }
        }
    }
}

Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int n;
   cin >> n;
   while (n)
   {
      if (n % 10 == 9)
      {
         cout << "Yes" << endl;
         return 0;
      }
      n /= 10;
   }
   cout << "No" << endl;

   return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int64_t> X(N);
  int64_t av=0;
  for(int i=0;i<N;++i){
    cin>>X[i];
    av += X[i];
  }

  av /= N;
  int64_t min1=0,min2=0;
  for(int i=0;i<N;++i){
    min1 += (X[i]-av)*(X[i]-av);
    min2 += (X[i]-av-1)*(X[i]-av-1);
  }

  cout<<min(min1,min2)<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

bool chmax(int &a,int b){if(a<b){a=b;return 0;}return 1;}
bool chmin(int &a,int b){if(a>b){a=b;return 0;}return 1;}

int n,m;
vec2(g,100000,0);
vector<int> d(100000,-1);

int DP(int x){
   if(d[x]!=-1) return d[x];
  if(g[x].empty()){d[x]=0;return 0;}
  for(auto y:g[x]){
  	chmax(d[x],DP(y)+1);
  }
  return d[x];
}

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin>>n>>m;
  int x,y;
  rep(i,m){
  	cin>>x>>y;
    x --;
    y --;
    g[x].push_back(y);
  }
  
  rep(i,n){
    if(d[i]==-1) DP(i);
  }
 cout<<*max_element(all(d))<<'\n';
  
}

Measured memory_bytes: 42752
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ;
	cin >> n ; 
	vi a(n) ; re(a);
	sort(all(a));
	int mx = a.back();
	int hf = 0 ;
	for(int i = 0 ; i < n ; ++i){
		if(a[i] > mx/2){
			if(i==0) hf = a.front();
			else if(mx - a[i] > a[i-1]) hf = a[i];
			else hf = a[i-1];
			break;
		}
	}
	cout << mx << ' ' << hf << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();

		System.out.println("" + s1.toUpperCase().charAt(0)
							+ s2.toUpperCase().charAt(0)
							+ s3.toUpperCase().charAt(0));

		sc.close();


	}
}




Measured memory_bytes: 23636
t = 0
h = 0
for _ in range(int(input())):
    n = list(input().split())
    if n[0] > n[1]:
        t += 3
    elif n[1] > n[0]:
        h += 3
    else:
        t += 1
        h += 1
print("%d %d" % (t, h))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
    
#define int long long
#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define all(x) ((x).begin(), (x).end())
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(), (x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n, k;
    cin >> n >> k;
    vector<char> v(k);
    REP(i, k){
        cin >> v[i];
    }

    FOR(i, n, INF){
        string s=to_string(i);
        bool f=1;
        REP(j, s.length()){
            REP(t, k){
                if(s[j]==v[t]){
                    f=0;
                }
            }

            if(!f){
                break;
            }
        }

        if(f){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int H,W; cin>>H>>W;
	vector<string> field(H);
	for(int i=0;i<H;i++)cin>>field[i];
	int kuro=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(field[i][j]=='#')kuro++;
		}
	}
	queue<pair<int,int>> que;
	que.push(make_pair(0,0));
	vector<vector<int>> dist (H,vector<int>(W,-1));
	dist[0][0]=1;
	while(!que.empty()){
		pair<int,int> now=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			pair<int,int> nv=make_pair(now.first+dy[i],now.second+dx[i]);
			if(nv.first<0 || nv.first>=H || nv.second<0 || nv.second>=W)continue;
			if(dist[nv.first][nv.second]!=-1 || field[nv.first][nv.second]=='#')continue;
			que.push(make_pair(nv.first,nv.second));
			dist[nv.first][nv.second]=dist[now.first][now.second]+1;
		}
	}
	int ans;
	if(dist[H-1][W-1]==-1)ans=-1;
	else ans=H*W-dist[H-1][W-1]-kuro;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[2][6010][2];
lint mo=1000000007;
int main()
{
	int n,m;
	cin>>n>>m;
	n--;m--;
	memset(dp,0,sizeof(dp));dp[0][0][1]=1;
	REP(i,0,n) dp[0][i+1][0]=1;
	rep(i,m){
		int now=i%2,ne=1-now;
		memset(dp[ne],0,sizeof(dp[ne]));
		rep(j,n+m+1){
			//cout<<i<<' '<<j<<' '<<dp[now][j][0]<<' '<<dp[now][j][1]<<endl;
			dp[now][j][0]%=mo;
			dp[now][j][1]%=mo;
			REP(k,-1,2){
				int t=1;if(k==0) t=2;
				if(j+k<0 || j+k>n) continue;
				if(j+k==0){
					dp[ne][j+k][1]+=(dp[now][j][1]+dp[now][j][0])*t;
				}
				else{
					dp[ne][j+k][0]+=dp[now][j][0]*t;
					dp[ne][j+k][1]+=dp[now][j][1]*t;
				}
			}
		}
	}
	lint out=0;
	rep(i,6005){
		out+=dp[m%2][i][1];out%=mo;
	}
	cout<<(out*4)%mo<<endl;
}


Measured memory_bytes: 384