akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool a[10000][10000];
long long  f[10000][10000];
long long  sum = 0, sum3=10000000;
bool sum2 = false;
void solve(int i, int j,int mi,int mj,int h,int w) {
	if (i == mi&&j == mj&&sum3>f[i][j]) {
		sum3 = f[i][j];
		sum2 = true;
		return;
	}
	if (a[i][j + 1] && f[i][j] + 1 < f[i][j + 1] && j + 1 < w) {
		f[i][j + 1] = f[i][j] + 1;
		solve(i, j + 1, mi, mj, h, w);
	}
	if (a[i][j - 1] && f[i][j] + 1 < f[i][j - 1] && j - 1 >= 0) {
		f[i][j - 1] = f[i][j] + 1;
		solve(i, j - 1, mi, mj, h, w);
	}
	if (a[i + 1][j] && f[i][j] + 1 < f[i + 1][j] && i + 1 < h) {
		f[i + 1][j] = f[i][j] + 1;
		solve(i + 1, j, mi, mj, h, w);
	}
	if (a[i - 1][j] && f[i][j] + 1 < f[i - 1][j] && i - 1 >= 0) {
		f[i - 1][j] = f[i][j] + 1;
		solve(i - 1, j, mi, mj, h, w);
	}
}
int main() {
	long long  h, w, n;
	cin >> h >> w >> n;
	long long  b[100][2], c;
	string d;
	for (int i = 0; i < h; i++) {
		cin >> d;
		for (int j = 0; j < w; j++) {
			if (d[j] == 'X')
				a[i][j] = false;
			else
				a[i][j] = true;
			if (d[j] >= '1'&&d[j] <= '9') {
				int e = (int)d[j] - '0';
				b[e][0] = i;
				b[e][1] = j;
			}
			if (d[j] == 'S') {
				b[0][0] = i;
				b[0][1] = j;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < h; j++)
			fill(f[j], f[j] + w, 1000001);
		sum2 = false;
		f[b[i][0]][b[i][1]] = 0;
		solve(b[i][0], b[i][1], b[i + 1][0], b[i + 1][1], h, w);
		sum += f[b[i + 1][0]][b[i + 1][1]];
	}
	cout << sum << endl;
}

Measured memory_bytes: 31776
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if (p[i] > p[i - 1] and p[i] < p[i + 1]) or (p[i] < p[i - 1] and p[i] > p[i + 1]):
        count += 1
print(count)


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n;
string s[N];
map<string, int>mp;
int main()
{
	cin >> n;
	int ma = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> s[i];
		mp[s[i]]++;
		ma = max(ma ,mp[s[i]]);
	}
	for (auto it = mp.begin(); it != mp.end(); it++)
	{
		if (it->second == ma)
		cout << it->first << endl;
	}
}

Measured memory_bytes: 26752
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	vector<string>a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++) cout<<a[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string s;
    
    cin>>s;
    
    if(s[5]=='0'){
        if(s[6]<='4'){
            cout<<"Heisei"<<endl;
        }else{
            cout<<"TBD"<<endl;
        }
    }else{
        cout<<"TBD"<<endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin>>N;
    int i;
    string ans;
    while(N>0){
        ll num = (N-1)%26;
        char c = 'a' + num;
        ans = c + ans;
        N = (N-1)/26;
    }
    cout<<ans<<endl;
    return 0;
}
    

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll A = a - 1;
  A /= x;
  ll B = b / x;
  if (a == 0) A = -1;
  printf("%lld\n", B-A);
}

Measured memory_bytes: 256
N=int(input())
p=input().split()
P=[int(a) for a in p]
answer=0
for a in range(N):
    if P[a]==a+1:
        answer+=1
        if a+1<N:
            if P[a + 1] == a + 2:
                P[a + 1] = 0
print(answer)


Measured memory_bytes: 13880
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int i = 1;
    while(true) {
      int n = in.nextInt();
      if (n == 0) break;
      System.out.println("Case " + i + ": " + n);
      i++;
    }
  }
}

Measured memory_bytes: 42436
n = int(input())
xy = []
for _ in range(n):
    xy.append([])
    a = int(input())
    for _ in range(a):
        xy[-1].append([int(i) for i in input().split()])
        xy[-1][-1][0]-=1

