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

using ll = long long;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1001001001;

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)
  {
    assert(n < mod);
    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];
  }
};

void solve()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = INF;
  for(int i = 0; i <= max(x, y); i++) {
    int tmp = a*max(0, x-i) + b*max(0, y-i) + c*2*i;
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 256
#import"iostream"
#define F(i, n)for(int i=0;i<n;i++)
main(){int k,s,c=0,v;std::cin>>k>>s;F(i,k+1)F(j,k+1){v=s-(i+j);if(v<=k&&0<=v)c++;}std::cout<<c;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];
    sort(ALL(s));
    s.erase(unique(ALL(s)), s.end());
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 9520
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int x[] = new int[n];
        for(int i=0;i<n;i++){
            x[i] = sc.nextInt();
        }
        sc.nextLine();
        
        int y[] = new int[n];
        for(int i=0;i<n;i++){
            y[i] = sc.nextInt();
        }
        sc.nextLine();
        
        System.out.println(distanceMinkowski(x, y, n, 1));
        System.out.println(distanceMinkowski(x, y, n, 2));
        System.out.println(distanceMinkowski(x, y, n, 3));
        System.out.println(distanceChebyshev(x, y, n));
    }
    static double distanceMinkowski(int x[], int y[], int n, int p){
        double D = 0;
        for(int i=0;i<n;i++){
            D += Math.pow(Math.abs(x[i]-y[i]),p);
        }
        return Math.pow(D,1.0/p);
    }
    static double distanceChebyshev(int x[], int y[], int n){
        double D = 0;
        for(int i=0;i<n;i++){
            double d = Math.abs(x[i]-y[i]);
            if(D<d){
                D = d;
            }
        }
        return D;
    }
}


Measured memory_bytes: 26724
#include <bits/stdc++.h>
using namespace std;
long long mod=1000000007;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]]++;
  }
  bool f=true;
  if(n%2==1){
    for(int i=0;i<n-1;i+=2){
      if(i==0){
        if(b[i]!=1){
          f=false;
          break;
        }
      }
      else{
        if(b[i]!=2){
          f=false;
          break;
        }
      }
    }
  }
  else{
    for(int i=1;i<n-1;i+=2){
      if(b[i]!=2){
        f=false;
        break;
      }
    }
  }
  if(f){
    long long ans=1;
    for(int i=0;i<n/2;i++){
      ans=ans*2%mod;
    }
    cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
    while(n){
        n/=k;
        ans++;
    }
    out(ans);
}

Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

ans = 0

