akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadLong();
        var B = sc.ReadLong();
        var X = sc.ReadLong();
        var ans = B / X - Math.Max(0, (A - 1)) / X;
        if (A == 0) ans++;
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main()
{
	ll n,w;
	cin>>n>>w;
	ll wt[n],val[n];
	ll mx_val=0;
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
		mx_val+=val[i];
	}
	ll dp[mx_val+1];
	for(ll i=0;i<=mx_val;i++)
	dp[i]=123456789012;
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=mx_val;j>=val[i];j--)
		{
		dp[j]=min(dp[j],wt[i]+dp[j-val[i]]);
	    }
	}
	ll ans=0;
	for(int i=0;i<=mx_val;i++)
	{
		if(dp[i]<=w)
		ans=i;
	}
	cout<<ans<<"\n";
	
	
}

Measured memory_bytes: 1024
import sys
S = input()

arr = {}

for i in S:
    if i in arr:
        arr[i] += 1
    else:
        arr[i] = 1


if len(arr) > 2:
    print("No")
    sys.exit()

if arr[S[0]] is 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

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


int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }
#include <iomanip>


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

double a,b,h,m;
cin >> a >> b >> h >> m;
double pai = acos(-1);

double mk = m/60;
double hk = (h+mk)/12;

double k = abs(hk-mk)*360;
double r = k*(pai/180);


double a2 = pow(a,2);
double b2 = pow(b,2);
double c = 2 * a * b;


double ans = a2 + b2 -c*cos(r);

cout  << fixed << setprecision(18) << sqrt(ans) << endl;


//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 4232
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        final int n = sc.nextInt();
        final int m = sc.nextInt();

        final int[] a = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
        }

        int sum = Arrays.stream(a).sum();
        System.out.println(sum > n ? -1 : n - sum);
    }
}


Measured memory_bytes: 46340
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int tr[N<<2],h[N],a[N],n,ans;
void pushup(int k)
{
	tr[k]=max(tr[k<<1],tr[k<<1|1]);
}
void update(int k,int l,int r,int x,int v)
{
	if(l==r)
	{
		tr[k]=v;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) update(k<<1,l,mid,x,v);
	else update(k<<1|1,mid+1,r,x,v);
	pushup(k);
}
int query(int k,int l,int r,int a,int b)
{
	if(l==a&&r==b)
		return tr[k];
	int mid=l+r>>1;
	if(b<=mid) return query(k<<1,l,mid,a,b);
	else if(a>mid) return query(k<<1|1,mid+1,r,a,b);
	else return max(query(k<<1,l,mid,a,mid),query(k<<1|1,mid+1,r,mid+1,b));
}
main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		int mx=query(1,1,n,1,h[i])+a[i];
		ans=max(ans,mx);
		update(1,1,n,h[i],mx);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int main(int argc, char *argv[]){
    int n; cin >> n;
    v X(n); rep(i, n) cin >> X[i];
    v Y(n); rep(i, n) Y[i] = X[i];
    sort(all(Y));
    rep(i, n){
        if(X[i] <= Y[(n / 2) - 1]) cout << Y[n / 2] << endl;
        else cout << Y[n / 2 - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str = br.readLine();

        String[] data = str.split("");

        String[] keyence = { "k", "e", "y", "e", "n", "c", "e" };

        int x = 0;
        int y = 0;
        int z = 0;
        int i = 0;
        while (i < keyence.length) {
            if (data[x].equals(keyence[i])) {
                i++;
                x++;
            } else {
                if (y == 0) {
                    x = x + (data.length - keyence.length);
                    y = 1;
                } else {
                    z = 1;
                    break;
                }
            }
        }

        if (z == 1)
            System.out.println("NO");
        else
            System.out.println("YES");
    }
}

Measured memory_bytes: 21332
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
int dp[1006][1005] = {0};
int main(){
  int n, m;
  cin >> n >> m;
  string s;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      if(s[j] == '#') {
        dp[i][j] = 0;
        continue;
      }
      if (i > 0 && j > 0) {
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
      }
      else if (i > 0) {
        dp[i][j] = dp[i - 1][j];
      }
      else if(j > 0) {
        dp[i][j] = dp[i][j - 1];
      }

    }
  }
  cout << dp[n - 1][m - 1] << endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int n;
