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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 3e5 + 5;
const int inf = 1e18 + 2;


void solve(int Case) {
    string s ;
    cin >> s ;
    if(s.back() == 's') cout << s << "es" << '\n';
    else cout << s << "s" << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case);
    }
    return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n,a,b;cin>>n>>a>>b;
  ll res=0;
  ll pos;cin>>pos;
  for(ll i=1;i<n;i++){
    ll nx;
    cin>>nx;
    res+=min((nx-pos)*a, b);
    pos=nx;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  rep(i,n) cin>>p[i].se;
  rep(i,n) cin>>p[i].fi;
  sort(rng(p));
  vi a(n);
  rep(i,n) a[i] = p[i].se;
  vi o = a;
  sort(rng(a));
  rep(i,n) if (a[i] > p[i].fi) dame;
  bool ok = false;
  rep(i,n-1) if (a[i+1] <= p[i].fi) ok = true;
  map<int,int> mp;
  rep(i,n) mp[o[i]] = i;
  {
    int i = 0;
    vi used(n);
    int cnt = 0;
    while (!used[i]) {
      used[i] = 1;
      i = mp[a[i]];
      ++cnt;
    }
    if (cnt != n) ok = true;
  }
  if (!ok) dame;
  cout<<"Yes"<<endl;
  return 0;
}






















Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int a,b,c;
    cin >> a >> b >> c;
    bool can = false;

    int i=1;
    while(i*a<=a*b){
        if((i*a)%b == c)
            can = true;
      	i++;
    }

    if(can)
    cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    
}

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

void RotateString(string&);
bool CheckMatch(string&, string&);

int main() {
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		RotateString(S);
		if (CheckMatch(S, T)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

void RotateString(string& string) {
	char tmp_char = string[0];
	for (int i = 0; i < string.size() - 1; i++) {
		string[i] = string[i + 1];
	}
	string[string.size() - 1] = tmp_char;
}

bool CheckMatch(string& S, string& T) {
	int string_size = S.size();
	for (int i = 0; i < string_size; i++) {
		if (S[i] != T[i]) break;
		if (i == string_size - 1) return true;
	}
	return false;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(K)]

dp = [0] * (N + 1)
dp_sums = [0] * (N + 1)
dp[1] = dp_sums[1] = 1

for i in range(2,N+1):
    for l, r in S: 
        if i >= r + 1:
            dp[i] += dp_sums[i - l] - dp_sums[i - r - 1] 
            dp_sums[i] = dp_sums[i-1] + dp[i]
        elif i > l and i < r + 1:
            dp[i] += dp_sums[i - l] 
            dp_sums[i] = dp_sums[i-1] + dp[i]
        elif i <= l:
            dp_sums[i] = dp_sums[i-1] + dp[i]
    dp[i] %= 998244353
    dp_sums[i] %= 998244353
print(dp[N])

Measured memory_bytes: 76900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n, m;
int a[100010], b[100010];
vector<int> G[100010];
vector<int> rG[100010];
bool used[100010];

signed main(int argc, char const *argv[])
{
	cin >> n >> m;
	rep(i, n + m - 1) cin >> a[i] >> b[i];
	rep(i, n + m - 1) a[i]--, b[i]--;
	rep(i, n + m - 1) {
		G[a[i]].pb(b[i]);
		rG[b[i]].pb(a[i]);
	}

	vector<int> in(n, 0);
	rep(i, n) in[i] = rG[i].size();

	ll root;
	rep(i, n) if (rG[i].size() == 0) {
		root = i;
	}

	vector<int> parent(n, 0);
	queue<int> que; que.push(root);
	while(!que.empty()) {
		int u = que.front(); que.pop();
		used[u] = true;
		for (auto v : G[u]) {
			in[v]--;
			if (in[v] == 0) {
				parent[v] = u + 1;
				que.push(v);
			}
		}
	}

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


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,m;
	cin>>n>>m;
	lvi a(n+1,0);
	ll sum1=0;
	for (int i = 0; i <n; ++i)
	{
		cin>>a[i];
		sum1+=a[i];
	}
	ll x=ceil((ld)sum1/(ld)(4*m)),ct=0;
	for (int i = 0; i < n; ++i)
	{
		if(a[i]>=x) ct++;
	}
	if(ct>=m) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){
      init(n);
    }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){
      return root(x) == root(y);
    }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  i64 n,m,k;
  cin >> n >> m >> k;

  uf tree(n);
  vi cnt(n,1);

  i64 a,b;
  rep(i,m){
    cin >> a >> b;
    a--;b--;
    tree.unite(a,b);
    cnt[a]++;
    cnt[b]++;
  }
  rep(i,k){
    cin >> a >> b;
    a--;b--;
    if(tree.same(a,b)){
      cnt[a]++;
      cnt[b]++;
    }
  }
  rep(i,n){
    cout << tree.num(i) - cnt[i];
    if(i!=n-1) cout << " ";
    else cout << endl;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 3968
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: [chars; h],
    }
    let mut a = vec![vec![0; w]; h];
    let mut cnt = 0;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                cnt += 1;
                a[i][j] = cnt;
            }
        }
    }
    assert!(cnt == k);
    for i in 0..h {
        for j in 1..w {
            if a[i][j - 1] != 0 && a[i][j] == 0 {
                a[i][j] = a[i][j - 1];
            }
        }
    }
    for i in 0..h {
        for j in (1..w).rev() {
            if a[i][j - 1] == 0 && a[i][j] != 0 {
                a[i][j - 1] = a[i][j];
            }
        }
    }
    for i in 1..h {
        for j in 0..w {
            if a[i - 1][j] != 0 && a[i][j] == 0 {
                a[i][j] = a[i - 1][j];
            }
        }
    }
    for i in (1..h).rev() {
        for j in 0..w {
            if a[i - 1][j] == 0 && a[i][j] != 0 {
                a[i - 1][j] = a[i][j];
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            assert!(a[i][j] != 0);
            write!(out, "{}", a[i][j]).ok();
            if j == w - 1 {
                writeln!(out, "").ok();
            } else {
                write!(out, " ").ok();
            }
        }
    }
}

