akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<iostream>
#define x first
#define y second
using namespace std;
void koch(int n, auto s, auto e){
    if(n == 0) return;
    const double th = acos(-1) / 3;
    pair<double, double> a, b, c;
    a.x = (2 * s.x + e.x) / 3;
    a.y = (2 * s.y + e.y) / 3;
    c.x = (s.x + 2 * e.x) / 3;
    c.y = (s.y + 2 * e.y) / 3;
    b.x = (c.x - a.x) * cos(th) - (c.y - a.y) * sin(th) + a.x;
    b.y = (c.x - a.x) * sin(th) + (c.y - a.y) * cos(th) + a.y;
    koch(n-1, s, a);
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n-1, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    koch(n-1, b, c);
    printf("%.8f %.8f\n", c.x, c.y);
    koch(n-1, c, e);
}
int main(){
    pair<double, double> s, e;
    s.x = s.y = e.y = 0;
    e.x = 100;
    int n;
    cin>>n;
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n, s, e);
    printf("%.8f %.8f\n", e.x, e.y);
}

Measured memory_bytes: 3140
#include<stdio.h>
#define Num 100
int main() {
    int n[Num],x[Num];
    int i,j,k,l;
    int Sum=0;
    
    for(l=0;l<Num;l++){
        scanf("%d %d",&n[l],&x[l]);
    }
    for(l=0;l<Num;l++){
        if(n[l]==0 && x[l]==0){
            break;
        }
        for(i=1;i<n[l]-1;i++)
            for(j=i+1;j<n[l];j++)
                for(k=j+1;k<n[l]+1;k++){
                    if (i+j+k==x[l]){
                        Sum++;
                    }
                }
        printf("%d\n",Sum);
        Sum=0;
    }
}
    


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    ll n,cur=100,cnt=0;
    cin>>n;
    while(cur<n)
    {
        cnt++;
        cur+=cur/100;
    }
    cout<<cnt;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define nl endl
#define dbg(a) cout << #a << "=" << a << endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define md 1000000007

using namespace std;

int solve()
{
    string s;
    cin>>s;
    int i=0;
    ll c=0;
    ll mx=0;
    while(i<s.size())
    {
        if(s[i]=='R') c++;
        else{
            c=0;
        }
        mx=max(mx, c);
        i++;
    }
    cout<<mx<<endl;
    return 0;
}

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

Measured memory_bytes: 3652
n = int(input())
lis = []
for i in range(n):
    x, l = map(int, input().split())
    lis.append([x-l,x+l])
lis = sorted(lis, key=lambda x:x[1])
cnt = 1
p = lis[0][1]
for i in range(1, n):
    if lis[i][0] >= p:
        p = lis[i][1]
        cnt += 1
print(cnt)

Measured memory_bytes: 22104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    if (N==3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    if (N==4) {
        cout << "2 5 20 63" << endl;
        return 0;
    }
    if (N==5) {
        cout << "2 3 27 28 30" << endl;
        return 0;
    }
    if (N==6) {
        cout << "2 3 5 25 27 28" << endl;
        return 0;
    }
    if (N==7) {
        cout << "2 3 5 25 27 28 30" << endl;
        return 0;
    }
    vector<bool> A(30501);
    int cnt = 0;
    for (int i = 1; i <= 30000; i++) {
        if (i%2==0 || i%3==0 || i%5==0) {
            if (i%15==0 && i%2==1) continue;
            A[i] = true;
            cnt++;
        }
    }

    int M = cnt - N;
    if (M%2!=0) {
        M--;
        A[30000] = false;
    }
    for (int i = 30000; i >= 1; i--) {
        if (M == 0) break;
        if (!A[i]) continue;
        int k = i/30;
        int l = i%30;
        if (A[k*30+(30-l)]) {
            A[i] = A[k*30+(30-l)] = false;
            M -= 2;
        }
    }

    rep(i,30001) if (A[i]) cout << i << endl;
}