int cnt[10];
main()
{
    int i,x,ans;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        cnt[min(8,x/400)]++;
    }
    ans = 0;
    for(i=0;i<8;i++) ans += min(1,cnt[i]);
    printf("%d %d",max(1,ans),max(1,ans+cnt[8]));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n+1, 0);
  rep(i, m) {
    int l, r; cin >> l >> r;
    l--, r;
    a[l]++, a[r]--;
  }

  rep(i, n+1) {
    if(i) a[i] += a[i-1];
  }

  int ans = 0;
  rep(i, n+1) {
    if(a[i] == m) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    if (a>=13){
        cout << b<<endl;
    }
    else if (a>=6){
        cout << b/2<<endl;
    }
    else {
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int r = in.nextInt();
        out.println(n >= 10 ? r : r + 100 * (10 - n));
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        char c = scanner.nextLine().charAt(0);

        if(c == 'A'){
            System.out.println('T');
        }else if(c == 'T'){
            System.out.println('A');
        }else if(c == 'G'){
            System.out.println('C');
        }else if(c == 'C'){
            System.out.println('G');
        }

    }

}


Measured memory_bytes: 22996
import math

n = int(input())
aL = list(map(int, input().split(" ")))

MOD = 10**9 + 7

aL2 = [aL[-1]]
for a in reversed(aL[:-1]):
    aL2.append((aL2[-1] + a) % MOD)
aL2 = list(reversed(aL2))

ans = 0
for i in range(n - 1):
    ans += aL[i] * aL2[i + 1]
    ans %= MOD

print(ans)

Measured memory_bytes: 33020
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int a,b;
	cin >> a >> b;
	int ans = 0, sum = 1;
	while(sum<b){
		sum--;
		sum += a;
		ans++;
	}
	cout << ans;


	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int dp[50][420][420];
int n,ma,mb;
int a[50],b[50],c[50];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>ma>>mb;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	memset(dp,63,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		for(int na=0;na<=400;na++){
			for(int nb=0;nb<=400;nb++){
				dp[i+1][na][nb]=min(dp[i+1][na][nb],dp[i][na][nb]);
				dp[i+1][na+a[i+1]][nb+b[i+1]]=min(dp[i+1][na+a[i+1]][nb+b[i+1]],dp[i][na][nb]+c[i+1]);
			}
		}
	}
	int res=2e9;
	for(int tota=ma;tota<=400;tota+=ma){
		for(int i=1;i<=n;i++){
			res=min(res,dp[i][tota][tota/ma*mb]);
		}
	}
	if(res>=1e9)
		res=-1;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 34688
import java.util.*

val sc = Scanner(System.`in`)
val A = sc.nextInt()
val B = sc.nextInt()
val C = sc.nextInt()
val D = sc.nextInt()

fun main(args: Array<String>) {
    println(Math.max(0, arrayOf(B - A, D - C, B - C, D - A).min()!!))
}