ma = 0

for i in range(2 ** n):
    ok = True
    a = 0
    for j in range(n):
        if (2 ** j) & i != 0:
            a += 1
            for k in xy[j]:
                if (1 if (2 ** k[0]) & i != 0 else 0) != k[1]:
                    ok = False
    if ok:
        ma = max(ma, a)
print(ma)


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

int main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    int ans=0;

    for(int i=0; i<n; i++){
        if(a.at(i)==ans+1) ans++; 
    }
    ans=n-ans;
    if(ans==n) ans=-1;

    cout << ans << endl;
}

Measured memory_bytes: 4040
n = input()
a = input()
tmp_a = a.split()
a_list = []
o_list = []
flag = 0

for i in range(int(n)):
    if int(tmp_a[i]) < 400:
        a_list.append("gray")
    elif 400 <= int(tmp_a[i]) and int(tmp_a[i]) < 800:
        a_list.append("brown")
    elif 800 <= int(tmp_a[i]) and int(tmp_a[i]) < 1200:
        a_list.append("green")
    elif 1200 <= int(tmp_a[i]) and int(tmp_a[i]) < 1600:
        a_list.append("sky")
    elif 1600 <= int(tmp_a[i]) and int(tmp_a[i]) < 2000:
        a_list.append("blue")
    elif 2000 <= int(tmp_a[i]) and int(tmp_a[i]) < 2400:
        a_list.append("yellow")
    elif 2400 <= int(tmp_a[i]) and int(tmp_a[i]) < 2800:
        a_list.append("orange")
    elif 2800 <= int(tmp_a[i]) and int(tmp_a[i]) < 3200:
        a_list.append("red")
    else:
        o_list.append("other")

n_other = len(o_list)

if len(set(a_list))==0:
    min_num = 1
else:
    min_num = len(set(a_list))

max_num = len(set(a_list))+n_other
#if max_num > 8:
#    max_num = 8

print(min_num, max_num)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;
int N=1000000001, p[100005],w[100005], rk[100005],was[100005];
pair<int,int> val[100005];
vector<int> v;

