akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  string s;
  cin>>s;
  if(s[sz(s)-1]=='s'){
    cout<<s<<"es";LOL
    return;
  }
  cout<<s<<'s';LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3648
s=input()
if s.count("N")>0 and s.count("W")>0 and s.count("S")>0 and s.count("E")>0:
    print("Yes")
elif s.count("N")==0 and s.count("W")>0 and s.count("S")==0 and s.count("E")>0:
    print("Yes")
elif s.count("N")>0 and s.count("W")==0 and s.count("S")>0 and s.count("E")==0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9016
//#define _GLIBCXX_DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    vector<ll> a(n);
    char pred = ' ';
    for (int i = 0; i < n; i++) {
        if (s[i]=='B')
            a[i]= 1;
        if (i)
            a[i] += a[i - 1];
    }
    //ll ans = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == 'W')
            ans += a[i];

        cout << ans;
}


Measured memory_bytes: 2180
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  string s; readV(s);

  auto n = s.length.to!int, k = (n+1)/2+1;
  for (; k <= n; ++k)
    if (s[k-1] != s[n-k] || s[k-1] != s[k-2]) break;

  writeln(k-1);
}


Measured memory_bytes: 2556
#include <iostream>
#include <queue>
using namespace std;
struct po{int lx,ly,rx,ry;};
int w,h;
string mp[2][51];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

bool bfs(int lx,int ly,int rx,int ry){
  bool visited[50][50][50][50]={};
  queue <po> Q;
  Q.push((po){lx,ly,rx,ry});
  while(!Q.empty()){
    po t=Q.front();Q.pop();
    lx=t.lx, ly=t.ly;
    rx=t.rx, ry=t.ry;
    if(visited[lx][ly][rx][ry])continue;
    int cnt=(mp[0][ly][lx]=='%')+(mp[1][ry][rx]=='%');
    if(cnt==2)return true;
    if(cnt)continue;
    visited[lx][ly][rx][ry]=1;
    for(int i=0;i<4;i++){
      int flg=0;
      int nlx=lx+dx[i],nly=ly+dy[i];
      int nrx=rx-dx[i],nry=ry+dy[i];
      if(nlx<0||nly<0||nlx>=w||nly>=h||mp[0][nly][nlx]=='#')nlx=lx,nly=ly,flg++;
      if(nrx<0||nry<0||nrx>=w||nry>=h||mp[1][nry][nrx]=='#')nrx=rx,nry=ry,flg++;
      if(flg==2||visited[nlx][nly][nrx][nry])continue;
      Q.push((po){nlx,nly,nrx,nry});
    }
  }
  return false;
}