Measured memory_bytes: 35900
import java.util.*;
import java.io.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(200000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    private static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    private static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }

}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int[] degree = new int[N];
        for (int n = 0; n < N - 1; n++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            degree[a]++;
            degree[b]++;
        }

        for (int n = 0; n < N; n++) if(degree[n] >= K) {
            System.out.println(0);
            System.exit(0);
        }

        long ans = K;

        ans = Mod.mults(ans, Mod.fact[K - 1], Mod.factInv[K - 1 - degree[0]]);

        for (int n = 0; n < N; n++) if(n != 0 && degree[n] > 1){
            ans = Mod.mults(ans, Mod.fact[K - 2], Mod.factInv[K - 1 - degree[n]]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 66056
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const ll mod = 1e9 + 7;


void solve()
{
    int n,k;
    cin>>n>>k;
    int height[n]={0};
    for (int i = 0; i < n; i++)
    {
        cin>>height[i];
    }
    ll jump[n];
    for (int i = 1; i < n; i++)
    {
        jump[i]=mod;
    }
    
    jump[0]=0;
    
  
    for (int i = 1; i < n; i++)
    {

        for (int j = 1; j <=k; j++)
        {
            if(i-j>=0)
            jump[i]=min(abs(height[i]-height[i-j])+jump[i-j],jump[i]);
        }
        
      
    }
    cout<<jump[n-1]<<endl;
    
}

int main()
{
  
        solve();
     

    return 0;
}

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

vector<string> S = {"Sunny", "Cloudy", "Rainy"};

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	string T; cin>>T;
	int n = find(S.begin(), S.end(), T) - S.begin();
	cout<<(S[(n+1)%3])<<'\n';

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt(); scan.nextLine();
		boolean[] g = new boolean[n];
		boolean[] r = new boolean[m];
		Arrays.fill(g, false);
		Arrays.fill(r, false);

		ArrayList<Character> c = new ArrayList<>();
		char[][] a = new char[n][m];
		for (int i = 0; i < n; i++) {
			String A = scan.nextLine();
				for (int j = 0; j < m; j++) {
					a[i][j] = A.charAt(j);
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a[i][j] == '#') {
					g[i] = true;
				}
			}
		}
		for (int j = 0; j < m; j++) {
			for (int i = 0; i < n; i++) {
				if (a[i][j] == '#') {
					r[j] = true;
				}
			}
		}
		
		for (int i = 0; i < n; i++) {
			if (!g[i]) continue;
			for (int j = 0; j < m; j++) {
				if (!r[j]) continue;
				System.out.print(a[i][j]);
			}
			System.out.println("");
		}

	}
}


Measured memory_bytes: 26064
public class Main {

