akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong a, b, c;
    cin >> a >> b;
    c = b;
    int loop_cnt = 0;
    while (1) {
        ++loop_cnt;
        c /= 2;
        if (c == 0) break;
    }
    loop_cnt = 50;
    vector<llong> counter(loop_cnt, 0);
    for (int i = 0; i < loop_cnt; ++i) {
        llong tmp1 = (b / (llong)pow(2, i + 1)) * (llong)pow(2, i);
        llong tmp2 = b % (llong)pow(2, i + 1);
        ++tmp2;
        tmp1 += max((llong)0, tmp2 - (llong)pow(2, i));
        counter[i] += tmp1;
        // cout << i << " " << counter[i] << endl;
    }
    // cout << "----" << endl;
    if (a != 0) --a;
    for (int i = 0; i < loop_cnt; ++i) {
        llong tmp1 = (a / (llong)pow(2, i + 1)) * (llong)pow(2, i);
        llong tmp2 = a % (llong)pow(2, i + 1);
        ++tmp2;
        tmp1 += max((llong)0, tmp2 - (llong)pow(2, i));
        if (a) counter[i] -= tmp1;
        // cout << i << " " << tmp1 << endl;
    }

    llong ans = 0;
    rep(i, loop_cnt) {
        // cout << counter[i] << endl;
        if (counter[i] % 2 == 1) ans += (llong)pow(2, i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll arr[10][10]={0};
    bool hae[10][10]={0};
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    ll n;
    cin>>n;
    ll brr[n+5]={0};
    for(int i=0;i<n;i++)
    {
        cin>>brr[i];
    }
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<n;k++)
            {
                if(arr[i][j]==brr[k])
                {
                    hae[i][j]=1;
                }
            }
        }
    }
    bool ok=0;
    for(int i=0;i<3;i++)
    {
        if(hae[i][0]==1 and hae[i][1]==1 and hae[i][2]==1)
        {
            ok=1;
        }
    }
     for(int i=0;i<3;i++)
    {
        if(hae[0][i]==1 and hae[1][i]==1 and hae[2][i]==1)
        {
            ok=1;
        }
    }
    if(hae[0][0]==1 and hae[1][1]==1 and hae[2][2]==1)
    {
        ok=1;
    }
    if(hae[0][2]==1 and hae[1][1]==1 and hae[2][0]==1)
    {
        ok=1;
    }
    if(ok==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}


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

using namespace std;

#define ll long long

int main()
{
    map<ll, ll> mp;
    mp[0]++;
    int n;
    scanf("%d", &n);
    ll sum = 0;
    for(int i=1; i<=n; i++){
        ll val;
        scanf("%lld", &val);
        sum += val;
        mp[sum]++;
    }
    ll ans = 0;
    map<ll, ll> ::iterator it;
    for(it = mp.begin(); it!= mp.end(); it++){
        ll z = it->second;
        ans += (z*(z-1))/2;
    }
    cout << ans;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, a[205], cnt=0;

bool allEven(){
    rep(i,N){
        if(a[i] % 2 != 0) return false;
        else a[i] = a[i] / 2;
    }
    return true;
}

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

    while(allEven()){
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	
	x3=x2-(y2-y1);
	y3=y2+(x2-x1);
	x4=x3-(y3-y2);
	y4=y3+(x3-x2);
	
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}

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

using namespace std;

map<string , int> ma;

int main()
{
    ios::sync_with_stdio(0);
    string s;
    int n;
    ll ans = 0;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        sort(s.begin(),s.end());
        ans += ma[s];
        ma[s]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
N,P=map(int, sys.stdin.readline().split())
S=sys.stdin.readline().strip()

if P in (2,5):
    ans=0
    for i,x in enumerate(S):
        if int(x)%P==0:
            ans+=i+1
    print ans
else:
    L=[int(S)%P]
    for i,x in enumerate(S):
        L.append((L[-1]-int(x)*pow(10,N-1-i,P))%P)
    ans=0
    D=defaultdict(lambda: 0)
    for i in range(N,-1,-1):
        x=L[i]
        ans+=D[x]
        D[x]+=1
    print ans


Measured memory_bytes: 55964
#include<atcoder/dsu>
#include<iostream>
using namespace std ;
using namespace atcoder ;

int main(){
  int n,q ;
  cin >> n >> q ;
  dsu d(n) ;
  while(q--){
    int t,u,v ;
    cin >> t >> u >> v ;
    if(t) cout << (d.same(u,v)?1:0) << endl ;
    else d.merge(u,v) ;
  }
}

Measured memory_bytes: 3896
#include <bits/extc++.h>
using namespace std;
using i64 = int64_t;
#define mod 1000000007
i64 power(i64 a, i64 b) {
  i64 ret{1};
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a;
    a %= mod;
    b /= 2;
  }
  return ret;
}
main() {
  int n;
  cin >> n;
  i64 ans, t, s, ten(10), nine(9), eight(8);
  ans = (power(ten, n) - 2 * power(nine, n) % mod) % mod + power(eight, n);
  ans %= mod;
  if (ans < 0) ans += mod;
  cout << ans;
}


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

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

template <int64_t mod>
struct modint {
  int64_t a;
  modint(int64_t a = 0) {
    a %= mod;
    if (a < 0) a += mod;
    this->a = a;
  }
  modint operator+(modint rhs) { return modint(a + rhs.a); }
  modint operator-(modint rhs) { return modint(a - rhs.a); }
  modint operator*(modint rhs) { return modint(a * rhs.a); }
  modint pow(modint base, int64_t exp) {
    auto b = base;
    auto res = modint(1);
    while (exp > 0) {
      if (exp & 1) { res = res * b; }
      b = b * b;
      exp = exp / 2;
    }
    return res;
  }
  modint inv() { return pow(*this, mod - 2); }
  modint operator/(modint rhs) { return (*this) * rhs.inv(); }
};

using mint = modint<1000000000 + 7>;
mint solve(int r, int c) {
  auto n = r + c + 2;
  vector<mint> fac(n), inv(n);
  fac[0] = 1;
  for (int i = 1; i < n; i++) {
    // fac[i] = mint(i) * fac[i - 1];
    fac[i] = fac[i - 1] * i;
  }
  inv[n - 1] = fac[n - 1].inv();
  for (int i = n - 2; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1);
  }
  auto binom = [&](int a, int b) -> mint {
    if (a < 0 or b < 0) return 0;
    if (a < b) return 0;
    return fac[a] * inv[b] * inv[a - b];
  };
  auto countPath = [&](int a, int b) { return binom(a + b, b); };
  auto res = mint(0);
  for (int i = 0; i <= r; i++) {
    res = res + countPath(i + 1, c);
  }
  return res;
}

