akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    n *= 2;
    /*
    int z[10] = {1, 3, 2, 7, 4, 3, 6, 15, 8, 19};
    if (n<=10) {
        pr(z[n-1]);
        return 0;
    }
    */
    map<ll, ll> mp;
    ll now = n;
    for (ll i=2; i*i<=now; i++) {
        if (now%i==0) {
            while (now%i==0) {
                now /= i;
                mp[i]++;
            }
        }
    }
    if (now>1) mp[now]++;
    int fs = mp.size();
    vector<ll> factors(fs);
    int index = 0;
    for (auto m: mp) {
        factors[index] = m.first;
        index++;
    }
    ll k = INFll;
    
    //mp[2]++;
    
    rep(i, 1<<fs) {
        vector<bool> vb(fs);
        ll a = 1, b = 1;
        rep(j, fs) {
            if (i>>j&1) {
                rep(ii, mp[factors[j]]) a *= factors[j];
            }
            else {
                rep(ii, mp[factors[j]]) b *= factors[j];
            }
        }
        //const int mod = y;
        vector<ll> r, m;
        m.pb(a); m.pb(b);
        r.pb(0); r.pb(-1);
        auto c = crt(r, m);
        ll res = c.first;
        //debug(c.first); debug(c.se);
        if (res<=0) res += c.se;
        chmin(k, res);
    }

    
    
    pr(k);
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 4e5 + 5, MAXM = 2e5 + 5, BOUND = 1e7, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int r, g, b, n;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> r >> g >> b >> n;
	ll ans = 0;
	for (int i = 0; i*r <= n; i++) {
		for (int j = 0; j*g + i * r <= n; j++) {
			int t = n - i * r - j * g;
			if (t%b == 0)ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
s=list(input())

a=[]
z=[]

for i in range(len(s)):
    if s[i]=="A":
        a.append(i)

    if s[i]=="Z":
        z.append(i)

a=min(a)
z=max(z)

if z<=a:
    print("0")
else:
    print(len(s[a:z+1]))


Measured memory_bytes: 12544
// Goods things are coming, just keep believing 
 
#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 FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;
 
void solve()
{
	string input;
	cin >> input;
	int cnt = 0;
	int s = 0;
	int e = input.si - 1;
	while(s <= e)
	{
		if(input[s] != input[e])
		{
			cnt++;
		}
		s++;
		e--;
	}
	cout << cnt << endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
N = len(S)+1

ANS = [0]*N
for i in range(N-1):
    if S[i] == '<':
        ANS[i+1] = ANS[i]+1

for i in range(N-2,-1,-1):
    if S[i] == '>':
        ANS[i] = max(ANS[i],ANS[i+1]+1)

print(sum(ANS))


Measured memory_bytes: 93000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll l = 0, r = 0;
    if(s[0]=='<') l++;
    if(s[0]=='>') r++;
    ll before;
    for(ll i = 1; i < s.length(); i++){
        if(s[i]=='<') l++;
        if(s[i]=='>') r++;
        if(s[i]=='>' && s[i+1]=='<' || i == s.length()-1){
            ll a = max(l, r);
            ll b = min(l, r);
            ans+=a*(a+1)/2+(b-1)*b/2;
            l = 0, r = 0;
        }
        //cout << l << " " << r << " " << s[i] << endl;
    }
    if(s.length()==1)
        ans=1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
N = 1000000
p = [1] * N

(p[0],p[1]) = (0,0)
for i in range(N):
  if (p[i]):
    for j in range (i*2,N,i):
      p[j] = 0

for i in range (1,N):
  p[i] += p[i-1]

while True:
  try:
     n = int(input())
  except EOFError:
     break
  print (p[n])


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

#define ft first
#define sd second
#define sz(x) ((int)x.size())

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;







int a[3];


int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
		return cout << "YES", 0;
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
int n,a[30];
double dp[22][200005],ans;
vector<int>p[200005];
int main()
{
	int i,j,k,h;
	for(i=1;i<200005;i++)
	    for(j=i;j<=200000;j+=i) p[j].push_back(i);
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=1;i<=200000;i++) dp[0][i]=(abs(i-a[0])+0.0)/a[0];
	for(i=1;i<n;i++)
	{
	    for(j=1;j<=200000;j++)
	    {
	        dp[i][j]=100000000.0;
	        for(k=0;k<p[j].size();k++)
	        {
	            dp[i][j]=min(dp[i][j],max(dp[i-1][p[j][k]],(abs(j-a[i])+0.0)/a[i]));
	        }
	    }
	}
	ans=100000000.0;
	for(i=1;i<=200000;i++) ans=min(ans,dp[n-1][i]);
	printf("%.9lf\n",ans);
	return 0;
}

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

int k;
int n;

#define MAX 100002

vector<int> v[MAX];

char buf[MAX];
string s;

bool ok[MAX];

bool flag[MAX];

inline bool dfs(int b,int pr=-1){
    if(pr!=-1)flag[b]^=true;
    if(s[b]=='W'){
        ok[b]=true;
        //cout<<"ok"<<endl;
    }
    for(int go:v[b]){
        if(go==pr)continue;
        ok[b]|=dfs(go,b);
    }
    for(int go:v[b]){
        if(go==pr)continue;
        if(ok[go]){
            flag[b]^=true;
        }
    }
    return ok[b];
}
int dist[MAX];
int ds[MAX];

pair<int,int> bfs(int b){
    memset(dist,-1,sizeof(dist));
    dist[b]=0;
    ds[b]=0;
    queue<int> q;
    q.push(b);
    pair<pair<int,int> ,int> p=make_pair(make_pair(-1,-1),-1);
    while(!q.empty()){
        b=q.front();
        q.pop();
        p=max(p,make_pair(make_pair(dist[b],ds[b]),b));
       // cout<<"comp "<<dist[b]<<" "<<b<<endl;
        for(int go:v[b]){
            if(ok[go]==false)continue;
            if(dist[go]>=0)continue;
            dist[go]=dist[b]+(int)(flag[go]==false);
            ds[go]=ds[b]+1;
           // cout<<"go "<<go<<" "<<dist[go]<<endl;
            q.push(go);
        }
    }
   // cout<<"res "<<p.first<<" "<<p.second<<endl;
    return make_pair(p.first.first,p.second);
}
bool cmp(int a){
    return a==1;
}
bool cmpp(int a){
    if(a==0&&ok[a]==true){
    //    cerr<<"!! "<<a<<endl;
    }
    return flag[a]==0&&ok[a]==true;
}
int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d",&a,&b);
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
	}
    scanf("%s",buf);
    s=buf;
    int star=-1;
    int cn=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            star=i;
            cn++;
        }
        if(s[i]=='B'){
            flag[i]=true;
        }
        else{
            flag[i]=false;
        }
    }
    if(star==-1){
        puts("0");
        return 0;
    }
    if(cn==1){
        puts("1");
        return 0;
    }
    dfs(star);
    int ans=bfs(bfs(star).second).first;
    int sum=count_if(ok,ok+n,cmp)-1;
    sum*=2;
    int S=0;
    for(int i=0;i<n;i++){
        if(cmpp(i)){
            S++;
        }
    }
    sum+=S;
    sum-=ans*2;
    cerr<<(count_if(ok,ok+n,cmp)-1)*2<<" "<<S<<" "<<ans<<endl;
    printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    int n;cin>>n;
    int i = 1;
    while(i*2<= n){
        i *= 2;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int a,b,c=0,d=0,e=0;
cin >> a >> b;
d = b;
while(b>0){
	b = b/10;
	c++;
}

e = sqrt(a*pow(10,c)+d);
if(e*e==a*pow(10,c)+d){
	cout << "Yes" << endl;
}

else{
	cout << "No" << endl;
}


////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector <int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int ans = MOD;
	for (int i = 0; i < n; i++) {
		vector <int> cont;
		int last = -1;
		for (int j = 0; j < n; j++) {
			if(A[j] < A[i] || j == n - 1) {
				int ed = (j == n - 1 && A[j] >= A[i]);
				vector <int> v;
				for (int el = last + 1; el <= j - 1 + ed; el++)
					v.push_back(A[el]);
				sort(all(v));
				for (int el = 0; el < (int) v.size() - k + 1; el++)
					cont.push_back(v[el]);
				last = j;
			} 
		}
		
		sort(all(cont));
		if((int) cont.size() >= q)
			ans = min(ans, cont[q - 1] - cont[0]);
	}
	cout << ans;
}


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