fn main() {
    run();
}


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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

inline bool operator<(const Point &a, const Point &b){
    if (sgn(a.real() - b.real()))
        sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag());
}

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

struct Circle{
    Point p;
    double r;
    Circle(Point p=Point(), double r=0):p(p),r(r){}
};

int intersect_circle(Circle a, Circle b){
    double dsq = norm(a.p - b.p);
    double rs = (a.r + b.r) * (a.r + b.r);
    double rd = (a.r - b.r) * (a.r - b.r);
    if(dsq > rs)return 0;
    else if(dsq <= rs && dsq >= rd)return 1;
    else if(a.r > b.r)return 2;
    else return -2;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        cout << intersect_circle(Circle(Point(xa, ya), ra), Circle(Point(xb, yb), rb)) << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int n = Integer.parseInt(s.next());
        List<Integer> v = new ArrayList<>();
        List<Integer> c = new ArrayList<>();

        for(int i = 0; i < n; i++)
            v.add(Integer.parseInt(s.next()));
        for(int i = 0; i < n; i++)
            c.add(Integer.parseInt(s.next()));

        int now = 0;
        for(int i = 0; i < n; i++){
            int vvalue = v.get(i);
            int cvalue = c.get(i);
            if(vvalue - cvalue > 0)
                now += vvalue - cvalue;
        }

        System.out.println(now);
    }

}


Measured memory_bytes: 21332
N, M = map(int, input().split())
all_switches = [[] for _ in range(N)]

for i in range(M):
    input_text = list(map(int, input().split()))
    switches = input_text[1:]
    for switch in switches:
        all_switches[switch - 1].append(i)


# 電球が光る条件(M個)
lightup_terms = list(map(int, input().split()))
# print(all_switches)
count = 0
for i in range(1 << N):
    lightup_counts = [0 for _ in range(M)]
    for j in range(N):
        # 組み合わせを一つずつ確認する
        if i >> j & 1:
            for light in all_switches[j]:
                lightup_counts[light] += 1
    # print(lightup_counts)
    compute_success = True
    for j, term in enumerate(lightup_terms):
        if lightup_counts[j] % 2 != term:
            compute_success = False
            break
    if compute_success:
        count += 1
