akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  for (int i = 0; i <= 999; ++i) {
    string t = to_string(i);
    while (t.size() != 3) {
      t = '0' + t;
    }
    auto it0 = find(rng(s),t[0]);
    auto it1 = find(it0+1,s.end(),t[1]);
    auto it2 = find(it1+1,s.end(),t[2]);
    //show3(it0-s.begin(),it1-s.begin(),it2-s.begin());
    if (it2 != s.end()) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int top,S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];

    while (scanf("%s",s) != EOF){
        if (s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if (s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        } else if (s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n",pop());

    return 0;
}


Measured memory_bytes: 2036
H, W = list(map(int, input().split()))
A = [[0 for j in range(W)] for i in range(H)]
count = 0
res = []
for i in range(H):
    A[i] = list(map(int, input().split()))
    for j in range(W-1):
        if A[i][j] % 2 != 0:
            A[i][j] -= 1
            A[i][j+1] += 1
            res.append([i+1,j+1,i+1,j+2])
            count += 1
for i in range(H-1):
    if A[i][W-1] % 2 != 0:
        A[i][W-1] -= 1
        A[i+1][W-1] += 1
        res.append([i+1,W,i+2,W])
        count += 1
print(count)
print("\n".join([" ".join(map(str, l)) for l in res]))


Measured memory_bytes: 38776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string temp;
    rep(i,n) {
        if(s.substr(i, n) == t.substr(0, n-i)){
            temp = s.substr(0, i) + t;
            int ans = temp.size();
            cout << ans << endl;
            return 0;
        }
    }
    int ans = s.size() + t.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;

int main()
{
	int n;
	cin>>n;
	int sum=0,t=1;
	for(int i=1;i<=n;i++){
		int x=ceil(log10(i+1));
		if(x%2==1){
			sum++;
		}
	}
	cout<<sum <<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b,i=1,c;
cin>>a>>b;
if(a<=0&&b>=0) cout<<"Zero"<<endl;
if(a>0) cout<<"Positive"<<endl;
if(b<0) {
 if((b-a)%2==0) cout<<"Negative"<<endl;
 if((b-a)%2!=0) cout<<"Positive"<<endl;
}
return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
list = []
clst = [i for i in range(1, N + 1)]
for i in itertools.permutations(clst, N):
    list.append(i)

acnt = 0
bcnt = 0
for i in range(len(list)):
    aF = True
    for j in range(N):
        if list[i][j] != P[j]:
            aF = False
            break
    if aF:
        acnt = i + 1

for i in range(len(list)):
    bF = True
    for j in range(N):
        if list[i][j] != Q[j]:
            bF = False
            break
    if bF:
        bcnt = i + 1
print(abs(acnt - bcnt))

Measured memory_bytes: 7924
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i <= 100; $i++){
  $h[$i] = $t[$i] = 0;
}

for($i = 1; $i <= $n; $i++){
  $si = "$i";
  $h[(int)($si[0].$si[strlen($si)-1])]++;
  $t[(int)($si[strlen($si)-1].$si[0])]++;
}
$sum = 0;
for($i = 1; $i <= 100; $i++){
  $sum+=$h[$i] * $t[$i];
}
echo $sum;


Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;

	void solve() {
		boolean[] flg = new boolean[26];
		String line = readLine();
		for (int i = 0; i < line.length(); i++) {
			char ch = line.charAt(i);
			int idx = (int) (ch - 'a');
			if (flg[idx]) {
				pln("no");
				return;
			}
			flg[idx] = true;
		}
		pln("yes");
	}

	// -----------------------------------------------------
	// 2018/04/26 r2
	// -----------------------------------------------------
	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = plong(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	void pln(int[] ia) {
		for (int i = 0; i < ia.length; i++)
			pln(ia[i]);
	}

	void pln(long[] la) {
		for (int i = 0; i < la.length; i++)
			pln(la[i]);
	}

	static BufferedReader _in;
	static PrintWriter _out;
	static boolean _bElapsed = false;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (_bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 19412
N = int(input())
A = list(map(int, input().split()))

ans = 1
mod = 10 ** 9 + 7
l = [0] * (max(A)+1)

for a in A:
    if not a:
        ans *= (3 - l[a])
    else:
        ans *= (l[a-1] - l[a])
    l[a] += 1

    if ans > mod:
        ans = ans % mod

print(ans)

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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

signed main(){
  Int n;
  Int cnt=0;
  while(cin>>n,n){
    vector<string> ss(n);
    vector<Int> ls(n),vs(n);
    for(Int i=0;i<n;i++) cin>>ss[i]>>vs[i],ls[i]=ss[i].size();
    string t;
    cin>>t;
    Int m=t.size();

    const Int INF = 1e9;
    vector<Int> dp1(m+1,-INF);
    dp1[0]=0;

    for(Int i=0;i<m;i++){
      for(Int j=0;j<n;j++){
	if(i+ls[j]>m) continue;
	if(t.substr(i,ls[j])!=ss[j]) continue;
	chmax(dp1[i+ls[j]],dp1[i]+vs[j]);
      }
    }

    vector<Int> dp2(dp1[m]+1,INF);
    dp2[0]=0;
    for(Int i=0;i<dp1[m];i++){
      for(Int j=0;j<n;j++){
	if(i+vs[j]>dp1[m]) continue;
	chmin(dp2[i+vs[j]],dp2[i]+ls[j]);
      }      
    }
    
    cout<<"Case "<<++cnt<<": "<<dp2[dp1[m]]<<endl;
  }
  return 0;
}




Measured memory_bytes: 3156
/*
	0130:Train
*/
#include	<iostream>
#include	<vector>
#include	<string>
#include	<utility>
#include	<algorithm>

using namespace std;

typedef vector< pair<int, char> > VpIC;

string solve(string hoge);

int main(void) {
	int data;
	
	cin >> data;
	for(int i = 0; i < data; i++) {
		string aaa;
		
		cin >> aaa;
		cout << solve(aaa) << endl;
	}
	
	return 0;
}

string solve(string hoge) {
	string::iterator it = hoge.begin();
	string ans;
	int rank = 0, count = 0;
	VpIC list;
	int piyo[26] = { 0 };
	
	while( it != hoge.end() ) {
		if(*it == '-') {
			rank--;
			it++;	it++;
		} else if(*it == '<') {
			rank++;
			it++;	it++;
		} else {
			if( piyo[*it - 'a'] == 0) {
				list.push_back( pair<int, char>(rank, *it) );
				piyo[*it - 'a'] = 1;
				count++;
			}
			it++;
		}
	}
	sort(list.begin(), list.end());
	for(int i = count-1; i >= 0; i--) {
		ans += list[i].second;
	}
	
	return ans;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>

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

using namespace std;
const long long mod = 1e9+7;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> W(M), dp(N+1);
  rep(i,M) {
    cin >> W[i];
    dp[W[i]] = -1;
  }
  dp[0] = 1;
  for(int i = 1; i <= N; ++i){
    if (dp[i] == -1) continue;
    if (i >= 2 && dp[i-2] != -1) {
      dp[i] += dp[i-2] % mod;
    }
    if (dp[i-1] != -1){
      dp[i] += dp[i-1] % mod;
    }
  }
  cout << dp[N] % mod << endl;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

want=1
ans=0
log=-1
for i in range(N):
    if A[i]==want:
        if want==1:
            log=i
        want+=1
    else:
        ans+=1

if log==-1:
    print(-1)
else:
    print(ans)

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

int main() {
  int n,l;
  cin>>n>>l;
  if(l>0){
    cout<<(2*l+n)*(n-1)/2<<endl;
  }
  else if(l+n-1<0){
    cout<<(2*l+n-2)*(n-1)/2<<endl;
  }
  else{
    cout<<(2*l+n-1)*n/2<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

void DiceandCoin()
{
  double n;
  double k;
  double ans = 0;
  cin >> n >> k;
  
  for (int i = 1; i <= n; i++)
  {
    if (i <= k)
    {
      double point = i;
      double count = 0;
      while (point < k)
      {
        point = point * 2;
        count++;
      }
      ans += pow(0.5, count) / n;
    }
    else
    {
      ans += (n - k) / n;
      break;
    }
  }

  cout << fixed << setprecision(10) << ans << endl;
  return;
}

int main()
{
  DiceandCoin();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値));
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2));  // 初期値を省略

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string ts="test";
	
	int n; cin >> n;
	vector<string> s(n); rep(i,n) cin >> s[i];
	//map<string,int> mp;
	
	sort(all(s));
	//cout << endl;
	
	
	map<string,int> m;
	
	rep(i,n){
		
		if(m.find(s[i])==m.end()) m.emplace(s[i],1);  ///   caution!
		else{
			m[s[i]]++;
			//cout << ts << endl;
		}
	}
	
	int c=1,mx=0;
	
	rep(i,n-1){
		if(s[i]!=s[i+1] || i==n-2){ // &&==1 -> mx==1, dontcare
			if(s[i]==s[i+1]) c++;
			chmax(mx,c);
			c=1;
		}
		else c++;
	}
	
	for(auto x:m) if(x.second==mx) cout << x.first << endl;
	
	//if(mx==1) cout << s[n-1] << endl;
	
	
	//cout << mx << endl;
	
	//cout << m[s[2]] << s[2] << endl;
	
	
	return 0;
}



Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long t,t2;
int main(){
	cin >> n >> k;
	if(k&1){
		t=n/k;
		cout << t*t*t;
	}
	else{
		t2=t=n/k;
		if(n%k>=k/2)t2++;
		cout << t*t*t+t2*t2*t2;
	}
} 

Measured memory_bytes: 256
/*
ID:xmydada1
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
long long a[100010],f[100010],g[100010],m,n,ans=0,sum=0,p;
char s[100001];
#define reg register
inline int read() {
reg int s = 0, t = 0; reg char ch = getchar();
while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
return t ? -s : s;
}

inline void print(reg long long x) {
if(x < 0) putchar('-'), x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + 48);
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)a[i]=s[i]-'0';
	
	f[1]=2;g[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		{
			f[i]=f[i-1];
			g[i]=g[i-1]*3%M;
		}
		if(a[i]==1)
		{
			f[i]=f[i-1]*2%M;
			g[i]=(g[i-1]*3+f[i-1])%M;
		}
	}
	cout<<(f[n]+g[n])%	M;

	
	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>b[i];
    ans+=max(0,a[i]-b[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.length()<= k){
        cout << s << endl;
    }else{
        int i;
        for(i=0;i<k;i++) cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int x,y;
int ans;
int main()
{
	ans=0;
	scanf("%d%d",&x,&y);
	if(x==1)
	{
		ans+=300000;
	}
	if(x==2)
	{
		ans+=200000;
	}
	if(x==3)
	{
		ans+=100000;
	}
	if(y==1)
	{
		ans+=300000;
	}
	if(y==2)
	{
		ans+=200000;
	}
	if(y==3)
	{
		ans+=100000;
	}
	if(x==1&&y==1)
	{
		ans+=400000;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

bool dp[60][2510][2510];

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

    int n; cin>>n;
    vector<int> t(n);
    for(int i=0; i<n; i++) cin>>t[i];

    dp[0][0][0] = true;
    for(int i=0; i<n; i++){
        for(int j=0; j<=2500; j++){
            for(int k=0; k<=2500; k++){
                if(!dp[i][j][k]) continue;

                if(j + t[i] <= 2500) dp[i+1][j+t[i]][k] = true;
                if(k + t[i] <= 2500) dp[i+1][j][k+t[i]] = true;
                dp[i+1][j][k] = true;
            }
        }
    }

    int ans = inf, tsum = accumulate(all(t), 0);
    for(int i=0; i<=2500; i++){
        for(int j=0; j<=2500; j++){
            if(!dp[n][i][j]) continue;

            chmin(ans, max({i, j, tsum - i - j}));
        }
    }

    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using uint = unsigned int;
template <uint MOD>
struct ModInt {
  using M = ModInt;
  uint v;
  ModInt() : v(0) {}
  ModInt(ll _v) { norm(_v % MOD + MOD); }
  M& norm(uint _v) {
    v = (_v < MOD) ? _v : _v - MOD;
    return *this;
  }
  M operator+(const M x) const { return M().norm(v + x.v); }
  M operator-(const M x) const { return M().norm(v + MOD - x.v); }
  M operator*(const M x) const { return M().norm(ll(v) * x.v % MOD); }
  M operator/(const M x) const { return *this * x.inv(); }
  M& operator+=(const M x) { return *this = *this + x; }
  M& operator-=(const M x) { return *this = *this - x; }
  M& operator*=(const M x) { return *this = *this * x; }
  M& operator/=(const M x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    input >> x.v, x.norm(x.v);
    return input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(ll n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return (*this).pow(MOD - 2); }

  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
};
template <uint MOD>
vector<ModInt<MOD>> ModInt<MOD>::fact = vector<ModInt<MOD>>();
template <uint MOD>
vector<ModInt<MOD>> ModInt<MOD>::finv = vector<ModInt<MOD>>();
using mint = ModInt<uint(1e9 + 7)>;

int main() {
  int n;
  mint a, b, c;
  cin >> n >> a >> b >> c;
  mint pa = a / (a + b);
  mint pb = b / (a + b);
  mint::build(n * 2);
  mint ans = 0;
  for (int i = 0; i < n; i++) {
    mint sum = 0;
    sum += mint::comb(n - 1 + i, i) * pa.pow(n) * pb.pow(i);
    sum += mint::comb(n - 1 + i, i) * pb.pow(n) * pa.pow(i);
    ans += mint(n + i) * sum;
  }
  ans *= mint(100) / (mint(100) - c);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,K,S;
  cin>>N>>K>>S;
  for(ll i=0;i<K;i++){
    cout<<S<<" ";
  }
  for(ll i=0;i<N-K;i++){
    if(S==1e9){cout<<S-1<<" ";}
    else{cout<<S+1<<" ";}
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D,T,S; cin>>D>>T>>S;
    if (D<=S*T){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3648
import std.stdio;
import std.string;

int[] dx = [-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1];
int[] dy = [2, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -2];
int[] sdx = [-1, 0, 1, -1, 0, 1, -1, 0, 1];
int[] sdy = [1, 1, 1, 0, 0, 0, -1, -1, -1];
int[10] sx;
int[10] sy;
int n, tx, ty;

void main(){
	int x, y;
	string s;
	while (readf("%d %d\n", &x, &y), x != 0 || y != 0) {
		readf("%d\n", &n);
		s = chomp(readln());
		for (int i = 0; i < n; i++) {
			sx[i] = s[i*4] - '0';
			sy[i] = s[i*4+2] - '0';
		}
		if (solve(x, y, 0)) writeln("OK");
		else writeln("NA");
	}
}

bool solve(int x, int y, int depth){
	if (depth >= n) return true;
	for (int i = 0; i < dx.length; i++) {
		for (int j = 0; j < sdx.length; j++) {
			tx = x + dx[i];
			ty = y + dy[i];
			if (tx == sx[depth]+sdx[j] && ty == sy[depth]+sdy[j]) {
				if( tx >= 0 && tx < 10 && ty >= 0 && ty < 10 && solve(tx, ty, depth+1)) return true;
			}
		}
	}
	return false;
}

Measured memory_bytes: 1048
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
class RightTriangle{
    public:
        void solve(vector<int> l){ 
            for(int i=0;i<l.size();i++){ 
                for(int j=l.size()-1;j>i;j--){ 
                    if(l[j-1]<l[j]){ 
                        int tmp=l[j-1];
                        l[j-1]=l[j];
                        l[j]=tmp;
                    }
                }
            }
            if(pow(l[0],2)==pow(l[1],2)+pow(l[2],2))cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
};
int main(){ 
    int n;
    cin>>n;
    RightTriangle inst;
    vector<int> l(3);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
        cin>>l[j];
        }
        inst.solve(l);
    }
} 

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


int main(){
 int A,B;
  string S,T,U;
  cin>>S>>T >> A >> B >> U;
  if (U==S) A-=1;
  if (U==T) B-=1;
  cout << A <<" "<<B;
}

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

using ll=long long;

int main(){

ll N;
cin>>N;

vector<ll> d(N);

for(ll i=0;i<N;++i) cin>>d[i];

ll S=0;

for(ll i=0;i<N-1;++i){
for(ll j=i+1;j<N;++j){
S+=d[i]*d[j];
}
}

cout << S << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N, M, X, Y; cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    REP(i, N) cin >> x[i]; REP(i, M) cin >> y[i];
    sort(ALL(x)); sort(ALL(y));
    if (max(X, x[N-1]) < min(Y, y[0])) cout << "No War" << endl;
    else cout << "War" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int N,M,L;

struct edge{int to,dist,enemy;};
struct state{
    int node,dist,enemy;
    bool operator<(const state& right)const{
        return enemy>right.enemy;
    }
};

vector<vector<edge>> v(110);
int dp[110][110] = {};
int inf = 1e9;

int main(){
    while(cin >> N >> M >> L && N>0){
        for(int i=1;i<=N;i++) v[i].clear();
        int a,b,d,e;
        for(int i=0;i<M;i++){
            cin >> a >> b >> d >> e;
            v[a].push_back({b,d,e});
            v[b].push_back({a,d,e});
        }
        for(int i=1;i<=N;i++) for(int j=0;j<=L;j++) dp[i][j] = inf;
        dp[1][L] = 0;
        priority_queue<state> Q;
        Q.push({1,L,0});
        while(!Q.empty()){
            state now = Q.top(); Q.pop();
            if(dp[now.node][now.dist]<now.enemy) continue;
            for(auto x:v[now.node]){
                state ne = now;
                ne.node = x.to;
                //雇わない
                ne.dist = now.dist;
                ne.enemy = now.enemy+x.enemy;
                if(dp[ne.node][ne.dist]>ne.enemy){
                    dp[ne.node][ne.dist] = ne.enemy;
                    Q.push(ne);
                }
                if(now.dist-x.dist>=0){
                    ne.dist = now.dist-x.dist;
                    ne.enemy = now.enemy;
                    if(dp[ne.node][ne.dist]>ne.enemy){
                        dp[ne.node][ne.dist] = ne.enemy;
                        Q.push(ne);
                    }
                }
            }
        }
        int ans = inf;
        for(int i=0;i<=L;i++) ans = min(ans,dp[N][i]);
        cout << ans << endl;
    }   
}


Measured memory_bytes: 3436
import sys
readline = sys.stdin.readline

H, W, M = map(int, readline().split())

h = {}
w = {}
m = {}
for i in range(M):
    hi, wi = map(int, readline().split())
    if hi not in h:
        h[hi] = 1
        m[hi] = set()
        m[hi].add(wi)
    else:
        h[hi] += 1
        m[hi].add(wi)
    if wi not in w:
        w[wi] = 1
    else:
        w[wi] += 1

max_h = max(h.values())
max_w = max(w.values())
max_h_list = [kv[0] for kv in h.items() if kv[1] == max_h]
max_w_list = [kv[0] for kv in w.items() if kv[1] == max_w]

for i in max_h_list:
    for j in max_w_list:
        if j not in m[i]:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)


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

int h, w;

void init(){
	scanf("%d", &h);
	scanf("%d", &w);
	char ch[1234], c[1234];
	for (int i = 0; i < h; ++i)
	{
		scanf("%s", ch);
		printf("%s\n%s\n", ch, ch);

	}
}

int main(){

	init();
	return 0;
}

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

int main()
{
    int N,M;
    cin >> N >> M;
    priority_queue<ll> a;
    
    ll val;
    rep(i,N){
        cin >> val;
        a.push(val);
    };

    rep(i,M){
        val=a.top();a.pop();
        val/=2;
        a.push(val);
    }
    
    ll ans=0;
    rep(i,N){
        val=a.top();
        ans+=val;
        a.pop();
    }
    cout << ans << endl;

}

Measured memory_bytes: 1400
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
const A : u8 = 'a' as u8;
fn rec(n : usize,s : String, c : u8){
    if s.len() == n {
        println!("{}",s);
        return;
    }
    for t in A..(c+1) {
        rec(n, format!("{}{}",s,t as char), if t == c { c + 1 } else {c} );
    }
}

fn main() {
    input!{
        n:usize
    }
    rec(n, String::new(), A);
    return;
}



Measured memory_bytes: 5500
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (size_t i = 0; i < n; i++)
    {
        ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=20000+20;
int n,d,x,y,sz[N];
int main()
{
    //freopen("out.txt","w",stdout);
    while(~scanf("%d%d%d",&n,&d,&x))
    {
        memset(sz,0,sizeof(sz));
        int sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&y);
            for(int j=1;j<=d;j+=y)
            {
                sum++;
            }
        }
        printf("%d\n",sum+x);
    }


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    if(s.size() >= 4 && s.substr(0, 4) == "YAKI"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int h,m,s;
    cin >> s;
    h=s/3600;
    m=(s%3600)/60;
    s=(s%3600)%60;
    cout << h <<":"<< m << ":"<< s <<"\n";
    
    return 0;
}


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

int main() {

    int n; cin >> n;

    if (n == 2) {
        int a1, a2; cin >> a1 >> a2;
        cout << abs(a1 - a2) << endl;
        return 0;
    }

    vector<ll> accum(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        ll tmp_a; cin >> tmp_a;       
        accum[i] += accum[i - 1];
        accum[i] += tmp_a;
    }

    ll ans = 9223372036854775807LL;
    for (int i = 1; i <= n - 1; i++) {        
        ll left = accum[i];
        ll right = accum[n] - accum[i];
        ll sum = abs(left - right);
        ans = min(ans, sum);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
      int N = scanner.nextInt();
       
      ArrayList <Integer> a = new ArrayList <Integer>();
 	  int n[] = new int[N];
      for(int i=0; i<N; i++){
         n[i] =scanner.nextInt();
      	 a.add(n[i]);//[1.4.3]の入力が入る
      }
  
      Collections.sort(a);
  
  	  for(int i=0; i<N; i++){
         int max = a.get(a.size()-1);//aの最大値
         int max2 = a.get(a.size()-2);//aの二番目に大きい数値
      if(max==n[i]){//最大値がn[i]番目の数値と同じならば,出力は二番目に大きい数値を表す
                    //[1,3,4]でmax[4]とn[i]==n[2]...(4)が同じならば,[1,3]を比較してmax2==3を出力している
        System.out.println(max2);
      }
      else{
        System.out.println(max);
      }
      }
}
}

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

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

    vector<string> s(n, "");
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());

    int ans = 1;
    for(int i = 1; i < n; i++) {
        if(s[i - 1] != s[i]) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
using namespace std;

int		main(void)
{
	int n;

	cin >> n;
	vector<int> p(n);

	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(all(p));
	p.back() /= 2;
	int sum = 0;

	for (int i = 0; i < n; i++)
	{
		sum += p[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char S[4];
  int i;
  int flag[2] = {0,0};

  scanf("%s", S);

  for (i = 0; i < 3; i++) {
    if (S[i] == 'A') flag[0] = 1;
    if (S[i] == 'B') flag[1] = 1;
  }

  if (flag[0] == 1 && flag[1] == 1) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  return (0);
}


Measured memory_bytes: 128
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
double p[200010];

ll ltmp;
string stmp;
double dtmp;
double sum = 0;
ll start = 1;
double sumax = 0;

double getv(double ni){
    return ni * (ni + 1) / 2 / ni;
}

int main(){

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

    cin >> N;
    cin >> K;
    

    for( int ni = 1 ; ni <=K ; ni++ ){
        cin >> ltmp;
        dtmp = getv(ltmp);
        p[ni]=dtmp;
        sum+=dtmp;
    }
    sumax = sum;
    start = 1;
    for( int ni = K+1 ; ni <=N ; ni++ ){
        cin >> ltmp;
        dtmp = getv(ltmp);
        p[ni]=dtmp;
        sum-=p[ni-K];
        sum+=p[ni];
        if(sum>sumax){
            start = ni - K + 1;
            sumax = sum;
        }
    }
    cout << std::fixed << std::setprecision(10) << sumax << endl;







}

Measured memory_bytes: 1792
// 2017/12/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

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

		int sum = -1;

		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int p = a[i]+a[j];

				if(p<=m && p>sum){
					sum = p;
				}
			}
		}

		if(sum!=-1){
			cout << sum << endl;
		}
		else{
			cout << "NONE" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <queue>
#include <map>


using namespace std;
using namespace std;

int N, Q;
vector<int>S, T, X;


int main()
{

	map<int,int> mp;
	auto c = [](int l, int r) { return X.at(l) > X.at(r); };
	priority_queue<int, vector<int>, decltype(c)> pq(c);

	cin >> N;
	cin >> Q;

	vector<int> ans = vector<int>(Q,-1);
	S = vector<int>(N);
	T = vector<int>(N);
	X = vector<int>(N);

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

		cin >> S.at(i);
		cin >> T.at(i);
		cin >> X.at(i);

		pq.push(i);
	}

	for (int i = 0; i < Q; i++) {
		int q;

		cin >> q;
		mp.insert(make_pair(q,i));
	}

	while (!pq.empty()) {
		int i = pq.top();
		pq.pop();

		int bgn = S.at(i) - X.at(i);
		int end = T.at(i) - X.at(i);

		auto it = mp.lower_bound(bgn);
		auto last = mp.lower_bound(end);

		while (it != last) {

			ans.at(it->second) = X.at(i);
			it = mp.erase(it);
		}
	}

	for (int i = 0; i < Q; i++) {
		cout << ans.at(i) << endl;
	}


	return 0;
}


Measured memory_bytes: 15988
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int nowa=0,nowx=0, nowy=0;
    int a=0,b=0,c=0;
    int dd=0;
    bool  flg = true;
    for(int i=0;i<n;i++){
        cin >> a >> b >> c;
        dd = abs(nowx-b) + abs(nowy-c);
        if(dd>a-nowa) flg = false;
        else if(dd%2!=(a-nowa)%2) flg = false;
        nowa = a;
        nowx = b;
        nowy = c;
        if(!flg)break;
    }
    cout << (flg?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int k = 0;
    rep(i, 0, 3) if (s[i] == t[i]) k++;
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 7 || x == 5 || x == 3)

                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();
       }
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;

int mi[1<<26];
int ret[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	
	N=S.size();
	FOR(i,1<<26) mi[i]=N+10;
	mi[0]=0;
	
	int cur=0;
	FOR(i,N) {
		ret[i+1]=N+10;
		S[i]-='a';
		cur ^= 1<<S[i];
		
		FOR(j,27) {
			int mask=(cur ^ (1<<j))&((1<<26)-1);
			ret[i+1]=min(ret[i+1],mi[mask]+1);
		}
		mi[cur]=min(mi[cur],ret[i+1]);
	}
	
	cout<<ret[N]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 263572
#include<stdio.h>

int main(){

	int a,b,c,i;

	scanf("%d",&i);

	while(i!=0)
	{
		scanf("%d %d %d",&a,&b,&c);
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
			printf("YES\n");
		else
			printf("NO\n");
		i--;
	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<ll,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.out", "w", stdout);
	ll h,w;
	cin>>h>>w;
	vll v;
	ll ans=100000000011LL;
	for(int i=1;i<h;i++)
	{
		v.clear();
		ll x=h-i;
		v.pb(i*w);
		v.pb((x/2LL)*w);
		v.pb((x-x/2LL)*w);
		sort(v.begin(),v.end());
		ans=min(ans,v[2]-v[0]);

		v.clear();
		v.pb(i*w);
		v.pb((w/2LL)*x);
		v.pb((w-w/2LL)*x);
		sort(v.begin(),v.end());
		ans=min(ans,v[2]-v[0]);		
	}
	swap(h,w);
	for(ll i=1;i<h;i++)
	{
		v.clear();
		ll x=h-i;
		v.pb(i*w);
		v.pb((x/2LL)*w);
		v.pb((x-x/2LL)*w);
		sort(v.begin(),v.end());
		ans=min(ans,v[2]-v[0]);

		v.clear();
		v.pb(i*w);
		v.pb((w/2LL)*x);
		v.pb((w-w/2LL)*x);
		sort(v.begin(),v.end());
		ans=min(ans,v[2]-v[0]);		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# E - Crested Ibis vs Monster
from collections import defaultdict


def main():
    H, N, *AB = map(int, open(0).read().split())
    dp = defaultdict(lambda: 1 << 30)  # dp[i] := min magic points to decrease monster's health by i
    dp[0] = 0
    for a, b in zip(*[iter(AB)] * 2):
        for i in range(H):
            if i not in dp:
                continue
            dp[i + a] = min(dp[i + a], dp[i] + b)
    ans = min(magic for health, magic in dp.items() if health >= H)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45660
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
typedef long long int ll;
using namespace std;
#define INF 1234567890
#define LIMIT 1

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

	int N;
	cin >> N;
	vector<string> vc(N);
	cout << 0 << endl;
	cin >> vc[0];
	int left = 0, right = N;
	int mid = 0;
	while (vc[mid] != "Vacant")
	{
		mid = (left + right) / 2;
		cout << mid << endl;
		cin >> vc[mid];
		if (((mid - left) & 1 ) ^ (vc[left] == vc[mid])) 
			left = mid;
		else 
			right = mid;
	}



	return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  f80 f = 0;
  reps(i, n) if (i % 2) f++;
  f /= n;
  cout << f << endl;
}


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

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

string S[100010];

int P[10] = { 0,0,0,0,0,0,1,1,1,2 };
int Q[10] = { 1,1,1,2,2,3,2,2,3,3 };
int RR[10] = { 2,3,4,3,4,4,3,4,4,4 };

int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> S[i];

    int M = 0, A = 0, R = 0, C = 0, H = 0;
    rep(i, N) {
        if (S[i][0] == 'M')M++;
        if (S[i][0] == 'A')A++;
        if (S[i][0] == 'R')R++;
        if (S[i][0] == 'C')C++;
        if (S[i][0] == 'H')H++;
    }
    long long D[5] = { M,A,R,C,H };
    long long res = 0;
    for (int d = 0; d < 10; d++) {
        res += D[P[d]] * D[Q[d]] * D[RR[d]];
    }
    cout << res << endl;
}

Measured memory_bytes: 6144
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        for (int i = 1; i*K <= B; i++) {

            if (A <= i*K && i*K <= B) {
                System.out.println("OK");
                return;
            } 
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);

    for(int i = 0; i < H; i++) {
        cin >> a.at(i);
    }
    
    for(int i = 0; i <= H+1; i++) {
        if(i == 0 || i == H+1) {
            for(int j = 0; j <= W+1; j++) {
                cout << "#";
            }
        }else {
            for(int j = 0; j <= W+1; j++) {
                if(j == 0 || j == W+1) {
                    cout << "#";
                }else {
                    cout << a.at(i-1) + "#";
                    break;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256