Measured memory_bytes: 384
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<pair<int,int> > vi[20];
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&curr);
        for(j=1;j<=curr;j++)
        {
            int cek;
            scanf("%d %d",&temp,&cek);
            vi[i].push_back({temp-1, cek});
        }
    }
    int sana = 0;
    for(i=0;i< (1 << n); i++)
    {
        bool can = 1;
        int good[n+5];
        memset(good, 0, sizeof(good));
        curr = 0;
        for(j=0;j<n;j++)
        {
            if((1 << j) & i)
            {
                good[j] = 1;
                curr++;
            }
        }
        for(j=0;j<n;j++)
        {
            for(auto x : vi[j])
            {
                if(good[j])
                {
                    if(good[x.first] != x.second) can = 0;
                }
            }
        }
        if(!can) continue;
        sana = max(sana, curr);
    }
    printf("%d\n",sana);
    return 0;
}


Measured memory_bytes: 256
while(h,w=gets.split.map &:to_i)!=(x,y=[0,0]);
m=[];f=[];h.times{f.push [1]*w;m.push gets};b=1;
while(?.<c=m[y][x])&&0<b=f[y][x];
f[y][x]=0;
(c[?v])?(y+=1):(c[?^])?(y-=1):(c[?<])?(x-=1):(x+=1);
end;
puts ["LOOP","#{x} #{y}"][b];
end

Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,l;cin>>n>>l;
    vector<string> S(n);
    for(int i=0;i<n;i++)cin>>S[i];
    sort(S.begin(),S.end());
    for(int i=0;i<n;i++)cout<<S[i];
    cout<<endl;
    return 0;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 1000010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,ans;

char st[maxn];

int A[maxn];

int num[maxn],L,R;

void solve(){
	RREP(i,R,L+1)if(A[num[i]]>A[num[i-1]]){
		R=i;num[R]--;n=num[R];if(L<R&&num[R]==num[R-1])R--;
		
		int j;
		for(j=1;j<=n;j++){
			A[j]++;
			if(A[j]==10)A[j]=0;
			else break;
		}
		
		while(L<=R&&num[L]<=j)L++;
		
		A[n+1]=-1;
		
		RREP(k,j,1)if(A[k]!=A[k+1])num[--L]=k;
		
		return;
	}
	n=0;
	/*RREP(i,n,2)if(A[i]>A[i-1]){
		while(i<n&&A[i+1]==A[i])i++;
		n=i;
		REP(i,1,n-1){
			A[i]++;
			if(A[i]==10)A[i]=0;
			else break;
		}
		A[n]=0;
		while(n&&!A[n])n--;
		return;
	}
	n=0;*/
}

int lst[maxn],m;

void print(){
	REP(i,1,n)lst[i]-=A[i];
	REP(i,1,m)if(lst[i]<0)lst[i]+=10,lst[i+1]-=1;
	while(m&&!lst[m])m--;
	lst[m+1]=0;
/*	RREP(i,m,1){
		printf("%d",lst[i]);
	//	assert(lst[i]>=lst[i+1]);
	}cout<<endl;*/
}

void Work(){
	while(n){
		ans++,solve();
//		print();
//		RREP(i,n,1)cout<<A[i];cout<<endl;
	}
	iout(ans);
}

void Init(){
	scanf("%s",st+1);
	n=strlen(st+1);
	REP(i,1,n)A[i]=st[n-i+1]-'0';
	L=500000;R=L-1;
	REP(i,1,n)if(A[i]!=A[i+1])num[++R]=i;
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 10496
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);

    while (1)
    {
        if (n == 0)
        {
            printf("No");
            break;
        }
        if (n % 10 == 7)
        {
            printf("Yes");
            break;
        }
        n /= 10;
    }
    return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint p(n+1);
    rep(i,n) cin >> p[i];
    p[n] = 0;
    int ct = 0;
    int id = 0;
    while (id < n) {
        if (p[id] == id+1) {
            ct++;
            if (p[id+1] == id+2) id++;
        }
        id++;
    }
    cout << ct << endl;
}

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

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

    int n;
    cin >> n;

    vector<long long> L(n + 1);
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i <= n; i++){
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[n] << endl;

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()]


if n==k:
    print(sum(p))
else:
    sump = [0]*n
    sump[0]=p[0]
    for i in range(n-1):
        sump[i+1] = sump[i]+p[i+1]
    ans=max(sump[i+k]-sump[i] for i in range(n-k))
    print(ans)