int main() {

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  auto ans = solve(r2, c2);
  ans = ans - solve(r1 - 1, c2);
  ans = ans - solve(r2, c1 - 1);
  ans = ans + solve(r1 - 1, c1 - 1);
  cout << ans.a << endl;

  return 0;
}


Measured memory_bytes: 31488
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, p;
	cin >> n >> p;
	if(n == 1) {
		cout << p << endl;
		return 0;
	}
	ll ans = 1;
	for(ll i = 2; i * i <= p; i++) {
		if(p % i) continue;
		ll a = i, b = p / i;
		ll cnt = 0;
		ll tmp = p;
		while(tmp % a == 0) {
			cnt++;
			tmp /= a;
		}
		if(cnt >= n) ans = max(ans, a);
		cnt = 0; tmp = p;
		while(tmp % b == 0) {
			cnt++;
			tmp /= b;
		}
		if(cnt >= n) ans = max(ans, b);
	}
	cout << ans << endl;
	return 0;
}
/* --------------------------------------- */


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

typedef long long LL;
const int M=305;
const LL INF=(LL)M*(1000000000);

LL dp[2][M]; // dp[i][j] i block end at j
// if k=0 ans=\sum_{1~n} {h[i]-h[i-1]} (h[0]=0)
// if k>0 should change k blocks as the left one of themselves

LL h[M];

int n,k;
struct BIT
{
	LL mi[M];
	void init(int n)
	{
		for(int i=1;i<=n;i++)
			mi[i]=INF;
	}
	int lowbit(int x)
	{
		return x&(-x);
	}
	void add(int p,LL v)
	{
		for(;p<=n;p+=lowbit(p))
			mi[p]=min(v,mi[p]);
	}
	LL query(int p)
	{
		LL ans=INF;
		for(;p;p-=lowbit(p))
			ans=min(ans,mi[p]);
		return ans;
	}
}bit1,bit2;
// maintain dp[i][k] and dp[i][k]-h[k]

