akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    int a,b,c;
    scanf("%d%d%d", &a,&b,&c);
    
    if(a==b && b==c){
        printf("No");
    }else if(a==b || b==c || c==a){
        printf("Yes");
    }else{
        printf("No");
    }   

    
    return 0;

}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
vector<P>v;
int kj[1000006],kji[1000006];
int rw[1000006];

int modpow(int a,int x,int mod){
	int res=1;
	while(x){
		if(x&1)res=res*a%mod;
		a=a*a%mod;
		x>>=1;
		}
	return res;
	}
void kjinit(){
	kj[0]=1;
	for(int i=0;i<1000003;i++){
		kj[i+1]=kj[i]*(i+1)%mod;
		kji[i]=modpow(kj[i],mod-2,mod);
		}
	}
int comb(int r,int c){
	int res=kj[r]*kji[c]%mod;
	return res*kji[r-c]%mod;
	}
signed main(){
	int n;cin>>n;
	kjinit();
	int n2=(n-2)/2,n1=n&1;
	while(n2>=0){
//		cout<<n1<<' '<<n2<<endl;
		rw[n1+n2]=(kj[n-n2-n1-2]*comb(n1+n2,n1)%mod)*kj[n1+n2+1]%mod;
		n2--;n1+=2;
		}
		
	int cnt=0;	
	for(int i=n-2;i>0;i--){
		rw[i]=(rw[i]-rw[i-1]+mod)%mod;
		cnt+=rw[i]*(i+1);
		cnt%=mod;
		}	
	cnt+=rw[0];cnt%=mod;	
	cout<<cnt<<endl;	
	}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> v{a, b, c};
  sort(v.begin(), v.end());

  cout << v.at(0) << " " << v.at(1) << " " << v.at(2) << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    
    int turn = 0;
    while(true) {
        if (s[turn].size() <= 0) {
            put((char)('A' + turn));
            break;
        }
        int nxt = s[turn][0] - 'a';
        s[turn] = s[turn].substr(1);
        turn = nxt;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int s[500100];
int N;
int dp[500100];

int main(){
  cin >> N;
  string ss;
  cin >> ss;
  ss = "00" + ss + "00";
  N += 4;
  for(int i = 0; i < N; i++){
    if(ss[i] == '1') s[i] = 1;
    else s[i] = 0;
  }
  fill(dp, dp+N+1, 0);

  for(int i = 2; i < N;){
    if(s[i-1] == 1 && s[i] == 0 && s[i+1] == 1){
      dp[i] = dp[i-1];
      int a = i-1, b = i+1;
      while(s[a] == 1){
        a--;
      }
      dp[i+1] = max(dp[a-1]+(i-a-1), dp[a+1]+(i-a-2));

      while(s[b] == 1){
        dp[b] = max(dp[b], dp[i-2] + (b-i));
        b++;
      }
      i++;
    }
    else{
      dp[i] = max(dp[i], dp[i-1]);
      i++;
    }
  }

/*
  for(int i = 0; i < N; i++){
    cout << dp[i] << " ";
  }
*/

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<vector>
#include<cctype>
#include<cstdio>
#include<cstring>
using namespace std;


int main() {
    char number[1001];
    char num;
    int sum = 0;
    while (1) {
        scanf("%s", number);
        if (number[0] == '0') break;
        for (int i=0; i<strlen(number); ++i) {
            sum += number[i] - '0';
        }
        printf("%d\n", sum);
        sum = 0;
    }
    return 0;
}



Measured memory_bytes: 3224
//ITP1_6_D
#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int m,n,i,j,c=0,s;
	
	cin>>n>>m;

	int A[101][101];
	int b[101];
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>s;
			A[i][j]=s;
			}
		}
	
	for(i=0;i<m;i++){
		cin>>s;
		b[i]=s;
		}
	
	for(i=0;i<n;i++,c=0){
		for(j=0;j<m;j++){
			c+=(A[i][j])*(b[j]);
			}
		cout<<c;
		cout<<endl;
		}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double r ;
	cin >> r ;
	double pi = 3.1415926535 ;
	cout << setprecision(10) << 2*pi*r;
 	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