Measured memory_bytes: 71792
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    string s;
    cin>>s;

    vector<char> tmp;
    int64 nofo=0;
    int64 ans=0;

    for(int64 i=0;i<s.length();i++){
        if(s[i]=='A'){
            tmp.push_back('o');
        }else if(s[i]=='B'&&s[i+1]=='C'){
            tmp.push_back('x');
            i++;
        }else{
            // for(int64 j=0;j<tmp.size();j++){
            //     cout<<tmp[j];
            // }
            // cout<<endl;
            reverse(tmp.begin(),tmp.end());
            nofo=0;
            for(int64 j=0;j<tmp.size();j++){
                if(tmp[j]=='o'){
                    ans+=j-nofo;
                    nofo++;
                }
            }
            tmp.clear();
        }
    }
    // for(int64 j=0;j<tmp.size();j++){
    //     cout<<tmp[j];
    // }
    // cout<<endl;
    reverse(tmp.begin(),tmp.end());
    nofo=0;
    for(int64 j=0;j<tmp.size();j++){
        if(tmp[j]=='o'){
            ans+=j-nofo;
            nofo++;
        }
    }
    tmp.clear();

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

Measured memory_bytes: 772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  set<int> s;
  for(int i = 0; i < k; i++) {
    cin >> d[i];
    for(int j = 0; j < d[i]; j++) {
      int a;
      cin >> a;
      s.insert(a);
    }
  }
  cout << n - s.size();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int color[MAXN];

vector<pii> g[MAXN];

void dfs(int u, int p) {
	for(auto i : g[u]) {
		if(i.f == p) continue;
		if(i.s % 2 == 0) {
			color[i.f] = color[u];
			dfs(i.f, u);
		}
		else {
			color[i.f] = color[u] ^ 1;
			dfs(i.f, u);
		}
	}
}

int32_t main() {
	FAST;
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].pb({b, c});
		g[b].pb({a, c});
	}
	dfs(0, 0);
	for(int i = 0; i < n; i++)
		cout << color[i] << endl;
}