LL d[M];
int m;
int id(int x)
{
	return lower_bound(d,d+m,x)-d+1;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
		d[i]=h[i];
	}
	sort(d,d+1+n);
	m=unique(d,d+1+n)-d;
	for(int i=1;i<=n;i++)
		dp[0][i]=INF;
	for(int i=1;i<=n-k;i++)
	{
		bit1.init(m);
		bit2.init(m);
		for(int j=0;j<=n;j++)
			dp[i&1][j]=INF;
		for(int j=i;j<=n;j++)
		{
			bit1.add(id(h[j-1]),dp[(i+1)&1][j-1]-h[j-1]);
			bit2.add(m+1-id(h[j-1]),dp[(i+1)&1][j-1]);
			dp[i&1][j]=min(bit1.query(id(h[j]))+h[j],bit2.query(m+1-id(h[j])));
			//cout<<i<<" "<<j<<" "<<dp[i&1][j]<<endl;
		}
	}
	LL ans=INF;
	for(int i=n-k;i<=n;i++)
		ans=min(ans,dp[(n-k)&1][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

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

long long int dp[2][256];

int main(){
	int i, j, m, n, c[16], x;
	long long int ans;
	while(1){
		cin >> n >> m;
		if(!n) break;
		ans = INF;
		REP(a,2)REP(b,256) dp[a][b] = INF;
		dp[0][128]=0;
		REP(a,m) cin >> c[a];
		REP(a,n){
			cin >> x;
			REP(y,256){
				if(dp[0][y]!=INF){
					REP(z,m){
						if(y+c[z]<=0){
							if(dp[1][0]>=dp[0][y]+pow(x-0,2)){
								dp[1][0]=dp[0][y]+pow(x-0,2);
							}
						}
						else if(y+c[z]>=255){
							if(dp[1][255]>=dp[0][y]+pow(x-255,2)){
								dp[1][255]=dp[0][y]+pow(x-255,2);
							}
						}
						else{
							if(dp[1][y+c[z]]>=dp[0][y]+pow(x-y-c[z],2)){
								dp[1][y+c[z]]=dp[0][y]+pow(x-y-c[z],2);
							}
						}
					}
				}
			}
			REP(b,256){
				dp[0][b]=dp[1][b];
				dp[1][b]=INF;
			}
		}
		REP(a,256)if(dp[0][a]<ans) ans = dp[0][a];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h> 
 #include <ctype.h> 
 
 
 int main(){ 
     char ch; 
     while(1){         
     scanf("%c", &ch); 
         if(ch=='\n'){ 
             printf("\n"); 
             break; 
         }else if(islower(ch)){ 
             printf("%c", toupper(ch)); 
         }else if(isupper(ch)){ 
            printf("%c", tolower(ch)); 
        }else{ 
             printf("%c", ch); 
         } 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2612
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << c << " " << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (n); i++)
int main(){
int n=0, a=0, b=0;
cin >> n >> a >> b;
int sum=0;
rep(i, n+1){
    int ii=0;
    ii=i;
    int sum_keta=0;
    rep(j, 5){
        sum_keta += ii%10;
        ii=ii/10;
    }
    if (a<=sum_keta && sum_keta<=b) sum += i;
}
cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


namespace geom {

using Float = double;
using Point = complex<Float>;
constexpr Float EPS = 1e-9;

inline int sgn(const Float &r) {
	return (r > EPS) - (r < -EPS);
}
bool operator==(const Point &a, const Point &b) {
	bool xeq = sgn(real(a) - real(b)) == 0;
	bool yeq = sgn(imag(a) - imag(b)) == 0;
	return xeq && yeq;
}
bool operator<(const Point &a, const Point &b) {
	Float xsgn = sgn(real(a) - real(b));
	if (xsgn == 0) {
		return sgn(imag(a) - imag(b)) < 0;
	}
	return xsgn < 0;
}

Float dot(const Point &a, const Point &b) {
	return real(conj(a)*b);
}
Float cross(const Point &a, const Point &b) {
	return imag(conj(a)*b);
}

struct Circle {
	Point center;
	Float radius;

	Circle() {}
	Circle(const Point &center, const Float &radius)
		: center(center), radius(radius) {}

	// 1: interior, 0: boundary, -1: exterior
	int relation(const Point &p) {
		return sgn(radius - abs(p - center));
	}
};

vector<Point> intersection(const Circle &a, const Circle &b) {
	Point p = b.center - a.center;
	Float d = norm(p);
	Float t = (d + a.radius*a.radius - b.radius*b.radius) / 2.;
	Float q = d*a.radius*a.radius - t*t;
	int qsgn = sgn(q);
	vector<Point> ret;
	if (qsgn < 0) return ret;
	ret.emplace_back(
		(t*real(p) + imag(p)*sqrt(q)) / d,
		(t*imag(p) - real(p)*sqrt(q)) / d
	);
	if (qsgn > 0) {
		ret.emplace_back(
			(t*real(p) - imag(p)*sqrt(q)) / d,
			(t*imag(p) + real(p)*sqrt(q)) / d
		);
	}
	for (auto &x : ret) {
		x += a.center;
	}
	return ret;
}

}

int main() {
	int n, k; cin >> n >> k;
	vector<geom::Circle> circ(n);
	for (int i = 0; i < n; i++) {
		geom::Float a, b, r;
		cin >> a >> b >> r;
		circ[i].center = { a, b };
		circ[i].radius = 1. / r;
	}

	auto cntp = [&](geom::Point p) {
		int cnt = 0;
		for (const auto &c : circ) {
			cnt += geom::sgn(abs(p - c.center) - c.radius) <= 0;
		}
		return cnt;
	};
	double lo = 0, hi = 1e9;
	for (int iter = 0; iter < 100; iter++) {
		double mid = (lo + hi) / 2;
		for (auto &c : circ) c.radius *= mid;
		bool flag = false;
		for (const auto &c : circ) {
			flag |= cntp(c.center) >= k;
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				auto v = move(geom::intersection(circ[i], circ[j]));
				for (const auto& p : v) {
					flag |= cntp(p) >= k;
				}
			}
		}
		if (flag) hi = mid;
		else lo = mid;
		for (auto &c : circ) c.radius /= mid;
	}
	printf("%.10f\n", lo);
	return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))

mc = 0
absum = 0
absmin = 10**9+7

for a in A:
    if a < 0:
        mc += 1
    absum += abs(a)
    absmin = min(absmin,abs(a))

if mc%2 == 0:
    ans = absum
else:
    ans = absum-absmin*2

print(ans)


Measured memory_bytes: 14412
import math

args = input().split("\n")[0].split()
A = int(args[0])
B = int(args[1])
H = int(args[2])
M = int(args[3])

S = 360/720*(H*60+M)
L = 360/60*M
tmp = abs(L-S)

print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.pi*(min(tmp,360-tmp))/180)))

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

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int X=int.Parse(str[0]);
      int Y=int.Parse(str[1]);
      int ans=0;
      for(int i=X;i<=Y;i++){
      var rev=new string(i.ToString().Reverse().ToArray());
    if(i.ToString()==rev){
      ans++;
    }
      }
      Console.WriteLine(ans);
    }
    
  }

}

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