bool judge(){
    string n;
    cin >> n;
    for(int i=0;i<n.length();i++){
        if(n[i]=='7')return true;
    }
    return false;
}
int main()
{   
    if(judge()){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	var ans int
	for i := 0; i < k; i++ {
		ans += l[i]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int a,b,c,A,B,C,X,co;
    co = 0;
    scanf("%d\n%d\n%d\n%d",&A,&B,&C,&X);
    for(a = 0;a <= A;a++){
        for(b = 0;b <= B;b++){
            for(c = 0;c <= C;c++){
                if(a * 500 + b * 100 + c * 50 == X) co++;
            }
        }
    }
    printf("%d\n",co);
	return 0;
}

Measured memory_bytes: 1724
def solve(a, b):
    return "Yay!" if (max(a, b) <= 8) else ":("

assert solve(5, 4) == "Yay!"
assert solve(8, 8) == "Yay!"
assert solve(11, 4) == ":("

a, b = map(int, raw_input().split())
print solve(a, b)

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

int main(){
	int n;
	cin >> n;
	int x[n] = {};
	int y[n] = {};

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

	for (int i = 0; i < n; i++){
		cin >> y[i];
	}

	double d1 = 0, d2 = 0, d3 = 0, dm = 0;
	for (int i = 0; i < n; i++){
		d1 += fabs(x[i] - y[i]);
	}

	for (int i = 0; i < n; i++){
		d2 += pow(x[i] - y[i], 2);
	}
	d2 = sqrt(d2);

	for (int i = 0; i < n; i++){
		d3 += pow(fabs(x[i] - y[i]), 3);
	}

	d3 = pow(d3, 1.0/3.0);

	for (int i = 0; i < n; i++){
		if (dm < fabs(x[i] - y[i])) dm = fabs(x[i] - y[i]);
	}

	printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, dm);

	return 0;

}


Measured memory_bytes: 3312
#include<stdio.h>
int main(){
	int n,x,i,j,k,ans;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)		break;
		ans=0;
		for(i=1; i<=n; i++){
			for(j=i+1; j<=n; j++){
				for(k=j+1; k<=n; k++){
					if(i+j+k == x)	ans++;
					
					
				}
			
			}
		}
		printf("%d\n",ans);
	}
	
	return 0;
}


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

int main(void)
{
	string str;
	getline(cin, str);
	while (str.find("apple") != -1) str.replace(str.find("apple"), 5, "tempa");
	while (str.find("peach") != -1) str.replace(str.find("peach"), 5, "tempp");
	while (str.find("tempa") != -1) str.replace(str.find("tempa"), 5, "peach");
	while (str.find("tempp") != -1) str.replace(str.find("tempp"), 5, "apple");
	cout << str << endl;
	return 0;
}


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

using namespace std;

int N, M, X[100000], d[100000];

int main()
{
	cin >> N >> M;
	for (int i = 0; i < M; ++i)
	{
		cin >> X[i];
	}
	if (N >= M)
	{
		cout << 0 << endl;
		return 0;
	}
	sort(X, X + M);
	for (int i = 0; i < M - 1; ++i)
	{
		d[i] = X[i + 1] - X[i];
	}
	sort(d, d + M - 1);
	cout << X[M - 1] - X[0] - accumulate(d + M - N, d + M - 1, 0) << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int short_hand=in.nextInt();
        int long_hand=in.nextInt();
        int hour=in.nextInt();
        int minutes=in.nextInt();

        double pai=Math.PI;

        double x=Math.abs(hour*pai/6+minutes*pai/360-minutes*pai/30);  //计算其中度数

        double cos_x=Math.cos(x);   //得到余弦值

        double result_pow2= short_hand*short_hand+long_hand*long_hand-2*short_hand*long_hand*cos_x;

        double result=1.0;
        while(Math.abs(result-result_pow2/result)>1e-10)

        {
            result=(result+result_pow2/result)/2;

        }
        System.out.println(result);




    }
}

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