int main(){
    int a,b,i;
    int c[3];
    int ans;

    cin >> a >> b;
    ans=a+b;
    c[0]=a-b;
    c[1]=a*b;

    for (i=0;i<2;i++){
        if(ans < c[i]){
            ans = c[i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,ans=0;cin>>x;
  ans+=1000*(x/500)+5*((x%500)/5);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF=1LL<<62;
inline void read(int &x){
    x=0;int f=1;
    char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();x*=f;
}
int main(){
    int a,b;
    read(a),read(b);
    if(a<b) cout<<"a < b"<<endl;
    else if(a==b) cout<<"a == b"<<endl;
    else cout<<"a > b"<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=200005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int cnt[105],a[MAXN],num=0;
void add(int x,int y)
{
	for (int i=0;i<20;i++) 
	if ((x>>i)&1)
	{
		if (y==1) num+=((++cnt[i])==2);
		else num-=((--cnt[i])==1);
	}
}
int main() 
{
	int n=read(); ll ans=0;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int l=1,r=1;r<=n;r++)
	{
		add(a[r],1);
		while (num) add(a[l],-1),l++;
		ans+=(r-l+1);
	} 
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int n, w, d;

struct piec{
	int x;
	int y;

	bool operator<(const piec &in) const{
		return x*y<in.x*in.y;
	};
};

vector<piec> v;

void cutp(int ind, int s){
  	piec tmp1, tmp2;
	//cout<< ind << " " << s <<endl;
	//cout<< v[ind-1].x << " " << v[ind-1].y <<endl;
  	s=s%(2*v[ind-1].x+2*v[ind-1].y);
  
    tmp1.x=v[ind-1].x;
    tmp2.x=v[ind-1].x;
    tmp1.y=v[ind-1].y;
    tmp2.y=v[ind-1].y;
  
  	if(s<v[ind-1].x){
      	//cout<< "#1" <<endl;
      	tmp1.x=s;
      	tmp2.x=v[ind-1].x-s;
    }else if(s<v[ind-1].x+v[ind-1].y){
      	//cout<< "#2" <<endl;
      	tmp1.y=s-v[ind-1].x;
      	tmp2.y=v[ind-1].x+v[ind-1].y-s;
    }else if(s<2*v[ind-1].x+v[ind-1].y){
      	//cout<< "#3" <<endl;
      	tmp1.x=s-(v[ind-1].x+v[ind-1].y);
      	tmp2.x=2*v[ind-1].x+v[ind-1].y-s;
    }else{
      	//cout<< "#4" <<endl;
      	//cout<< 2*v[ind-1].x+v[ind-1].y << " " << 2*v[ind-1].x+2*v[ind-1].y <<endl;
      	tmp1.y=s-(2*v[ind-1].x+v[ind-1].y);
      	tmp2.y=2*v[ind-1].x+2*v[ind-1].y-s;
    }
  	if(tmp1.x>tmp2.x) swap(tmp1.x, tmp2.x);
  	if(tmp1.y>tmp2.y) swap(tmp1.y, tmp2.y);

	//cout<< tmp1.x << " " << tmp1.y <<endl;
	//cout<< tmp2.x << " " << tmp2.y <<endl;
	//cout <<endl;
  	v.erase(v.begin()+ind-1);
  	v.push_back(tmp1);
  	v.push_back(tmp2);
}

int main(){

  	int ind, s;
  	piec tmp;
  
  	while(1){
  		cin>> n >> w >> d;
      	if(n+w+d==0) break;
  
		v.resize(1);
      	tmp.x=w;
      	tmp.y=d;
      	v[0]=tmp;
      
		for(int i=0;i<n;i++){
      		cin>> ind >> s;
      		cutp(ind, s);
    	}
      
      	sort(v.begin(), v.end());
      	for(int i=0;i<v.size()-1;i++) cout<< v[i].x*v[i].y << " ";
        cout<< v[v.size()-1].x*v[v.size()-1].y <<endl;
      
    }

	return 0;
}



Measured memory_bytes: 3124
#include<stdio.h>
#include<string.h>
int main()
{
	int l,i,w=0;
	char s[105];
	scanf("%s",s);
	l=strlen(s);
	for(i=0;i<(l+1)/2;i++)
	{
		if(s[i]!=s[l-i-1]){w++;s[i]=s[l-i-1];}
	}
	printf("%d\n",w);
}

Measured memory_bytes: 128
N, Q = map(int, input().split())
S = input()

n = len(S)
ctr = [0] * n
for i in range(n):
    if i > 0 and S[i - 1] == "A" and S[i] == "C":
        ctr[i] = 1

cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i + 1] = cumsum[i] + ctr[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l - 1] - ctr[l - 1])


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

int N1, N2, A[20], M[200];

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

int main()
{
	cin >> N1;
	for (int i = 0; i < N1; i++)
	{
		cin >> A[i];
	}
	cin >> N2;
	for (int i = 0; i < N2; i++)
	{
		cin >> M[i];
		if (res(0, M[i]))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}


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

int main(){
  int n,x=0,max=0; cin>>n;
  string s; cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I') x++;
    else x--;
    if(x>max) max=x;
  }
  cout<<max<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,m;
struct edge{
    int u,v;
    double w;
    edge(int _u,int _v,double _w):u(_u),v(_v),w(_w){}
    bool operator<(const edge& b)const{
        return w > b.w;
    }
};
vector<edge> ve;
int parent[10005];
int findSet(int u)
{
    if(parent[u]==u)
        return u;
    return parent[u] = findSet(parent[u]);
}
void Union(int x,int y)
{
    int px = findSet(x);
    int py = findSet(y);
    if(px!=py)
        parent[px]=py;
}
bool isSameSet(int x,int y){
    return findSet(x) == findSet(y);
}
vector<pii> vp;

int main()
{   
    // freopen("in","r",stdin);
    while(~scanf("%d%d",&n,&m)){
        for(int i=0;i<=n;i++) parent[i]=i;
        ve.clear();
        vp.clear();
        for(int i=0;i<n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            vp.push_back(make_pair(x,y));
        }
        double ori=0;
        for(int i=0;i<m;i++){
            int u,v;
            scanf("%d%d",&u,&v);
            u--,v--;
            pii p1 = vp[u];
            pii p2 = vp[v];
            double w = sqrt((p1.first-p2.first)*(p1.first-p2.first)+(p1.second-p2.second)*(p1.second-p2.second));
            ori += w;
            ve.push_back(edge(u,v,w));
        }
        sort(ve.begin(),ve.end());
        double MaxST = 0;
        for(int i=0;i<ve.size();i++){
            edge e = ve[i];
            if(!isSameSet(e.u,e.v)){
                Union(e.u,e.v);
                MaxST += e.w;
            }
        }
        printf("%.3lf\n",ori-MaxST);
    }
    return 0;
}

Measured memory_bytes: 1896
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] T = new int[N+1];
        for(int i=1;i<=N;i++) T[i]=sc.nextInt();
        int M = sc.nextInt();
        int[] sum = new int[N+1];
        for(int i=1;i<=N;i++) sum[i]=sum[i-1]+T[i];
        for(int i=0;i<M;i++){
            int p = sc.nextInt();
            int x = sc.nextInt();
            int ans = sum[N]-T[p]+x;
            System.out.println(ans);
        }
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    long long int n,k;
    cin>>n>>k;
    long long int i,j,a[n],dp[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(j=1;j<=k && i-j>=0;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define pf push_front
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

signed main() {
    int n,num,sum=0,dig=0;
    cin >> n;

    num = n;
    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }

    if(n%sum == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
    int n, a, Mi=100000, Ma=0, k1=0, kMa=0, kMi=0;
    cin >> n;
    int K[101];
    for (int i = 0; i <= 100; i++)
    {
        K[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        K[a]++;
        Ma = max(Ma, a);
        Mi = min(Mi, a);
    }
    if (Mi*2 < Ma)
    {
        cout << "Impossible";
        return 0;
    }
    else if ((Ma % 2 == 0 && K[Mi] != 1) || (Ma % 2 == 1 && K[Mi] != 2))
    {
        cout << "Impossible";
        return 0;
    }
    for (int i = Mi; i <= Ma; i++)
    {
        if (K[i] == 0)
        {
            cout << "Impossible";
            return 0;
        }
    }
    cout << "Possible";
    return 0;
}


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


int main()
{
	int i,j,k,l;
	int n;
	int w,h;
	int ww,hh;
	int ans,sum;
	int a[101][101];

	int p,q;

	while(1)
	{
		scanf("%d",&n);
		if(n==0){break;}
		else
		{
			ans=0;
			for(i=0;i<101;i++){for(j=0;j<101;j++){a[i][j]=0;}}

			scanf("%d %d",&w,&h);

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

			scanf("%d %d",&ww,&hh);

			for(i=0;i<(w-ww+1);i++)
			{
				for(j=0;j<(h-hh+1);j++)
				{
					sum=0;
					for(k=i;k<(i+ww);k++)
					{
						for(l=j;l<(j+hh);l++)
						{
							sum+=a[k][l];
						}
					}
					if(ans<sum){ans=sum;}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
	

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  vector<int> black(n + 2), white(n + 2);
  for (int i = 0; i < n; i++) {
    if (s.at(i) == '#') black.at(i + 1)++;
    black.at(i + 1) += black.at(i);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s.at(i) == '.') white.at(i + 1)++;
    white.at(i + 1) += white.at(i + 2);
  }
  
  int ans = 1e9;
  for (int i = 0; i <= n; i++) ans = min(ans, black.at(i) + white.at(i + 1));
  
  cout << ans << '\n';
}

Measured memory_bytes: 2196
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,m;
char s[100010],t[100010];
int GCD(int a,int b) { return (!b)?a:GCD(b,a%b);}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	scanf("%s",t+1);
	int gcd=GCD(n,m),a=n/gcd,b=m/gcd;
	for (int i=1,j=1;i<=n&&j<=m;i+=a,j+=b)
	{
		if (s[i]!=t[j]) { puts("-1");return 0;}
	}
	printf("%lld\n",(long long)n*m/gcd);
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
const ll MOD = 10007;

void chmin(ll& x, ll y) {
    if (x > y) x = y;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];

    vll dp(n, INF);

    REP(i, n) {
        auto it = lower_bound(ALL(dp), a[i]);
        *it = a[i];
    }

    int cnt = 0;
    REP(i, n) {
        if (dp[i] == INF) break;
        cnt++;
    }

    print(cnt);
}


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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct __scanner__{ bool e; operator bool(){ return e; } } IN = { false };
inline __scanner__& operator>>(__scanner__& in,int &n)
{ in.e = scanf("%d",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,ll &n)
{ in.e = scanf("%lld",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,double &n)
{ in.e = scanf("%lf",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,char &n)
{ in.e = scanf(" %c",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,string &n) // BUFFER SIZE!
{ static char buf[1000000]; in.e = scanf(" %s",buf)==1; n = buf; return in; } 

int main(){
  int n;
  while (cin >> n) {
    vint v(1<<20);
    REP(i,n) {
      int t; cin >> t; v[t+1]++;
    }
    int result = 0;
    FOR(i,1,v.size()-1) {
      gs(result, v[i-1] + v[i] + v[i+1]);
    }
    cout << result << endl;
  }
}


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

int main(void)
{
        char s[11];
        scanf("%s",s);
        int i,j=0,a=0,n=strlen(s);

        for(i=0;i<n;i++){
                a=0;
        while(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
        a++;
        i++;
        }
        if (j<a) j=a;
        }
        printf("%d\n",j);
        return 0;
        }

Measured memory_bytes: 128
h, w = map(int, input().split())
mass = [list(input()) for _ in range(h)]
ans = [[""]*w for _ in range(h)]
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]
for i in range(h):
    for j in range(w):
        if mass[i][j] == "#":
            ans[i][j] = "#"
            continue
        cnt = 0
        for k in range(8):
            ni = i + dy[k]
            nj = j + dx[k]
            if ni < 0 or h <= ni:
                continue
            if nj < 0 or w <= nj:
                continue
            if mass[ni][nj] == "#":
                cnt += 1
        ans[i][j] = str(cnt)
for a in ans:
    print("".join(a))



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vi c(n);
    vector<vi> a(n, vi(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    int ans = INF;
    rep(i, 1<<n) {
        int sum = 0;
        vi b(m);
        rep(j, n) {
            if (i>>j&1) {
                rep(h, m) b[h] += a[j][h];
                sum += c[j];
            }
        }
        bool ok = true;
        rep(i, m) {
            if (b[i] < x) ok = false;
        }
        if (ok) ans = min(ans, sum);
    }
    if (ans==INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    map<string,int>memo;
    vector<int>A(5,0);
    REP(i,N){
        string s;cin>>s;
        if(memo[s]==0){
          	char z=s[0];
        	if(z=='M')A[0]++;
        	if(z=='A')A[1]++;
        	if(z=='R')A[2]++;
        	if(z=='C')A[3]++;
        	if(z=='H')A[4]++;
          	memo[s]++;
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++)ans+=A[i]*A[j]*A[k];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;

int N, C, D[50][50], g, color[3][50], ans = inf;

int main()
{
    cin >> N >> C;
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < C; j++)
        {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> g;
            color[(i + j) % 3][g - 1]++;
        }
    }
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 0; k < C; k++)
            {
                if (i == j || j == k || k == i)
                    continue;
                int sum = 0;
                for (int l = 0; l < C; l++)
                    sum += (l != i) * D[l][i] * color[0][l] + (l != j) * D[l][j] * color[1][l] + (l != k) * D[l][k] * color[2][l];
                ans = min(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,j,n,d,count,sum,h,length;
    double check;
    length = 0;
    count = 0;
    cin >> n >> d;
    int vec[n][d];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            cin >> vec[i][j];
        }
    }
    for(i=0;i<n-1;i++){
    for(h=i+1;h<n;h++){
    for(j=0;j<d;j++){
        length+=(vec[i][j]-vec[h][j])
                 *(vec[i][j]-vec[h][j]);
    }
    check = sqrt (length);
    if (check - floor(check)==0){
        count++;
    }
    length = 0;
    }
    }
    cout << count << endl;


}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int bingo[3][3]={0};
  int ans[3][3]={0};
  int n=0;
  int bn=0;
  int i,j,z;
  int flag=0; //0No,1Yes
  //ビンゴカードの入力
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&bingo[i][j]);
    }
  }
  //nの入力
  scanf("%d",&n);
  //bnの入力
  for(i=0;i<n;i++){
    scanf("%d",&bn);
    for(j=0;j<3;j++){
      for(z=0;z<3;z++){
        //bnに入力された値がビンゴカードにあったらansのカードに1をつける
        if(bingo[j][z] == bn){
        	ans[j][z]=1;
        }
      }
    }
  }
  //縦横でビンゴがそろっていればflag=1
  for(j=0;j<3;j++){
    if(ans[j][0]==1 && ans[j][1]==1 && ans[j][2]==1 || ans[0][j]==1 && ans[1][j]==1 && ans[2][j]==1){
      flag=1;
    }
  }
  //斜めでビンゴがそろっていればflag=1
  if(ans[0][0]==1 && ans[1][1]==1 && ans[2][2]==1 || ans[2][0]==1 && ans[1][1]==1 && ans[0][2]==1){
    flag=1;
  }
  
  //結果の出力
  if(flag==0){
    printf("No");	
  }
  else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 1736
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def next(v, cu):
	for i in cu:
		if i > v:
			return i
	else:
		return -1

def main():
	n, k = IN()
	al = list(IN())
	cu=[]
	for i in range(10):
		if i not in al:
			cu.append(i)
	non_zero_min = cu[0] if cu[0] > 0 else cu[1]
	is_cu0_is_0 = cu[0]==0
	
	if n < 10:
		if n in cu:
			return n
		if n > cu[-1]:
			return non_zero_min*10+cu[0]
	
	kiriage=False
	ret=[]
	for i, v in enumerate(str(n)):
		if kiriage:
			ret.append(cu[0])
		elif int(v) in cu:
			ret.append(v)
		else:
			kiriage=True
			n = next(int(v),cu)
			if n == -1:
				if i != 0:
					ret.append(cu[0])
				else:
					ret.append(str(non_zero_min)+str(cu[0]))
				
				for ic in range(i-1,-1,-1):
					#print(ic)
					t=ret[ic]
					nt = next(int(t),cu)
					if nt != -1:
						#print('a', nt, int(t))
						ret[ic]=nt
						break
					elif nt == -1 and ic == 0:
						ret[ic]=str(non_zero_min)+str(cu[0])
						#print(ret)
					else:
						ret[ic]=cu[0]
			else:
				ret.append(n)
	return ''.join([str(r) for r in ret])
			
			
			
			
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3192
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
tmp = set()
for i in range(K):
    d = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    tmp = tmp | set(A)
print(len(set(range(1,N+1))-tmp))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(3003);
double dp[N][N], p[N], res;
int n;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> p[i];
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= i; ++j)
            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1.0 - p[i]);
    for (int j = n / 2 + 1; j <= n; ++j)
        res += dp[n][j];
    cout << fixed << setprecision(10) << res;
    PLEC
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int h, w;
vector<string> grd(1010);
ll mem[1010][1010];
ll mod;
ll dp(int x, int y){
    if(x >= w || y >= h){
        return 0;
    }
    if(grd[y][x] == '#') return 0;
    if(x == w-1 && y == h-1){
        return 1;
    }
    if(mem[x][y] != -1) return mem[x][y];
    return mem[x][y] = (dp(x+1,y)+dp(x, y+1)) % mod;
}


int main(){
    cin.sync_with_stdio(false);
    cin >> h >>  w;
    mod = 1000000007;
    memset(mem, -1,sizeof(mem));
    rep(i,0,h) cin >> grd[i];
    cout << dp(0,0) % mod << endl;
    return 0;
}


Measured memory_bytes: 9344
#include<stdio.h>
int main(void)
{
	char str[51];
	int i = 0,j=0;

	while (scanf("%s",str,51) != EOF)
	{
		for (i = 0; str[i] != '\0'; i++) {
			if (str[i] == '@') {
				j = 0;
				while (j++ < str[i+1]-'0') {
					printf("%c",str[i+2]);
				}
				i += 2;
			}
			else {
				printf("%c", str[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| n; r |] ->
    [| 1 .. r |]
    |> Array.collect readIntArray
    |> Array.append [| 1 .. n |]
|> Array.groupBy id
|> Array.sortBy fst
|> Array.map (fun x -> x |> snd |> Array.length |> (-) <| 1 |> string)
|> String.concat "\n"
|> printfn "%s"


Measured memory_bytes: 30104
(n,q),*t=[map(int,t.split())for t in open(0)]
s=[0]
d=s*n
f=s+[1]*n
e=[[]for _ in d]
for t in t:
  a,b=t
  if~-n:
    n-=1
    e[a-1]+=b-1,
    e[b-1]+=a-1,
  else:d[a-1]+=b
while s:
  v=s.pop()
  for w in e[v]:
    if f[w]:
      d[w]+=d[v]
      s+=w,
      f[w]=0
print(*d)

Measured memory_bytes: 207676
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

def custom_round(number, ndigits=0):
  if type(number) == int: #整数ならそのまま返す
    return number
  d_point = len(str(number).split('.')[1]) #小数点以下が何桁あるか定義
  if ndigits >= d_point:#求める小数点以下の値が引数より大きい場合はそのまま返す
    return number
  c = (10 ** d_point) * 2
    #小数点以下の桁数分元の数に0を足して整数にして2倍するための値(0.01ならcは200)
  return round((number * c + 1) / c, ndigits)
    #元の数に0を足して整数にして2倍して1を足して2で割る。元の数が0.01なら0.015にしてroundを行う

Ai = list(mi())

for a in Ai:
  if a % 2 == 0:
    print(0)
    exit()

print(min([Ai[0]*Ai[1], Ai[1]*Ai[2], Ai[0]*Ai[2]])) 

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

int N;
vector<int> d;

int main(void) {
	cin >> N;
	d.resize(N);

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

	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	int ans = d.size();
	cout << ans << '\n';
	return 0;
}


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

int main(){
  int sum,a,b,n;
  while(cin>>a>>b>>n){
    sum=0;
    a=a%b;
    a*=10;
    for(int i=0;i<n;i++){
      sum+=a/b;
      a=a%b;
      if(a==0)break;
      a*=10;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<pair<int,int>> abs;
    for(int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      abs.push_back(make_pair(a, b));
    }
    sort(abs.begin(), abs.end());
    int s = 0;
    int best = 0;
    std::priority_queue<int> heap;
    // heap = friends x s.t. abs[x].second >= k+1
    for(int k = 1; k <= n; k++) {
      while(s < n && abs[s].first <= k+1) {
        heap.push(-abs[s].second);
        s++;
      }
      while(heap.size() > 0 && -heap.top() <= k) heap.pop();
      if(heap.size() >= k) { best = k; }
    }
    cout << best << endl;
    break;
  }
  return 0;
}

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

int main()
{
  string S;
  cin >> S;
  string ans = "No";
  if(S[0] == S[1] && S[1] == S[2])
    ans = "Yes";
  else if(S[1] == S[2]&&S[2] == S[3])
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstring>

using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N;
double dp[310][310][310];

double rec(int c1, int c2, int c3){
    if(dp[c1][c2][c3] >= 0) return dp[c1][c2][c3];
    if(c1==0 && c2==0 && c3==0) return 0.0;

    double res = 0.0;
    if(c1 > 0) res += rec(c1 - 1, c2, c3) * c1;
    if(c2 > 0) res += rec(c1 + 1, c2 - 1, c3) * c2;
    if(c3 > 0) res += rec(c1, c2 + 1, c3 - 1) * c3;
    res += N;
    res *= 1.0 / (c1+c2+c3);
    return dp[c1][c2][c3] = res;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    cin >> N;
    int C[4];
    memset(C, 0, sizeof(C));
    rep(i,N){
        int a; cin >> a;
        C[a]++;
    }
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(10) << rec(C[1],C[2],C[3]) << endl;
    return 0;
}

Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <algorithm>
#define SIZE 101
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int k, n; cin>>k>>n;
	if(!n){
		cout<<k;
		return 0;
	}
	vector<bool> num(SIZE);
	for(int i=0;i<n;i++){
		int a; cin>>a;
		num[a] = true;
	}
	int l = k, r = k;
	while(num[l]) l--;
	while(num[r]) r++;

	cout<<((k - l) <= (r - k) ? l : r);
}

Measured memory_bytes: 3164