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


int main() {
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string ss;
	cin >> ss;
	string choose = string(n, '?');
	for (int i = 0; i < n; i++) {
		switch (ss[i]) {
		case 'r':
			choose[i] = 'p';
			break;
		case 's':
			choose[i] = 'r';
			break;
		case 'p':
			choose[i] = 's';
			break;
		}
	}
	vector<int> points(n);
	for (int i = 0; i < n; i++) {
		switch (choose[i]) {
		case 'r':
			points[i] = r;
			break;
		case 's':
			points[i] = s;
			break;
		case 'p':
			points[i] = p;
			break;
		}
	}
	vector<int> dp(n);
	dp[0] = points[0];
	for (int i = 1; i < k; i++) dp[i] = dp[i - 1] + points[i];
	for (int i = k; i < n; i++) {
		if (choose[i] == choose[i - k]) {
			dp[i] = dp[i - 1];
			choose[i] = '?';
		}
		else {
dp[i] += dp[i-1] +points[i];
		}
		
	}
	cout << dp[n - 1];


	return 0;
}

Measured memory_bytes: 4296
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long

int main() {
    int A, B;
    cin >> A >> B;
    
    int ans = 0;
    for(int i = A; i <= B; i++) {
        int s = i;
        int t[5];
        for(int j = 0; j <= 4; j++) {
            t[j] = s % 10;
            s /= 10;
        }
        if (t[0] == t[4] && t[1] == t[3]) ans++;
    }
    cout << ans << endl;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  long long n, m, k;
  cin>>n>>m>>k;
  COMinit();
  long long ans = 0;
  for (int i=1; i<=m; i++) {
    long long cnt = n * n % MOD * (i - 1 - (m - i)) % MOD;
    if (cnt < 0) {
      cnt += MOD;
    }
    cnt = cnt * COM(n * m - 2, k - 2) % MOD * i % MOD;
    ans = (ans + cnt) % MOD;
  }
  for (int i=1; i<=n; i++) {
    long long cnt = m * m % MOD * (i - 1 - (n - i)) % MOD;
    if (cnt < 0) {
      cnt += MOD;
    }
    cnt = cnt * COM(n * m - 2, k - 2) % MOD * i % MOD;
    ans = (ans + cnt) % MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12796
import java.util.Scanner;

class Main {

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

        int h[] = new int[2];
        int k[] = new int[2];
        int i;
        int f;
        int g;
        int z;
        int y;
        int gouH;
        int gouK;
        for (i = 0; i < 2; i++) {
            h[i] = scan.nextInt();
        }
        for (i = 0; i < 2; i++) {
            k[i] = scan.nextInt();
        }
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        i = 0;
        f = (h[i] * a) + ((h[i] / 10) * c);
        g = (k[i] * a) + ((k[i] / 10) * c);
        i = 1;
        z = (h[i] * b) + ((h[i] / 20) * d);
        y = (k[i] * b) + ((k[i] / 20) * d);

        gouH = f + z;
        gouK = g + y;

        if (gouH < gouK) {
            System.out.println("kenjiro");
        } else if (gouH > gouK) {
            System.out.println("hiroshi");
        } else if (gouH == gouK){
            System.out.println("even");
        }

    }

}



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

int main()
{
    int n; cin >> n; cout << n << ":";
    int i = 2;
    while(n != 1){ 
        if(n % i == 0){
            n /= i;
            cout << " " << i;
        }
        else if (n < i * i) //nが大きい素数である場合がありO(√n)が最適解
        {
            cout << " " << n;
            break;
        }
        else
        {
            i++;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n, k; cin>>n>>k;
	int l[11], r[11];
	for(int i=0; i<k; i++){
		cin>>l[i]>>r[i];
	}
	const ll MOD=998244353;
	ll dp[200020]={};
	ll s[200020]={};
	dp[0]=1;
	s[1]=1;
	for(int i=1; i<n; i++){
		for(int j=0; j<k; j++){
			(dp[i]+=s[max(0, i-l[j]+1)]-s[max(0, i-r[j])]+MOD)%=MOD;
		}
		s[i+1]=(s[i]+dp[i])%MOD;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



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

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

    double den = 0.0;
    for (int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        den += 1.0 / tmp;
    }

    

    cout << 1 / den << endl;
}


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

using namespace std;
using P=pair<int,int>;
using PP=pair<P,int>;

int main(){
    int n;
    while(cin>>n,n){
        vector<PP>data;
        for(int j=0;j<n;++j){
            char c;cin>>c;
            if(c=='W'){
                int l,s;cin>>l>>s;
                int siz=data.size();
                if(siz==0)data.push_back(PP(P(0,s),l));
                for(int i=0;i<siz;++i){
                    if(data[i].second==-1){
                        if(s>=data[i].first.second-data[i].first.first){
                            s-=(data[i].first.second-data[i].first.first);
                            data[i].second=l;
                            if(!s)break;
                        }else{
                            data.push_back(PP(P(data[i].first.first,data[i].first.first+s),l));
                            data[i].first.first+=s;
                            s=0;
                            break;
                        }
                    }
                    if(i==(siz-1)){
                        data.push_back(PP(P(data[i].first.second,data[i].first.second+s),l));
                        s=0;
                    }
                }
                sort(data.begin(),data.end());
            }else if(c=='D'){
                int l;cin>>l;
                for(int i=0;i<data.size();++i){
                    if(data[i].second==l){
                        data[i].second=-1;
                    }
                }
            }else{
                int p,ans=-1;cin>>p;
                for(int i=0;i<data.size();++i){
                    if(data[i].first.first<=p && data[i].first.second>p){
                        ans=data[i].second;
                        break;
                    }
                }
                cout<<ans<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>
#include <string.h>

#define N   1121
#define PN  187

static int  p[ N ] = { 1, 1, 0 };
static int  pn = 0;

static int k_operafan[ N ][ PN ][ 15 ];

static int
dpFSA (
  int n,
  int r,
  int k
  )
{
  if ( n < 0 )    return ( 0 );
  if ( k == 0 )   return ( n == 0 );
  if ( k < 0
    || r >= pn )  return ( 0 );

  if ( ~k_operafan[ n ][ r ][ k ] ) ;
  else
  {
    k_operafan[ n ][ r ][ k ] = dpFSA ( n, r + 1, k )
                              + dpFSA ( n - p[ r ], r + 1, k - 1 );
  }

  return ( k_operafan[ n ][ r ][ k ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 2; i < N; ++i )
  {
    if ( p[ i ] ) continue ;

    p[ pn++ ] = i;
    for ( j = i * 2; j < N; j += i )
    {
      p[ j ] = 1;
    }
  }

  memset ( k_operafan, -1, sizeof ( k_operafan ) );
  for ( ; ; )
  {
    int n, k;

    scanf ( "%d%d", &n, &k );
    if ( !( n | k ) ) break ;

    printf ( "%d\n", dpFSA ( n, 0, k ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		sc.close();
		int cnt = 0;
		for(int i = 0; i < 3; ++i){
			if(s.charAt(i) == t.charAt(i))++cnt;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22740
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
using namespace std;

#define int long long int
#define all(x) (x).begin(), (x).end()
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'

void solve(){
	string s;
	cin>>s;
	if(s.back()=='s'){
		cout<<s+"es"<<endl;
	}else{
		cout<<s+"s"<<endl;
	}
}

int32_t main(){

	//remove for interactive problems
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

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

	return 0;
}

Measured memory_bytes: 3848
#include<iostream>
#include<cstdio> 
#include<cstring>  
#include<cstdlib>
#include<algorithm> 
using namespace std;  
int main()  
{  
    int a; 
    cin>>a;
    int n=0;  
    int i=0;
    while(n*(n+1)/2<a)
    {n++;}
    int cnt=n*(n+1)/2-a;
    for(i=0;i<n-cnt;i++)  
    cout<<")";//yuan
    cout<<"(";//duiqijinxingxiugai
    for(i=n-cnt+1;i<=n;i++)  
    cout<<")";
    for(int i=n+1;i<n*2;i++)  
    cout<<"(";///yuan
cout<<endl;
    return 0;
} 

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k; cin>>n>>m>>k;
  int g=__gcd(n,m);
  vector<int>v;
  int i;
  for(i=1;i*i<g;i++)
  {
    if(g%i==0)
    {  
       v.push_back(i);
      v.push_back(g/i);
    }
  }
  if(i*i==g) v.push_back(i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  cout<<v[k-1]<<endl;
  //cout<<g<<endl;
  
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }


int _dp[2010][2010];
int N;
int A[2010];

using P = pair<int, int>;
vector<P> p;

int left[2010];
int right[2010];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
		p.push_back(make_pair(A[i], i));
	}

	RSORT(p);

	for (int i = 0; i < N; i++)
	{
		int score = 0;

		for (int j = 0; j <= i; j++)
		{
			int len = abs(j - p[i].second);
			int s = len * p[i].first;

			int prev = _dp[j][i - j];
			int next = prev + s;
			_dp[j + 1][i - j] = max(_dp[j + 1][i - j], next);
		}

		for (int j = 0; j <= i; j++)
		{
			int r = N - 1 - j;

			int len = abs(r - p[i].second);
			int s = len * p[i].first;

			int prev = _dp[i - j][j];
			int next = prev + s;
			_dp[i - j][j + 1] = max(_dp[i - j][j + 1], next);
		}
	}

	int m = 0;
	for (int i = 0; i < N; i++)
	{
		m = max(m, _dp[i][N - i]);
	}

	cout << m << endl;
}




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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
int X[10];

signed main() {
  cin >> N;
  int Min = 1e18;
  int idx = 0;
  rep (i, 5) {
    cin >> X[i];
    if (X[i] < Min) {
      Min = X[i];
      idx = i;
    }
  }

  cout << (N+Min-1) / Min + 4 << endl;
  return 0;

  int ans = 0;
  int n = N;
  int ii = 0;
  rep (i, 5) {
    ans += n / X[i];
    n = n % X[i];
  }

  dbg(ii)
  cout << ans -idx << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long llong;

//refering to exp.
int main(){
	llong a,b;
	cin>>a>>b;
	
	llong n=__gcd(a,b);
	llong cnt=1;
	for(llong i=2;i*i<=n;++i){
		if(n%i==0){
			cnt++;
			while(n%i==0) n/=i;
		}
	}
	if(n!=1) cnt++;
	
	cout<<cnt<<endl;
}


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 ans=0;
    for( int i=1;i<=n;i++)
    {
      int x=sc.nextInt();
      if((x%2!=0)&&(i%2!=0))
        ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35984
#include<cstdio>
using namespace std;
int a,b;
int main()
{
  scanf("%d%d",&a,&b);
  if(a<=0&&b>=0)
    return puts("Zero"),0;
  if(a<0)
   	puts((b-a)&1?"Positive":"Negative");
  else
	puts("Positive");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> vec[100005],cnt,vs;
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec[a%m].push_back(a);
  }
  for(int i=0;i<m;i++){
    sort(vec[i].begin(),vec[i].end());
    int kn=0;
    for(int j=0;j<vec[i].size();j++){
      if(vec[i][j]==vec[i][j+1]){
        kn++;
        j++;
      }
    }
    cnt.push_back(kn);
    vs.push_back(vec[i].size());
  }
  ll ans=0;
  for(int i=1;i<(m-i);i++){
    ll pr=min(vs[i],vs[m-i]);
    ans+=pr;
    vs[i]-=pr;
    vs[m-i]-=pr;
  }
  for(int i=0;i<m;i++){
    if(i==0) ans+=vs[i]/2;
    else if(i*2==m) ans+=vs[i]/2;
    else ans+=min(vs[i]/2,cnt[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7452
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int K;
  cin>>K;
  vector<ll> A(K);
  rep(i,K) cin>>A[i];

  ll low=2,high=2;
  for(int i=K-1;i>=0;i--){
    ll nexLow=low,nexHigh=high;
    nexLow=low+(A[i]-low%A[i])%A[i];
    nexHigh=high-(high%A[i])+A[i]-1;

    low=nexLow;
    high=nexHigh;
    if(low>high){
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<low<<" "<<high<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0;
  rep(i,n) {
    ll c=0,d=0;
    rep(j,i) {
      if(a[j]>a[i]) c++;
    }
    REP(j,i+1,n) {
      if(a[j]>a[i]) d++;
    }
    ans+=m*(m+1)/2%MAX*c;
    ans+=m*(m-1)/2%MAX*d;
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val kuku = for {
      x <- 1 to 9
      y <- 1 to 9
    } yield x * y
    val input = StdIn.readLine.toInt
    val res = if (kuku.exists(_ == input)) "Yes" else "No"
    println(res)
  }
}


Measured memory_bytes: 27204
#include<bits/stdc++.h>
#define e 1000000007
#define PB push_back
#define MP make_pair
#define lli long long int
#define pll pair< lli,lli >
#define pls pair< lli,string >
#define pii pair< int,int >
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x,y;
	cin>>n;
	x=log2(n);
	y=pow(2,x);
	if(y==n || n==1){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<n;i+=2){
		cout<<1<<" "<<i<<endl;
		cout<<i<<" "<<i+1<<endl;
		cout<<1<<" "<<n+i+1<<endl;
		cout<<n+i+1<<" "<<n+i<<endl;
		if(i==2)cout<<n+i<<" "<<n+1<<endl;
	}
	if(n%2==0){
		cout<<n-2<<" "<<n+n<<endl;
		y=n^(n-2)^1;
		y+=n;
		cout<<y<<" "<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

void dfs(int pre, int v, vi &used, vector<vi> &g, vi &a, vi &res) {
  if(used[v]) return;
  used[v] = 1;
  res.push_back(a[v]);
  FOR(e, g[v]) {
    if((*e) == pre) continue;
    dfs(v, *e, used, g, a, res);
  }
}

int main(void){
  int n, m;
  cin >> n >> m;
  vi a(n);
  REP(i, n) cin >> a[i];
  vector<vi> g(n);
  REP(i, m) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  if(n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  if(n == 2 && m == 0) {
    cout << a[0] + a[1] << endl;
    return 0;
  }
  if(m == 0) {
    cout << "Impossible" << endl;
    return 0;
  }


  vi used(n, 0);
  priority_queue<int, vi, greater<int> > pq;
  ll ans = 0;
  int k = 0;
  REP(i, n) {
    if(used[i]) continue;
    vi x;
    dfs(-1, i, used, g, a, x);
    sort(ALL(x));
    ans += x[0];
    REP(j, x.size() - 1) pq.push(x[j+1]);
    k++;
  }
  if(k == 1) {
    cout << 0 << endl;
    return 0;
  }
  while(k - 2 > 0) {
    k--;
    if(pq.empty()) {
      cout << "Impossible" << endl;
      return 0;
    }
    ans += pq.top(); pq.pop();
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7676
def MMcheck(MM):
    if 1 <= MM and MM <= 12:
        return 1
    else:
        return 0
S = input()
s = list(S)
#mae
#print(s[0:2])
mae = int("".join(s[0:2]))
#print(mae)
countmae = MMcheck(mae)
#print(s[2:4])
ushiro = int("".join(s[2:4]))
#print(ushiro)
countushiro = MMcheck(ushiro)

if countmae == 1 and countushiro == 1:
    print("AMBIGUOUS")
elif countmae == 0 and countushiro == 1:
    print("YYMM")
elif countmae == 1 and countushiro == 0:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 38408
#include <stdio.h>
#include <math.h>

int main(void){
	int a,b,t,c,d=0;
	while(1){
		c=0;
		scanf("%d %d",&a,&b);
		if((a==0)&&(b==0)){
			return 0;
		}
		if(d!=0){
			printf("\n");
		}
			for(t=a;t<=b;t++){
				if((t%4==0) && ((t%100!=0)||(t%400==0))){
					printf("%d\n",t);
					c++;
				}
			}	
		if(c==0){
			printf("NA\n");
		}
			d++;
	

	}
return 0;
}

Measured memory_bytes: 616
x,n=map(int,input().split())
if(n==0):
    print(x)
    exit()
p = list(map(int,input().split()))

c = 0
while True:
    if (not (x-c) in p):
        print(x-c)
        exit()
    if (not (x+c) in p):
        print(x+c)
        exit()
    c+=1

Measured memory_bytes: 9180
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0;
    String s=sc.next();
    for(int i=0;i<n;i++)if(s.substring(i, i+1).equals("R"))count++;
    if(count>n/2.0) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
long long solve(vector<vector<long long> >&dp,int N,int W, int *w,int *v){
    if(N == 0 || W == 0) return 0;
    if(dp[N][W] != -1) return dp[N][W];
    long long a1, a2;
    if(W >= w[N-1]){
        dp[N][W] = max(v[N-1] + solve(dp, N-1, W-w[N-1],w,v), solve(dp, N-1, W, w, v) );
    }
    else{
        dp[N][W] = solve(dp, N-1, W, w, v);
    }
    return dp[N][W];
}
int main(){
    int N, W;
    scanf("%d %d",&N, &W);
    int w[N], v[N];
    for(int i = 0; i < N; i++){
        scanf("%d %d",&w[i], &v[i]);
    }
    vector<vector<long long> > dp(N+1, vector<long long>(W+1, -1));
    solve(dp, N, W, w, v);
    printf("%lld\n", dp[N][W]);
    return 0;
}

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

int main(){

  while(1){
    int n,p;
    cin >> n >> p;
    if(n==0)break;
    
    int st[55]={};
    int i=0,hoge=p;

    while(1){
      if( st[i] == hoge-1 && p>0){
	cout << i << endl;
	break;
      }
      if(p>0){
	st[i]++;
	p--;
      }
      else{
	p = st[i]; 
	st[i]=0;
      }

      i++;
      if(i==n) i=0;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin>>str;
  char a,b,c;
  a=str.at(0);
  b=str.at(1);
  c=str.at(2);
  if(a==b&&b==c){
      cout<<"No"<<endl;
		}else{
	cout<<"Yes"<<endl;
  }
}



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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}

lli N;
lli A[100010],B[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i]>>B[i];
    }
    lli ans = 0;
    lli sofar = 0;
    for(int i=N;i>=1;i--){
        A[i] += sofar;
        lli x = B[i] - (A[i]%B[i]);
        if(x == B[i])
            x = 0;
        sofar += x;
        ans += x;
    }
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN];
int ans[MAXN];
bool cmp(int x, int y) {
	return ans[x] < ans[y];
}
void work(int pos) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		work(a[pos][i]);
	sort(a[pos].begin(), a[pos].end(), cmp);
	int tans = 0;
	for (unsigned i = 0; i < a[pos].size(); i++)
		tans = max(tans + 1, ans[a[pos][i]] + 1);
	ans[pos] = tans;
}
int main() {
	int n; read(n);
	for (int i = 2; i <= n; i++) {
		int x; read(x);
		a[x].push_back(i);
	}
	work(1);
	cout << ans[1] << endl;
	return 0;
}

Measured memory_bytes: 10752
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=1e9+7;
inline int poww(int a,int b)
{
    int base=a,ans=1;
    while(b)
    	{
          if(b&1)
		     ans=(ans*base)%inf;
          base=(base*base)%inf;
          b>>=1;
    	}
    return ans;
}
/*
inline ll mul(ll x,ll y,ll mod)//O(1)快速乘
{
    ll tmp=(x*y-(ll)((long double)x/mod*y+1.0e-8)*mod);
    return tmp<0?tmp+mod:tmp;
}*/
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int main()
{
	printf("ABC%d",read());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  long long arr[n];
  bool over2 = false;
  for (int i=0; i<n; i++){
      cin >> arr[i];
      if (arr[i] >= n){
          over2 =true;
      }
  }
  if (!over2){
      cout << 0;
      return 0;
  }
  long long times = 0;
  while (true){
      long long sums[n];
      long long tot = 0;
      for (int i=0; i<n; i++){
          long long left = max(0LL, arr[i]-(n-1));
          long long num = left/n+(left%n != 0);
          arr[i] -= num*n;
          sums[i] = num;
          tot += num;
          times += num;
      }
      bool over = false;
      for (int i=0; i<n; i++){
          arr[i] += tot-sums[i];
          if (arr[i] >= n){
              over = true;
          }
      }
      if (!over){
          break;
      }
  }
  cout << times;
  return 0; 
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,m,start,i,temp,left=0,right=0;
    int fg[200];
    for(i=0;i<200;i++){
        fg[i]=0;
    }
    scanf("%d %d %d",&n,&m,&start);
    for(i=0;i<m;i++){
        scanf("%d",&temp);
        fg[temp]=1;
    }
    for(i=start-1;i!=0;i--){
        left+=fg[i];
    }
    for(i=start+1;i!=n;i++){
        right+=fg[i];
    }
    if(left<right){
        printf("%d\n",left);
    }else{
        printf("%d\n",right);
    }
    return 0;
}



Measured memory_bytes: 128
N = int(input())
array1 = []
array2 = []
for i in range(N):
    a,b = map(int,input().split())
    array1.append(a)
    array2.append(b)

array1.sort()
array2.sort()

if N % 2 == 0:
    min = array1[N//2]+array1[N//2-1]
    max = array2[N//2]+array2[N//2-1]
    print(max-min+1)
else:
    min = array1[N//2]
    max = array2[N//2]
    print(max-min+1)


Measured memory_bytes: 99072
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[100005],num[100005];
int main() {
	cin.tie(),cout.tie();
	memset(dp,233333,sizeof(dp));
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>num[i];
	dp[0]=0;
	dp[1]=0;
	for (int i=2;i<=n;i++) {
		for (int j=max(1,i-k);j<=i-1;j++) {
			int add=fabs(num[i]-num[j]);
			dp[i]=min(dp[i],dp[j]+add);
		}
//		cout<<i<<':'<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
	return 0;
} 

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var prods = new List<int>();
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    prods.Add(i * j);
                }
            }

            if (prods.Contains(N))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_N(505);
typedef long long int LL;

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

int N;
LL A[Max_N][Max_N], Sum1[Max_N][Max_N], Sum2[Max_N][Max_N], F[Max_N][Max_N], Ans;

inline LL query1(int l1, int r1, int l2, int r2)
{
	return Sum1[r1][r2] - Sum1[l1 - 1][r2] - Sum1[r1][l2 - 1] + Sum1[l1 - 1][l2 - 1];
}

inline LL query2(int l1, int r1, int l2, int r2)
{
	return Sum2[r1][r2] - Sum2[l1 - 1][r2] - Sum2[r1][l2 - 1] + Sum2[l1 - 1][l2 - 1];
}

inline void upd(LL &a, LL b)
{
	a = min(a, b);
}

int main()
{
	gi(N);
	for (int i = 1;i <= N;++i)
		for (int j = 1;j <= N;++j)
		{
			if (i != j)
				gi(A[i][j]);
			Sum1[i][j] = Sum1[i - 1][j] + Sum1[i][j - 1] - Sum1[i - 1][j - 1] + A[i][j] * (i < j);
			Sum2[i][j] = Sum2[i - 1][j] + Sum2[i][j - 1] - Sum2[i - 1][j - 1] + A[i][j] * (i > j);
		}
	Ans = Sum1[N][N];
	for (int x = 1;x <= N - 1;++x)
		Ans = min(Ans, query1(1, x, 1, x) + query1(x + 1, N, x + 1, N));
	memset(F, 0X3F, sizeof(F));
	for (int a = 1;a <= N - 1;++a)
		for (int b = a + 1;b <= N - 1;++b)
		{
			upd(F[a][b], query1(1, a, 1, a) + query1(a + 1, b, a + 1, b) + query2(b + 1, N, 1, a));
			for (int c = b + 1;c <= N - 1;++c)
				upd(F[b][c], F[a][b] + query1(b + 1, c, b + 1, c) + query2(c + 1, N, a + 1, b));
			upd(Ans, F[a][b] + query1(b + 1, N, b + 1, N));
		}
	print(Ans);
	return 0;
}

Measured memory_bytes: 12288
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,m;cin>>n>>m;
  vector<int> a(n);
  priority_queue<int> q;
  rep(i, n) {
    cin>>a[i];
    q.push(a[i]);
  }
  sort(all(a));
  dump(a);

  rep(i, m){
    int y = q.top();
    q.pop();
    y /= 2;
    q.push(y);
  }
  int ans = 0;
  while(!q.empty()){
    int y = q.top();q.pop();
    ans += y;
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

typedef long long ll;
const int N = 1e6 + 10;
int q[N], n;
int vis[N];

void solve() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &q[i]), vis[q[i]]++;
    sort(q + 1, q + 1 + n);

    int g = 0;
    for(int i = 1; i <= n; i++) {
        q[++g] = q[i];
        int j = i + 1;
        while(j <= n && q[i] == q[j]) j++;
        i = j - 1;
    }
    n = g;
    
    int res = 0;
    for(int i = 1; i <= n; i++) {
        if(vis[q[i]] == 1) res++;
        for(int j = q[i]; j < N; j += q[i]) vis[j] = 0;
    }

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

int main()
{

    int T = 1;
    //scanf("%d", &T);
    while(T--) {
        solve();
    }
}

Measured memory_bytes: 8492
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, h = IR(3)
    print((a+b)*h//2)
    return

#B
def B():
    d = defaultdict(int)
    d["a"] = deque(S())
    d["b"] = deque(S())
    d["c"] = deque(S())
    tern = "a"
    while d[tern]:
        tern =  d[tern].popleft()
    print(str.capitalize(tern))
    return

#C
def C():
    s = S()
    def dfs(tmp, s):
        res = "0"
        t = tmp if s == [] else 0
        for i in range(len(s)):
            res += s[i]
            t += dfs(int(res)+tmp, s[1 + i:])
        return t
    print(dfs(0, s))
    return

#D
def D():
    h, w, n = LI()
    ans = [(h - 2) * (w - 2)] + [0] * 9
    d = defaultdict(int)
    for _ in range(n):
        a, b = LI()
        for mb in range(-1, 2):
            mb += b
            for ma in range(-1, 2):
                if mb == ma == 0:
                    continue
                ma += a
                if 2 <= ma < h and 2 <= mb < w:
                    d[(ma, mb)] += 1
    for _, value in d.items():
        ans[value] += 1
        ans[0] -= 1
    print("\n".join(map(str, ans)))
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int h = n/2;
  int count = 0;
  for (int i = 0;i < h;i++){
    if (s[i] != s[n-i-1]){
      count++;
    }
  }
  cout << count << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, d;
    cin >> n >> d;

    d = d * 2 + 1;

    cout << (n + d - 1) / d << endl;

    return 0;
}

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

using namespace std;

int N, P, a[109];
long long dp[109][2];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &P);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), a[i] &= 1;
dp[0][0] = 1;
for (int i=0; i<N; i++)
    for (int j=0; j<2; j++)
        for (int k=0; k<2; k++)
            dp[i + 1][(j + k * a[i]) % 2] += dp[i][j];
printf ("%lld\n", dp[N][P]);
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i, 0, N) cin >> A[i] >> B[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(H + 101010, INF));
    dp[0][0] = 0;
    rep(i, 0, N) rep(j, 0, H + 101010) {
        if (j < A[i]) {
            dp[i + 1][j] = dp[i][j];
        }
        else {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
        }
    }
    ll ans = INF;
    rep(i, H, H + 101010) {
        chmin(ans, dp[N][i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;

int main()
{

    string s;
    cin>>s;

    int a,b,c,d;


    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';


    if(a+b+c+d==7)    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a-b+c+d==7)    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a-b-c+d==7)    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a+b-c+d==7)    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a+b+c-d==7)    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a+b-c-d==7)    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a-b+c-d==7)    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a-b-c-d==7)    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compare_ascending(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

void swap(int* a,int* b){
    int c=*a;
    *a=*b;
    *b=c;
}

int gcd(int a, int b){
    if(a<b){
        swap(&a,&b);
    }while(a%b!=0){
        int c=a%b;
        a=b;
        b=c;
    }
    return b;
}

int main(){
    int n;
    scanf("%d", &n);
    int x;
    int a[n];
    scanf("%d", &x);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    int ans = abs(x - a[0]);
    for(int i=1; i<n; i++){
        ans = gcd(ans, abs(x - a[i]));
    }
    printf("%d", ans);

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int v[100];
    int c[100];
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++)
        cin>>c[i];

    int sum=0;

    for(int i=0;i<n;i++)
    {
        if((v[i]-c[i])>0)
        {
            sum+=(v[i]-c[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

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

int main() {
  vector<string> v;
  // string temp;
  while(true) {
    string temp;
    cin >> temp;
    if(cin.eof()) {
      break;
    }
    if(temp == "+") {
      // string s = v.back();
      int x = atoi(v.back().c_str());
      v.pop_back();
      int y = atoi(v.back().c_str());
      v.pop_back();
      int res = x + y;
      v.push_back(to_string(res));
    } else if(temp == "-") {
      // string s = v.back();
      int x = atoi(v.back().c_str());
      v.pop_back();
      int y = atoi(v.back().c_str());
      v.pop_back();
      int res = y - x;
      v.push_back(to_string(res));
    } else if(temp == "*") {
      // string s = v.back();
      int x = atoi(v.back().c_str());
      v.pop_back();
      int y = atoi(v.back().c_str());
      v.pop_back();
      int res = x * y;
      v.push_back(to_string(res));
    } else {
      v.push_back(temp);
    }
  }
  cout << v[0] << endl;
  return 0;
}


Measured memory_bytes: 3276
#include <stdio.h>

int main(void){

	int x = 1, i = 1;
	while(1){
		scanf("%d", &x);
		if(x != 0){
			printf("Case %d: %d\n", i, x);
			i++;
		}
		
		if(x == 0){
			break;
		}
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

string s;

int main()
{
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7') puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += min(abs(k-a[i])*2,a[i]*2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556