	private static void solve() {
		int n = ni();
		int y = ni() / 1000;
		
		// a + b + c = n
		//10a + 5b + c = y
		//9a + 4b = y - n
		//b = (y - n - 9a) / 4;
		for (int a = n; a >= 0; a --) {
			int x = y - n - 9 * a;
			if (x >= 0 && x % 4 == 0) {
				int b = x / 4;
				int c = n - a - b;
				
				if (c >= 0) {
					System.out.println(a + " " + b + " " + c);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


Measured memory_bytes: 22356
function Main(input) {
  var list = input.split("\n");
  var nk = list[0].split(" ");
  var N = nk[0];
  var K = nk[1];
  var L = 2*K+1;
  var S = list[1].split("");
  S.map( function(value){
    return parseInt(value);
  })
  
  var count, rev;
  var state = 0;
  var maxcount = 0;
  var Sarray = new Array(0);
  
  count = 0
  state = 1;
  
  for(i=0;i<N;i++){
    if(S[i] != state) {
      state = 1 - state;
      Sarray.push(count);
      count = 1;
    } else count++;
  }
  Sarray.push(count);
  if(Sarray.length == 1) Sarray.push(0);
  if(Sarray.length % 2 == 0) Sarray.push(0);
  
  var ans = 0;
  for(i=0;i<Math.min(Sarray.length,L);i++){
    ans += Sarray[i];
  }
  var tmp;
  var lasttmp = ans;
  var Sn = Sarray.length;
  
  while(Sarray.length > L) {
    tmp = lasttmp - (Sarray[0] + Sarray[1]) + (Sarray[L] + Sarray[L+1]);
    if (tmp > ans) ans = tmp;
    lasttmp = tmp;
    Sarray.shift();
    Sarray.shift();
  }
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15040
import java.util.*;

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

        int n = (R - L) / d;
        if(R % d == 0)
        n = n + 1;
    System.out.println(n);

    }
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool check(int length)
{
    map<string, int> m;
    for(int i = 0; i+length <= n; i++)
    {
        string tmp = s.substr(i, length);
        if(m[tmp])
        {
            if(i+1-m[tmp]>=length) return true;
        }
        else
        {
            m[tmp] = i+1;
        }
    }
    return false;
}

int main()
{
    cin >> n;
    cin >> s;
    int l = 0, r = n;
    while(l <= r)
    {
        int mid = (l+r)>>1;
        if(check(mid)) l = mid+1;
        else r = mid-1;
    }
    cout << r << endl;
}


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

int n, m, a[300005];
int main()
{
	int i, j;
	cin >> n >> m;
	if (n % 2 == 0) {
		printf("%d ", n / 2);
		for (i =1; i < m; i++) printf("%d ", n);
		return 0;
	}
	for (i = 0; i < m; i++) a[i] = (n + 1) / 2;
	i = m - 1;
	for (j = 0; j < m / 2; j++) {
		a[i]--;
		if (a[i] == 0) i--;
		else {
			for (i++; i < m; i++) a[i] = n;
			i = m - 1;
		}
	}
	for (j = m - 1; j >= 0; j--) if (a[j] != 0) break;
	for (i = 0; i <= j; i++) printf("%d ", a[i]);
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long ans = 0;
  if(n%2 == 0){
  	ans = n/2;
    ans *= (n-1);
  }
  else{
    ans = (n-1)/2;
    ans *= n;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct BIT{
    // [1,n]
    int n; vector<ll> bit;
    // ?????????
    BIT(int _n){
        n = _n;
        bit = vector<ll>(n+1,0);
    }
    // sum of [1,i]
    ll sum(int i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    // add x in i-th element
    void add(int i, ll x){
        while(i<=n){
            bit[i] += x;
            i += i & -i;
        }
    }
};

ll query(int x)
{
    printf("? 1 %d\n", x); fflush(stdout);
    ll ret;
    scanf(" %lld", &ret);
    return ret;
}

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

    vector<int> ans(n);

    BIT bit(n);
    for(int i=1; i<=n; ++i) bit.add(i,1);

    ll x = query(n);
    for(int i=n-1; i>0; --i)
    {
        ll y = query(i);
        ll diff = x-y;

        int l=0, r=n;
        while(r-l>1)
        {
            int m = (l+r)/2;
            if(bit.sum(n)-bit.sum(m)<=diff) r=m;
            else l=m;
        }

        // dbg(l);dbg(r);
        ans[i] = r;
        bit.add(r,-1);
        x = y;
    }

    for(int i=1; i<=n; ++i) if(bit.sum(i)-bit.sum(i-1)>0) ans[0] = i;

    printf("!");
    rep(i,n) printf(" %d", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 288940
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func calcAngle(height, base, volume int) float64 {
	area := float64(volume) / float64(base)
	var (
		a float64
		b float64
	)
	switch s := 2*area - float64(height*base); {
	case s == 0: //ぴったりな直角三角形
		a = float64(base)
		b = float64(height)
	case s > 0: //台形
		a = float64(base * base)
		b = float64(2 * (float64(height*base) - area))
	case s < 0: //不足した直角三角形
		a = float64(2 * volume)
		b = float64(height * height * base)
	}
	return math.Atan2(b, a) * (180 / math.Pi)
}

func main() {
	a, b, x := nextInt(), nextInt(), nextInt()
	r := calcAngle(b, a, x)
	fmt.Println(r)
}


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

using namespace std;

typedef long long ll;

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

int n;
int a[100010];
// int b[100010];

int main() {
    cin >> n;
    rep(i, n + 1) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        int b;
        cin >> b;
        int c1 = min(a[i], b);
        int c2 = min(a[i+1], b - c1);
        ans += c1 + c2;
        a[i] -= c1;
        a[i+1] -= c2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, x, mon;
	scanf("%d", &n);
	scanf("%d", &mon);
	for(int i = 1 ; i < n ; i++){
		scanf("%d", &x);
		mon = __gcd(mon, x);
	}
	printf("%d\n", mon);	
		
	return 0;
}

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

using namespace std;

int dp[200005];

int calc(int idx, int c, string& s) {
    if (idx >= s.size()) {
        return 0;
    }
    if (dp[idx] != -1) {
        return dp[idx];
    }
    if (s[idx] == 'x') {
        return dp[idx] = calc(idx + 1, c, s);
    } else {
        return dp[idx] = max(1 + calc(idx + c + 1, c, s), calc(idx + 1, c, s));
    }
}

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        dp[i] = -1;
    }
    int max_days = calc(0, c, s);
    if (max_days > k) {
        cerr << "No answer" << endl;
        return 0;
    } else if (max_days < k) {
        cerr << "Impossible" << endl;
        return 1;
    }

    int scanning = k + 1;
    int last_found = -1;
    int current_barrier = -1;
    int next_barrier = -1;
    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        //cerr << i << " " << dp[i] << endl;
        if (s[i] == 'x') continue;
        if (dp[i] != scanning) {
            current_barrier = next_barrier;
            next_barrier = -1;
            scanning--;
            if (count == 1) {
                cout << last_found + 1 << endl;
            }
            count = 0;
        }
        if (i > current_barrier) {
            count++;
            last_found = i;
            if (next_barrier == -1) next_barrier = i + c;
        }
    }
    if (count == 1) {
        cout << last_found + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 12036
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{

    ll i,j,k,cb=0,ans=0;
    ll n,maxi=0,gcdxx;
    cin>>n>>k;
    vector<ll>v(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        if(v[i]>maxi)
            maxi=v[i];
        if(i==0)
            gcdxx=v[0];
        gcdxx=GCD(gcdxx,v[i]);
    }
    if(debug)
    {
        cout<<gcdxx<<" "<<maxi<<endl;
    }
    if(k%gcdxx==0&&k<=maxi)
        cout<<"POSSIBLE"<<endl;
    else
       cout<<"IMPOSSIBLE"<<endl;

    //cout<<sum<<endl;


    //cout<<endl;
}


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
using namespace std;
struct Card{
    char a;
    int b;
};
bool compare_as_ints(Card i, Card j){ // stable_sort()のため
    return (i.b<j.b);
}
int partition(Card A[], int p, int r){
    Card x=A[r];
    int i=p-1;
    for(int j=p;j<=r-1;j++){
        if(A[j].b<=x.b){
            i+=1;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
void QuickSort(Card A[], int p, int r){
    if(p<r){
        int q=partition(A, p, r);
        QuickSort(A, p, q-1);
        QuickSort(A, q+1, r);
    }

}
int main(){
    int n;
    cin>>n;

    Card A[100000], B[100000];
    for(int i=0;i<n;i++){
        cin>>A[i].a>>A[i].b;
        B[i]=A[i];
    }
    QuickSort(A, 0, n-1);
    stable_sort(B, B+n, compare_as_ints);
    bool f=true;
    for(int i=0;i<n;i++){
        if(!(A[i].a==B[i].a&& A[i].b==B[i].b)){
            f=false;
            break;
        }
    }
    if(f){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    for(int i=0;i<n;i++){
        cout<<A[i].a<<' '<<A[i].b<<endl;
    }
}


Measured memory_bytes: 4712
#include <iostream>
using namespace std;
#define ll long long int
ll a, b, ans;

int main(){
    cin >> a >> b;
    ll i = a / 4;
    ans = a;
    for (ll f = a+1; f < (i + 1) * 4; f++){
        ans = ans ^ f;
    }
    ll j = b / 4;
    for (ll f = j*4; f <= b; f++){
        ans = ans ^ f;
    }
    if (i!=j) ans = ans ^ 0;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int maxn = 1e5+10;

int n,a[maxn],b[maxn],res,tmpa[maxn],tmpb[maxn];
map<int,int> p,been;

int fin(int u) {
    if (p[u]==u) return u;
    return p[u] = fin(p[u]);
}

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    int sxa=0,sxb=0;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        tmpa[i] = a[i];
        sxa ^= a[i];
    }
    tmpa[n+1] = sxa;
    for (int i=1;i<=n;i++) {
        cin>>b[i];
        tmpb[i] = b[i];
        sxb^=b[i];
    }
    tmpb[n+1]=sxb;
    sort(tmpa+1,tmpa+n+2);
    sort(tmpb+1,tmpb+n+2);
    for (int i=1;i<=n+1;i++)
        if (tmpb[i]!=tmpa[i]) {
            cout<<-1<<endl;
            return 0;
        }
    for (int i=1;i<=n;i++)
        if (a[i]!=b[i]) {
            p[a[i]]=a[i];
            p[b[i]]=b[i];
        }
    for (int i=1;i<=n;i++) res+=(a[i]!=b[i]);
    for (int i=1;i<=n;i++)
        if (a[i]!=b[i]) {
            int u = fin(a[i]);
            int v = fin(b[i]);
            if (u!=v) p[u]=v;
        }
    for (int i=1;i<=n;i++)
        if (a[i]!=b[i]) {
            res += (been[fin(a[i])]==0);
            been[fin(a[i])]=1;
        }
    bool ok = false;
    for (int i=1;i<=n;i++) ok |= (b[i]==sxa && a[i]!=sxa);
    res-=ok;
    cout<<res<<endl;


}


Measured memory_bytes: 15872
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))

ans = [[0 for i in range(w+2)] for i in range(h+2)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i+1][j+1] = '#'
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    if ans[k+1][l+1] != '#':
                        ans[k+1][l+1] += 1
#print(ans)
del ans[0]
del ans[-1]
#print(ans)
for i in range(h):
    del ans[i][0]
    del ans[i][-1]
#print(ans)
for i in range(h):
    print(''.join(map(str,ans[i])))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>

using namespace std;
typedef long long ll;

ll N, X[200001] = {}, Y[200001] = {};

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	stable_sort(X, X + N + 1);
	for (int i = 1; i <= N; i++) {
		if (Y[i] <= X[N / 2]) {
			cout << X[N / 2 + 1] << endl;
		}
		else {
			cout << X[N / 2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5360
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	long long int a;
	cin >> a;
	long long int j = (long long int)sqrt(a);
	for(int i = j;;i--)
	{
		if (a % i == 0)
		{
			cout << (a / i) + i - 2<< endl;
			break;
		}
	}
	return 0;
}

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

int main() {
  int N, i, X, Y, sum;
  sum=0;
  cin >> N;
   for(i=0;i<N;i++){
    cin >> X >> Y;
    sum+= Y-X+1;
   }
  cout << sum <<endl;
}
     

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner sc = new Scanner(System.in);

    private void solve() {
        int S = sc.nextInt();
        int W = sc.nextInt();

        if (W >= S) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }

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


Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
int main(){
 
  int n;cin>>n;
  unordered_map<string,int>mapped;
  while(n--)
  {
    string s;cin>>s;
    mapped[s]++;
    
  }
 cout<<mapped.size();
  
  
  return 0;}

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

int main(){
    int N,Alice,Bob,ans,o;
    Alice = 0;Bob = 0;ans = 0;
    vector<int> A;
    cin >> N ;
    for (int i=0; i < N; i++){
        cin >> o;
        A.push_back(o);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    for (int i=0; i<A.size();i++){
        if (i%2==0){
            Alice = Alice + A[i];
        }
        else{
            Bob = Bob + A[i];
        }
    }
    ans = Alice - Bob;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};


int main(){
    string s;
    cin >> s;
    cout << (s[5] == '0' && s[6] <= '4' ? "Heisei" : "TBD") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int main() {
	int64_t n, k;
	vector<int64_t> a;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int64_t ai;
		cin >> ai;
		a.push_back(ai);
	}
	const int64_t MOD = 1000000007;
	int64_t cnt = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			int64_t ai = a[i];
			int64_t aj = a[j];
			if (ai > aj) {
				cnt += k*(k+1)/2;
			}
			else if(ai<aj){
				cnt += (k-1)*(k)/2;
			}
			cnt %= MOD;
		}
	}
	cout << cnt << endl;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int x;
    cin >> x;
    vector<bool> ex(x + 1);
    ex[1] = 1;
    for (int i = 2; i <= x; i++)
    {
        int a = i * i;
        while (a <= x)
        {
            ex[a] = true;
            a *= i;
        }
    }
    for (int i = x; i > 0; i--)
    {
        if (ex[i])
        {
            c(i);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll n, amax=0, asec=0;
  bool same = false;
  cin >> n;
  ll a[200010];
  rep(i, 0, n){
    cin >> a[i];
    if (amax == a[i]){
      same = true;
    }else if (a[i] > amax){
      asec = amax;
      amax = a[i];
      same = false;
    }else if (a[i] < amax){
      asec = max(asec, a[i]);
    }
  }
  rep(i, 0, n){
    if (same){
      print(amax);
    }else{
      if (a[i] == amax){
        print(asec);
      }else{
        print(amax);
      }
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll bin(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2) % mod)) % mod;
}
void solve()
{
	int x, n;
	cin >> x >> n;
	map<int , int>mp;
	vector<int>v;
	rep(i, 0, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	rep(i, -2, 103) {
		if (mp[i] == 0) {
			v.pb(i);
		}
	}
	sort(v.begin(), v.end());
	auto it = lower_bound(v.begin(), v.end(), x);
	if (it == v.end()) {
		it--;
		cout << (*it);
		return;
	}
	auto it1 = it;
	it1--;
	if (x - (*it1) <= (*it) - x) {
		cout << (*it1);
	}
	else {
		cout << (*it);
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
 
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
 
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
 
int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    REP(n,N) cin >> A[n];
    REP(n,N) cin >> B[n];
    REP(n,N) cin >> C[n];
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    
    vector<int> Bans(N);
    REP(i, N){
      auto b = B[i];
      auto idx = upper_bound(ALL(C), b);
      auto lower = idx - C.begin();
      Bans[i] = N - lower;
      // printf("b, ans = %d, %d\n", b, Bans[i]);
    }

    vector<ll> acc(N);
    ll s = 0;
    for(int i = N-1; i >= 0; --i) {
      s += Bans[i];
      acc[i] = s;
    }

    ll ans = 0;
    REP(i, N){
      auto a = A[i];
      auto idx = upper_bound(ALL(B), a) - B.begin();
      if (idx <= N - 1) {
	ans += acc[idx];
      }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    unsigned long N;
    cin >> N;
    auto k = ((N + 99) % 100 < 12) * 2 + ((N / 100) && (N / 100 <= 12));
    vector<string> ans({"NA", "MMYY", "YYMM", "AMBIGUOUS"});
    cout << ans[k] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(OrdinaryNumber(N, P, 1));
    }
    public static int OrdinaryNumber(int N, int[] P, int index) {
        if (N - 1 <= index) {
            return 0;
        }
        if ((P[index - 1] < P[index] && P[index] < P[index + 1]) ||
            (P[index + 1] < P[index] && P[index] < P[index - 1])) {
            return 1 + OrdinaryNumber(N, P, index + 1);
        }
        return OrdinaryNumber(N, P, index + 1);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    /*
     int n;
     cin >> n;
     vector<int> a(n);
     rep(i, n) cin >> a[i];
     */
    
    int table[100005] = {0};
    rep(i, 100005) table[i] = -1;
    table[0] = 1;
    
    rep(i, 6) {
        rep(j, 100000) {
            if (table[j] == -1) continue;
            if (j + 100 + i < 100005) table[j + 100 + i] = 1;
        }
    }
    
    int x;
    cin >> x;
    
    if (table[x] == 1) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        int[] inputs = {a, b, c};
        Arrays.sort(inputs);
 
        int da = inputs[2] - inputs[0];
        int db = inputs[2] - inputs[1];
 
        if (da % 2 == 0 && db % 2 == 0) {  // even & even
            System.out.println((da / 2) + (db / 2));
        }
        else if (da % 2 == 1 && db % 2 == 1) {  // odd & odd
            System.out.println(((da - 1) / 2) + ((db - 1) / 2) + 1);
        }
        else {  // odd & even
            System.out.println((da / 2) + (db / 2) + 2);
        }
    }
}


Measured memory_bytes: 21972