int i,j,w,h;
string tile[21];
int cnt=0;
int result=0;
int si,sj;

void rec(int i,int j){
  if(tile[i][j]=='.'){
    tile[i][j]='#';
    cnt++;
  }

  if(i+1 < h && tile[i+1][j]=='.')  rec(i+1,j);
  if(j+1 <w && tile[i][j+1]=='.')  rec(i,j+1);
  if(j-1 >=0 && tile[i][j-1]=='.')  rec(i,j-1);
  if(i-1 >=0 && tile[i-1][j]=='.' )  rec(i-1,j);
}

int main(){

  while(1){
    cnt=0;
    result=0;
  cin >> w >> h;
  if(w==0 && h==0)break;
  for(i = 0; i < h; i++){
    cin >> tile[i];
    for(j = 0; j < w; j++){
     
      if(tile[i][j]=='@'){
	si=i;
	sj=j;
      }
    }
  }
 
  rec(si,sj);
 
 
  cout << cnt+1 << endl;
  }
  return 0;
}

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

int main() { 
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    // auto list = vector<string>();
    auto offset = string::size_type(0);
    string sep = "AC";
    auto idx = vector<int>();
    while(true) {
        auto pos = S.find(sep, offset);
        if (pos == string::npos) {
            break;
        }
        // cout << S << endl;
        // cout << "pos=" << pos << ", offset=" << offset << endl;
        idx.push_back(pos);
        offset = pos+sep.length();
    }
    // for (auto v: idx) {
    //     cout << v << endl;
    // }


    for (int i=0; i<Q; i++) {
        int l, r; cin >> l >> r;
        int ct = 0;
        l--; r--;
        // cout << "l=" << l << ", r=" << r << endl;
        for (auto id: idx)  {
            if (l<=id && id+1<=r) ct++;
        }
        cout << ct << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int r=tx-sx;
    int u=ty-sy;
    rep(i,r){
        cout<<'R';
    }
    rep(i,u){
        cout<<'U';
    }
    rep(i,r){
        cout<<'L';
    }
    rep(i,u+1){
        cout<<'D';
    }
    rep(i,r+1){
        cout<<'R';
    }
    rep(i,u+1){
        cout<<'U';
    }
    cout<<"LU";
    rep(i,r+1){
        cout<<'L';
    }
    rep(i,u+1){
        cout<<'D';
    }
    cout<<"R"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int i, n;
	short a[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');
	return 0;
}



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

int main(){
  long long int a,b,k;
  cin >>a>>b>>k;
  for(int i=0;i<k/2;i++){
    a = a/2;
    b += a;
    b = b/2;
    a += b;
  }
  if(k%2 == 1){
    a = a/2;
    b += a;
  }
  cout << a <<" " <<b <<endl;
}

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

using namespace std;

const int inf = 0x3f3f3f3f;

int n, m;
int pd[100010];
vector <int> adj[100010];

int solve(int x){
  if(pd[x] != -1) return pd[x];

  pd[x] = 0;

  for(int i=0 ; i<adj[x].size() ; i++){
    int u = adj[x][i];
    if(pd[u] == -1){
      int aux = solve(u);
      pd[x] = max(pd[x], aux + 1);
    }else{
      pd[x] = max(pd[x], pd[u] + 1);
    }
  }

  return pd[x];
}

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

  for(int i=0 ; i<m ; i++){
    int x, y;
    cin>>x>>y;

    adj[x].push_back(y);
  }

  memset(pd, -1, sizeof pd);
  int maior = 0;

  for(int i=1 ; i<=n ; i++){
    if(pd[i] == -1){
      int aux = solve(i);
      maior = max(maior, aux);
    }
  }

  cout<<maior<<endl;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int n,k;
bool vis[105][105];
int main()
{
    scanf("%d%d",&n,&k);
    if(k>(n-2)*(n-1)/2) printf("-1\n");
    else
    {
        printf("%d\n",n*(n-1)/2-k);
        for(int i=1;i<=n-2&&k;i++)
            for(int j=i+1;j<=n-1&&k;j++)
            {
                k--;
                vis[j][i]=vis[j][i]=true;
            }
        for(int i=1;i<=n;i++)
            for(int j=1;j<i;j++)
        if(vis[i][j]==false)
            printf("%d %d\n",i,j);
    }
}


Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())
A = sorted(A, reverse = False)
count = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if (A[i] != A[j] != A[k]) and (A[k] < A[i] + A[j]):
                count += 1

print (count)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll N, x;
    cin >> N >> x;
    ll M = 2 * N - 1;

    if (x == 1 || x == M) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    ll a = 2;
    for (ll i = 1; i < N - 1; i++) {
        if (a == x)
            a++;
        cout << a << endl;
        a++;
    }
    cout << 1 << endl;
    cout << x << endl;
    cout << M << endl;
    for (ll i = 1; i < N - 1; i++) {
        if (a == x)
            a++;
        cout << a << endl;
        a++;
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define For(i,a,b) for(ll i=(a); i<(b); ++i)
using namespace std;
typedef unsigned long long ll;

int main(){
	ll n,sum=0,p=1;
	cin>>n;
	while(n)
		n/=2,sum+=p,p*=2;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 200000;
const int MAXQ = 200000;
const int MAXS = 4 * MAXN;
typedef struct Q { int l, r; } Q;
bool operator<(const Q &a, const Q &b) { return a.l < b.l; }

int n;
int b[MAXN];
int nq;
Q q[MAXQ];

int slazy[MAXS];
int sval[MAXS];

void sapply(int x, int by) {
	if (sval[x] != INT_MAX) sval[x] += by;
	slazy[x] += by;
}
void spush(int x) {
	if (slazy[x] == 0) return;
	sapply(2 * x + 1, slazy[x]), sapply(2 * x + 2, slazy[x]), slazy[x] = 0;
}
void spull(int x) {
	sval[x] = min(sval[2 * x + 1], sval[2 * x + 2]);
}
void sinit(int x, int l, int r) {
	slazy[x] = 0, sval[x] = INT_MAX;
	if (l != r) {
		int m = l + (r - l) / 2;
		sinit(2 * x + 1, l, m); sinit(2 * x + 2, m + 1, r);
	}
}
void sinc(int x, int l, int r, int L, int R) {
	if (L <= l&&r <= R) {
		sapply(x, +1);
	} else {
		spush(x);
		int m = l + (r - l) / 2;
		if (L <= m) sinc(2 * x + 1, l, m, L, R);
		if (m + 1 <= R) sinc(2 * x + 2, m + 1, r, L, R);
		spull(x);
	}
}
int sget(int x, int l, int r, int L, int R) {
	if (L <= l&&r <= R) {
		return sval[x];
	} else {
		spush(x);
		int m = l + (r - l) / 2;
		int ret = INT_MAX;
		if (L <= m) ret = min(ret, sget(2 * x + 1, l, m, L, R));
		if (m + 1 <= R) ret = min(ret, sget(2 * x + 2, m + 1, r, L, R));
		spull(x);
		return ret;
	}
}
void supd(int x, int l, int r, int IDX, int VAL) {
	if (l == r) {
		sval[x] = min(sval[x], VAL);
	} else {
		spush(x);
		int m = l + (r - l) / 2;
		if (IDX <= m) supd(2 * x + 1, l, m, IDX, VAL);
		if (m + 1 <= IDX) supd(2 * x + 2, m + 1, r, IDX, VAL);
		spull(x);
	}
}

void run() {
	scanf("%d", &n); REP(i, n) scanf("%d", &b[i]);
	scanf("%d", &nq); REP(i, nq) scanf("%d%d", &q[i].l, &q[i].r), --q[i].l, --q[i].r; sort(q, q + nq);

	sinit(0, 0, n);
	supd(0, 0, n, 0, 0);
	int qi = 0;
	REP(i, n) {
		while (qi < nq&&q[qi].l == i) {
			int ql = q[qi].l, qr = q[qi].r; ++qi;
			int now = sget(0, 0, n, i, qr + 1); // minimum current cost for states that have qr+1 unmarked
			supd(0, 0, n, qr + 1, now);
		}
		if (b[i] == 0) sinc(0, 0, n, i + 1, n); // all states that end >=i gain one cost
		int cur = sget(0, 0, n, i, i); // current cost when not having marked i
		supd(0, 0, n, i + 1, cur + (b[i] == 0 ? 0 : 1)); // do not mark i
	}
	int ret = sget(0, 0, n, n, n);
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 8832
N,M = map(int,input().split())
MOD = 10**9 + 7
a = []
broken = [False for i in range(N+1)]
for i in range(M):
	x = int(input())
	a.append(x)
	broken[x] = True

for i in range(M-1):
	if a[i+1]-a[i] == 1:
		print(0)
		exit()

dp = [0 for i in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
	if broken[i]:
		continue
	if i == 1:
		dp[i] = dp[i-1]
	else:
		dp[i] = (dp[i-2] + dp[i-1]) % MOD
print(dp[N])


Measured memory_bytes: 8188
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n, m;
		cin >> n >> m;

		if ( !( n | m ) )
		{
			break;
		}

		vector< vector< PII > > G( n );

		REP( i, 0, m )
		{
			int a, b, c;
			cin >> a >> b >> c;

			G[a].PB( MP( b, c ) );
			G[b].PB( MP( a, c ) );
		}

		priority_queue< PII, vector< PII >, greater< PII > > que;
		que.push( MP( 0, 0 ) );

		vector< bool > used( n, false );

		int res = 0;

		while ( !que.empty() )
		{
			auto cur = que.top();
			que.pop();

			if ( used[ cur.snd ] )
			{
				continue;
			}

			used[ cur.snd ] = true;
			res += cur.fst;

			EACH( e, G[ cur.snd ] )
			{
				auto next = MP( e.snd, e.fst );

				que.push( next );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
n=int(input())
a=list(map(int,input().rstrip().split()))
b=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
a.insert(0,0)
b.insert(0,0)
c.insert(0,0)
#print(a,b,c)

sum1=0
sum1+=b[a[1]]
for i in range(2,n+1):
    if a[i]==a[i-1]+1:
        sum1+=b[a[i]]
        sum1+=c[a[i-1]]
    else:
        sum1+=b[a[i]]
    
print(sum1)
        
    

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

int n,m,k;
int food[15];
int a[1005000];
queue<int> q;

int run(int i,int i0){
	queue<int> empty;
	swap(q,empty);
	for(int i1=0;i1<n*m;i1++){
		if(a[i1]>0)a[i1]=0;
	}
	q.push(i);
	a[i]=1;
	while(!q.empty()){
		i = q.front();
		q.pop();
//		printf("from:%d %d %d\n",i/m,i%m,a[i]);
		if(i==i0)return a[i]-1;
		for(int di=-1;di<=1;di++){
			for(int dj=-1;dj<=1;dj++){
				if(((di^dj)&1)==0)continue;
				if(a[i+di*m+dj]!=0)continue;
				a[i+di*m+dj] = a[i] + 1;
//				printf("\tto:%d %d %d\n",i/m+di,i%m+dj,a[i+di*m+dj]);
				q.push(i+di*m+dj);
			}
		}
	}
	return -1;
}

int main(){
	cin>>n>>m>>k; 
	string s;
	m+=2;n+=2;
	for(int i=0;i<n;i++){
		if(i%(n-1)!=0)cin>>s;
		for(int j=0;j<m;j++){
			if(i%(n-1)==0||j%(m-1)==0)a[i*m+j]=-1;
			else{
				a[i*m+j] = s[j-1]=='X'?-1:0;
				if(s[j-1]>'0'&&s[j-1]<='9'){
					food[s[j-1]-'0']=i*m+j;
				}else if(s[j-1]=='S'){
					food[0]=i*m+j;
				}
			}
		}
	}
	
	int end = 0;
	for(int i=1;i<=k;i++){
		end += run(food[i-1],food[i]);
//		printf("%d   step:%d\n",i,run(food[i-1],food[i]));
//		for(int x=0;x<n;x++){
//			for(int y=0;y<m;y++){
//				printf("%d\t",a[x*m+y]);
//			}
//			printf("\n");
//		} 
	}
	cout<<end<<endl;
	return 0;
}


Measured memory_bytes: 7000
using System;


class AOJ
{

    public static void Main()
    {
        while (true)
        {
            string[] s = Console.ReadLine().Split(' ');
            
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);

            if (x == 0 && y == 0) break;

            DateTime dt = new DateTime(2004, x, y);
            Console.WriteLine(dt.DayOfWeek);
        }
    }
}

Measured memory_bytes: 5752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    string s; cin >> s;
    vector<char> b;
    int ans=0;
    rep(i,s.length()){
        if(b.empty()){
            b.push_back(s[i]);
            continue;
        }
        if(b[0]!=s[i]){
            b.erase(b.begin());
            ans+=2;
        }
        else b.push_back(s[i]);
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int  n,k;
  	cin>>n>>k;
  	vector<int> h(n);
  	int mymin=1000000000;
  	for(int  i=0;i<n;i++){
    	cin>>h.at(i);
    }
  	sort(h.begin(),h.end());
  	for(int  i=0;i<n-k+1;i++){
    	mymin=min(mymin,h.at(i+k-1)-h.at(i));
    }
  	cout<<mymin<<endl;
  
}


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

int *countingSort(int *array, size_t length, int max)
{
  int i, *counts, *working;
  // allocate the counts array and working array
  counts = (int *) malloc((max+1)*sizeof(int));
  working = (int *) malloc(length*sizeof(int));
  // initialize all the counts to 0
  memset(counts, 0, max+1);
  // set the elements of counts array to the number of each element
  // in the input array
  for ( i = 0; i < length; i++ )
    counts[array[i]] += 1;
  // set the elements of counts array to the number of each element less
  // than or equal to it in the input array
  for ( i = 1; i <= max; i++ )
    counts[i] += counts[i-1];
  // set each element in the working array to the proper element
  // from the input array
  for ( i = 0; i < length; i++ )
    working[--counts[array[i]]] = array[i];
  // free all the arrays except the working array
  free(array);
  free(counts);
  return working;
}

int main()
{
  int max = INT_MIN, i, *array;
  size_t length;
  // get input
  scanf(" %lud", &length);
  array = (int *) malloc(length*sizeof(int));
  for ( i = 0; i < length; i++ )
    {
      scanf(" %d", array+i);
      // find k (the max value in array)
      if ( array[i] > max )
	max = array[i];
    }
  // countingSort the array
  array = countingSort(array, length, max);
  // print the array
  for ( i = 0; i < length; i++ )
    printf("%d%c", array[i], i == length-1 ? '\n' : ' ');
  free(array);
  return 0;
}



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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;


class AFrog1 {
public:
    void init() {
    }

    void solve(istream &cin, ostream &cout) {
        init();
        int n;
        cin >> n;
        int dp[3] = {}, h[3] = {};
        int dp0 = 0, dp1 = 0, ans = 0;
        int stone0 = 0, stone1 = 0, curStone;
        for (int i = 0; i < n; i++) {
            int ii = i % 3;
            int j = ((i - 1) % 3 + 3) % 3;
            int k = ((i - 2) % 3 + 3) % 3;
            cin >> h[ii];
            if (i == 0)
                continue;
            else if (i == 1) {
                dp[ii] = abs(h[ii] - h[j]);
                continue;
            }
            dp[ii] = min(dp[j] + abs(h[ii] - h[j]), dp[k] + abs(h[ii] - h[k]));
        }
        cout << dp[(n - 1) % 3] << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	AFrog1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <cmath>
//const double PI = 3.141592653589793;

using namespace std;
int main()
{
    int n;
    cin>>n;
    int a;
    map<int,int>m;
    for(int i=0;i<n-1;i++)
    {
        cin>>a;
        m[a]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
    /*int i=m.size();
    while(i<n)
    {
        cout<<0<<endl;
        i++;
    }*/
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  bool flag = true;
  vector<string> v(n);
  char w;
  string t;
  REP (i, n) {
    cin >> t;
    if (i > 0 && t[0] != w) flag = false;
    w = t[t.size() - 1];
    v[i] = t;
  }

  sort(v.begin(), v.end());
  FOR (i, 1, n) {
    if (v[i - 1] == v[i]) flag = false;
  }

  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;int s=0;
	for(int i=max(1LL,k);i<=n;i++)
	{
		s+=(i-k)*(n/i);
		s+=max(n%i-(k-1), 0LL);
	}
	if(k==0)s-=n;
	cout<<s;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    vector<ll> cnt(2019, 0), ac(s.size()+1, 0);
    reverse(ALL(s));
    ll res = 0;
    ll base = 1;
    cnt[0]++; // 2019の倍数は1つでもあれば答えに数えられる
    for(int i=0; i<s.size(); i++){
        ac[i+1] = (ac[i] + (s[i] - '0')*base%2019)%2019;
        cnt[ac[i+1]%2019]++;
        base = base*10%2019;
    }
    REP(i, 2019){
        if(cnt[i] != 0) res += cnt[i]*(cnt[i]-1)/2;
    }
    //cout << ac << endl;
    cout << res << endl;
}

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

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define ll long long
#define be(v) v.begin(), v.end()

int main() {
	string s; cin >> s;
	int count = 0;
	rep(i,s.size()-1) {
		if(s[i] == s[i+1]) {
			count ++;
			if(s[i] == '0') s[i+1] = '1';
			else s[i+1] = '0';
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll ppp(ll x, ll k){
    ll res = 1;
    if(k == 0) return 1;
    res = ppp(x * x % mod, k/2);
    if(k & 1) res = res * x % mod;
    return res;
}
int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    cout<<ppp(n, m)<<endl;
    return 0;
}


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

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    vector<int> len(N,0);
    rep(i,N-1){
        for (int j=i+1;j<N;j++){
            int step = min(j-i, abs(X-i)+abs(Y-j)+1);
            len[step]++;
        }
    }
    for (int i=1;i<N;i++){
        cout << len[i] << endl;
    }
    return 0;
} 

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

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

int main()
{
    const int day = 24 * 60 * 60;
    vector<int> imos;
    int n;
    while(cin >> n,n){
        imos.assign(day + 1, 0);
        for(int i=0;i<n;i++){
            string s,t;
            cin >> s >> t;
            int ts = stoi(s.substr(0,2)) * 60 * 60 + stoi(s.substr(3,2)) * 60 + stoi(s.substr(6,2));
            int tt = stoi(t.substr(0,2)) * 60 * 60 + stoi(t.substr(3,2)) * 60 + stoi(t.substr(6,2));
            // cerr << s << " " << t << " " << ts << " " << tt << endl;
            imos[ts]++;imos[tt]--;
        }
        for(int i=0;i<day;i++){
            imos[i+1] += imos[i];
        }
        int res = 1;
        for(int i=0;i<day+1;i++){
            res = max(res,imos[i]);
        }
        // cerr << imos[10800] << endl;
        cout << res << endl;
    }

}




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

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

    for(int n=1;;n++){
        if(n*(n-1)/2 < X && X <= (n+1)*n/2){
            cout << n << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    q = I()
    m = LI()
    M = max(m)
    l = [i for i in a[:n>>1]]
    r = [i for i in a[n>>1:]]
    nl = len(l)
    nr = len(r)
    fl = [0]*(M+1)
    fr = [0]*(M+1)
    for b in range(1<<nl):
        s = 0
        for i in range(nl):
            if b&(1<<i):
                s += l[i]
        if s <= M:
            fl[s] = 1
    for b in range(1<<nr):
        s = 0
        for i in range(nr):
            if b&(1<<i):
                s += r[i]
        if s <= M:
            fr[s] = 1
    f = [0]*(M+1)
    for i in range(M+1):
        if not fl[i]:
            continue
        for j in range(M+1-i):
            if fr[j]:
                f[i+j] = 1
    for i in m:
        print(["no","yes"][f[i]])
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6112
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;


class Compress {
public:
    vector<long long> v;
    map<long long, long long> rev;
    
    // ??§?¨???§?????????
    // vec????????¨????????±??????????????????????????????????????????????´???????????????????
    Compress(vector<long long> vec) {
        this->v = vec;
        sort(this->v.begin(), this->v.end());
        this->v.erase(unique(this->v.begin(), this->v.end()), this->v.end());
        
        for (long long x : v) {
            rev[this->zip(x)] = x;
        }
    }

    long long zip(long long x) {
        return lower_bound(ALL(this->v), x) - this->v.begin();
    }

    long long unzip(long long x) {
        return this->rev[x];
    }
};


int main(int argc, char *argv[]) {
    LL N, X1, Y1, X2, Y2;
    
    cin >> N;
    vector<LL> allX(N), allY(N);
    vector<LL> x1(N), y1(N), x2(N), y2(N);
    FOR(i, 0, N) {
        cin >> X1 >> Y1 >> X2 >> Y2;
        x1[i] = X1;
        y1[i] = Y1;
        x2[i] = X2;
        y2[i] = Y2;
        
        allX.push_back(X1);
        allX.push_back(X2);
        allY.push_back(Y1);
        allY.push_back(Y2);
    
    }
    allX.push_back(1000000001);
    allY.push_back(1000000001);
    
    // ??§?¨???§???
    Compress cx(allX);
    Compress cy(allY);
    
    
    vector<vector<int>> field(5100, vector<int>(5100, 0));
    FOR(i, 0, N) {
        field[cy.zip(y1[i])][cx.zip(x1[i])]++;
        field[cy.zip(y2[i])][cx.zip(x2[i])]++;
        field[cy.zip(y1[i])][cx.zip(x2[i])]--;
        field[cy.zip(y2[i])][cx.zip(x1[i])]--;
    }
    
    // ?´???????
    FOR(y, 0, field.size() - 1) {
        FOR(x, 1, field[0].size() - 1) {
            field[y][x] += field[y][x-1];
        }
    }
    FOR(x, 0, field[0].size()) {
        FOR(y, 1, field.size()) {
            field[y][x] += field[y-1][x];
        }
    }
    
    LL area = 0;
    FOR(y, 0, field.size() - 1) {
        FOR(x, 0, field[0].size() - 1) {
            if (field[y][x]) {
                area += (cx.unzip(x + 1) - cx.unzip(x)) * (cy.unzip(y + 1) - cy.unzip(y));
            }
        }
    }

    cout << area << endl;
}

Measured memory_bytes: 105564
#include <iostream>
using namespace std;
int main() {
  int n, a, b = ~(1<<31), w;
  cin >> n;
  for (int i = n; i--; ) {
    cin >> a;
    b &= (a & -a) - 1;
  }
  for (w = 0; b; w++, b>>=1);
  cout << w << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli i,n,j;
		cin>>n;
		string s[n];
		for(i=0;i<n;i++)
		cin>>s[i];
		map<char,lli> mp[n];
		map<map<char,lli>,lli> mpf;
		for(i=0;i<n;i++)
		{
			for(j=0;j<10;j++)
			{
				mp[i][s[i][j]]++;
			}
		}
		for(i=0;i<n;i++)
		{
			mpf[mp[i]]++;
		}
		lli ans=0;
		for(auto itr=mpf.begin();itr!=mpf.end();itr++)
		{
			n=itr->S;
			if(n==1)
			continue;
			else
				ans+=((n*(n-1))/2);
		}
		cout<<ans<<endl;
	}
}
/*
contest
tt
*/


Measured memory_bytes: 125184
S = input()
N = len(S)
ans = [1] * (N)

for i in range(N - 2):
    if S[i] == 'L':
        continue
    if S[i + 1] == 'R':
        ans[i + 2] += ans[i]
        ans[i] = 0

for i in range(2, N)[:: -1]:
    if S[i] == 'R':
        continue
    if S[i - 1] == 'L':
        ans[i - 2] += ans[i]
        ans[i] = 0

print(*ans)

Measured memory_bytes: 6400
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = list(map(lambda x, y: x-y, A, B))

C_neg = list(filter(lambda x: x < 0, C))
C_pos = list(filter(lambda x: x > 0, C))
len_odd_neg = len(list(filter(lambda x: x % 2 == 1, C_neg)))
pos_sum = sum(C_pos)
neg_sum = sum(C_neg)+len_odd_neg

if pos_sum <= abs(neg_sum)//2:
    ans = "Yes"
else:
    ans = "No"
print(ans)


Measured memory_bytes: 4596
import scala.io.StdIn._
import scala.collection.mutable

object Main extends App {
  val Array(n, a) = readLine().split(' ').map(_.toInt)
  val values = readLine().split(' ').map(_.toInt).map(_ - a).toList

  val table = values.foldLeft(mutable.Map(0 -> 1L)) { (table, n) =>
    table.clone().foreach { case (k , v) => table.update(k + n, table.getOrElse(k + n, 0L) + v ) }
    table
  }

  println(table(0) - 1)
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    string s;
    cin>>n>>s;

    int ans=0,cnt=0;
    string abc="ABC";

    rep(i,n){
       if(s[i]==abc[cnt]){
           if(cnt==2)ans++;
           cnt=(cnt+1)%3;
       }else if(s[i]=='A'){
           cnt=1;
       }else{
           cnt=0;
       }
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int A[200010];
int cnt[200010];

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

    cin >> N;
    REP (i, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    int sum = 0;
    REP (i, 200010) {
        int c = cnt[i];
        sum += c * (c - 1) / 2;
    }
    REP (i, N) cout << sum - cnt[A[i]] + 1 << endl;
}

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    s = input()
    k = int(input())
    extracted = list()
    s_len = len(s)

    for i in range(1, min(k, s_len) + 1):
        start = 0
        ended = i

        for j in range(s_len - i + 1):
            sub_str = s[start:ended]

            if sub_str not in extracted:
                extracted.append(sub_str)

            start += 1
            ended += 1

    sorted_extracted = sorted(extracted)
    print(sorted_extracted[k - 1])


Measured memory_bytes: 4084