Measured memory_bytes: 10240
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(void){
    // Your code here!
    int n;
    
    cin >> n;
    for(int i = 0; i < n / 4 + 1; i++){
        if((n - i * 4) % 7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	int N,K,X,Y;
	cin >> N >> K >> X >> Y;
	if(N<K){
		cout << X*N << endl;
	}else{
		cout << X*K+(N-K)*Y << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, M, K; cin >> N >> M >> K; 
	long long A[100010] = {}; 
	for(int i = 1; i <= N; i++) cin >> A[i]; 
	long long dp[305][100005] = {};
	for(int i = 1; i <= K; i++){
		deque<int> deq; 
		deq.push_back(0); 
		for(int j = 1; j < M; j++){
			if(j >= i) dp[i][j] = dp[i-1][deq.front()] + A[j] * i; 
			while(deq.size() && dp[i-1][deq.back()] <= dp[i-1][j]){
				deq.pop_back(); 
			}
			deq.push_back(j); 
		}
		for(int j = M; j <= N; j++){
			if(j >= i) dp[i][j] = dp[i-1][deq.front()] + A[j] * i; 
			if(deq.front() == j - M) deq.pop_front(); 
			while(deq.size() && dp[i-1][deq.back()] <= dp[i-1][j]){
				deq.pop_back(); 
			}
			deq.push_back(j); 
		}
	}
	long long ans = 0; 
	for(int i = K; i <= N; i++) ans = max(ans, dp[K][i]); 
	cout << ans << "\n"; 
}

Measured memory_bytes: 242676
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

#define MOD INF

ll powermod (ll B, ll P, ll M)
{
  ll r = 1;
  if (B >= M) B %= M;
  while (P > 0)
  {
    if ((P & 1) == 1)
    {
      r *= B;
      if (r >= M) r %= M;
    }
    P >>= 1;
    B *= B;
    if (B >= M) B %= M;
  }
  return r;
}

int n, k;
ll res, numexx[100014];

int main ()
{
  R2(n, k);
  res = 0;
  FORDE(i, k, 1)
  {
    numexx[i] = powermod(k / i, n, MOD);
    for (int j = 2 * i; j <= k; j += i) 
    {
      numexx[i] -= numexx[j];
      numexx[i] += MOD;
      numexx[i] %= MOD;
    }
    res += i * numexx[i];
    res %= MOD;
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int n, m;
int x[100005], y[100005];
ll ans[100005];
 
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
 
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
 
int main() {
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    ll res = 1ll*n*(n-1)/2;
    for (int i = m; i >= 0; i--) {
        ans[i] = res;
        if (uf.root(x[i]) == uf.root(y[i])) {
            continue;
        }
        else res -= 1ll*uf.size(x[i])*uf.size(y[i]);
        uf.merge(x[i], y[i]);
    }
    for (int i = 0; i < m; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<int> w;

    void input() {
        w.resize(N);
        rep(i, 0, N) cin >> w[i];
    }

    int dp[305][305];

    int rec(int l, int r) {
        if (l >= r) return 0;
        if (dp[l][r] != -1) return dp[l][r];

        if (l + 1 == r) {
            return dp[l][r] = 2 * (abs(w[l] - w[r]) <= 1);
        }
        int ret = 0;
        for (int k = l; k < r; ++k) {
            chmax(ret, rec(l, k) + rec(k + 1, r));
        }
        if (rec(l + 1, r - 1) == r - l - 1 && abs(w[l] - w[r]) <= 1) {
            chmax(ret, rec(l + 1, r - 1) + 2);
        }

        return dp[l][r] = ret;
    }

    void solve(int n) {
        N = n;
        input();
        memset(dp, -1, sizeof(dp));

        int ans = rec(0, n - 1);
        cout << ans << endl;

    }
};


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

    while (true) {
        int tmp;
        cin >> tmp;
        if (tmp == 0) break;
        Solve().solve(tmp);
    }


    return 0;
}



Measured memory_bytes: 3488
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n, m;
	string s[100], t[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	int count_n[100] = {};
	for (int i = 0; i < n; i++) {
		if (s[i] != "1") {
			count_n[i]++;
			for (int j = i + 1; j < n; j++) {
				if (s[i] == s[j]) {
					count_n[i]++;
					s[j] = "1";
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (count_n[i] != 0) {
			for (int j = 0; j < m; j++) {
				if (s[i] == t[j]) {
					count_n[i]--;
				}
			}
		}
		ans = max(ans, count_n[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int a[5];
  rep(i, 5) cin >> a[i];
  int k; cin >> k;

  bool ans = true;
  for(int i = 0; i < 4; i++){
    for(int j = i+1; j < 5; j++){
      if((a[j] - a[i]) > k) ans = false;
    }
  }
  
  cout << (ans ? "Yay!" : ":(") << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cstring>
#include <vector>
#define rep(i,n) for(ll i=1;i<=n;i++)
#define repn(i,n) for(ll i=n;i>=1;i--)
#define ll long long
#define mt(a,x) memset(a,x,sizeof(a))
const ll mod = 1e9+7;
const ll maxn = 1000050;
using namespace std;
vector<int> road[maxn],rail[maxn];
int road_father[maxn],rail_father[maxn];
int n,k,l;
int road_g[maxn],rail_g[maxn];
int ans1[maxn],ans2[maxn];
map<pair<int,int>,int> mp;
map<int,int> mp1,mp2;
void solve1(int pos,int father)
{
    road_father[pos]=father;
    road_g[pos]=1;
    mp1[father]++;
    for(int i=0;i<road[pos].size();i++)
    {
        if(!road_g[road[pos][i]]) solve1(road[pos][i],father);
    }
    return ;
}
void solve2(int pos,int father)
{
    rail_father[pos]=father;
    mp2[father]++;
    rail_g[pos]=1;
    for(int i=0;i<rail[pos].size();i++)
    {
        if(!rail_g[rail[pos][i]]) solve2(rail[pos][i],father);
    }
    return ;
}
void connect()
{
    mt(road_g,0);
    mt(rail_g,0);
    rep(i,n)
    {
        if(road_g[i]) continue;
        solve1(i,i);
    }
    rep(i,n)
    {
        if(rail_g[i]) continue;
        solve2(i,i);
    }
}
int main()
{
    //freopen("data","r",stdin);
    ios::sync_with_stdio(0);
    cin>>n>>k>>l;
    rep(i,k)
    {
        int p,q;
        cin>>p>>q;
        road[p].push_back(q);
        road[q].push_back(p);
    }
    rep(i,l)
    {
        int r,s;
        cin>>r>>s;
        rail[r].push_back(s);
        rail[s].push_back(r);
    }
    connect();
    /*rep(i,n) ans1[i]=mp1[road_father[i]],cout<<road_father[i]<<" ";
    cout<<endl;
    rep(i,n) ans2[i]=mp2[rail_father[i]],cout<<rail_father[i]<<" ";
    cout<<endl;*/
    rep(i,n) mp[make_pair(road_father[i],rail_father[i])]++;
    rep(i,n) cout<<mp[make_pair(road_father[i],rail_father[i])]<<" ";
}


Measured memory_bytes: 94080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string X;
  int x=0;
  int y=0;
  cin >> N;
  vector<string> vec1(N);
  vector<int> vec2(N);

  
  for (int i=0; i<N; i++) {
    cin >> vec1[i] >> vec2[i];
  }
  cin >> X;
  
  for (int i=0; i<N; i++) {
    if (X==vec1[i]) x=i;
  }
  
  for (int i=0; i<N; i++) {
    y += vec2[N-1-i];
    if (N-i-2==x) break;
  }
  
  if (X==vec1[N-1]) y=0;
  
  cout << y << endl;

  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int MAX=0;
    for(int i=0;i<n;i++) MAX=max(MAX,a[i]);
    int f=0;
    for(int i=0;i<n;i++){
        if(MAX==a[i]){
            f++;
        }
    }
    int MAXX=0;
    for(int i=0;i<n;i++){
        if(MAX==a[i]) continue;
        else MAXX=max(MAXX,a[i]);
    }
    if(f>=2){
        for(int i=0;i<n;i++){
            cout<<MAX<<endl;
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(MAX==a[i]){
                cout<<MAXX<<endl;
            }
            else cout<<MAX<<endl;
        }
    }
}

Measured memory_bytes: 2432
N,K=map(int, input().split())
instr=input()
lft=0
rgt=1
voids=0 if instr[0] == '1' else 1

maxlen=0
while lft < rgt:
    maxlen = max(maxlen, rgt-lft)
    # print("lft {} rgt {} maxlen {} void {} {}".format(lft, rgt, maxlen, voids, instr[lft:rgt]))
    if rgt < N and (instr[rgt] == '1' or (instr[rgt-1] == '0' and instr[rgt] == '0')):
        rgt += 1
    elif rgt < N and instr[rgt] == '0' and voids < K:
        voids += 1
        rgt += 1
    else:
        # 左を動かすケース
        if lft+1 < N and instr[lft] == '0' and instr[lft+1] == '1':
            voids -= 1
        lft += 1

print(maxlen)


Measured memory_bytes: 3316
using System;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = input[0];
            var b = input[1];

            Console.WriteLine(a * b);
        }
    }
}


Measured memory_bytes: 28120
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, 0, N) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int sum = 0;
    rep(i, 0, K) sum += l[i];
    cout << sum << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#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 ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class CGreenBin {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in>>N;
	    map<map<char, int>, lint> mp;
	    REP(i, N){
	        string s;
	        in>>s;
	        map<char, int> mm;
	        for(auto c : s) mm[c]++;
	        mp[mm]++;
	    }
	    lint ans = 0;
	    for(auto m : mp){
	        ans += m.second * (m.second-1) / 2;
	    }
	    out<<ans<<'\n';
	}
};


int main() {
	CGreenBin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 49152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin>>n;
  for(int i=(int)sqrt(n);i>=1;i--){
    if(n%i==0){
      int cn=0,j=n/i;
      while(j!=0){
        j/=10;
        cn++;
      }
      cout<<cn;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n, x = map(int, input().split())
P = [1]
A = [1]
for i in range(n):
    P.append(P[i] * 2 + 1)
    A.append(A[i] * 2 + 3)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    
    elif x <= A[n-1] + 1:
        return f(n-1, x-1)
    
    else:
        return P[n-1] + 1 + f(n-1, x-A[n-1] -2)
    
print(f(n, x))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

map<string, int> m;

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

    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        m.insert(make_pair(S, 1));
    }

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

    return 0;
}

Measured memory_bytes: 19160
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 3e5 + 10; 

int a[N];
int val[61];

ll power(ll x, ll y){
   ll ans=1;
   if(y==1) return x%MOD;
   x=x % MOD,y=y % (MOD-1);
   while(y){
      if(y & 1) ans = (ans*x) %MOD;
      x *= x;
      x = x % MOD;
      y >>= 1;
   }
   return ans;
}
 
ll inv(ll x){
   return power(x,MOD-2);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   f(i,0,n){
      cin >> a[i];
   }
   reverse(a,a+n);
   int ans = 0;
   f(i,0,n-1){
      f(j,0,61){
         if(a[i]&(1ll<<j)){
            val[j]++;
         }
      }
      f(j,0,61){
         if(a[i+1]&(1ll<<j)){
            ans += (i+1-val[j]%MOD)*((1ll<<j)%MOD);
            ans = ans%MOD;
         }else{
            ans += (val[j]%MOD)*((1ll<<j)%MOD);
            ans = ans%MOD;
         }
         // cout << j << ' ' << ans << '\n';
      }
      // cout << a[i] << ' '<< ans << "\n\n";
   }
   // ans = ans*inv(2);
   ans = ans%MOD;
   cout << ans << '\n';
   return 0;
} 

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

vector<int> v[200001];

int main(){
	int n,m;
	int a,b;
	
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a >> b;
		if(a==1||b==n){
			v[a].push_back(b);
			v[b].push_back(a);
		}
	}
	for(int i = 0;i < v[1].size();i++){
		int x = v[1][i];
		for(int j = 0;j < v[x].size();j++){
			if(v[x][j]==n){
				cout << "POSSIBLE";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE";
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
string co="RGB";
int W,H;
typedef struct{
	int cnt,area;
	char f[12][12];
}F;

int chk(F tmp){
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(tmp.f[1][1]!=tmp.f[j][i])return 0;
		}
	}
	return 1;
}

F dt,df,dc;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int>P;
void flgon(){
	queue<P>Q;
	Q.push(P(1,1));
	while(!Q.empty()){
		P p=Q.front();Q.pop();
		if(df.f[p.first][p.second]=='#'){
			df.f[p.first][p.second]='*';
			for(int i=0;i<4;i++){
				if(df.f[p.first+dx[i]][p.second+dy[i]]=='#' && dt.f[p.first+dx[i]][p.second+dy[i]]==dt.f[p.first][p.second]){
					Q.push(P(p.first+dx[i],p.second+dy[i]));
				}
			}
		}
	}
}

int flgcnt(){
	int cnt=0;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(df.f[j][i]=='*')cnt++;
		}
	}
	return cnt;
}

void flgdraw(char c){
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(df.f[j][i]=='*')dt.f[j][i]=c;
		}
	}
}

int main(){
	for(int i=0;i<144;i++)dc.f[i/12][i%12]='#';
	dc.cnt=0;
	while(cin>>W>>H,W){
		F tmp=dc;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>tmp.f[j][i];
			}
		}
		dt=tmp;
		df=dc;flgon();
		tmp.area=flgcnt();
		
		queue<F>Q;
		Q.push(tmp);
		while(!Q.empty()){
			tmp=Q.front();
			Q.pop();
			if(chk(tmp)){
				cout<<tmp.cnt<<endl;
				break;
			}
			for(int i=0;i<3;i++){
				if(tmp.f[1][1]==co[i])continue;
				dt=tmp;
				df=dc;flgon();
				flgdraw(co[i]);
				df=dc;flgon();
				int k=flgcnt();
				if(tmp.area==k)continue;
				dt.cnt=tmp.cnt+1;
				dt.area=k;
				Q.push(dt);
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 10928
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

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

	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll mx = a[0];
	ll sum = 0;
	for(int i=1;i<n;i++){
		if(a[i]<mx){
			sum += (mx - a[i]);
		}else{
			mx = max(mx,a[i]);
		}
	}

	cout<<sum<<endl;

	

	return 0;
}

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


int main() {
int A,B,K;
  cin>>A>>B>>K;
  int counter=0;
  for(int i=min(A,B);i>0;i--){
    if(A%i==0&&B%i==0){
      counter++;
      if(counter==K){
        cout<<i<<endl;
        break;
      }
    }
  }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (s.size() > n) {
    for (int i = 0; i < n; i++) {
      cout << s[i];
    }
    cout << "...";
  } else {
    cout << s;
  }
  cout << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    li res = INF;
    repp(i, 1, n) {
        li tres = 0;
        li j = n - i;
        stringstream ssi;
        ssi << i;
        stringstream ssj;
        ssj << j;
        for (char c : ssi.str()) {
            tres += c - '0';
        }
        for (char c : ssj.str()) {
            tres += c - '0';
        }
        res = min(res, tres);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define coud(a,d) cout << fixed << showpoint <<setprecision(d)<<a;
using namespace std;

const int N = 3000;
double p[N];
double dp[N][N];
int n;

void result()
{
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i <= n; ++i)
	{
		dp[i][0] = pow((1-p[i]),i);
	}

	for (int i = 1; i <= n; ++i)
	{
		dp[0][i] = 0.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-p[i]);
		}
	}
	double sum = 0.0;
	for (int i = ceil(n/2.0); i <= n; ++i)
	{
		sum += dp[n][i];
	}
	coud(sum, 10);
}
int main()
{
	cin >> n;
	p[0] = 1.0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> p[i];
	}	
	result();
  	cout << endl;
	return 0;
}




Measured memory_bytes: 70528
#include <iostream>
#include <string>
using namespace std;
bool kaibun(string v){int n = v.size();for(int i=0;i<n;i++){if(v[i]!=v[n-1-i])return false;}return true;}
int main(){string s;cin >> s;int n = s.size();string a = s.substr(0,n/2),b=s.substr(n/2+1,n);if(kaibun(s)&&kaibun(a)&&kaibun(b))cout << "Yes" << endl;else cout << "No" << endl;}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int i, j, z, K, S;
    int count = 0;
    
    scanf("%d %d", &K, &S);

    for (i=0; i<=K; i++) {
        for (j=0; j<=K; j++) {
            z = S - i - j;
            if (z >= 0 && z <= K) count++;
        }
    }
    printf("%d", count);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int num = 21;
		int max = -1;
		
		int nico = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < nico; i++) {
			String[] data = sc.nextLine().split(" ");
			
			int tmpn = Integer.parseInt(data[0]);
			int tmpm = Integer.parseInt(data[1]);
			
			if (max <= tmpm) {
				if (max == tmpm) {
					if (num > tmpn) num = tmpn;
				} else {
					max = tmpm;
					num = tmpn;
				}
			}
		}
		System.out.println(num + " " + max);
	}
}

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

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

    map<string, int> m;

    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        m[s] = 1;
    }
	
    cout << m.size() << endl; 
    
    return 0;
}