int root(int a){
    return p[a]==a ? a:root(p[a]);
}
void unite(int a, int b){
    a=root(a); b=root(b);
    if(a==b) return;
    if(rk[a]<rk[b]) p[a]=b;
    else{
        p[b]=a;
        if(rk[a]==rk[b]) rk[a]++;
    }
}
int main() {
    // insert code here...
    memset(val,0,sizeof(val));
    memset(was,0,sizeof(was));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        p[i]=i;
    }
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        unite(x,y);
    }
    for(int i=0;i<n;i++){
        val[i]=make_pair(N,N);
    }
    for(int i=0;i<n;i++){
        val[root(i)]=min(val[root(i)],make_pair(w[i],i));
        //cout<<val[1]<<endl;
    }
    //cout<<val[1].first<<endl;
    long long sum=0;
    int counter=0;
    for(int i=0;i<n;i++){
        if(root(i)==i) {
            counter++;
            sum+=val[i].first;
            //cout<<sum<<endl;
            was[val[i].second]=1;
        }
    }
    if((counter-1)*2>n) {
        cout<<"Impossible"<<endl;
        return 0;
    }
    if(counter==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(!was[i])  v.push_back(w[i]);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<counter-2;i++){
        sum+=v[i];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;
vector<int> S[MAX];
int N,ord[MAX],low[MAX],visit[MAX],par[MAX],timer;

void DFS(int cur,int mae){
    
    ord[cur]=low[cur]=timer;
    par[cur]=mae;
    visit[cur]=1;
    timer++;
    
    for(int i=0;i<S[cur].size();i++){
        int a=S[cur][i];
        if(a==mae) continue;
        if(visit[a]){
            low[cur]=min(low[cur],ord[a]);
            continue;
        }
        DFS(a,cur);
        low[cur]=min(low[cur],low[a]);
    }
}

void search(int u){//u==0なら関節点、1なら橋
    for(int i=0;i<N;i++){
        visit[i]=0;
        par[i]=-1;
    }
    timer=1;
    
    DFS(0,-1);
    
    if(u==0){
        set<int> se;
        int cnt=0;
        for(int i=1;i<N;i++){
            if(par[i]==0) cnt++;
            else if(ord[par[i]]<=low[i]) se.insert(par[i]);
        }
        if(cnt>1) se.insert(0);
        
        for(auto it=se.begin();it!=se.end();it++){
            cout<<*it<<endl;
        }
    }else{
        set<pair<int,int>> se;
        for(int i=0;i<N;i++){
            for(int j=0;j<S[i].size();j++){
                int x=S[i][j];
                if(ord[i]<low[x]){
                    int a=i,b=x;
                    if(a>b) swap(a,b);
                    se.insert(make_pair(a,b));
                }
            }
        }
        
        for(auto it=se.begin();it!=se.end();it++){
            cout<<(*it).first<<" "<<(*it).second<<endl;
        }
    }
}

int main(){

    int M;cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    
    search(1);
}




Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<vvi> vvvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main() {
  ll N,M; cin>>N>>M;
  cout<<(M*1900+(N-M)*100)*(1ll<<M)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main () {
    vector<int> x;
    int N, ans=0;
    cin >> N;
    for (int i=0;i<N;i++){
        int a;
        cin >> a;
        x.push_back(a);
    }
    while (1){
        int cnt=1;
        for (int i=0;i<N;i++){
            if (x[i]){
                cnt=0;
                ans++;
                for (int j=i;j<N;j++){
                    if (x[j])
                        x[j]--;
                    else
                        break;
                }
                break;
            }
        }
        if (cnt)
            break;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
const long mod=1e9+7;
int N;
int P[5050];
long dp[5050];
bool vis[5050];
long Nf[5050];
main()
{
	cin>>N;
	UF uf(N);
	int out=N;
	Nf[0]=1;
	for(int i=0;i<N;i++)
	{
		Nf[i+1]=Nf[i]*(N-1)%mod;
		cin>>P[i];
		if(P[i]>0)
		{
			P[i]--;
			if(!uf.unite(i,P[i]))
			{
				out--;
				vis[i]=true;
			}
		}
	}
	dp[0]=1;
	for(int i=0;i<N;i++)if(vis[i])vis[uf.find(i)]=true;
	int K=0;
	for(int i=0;i<N;i++)if(!vis[uf.find(i)])
	{
		int sz=uf.size(i);
		vis[uf.find(i)]=true;
		for(int j=K;j>=0;j--)
		{
			(dp[j+1]+=dp[j]*sz*(j==0?1:j))%=mod;
		}
		K++;
	}
	long ans=Nf[K]*out%mod;
	for(int i=1;i<=K;i++)
	{
		(ans+=mod-Nf[K-i]*dp[i]%mod)%=mod;
	}
	(ans+=Nf[K-1]*K)%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 3748
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, pair<int, int> > triple;

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

int const max_n = 200000;
int n, k, l;
map<pii, int> c;
int par1[max_n], par2[max_n];
int r1[max_n], r2[max_n];

void init(int n, int (&par)[max_n], int (&r)[max_n]){
    REP(i, n){
        par[i] = i;
        r[i] = 0;
    }
}

int find(int x, int (&par)[max_n]){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = find(par[x], par);
    }
}

void unite(int x, int y, int (&par)[max_n], int (&r)[max_n]){
    x = find(x, par);
    y = find(y, par);

    if(x == y) return;
    if(r[x] < r[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}

bool same(int x, int y, int (&par)[max_n]){
    return find(x, par) == find(y, par);
}

int main(){
    cin >> n >> k >> l;
    init(n, par1, r1);
    REP(i, k){
        int p, q;
        cin >> p >> q;
        unite(p-1, q-1, par1, r1);
    }
    init(n, par2, r2);
    REP(i, l){
        int r, s;
        cin >> r >> s;
        unite(r-1, s-1, par2, r2);
    }

    REP(i, n){
        if(c.find(make_pair(find(i, par1), find(i, par2))) != c.end()){
            c[make_pair(find(i, par1), find(i, par2))] += 1;
        } else {
            c[make_pair(find(i, par1), find(i, par2))] = 1;
        }
    }
    REP(i, n){
        cout << c[make_pair(find(i, par1), find(i, par2))];
        if(i<n-1){
            cout << " ";
        } else {
            cout << endl;
        }
    }
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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 i, j;
    int n, m, r;
    cin >> n >> m >> r;
    VI v(r);
    for (i = 0; i < r; i++) {
        cin >> v[i];
        v[i]--;
    }
    VVI d(n, VI(n, INF));
    for (i = 0; i < m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        chmin(d[a][b], c);
        chmin(d[b][a], c);
    }
    for (int k = 0; k < n; k++) {
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    VVI dis(r, VI(r));
    for (i = 0; i < r; i++) {
        for (j = 0; j < r; j++) {
            dis[i][j] = d[v[i]][v[j]];
            // cout << i << " " << j << " " << dis[i][j] << endl;
        }
    }
    VVI dp(1 << r, VI(r, INF));
    for (i = 0; i < r; i++) {
        dp[(1 << i)][i] = 0;
    }
    for (i = 1; i < (1 << r); i++) {
        for (j = 0; j < r; j++) {
            if ((i >> j) & 1) {
                for (int k = 0; k < r; k++) chmin(dp[i][j], dp[i ^ (1 << j)][k] + dis[k][j]);
            }
        }
    }
    ll ans = INF;
    for (i = 0; i < r; i++) chmin(ans, dp[(1 << r) - 1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 3704
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 998244353LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;
 
 
inline ll ksum(ll n, ll k){
  return k * (2*n - k - 1);
}

pii updtp2(pii p, int nw){
  if(p.first == -1) p.first = nw;
  else if(p.second == -1) p.second = nw;
  else if(p.first >= nw) {
    p.second = p.first;
    p.first = nw;
  }
  else if(p.second >= nw) p.second = nw;
  return p;
}
 
#define isValid(y,x) (y >=0 && y < n && x >= 0 && x < m)

const pii Dir[4] = {{-1,0}, {0,1}, {1,0}, {0,-1}};

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int all = 0;
    REP(i,n) {
        cin >> a[i];
        all ^= a[i];
    }

    REP(i,n){
        cout << (a[i] ^ all) << " ";
    }
    cout << endl;
	return 0;
} 

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,b;
    cin >> n;
    vector<ll> a(100005,0);
    rep(i,n){
        cin >> b;
        a[b+1]++;
    }
    ll ans = 0;
    rep(i,1,100000){
        chmax(ans,a[i-1]+a[i]+a[i+1]);
    }
    PRINT(ans);
}



Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

type Entry struct {
	size  int
	count int
}

type List []Entry

func (l List) Len() int {
	return len(l)
}

func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l List) Less(i, j int) bool {
	return (l[i].size < l[j].size)
}

func main() {
	var n int

	fmt.Scan(&n)
	d := make([]int, n)

	mochi := make(map[int]int, 0)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
		if _, exists := mochi[d[i]]; exists {
			mochi[d[i]]++
		} else {
			mochi[d[i]] = 1
		}
	}

	sortedMochi := List{}
	for k, v := range mochi {
		e := Entry{k, v}
		sortedMochi = append(sortedMochi, e)
	}

	sort.Sort(sortedMochi)

	/*
		for i := 0; i < len(sortedMochi); i++ {
			fmt.Printf("sortedMochi[%d] = %d\n", i, sortedMochi[i])
		}
	*/

	count := 1
	for i := len(sortedMochi) - 1; i > 0; i-- {
		if sortedMochi[i].size > sortedMochi[i-1].size {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 640
import math

A,B,H,M = map(int,input().split())

theta_jisin = 30 * H + 0.5 * M
theta_hunsin = 6 * M

delta_x = A * math.cos(math.radians(theta_jisin)) - B * math.cos(math.radians(theta_hunsin))
delta_y = A * math.sin(math.radians(theta_jisin)) - B * math.sin(math.radians(theta_hunsin))
print(math.sqrt(delta_x*delta_x + delta_y*delta_y))

Measured memory_bytes: 9476
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
 
using namespace std;
 
int main()
{
    int a[5];
    int k;
    rep(i, 5) cin >> a[i];
    cin >> k;
    int flag = 1;
    rep(i, 4){
        for(int j=i+1; j<5; j++){
            if(a[j] - a[i] > k) flag *= 0;
        }
    }
    if(flag == 0) cout << ":(";
    else if (flag == 1) cout << "Yay!";
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int r, c, n;
int x[100010][2], y[100010][2];

int conv(int x, int y) {
	if (x == 0) return y;
	if (y == c) return c + x;
	if (x == r) return c + r + (c - y);
	if (y == 0) return c + r + c + (r - x);
	return -1;
}

int main(void) {
	cin >> r >> c >> n;
	rep(i, n)rep(j, 2) cin >> x[i][j] >> y[i][j];

	using pii = pair<int,int>;
	vector<pii> cover;

	rep(i, n) {
		const int a = conv(x[i][0],y[i][0]);
		const int b = conv(x[i][1],y[i][1]);
		if(a == -1 or b == -1) continue;
		cover.push_back(pii(a,i));
		cover.push_back(pii(b,i));
	}

	sort(begin(cover),end(cover));
	stack<pii> stk;

	const int m = cover.size();
	
	rep(i,m){
		if(!stk.empty() and stk.top().second == cover[i].second)
			stk.pop();
		else
			stk.push(cover[i]);
	}

	if (stk.empty())
		puts("YES");
	else
		puts("NO");

	return 0;
}

Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int ans = inf;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        int now = 0;
        while(v[i]%2==0){
            now++;
            v[i]/=2;
        }
        ans = min(now,ans);    
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int &e : a) cin >> e;
    
    auto query = [&] (long long x) {
        long long ans = 0;
        long long sum = 0;
        for (int l = 0, r = 0; l < n; l++) {
            while (r < n and sum + a[r] <= x) sum += a[r++];
            ans += (r - l);
            sum -= a[l];
        }
        return ans;
    };
    
    for (int i = 0; i < q; i++) {
        long long x;
        cin >> x;
        cout << query(x) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 3140
# -*- coding: utf-8 -*-

n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            counter -= 1
print(counter)


Measured memory_bytes: 9180
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (1000000000+7);
    int ans=0,id;
    int N,M;
    ll A,B,C;
    string O,E;
    ll sum=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    A=1;
    EREP(i,N){
        A*=i;
        A%=MOD;
    }
    A%=MOD;
    cout<<A;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		long n = scn.nextLong();
		long ans = 1000 * (n / 500);
		ans += 5 * ((n % 500) / 5);
		System.out.println(ans);
	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 21076
while True:
  ns = list(map(int, input().split()))
  if not any(ns):
    break
  a = ns[0] + ns[3]
  b = ns[1] + ns[4]
  c = ns[2] + ns[5]
  av, ar = a // 3, a % 3
  bv, br = b // 3, b % 3
  cv, cr = c // 3, c % 3
  if max(ar, br, cr) == 0:
    print(av + bv + cv)
  elif max(ar, br, cr) == 1:
    print(av + bv + cv + min(ar, br, cr))
  elif max(ar, br, cr) == 2:
    if [ar, br, cr].count(2) == 3:
      print(av + bv + cv + 2)
    elif [ar, br, cr].count(2) == 2:
      for xr, xv in ((ar, av), (br, bv), (cr, cv)):
        if xr == 2:
          continue
        if xv == 0:
          print(av + bv + cv + xr)
        else:
          print(av + bv + cv + 1)
        break
    else:
      print(av + bv + cv + min(ar, br, cr))
  


Measured memory_bytes: 5624
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>


using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;


class bit_t
{
	vll m_v;
	int m_n;
public:
	bit_t(int n)
	{
		m_n=n;
		m_v.assign(m_n+1, 0);
	}
	ll sum(int i)
	{
		ll ret=0;
		for(;i;i-=(i&-i)) ret+=m_v[i];
		return ret;
	}
	void add(int i, ll a)
	{
		for(;i<=m_n;i+=(i&-i)) m_v[i]+=a;
	}
	void dump(void)
	{
		printf("----- dump -----\n");
		for(auto ve:m_v) printf("%lld ", ve);
		printf("\n");
	}
};


struct v_t
{
	int i, r;
	ll v;
};


bool v_v_cmp(const struct v_t&lhs, const struct v_t&rhs)
{
	return lhs.v<rhs.v;
}


bool v_i_cmp(const struct v_t&lhs, const struct v_t&rhs)
{
	return lhs.i<rhs.i;
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vi a(n);
		vector<v_t> s(n+1);

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

		sort(s.begin(), s.end(), v_v_cmp);
		s[0].r=0;
		for(int i=1;i<=n;i++)
		{
			if(s[i].v!=s[i-1].v) s[i].r=i;
			else s[i].r=s[i-1].r;
		}
		sort(s.begin(), s.end(), v_i_cmp);
/*
printf("----- s -----\n");
for(auto se:s) printf("%d ", se.r);
printf("\n");
*/
		ll ans=0;
		bit_t b(s.size()+1);
		for(int i=0;i<=n;i++)
		{
			ans+=b.sum(s[i].r+1);
			b.add(s[i].r+1, 1);
//			b.dump();
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 5760
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int a, b;
    cin >> a >> b;

    cout << max({a + b, a - b, a * b}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll INF = 1e18 + 10;
const double EPS = 1e-9;

/*
typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}
*/

int P, Q, A, N;

int Solve(int p, int q, int a, int n, int num) {
  if (P * q < Q * p) {
    return 0;
  }
  if (n > N) {
    return 0;
  }
  if (a > A) {
    return 0;
  }
  if (P * q == Q * p) {
    return 1;
  }
  

  int ret = 0;
  for (int i = num; q * i <= A; i++) {
    ret += Solve(i * p + q, q * i, a * i, n + 1, i);
  }

  return ret;
}


int main() {
  while (true) {
    cin >> P >> Q >> A >> N;
    if (P + Q + A + N == 0) {
      break;
    }

    int ans = Solve(0, 1, 1, 0, 1);

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

Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
	/*#ifndef ONLINE_JUDGE
        freopen("/home/shubham/Desktop/Programming-CP/input.txt", "r", stdin);
        freopen("/home/shubham/Desktop/Programming-CP/output.txt", "w", stdout);
    #endif*/
	ll a,b,k,resa = 0, resb = 0;
	cin>>a>>b>>k;
	if(a>0){
		if(a>k){
			resa = a-k;
			k = 0;
		}
		else{
			resa = 0;
			k = k - a;
		}
	}
	else{
		resa = 0;
	}
	if(b>0 && k>=0){
		if(b>k){
			resb = b - k;
		}
		else{
			resb = 0;
		}
	}
	else{
		resb = 0;
	}
	cout<<resa<<" "<<resb<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){


*/
signed main(){
  string a;
  cin>>a;
  fo(i,a.size()){
    cout<<'x';
  }
  cout<<endl;
}

Measured memory_bytes: 256
def main():
    A,V = map(int, input().split())
    B,W = map(int, input().split())
    T = int(input())
    #print(A,V,B,W,T)

    if( (V-W)*T - abs(B - A) >= 0 ):
        return print('YES')
    else:
        return print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
import sys
from collections import defaultdict
n, limit = map(int, sys.stdin.readline().split())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]

dp =[defaultdict(int) for _ in range(n)]
dp[0][L[0][1]] = L[0][0]
#print(dp)
for i in range(1, n):
    dp[i][L[i][1]] = min(L[i][0], dp[i-1].get(L[i][1], L[i][0])) #①L[i]の荷物を代入
    for v, w in dp[i-1].items():
        dp[i][v] = min(w, dp[i].get(v, w)) #②i-1番目の各荷物を代入
        dp[i][v+L[i][1]] = min(w + L[i][0], dp[i-1].get(v+L[i][1], w + L[i][0]) ) #③i-1番目の各荷物とL[i]を足した物を代入
        #print(dp)

ans =0
for v, w in dp[-1].items():
    if w<=limit:
        if ans < v:
            ans = v

print(ans)

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

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



        }
        cout<<max<<endl;
}


Measured memory_bytes: 3596
from sys import stdin
import heapq

n,m = [int(x) for x in stdin.readline().rstrip().split()]
a_lst = [int(x) * (-1) for x in stdin.readline().rstrip().split()]
heapq.heapify(a_lst)

for i in range(m):
  tmp = heapq.heappop(a_lst)
  tmp = (-1) * ((-1*tmp)//2)
  heapq.heappush(a_lst, tmp)
  
print(-sum(a_lst))


Measured memory_bytes: 14180
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, A[200010];
	int max = 0, max2 = 0, point = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (A[i] > max) {
			max = A[i];
			point = i;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i != point) {
			if (A[i] > max2) {
				max2 = A[i];
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (i == point) {
			printf("%d\n", max2);
		}
		else {
			printf("%d\n", max);
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>

int main(void){
  char S[101];
  int i , N;
  int answer=0;
  int max=0;
  scanf("%d %s",&N,S);
  for(i=0; i<N; i++){

    if(S[i] == 'I'){
      answer++;
   } else {
      answer--;
   }
    if(max<answer){
       max=answer;
    }
 }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    ll n = s.size();
    // 余りの箱を用意する
    vector<ll> val(2019,0);
    // 位の変数を作る(初期値は1)
    ll fac = 1;
    // あまり
    ll cur = 0;
    val[cur]++;
    rep(i,n) {
        // 各桁の値を取得
        ll add = s[n-i-1]-'0';
        // addの位のあまりを求める(addより1つ下のあまりと桁を使って計算)
        cur = (cur+add*fac)%2019;
        // 位がオーバーフローする場合もあるので余りで代用する
        fac = (fac*10)%2019;
        // 余りをindexにしてその個数を勘定する
        val[cur]++;
    }
    // nCn-2を求める
    ll ans = 0;
    rep(i,2019) {
        ans += val[i]*(val[i]-1)/2;
    }
    ct(ans);
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
char s[105];
int i,j;
int main()
{
    gets(s);
    for(i=0;i<strlen(s);i++)
    if(s[i]=='C')
    {
        for(j=i+1;j<strlen(s);j++)
        if(s[j]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;

	if (x >= r && y >= r && x <= W - r && y <= H - r){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;

	bool is_on_way = false;
	if(a < c && c < b) is_on_way = true;
	if(b < c && c < a) is_on_way = true;

	std::cout << (is_on_way ? "Yes" : "No") << std::endl;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

ans = ["null","one pair","two pair","three card","straight","full house","four card"]
straits = [[i,i+1,i+2,i+3,i+4]for i in range(1,10)]
straits.append([1,10,11,12,13])

while(True):
    try:
        l = sorted(list(map(int,input().split(","))))
        v = sorted(list(Counter(l).values()))
        p = 0
        if v == [1,1,1,2]: p = 1
        elif v == [1,2,2]: p = 2
        elif v == [1,1,3]: p = 3
        elif l in straits: p = 4
        elif v == [2,3]: p = 5
        elif v == [1,4]: p = 6
        print(ans[p])
    except:
        break


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

int main()
{
	string str;
	cin >>str;
	int i,N,ans=0, temp=0;
	N=str.length();
	for(i=0;i<N;i++){
		if((str[i]=='A')||(str[i]=='T')||(str[i]=='C')||(str[i]=='G')){
			temp++;
		}else {
			if(ans<temp){
				ans=temp;
			}
			temp=0;
		}
	}
	if(ans<temp){
		ans=temp;
	}
	cout <<ans;
	return 0;
}


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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int N, A;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        cin >> A;
        auto itr = mp.find(A);
        if (itr != mp.end()) mp[A]++;
        else mp[A] = 1;
    }
    if (mp.find(0) != mp.end() && mp[0] == N) {
        cout << "Yes" << endl;
        return 0;
    }
    if (N % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (mp.size() == 2 && mp.find(0) != mp.end() && mp[0] == N / 3) {
        cout << "Yes" << endl;
        return 0;
    }
    if (mp.size() != 3) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> b(0), c(0);
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        b.push_back(itr->first);
        c.push_back(itr->second);
    }
    if ((b[0] ^ b[1]) != b[2]) {
        cout << "No" << endl;
        return 0;
    }
    if (c[0] == c[1] && c[1] == c[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <algorithm>
#define F first
#define S second
using namespace std;

int Q = 1e6, h1, h2, cut = 10;
int n, s, D, l, r, up, mx, cnt, mxx, xx, a[30], b[400][30], la[400], u[400], ans[400], o[400];
pair<int, int> c[400][30];
bool v[400][30];

int f(int p, int q1, int q2) {
	int sz = q2 - q1 + 1;
	return p * sz * (sz + 1) / 2;
}

int main()
{
	int i, j, k, t, x, t1, t2;
	srand(time(NULL));
	cin >> D;
	for (i = 0; i < 26; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 1; i <= D; i++) {
		mxx = -2e9;
		for (j = 0; j < 26; j++) {
			scanf ("%d", &b[i][j]);
		}
		for (j = 0; j < 26; j++) {
			cnt = b[i][j];
			for (k = 0; k < 26; k++) {
				if (k == j) continue;
				cnt -= (i - o[k]) * a[k];
			}
			if (cnt > mxx) {
				xx = j;
				mxx = cnt;
			}
		}
		s += mxx;
		o[xx] = i;
		ans[i] = u[i] = xx;
	}
//	for (i = 1; i <= D; i++) {
//		ans[i] = u[i] = 1;
//	}
//	for(i = 1; i <= D; i++) {
//		printf("%d\n", ans[i] + 1);
//	}

	for (i = 1; i <= D; i++){
//		scanf ("%d", &t);
		t = u[i] - 1;
		s += b[i][t];
		la[t] = i;
		for (j = 0; j < 26;j++) {
			s -= a[j] * (i - la[j]);
		}
		v[i][t] = 1;
	}
//	cout << s << endl;
//	cin >> Q;
	for (i =0; i < 26; i++) {
		v[0][i] = 1;
		v[D + 1][i] = 1;
	}
	mx = s;
	while (Q--) {
//		scanf ("%d %d", &t1, &t2);
		t1 = rand() % D + 1;
		t2 = rand() % 26;
		if (u[t1] == t2) t2 = (t2 + 1) % 26;
		x = u[t1];
		s -= b[t1][x];
		v[t1][x] = 0;
		v[t1][t2] = 1;
		u[t1] = t2;
		s += b[t1][t2];
		for (l = t1 - 1; l >= 0; l--) if (v[l][x]) break;
		for (r = t1 + 1; r <= D + 1; r++) if (v[r][x]) break;
		s += f(a[x], l + 1, t1 - 1);
		s += f(a[x], t1 + 1, r - 1);
		s -= f(a[x], l + 1, r - 1);
		for (l = t1 - 1; l >= 0; l--) if (v[l][t2]) break;
		for (r = t1 + 1; r <= D +1; r++) if (v[r][t2]) break;
		s += f(a[t2], l + 1, r - 1);
		s -= f(a[t2], l + 1, t1 - 1);
		s -= f(a[t2], t1 + 1, r - 1);
		if (s > mx) {
			up = 0;
			for (i = 1; i <= D; i++) {
				ans[i] = u[i];
			}
			mx = s;
		} else up++;
		if (up == cut) {
			up = 0;
			for (i = 1; i <= D; i++) {
				u[i] = ans[i];
			}
			s = mx;
		}
	}
	for (i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int a,b; cin >> a >> b;
  cout << max(0,a-2*b) << endl;
  return 0;
}

Measured memory_bytes: 384
MAX = 24*60**2 + 60*60 + 60

def datetime2second(datetime):
    hours, minutes, seconds = map(int, datetime.split(':'))

    return hours * 60**2 + minutes * 60 + seconds

while True:
    n = int(input())
    if n == 0: break

    s = [0] * (MAX + 1)
    for i in range(n):
        d, a = map(datetime2second, input().split())

        s[d] += 1
        s[a] -= 1
    
    ans = s[0]
    for i in range(MAX):
        s[i+1] += s[i]
        ans = max(ans, s[i+1])

    print(ans)



Measured memory_bytes: 9636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <sstream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <cctype>
#include <iomanip>
#include <list>
#include <cstring>

#define INF 2000000000
#define ull unsigned long long int
#define vi vector<int>
#define vii vector<ii>

#define UNVISITED 0
#define OPENED 1
#define CLOSED 2

#define PI 3.14159


using namespace std;

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

    vector <char> sta;

    for(int i= 0;  i < s.size(); i++) {
        
        if(s[i] == 'B') {
            if(!sta.empty())
                sta.pop_back();
        }
        else {
            sta.push_back(s[i]);
        }
    
    }

    for(int i =0; i < sta.size(); i++) {
        cout << sta[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256