int main(){
  while(1){
    cin >>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[0][i]>>mp[1][i];
    int lx,ly,rx,ry;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(mp[0][i][j]=='L')lx=j,ly=i;
	if(mp[1][i][j]=='R')rx=j,ry=i;
      }

    if(bfs(lx,ly,rx,ry))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int N, M;
V X;

int main() {
    cin >> N >> M;
    X.resize(M);
    VECCIN(X);
    sort(All(X));
    int Min = X[0];
    int Max = X[M - 1];
    PQ p;
    REP(i, M - 1) p.push(X[i + 1] - X[i]);
    int dif = 0;
    REP(i, N - 1) {
        if(p.empty()) break;
        dif += p.top();
        p.pop();
    }
    cout << (Max - Min) - dif << "\n";
    return 0;
}


Measured memory_bytes: 1276
N, K = map(int, input().split())
x_list = list(map(int, input().split()))

result = []
for i in range(N-(K-1)):
    start = i
    end = i + (K -1)
    result.append(abs(x_list[start]) + abs(x_list[end] - x_list[start]))
    result.append(abs(x_list[end]) + abs(x_list[end] - x_list[start]))
print(min(result))

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

const ll mod = 1000000007;


int main() {
	ll n, k; cin >> n >> k;
	int cnt = 0;
	ll tmp = 1;
	while(n >= tmp){
		cnt++;
		tmp *= k;
	}
	cout << cnt << endl;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char a, b, c, d, e, f;
    a = getchar();
    b = getchar();
    c = getchar();
    d = getchar();
    e = getchar();
    f = getchar();
    if(c == d && e == f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main() {
	int n;
    cin >> n;
    int d[n];

    rep (i, n) cin >> d[i];

    int sum  = 0;
    rep (i, n) {
        for (int j=i+1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3496
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int N,D;
int a[15][15];
bool flag[1000010];
int dis(int x,int y){
	int res=0;
	for(int i=1;i<=D;i++)
		res+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	return res;
}
int main(){
	//freopen("in","r",stdin);
	for(int i=0;i*i<=1000000;i++)
		flag[i*i]=1;
	N=read(),D=read();
	for(int i=1;i<=N;i++)
		for(int j=1;j<=D;j++)
			a[i][j]=read();
	int ans=0;
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++)
			if(flag[dis(i,j)])
				ans++;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
#define DEBUG(x)        do { std::cerr << #x << " = " << x << std::endl;  } while(0)
#define DEBUGV(x)       for(auto e : x) { std::cerr << e << " "; }; cout << endl;
#define INFO(msg)       do { std::cerr << msg << std::endl; } while(0)
#define ll              long long
#define vi              vector<int>
#define pii             pair<int, int>
#define fori(i, s, e)   for(int i = s; i < e; i++)
#define ford(i, s, e)   for(int i = s; i >= e; i--)
 
using namespace std;

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

    map<int, pii> m;
    int x;

    fori(i, 0, 3) {
        fori(j, 0, 3) {
            cin >> x;
            m[x] = make_pair(i, j);
        }
    }

    int n, s = 0;
    cin >> n;

    int rows[3], cols[3], diags[2];
    memset(rows, 0, sizeof rows);
    memset(cols, 0, sizeof cols);
    memset(diags, 0, sizeof diags);

    fori(i, 0, n) {
        cin >> x;
        if(m.find(x) == m.end()) continue;
        rows[m[x].first]++;
        cols[m[x].second]++;
        if(m[x].first == m[x].second) diags[0]++;
        if(m[x].first == 2 - m[x].second) diags[1]++;
        if(rows[m[x].first] == 3 || cols[m[x].second] == 3 || diags[0] == 3 || diags[1] == 3) {
            cout << "Yes" << endl;
            s = 1;
            break;
        }
    }

    if(!s) {
        cout << "No" << endl;
    }

    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;
    int cnt = s.size() - 2;
    cout << s[0] << cnt << s[s.size()-1] << endl;

    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll par[800010];
ll len[800010];
void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        len[i]=0;
    }
}
ll root(ll n){
    if(par[n]==n)return n;
    return par[n]=root(par[n]);
}
void unit(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(len[a]<len[b]){
        par[a]=b;
    }
    else{
        par[b]=a;
        if(len[a]==len[b])len[a]++;
    }
}
struct edge{
    ll from,to,cost;
};
bool cmp(edge a,edge b){
    return a.cost<b.cost;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<ll> v[n+1],w[n+1];
    rep(i,0,n+m-1){
        ll a,b;cin>>a>>b;
        v[a].push_back(b);
        w[b].push_back(a);
    }
    queue<ll> q;
    rep(i,1,n+1){
        if(v[i].size()==0)q.push(i);
    }
    ll cnt[n+1];
    fill(cnt,cnt+n+1,0);
    ll par[n+1];
    fill(par,par+n+1,0);
    while(q.size()>0){
        ll now=q.front();q.pop();
        rep(i,0,v[now].size()){
            ll ne=v[now][i];
            if(par[ne]>0)continue;
            par[ne]=now;
        }
        rep(i,0,w[now].size()){
            ll ne=w[now][i];
            cnt[ne]++;
            if(v[ne].size()==cnt[ne]){
                q.push(ne);
            }
        }
        
    }
    rep(i,1,n+1)cout<<par[i]<<endl;
}


Measured memory_bytes: 13312
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

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

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/

int main(){
	int N;
	cin>>N;
	int p[1000][3];
	for(int i=0;i<N;i++){
		cin>>p[i][0]>>p[i][1]>>p[i][2];
		sort(p[i],p[i]+3);
	}
	int q[1000];
	for(int i=0;i<N;i++){
		q[i]=0;
	}
	int answer=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(q[i]==0){
				if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
					answer=answer+1;
					q[i]=1;
				}
			}
		}
	}
	cout<<answer<<endl;


	/*int W,H,C;
	cin>>W>>H>>C;
	int gcd=0;
	for(int i=1;i<min(W,H)+1;i++){
		if(W%i==0 && H%i==0){
		gcd=max(gcd,i);
	}
	}
	cout<<(W/gcd)*(H/gcd)*C<<endl;*/
	/*int E,Y;
	cin>>E>>Y;
	if(E==0){
		int y=Y-1867;
		if(y<=44){
			cout<<'M'<<y<<endl;
		}
		if(y-44>0 && y-44<=14){
			cout<<'T'<<y-44<<endl;
		}
		if(y-58>0 && y-58<=63){
			cout<<'S'<<y-58<<endl;
		}
		if(y-121>0){
			cout<<'H'<<y-121<<endl;
		}
	}
		if(E==1){
			cout<<Y+1867<<endl;
		}
		if(E==2){
			cout<<Y+1911<<endl;
		}
		if(E==3){
			cout<<Y+1925<<endl;
		}
		if(E==4){
			cout<<Y+1988<<endl;
		}*/
	/*int H,R;
	cin>>H>>R;
	if(H>-R){
		cout<<1<<endl;
	}
	if(H==-R){
		cout<<0<<endl;
	}
	if(H<-R){
		cout<<-1<<endl;
	}*/

	/*
int W;
cin>>W;
cout<<W*32<<endl;*/

    return 0;
}


Measured memory_bytes: 3180
A, B, C, X, Y = map(int, input().split())

if A+B <= 2*C:
    print(A*X+B*Y)
else:
    if X <= Y:
        print(min(2*C*Y, 2*C*X+B*(Y-X)))
    else:
        print(min(2*C*X, 2*C*Y+A*(X-Y)))


Measured memory_bytes: 8784
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//#include<algorithm>
//#include<cmath>
//#include<string>
using namespace std;
int main() {
	int n, m,i;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		if (i <= n / 2) cout << "0";
		else cout << m;
	}
	puts("");
	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>

int main(void)
{

   int n,k,a[100000],x,i;

   scanf("%d %d",&n,&k);

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

   for(i=0;i<n;i++){
      if(a[i]>=k) x++;
   }

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

   return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N], t[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s%s", s, t);
  int g = __gcd(n, m);
  int stepS = n / g, stepT = m / g;
  bool found = false;
  for (int i = 0, j = 0; i < n && j < m; i += stepS, j += stepT) {
    if (s[i] != t[j]) found = true;
  }
  if (found) {
    puts("-1");
  } else {
    printf("%lld\n", (int64)n * m / g);
  }
  return 0;
}


Measured memory_bytes: 384
S = input()

K = 1
prev = S[0]
i = 1
len_S = len(S)
while i < len_S:
    K += 1
    if prev == S[i] or i == len_S - 2 and S[i] == S[i + 1]:
        prev = S[i:i + 2]
        i += 2
    else:
        prev = S[i]
        i += 1
print(K)


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

int main() {
    bool spade[13], heart[13], club[13], diamond[13];
    int n, index;
    char picture;

    for (int i = 0; i < 13; i++) {
        spade[i] = false;
        heart[i] = false;
        club[i] = false;
        diamond[i] = false;
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> picture >> index;
        switch (picture) {
            case 'S':
                spade[index - 1] = true;
                break;
            case 'H':
                heart[index - 1] = true;
                break;
            case 'C':
                club[index - 1] = true;
                break;
            case 'D':
                diamond[index - 1] = true;
                break;
        }
    }

    for (int i = 0; i < 13; i++) {
        if (spade[i] == false) {
            cout << 'S' << ' ' << (i + 1) << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (heart[i] == false) {
            cout << 'H' << ' ' << (i + 1) << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (club[i] == false) {
            cout << 'C' << ' ' << (i + 1) << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (diamond[i] == false) {
            cout << 'D' << ' ' << (i + 1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	int g = 0, ma = 0;
	FOR(i, n) {
		int a;
		cin >> a;
		ma = max(ma, a);
		g = __gcd(g, a);
	}
	if (k <= ma && k % g == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	int N;
	cin >> N;
	queue<string> que;
	vector<char> c;
	for (int i = 0; i < N; i++)
	{
		c.push_back(i + 'a');
	}
	que.push("a");
	for (int i = 1; i < N; i++)
	{
		// 長さiのphase
		int M = que.size();
		for (int j = 0; j < M; j++)
		{
			string p = que.front();
			que.pop();
			map<char, int> mp;
			for (int k = 0; k < p.size(); k++)
			{
				mp[p[k]]++;
			}

			for (int k = 0; k < i + 1; k++)
			{
				if (mp[c[k]] > 0)
					que.push(p + c[k]);
			}
			for (int k = 0; k < i + 1; k++)
			{
				if (mp[c[k]] == 0)
				{
					que.push(p + c[k]);
					break;
				}
			}
		}
	}
	int M = que.size();
	for (int i = 0; i < M; i++)
	{
		cout << que.front() << "\n";
		que.pop();
	}
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    string s,t;
    int tim[100000]={};
    for(int i=0;i<n;i++){
      cin>>s>>t;
      int h=(s[0]-'0')*10+(s[1]-'0');
      int m=(s[3]-'0')*10+(s[4]-'0');
      int k=(s[6]-'0')*10+(s[7]-'0');
      int hh=(t[0]-'0')*10+(t[1]-'0');
      int mm=(t[3]-'0')*10+(t[4]-'0');
      int ss=(t[6]-'0')*10+(t[7]-'0');
      tim[h*60*60+m*60+k]++;
      tim[hh*60*60+mm*60+ss]--;
    }
    int ans=0;
    for(int i=1;i<100000;i++){
      tim[i]+=tim[i-1];
      ans=max(tim[i],ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3396
#include <iostream>

using namespace std;

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

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if (0 < a) {
        cout << "Positive" << endl;
    } else if (b < 0) {
        if ((b - a) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    x = x/a;
    double san = a*b/2;
    if(san>=x){
        double h;
        h = x*2/b;
        double res = atan(b/h)/3.14159*180;
        printf("%.10f",res);
    }else{
        double h;
        h = 2*x/a - b;
        b = b-h;
        double res = 180/3.14159*atan(b/a);
        printf("%.10f",res);
    }
}


Measured memory_bytes: 512
def examA():
    A, B, C = LI()
    if A<=C<=B:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
const int maxn = 100005;
const int maxm = 200005;
vector<int>G[maxn];
int visit[maxn]={0};
int main()
{
    int n,m;
    cin >> n >> m;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<pair<int,int>>q;
    q.push({1,1});
    visit[1]=1;
    while(!q.empty()){
        int fa = q.front().second;
        q.pop();
        for(auto v:G[fa]){
            if(!visit[v]){
                q.push({fa,v});
                visit[v]=fa;
            }
        }
    }
    for(int i=2;i<=n;i++){
        if(!visit[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(int i=2;i<=n;i++){
        cout << visit[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 10572
#include <iostream>
#include <cstdio>

struct Node {
    int parent;
    int child_left;
    int brother_right;
};

void DumpDepth(int node_id, Node *node_list)
{
    int depth = 0;
    int target_id = node_id;
    while(1) {
        int parent_id = node_list[target_id].parent;
        if (parent_id == -1) {
            break;
        } else {
            depth++;
            target_id = parent_id;
        }
    }
    std::cout << "depth = " << depth << ", ";
}

void DumpType(int node_id, Node *node_list)
{
    std::string type;
    if (node_list[node_id].parent == -1) {
        type = "root";
    } else if (node_list[node_id].child_left != -1) {
        type = "internal node";
    } else {
        type = "leaf";
    }
    std::cout << type << ", ";
}

void DumpChild(int node_id, Node *node_list)
{
    std::cout << "[";
    int child_id = node_list[node_id].child_left;
    if (child_id != -1) {
        while(1) {
            if (node_list[child_id].brother_right == -1) {
                std::cout << child_id;
                break;
            } else {
                std::cout << child_id << ", ";
                child_id = node_list[child_id].brother_right;
            }
        }
    }
    std::cout << "]";
}

int main(int argc, char *argv[])
{
    /***************** Input ***************/
    int n;
    scanf("%d", &n);

    // init
    Node *node_list = (Node*)malloc(sizeof(Node) * n);
    for (int i = 0; i < n; i++) {
        node_list[i].parent = -1;
        node_list[i].child_left = -1;
        node_list[i].brother_right = -1;
    }

    for (int i = 0; i < n; i++) {
        // Make Node
        int id, dimention;
        scanf("%d", &id);
        scanf("%d", &dimention);

        // Child Information
        for (int j = 0; j < dimention; j++) {
            int child_id, prev_child_id;
            scanf("%d", &child_id);
            if (j == 0) {
                node_list[id].child_left = child_id;
            } else {
                node_list[prev_child_id].brother_right = child_id;
            }
            node_list[child_id].parent = id;
            node_list[child_id].brother_right = -1;
            prev_child_id = child_id;
        }
    }    
    /***************** Output ***************/
    for (int i = 0; i < n; i++) {
        std::cout << "node " << i << ": ";
        std::cout << "parent = " << node_list[i].parent << ", ";
        DumpDepth(i, node_list);
        DumpType(i, node_list);
        DumpChild(i, node_list);
        std::cout << std::endl;
    }
}


Measured memory_bytes: 4400
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <climits>
using namespace std;
typedef long long ll;
ll INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int dp[n+1][3];
	for(int i=0;i<n+1;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=0;
		}
	}
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k) continue;
				if(j==0) dp[i+1][j]=max(dp[i+1][j],dp[i][k]+a[i]);
				if(j==1) dp[i+1][j]=max(dp[i+1][j],dp[i][k]+b[i]);
				if(j==2) dp[i+1][j]=max(dp[i+1][j],dp[i][k]+c[i]);
			}
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}



Measured memory_bytes: 2560
N,T=map(int,input().split())
A=list(map(int,input().split()))
i=0
j=1
a=0
b=0
while i<=N-1:
    if j==N:
        i=N
    elif A[i]>A[j]:
        i=j
        j+=1
    else:
        if A[j]-A[i]>a:
            a=A[j]-A[i]
            b=1
            j+=1
        elif A[j]-A[i]==a:
            b+=1
            j+=1
        elif A[j]-A[i]<a:
            j+=1
print(b)

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

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif

  int a,b,c;
  cin >> a >> b >> c;
  vector < int > v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(),v.end());
  if(v[0] == 5 && v[1] == 5 && v[2] == 7)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=int_fast64_t;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double EPS=1e-9;
const int MOD=1e9+7;
int dp[3010][2][2];
int main(){
    int n,m;cin>>n>>m;
    vector<string> s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    int ans=0;
    for(int i=min(0,-n);i<m-1;i++){
        int x,y;
        if(i>=0){
            x=i+1,y=n-1;
        }else{
            x=0,y=abs(i+1);
        }
        memset(dp,0,sizeof(dp));
        if(s[y][x]=='G'){
            if(y>0&&y<n-1&&s[y-1][x]=='R'&&s[y+1][x]=='W'){
                dp[x][1][0]=1;
            }
            if(x>0&&x<m-1&&s[y][x-1]=='R'&&s[y][x+1]=='W'){
                dp[x][0][1]=1;
            }
        }
        while((++x)>=0&&(--y)>=0&&x<m&&y<n){
            dp[x][0][0]=max(dp[x-1][0][0],max(dp[x-1][0][1],dp[x-1][1][0]));
            if(s[y][x]!='G')continue;
            if(y>0&&y<n-1&&s[y-1][x]=='R'&&s[y+1][x]=='W'){
                dp[x][1][0]=max(dp[x-1][0][0],dp[x-1][1][0])+1;
            }
            if(x>0&&x<m-1&&s[y][x-1]=='R'&&s[y][x+1]=='W'){
                dp[x][0][1]=max(dp[x-1][0][0],dp[x-1][0][1])+1;
            }
        }
        ans+=max(dp[x-1][0][0],max(dp[x-1][0][1],dp[x-1][1][0]));
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 23724
s = input()
n = len(s)+1
A = [0]*n

for i in range(n-1):
    if s[i] == '<':
        A[i+1] = A[i] + 1

for i in reversed(range(n-1)):
    if s[i] == '>':
        A[i] = max(A[i], A[i+1] + 1)

print(sum(A))


Measured memory_bytes: 46792
//D
#include <iostream>
#include<bits/stdc++.h>
#define ll long long 

#define pb push_back
#define pii pair<int,int>
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;


void solve(){
	int n;
	cin >> n;
	vector<ll> v(100007,0);
	ll sum=0;
	for(int i=1;i<=n;i++){
		int x;
		
		cin >> x;
		sum+=x;
		
		v[x]++;
	}
	int q;
	cin >> q;
	while(q--){
		int x , y;
		cin >> x >> y;
		if(v[x]>0){
			sum-= (x * v[x]);
			sum+= (v[x]*y);
			v[y] +=v[x];
			v[x]=0;
			
			
		}
		
	/*	for(int i =1;i<=n;i++){
			cout << v[i] << " ";
		}
		cout<<endl;*/
		
		cout<<sum<<endl;
	}
	
}

int main() {
	


	solve();
	    
	return 0;
}


Measured memory_bytes: 4036
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n = i()
nx = str(n)[0]
ny = str(n)[-1]
digit = len(str(n))
is_full = [1, 11, 111, 1111, 11111]

for i in range(1, n + 1):
    x = str(i)[0]
    y = str(i)[-1]
    if y == "0":  # 0が先頭になるときを考えない
        continue

    if x == y:  # xとyが同じとき3などの一桁の値をとりうるので+1する
        ans += 1

    if y < nx:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより小さいとき
        if digit - 2 < 0:  # 無条件で取れる，ものが無ければcontinue
            continue
        ans += is_full[digit - 2]
    elif y == nx:
        if digit - 3 >= 0:
            ans += is_full[digit - 3]
        for num, k in enumerate(list(str(n))[1: -1], 1):  # y???xとnx???nyを比較していく
            ans += int(k) * 10 ** (digit - 2 - num)

        if digit >= 2 and x <= ny:  # 10の位をもうひとつ上げられるとき
            ans += 1
    else:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより大きいとき
        if digit - 3 < 0:  # このときは無条件に取れるis_fullの位が一段階下がる
            continue
        ans += is_full[digit - 3]

print(ans)

Measured memory_bytes: 5464
#include <stdio.h>
int main(void){
    int c[3][3] = {0};
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &c[i][j]);
        }
    }
    
    int a[3] = {0}; int b[3] = {0};
    a[0] = 0;
    b[0] = c[0][0] - a[0]; b[1] = c[0][1] - a[0]; b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0]; a[2] = c[2][0] - b[0];

    if(c[1][1] == a[1] + b[1]){
        if(c[1][2] == a[1] + b[2]){
            if(c[2][1] == a[2] + b[1]){
                if(c[2][2] == a[2] + b[2]){
                    printf("Yes\n");
                }else {
                    printf("No\n");
                }
            }else {
                printf("No\n");
            }
        }else {
            printf("No\n");
        }
    }else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	int data[100][100];
	int i,j;
	int sum = 0;
	int r =0,c = 0;
	
	scanf("%d %d",&r,&c);
	if(r < 1|| c < 1){
		r = 1;
		c = 1;
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			scanf("%d",&data[i][j]);
		}
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			printf("%d ",data[i][j]);
			sum += data[i][j];
		}
		printf("%d\n",sum);
		sum = 0;	
	}
	
	for(i = 0;i < c;i++){
		for(j = 0;j < r;j++){
			sum += data[j][i];
		}
		printf("%d ",sum);
		sum = 0;
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			sum += data[i][j];
		}
	}
	printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
template<class T>

void Swap(T& a, T& b)
{
	T c = a;
	a = b;
	b = c;
}

class card
{
public:
	char suit;
	int value;
};



int main()
{
	int N;
	card c[36]{};
	card c1[36]{};
	card c2[36]{};

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> c[i].suit >> c[i].value;
		c1[i].suit = c[i].suit;
		c2[i].suit = c[i].suit;
		c1[i].value = c[i].value;
		c2[i].value = c[i].value;
	}

	for (int i = 0; i < N; i++) // Bubble sort
	{
		for (int j = N - 1; j >= i + 1; j--)
		{
			if (c1[j].value < c1[j - 1].value) Swap(c1[j], c1[j - 1]);
		}
	}

	for (int i = 0; i < N; i++) // Selection sort
	{
		int mini = i;
		for (int j = i; j < N; j++)
		{
			if (c2[j].value < c2[mini].value)
			{
				mini = j;
			}
		}
		if (mini != i)
		{
			Swap(c2[i], c2[mini]);
		}
	}

	for (int i = 0; i < N; i++)
	{
		if (i != N - 1) cout << c1[i].suit << c1[i].value << " ";
		else cout << c1[i].suit << c1[i].value << endl;
	}
	cout << "Stable" << endl;

	for (int i = 0; i < N; i++)
	{
		if (i != N - 1) cout << c2[i].suit << c2[i].value << " ";
		else cout << c2[i].suit << c2[i].value << endl;
	}

	bool f = true;
	for (int i = 0; i < N; i++)
	{
		if (c1[i].suit != c2[i].suit || c1[i].value != c2[i].value)
		{
			f = false;
		}
	}

	cout << (f ? "Stable" : "Not stable") << endl;
}


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

signed main(){
  
  int n;
  cin>>n;
  
  int num = 1;
  stack<int> ST;
  
  string ans;
  
  for(int i=0;i<n;i++){
    
    int p;
    cin>>p;
    
    while( num <= p ){
      ST.push( num++ );
      ans += "(";
    }
    
    if( ST.top() == p ){
      ST.pop();
      ans += ")";
    }
    else{
      cout<<":("<<endl;
      exit(0);
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}



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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    string a,b;
    cin>>a>>b;
    //reverse(all(a));
    //reverse(all(b));
    if(a.size()==b.size()){
        REP(i,a.size()){
            if(a[i]<b[i]){
                cout<<"LESS"<<endl;
                return 0;
            }else if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;

    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
    }else{
        cout<<"GREATER"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

// graph //
int V,E,from,to,weight;

// uf //
vector<int> par;
vector<int> rnk;

struct Edge {
    int s,t,w;
    Edge(int s,int t,int w) : s(s), t(t), w(w) {}
    bool operator< (const Edge &e) const {
        return w < e.w;
    }
};

vector<Edge> edges;

int find(int x){
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
}

bool same(int x,int y){
    return find(x) == find(y);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y) return;
    
    // unite //
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x]==rnk[y]) ++rnk[x];
    }
}

int kruskal(){
    sort(edges.begin(),edges.end());

    int cost = 0;
    for(auto itr = edges.begin(); itr!=edges.end(); ++itr){
        if(!same(itr->s,itr->t)){
            cost += itr->w;
            unite(itr->s,itr->t);
        }
    }
    return cost;
}

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

    cin >> V >> E;
    par.resize(V,0);
    rnk.resize(V,0);
    for(int i = 0; i < V; ++i) par[i] = i;

    for(int i = 0; i < E; ++i){
        cin >> from >> to >> weight;
        edges.emplace_back(from,to,weight);
        edges.emplace_back(to,from,weight);
    }
    cout << kruskal() << '\n';
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << counter*100 + 700 << endl;
}


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

bool isOK(vector<string> s) {
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s.size(); j++) {
            if (s[i][j] != s[j][i]) {
                return false;
            }
        }
    }

    return true;
}

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    long long ans = 0;
    for (int A = 0; A < 1; A++) {
        for (int B = 0; B < N; B++) {
            vector<string> S2(N);
            for (int i = 0; i < N; i++) {
                S2[i].resize(N);
            }

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    S2[i][j] = S[(i + A) % N][(j + B) % N];
                }
            }

            (isOK(S2) ? ans++ : 0);
        }
    }

    cout << ans * N << endl;
}

Measured memory_bytes: 744
#include <iostream>
#include <stdio.h>
#include <vector>
#include <sstream>

using namespace std;


vector<string> split(const string &str, char delim){
    vector<string> v;
    string buffer;
    stringstream ss(str);
    while(getline(ss, buffer, delim)) v.push_back(buffer);
    return v;
}

string getLine(){
    string str;
    getline(cin, str);
    return str;
}

template<typename T, typename R>
vector<R> map(vector<T> xs, R(*fp)(T)){
    vector<R> ys;
    for(T x : xs) ys.push_back(fp(x));
    return ys;   
}


template<typename T, typename R>
R foldl(vector<T> xs, R(*fp)(R, T), R initial){
    R s = initial;
    for(T x : xs) s = fp(s, x);
    return s;
}

template<typename T>
T product(vector<T> xs){
    return foldl(xs, +[](T n, T m){ return n * m; }, 1);   
}

template<typename T>
T sum(vector<T> xs){
    return foldl(xs, +[](T n, T m){ return n + m; }, 0);   
}

int main(void){
    vector<int> v = map(split(getLine(), ' '), +[](string x){ return stoi(x); });
    printf("%d %d\n", product(v), sum(v) * 2);
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end();
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c;
  d = a;
  a /= (b+c);
  cout << a*b + min(d-a*(b+c),b);
}

Measured memory_bytes: 3644
import sys
import itertools

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    ans = 0
    P2 = []
    for i in range(N):
        P2.append((P[i] / 2) * (P[i] + 1) / P[i])

    if N == 1:
        print(max(P2))
        return
    if N == K:
        print(sum(P2))
        return
    P3 = list(itertools.accumulate(P2))
    for i in range(N - K):
        ans = max(ans, P3[i + K] - P3[i])



    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25164
#include <iostream>
 
using namespace std;
 
int main (void) {
  int G[101][101] = {0}, sum[101] = {0}, rank[101] = {0};
  int a, b, c, d;
  int n;
 
  cin >> n;
 
  for(int i = 1; i <= n*(n-1)/2; i++) {
    cin >> a >> b >> c >> d;
    if(c < d) {
      G[a][b] = 0; G[b][a] = 3;
    } else if(c == d) {
      G[a][b] = 1; G[b][a] = 1;
    } else {
      G[a][b] = 3; G[b][a] = 0;
    }
  }
 
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if (i == j) continue;
      sum[i] += G[i][j];
    }
  }
 
  //cout << sum[0] << " " << sum[1] << " " << sum[2] << " " << sum[3] << endl;
 
  int daburi = 1;
 
  // rank&#227;&#129;&#174;&#229;‡&#186;&#227;&#129;—&#230;&#8211;&#185;&#227;&#129;&#175;&#228;&#191;&#186;&#227;&#129;&#338;&#232;&#8364;&#402;&#227;&#129;&#710;&#227;&#129;&#376;&#227;&#8218;&#162;&#227;&#402;&#171;&#227;&#8218;´&#227;&#402;&#170;&#227;&#8218;&#186;&#227;&#402; &#227;&#129;&#732;&#227;&#8218;&#402;&#227;&#129;&#170;&#227;&#129;&#8222;
  for(int i = 1; i <= n; i++) {
    rank[i] = 1;
    for(int j = 1; j <= n; j++) {
      if(sum[i] < sum[j]) rank[i]++;
    }
  }
 
  for(int i = 1; i <= n; i++) {
    cout << rank[i] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;	


string s;
int len;
int sum;
int dig;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	
	cin >> s;
	len = s.size();
	for (int i=0;i<len;i++){
		dig = s[i]-'0';
		sum += dig;
		sum %= 9;
	}
	if (sum == 0) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}

Measured memory_bytes: 3760
#define E 0.00000001
#define zero(n)(fabs(n)<E)
main(n,a,b,c,d,p,q,r,D,f){
	for(scanf("%d",&n);n;n--){
		scanf("%d%d%d%d",&a,&b,&c,&d);//fx=ax3+bx2+cx+d
		if(a<0)a=-a,b=-b,c=-c,d=-d;   //won't lose generality
		p=3*a,q=2*b,r=c,D=q*q-4*p*r;  //f'x=3ax2+2bx+c D: f'x=0?
		if(D>0){
			double x1=(-q-sqrt(D))/p/2,x2=(-q+sqrt(D))/p/2;
			double y1=a*x1*x1*x1+b*x1*x1+c*x1+d;
			double y2=a*x2*x2*x2+b*x2*x2+c*x2+d;
			if(!zero(y1)&&!zero(y2)>E&&y1*y2>0)goto one;
			puts(
				zero(x1)?(
					d==0?"1 0":
					"2 1"
				):zero(x2)?(
					d==0?"0 1":
					"1 2"
				):x1>0?(
					d>0?"2 1":
					d<0?"3 0":
					"2 0"
				):x2<0?(
					d>0?"0 3":
					d<0?"1 2":
					"0 2"
				):(
					d>0?"2 1":
					d<0?"1 2":
					"1 1"
				)
			);
		}else if(D==0)puts(
			d>0?"0 1":
			d<0?"1 0":
			"0 0"
		);else{one:
			puts(d>0?"0 1":d<0?"1 0":"0 0");
		}
	}
	exit(0);
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI a(n);
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    
    VB isMax(n,false);
    VI prevMax(n, 0);
    
    int maxPos = -1;
    FOR(i,0,n-1) {
        if (maxPos == -1 || a[i] > a[maxPos]) {
            if (maxPos != -1) {
                prevMax[i] = a[maxPos];
            }
        
            maxPos = i;
            isMax[i] = true;
        }
    }
    
    VL ans(n, 0);
    
    multiset <int,greater<int>> values;
    int alreadyAbove = 0;
    ll sumAbove = 0;
    
    int limit = INF;
    ll lastAns = 0;
    
    FORD(i,n-1,0) {
        values.insert(a[i]);
        
        if (isMax[i]) {
            limit = prevMax[i];
            while (!values.empty() && *values.begin() > limit) {
                sumAbove += *values.begin();
                alreadyAbove++;
            
                values.erase(values.begin());
            }
            
            ll here = sumAbove - (ll) alreadyAbove * limit;
            
            ans[i] = here - lastAns;
            lastAns = here;
        }
    }
    
    FOR(i,0,n-1) {
        cout << ans[i] << '\n';
    }

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 6784
require 'prime'
include Math
def max(a,b);                           a > b ? a : b                             end
def min(a,b);                           a < b ?  a : b                            end
def swap(a,b);                          a, b = b, a                               end
def gif;                                gets.to_i                                 end
def gi;                                 gets.split.map(&:to_i)                    end
def gs;                                 gets.chomp                                end
def gc;                                 gets.chomp.split('')                      end
def pr(num);                            num.prime_division                        end
def putall(obj);                        obj.each{|o| puts(o)}                     end
def array(size,init = nil);             Array.new(size){init}                     end
def darray(size1, size2, init = nil);   Array.new(size1){Array.new(size2){init}}  end
def rep(num);                           num.times do|i|yield(i) end               end
  def repl(st,en);                      st.upto en-1 do|i|yield(i) end            end

		n = gif
		t = gi
		m = gif
		sum = 0
		t.each do |tt|
			sum += tt
		end

		rep m do
			d = gi
			puts sum - t[d[0]-1]+d[1]
		end




Measured memory_bytes: 2044
# https://atcoder.jp/contests/agc011/tasks/agc011_b

# 色は最後に食ったcreatureになる
# 食って自分の色を残したまま多くなる→小さすぎる生物は食われるしか無い(その色は失われる)
# ソートして、連結していって、連結できなくなった部分はその色に成ることはできない

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
A.sort()
no_idx = 0  # 初めてその色になれないidx [0,no_idx)の色を取ることはできない
s = 0
# いわゆる累積和でどうにかなる
for i, a in enu(A):
    if s * 2 < a:
        no_idx = i
    s += a

print(N - no_idx)


Measured memory_bytes: 14096
import java.io.*;
import java.util.*;
public class Main{
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int rand[] = new int[x];
    for (int i = 0;i<x ;i++ ) {
      rand[i] = sc.nextInt();
    }
    sc.close();
    int count = -1;
    int half[] = new int[x];
    half = rand;
    boolean flg = true;
    while(flg){
      for (int i = 0;i<x;i++) {
        if (half[i]%2 ==1) {
          flg = false;
        }
        half[i] = half[i]/2;
      }
      count = count + 1;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 24020
// Coder: @SumitRaut
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
const int mod = 1e9+7;
template<typename T> T pwm(T a,T b,T md=mod) { T p=1,one=1; while(b) { if(b&one) p=p*a%md; a=a*a%md; b >>=1; } return p; }

using namespace std;
class Timer { chrono::high_resolution_clock::time_point start_t, end_t; public: Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };

void solve() {
    int n;
    cin>>n;
    int x1=INT_MIN,x2=INT_MIN,n1=INT_MAX,n2=INT_MAX;
    while(n--) {
        int x,y;
        cin>>x>>y;
        x1=max(x1,x+y);
        x2=max(x2,x-y);
        n1=min(n1,x+y);
        n2=min(n2,x-y);
    }
    cout<<max(x1-n1,x2-n2)<<'\n';
}
int main()
{
    speedup;
    #ifndef ONLINE_JUDGE
    Timer timer;
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 3544