Measured memory_bytes: 19148
import sys
n = int(input())
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no") 
        

Measured memory_bytes: 112344
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(3*n);
	rep(i,3*n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll ans = 0;
	for(int i = 1; i < 2*n; i += 2){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
a,b,n = gets.chomp.split(" ").map(&:to_f)

def cul(a,b,x)
  f1 = (a*x/b).floor
  f2 = a*((x/b).floor)
  (f1-f2).to_i
end
if n < b
  puts cul(a,b,n)
else
  puts cul(a,b,b-1)
end

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

using namespace std;

constexpr uint64_t THRESHOLD = 1000000000000000000;

int main() {
  size_t N;
  cin >> N;

  vector<uint64_t> values(N, 0);
  
  for (size_t i = 0; i < N; ++i) {
    cin >> values[i];
    if (values[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  uint64_t prod = 1;
  for (size_t i = 0; i < N; ++i) {
    double capacity = THRESHOLD / prod;
    if (capacity < values[i]) {
      cout << "-1" << endl;
      return 0;
    }
    prod *= values[i];
  }
  
  cout << prod << endl;

  return 0;
}


Measured memory_bytes: 4060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= n; i++) {
			ans += i;
		}
		System.out.println(ans);
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll x, y;
  cin >> x >> y;
  int ans = 1;
  for(ll i = x * 2; i <= y; i *= 2){
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[1000],q;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;i++){
    int c,b,e;
    cin>>c>>b>>e;
    if(c){
      int r=-(int)1e9;
      for(int j=b;j<e;j++) r=max(r,a[j]);
      cout<<r<<endl;
    }else{
      int r=(int)1e9;
      for(int j=b;j<e;j++) r=min(r,a[j]);
      cout<<r<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3096
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
      	String str1 = sc.next();
        char[] ch1 = getChars(str1);
      	String str2 = sc.next();
      	char[] ch2 = getChars(str2);

      	int count = 0;
      	for (int i=0; i<str1.length(); i++) {
          if(ch1[i] != ch2[i]) {
            count++;
          }
        }

      	System.out.println(count);
    }
  
  	public static char[] getChars(String str) {
      	char[] ch = new char[str.length()];
      	for (int i=0; i<str.length(); i++) {
            ch[i] = str.charAt(i);
        }
      	return ch;
    }
}

Measured memory_bytes: 42076
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            in = sc.next().toCharArray();
            p = 0;     
            System.out.println(expr());            
        }
    }

    int expr(){
        int a = term();
        while(p<in.length && (in[p]=='+' || in[p]=='-')){
            boolean boo = in[p]=='+';
            p++;
            int b = term();
            if(boo) a += b;
            else a -= b;
        }
        return a;
    }

    int term(){
        int a = factor();
        while(p<in.length && (in[p]=='*' || in[p]=='/')){
            boolean boo = in[p]=='*';
            p++;
            int b = factor();
            if(boo) a *= b;
            else a /= b;
        }
        return a;
    }

    int factor(){
        if(p<in.length && in[p]=='('){
            p++;
            int res = expr();
            p++;
            return res;
        }
        else return digit();
    }

    int digit(){
        int res = 0;
        while(p<in.length && Character.isDigit(in[p])){
            res = res*10 + (in[p]-'0');
            p++;
        }
        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 17172
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a,b,c;
  cin >> a;
  b="CODEFESTIVAL2016";
  int d=0;
  for(int i=0;i<16;i++){
    if(a[i]!=b[i]) d++; 
  }
  cout << d <<endl;
   return 0;
}


Measured memory_bytes: 256
from fractions import gcd
lcm = lambda a, b: a * b // gcd(a, b)
num_of_multi = lambda n: b // n - a // n - bool(a % n) + 1

a, b, c, d = map(int, input().split())
print(b - a + 1 - num_of_multi(c) - num_of_multi(d) + num_of_multi(lcm(c, d)))


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

int main(){
    string s;
    bool ans = false;
    cin >> s;
    for(int i=0;i<s.size();i+=1){
        if(i%2==0 && s[i] != 'L')ans = true;
        else if(i%2==1 && s[i] != 'R')ans =true;
        else{
            ans = false;
            break;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000003;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 1000006;

ll q,x,d,n;
ll mpow(ll base,ll ep) {
    if (ep == 0) {
        return 1;
    }
    ll hf = mpow(base,ep>>1);
    hf = hf * hf % MOD;
    return ep & 1 ? hf * base % MOD : hf;
}

ll fc[MAXN],ifc[MAXN];
void build() {
    fc[0] = ifc[0] = 1;
    REP1 (i,MAXN-1) {
        fc[i] = fc[i-1] * i % MOD;
        ifc[i] = mpow(fc[i],MOD-2);
    }
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    build();
    cin >> q;
    while (q--) {
        cin >> x >> d >> n;
        ll f = x * mpow(d,MOD-2) % MOD;
        ll m = (1+(MOD-x) * mpow(d,MOD-2)) % MOD;
        if (d == 0) {
            cout << mpow(x,n) << endl;
            continue;
        }
        debug(m);
        if (n >= m) {
            cout << 0 << endl;
        } else {
            cout << mpow(d,n) * fc[(f+n-1)%MOD] % MOD * ifc[(f-1+MOD)%MOD] % MOD << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 16512
# see: https://kimiyuki.net/blog/2016/07/23/arc-058-c/

n, k = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)

i = n
loop do
  valid = true
  i.to_s.split("").map(&:to_i).each do |c|
    valid = false if d.include? c
  end

  break if valid
  i += 1
end

puts i


Measured memory_bytes: 2044