int main() {
    int64_t H, W;
    cin >> H >> W;
    vector<vector<int64_t>> A(H, vector<int64_t>(W));
    for (int64_t i = 0; i < H; i++) {
        for (int64_t j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    vector<vector<int64_t>> B(H, vector<int64_t>(W));
    for (int64_t i = 0; i < H; i++) {
        for (int64_t j = 0; j < W; j++) {
            cin >> B[i][j];
        }
    }

    vector<vector<int64_t>> C(H, vector<int64_t>(W));
    for (int64_t i = 0; i < H; i++) {
        for (int64_t j = 0; j < W; j++) {
            C[i][j] = abs(A[i][j] - B[i][j]);
        }
    }

    constexpr int64_t VALUE_MAX = 80 * 80;
    vector<vector<vector<bool>>> can_reach(H, vector<vector<bool>>(W, vector<bool>(VALUE_MAX, false)));
    can_reach[0][0][C[0][0]] = true;
    stack<tuple<int64_t, int64_t, int64_t>> st;
    st.push(make_tuple(0, 0, C[0][0]));

    while (!st.empty()) {
        tuple<int64_t, int64_t, int64_t> top = st.top();
        st.pop();
        int64_t h, w, c;
        tie(h, w, c) = top;

        //右に遷移
        if (w < W - 1) {
            for (int64_t new_cost : {c + C[h][w + 1], abs(c - C[h][w + 1])}) {
                if (can_reach[h][w + 1][new_cost] || new_cost >= VALUE_MAX) {
                    continue;
                }
                can_reach[h][w + 1][new_cost] = true;
                st.push(make_tuple(h, w + 1, new_cost));
            }
        }

        //下に遷移
        if (h < H - 1) {
            for (int64_t new_cost : {c + C[h + 1][w], abs(c - C[h + 1][w])}) {
                if (can_reach[h + 1][w][new_cost] || new_cost >= VALUE_MAX) {
                    continue;
                }
                can_reach[h + 1][w][new_cost] = true;
                st.push(make_tuple(h + 1, w, new_cost));
            }
        }
    }

    for (int64_t i = 0; i < VALUE_MAX; i++) {
        if (can_reach[H - 1][W - 1][i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 7808
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n,m;
int a[100005];
int b[200005],c[100005],cnt=0;

void s0(){
	int s=n;
	b[++cnt]=1;-- s;
	for(int i=1;i<=m-1;i++)b[++cnt]=a[i], s -= a[i];
	if(s==0)return ;
	s>>=1;
	
	for(int i=1;i<=s/2;i++)b[++cnt]=2;b[++cnt]=1;
	for(int i=1;i<=s-s/2;i++)b[++cnt]=2;
} // 1 a[1] .. a[m-1] 2 2 .. 2 1 2 .. 2 2

void s1(){
	for(int i=1;i<=a[1]/2;i++)b[++cnt]=2;
	for(int i=2;i<=m;i++)b[++cnt]=a[i];
	b[++cnt]=1;
} // 2 2 .. 2 a[2] .. a[m] 1

void s2(){
	b[++cnt]=a[1]+1;
	for(int i=2;i<m;i++)b[++cnt]=a[i];
	for(int i=1;i<=a[m]/2;i++)b[++cnt]=2;
} // a[1]+1 a[2] .. a[m] 2 2 .. 2 2

int main(){
	int od=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]), od += (a[i]&1);
	if(od>2)return puts("Impossible"),0;
	
	int cnt2=0;
	for(int i=1;i<=m;i++)
		if(a[i]&1)c[++ cnt2]=i;
	if(cnt2>=1)swap(a[1],a[c[1]]);
	if(cnt2>=2)swap(a[m],a[c[2]]);
	for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
		
	if(cnt2==0)s0();
	if(cnt2==1)s1();
	if(cnt2==2)s2();
	
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)printf("%d ",b[i]);puts("");

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 40;

int main() {
  int K, N;
  while (cin >> K >> N) {
    vector<int> ans;
    if (K % 2 == 0) {
      ans.push_back(K / 2);
      for (int i = 0; i < N - 1; i++) {
        ans.push_back(K);
      }
    } else {
      for (int i = 0; i < N; i++) {
        ans.push_back((K + 1) / 2);
      }
      for (int t = 0; t < N / 2; t++) {
        if (ans.back() == 1) {
          ans.pop_back();
        } else {
          ans.back() -= 1;
          while (ans.size() < N) {
            ans.push_back(K);
          }
        }
      }
    }
    for (int x : ans) {
      cout << x << " ";
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
	int arr[3];
	cin >>arr[0]>>arr[1]>>arr[2];
	sort (arr, arr+3);
	if ((arr[2]-arr[1])==(arr[1]-arr[0])) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 16
using namespace std;

//N人が01 2^n通り: j = 0 ~ 2^n 
//k人目がhonest : k-1桁目が1

//①bits② i = 0~n (i-1)人目がhonestでないならcontinue
//③ j = 0~A[i] iの証言
//④ bitの(x[i][j] -1) = 0:1
//④y[i][j] = iの証言

//①仮定bit
//② honestである(i-1)人目
//if(!(bit&(1<<(i-1))) continue;
//③(i-1)人目のj 個の証言
//④(i-1)の証言y[i][j]と 仮定の(x[i][j]-1)の01が一致するか
// ((bit >> (x[i][j]-1))&1) 
// y[i][j]

int a[16];
int x[16][16];
int y[16][16];
int n;

int cunter(int x){
    if(x==0) return 0;
    return cunter(x >> 1) + (x&1);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    int ans = 0;
    for(int i =1; i<=n;i++){
        cin>>a[i];
        for(int j =1;j <= a[i]; j++){
            cin>>x[i][j]>>y[i][j];
        }
    }

    for(int bit = 1;bit < (1<<n); bit++){
        bool flag = true;
        for(int i =1; i<=n; i++){
            if(!(bit&(1 << (i-1)))) continue;
            for(int j =1; j <= a[i]; j++){
                if(((bit >> (x[i][j]-1)) &1)^y[i][j]) flag = false;
            }
        }
        if(flag) ans = max(cunter(bit),ans);
    }
    cout<< ans <<endl;
}


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

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int v1[]=new int[n/2];
		int v2[]=new int[n/2];

		for(int i=0;i<n/2;++i){
			v1[i]=sc.nextInt();
			v2[i]=sc.nextInt();
		}

		int v1max=0, v1sec=0, v1num1=v1[0], v1num2;
		int v2max=0, v2sec=0, v2num1=v2[0], v2num2;
		Arrays.sort(v1);
		Arrays.sort(v2);

		for(int i=0;i<n/2;++i){
			int sum=1;
			for(; i<n/2-1&&v1[i]==v1[i+1] ;++i){
				++sum;
			}
			if(v1max<sum){
				v1sec=v1max;
				v1max=sum;
				v1num1=v1[i];
			}
			else if(v1sec<sum){
				v1sec=sum;
				v1num2=v1[i];
			}
		}

		for(int i=0;i<n/2;++i){
			int sum=1;
			for(; i<n/2-1 && v2[i]==v2[i+1];++i){
				++sum;
			}
			if(v2max<sum){
				v2sec=v2max;
				v2max=sum;
				v2num1=v2[i];
			}
			else if(v2sec<sum){
				v2sec=sum;
				v2num2=v2[i];
			}
		}

		if(v1num1!=v2num1)	System.out.println(n-v1max-v2max);
		else{

			if(v1sec+v2max>=v1max+v2sec && v1sec!=0) System.out.println(n-v1sec-v2max);
			else if(v1max+v2sec>=v1sec+v2max &&v2sec!=0) System.out.println(n-v1max-v2sec);
			else System.out.println(n/2);
		}


	}
}


Measured memory_bytes: 50960
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int a,b,c;
    cin>>a>>b>>c;
    cout << max(c-a+b,0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define NMAX 100000
#define MMAX 10000
using namespace std;
vector<int > group[NMAX];
int main(){
	int N,T,A[NMAX] = {},dif[NMAX] = {},most = 0,first,end = 0,num = 0,gr_num = 0;
	cin >> N >> T;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if(i == 0){
			first = A[i];
			group[gr_num].push_back(A[i]);
		}else if(first < A[i]){
			group[gr_num].push_back(A[i]);
			if(i == N-1){
				sort(group[gr_num].begin(), group[gr_num].end());
				dif[gr_num] = group[gr_num][group[gr_num].size()-1]-group[gr_num][0];
				most = max(most,dif[gr_num]);
			}
		}else{
			first = A[i];
			sort(group[gr_num].begin(), group[gr_num].end());
			dif[gr_num] = group[gr_num][group[gr_num].size()-1]-group[gr_num][0];
			most = max(most,dif[gr_num]);
			gr_num++;
			group[gr_num].push_back(A[i]);
		}
	}
	// for (int i = 0; i <= gr_num; ++i)
	// {
	// 	for (int j = 0; j < group[i].size(); ++j)
	// 	{
	// 		cout << group[i][j] << " ";
	// 	}
	// 	cout << dif[i];
	// 	cout << "\n";
	// }
	for (int i = 0; i < N; ++i)
	{
		if(dif[i] == most){
			num += /*dif_num[i]*/1;
			// cout << dif_num[i] << "\n";
		}
	}
	// cout << dif_num[N-1] << "\n";
	cout << num << "\n";
	return 0;
}

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

int main(){
 ll n;
 cin>>n;
 vector<double> p(n+1,1);
 vector<vector<double>> dp(n+1,vector<double>(n+1));
 for(ll i=1;i<=n;i++){
 	cin>>p[i];
 }
 dp[0][0]=1;
 for(ll i=1;i<=n;i++){
 	dp[0][i]=dp[0][i-1]*(1-p[i]);
 }
 for(ll j=1;j<=n;j++){
 	for(ll i=1;i<=j;i++){
 		double a=dp[i][j-1]*(1-p[j]);
 		double b=(dp[i-1][j-1]*p[j]);
 		dp[i][j]=a+b;	
	}
 }
 double ans=0;
 for(ll j=1;j<=n;j++){
 	if(j>n/2){
 		ans+=dp[j][n];	
	}
 }
 cout<<fixed<<setprecision(10)<<ans<<endl;
 return 0;
}



Measured memory_bytes: 73736
# -*- coding utf-8 -*-
N = int(input())

an = list(map(int, input().split()))

bn = [0] * N

for i in range(N, 0, -1):
    s = sum(bn[(i - 1)::i]) % 2
    bn[i - 1] = 0 if s == an[i - 1] else 1

ans = sum(bn)
print(ans)
ans_b = []
if ans != 0:
    for i in range(N):
        if bn[i] == 1:
            ans_b.append(str(i + 1))
    print(' '.join(ans_b))


Measured memory_bytes: 70364
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n;
	cin >> n;
	cout.precision(100);
	cout << (2 * n * 3.141592653);
}


Measured memory_bytes: 34216
#include<bits/stdc++.h>
using namespace std;
deque<int> arr;
int is[200005];
int main(){
    int n,x;
    scanf("%d%d",&n,&x);
    if(x==1 || x==2*n-1){
        puts("No");
        return 0;
    }
    arr.push_back(x);
    is[x]=1;
    int tmp=0;
    for(int i=n*2-1;i>0;i--){
        if(is[i]) continue;
        tmp++;
        arr.push_back(i);
        is[i]=1;
        if(tmp==n-1) break;
    }
    for(int i=1;i<2*n;i++){
        if(is[i]) continue;
        arr.push_front(i);
    }
    puts("Yes");
    for(int i=0;i<arr.size();i++) printf("%d\n",arr[i]);
}


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

int main(){
    int N, A, B, ans = 0;
    cin >> N >> A >> B;
    for(int i = 1; i <= N; ++i){
        string s = to_string(i);
        int buf = 0;
        for(int j = 0; j < s.size(); ++j) buf += s[j] - '0';
        if(A <= buf && buf <= B) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int n;
int a;
int func(int x)
{
	int ans=0;
	while(x%2==0)
	{
		ans++;
		x=x/2;
	}
	return ans;
}
int main()
{	
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		ans+=func(a);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> coin(M);
    rep(i, M) cin >> coin[i];

    vector<int> dp(N + 1, INF);

    dp[0] = 0;
    rep(i, N + 1) {
        if (dp[i] != INF)
            rep(j, M) {
                if (i + coin[j] <= N)
                    dp[i + coin[j]] = min(dp[i + coin[j]], dp[i] + 1);
            }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
#define N 1010
int main()
{
    LL i,j,k,n,m,s;
    s=1;
    scanf("%lld%lld",&n,&m);
    for(i=2;i*i<=m;i++)
    if(m%i==0)
    {
        j=0;
        while(m%i==0)
        {
            m=m/i;
            j++;
        }
        k=j/n;
        for(j=1;j<=k;j++)
            s=s*i;
    }
    if(m>1&&n==1)
        s=s*m;
    printf("%lld\n",s);
    return 0;
}


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

int main(){
  int n;
  string s;
  string ff[105];
  bool flag=true;
  
  cin >> n;

  for(int i=0;i < n;i++){
    if(i) ff[i-1] = s;
    cin >> s;
    
    for(int j=0;j < i;j++){
      if(ff[j] == s) flag = false;
    }
    if(i){
      char sl = ff[i-1][ff[i-1].size()-1];
      if(sl != s[0]){
	flag=false;
      }
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register int i = (a); i <= (b); ++i)
#define per(i, a, b) for (register int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e6 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n;

int a[maxn];

signed main()
{
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1), reverse(a + 1, a + n + 1);
	int pos = 1;
	while(a[pos + 1] >= pos + 1 && pos < n) ++ pos;
	int sum = 0;
	rep(i, pos + 1, n) if(a[i] == pos) sum ++;
	sum = (sum & 1) | ((a[pos] - pos) & 1);
	puts(sum ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final String s1 = sc.next();
        sc.close();
        String result = "a";
        if (Character.isUpperCase(s1.charAt(0))) {
            result = "A";
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35540
#include <stdio.h>
int A[100000];
int partition(int p,int r){
	int x,j,i,b;
	x=A[r];
	i=p-1;
	for(j=p;j<=r;j++){
		if(A[j]<=x){
			i=i+1;
			b=A[i];
			A[i]=A[j];
			A[j]=b;
		}
	}
	return i;
}

int main(){
	int n,i,q;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	q=partition(0,n-1);
	for(i=0;i<n;i++){
		if(0<i && i<n)
			printf(" ");
		if(i==q)
			printf("[");
		printf("%d",A[i]);
		if(i==q)
			printf("]");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define printpair(v) for(auto val: v){cout<<val.fi<<":"<<val.se<<", ";}cout<<endl;
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
const int mod = 1e9+7;
#define sz size()
const int inf = 1e18;
int s;
int dp[2005];
int mi=0;
int f(int cs){
//    mi=max(mi,i);
    if(cs>s){
        return 0;
    }
    if(cs==s){
        return 1;
    }
    int su=0;
    if(dp[cs]!=-1){
        return dp[cs];
    }
    rep(j,3,2001){
        su+=f(cs+j);
        su%=mod;

    }
    su%=mod;
    dp[cs]=su;
    return su;

}
void solve() {
    clr(dp,-1);
    cin>>s;
    cout<<f(0)<<endl;
//    cout<<mi<<endl;
}

int32_t main(){
    fastIO

    int t=1;
//    cin>>t;
    while(t--){
        solve();
//        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3676
let [| n; m; |] = stdin.ReadLine().Split() |> Array.map int
let a = stdin.ReadLine().Split() |> Array.map int64

let sortedSet = a |> Array.mapi (fun i x -> x, i+1) |> Set.ofArray

seq{1..m} |> Seq.fold (fun (set:Set<int64*int>) _ -> 
    set |> Set.remove (set.MaximumElement) |> Set.add (set.MaximumElement |> fun (x,i) ->(x/2L, i))) sortedSet 
|> Seq.sumBy (fun (x,_) -> x)
|> stdout.WriteLine

Measured memory_bytes: 50464
#include<bits/stdc++.h>
 
using namespace std;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()
 
#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
 
#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;
 
ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}
 
ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}
 
ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}
 
ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}
 
void solve () {
	
	int n, k;
	cin >> n >> k;

	int arr[n];
	for (int i = 0; i <=n; i++) {
		cin >> arr[i];
	}

	int dp[k+1];
	memset(dp, 0, sizeof(dp));
	
	dp[0] = 1;
	for (int i = 1; i <= k; i++) {
		
		int flag = 0;
		for (int j = 0; j < n; j++) {
			
			if(arr[j] <= i and dp[i - arr[j]] == 1)
				flag = 1;
		}

		if (flag == 0)
			dp[i] = 1;
	}

	if (dp[k] == 0)
		cout << "First" << endl;
	else 
		cout << "Second" << endl;
}

 
signed main() 
{
    fast_cin();
    
    
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 4040
x,k,d=map(int,input().split())
if x-k*d>=0:
  print(x-k*d)
elif x+k*d<=0:
  print(-x-k*d)
else:
  a=(k*d-x)//(2*d)
  if (k-2*a)*d-x<=x+2*d+(2*a-k)*d:
    print((k-2*a)*d-x)
  else:
    print(x+2*d+(2*a-k)*d)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	int N, T;
 	cin >> N >> T;
 	int c = 1000;
 	int r = 0;
 	bool flag = false;
 	while(N--){
 		int a, b;
 		cin >> a >> b;
 		if(a <= c && b <= T){
 			c = a;
 			r = b;
 			flag = true;
 		}
 	}
 	if(flag)
 		cout << c << endl;
 	else
 		cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
class UF_weighed:
    def __init__(self, n):
        self.n = n
        self.par = list(range(n+1))
        self.rank = [0]*(n+1)
        self.size = [1]*(n+1)
        self.diff_w = [0]*(n+1)

    def find(self, x):
        if self.par[x] == x: return x
        p = self.find(self.par[x])
        self.diff_w[x] += self.diff_w[self.par[x]]
        self.par[x] = p
        return self.par[x]

    def weight(self, x):
        self.find(x)
        return self.diff_w[x]

    def diff(self, x, y):
        if not self.same(x, y): return None
        return self.weight(y) - self.weight(x)

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def merge(self, x, y, w):
        w += self.weight(x) - self.weight(y)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.rank[x] < self.rank[y]:
            x, y, w = y, x, -w
        self.par[y] = x
        self.size[x] += self.size[y]
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.diff_w[y] = w
        return True
      
def main():
  n,m = map(int, input().split())
  uf = UF_weighed(n+1)
  for _ in range(m):
    a, b, c = map(int, input().split())
    if uf.same(a, b) and uf.diff(a, b) != c:
      return 'No'
    uf.merge(a, b, c)
  return 'Yes'

if __name__ == '__main__':
  print(main())


Measured memory_bytes: 12640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int monooki;
		int[] menu=new int[100];
		for(int i=0;i<N;i++){
			menu[i]=sc.nextInt();
		}
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(menu[i]<menu[j]){
					monooki=menu[i];
					menu[i]=menu[j];
					menu[j]=monooki;
				}
			}
		}
		for(int i=0;i<N;i++){
			if(C/A<menu[i]/B){
				A=A+B;
				C=C+menu[i];
			}
		}
		System.out.println(C/A);
	}
}

Measured memory_bytes: 18136
a=list(map(int,open(0).read().split()))
print('Yes' if a[0]-a[1]==a[3]-a[4]==a[6]-a[7] and a[1]-a[2]==a[4]-a[5]==a[7]-a[8] and a[0]-a[3]==a[1]-a[4]==a[2]-a[5] and a[3]-a[6]==a[4]-a[7]==a[5]-a[8] else 'No')

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

int main(){

  int t;
  int n;
  int h;
  int a[500];
  int x,y;

  cin >> t;

  for(int l=0;l<t;l++){
    x = y = 0;

    cin >> n;
    cin >> a[0];

    for(int i=1;i<n;i++){
      cin >> a[i];

      x = max(a[i]-a[i-1],x);
      if(a[i-1]-a[i] >= 0) y = max(a[i-1]-a[i],y);

    }
 
    cout << x << " " << y << endl;

  }
}

Measured memory_bytes: 1160
/*
2020-05-05
atcoder ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;
    if((S.length() + 1 == T.length()) && (T.substr(0, S.length()) == S)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #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++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

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


    
    
    int main(){
        vector<vector<int>> c(3,vector<int>(3));
        rep(i,3)rep(j,3)cin>>c[i][j];
        auto a = vec(int,3);
        auto b = vec(int,3);
        rep(i,3)a[i] = c[0][i];
        rep(i,3)b[i] = c[i][0]-a[0];
        rep(i,3)rep(j,3){
            if(c[i][j] != a[j]+b[i]){
                cout<<"No";
              return 0;
            }
        }
        cout<<"Yes";
    }
    


Measured memory_bytes: 256
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		long t = 0;
		int x=n;
		
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);

		if(n>=k) {
		for(int i =0;i<n-k;i++) {
			t+=a[i];
		}}


		
		
		
		
			System.out.println(t);

 
		sc.close();
	}
}

Measured memory_bytes: 65044
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        System.out.println(factorial(n));
    }
    
    public static long factorial(int n) {
        if (n > 1) return factorial(n-1)*n;
        return 1;
    }
}

Measured memory_bytes: 26144
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

using namespace std;
// cout << setprecision(20) << ans << "\n";

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

  string s;
  cin >> s;
  if (s.size() != 26) {
    vector<int> seen(26, 0);
    for (char c : s) {
      seen[c - 'a'] = 1;
    }
    for (int i = 0; i < 26; i++) {
      if (!seen[i]) {
        s.push_back('a' + i);
        cout << s << "\n";
        return 0;
      }
    }
  }

  set<char> g;
  while (s.size()) {
    char c = s.back();
    s.pop_back();
    auto it = g.upper_bound(c);
    if (it != g.end()) {
      s += *it;
      cout << s << '\n';
      return 0;
    }
    g.insert(c);
  }
  cout << -1 << "\n";

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>

#include <vector>

using namespace std;

int main()
{
    int card, n;
    char suit;
    cin >> n;

    int cards[4][13] = {};

    for(int i = 0; i < n; i++) {
        cin >> suit >> card;
        
        switch (suit) {
        case 'S':
            cards[0][card-1] = 1;
            break;
        case 'H':
            cards[1][card-1] = 1;
            break;
        case 'C':
            cards[2][card-1] = 1;
            break;
        case 'D':
            cards[3][card-1] = 1;
            break;
        }
    }

    for (int i = 0; i < 4 ; i++ ) {
            for (int j = 0; j < 13; j++) {
                if (cards[i][j] == 0) {
                    if (i==0) {
                        cout << "S" << " " << j+1 << endl;
                    }
                    else if (i ==1 ) {
                        cout << "H" << " " << j+1 << endl;
                    }
                    else if (i == 2) {
                        cout << "C" << " " << j+1 << endl;
                    }
                    else {
                        cout << "D" << " " << j+1 << endl;
                    }
                }
            }
    }

    return 0;
}


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

const int64_t S_MAX = 1e5*2;
const int64_t base = 1007;
const int64_t MOD = 1e9+7;
int64_t mod_table[S_MAX];

void create_mtable(){
  mod_table[0] = 1;
  for(int i=1; i<S_MAX; i++){
    mod_table[i] = mod_table[i-1]*base;
    mod_table[i] %= MOD;
  }
}

int64_t to_hash(string s){
  int64_t ret = 0;
  int S = s.size();
  for(int i=0; i<S; i++){
    ret += s[i]*mod_table[S-i-1];
    ret %= MOD;
  }
  return ret;
}

int64_t rolling_hash_count(string s, string t){
  int S = s.size();
  int T = t.size();
  if(S < T){
    return 0;
  }
  create_mtable();
  int64_t s_hash = to_hash(s.substr(0,T));
  int64_t t_hash = to_hash(t);
  int cnt = 0;
  if(s_hash == t_hash){
    cnt++;
  }
  for(int i=0; i<S-T; i++){
    s_hash *= base;
    s_hash %= MOD;
    s_hash -= mod_table[T]*s[i];
    s_hash += s[T+i];
    while(s_hash < 0){
      s_hash += MOD;
    }
    s_hash %= MOD;
    if(s_hash == t_hash){
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S;
  T = "ABC";
  cout << rolling_hash_count(S,T) << endl;
}

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

int main(){
  int N;
  cin >> N;
  int64_t ans = -1,cont =0,a,b;
  cin >> a;
  for(int i=0;i<N-1;i++){
    cin >> b;
    if(a>=b) cont++;
    else{
      ans = max(cont,ans);
      cont=0;
    }
    a=b;
  }
  ans = max(cont,ans);
  cout << ans <<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x,a,b;
    cin>>x>>a>>b;
    if(x-a>0 && x-b>0 && x-a>x-b) cout<<"B\n";
    else if(x-a>0 && x-b>0 && x-a<x-b) cout<<"A\n";
    else if(x-a<0 && x-b>0 && a-x<x-b) cout<<"A\n";
    else if(x-a<0 && x-b>0 && a-x>x-b) cout<<"B\n";
    else if(x-a<0 && x-b<0 && a-x>b-x) cout<<"B\n";
    else if(x-a<0 && x-b<0 && a-x<b-x) cout<<"A\n";
    else if(x-a>0 && x-b<0 && x-a<b-x) cout<<"A\n";
    else if(x-a>0 && x-b<0 && x-a>b-x) cout<<"B\n";
    else cout<<"A\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    map<int, int> used;
    rep (i, 1000) {
        int num[3] = {i / 100, (i % 100) / 10, i % 10};
        int s1 = i / 100, s2 = (i % 100) / 10, s3 = i % 10;
        int now = 0;
        rep (j, n) {
            if (s[j] - '0' == num[now]) now++;
        }
        if (now == 3) {
            if (!used[i]) ans++;
            used[i]++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

class tsort {
public:
  int V;
  vector<vector<int>> G;
  vector<int> deg, res;
  tsort(int node_size) : V(node_size), G(V), deg(V, 0) {}
  void add(int from, int to) {
    G.at(from).push_back(to);
    deg.at(to)++;
  }
  bool solve() {
    queue<int> que;
    for(int i = 0; i < V; i++) {
      if(deg.at(i) == 0) {
        que.push(i);
      }
    }
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      res.push_back(p);
      for(int v : G.at(p)) {
        if(--deg.at(v) == 0) {
          que.push(v);
        }
      }
    }
    return (*max_element(deg.begin(),deg.end()) == 0);
  }
};

int main() {
  int N;
  cin >> N;
  map<pair<int, int>, int> MA;
  for (int i = 1, cnt = 0; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      MA[{i, j}] = cnt++;
    }
  }
  int Q = N;
  N = N * (N - 1) / 2;
  tsort TS(N);
  for (int q = 1; q <= Q; q++) {
    vector<int> tmp(Q - 1);
    for (int i = 0; i < Q - 1; i++) cin >> tmp.at(i);
    for (int i = 0; i + 1 < Q - 1; i++) {
      int x1 = q, y1 = tmp.at(i);
      if (x1 > y1) swap(x1, y1);
      int X = MA[{x1, y1}];
      int x2 = q, y2 = tmp.at(i + 1);
      if (x2 > y2) swap(x2, y2);
      int Y = MA[{x2, y2}];
      TS.add(X, Y);
    }
  }
  bool b = TS.solve();
  if (!b) return cout << -1 << "\n", 0;
  vector<int> rank = TS.res;
  reverse(rank.begin(), rank.end());
  vector<int> DP(N);
  for (int i = 0; i < N; i++) {
    for (auto g :TS.G.at(rank.at(i))) {
      DP.at(rank.at(i)) = max(DP.at(rank.at(i)), DP.at(g) + 1);
    }
  }
  cout << *max_element(DP.begin(), DP.end()) + 1 << "\n";
}

Measured memory_bytes: 69752
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	int n, c[500], s[500], f[500];
	cin >> n;
	rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
	rep(i, n - 1) {
		int t = 0;
		rep(j, n - i - 1) {
			if (t <= s[i + j])t = s[i + j];
			else if (t%f[i + j] == 0);
			else t = t + f[i + j] - t % f[i + j];
			t += c[i + j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	end;
}


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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    int ans = 0;
    vector<ll> A(N,0);
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    for(int i = 0; i < N; i++) {
        //cout << A.at(i) << endl;
        while(!(A.at(i)%2)) {
            ans++;
            //cout << "##" << endl;
            A.at(i) /= 2;
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3704
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    if (s.equals("A")) {
      os.println("T");
    }
    if (s.equals("T")) {
      os.println("A");
    }
    if (s.equals("G")) {
      os.println("C");
    }
    if (s.equals("C")) {
      os.println("G");
    }
  }
}

Measured memory_bytes: 22996
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];

        for(int i = 0 ; i < n ; i++){
            a[i] = sc.nextLong();
        }

        long[][] dp = new long[n][3];
        int k = n/2;
        long max = 0;

        for(int i = 1 ; i <= k ; i++){
            dp[i][0] = dp[i-1][0] + a[2*i-2];
        }
        max = dp[k][0];

        for(int i = 1 ; i <= k ; i++){
            dp[i][1] = Math.max(    dp[i-1][0] + a[2*i-1],
                                    dp[i-1][1] + a[2*i-1]);
        }
        max = Math.max(max, dp[k][1]);

        if((n % 2) == 1) {
            for (int i = 1; i <= k; i++) {
                dp[i][2] = Math.max(dp[i - 1][0] + a[2 * i],
                            Math.max(dp[i - 1][1] + a[2 * i],
                                    dp[i-1][2] + a[2*i]));
            }
            max = Math.max(max, dp[k][2]);
        }

        System.out.println(max);
    }
}


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

using namespace std;


int main()
{
    string str;
    
    cin >> str;

    for (int i = 0; i < 3; i++) {
        if (str[i] == str[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256