for i in range(N//R + 1):
    for j in range(N//G + 1):
        if (N - i*R - j*G)%B == 0 and N - i*R - j*G >= 0:
            ans += 1
            
print(ans)

Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
/*
 abcde
 a * 10^4
 b * 10^3
 c * 10^2
 d * 10
 e
 
 a * (11 - 1)^4 ≡ a
 b * (11 - 1)^3 ≡ -b (11がない項は-1のみ)
 c * (11 - 1)^2 ≡ c
 d * (11 - 1) ≡ -d
 e
 
 (a + c + e) - (b + d) = 0であれば11の倍数
 
 最上位桁から見て偶奇を反転してとっていけばいい
 ちなみに7の倍数判定には1001 = 143 * 7が使える
 abcdefghi
 
 abc * 1000000 = abc * 1000^2 = abc * (1001 - 1)^2
 ghi * 1000 = ghi * (1001 - 1)
 jkl
 
 17819
 1 -7 8 -1 9
   -7 8 -1 9
      8 -1 9
        -1 9
           9
 
 累積和をとる
 1 -6 2 1 10
 -7 1 0 9
 0がでてきた
 781は11で割れる
 
 */
int dp[80007][13];
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    while (cin >> s && s[0] != '0') {
        fill_n(*dp, 80007 * 13, 0);
        rep(i, s.size()) {
            int a = s[i] - '0';
            if (i % 2 == 0) a = -a;
            if (s[i] - '0' != 0) dp[i + 1][(a + 11) % 11]++;
            rep(j, 11) {
                dp[i + 1][(j + a + 11) % 11] += dp[i][j];
            }
        }
        int ans = 0;
        rep(i, s.size()) ans += dp[i + 1][0];
        cout << ans << endl;
    }
}



Measured memory_bytes: 7396
gets.to_i.times do
  c = gets.chomp
  a, b = nil, nil
  c.split.select {|s| s.size == 4 }.each do |s|
    # this
    a = (s[2].ord - s[1].ord) % 26
    b = ((s[1].ord - ?a.ord) - a * 7) % 26
    break if s == 'this'.each_char.map {|c| ((a * (c.ord - ?a.ord) + b) % 26 + ?a.ord).chr }.join
    # that
    next unless s[0] == s[3]
    a = 15 * (s[1].ord - s[2].ord) % 26
    b = s[2].ord - ?a.ord
    break if s == 'that'.each_char.map {|c| ((a * (c.ord - ?a.ord) + b) % 26 + ?a.ord).chr }.join
  end
  puts c.tr (?a..?z).map {|c| ((a * (c.ord - ?a.ord) + b) % 26 + ?a.ord).chr }.join, (?a..?z).to_a.join
end

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

int main(){
  string s;
  cin >>s;
  bool mmyy = false;
  bool yymm = false;
  //mmyyから考慮
  if(s.at(0) == '0' && s.at(1) != '0'){
    mmyy = true;
  }
  else if(s.at(0) == '1' && (s.at(1) == '0' || s.at(1) == '1' || s.at(1) == '2')){
    mmyy = true;
  }
  //yymm
  if(s.at(2) == '0' && s.at(3) != '0'){
    yymm = true;
  }
  else if(s.at(2) == '1' && (s.at(3) == '0' || s.at(3) == '1' || s.at(3) == '2')){
    yymm = true;
  }

  if(mmyy == true && yymm == true){
    cout << "AMBIGUOUS" << endl;
  }
  else if(mmyy == false && yymm == true){
    cout << "YYMM" << endl;
  } 
  else if(mmyy == true && yymm == false){
    cout << "MMYY" << endl;
  }
  else{
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int array[200005];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  sort(array,array+n);
  bool is_dist=true;
  for(int i=0;i<n-1;i++){
    if(array[i]==array[i+1]){
      is_dist=false;
    }
  }
  
  if(is_dist){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return(0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<bool> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    ll n,k;cin>>n>>k;
    ll p[MAX2];
    double e[MAX2];
    rep(i,n)cin>>p[i];
    rep(i,n){
        e[i]=((double)p[i]+1.f)/2.f;
    }
    double sum[MAX2];
    sum[0]=0;
    rep(i,n)sum[i+1]=sum[i]+e[i];
    double ans=0.f;
    rep(i,n-k+1){
        chmax(ans,sum[i+k]-sum[i]);
    }
    printf("%.10lf\n",ans);
}

Measured memory_bytes: 8408
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <algorithm>
#include <vector>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>P(M);
  vector<int>Y(M);
  for(int i=0;i<M;i++){
    cin>>P[i]>>Y[i];
    P[i]--;
  }
  vector<vector<int>>s(N);
  for(int i=0;i<M;i++){
    s[P[i]].push_back(Y[i]);
  }
  for(int i=0;i<N;i++){
    sort(s[i].begin(),s[i].end());
  }
  for(int i=0;i<M;i++){
    int v=P[i];
    printf("%06d",v+1);
    int id=lower_bound(s[v].begin(),s[v].end(),Y[i])-s[v].begin();
    printf("%06d\n",id+1);
  }
  return 0;
}

Measured memory_bytes: 9368
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define Q 1000

typedef struct{
  char name[10];
  int time;
} D;

int main(){
  int n, t, i;
  int cnt = 0, head = 0, ta;
  D data[N];

  scanf("%d%d", &n, &t);
  ta = n;

  for(i = 0; i < n; i++){
    scanf("%s%d", data[i].name, &data[i].time);
  }

  while(head != ta){
    if(data[head].time > t){
      data[head].time -= t;
      data[ta] = data[head];
      ta++;
      cnt += t;
    }
    else{
      cnt += data[head].time;
      printf("%s %d\n", data[head].name, cnt);
    }
    head++;
    if(head >= N) head = 0;
    if(ta >= N) ta = 0;
  }

  return 0;
}



Measured memory_bytes: 3256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int f(int n) {
    if (n % 2 == 0)
        return n / 2;
    else
        return 3 * n + 1;
}

int main() {
    vector<int> a;
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    while (true) {
        a.push_back(f(a.back()));
        if (find(a.begin(), a.end() - 1, a.back()) != a.end() - 1)
            break;
        else
            continue;
    }

    cout << a.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

constexpr unsigned long maxN = 200010;

array<unsigned long, maxN> perm;
    array<unsigned long, maxN> binary;
    array<unsigned long, maxN> coef;
    array<unsigned long, maxN> fenwick_tree;

    unsigned long que(unsigned long i){
        unsigned long s{0}, j{i};
        while (i) { s += fenwick_tree[i]; i -= i & -i; }
        while (j < maxN) { ++fenwick_tree[j]; j += j & -j; }
        return s;
    };


int main() {
    //using namespace std;
   
    unsigned long N;
    scanf("%lu", &N);
   
    {
        array<pair<long, long>, maxN> p;
        for(unsigned long i = 0; i < N; ++i)scanf("%lu%lu", &p[i].first, &p[i].second);
        sort(p.begin(), p.begin() + N);
        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};
        sort(p.begin(), p.begin() + N);
        transform(p.cbegin(), p.cbegin() + N, perm.begin(), [](auto i){return i.second;});
    }

    constexpr unsigned long MOD = 998244353;

    unsigned long n = binary[0] = 1;
    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});




    coef[N] = N + MOD - 4;
    for(unsigned long i = 0; i != N; ++i){
        auto p = perm[i], q = que(p);
        ++coef[q];
        ++coef[i - q];
        ++coef[p - q - 1];
        ++coef[N - i - p + q];
    }

    printf("%lu", inner_product(binary.begin(), binary.begin() + N + 1, coef.begin(), 4 + MOD - N) % MOD);
    return 0;
}


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

const int N = 1e5 + 10;

vector <int> tr[N];
int a[N], p[N], indeg[N];
long long rec[N];

void dfs(int x, int fa){
	long long sum;
	p[x] = fa;
	if ((int)tr[x].size() == 1) rec[x] = a[x];
	else{
		sum = 0;
		for (int i = 0; i < (int)tr[x].size(); i++){
			if (tr[x][i] == fa) continue;
			dfs(tr[x][i], x);
			sum += rec[tr[x][i]];
		} 
		rec[x] = a[x] * 2 - sum;
		if (rec[x] < 0){
			printf("NO\n");
			exit(0);
		}
	}
}

int main(){
	int n, u, v, root;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	memset(indeg, 0, sizeof(indeg));
	for (int i = 1; i <= n - 1; i++){
		scanf("%d %d",&u,&v);
		tr[u].push_back(v);
		tr[v].push_back(u);
		indeg[u]++; indeg[v]++;
	}
	if (n == 2){
		if (a[1] == a[2]) printf("YES\n");
		else printf("NO\n");
		return 0;
	}
	for (int i = 1; i <= n; i++){
		if (indeg[i] > 1){
			root = i;
			break;
		}
	}
	dfs(root, 0);
	if (rec[root]){
		printf("NO\n");
		return 0;
	}
	for (int i = 1; i <= n; i++){
		if (i == root) continue;
		if (rec[i] > min(a[i], a[p[i]])){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a + b;
  if (c == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll x = n / c * a;
  ll y = min(n % c, a);
  cout << x + y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string n;
    cin >> n;
    if(n[n.size()-1]=='3')cout << "bon";
    else if(n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8')cout << "pon";
    else cout << "hon";
}   

Measured memory_bytes: 3592
# Finding Missing Cards

n = int(input())

exist = []
for i in range(4):
    exist.append([0 for j in range(13)])

for i in range(n):
    cards = [a for a in input().rstrip().split()]
    p = cards[0]
    k = int(cards[1]) - 1
    if p == 'S':
        exist[0][k] = 1
    elif p == 'H':
        exist[1][k] = 1
    elif p == 'C':
        exist[2][k] = 1
    elif p == 'D':
        exist[3][k] = 1

# print()

figure = ['S', 'H', 'C', 'D']
# print('足りないカードは')
for i in range(4):
    for j in range(13):
        if exist[i][j] == 0:
            print(figure[i] + ' ' + str(j + 1))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H,W;cin>>H>>W;
    int h,w;cin>>h>>w;
    int sum=H*W;
    int gyo_dif = h*W;
    int retsu_dif = w*H;
    int hokan = h*w;
    int ans = sum - gyo_dif - retsu_dif + hokan;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000

int solve(int,int);

int n, q, A[N], M[N];

int main()
{
  int i, j, flag=0;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  
  scanf("%d", &q);
  
  for(i=0; i<q; i++)
    scanf("%d",&M[i]);
  
  for(i=0; i<q; i++){
    flag = solve(0,M[i]);
    if(flag>=1) printf("yes\n");
    else if(flag==0) printf("no\n");
  }
  
  return 0;
  
}

int solve(int i, int m)
{
  int res=0;
  if(m==0) return 1;
  if(i>=n) return 0;
  res += solve(i+1,m);
  res += solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    int N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    ll n, r = -1;
    n = *max_element(all(A));
    A.erase(find(all(A), n));
    ll m = n / 2;
    rep(i, N - 1) {
        if (abs(A[i] - m) < abs(r - m)) r = A[i];
    }
    cout << n << " " << r << endl;
    return 0;
}

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


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto K = readln.chomp.to!int;
    auto S = readln.chomp;
    if (S.length <= K) {
        writeln(S);
    } else {
        writeln(S[0..K], "...");
    }
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char s[200005],t[200005];
   int a,b=0;
   cin>>s;
   cin>>t;
   a=strlen(s);
   for(int i=0;i<a;i++)
   {
       if(s[i]!=t[i])
        b++;
   }
   cout<<b<<endl;
}


Measured memory_bytes: 3952
import math
#入力値を定義
N, A, B, C, D, E = eval("int(input())," * 6)
# Nをmin(A~E)で割った商を繰り上げた分だけ、移動が余計にかかる
print(4 + math.ceil(N / min(A, B, C, D, E)))


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

int main() {
    int s;
    int count = 0;
    
    cin >> s;
    
    count = count + s % 10;
    s = s / 10;
    
    count = count + s % 10;
    s = s / 10;
    
    count = count + s % 10;
    s = s / 10;
    
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
int N;
int ans[222222];
signed main(){
    cin>>N;
    vpint latte;
    rep(i,N){
        int a;cin>>a;
        latte.pb({a,i});
    }
    sort(all(latte));
    rep(i,latte.size()){
        if(i<N/2){
            ans[latte[i].se]=latte[N/2].fi;
        }
        else{
            ans[latte[i].se]=latte[N/2-1].fi;
        }
    }
    rep(i,N)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N;string s;cin>>N>>s;
    string test="";
    bool flag=true;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }else{
        for(int i=0;i<N/2;i++){
            test+=s.at(i);
        }
        for(int i=N/2;i<N;i++){
            if(test.at(i-N/2)!=s.at(i)){
                flag=false;
                break;
            }
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3596
import sys
from math import log, ceil, floor

fin = sys.stdin.readline
A, B = [int(elem) for elem in fin().split()]

def official_solution(A, B):
    def partial_f(n):
        if n == 0:
            return 0
        return ((n + 1) >> 1) & 1 if n & 1 else n | ((n >> 1) & 1)

    return partial_f(A - 1) ^ partial_f(B)


def naive_solution(A, B):
    def calc_num_bits(num):
        num_bits = 0
        while num:
            num_bits += 1
            num >>= 1
        return num_bits
    
    def partial_f(num):
        if num <= 0: return 0
        num_bits = calc_num_bits(num)
        result = ((num >> 1) + (num & 1)) % 2
        for d in range(1, num_bits):
            base = 1 << d
            rem = num % (base << 1)
            parity = max(0, rem - base + 1) & 1
            if parity:
                result |= base
        return result

    return partial_f(A - 1) ^ partial_f(B)

print(naive_solution(A, B))


Measured memory_bytes: 3064
from collections import*
z,v,a=input,range,print
h,w,k=map(int,z().split());r,s,t,u=map(lambda x:int(x)-1,z().split());b=[z()for _ in v(h)];l=[[-1]*w for _ in v(h)];l[r][s]=0;d=deque([(r,s)])
while d:
  x,y=d.popleft();j=l[x][y]
  if(x==t)&(y==u):exit(a(j))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      p,q=x+e*i,y+f*i
      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@" or 0<=l[p][q]<=j:break
      if l[p][q]<0:d+=[(p,q)];l[p][q]=j+1
a(-1)

Measured memory_bytes: 93856
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[10];
    // ll n;
    scanf("%s",s);
    // ll [n];
    ll a,b,c,d;
    a=s[0]-'0'; b=s[1]-'0'; c=s[2]-'0'; d=s[3]-'0';
    ll ans=0;
    rep(i,0,POW(2,3)){
        ans=0;
        ans+= a ;
        ans+= (i&4) ? b : -b ;
        ans+= (i&2) ? c : -c ;
        ans+= (i&1) ? d : -d ;
        if(ans==7){
            printf("%lld",a);

            if(i&4) printf("+");
            else printf("-");
            printf("%lld",b);

            if(i&2) printf("+");
            else printf("-");
            printf("%lld",c);

            if(i&1) printf("+");
            else printf("-");
            printf("%lld",d);

            printf("=7\n");
            return 0;
        }
    }

    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
//#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    list<int> lst;
    string s;
    cin >> n;
    for(int i=0;i < n;i++){
        cin >> s;
        if(s[0] == 'i'){
            int tmp;
            cin >> tmp;
            lst.push_front(tmp);
        }
        else if(s[6] == 'F'){
            lst.pop_front();
        }
        else if(s[6] == 'L'){
            lst.pop_back();
        }
        else{
            int tmp;
            cin >> tmp; 
            for(list<int>::iterator itr = lst.begin(); itr != lst.end();++itr ) {
                if( *itr == tmp ){       //  要素が 1 ならば
                    lst.erase(itr);    // 要素を削除し、itr は次の要素を指す
                    break;
                }
            }
        }
    }
    for(auto itr = lst.begin(); itr != lst.end();){
        cout << *itr;
        ++itr;
        if(itr != lst.end()){
            cout << " ";
        }
    }
    print("");
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 34408
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,h[N] ,mn = 1e9+5 ;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",h+i);
    for(int i=n-1;i>=0;--i){
        mn = min(mn,h[i]);
        int x = h[i] - mn ;
        if(x>1) return cout << "No",0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float('inf')

for i in range(1<<d):
  count = 0
  sum = 0
  nokori = set(range(1, d+1))
  
  for j in range(d):
    if i & (1 << j):
      sum += pc[j][0]*(j+1)*100 + pc[j][1]
      count += pc[j][0]
      nokori.discard(j+1)
      
  if sum<g:
    use = max(nokori)
    n = min(pc[use-1][0], -(-(g-sum)//(use*100)))
    count += n
    sum += n*use*100
    
  if sum>=g:
    ans = min(ans, count)
    
print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    ll sum = a + b;
    cout << a*(n/sum) + min(a,n-sum*(n/sum)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<string>
using namespace std;
string replace(string s, string f, string t){
	string r;
	for(int p=0;(p=s.find(f))!=s.npos;){
		r+=s.substr(0,p)+t;
		s=s.substr(p+f.size());
	}
	return r+s;
}
int main(){
	string s;
	while(getline(cin,s)){
		s=replace(s,"peach","APPLE"); s=replace(s,"apple","PEACH");
		s=replace(s,"APPLE","apple"); s=replace(s,"PEACH","peach");
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
    
using namespace std;
    
int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;        

    if((r <= x) && (x + r <= W) && (r <= y) && (y + r <= H)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long n, a, b; cin >> n >> a >> b;
	if (a > b)cout << 0 << endl;
	else
	if (n == 1) {
		if (a == b)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else cout << (n - 2)*(b - a) + 1 << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int kyori, hayasa, a, v, b, w, t;

  cin >> a >> v >> b >> w >> t;

  if (a >= b) {
    kyori = a - b;

  } else {
    kyori = b - a;
  }

  hayasa = v - w;

  if (hayasa <= 0) {
    hayasa = 0;
  }

  if (kyori > hayasa * t) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return 0;
}

Measured memory_bytes: 3636
S = input()
z_o_cnt = 0
o_z_cnt = 0

for i,s in enumerate(S):
    if i % 2 == 0:
        if s== '0':
            z_o_cnt += 1
        else:
            o_z_cnt += 1
    else:
        if s == '0':
            o_z_cnt += 1
        else:
            z_o_cnt += 1

print(len(S) - (z_o_cnt if z_o_cnt > o_z_cnt else o_z_cnt))

Measured memory_bytes: 3188
#深さ優先探索(DFS)

import sys
sys.setrecursionlimit(1000000)

h,w = map(int,input().split())
s = [input() for _ in range(h)]
t = [[None]*w for _ in range(h)]


def dfs(i,j,color):

  if not (0<=i<h and 0<=j<w):return 0,0
  if s[i][j]==color: return 0,0
  if t[i][j]:return 0,0
 
  t[i][j]=True
  wh,bl=0,0
  
  if s[i][j]=="#":
    bl+=1
  else:
    wh+=1

  #再起呼び出し
  tmp1,tmp2=dfs(i+1,j,s[i][j])
  wh,bl=wh+tmp1,bl+tmp2
 
  tmp1,tmp2=dfs(i-1,j,s[i][j])
  wh,bl=wh+tmp1,bl+tmp2
        
  tmp1,tmp2=dfs(i,j-1,s[i][j])
  wh,bl=wh+tmp1,bl+tmp2
 
  tmp1,tmp2=dfs(i,j+1,s[i][j])
  wh,bl=wh+tmp1,bl+tmp2
 
  return wh,bl
 
ans=0
for i in range(h):
  for j in range(w):
    a,b=dfs(i,j,"!")
    ans+=a*b
 
print(ans)

Measured memory_bytes: 138728
#include<iostream>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<s.size()+1;j++){
			if(s[i]==s[j] && i!=j){
				ans=ans+1;
			}
		}
	}
	if(ans>0){
		cout<<"no"<<endl;
	}
	else{
		cout<<"yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <map>
using namespace std;

#define N 40
#define BIT (1<<17)
#define mod 1000000007

int add(int x,int y) {
  int ret = x+y;
  if(ret<0) {
    ret += mod;
  } else if(ret>=mod) {
    ret -= mod;
  }
  return ret;
}
int n,x[3],maxi;

int dp[N][BIT][2];
map<int,int> failure;
int ar[1000],tot = 0;

int failureCall(int bit) {
  if(bit==0) {
    return 0;
  }
  int nbit;
  if(failure.count(bit)) {
    return failure[bit];
  }
  for(int i=0;;++i) {
    if(bit&(1<<i)) {
      nbit = bit>>(i+1);
      break;
    }
  }
  if(nbit==0) {
    return 0;
  }
  if(nbit>=BIT) {
    return failure[bit] = failureCall(nbit);
  }
  int ret = 0;
  int sum = 0,cur = 0;
  int lastBit = -1;
  bool isGood = true;
  for(int i=0;;++i) {
    if((1<<i) >nbit) {
      break;
    }
    if(nbit&(1<<i)) {
      int a = i-lastBit;
      lastBit = i;
      sum += a;
      if(sum==x[cur]) {
        ++cur;
        sum = 0;
      }else if (sum>x[cur]) {
        isGood = false;
        break;
      }
    }
  }
  if(isGood) {
    return failure[bit] = nbit;
  } else {
    return failure[bit] = failureCall(nbit);
  }
}

map<int,pair<int,int> > BB;
pair<int,int> newBit(int bit,int num) {
  tot = 0;
  int lastBit = -1;
  int pos = 0;
  for(int i=0;i<17;++i) {
    if(bit&(1<<i)) {
      ar[pos++] = i-lastBit;
      lastBit = i;
    }
  }
  if(num!=-1) {
    ar[pos++] = num;
    bit |= (1<<(lastBit + num));
  }
  if(bit>=BIT) {
    return newBit(failureCall(bit),-1);
  }
  int cur = 0,sum = 0;
  for(int i=0;i<pos;++i) {
    sum += ar[i];
    tot += ar[i];
    if(sum==x[cur]) {
      ++cur;
      sum = 0;
    } else if(sum>x[cur]) {
      return newBit(failureCall(bit),-1);
    }
  }
  if( cur!=3) {
    return make_pair(0, bit);
  } else {
    //success but need failure
    return make_pair(1 , failureCall(bit));
  }
}
int solveDp(int ind,int bit,int isSatisfy) {
  if(ind==n) {
    if(isSatisfy) {
      return 1;
    } else {
      return 0;
    }
  }
  int &ret = dp[ind][bit][isSatisfy];
  if(ret!=-1) {
    return ret;
  }
  ret = 0;
  for(int num=1;num<=10;++num) {
    pair<int,int> nBit;
    if(num>maxi) {
      nBit = make_pair(0,0);
    } else {
      nBit = newBit(bit,num);
    }
    ret = add(ret, solveDp(ind+1,nBit.second, isSatisfy | nBit.first));
  }
  return ret;
}
void solve() {
  scanf("%d ", &n);
  for(int i=0;i<3;++i) {
    scanf("%d ", &x[i]);
    maxi = max(maxi,x[i]);
  }
  memset(dp,-1,sizeof(dp));
  printf("%d\n", solveDp(0,0,0));
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 48896
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
  string s ; cin>> s ;
  ll k = s.size() ;
  if((s[0]==s[k-1]&&(k%2)==1) ||(s[0]!=s[k-1]&&(k%2)==0)) cout<<"Second"<<endl ;
  else cout<<"First"<<endl ;

   return 0 ;
 }



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

int judge(int n){
    int lst[]={0,0,0};
    while(n>0){
        switch(n%10){
            case 3 :lst[0]++;break;
            case 5 :lst[1]++;break;
            case 7 :lst[2]++;break;
            default : return 0 ;
        }
        n=n/10;
    }
    for(int i:lst){
        if(i==0)return 0;
    }
    return 1;
}

int main(void){
    int ans=0,n;
    scanf("%d",&n);
    for(int i=357;i<n;i+=10){
        ans+=judge(i);
    }
    for(int i=375;i<n;i+=10){
        ans+=judge(i);
    }
    for(int i=573;i<n;i+=10){
        ans+=judge(i);
    }
    ans+=judge(n);
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
/** GRAPH
int edgenum, head[maxn], vet[2 * maxn], nxt[2 * maxn], wt[2 * maxn];
void addedge(int u, int v) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
}
void addedge(int u, int v, int w) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
	wt[edgenum] = w;
}
GRAPH **/

using namespace std;
int a[100005], x, y;
int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	for(int i = 1; i <= k; i ++) {
		cin >> x;
		for(int i = 1; i <= x; i ++) cin >> y, a[y] ++;
	}
	for(int i = 1; i <= n; i ++) if(a[i] == 0) ans ++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int A = 0, B = 0, C = 0;
	cin >> A >> B >> C;

	int m = 0, day = 0;
	while(m < C) {
		day++;
		m += A;
		if(day%7 == 0) m += B;
	}
	cout << day << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;

  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o' ){
      cout << "vowel" << endl;
  }
  else{
      cout << "consonant" << endl;
  }
}

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

int main() {
	string S, ABC = "ABC";
	static long long DP[100010][4] = {}, MOD = 1000000007;
	DP[0][0] = 1;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '?') {
			DP[i + 1][0] = (DP[i][0] * 3) % MOD;
			for (int j = 0; j < 3; j++) {
				DP[i + 1][j + 1] = (DP[i][j] + DP[i][j + 1] * 3) % MOD;
			}
		}
		else {
			DP[i + 1][0] = DP[i][0];
			for (int j = 0; j < 3; j++) {
				if (S[i] == ABC[j]) {
					DP[i + 1][j + 1] = (DP[i][j] + DP[i][j + 1]) % MOD;
				}
				else DP[i + 1][j + 1] = DP[i][j + 1] % MOD;
			}
		}
	}
	cout << DP[S.size()][3] << endl;
}

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

int main()
{
    long long x, y, a, b, r, prod;
    cin >> x >> y;
    prod = x * y;
    a = x; b = y;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    cout << prod / a;
    return 0;
}


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


#define INF 1000000000000


signed main()
 {
   int n,k;
   cin>>n>>k;
   vector<int>x(n);
   vector<int>y(n);
   vector<int>z(n);
   vector<int>s(n);
   rep(i,n){
     cin>>x[i]>>y[i]>>z[i];
   }
   int M=0;
   for(int i=0;i<=7;i++){
     int a,b,c;
     a=i%2;
        c=i/4;
     b=(i-a-c*4)/2;

     rep(i,n){
       s[i]=x[i]*pow(-1,a)+y[i]*pow(-1,b)+z[i]*pow(-1,c);
     }
     sort(s.begin(),s.end());
     int tmp=0;
     for(int i=n-k;i<=n-1;i++){
       tmp+=s[i];
     }
   M=max(M,tmp);
 }
 cout<<M;
}


Measured memory_bytes: 256
import java.util.*;

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

      if (input == 25) {
        System.out.println("Christmas");
      } else if (input == 24) {
        System.out.println("Christmas Eve");
      } else if (input == 23) {
        System.out.println("Christmas Eve Eve");
      } else if (input == 22) {
        System.out.println("Christmas Eve Eve Eve");
      }
    }
  }
}


Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int n,k;
    int ans;

    while(scanf("%d%d",&n,&k) != EOF)
    {
        ans = 1;
        while(n--)
        {
            if(ans < k) ans += ans;
            else ans += k;
        }
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>

using ll = long long;
using namespace std;

ll MOD = 1'000'000'007;
vector<vector<ll>> memo;
ll L, R;

ll solve(int i = 60, int A = 0, int B = 0, int C = 0){
    ll L0 = L & (1ll << i);
    bool Lcond = L0 == 0 or A;
    ll R1 = R & (1ll << i);
    bool Rcond = R1 > 0 or B;
    ll k = 4*A + 2*B + C;
    if(i < 0) return 1;
    if(memo[i][k] != -1) return memo[i][k];
    ll ans = 0;

    if(Lcond){
        // xi 0, yi 0
        ans += solve(i-1, A, R1 > 0 ? 1 : B, C);
    }

    if(Lcond and Rcond and C){
        // xi 0, yi 1
        ans += solve(i-1, A, B, C);
    }

    if(Rcond){
        // xi 1, yi 1
        ans += solve(i-1, L0 == 0 ? 1 : A, B, 1);
    }
    return memo[i][k] = ans % MOD;
}

void sub_main(istream &is) {
    is >> L >> R;
    if(!is) return;
    memo.clear();
    memo.resize(61, vector<ll>(8, -1));
    cout << solve() << endl;


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_F.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  ll now;
  if(n%2) now=0;
  else now=1;
  for(auto e: m){
    if(e.first!=now || (now!=0 && e.second!=2)){
      cout<<0<<endl;
      return 0;
    }
    now+=2;
  }
  cout<<modpow(2,n/2)<<endl;
}

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

int main() {
  int N;
  int K;
  cin>>N>>K;
  int A=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    A+=x*2;
    if(x>K-x){
      A-=x*2;
      A+=(K-x)*2;
    }
  }
  cout<<A<<endl;
}


Measured memory_bytes: 3644