akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll h,w;
  cin >> h >> w;
  if(h == 1 || w == 1){
    cout<<1<<endl;
    return 0;
  }
  ll ans = h*w/2;
  if(h%2 && w%2) ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <limits>

using namespace std;

const int N = 100;

enum {
    WHITE,
    GRAY,
    BLACK,
};

int main() {
    int A[N][N];

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            A[i][j] = a == -1 ? numeric_limits<int>::max() : a;
        }
    }

    // ????????????
    vector<int> color(n, WHITE); // ??????????¨??????¶???
    vector<int> d(n, numeric_limits<int>::max());
    vector<int> p(n, -1);

    d[0] = 0;
    while (1) {
        int minv = numeric_limits<int>::max();
        int u = -1;
        for (int i = 0; i < n; ++i) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;
        color[u] = BLACK;
        for (int v = 0; v < n; ++v) {
            if (color[v] != BLACK && A[u][v] != numeric_limits<int>::max()) {
                if (d[v] > A[u][v]) {
                    d[v] = A[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum;
    for (int i = 0; i < n; ++i) {
        if (p[i] != -1)
            sum += A[i][p[i]];
    }
    cout << sum << endl;

    return 0;
}

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

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define db              long double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vi              vector <int>
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define vec(v)          vector <v>
#define all(v)          (v.begin(), v.end())
#define rall(v)         (v.rbegin(), v.rend())
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define clr(x,y)        memset(x, y, sizeof(x))
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9 + 7;

void solve()
{
    string s;
    cin >> s;
    int n = s.length();
    char ch = s.at(n - 1);
    if (ch == 's')
        s += "es";
    else
        s += "s";
    cout << s;
}

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


    /***************-Code starts from here-***************/
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int main()
{
	vector<bool> isPrime(1001, true);
	vector<int> prime;
	rep(i, 2, 1000)
	{
		if (isPrime[i])
		{
			prime.push_back(i);
			for (int j = i + i; j <= 1000; j += i) isPrime[j] = false;
		}
	}
	int len = prime.size();
	vector<ll> a(len, 1);
	int n; cin >> n;
	rep(i, 1, n)
	{
		int x = i;
		rep(j, 0, len - 1)
		{
			int d = prime[j];
			while (x%d == 0)
			{
				++a[j];
				x /= d;
			}
		}
	}
	ll ans = 1;
	for (ll x : a)
	{
		ans = ans * x % 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = [int(x) for x in input().split()]
    XYZ = [[int(x) for x in input().split()] for _ in range(M)]

    u = UnionFind(N + 2)

    f = True
    for x, y, z in XYZ:
        x += 1
        y += 1
        if z % 2 == 0:
            u.union(x, y)
        else:
            if f:
                f = False
                u.union(x, 0)
                u.union(y, 1)
            if u.same(x, 0):
                u.union(y, 1)
            if u.same(x, 1):
                u.union(y, 0)
            if u.same(y, 0):
                u.union(x, 1)
            if u.same(y, 1):
                u.union(x, 0)

    for x, y, z in XYZ:
        x += 1
        y += 1
        if z % 2 == 1:
            u.union(x, y)
        else:
            if f:
                f = False
                u.union(x, 0)
                u.union(y, 1)
            if u.same(x, 0):
                u.union(y, 1)
            if u.same(x, 1):
                u.union(y, 0)
            if u.same(y, 0):
                u.union(x, 1)
            if u.same(y, 1):
                u.union(x, 0)

    print(u.group_count())


if __name__ == '__main__':
    main()


Measured memory_bytes: 26016
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[100],b[100],c[100],dp[110][110];
int main(){
	while(true){
		cin>>n>>m;if(n==0 && m==0)break;
		for(int i=0;i<110;i++){
			for(int j=0;j<110;j++)dp[i][j]=1<<30;
		}
		for(int i=0;i<m;i++)cin>>a[i]>>b[i]>>c[i];
		dp[0][0]=0;
		for(int i=0;i<=n;i++){
			for(int j=0;j<=100;j++){
				for(int k=0;k<m;k++){
					if(j<c[k])continue;
					int H=min(dp[min(n,i+a[k])][min(100,j+b[k])],dp[i][j]+1);
					dp[min(n,i+a[k])][min(100,j+b[k])]=H;
				}
			}
		}
		int minx=1<<30;
		for(int i=0;i<=100;i++)minx=min(minx,dp[n][i]);
		if(minx>=(1<<30))cout<<"NA"<<endl;
		else{cout<<minx<<endl;}
	}
}

Measured memory_bytes: 1212
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N == 1) {
    cout << abs(A[0] - W) << endl;
    return 0;
  }
  cout << max(abs(A.back() - W), abs(A[A.size() - 2] - A.back())) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint p=998244353;

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int r[2*N+1],b[2*N+1];
  r[0]=0;
  b[0]=0;
  int rt=0;
  int bt=0;
  int i=0;
  for(auto c:S){
    if(c=='0')rt+=2;
    else if(c=='1'){
      rt+=1;
      bt+=1;
    } else bt+=2;
    r[i+1]=r[i];
    if(rt>0){
      r[i+1]++;
      rt--;
    }
    b[i+1]=b[i];
    if(bt>0){
      b[i+1]++;
      bt--;
    }
    i++;
  }
  REP(i,N){
    r[i+N+1]=r[i+N];
    if(rt>0){
      r[i+N+1]++;
      rt--;
    }
    b[i+N+1]=b[i+N];
    if(bt>0){
      b[i+N+1]++;
      bt--;
    }
  }
  // REP(i,2*N+1)cerr<<r[i]<<" "<<b[i]<<endl;
  int R=r[2*N];
  lint dp[2*N+1][R+1];
  REP(i,2*N+1)REP(j,R+1)dp[i][j]=0;
  dp[0][0]=1;
  FOR(i,1,2*N+1)FOR(j,0,R+1){
    if(j<i-b[i]){
      dp[i][j]=0;
      continue;
    }
    if(j==0){
      dp[i][j]=1;
      continue;
    }
    if(j>r[i])dp[i][j]=dp[i-1][j];
    else dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
    dp[i][j]%=p;
  }
  cout<<dp[2*N][R]<<endl;
  // REP(i,2*N+1){
  //   REP(j,R+1)cerr<<dp[i][j]<<" ";
  //   cerr<<endl;
  // }
  return 0;
}


Measured memory_bytes: 125056
S = input()

def AGCT(S,i):
    if S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C":
        return 0
    else:
        return 1

c = 0
ANS = []
for i in range(len(S)):
    if AGCT(S,i) == 0:
        c += 1
    else:
        ANS.append(c)
        c = 0
ANS.append(c)
print(max(ANS))

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli x,y;
lli ans = 0;

int main(){
  cin >> x >> y;
  while(x <= y) ans++,x <<= 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
typedef pair<int, int> pii;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> used(n, 0);
    for (int i = 0; i < k; i++) {
        used[i] = 1;
    }
    sort(all(used));
    int ans = 0;
    do{
        int tm = m;
        vector<pii> poteto;
        for(int i = 0; i < n; i++){
            if(used[i] == 1)poteto.push_back(pii(a[i], b[i]));
        }
        sort(all(poteto));
        reverse(all(poteto));
        int tmp = 0;
        for (int i = 0; i < poteto.size() and tm > 0; i++) {
            tmp += poteto[i].first*min(tm, poteto[i].second);
            tm -= min(poteto[i].second, tm);
        }
        ans = max(ans, tmp + tm);
    }while(next_permutation(all(used)));
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int Mod = 998244353, Nmax = 205;

struct Fractie
{
    int up, down;
    bool operator < (const Fractie &other) const
    {
        return up * other.down < down * other.up;
    }

    bool operator == (const Fractie &other) const
    {
        return up * other.down == down * other.up;
    }
} v[Nmax];

struct Point
{
    int x, y;
    bool operator < (const Point &other) const
    {
        if(x == other.x) return y < other.y;
        return x < other.x;
    }
} a[Nmax];

int pw[Nmax], i, n, ans, j, k;

int main()
{
  //  freopen("input", "r", stdin);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i].x >> a[i].y;
    sort(a+1, a+n+1);

    pw[0] = 1;
    for(i=1; i<=n; ++i)
        pw[i] = pw[i-1] * 2 % Mod;

    ans = pw[n] - n - 1;
    for(i=1; i<=n; ++i)
    {
        for(j=i+1; j<=n; ++j) v[j-i] = {a[j].y - a[i].y, a[j].x - a[i].x};
        sort(v+1, v+n-i+1);

        for(j=1; j<=n-i; ++j)
        {
            k = j;
            while(k < n-i && v[j] == v[k+1]) ++k;
            ans -= pw[k-j+1] - 1;
            if(ans < 0) ans += Mod;
            j = k;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A + B == 15) {
		cout << "+" << endl;
	} else if (A * B == 15) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}
}


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

int main(){
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;

  vector<int> v(n);
  rep(i,n) cin >> v[i];

  double dt;
  int idx = 0;
  double min = INT_MAX;
  rep(i,n){
    dt = abs(a - (t - (v[i] * 0.006)));
    if (min > dt){
      min = dt;
      idx = i;
    }
  }

  cout << idx + 1 << endl;
  return 0;
}

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

using namespace std;

int sum[101];
int res;
int a[3][101];
int n, ans;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= 2; i++)
		for(int j = 1; j <= n; j++) {
			scanf("%d", &a[i][j]);
			if(i == 1) sum[j] = sum[j - 1] + a[i][j];
		}
	for(int i = n; i >= 1; i--)
		res += a[2][i], ans = max(ans, res + sum[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int lower_bound(int a[],int n,int k){
	int left=-1; int right=n;
	while(right-left>1){
		int mid=(left+right)/2;
		if(a[mid]<k) left=mid;
		else right=mid;
	}
	return right;
}
typedef struct{
	int x,y;
}Pos;
int comp1(const void *a,const void *b){ //昇順
	Pos p=*(Pos*)a,q=*(Pos*)b;
	return p.x-q.x;
}
int comp2(const void *a,const void *b){ //降順
	Pos p=*(Pos*)a,q=*(Pos*)b;
	return q.x-p.x;
}
Pos pos[200000];
int ary[200000];
int dp[200000];
int main(void)
{
	int n,size=0,X,Y,id,num,i;
	int min_x,max_x,min_y,max_y,dx,dy;
	double d1=5*M_PI-20,d2=10*M_PI-20;
	Pos s,g;
	
	scanf("%d%d%d%d",&s.x,&s.y,&g.x,&g.y);
	min_x=MIN(s.x,g.x); max_x=MAX(s.x,g.x);
	min_y=MIN(s.y,g.y); max_y=MAX(s.y,g.y);
	dx=max_x-min_x; dy=max_y-min_y;
	if(s.y>g.y) swap(Pos,s,g);
	
	scanf("%d",&n);
	FOR(i,0,n){
		scanf("%d%d",&X,&Y);
		if(X<min_x||X>max_x||Y<min_y||Y>max_y) continue;
		pos[size].x=X; pos[size++].y=Y;
	}
	
	if(s.x<=g.x) qsort(pos,size,sizeof(Pos),comp1);
	else qsort(pos,size,sizeof(Pos),comp2);
	//FOR(i,0,size) printf("%d %d\n",pos[i].x,pos[i].y);
	
	FOR(i,0,size){
		ary[i]=pos[i].y;
		dp[i]=INF;
	}
	FOR(i,0,size){
		id=lower_bound(dp,size,ary[i]);
		dp[id]=ary[i];
	}
	
	num=lower_bound(dp,size,INF);
	if(num==MIN(dx,dy)+1){
		printf("%.20lf\n",(double)(dx+dy)*100+d1*(num-1)+d2);
	}else{
		printf("%.20lf\n",(double)(dx+dy)*100+d1*num);
	}
	return 0;
}
    

Measured memory_bytes: 3324
// Problem : C - Next Prime
// Contest : AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
bool prime (int n) {
	for (int i = 2; i * i <= n; i++) if (n%i==0) return 0;
	return n != 1;
}
int main () {
	int x;
	scanf ("%d",&x);
	while (!prime(x)) ++x;
	printf ("%d\n",x);
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i64; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut x1 = 0i64;
    let mut sign = 1;
    for i in 0..n {
        x1 += sign * av[i];
        sign *= -1;
    }

    let mut xv = vec![0i64; n];
    xv[0] = x1;
    for i in 0..n - 1 {
        xv[i + 1] = (av[i] - xv[i] / 2) * 2;
    }

    for i in 0..n - 1 {
        print!("{} ", xv[i]);
    }
    println!("{}", xv[n - 1]);
}


Measured memory_bytes: 7420
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
using namespace std;

int main(){

    double a,b,c,d,e,f,y,x,bb,cc,dd,ee,ff;
    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
        y=(c*d-a*f)/(b*d-a*e);
        x=(c-b*y)/a;
        x+=0.0004;
        y+=0.0004;
        printf("%.3lf %.3lf\n",x,y);
    
        /*
        y=round(1000*y);
        y=(int)y;
        y=y/1000+0.0;
        
        x=round(1000*x);
        x=(int)x;
        x=x/1000+0.0;
        cout<<fixed<<setprecision( 3 )<<x<<" "<<y<<endl;*/
        //printf("%f %f\n",x,y);
    }
    return 0;
}

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


void solve() {
  map<int, int> mp;
  int x;
  for(int i = 0; i < 3; i++) {
    cin >> x;
    mp[x]++;
  }
  cout << mp.size();
}

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


Measured memory_bytes: 256
N,K = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp.split("")

si = "9"
indexs = []
j = 0

(0..N-1).each do |i|
  if si != S[i]
    si = S[i]
    indexs[j] = i
    j += 1
  end
end

i = 0
sum = 0
maxsum = 0

if S[0] == "0"
  if indexs[K*2].nil? then
    maxsum = N
  else
    maxsum = indexs[K*2]
  end
  i += 1
end

while i < indexs.count
  if indexs[i+(K*2)+1].nil? then
    sum = N - indexs[i]
  else
    sum = indexs[i+(K*2)+1] - indexs[i]
  end

  if maxsum < sum
    maxsum = sum
  elsif sum == 0
    break
  end

  i += 2
end

puts maxsum

Measured memory_bytes: 7876
#include <stdio.h>
#define LIM 1000000000
#define MAX 100

int n,a[MAX][MAX];

int prim(void);

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

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&e);
      if(e == -1) a[i][j] = LIM;
      else a[i][j] = e;
    }
  }

  printf("%d\n",prim());

  return 0;
}

int prim(){
  int s,small,sum = 0;
  int pa[MAX],min[MAX],judge[MAX];
  int i,j;

  for(i = 0; i < n; i++){
    min[i] = LIM;
    pa[i] = -1;
    judge[i] = 0;
  }

  min[0] = 0;

  for(;;){

    small = LIM;
    s = -1;

    for(i = 0; i < n; i++){
      if(small > min[i] && judge[i] != 2){
	s = i;
	small = min[i];
      }
    }

    if( s == -1) break;

    judge[s] = 2;

    for( j = 0; j < n; j++){
      if(judge[j] != 2 && a[s][j] != LIM){
	if(min[j] > a[s][j]){
	  min[j] = a[s][j];
	  pa[j] = s;
	  judge[j] = 1;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    if(pa[i] != -1) sum += a[i][pa[i]];
  }

  return sum;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005, MOD = 1e9 + 7;
int n, arr[MAXN], vis[MAXN], cir[MAXN], inc[MAXN];
int dep[MAXN], cnt[MAXN];
LL fac[MAXN], inv[MAXN];
vector<int> gra[MAXN];

LL modpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
	}
	return res;
}

int dfs(int u) {
	int cnt = 0, d = 0;
	for (int v : gra[u]) {
		if (inc[v]) continue;
		if (cnt++) {
			puts("0");
			exit(0);
		}
		d = dfs(v) + 1;
	}
	return d;
}

int main() {
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		scanf("%d", arr + i);
		gra[arr[i]].push_back(i);
		fac[i] = fac[i - 1] * i % MOD;
	}
	inv[n] = modpow(fac[n], MOD - 2);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % MOD;
	
	LL ans = 1;
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		int j = i, tot = 0;
		for (; !vis[j]; j = arr[j]) vis[j] = i;
		if (vis[j] != i) continue;
		for (int k = arr[j]; k != j; k = arr[k])
			cir[tot++] = k, inc[k] = 1;
		cir[tot++] = j, inc[j] = 1;
		memset(dep, 0, sizeof(int) * tot);
		bool flag = false;
		for (int k = 0; k < tot; k++) {
			int t = cir[k];
			if (gra[t].size() == 1) continue;
			dep[k] = dfs(t);
			flag = true;
		}
		if (flag) {
			for (int k = 0; k < tot; k++) if (dep[k]) {
				int nxt = 0;
				for (int j = (k - 1 + tot) % tot;; j = (j - 1 + tot) % tot) {
					if (dep[j]) break;
					++nxt;
				}
				if (nxt < dep[k] - 1) {
					puts("0");
					return 0;
				}
				if (nxt >= dep[k]) ans = ans * 2 % MOD;
			}
		} else ++cnt[tot];
	}
	for (int i = 1; i <= n; i++) if (cnt[i]) {
		LL pw = 1, t = (LL)i * (MOD + 1) / 2 % MOD, sum = 0;
		if (i & 1 && i > 1) pw = modpow(2, cnt[i]), t = (LL)i * (MOD + 1) / 8 % MOD;
		for (int j = 0; 2 * j <= cnt[i]; j++) {
			sum = (sum + pw * inv[cnt[i] - 2 * j] % MOD * inv[j]) % MOD;
			pw = pw * t % MOD;
		}
		ans = ans * sum % MOD * fac[cnt[i]] % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int s, sum;

int main(){
	REP(i, 10){
		cin >> s;
		sum += s;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1160
import sys

N = int(input())

steps = []
for i in range(N):
    t, x, y = map(int, input().split())
    steps.append([t, x, y])

prev = [0, 0, 0]
for step in steps:
    t, x, y = step
    diff = abs(x - prev[1]) + abs(y - prev[2])
    time = t - prev[0]
    if diff > time or (time - diff) % 2 > 0:
        print('No')
        sys.exit()
    prev = [t, x, y]

print('Yes')

Measured memory_bytes: 19572
import sys
bbn=1000000007
	
#+++++
		
def main():
	h, w = map(int, input().split())
	n = int(input())
	al = list(map(int, input().split()))
	
	al_i=0
	rr=[]
	for hi in range(h):
		ww=[-1]*w
		for wj in range(w):
			ww[wj] = al_i+1
			al[al_i] -= 1
			if al[al_i]==0:
				al_i+=1
		rr.append(ww)
		
	for i, r in enumerate(rr):
		b = r[:] if i % 2 == 0 else r[::-1]
		print(' '.join([str(v) for v in b]))
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 39792
#include "bits/stdc++.h"
using namespace std;
void insertsort(vector<int> &A,int n, int g, int &cnt){
    int j,k,v;
    for(j=g;j<n;j++){
        v=A.at(j);
        k = j - g;
        while(k>=0 && A.at(k) > v){
            A.at(k+g) = A.at(k);
            k -= g;
            cnt++;
        }
        A.at(k+g) = v;
    }
}
int main(){
    int n,i,m,g,cnt;
    m=0;
    cnt = 0;
    cin >> n;
    vector<int> A(n);
    for(i=0;i<n;i++) cin >> A.at(i);//read A
    g=1;
    while(g<=n){
        m++;
        g = 3*g+1;
    }
    cout << m << endl;
    for(i=0;i<m;i++){
        g /= 3;
        if(i) cout << " ";
        cout << g;
        insertsort(A,n,g,cnt);
    }
    cout << endl << cnt << endl;
    for(i=0;i<n;i++) cout << A.at(i) << endl;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin>>N;
    int A[N];
    rep(i, 0, N) {
        cin>>A[i];
    }
    sort(&A[0], &A[N]);
    int old=0;
    while (old!=A[0]) {
        old=A[0];
        rep(i, 1, N) {
            int tmp=A[i]%A[0];
            if (tmp) {
                A[i]=tmp;
            }
        }
        sort(&A[0], &A[N]);
    }
    cout<<A[0]<<endl;
}
int main()
{
    func();
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  string S;
  cin >> S;

  ll ans = 1000;
  for (int i = 0; i + 2 < S.size(); i++) {
    ll temp = 0;
    temp += (S[i + 0] - '0') * 100;
    temp += (S[i + 1] - '0') * 10;
    temp += (S[i + 2] - '0') * 1;
    ans = min(ans, abs(temp - 753));
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
def setFact(n, mod):
    global fact
    global ifact
    fact = [0]*(n+1)
    fact[0] = 1
    ifact = [0] * (n+1)
    for i in range(1, n+1):
        fact[i] = (fact[i-1]*i)%mod
    ifact[n] = pow(fact[n], mod-2, mod)
    for i in range(1, n+1):
        ifact[n-i] = ifact[n-i+1]*(n-i+1)%mod
def combination(n, k, mod):
    global fact
    global ifact
    if k < 0 or k > n:
        return 0
    else:
        return fact[n]*ifact[n-k]*ifact[k]%mod
k = int(input())
s = input()
n = len(s)
mod = 10**9 + 7
ans = 0
setFact(n+k, mod)
for i in range(k+1):
    now = 1
    now *= pow(26, i, mod)
    now %= mod
    now *= pow(25, k-i, mod)
    now %= mod
    now *= combination(k-i+n-1,n-1 , mod)
    now %= mod
    ans += now
    ans %= mod
print(ans)

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

typedef long long ll;
const int MN = 610, mod = 1e9+7;

typedef unsigned long long HASH_T;
char cad[1000];
HASH_T S[MN][MN];
HASH_T HH[MN][MN],
          HV[MN][MN], primo = 31;
int N;

HASH_T pot[MN];

HASH_T getHashH(int i, int j){
    HASH_T tmp = HH[i][j+N-1] - pot[N]*HH[i][j-1];
    return tmp;
}

HASH_T getHashV(int i, int j){
    HASH_T tmp = HV[i+N-1][j] - pot[N]*HV[i-1][j];
    return tmp;
}

bool isSimmetric(int x, int y){
    for (int i=0; i < N; i++)
        if (getHashH(i+x,y) != getHashV(x,i+y))
            return false;
    return true;
}

int main()
{
    #ifdef ACMTUYO
    //cout << "In ACM\n";
    freopen("a.in","r",stdin);
    #else
    cin.tie(0); ios_base::sync_with_stdio(0);
    #endif // ACMTUYO

    pot[0] = 1;
    for (int i=1; i < MN; i++)
        pot[i] = primo*pot[i-1];

    cin >> N;

    for (int i=1; i<=N; i++){
        cin >> cad;
        for (int j=1; j <= N; j++){
            S[i][j] = cad[j-1]-'a'+1;
            S[i+N][j] = S[i][j];
            S[i][j+N] = S[i][j];
            S[i+N][j+N] = S[i][j];
        }
    }

    for (int i=1; i<=2*N; i++){
        for (int j=1; j <= 2*N; j++){
            HH[i][j] = primo*HH[i][j-1] + S[i][j];
            HV[i][j] = primo*HV[i-1][j] + S[i][j];
        }
    }

    int cont=0;
    for (int i=1; i <= N; i++){
        for (int j=1; j <= N; j++){
            if (isSimmetric(i,j)){
                cont++;
            }
        }
    }

    cout << cont << "\n";

    return 0;
}


Measured memory_bytes: 8960
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s, t;cin>>s>>t;
  cout<<(s==t.substr(0, t.size()-1)?"Yes":"No")<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

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

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

  string s;
  cin >> s;

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

  map<int, int> amari;
  amari[0]++;

  ll now = 0;
  ll base = 1;

  int n;
  n = s.length();
  rep(i, n){

    now = (int(s[i]-'0') * base + now) % 2019;

    amari[now]++;

    base = (base * 10) % 2019;

  }

  ll ans = 0;
  for(auto p : amari){

    ll cnt = p.second;
    ans += cnt * (cnt-1)/2;

  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;

  bool flag = true;
  for (int i = 0; i < a; i++) {
    if ('0' <= s[i] && s[i] <= '9') {
    }
    else {
      flag = false;
      break;
    }
  }

  if (s[a] != '-') {
    flag = false;
  }

  for (int i = 0; i < b; i++) {
    if ('0' <= s[i+a+1] && s[i+a+1] <= '9') {
    }
    else {
      flag = false;
      break;
    }
  }


if (flag)
  cout << "Yes" << endl;
else
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	int a,b;
	while(~scanf("%d %d",&a,&b))
	{
		int c =a+b;
		if(c%2==0)
		{
			printf("%d\n",c/2);
		}
		else
		{
			printf("%d\n",(c+1)/2);
		}
	}
	return 0;
}

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

void print(int A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i!=0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insertionSort(int A[], int N) {
	int v, j;
	for (int i = 1; i < N; i++) {
		print(A, N);
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}
}


int main() {
	int N;
	cin >> N;
	int A[100];
	for (int i = 0; i < N; i++) cin >> A[i];

	insertionSort(A, N);
	print(A, N);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

int N, a,b;
int main(){
    scanf("%d%d%d", &N, &a,&b);
    
    printf("%d",N*a/2);

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    cout << (n+1)/2 << "\n";
    return 0;
}

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

using namespace std;

int main() {
    long n, s;
    cin >> n >> s;
    if (s >= n) {
        cout << (s==n ? n + 1 : -1) << '\n';
        return 0;
    }
    long r = sqrt(n);
    for (long b=2; b<=r; b++) {
        long f = 0;
        for (long _n=n; _n>0; _n/=b) f += _n % b;
        if (f == s) {
            cout << b << '\n';
            return 0;
        }
    }
    long d1 = min(n/(r+1), s);
    for ( ; d1>0; d1--) {
        long d0 = s - d1;
        if ((n - d0) % d1 == 0 && (n - d0) / d1 > d1 && (n - d0) / d1 > d0) {
            cout << (n - d0) / d1 << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    vector<long long int> dp(5,0);
    long long int N;
    cin>>N;
    long long int m;
    vector<long long int> person(5,0);
    cin>>m;
    person[0]=m;
    for(int i=1;i<5;i++){
        cin>>person[i];
        m=min(person[i],m);
    }
    long long int ans=N/m + 5;
    if(N%m==0) ans--;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
s = input()

if s =='SUN':
    print(7)
elif s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
elif s == 'MON':
    print(6)

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

class dice{	
public:
	int d[7];
	int set();
	int E();
	int W();
	int N();
	int S();
	int R();//?°´???????????¢
	int C(int *,int *,int *,int *);//??\??????????????????
};
int dice::set(){
	for(int i=1;i<=6;i++){
		cin>>d[i];
	}
	return 0;
}
int dice::C(int *w,int *x,int *y,int *z){
	int a[4];
	a[0]=*w;
	a[1]=*x;
	a[2]=*y;
	a[3]=*z;
	*w=a[3];
	*x=a[0];
	*y=a[1];
	*z=a[2];
	return 0;
}
int dice::E(){
	C(&d[1],&d[3],&d[6],&d[4]);
	return 0;
}
int dice::W(){
	C(&d[1],&d[4],&d[6],&d[3]);
	return 0;
}
int dice::N(){
	C(&d[1],&d[5],&d[6],&d[2]);
	return 0;
}
int dice::S(){
	C(&d[1],&d[2],&d[6],&d[5]);
	return 0;
}
int dice::R(){
	C(&d[2],&d[4],&d[5],&d[3]);
	return 0;
}
int main(){
	dice D;
	D.set();
	int n,s,t;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		for(int j=0;j<4;j++){
			D.E();
			if(D.d[1]==s)break;
		};
		for(int j=0;j<4;j++){
			D.N();
			if(D.d[1]==s)break;
		}
		while(1){
			D.R();
			if(D.d[2]==t)break;
		}
		cout<<D.d[3]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <functional>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

using ll = long long;
int edges[4][4];

int main()
{
  for (int i = 0; i < 3; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    edges[a][b] = 1;
    edges[b][a] = 1;
  }
  bool success = false;
  for (int i = 0; i < 4; i++) {
    int visits[4][4];
    for (int m = 0; m < 4; m++) for (int n = 0; n < 4; n++) visits[m][n]=edges[m][n];
    for (int j = 0; j < 4; j++) {
      if (visits[i][j] != 1) continue;
      visits[min(i,j)][max(i,j)]++;
      for (int k = 0; k < 4; k++) {
        if (visits[min(j,k)][max(j, k)] != 1) continue;
        visits[min(j,k)][max(j,k)]++;
        for (int l = 0; l < 4; l++) {
          if (visits[min(k,l)][max(k,l)] != 1) continue;
          success = true;
          goto endlabel;
        }
      }
    }
  nextlabel:
    continue;
  }
 endlabel:
  if (success) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
from collections import deque
h,w=map(int,input().split())
l=[["#" for i in range(w+2)]]
for i in range(h):
  l1=list(input())
  l1=["#"]+l1+["#"]
  l.append(l1)
l2=["#" for i in range(w+2)]
l.append(l2)
q=deque([[1,1]])
inf=1000000000
d=[[inf for i in range(w+2)] for j in range(h+2)]
d[1][1]=0
move=[[1,0],[-1,0],[0,1],[0,-1]]
while q:
  a=q.popleft()
  n1=a[0]
  n2=a[1]
  for i in move:
    m1=i[0]
    m2=i[1]
    if l[n1+m1][n2+m2]!="#":
      if d[n1+m1][n2+m2]>d[n1][n2]+1:
        d[n1+m1][n2+m2]=d[n1][n2]+1
        q.append([n1+m1,n2+m2])
dis=d[h][w]
count=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=="#":
      count+=1
if dis==inf:
  print(-1)
else:
  print(h*w-dis-1-count)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N;
    cin>>N;
    int a=0;;
    map<string, int> mp;
    string s;
    rep(i, N){
        cin>>s;
        mp[s]++;
        a=max(a, mp[s]);
    }
    for(const auto&p : mp){
        if(p.second==a){
            cout<<p.first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;

const static int MAX = 100;

struct Card
{
    char suit;
    int value;
};

bool isStble(struct Card C1[], struct Card C2[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if ((C1[i].suit != C2[i].suit) || (C1[i].value != C2[i].value))
        {
            return false;
        }
    }
    return true;
}

void print(struct Card A[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        printf("%c%d ", A[i].suit, A[i].value);
    }
    printf("%c%d ", A[n - 1].suit, A[n - 1].value);
}

void bubbleSort(Card A[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        int j = n - 1;
        for (; j > i; j--)
        {
            if (A[j].value < A[j - 1].value)
            {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void selectionSort(Card A[], int n)
{
    for (int i = 0; i < n; i++)
    {
        int min = i;
        for (int j = i + 1; j < n; j++)
        {
            if (A[j].value < A[min].value)
            {
                min = j;
            }
        }
        swap(A[min], A[i]);
    }
}

int main()
{
    Card C1[MAX] = {{0, '\0'}};
    Card C2[MAX];
    int n;
    char ch;
    scanf("%d", &n);
    getchar();
    for (int i = 0; i < n; i++)
    {
        if (i != n - 1)
        {
            scanf("%c%d ", &C1[i].suit, &C1[i].value);
            C2[i].suit = C1[i].suit;
            C2[i].value = C2[i].value;
        }
        else
        {
            scanf("%c%d", &C1[i].suit, &C1[i].value);
            C2[i].suit = C1[i].suit;
            C2[i].value = C2[i].value;
            getchar();
        }
    }
    for (int i = 0; i < n; i++)
    {
        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }

    bubbleSort(C1, n);
    selectionSort(C2, n);

    for (int i = 0; i < n - 1; i++)
    {
        printf("%c%d ", C1[i].suit, C1[i].value);
    }
    printf("%c%d\nStable\n", C1[n - 1].suit, C1[n - 1].value);
    for (int i = 0; i < n - 1; i++)
    {
        printf("%c%d ", C2[i].suit, C2[i].value);
    }
    printf("%c%d\n", C2[n - 1].suit, C2[n - 1].value);
    if (isStble(C1, C2, n))
    {
        printf("Stable\n");
    }
    else
    {
        printf("Not stable\n");
    }
    return 0;
}


Measured memory_bytes: 3220
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:String, b:String};

    let n:i32 = format!("{}{}", a,b).parse().unwrap();
    //debug!(n);

    for i in 0..(n as f64).sqrt() as i32 +1 {
        if i*i == n {
            println!("Yes");
            return ();
        }
    }
    println!("No");

}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, k;
  cin >> n >> k;

  int num = 1;
  rep(i, n) {
    num = min(num * 2, num + k);
  }

  cout << num << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100000
#define MOD (1.0e9 + 7)

using namespace std;

int zero;
int a[N+10];

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

    for(int i = 0;i < n;i++)
    {
	int temp;
	cin>>temp;

	a[temp]++;
	a[temp+1]++;
	if(temp == 0)
	    zero++;
	else
	    a[temp-1]++;
    }

    int max = zero;
    for(int i = 0;i <= N;i++)
	max = max > a[i] ? max : a[i];

    cout<<max<<endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

ll dp[60][60][2510]; //i番目まででj個使ってkを作れる総数

int main()
{
    int n,a;
    cin >> n >> a;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < 2510; k++){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k]; //使わない場合
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]; //使う場合
            }
        }
    }

    ll ans = 0;
    for(int j = 1; j <= n; j++) ans += dp[n][j][j*a];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 59648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll dp[101][100001];

struct Item
{
    ll weight;
    ll value;
};


int main(){

    ll N, W;
    cin >> N >> W;

    vector<Item> item(N+1);
    for(int i = 1; i <= N; i++){
        cin >> item[i].weight >> item[i].value;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            if( j - item[i].weight >= 0 ){
                dp[i][j] = max(dp[i-1][j], dp[i-1][ j - item[i].weight ] + item[i].value );
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    ll ans = 0;
    for(int j = 0; j <= W; j++){
        ans = max(ans, dp[N][j]);
    }

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
         //   cout <<setprecision(2) << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << ans << endl;


}

Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>

int ddd(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main () 
{
int n,i,j;
int a[200010];

scanf("%d",&n);


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

qsort(a, n, sizeof(int), ddd);

for(i=0;i<n;i++)
{
    if(a[i]==a[i+1])
    {
        printf("NO");
        return 0;
    }
}

printf("YES");
return 0;
}


Measured memory_bytes: 1788
H,W = map(int,input().split())
a = []
a.append(["#"] * (W+2))
for i in range(H):
       a.append(list("#" + str(input() + "#")))
a.append(["#"] * (W+2))
for j in range(len(a)):
        print("".join(a[j]))

Measured memory_bytes: 3060
def resolve():
    from scipy.sparse.csgraph import floyd_warshall
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m, l = map(int, input().split())
    inf = 10 ** 20
    ar = [[0] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        ar[a - 1][b - 1] = c
    x = floyd_warshall(ar, directed=False)
    br = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if x[i, j] <= l:
                br[i][j] = 1
    y = floyd_warshall(br, directed=False)
    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        print(int(y[s - 1, t - 1]) - 1 if y[s - 1, t - 1] < inf else -1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 18896
l=input()
n=len(l)
s=list(l)
i=0
ans=0
p=0
while i<n-2:
    if s[i]=="A":
        p+=1
    else:
        p=0
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        ans+=p
        i+=2
        s[i]="A"
        p-=1
    else:
        i+=1
print(ans)
        

Measured memory_bytes: 4840