print(count)


Measured memory_bytes: 42076
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, x, ans=0, sum = 0;
	cin >> n >> x;
	vector<int> m(n);
	rep(i,n){
		cin >> m[i];
		sum+=m[i];
	}
	x-=sum;
	sort(all(m));
	cout << n+x/m[0] << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 各桁について、"1"の数が n // 2 以下だったら "1"、 そうでなければ "0"

from math import log2
num = int(log2(10**12) + 1)
box = [0] * (num + 1)
for i in a:
  l = bin(i)[2:][::-1]
  for itr, val in enumerate(l):
    box[itr] += int(val)

X = 0
for itr, val in enumerate(box[::-1]):
  if val <= n // 2 and X + 2 ** (num - itr) <= k:
    X += 2 ** (num - itr)

ans = 0
for i in a:
  ans += X ^ i
  
print(ans)
    

Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n;
    cin >>n;
    vector<int> a(3);
    vector<int> b(n);
    rep(i,100){
        a[0]=i+1;
        rep(j,100){
            a[1]=j+1;
            rep(k,100){
                a[2]=k+1;
                int x;
                x=a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[0]*a[1]+a[1]*a[2]+a[2]*a[0];
                if(x>n){
                    break;
                }
                else{
                    b[x-1]++;
                }
            }
        }
    }
    rep(i,n){
        cout << b[i] << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int n,k;
int a[100100];

int main()
{
  cin >> n;
  for (int i = 0; i < n; ++i)
  cin >> a[i + 1];
  for (int i=1; i <= n; ++i)
  if(a[a[i]]==i) ++k;
  cout << k/2;
  
  return 0;
}


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


using namespace std;

typedef long long ll;
typedef vector<vector<int> > Graph;


int main() {
    int N,P;
    cin>>N>>P;
    string s;
    cin>>s;
    
    ll count=0;
    ll arr[N+1];
    for(int i=0;i!=N;++i)arr[i]=0;
    
    reverse(s.begin(),s.end());
    
    if(P==2||P==5){
        for(int i=0;i!=N;++i){
            if((s[i]-'0')%P==0){
                count+=N-i;
            }
        }
    }else{
        
        
        
        
        ll keta=1;
        ll num=0;
        arr[0]=0;
        for(int i=1;i<=N;++i){
            num+=(s[i-1]-'0')*keta;
            num%=P;
            arr[i]=num;
            keta=keta*10%P;
        }
        
        /* for(int i=0;i<=N;++i)cout<<arr[i];
        cout<<endl;
         */
        
        ll amari[P];
        for(int i=0;i!=P;++i)amari[i]=0;
        
        for(int i=0;i<=N;++i){
            ll tmp=arr[i];
            ++amari[tmp];
        }
        
        for(int i=0;i!=P;++i){
           // cout<<i<<": "<<amari[i]<<endl;
            count+=(amari[i])*(amari[i]-1)/2;
        }
        
    }
    cout<<count<<endl;
}


Measured memory_bytes: 5264
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <math.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

    int N, Y;
    cin >> N >> Y;
    int a=-1, b=-1, c=-1;
    
    if(10000*N >= Y){
        for(int i=0;i<N+1;i++){
            for(int j=0;j<N-i+1;j++){
                if (i*10000+j*5000+(N-i-j)*1000==Y) {
                    a = i; b = j; c = N - i - j;
                    break;
                }
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

#define mx 200005
#define ll long long

int ar[mx];
char ch[mx];

int n,m,k,ii;

void solve()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",&ar[i]);
    for(int i=k+1;i<=n;i++)
    {
        if(ar[i]>ar[i-k])
        {
            printf("Yes\n");
        }
        else printf("No\n");
    }
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    int l,i=0;
    while(cin>>l){
        vec[i] = l;
        i++;
    }
    for(i = vec.size()-1; i > 0; i--){
        cout << vec[i] << " ";
    }
    cout << vec[0] << endl;
}


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

int main() {
    int64_t n;
    cin >> n;
    map<string, int64_t> s;
    int64_t ans = 0;
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        sort(t.begin(), t.end());
        ans += s[t]++;
    }

    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
const int N = 1000001;

int main(void){
    vector<bool> isP(N);
    fill(ALL(isP), true);
    rep(i, 2) isP[i] = false;
    for(int i = 2; i * i < N; i ++) if(isP[i]) for(int j = i * i; j < N; j += i) isP[j] = false;

    for(int n, x; cin >> n >> x, n;){
        vector<bool> dp(x + 1);
        fill(ALL(dp), false);
        dp[0] = true;
        while(n --){
            int m; cin >> m;

            rep(i, x - m + 1) if(dp[i]) dp[i + m] = true;
        }
        while(~x && !(dp[x] && isP[x])) x --;
     
        if(~x) cout << x << endl;
        else cout << "NA" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K;
ll MOD = 1000000007;
ll ans = 0;

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<ll, ll> firstElof, pair<ll, ll> secondElof)
{
	return firstElof.second > secondElof.second;
}
//////////////
int main()
{
	cin >> N >> K;
	vector<int>A(N);
	int one;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] == 1) {
			one = i;
		}
	}
	if ((N - 1) % (K - 1) == 0) {
		cout << (N - 1) / (K - 1);
	}
	else {
		cout << (N - 1) / (K - 1) + 1;
	}

}

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

int main(){
int N; cin >> N;
vector<int> W(N);
for (int i = 0; i < N; i++) {
    cin >> W[i];
}
int ans = 10000;
for (int T = 0; T < N; T++) {
    int left = 0;
    int right = 0;
    for (int i = 0; i < T; i++) {
        left += W[i];
    }
    for (int j = T; j < N; j++) {
        right += W[j];
    }
    ans = min(ans, abs(left - right));
}
cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.random;
   
void main() {
  while (1) {
    auto x = readln.chomp.split.map!(to!int).array;
    if (!x[0] && !x[1]) break;
    x.sort.map!(to!string).join(" ").writeln;
  }
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {cout << "Balanced" << endl;}
  else if (A + B <= C + D) {cout << "Right" << endl;}
  else {cout << "Left" << endl;}
}

Measured memory_bytes: 3568
/**
 *    author:  FromDihPout
 *    created: 2020-08-13
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<bool> seen(4);
    for (int i = 0; i < 3; i++) {
        int x;
        cin >> x;
        seen[x] = true;
    }
    for (int i = 1; i <= 3; i++) {
        if (!seen[i]) {
            cout << i;
        }
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 500000;
const int MAX = 300000;
const int MOD = 1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m = 0;
    int K;cin>>K;
    for(int i = 0; i < K; i++) {
        m *= 10; m += 7; m %= K;
        if(m==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i <= h+1; i++) {
		if (i == 0 || i == h+1) {
			for (int j = 0; j <= w + 1; j++)cout << "#";
			cout << endl;
		}
		else cout << "#" << s[i-1] << "#" << endl;
	}
}




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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    if(x % (y + z) >= z){
        cout << x / (y+z) << endl;
    }else{
        cout << x / (y+z) - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void output(int n, int *elements)
{
	for (int i = 0; i < n - 1; i++)
		cout << elements[i] << " ";
	cout << elements[n - 1] << endl;
}

void insertion_sort(int n, int *elements)
{
	for (int i = 1; i < n; i++) {
		int key = elements[i];
		int j = i - 1;
		while (0 <= j && key < elements[j]) {
			elements[j + 1] = elements[j];
			j--;
		}
		elements[j + 1] = key;
		output(n, elements);
	}
}

int main()
{
	int n, elements[100] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> elements[i];
	output(n, elements);
	insertion_sort(n, elements);
	return 0;
}

Measured memory_bytes: 1160
use std::collections::LinkedList;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: i64 = read();

    for i in -200..200 {
        for j in -200..200 {
            if pow5(i) - pow5(j) == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}

fn pow5(i: i64) -> i64 {
    i * i * i * i * i
}

fn prime_lists(limit: u64) -> LinkedList<u64> {
    let mut ret: LinkedList<u64> = LinkedList::new();
    ret.push_back(2);
    let mut i: u64 = 3;

    while i * i <= limit {
        if (&ret).into_iter().fold(true, |a, &b| a && i % b != 0) {
            ret.push_back(i);
        }
        i += 2;
    }
    ret
}

fn factorize(fact: u64) -> Vec<u64> {
    let mut i = fact;
    let mut ret: Vec<u64> = Vec::new();
    let primes = prime_lists(fact);
    println!("a");
    for p in &primes {
        while i % p == 0 {
            ret.push(*p);
            i /= p;
        }
    }
    ret
}

fn factorize_all(fact: u64) -> Vec<u64> {
    let mut factorized = factorize(fact);
    let mut ret: Vec<u64> = Vec::with_capacity(factorized.len() * factorized.len());
    ret.push(1);

    while factorized.len() > 0 {
        let n = factorized.remove(0);
        let pushed = (&ret).into_iter().map(|&b| b * n).collect::<Vec<u64>>();
        for other in &pushed {
            ret.push(*other);
        }
    }
    ret.dedup();
    ret
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

ll f(ll x) {
    if (x < 2) return 1;
    else return x * f(x-2);
}

int main(void){
    // Your code here!
    ll n;
    cin >> n;
    if (n%2 != 0) cout << 0 << endl;
    else {
    ll res = 0;
    n /= 2;
    while (n > 0) {
        res += n/5;
        n /=5;
    }
    cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
 
    int N,i;
    int A[200];

    cin >> N;

    for(i=0;i<200;i++){
        cin >> A[i];
    }

    int ans = 0;

    while(true){
        bool exist_odd = false ;
        for(i=0;i<N;i++){
            if(A[i]%2!=0){
                exist_odd = true;
            }
        }

        if(exist_odd) break;

        for(i=0;i<N;i++){
            A[i] = A[i] /2;
        }
        ++ans;
    }

    cout << ans<<endl;

    return 0;
}

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

int main()
{
  int64_t ans = 0;
  vector<int64_t> p(6), tmp(5);
  for (int i = 0; i < 6; i++)
    cin >> p[i];
  for (int i = 0; i < 5; i++)
  {
    if (p[0] % p[i + 1] != 0)
      tmp[i] = p[0] / p[i + 1] + 1;
    else
      tmp[i] = p[0] / p[i + 1];
  }
  ans = 4 + *max_element(tmp.begin(), tmp.end());
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 1000000007
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}
 

vector<ll> ed[100005];
ll dp[100005][2];
int v[100005];

void dfs(int x){
        if(v[x]) return;
        v[x]=1;
        dp[x][0]=dp[x][1]=1;
        for(auto it:ed[x]){
            if(v[it]) continue;
            dfs(it);
            dp[x][0]=mod(dp[x][0]*(dp[it][0]+dp[it][1]));
            dp[x][1]=mod(dp[x][1]*dp[it][0]);
        }
}
int main(){
      sync;
      ll n;
      cin>>n;
      for(ll i=1; i<n; i++){
           int x,y;
           cin>>x>>y;
           ed[x].pb(y);
           ed[y].pb(x);           
       }
          
            

       dfs(1);
       cout<<mod(dp[1][0]+dp[1][1])<<endl;   
}

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

using namespace std;
#define ll long long

char g(char x) {
    if (x == 'r') return 'p';
    if (x == 'p') return 's';
    return 'r';
}

const int N = 1e5 + 5;
vector<char> v[N];
int id = 0;
int dp[N][3];
int vis[N][3];
vector<char> moves = {'r', 'p', 's'};
map<char, int> mp2;

int get(char x) {
    if (x == 'r') return 0;
    if (x == 'p') return 1;
    return 2;
}

int solve(int indx, char last, vector<char> &v) {
    if (indx == v.size()) return 0;
    int T = get(last);
    int &ret = dp[indx][T];
    if (vis[indx][T] == id)return ret;
    vis[indx][T] = id;
    ret = 0;
    for (auto &c:moves) {
        int val = 0;
        if (g(v[indx]) == c) val = mp2[c];
        if (c == last && indx) continue;
        ret = max(ret, solve(indx + 1, c, v) + val);
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    int r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    int ans = 0;
    mp2['r'] = r;
    mp2['s'] = s;
    mp2['p'] = p;
    for (int i = 0; i < n; i++) {
        v[i % k].push_back(t[i]);
    }
    for (int i = 0; i < k; i++) {
        id++;
        ans += solve(0, 0, v[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14544
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    int n;
    double x[10], y[10], ans = 0.0, count = 0.0;
    cin >> n;
    vector<int> num(n);
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n) num[i] = i;
    do
    {
        for (int i = 1; i < n; i++)
        {
            ans += sqrt(pow(x[num[i]] - x[num[i - 1]], 2) + pow(y[num[i]] - y[num[i - 1]], 2));
        }
        count++;
    } while (next_permutation(num.begin(), num.end()));
    cout << fixed << setprecision(10) <<ans / count << endl;
    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

int main(void) {

  for(;;) {
    int n;
    std::cin >> n;
    if( n == 0 ) break;

    bool left, right;
    left = right = false;
    bool prev = false;

    int res = 0;
    for(int i = 0; i < n; ++i) {
      std::string str;
      std::cin >> str;
      if( str[0] == 'l' ) left  = not left;
      else                right = not right;
      if( prev == not left and prev == not right ) {
        res += 1;
        prev = not prev;
      }
    }

    std::cout << res << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
// C++ program to find the minimum sum of costs such that
// each elements choose one of the costs.
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n];
	int i,j;
	for(i=0;i<n;i++)
		cin>>a[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++)
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int64_t MAX = pow(10, 9);

int main()
{
  int64_t N, K, S;
  cin >> N >> K >> S;
  if (S == MAX)
  {
    MAX--;
  }
  for (int i = 0; i < K; i++)
  {
    if (i == 0)
    {
      cout << S;
    }
    else
    {
      cout << ' ' << S;
    }
  }
  for (int i = 0; i < N - K; i++)
  {
    if (K == 0 && i == 0)
    {
      cout << MAX;
      continue;
    }
    cout << ' ' << MAX;
  }
  cout << endl;
}

Measured memory_bytes: 1280
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii; using namespace std;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(){
  int N; cin >> N; int v[N]; double a=0;
  rep(i, 0, N) {cin >> v[i];}
  sort(v, v+N); a=v[0];
  rep(i, 1, N) {
    a = (a + v[i]) / 2;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N),y(M);
  for(int i=0;i<N;i++){
    cin >> x.at(i);
  }
  for(int i=0;i<M;i++){
    cin >> y.at(i);
  }
  sort(x.begin(),x.end());
  reverse(x.begin(),x.end());
  sort(y.begin(),y.end());

  bool ans=false;
  if(x.at(0)>=y.at(0))  ans = true;
  else if(x.at(0)>=Y)  ans = true;
  else if(X>=y.at(0))  ans = true;

  if(ans){
    cout << "War" << endl;
  }
  else{
    cout << "No War" << endl;
  }
  return 0;
}


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

int main(){
double n,v,f,t,a,h[2000],mini=100001;
cin >> n >> t >> a;
for(int i=0;i<n;i++){
  cin >> h[i];
  v=h[i];
  h[i]=t-(v*0.006);
}
for(int j=0;j<n;j++){
  v=h[j];
  if(v<a){
    if(mini>abs(a-v)){
      mini=abs(a-v);
      f=j+1;
    }
  }else{
    if(mini>abs(v-a)){
      mini=abs(v-a);
      f=j+1;
    }
  }

}
cout<< f << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k, *a;
    int m = 0;
    cin >> n >> k;
    a = new int[n+1];
    for (int i = 0; i <= n; i++)
        a[i] = 0;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (a[d] == 0)
            m++;
        a[d]++;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i+1];
    }
    sort(a, a+n+1, greater<int>());
    sort(a, a+m);

    int counter = 0;
    int i = 0;
    while (m > k) {
        counter += a[i];
        m--;
        i++;
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
string s,h;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    if(a>=10){
        cout<<b;
    }else{
        cout<<b+(10-a)*100;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <queue>

#define int long long
using namespace std;
const int MOD = 1e9 + 7;

int A, B, C;


void solve()
{
}


signed main()
{
    cin >> A >> B >> C;
    if (A == B && A == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * Problem:	B. 
 * Author:	hkxadpall. 
 * Date:	2018-09-01. 
 * Upload:	AtCoder. 
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue> 
#include <map>
#include <set>
using namespace std;

namespace AuthorName { 
    template <typename _TpInt> inline _TpInt read();
    template <typename _TpRealnumber> inline double readr();
    template <typename _TpInt> inline void write(_TpInt x);
//	template <typename _TpSwap> inline void swap(_TpSwap &x, _TpSwap &y);
	
#	define Max_N 1007
	
	int x1, y1, x2, y2;
	int x3, y3, x4, y4;
	map <string, bool> a;
	int n, m;
	
	int main() 
	{
		char lc = 0;
		string l;
		n = read<int>();
		for (int i = 0; i < n; i++) {
			cin >> l;
			if (a[l] == 1) {
				printf("No");
				return 0;
			}
			a[l] = 1;
			if (i == 0) {
				lc = l[0];
//				printf("lc = %c", lc);
			}
			if (l[0] != lc) {
				printf("No");
				return 0;
			}
			lc = l[l.length() - 1];
		}
		printf("Yes");
	    return 0;
	}

#	define Getchar() getchar()

    template <typename _TpInt>
    inline _TpInt read()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpInt init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = (init << 3) + (init << 1) + (c & 15);
        return init * flag;
    }

    template <typename _TpRealnumber>
    inline double readr()       
    {
        register int flag = 1;
        register char c = Getchar();
        while ((c > '9' || c < '0') && c != '-') 
            c = Getchar();
        if (c == '-') flag = -1, c = Getchar();
        register _TpRealnumber init = (c & 15);
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init * 10 + (c & 15);
        if (c != '.') return init * flag;
        register _TpRealnumber l = 0.1;
        while ((c = Getchar()) <= '9' && c >= '0') 
            init = init + (c & 15) * l, l *= 0.1;
        return init * flag;
    }

    template <typename _TpInt>
    inline void write(_TpInt x)
    {
        if (x < 0) {
            putchar('-');
            write<_TpInt>(~x + 1);
        }
        else {
            if (x > 9) write<_TpInt>(x / 10);   
            putchar(x % 10 + '0');
        }
    }

//	template <typename _TpSwap>
//	inline void swap(_TpSwap &x, _TpSwap &y)
//	{
//	    _TpSwap t = x;
//	    x = y;
//	    y = t;
//	}
}

int main()
{
    AuthorName::main();
    return 0;
}

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

ll a[200010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll i,n,cnt=0,cnt2=0,ans=1e18,tp;
    cin>>n;
    fr(i,n) cin>>a[i], a[i]-=i,cnt+=a[i];
    sort(a+1,a+n+1);
    fr(i,n)
    {
        cnt-=a[i];
        cnt2+=a[i];
        tp=cnt-((n-i)*a[i])+i*a[i]-cnt2;
        ans=min(ans,tp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }
 	
void solve() {
    string s,p;
    cin>>s>>p;
    int l1=sz(s);
    int l2=sz(p);
    
    int mini=l2;
    
    rep1(i,0,l1-l2) {
		  int ct=0;
		  for(int j=0;j<l2;j++) {
			    if(p[j]!=s[i+j]) ct++;
			  }  
			  //~ cout<<i<<" "<<ct<<endl;
			 mini=min(mini,ct); 
		}
		
		cout<<mini<<endl;
                                
}

    
int32_t main() {
	cool;
	int t=1;	
   
	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        String X = sc.next();
        
        for (int i = 0; i < X.length(); i++) {
            if (i % 2 == 0) {
                System.out.print(X.substring(i, i+1));
            }
        }

		sc.close();
	}
}


Measured memory_bytes: 29692
#include <stdio.h>

int main()
{   char a[2],b[2];
    scanf("%c %c",a,b);
    if(a[0]=='H'){
        printf("%c",b[0]);
    }else if(b[0]=='H'){
        printf("D");
    }else printf("H");
    
    

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int M = 2019;

int main(){

  string S;
  cin >> S;

  reverse(S.begin(), S.end());

  int ten = 1;
  int r = 0;

  vector<int> cnt(M);

  ll ans = 0;

  rep(i, S.size()){
    cnt[r]++;
    r = (r + (S[i] - '0') * ten) % M;
    ten = (ten * 10) % M;
    ans += cnt[r];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3724