akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    char l;
    int sum = 0;
    for (int i = 0; cin >> l; i++) {
        if (l == '\\') S1.push(i);
        else if (l == '/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define ppb pop_back
#define ppf pop_front
#define W 1
#define B 2
#define G 3
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int row[]={-1,0,1,0};
int col[]={0,1,0,-1};

const ll N=60;
const ll M=1e7+19;

ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m


int main()
{
    
    fast_in_out;
    
    int a,b;
    cin>>a>>b;
    
    cout<<(a*3+b)/2<<endl;
    
    return 0;
}



//CoU Algo Marathon 01(BFS,DFS) [Cloned]

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e6 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;



int n, m, q, a[N], b[N], c[N], d[N], e[N], ans;

void rec (int i = 2) {
	if (i == n + 1) {
		int res = 0;
		for (int j = 1; j <= q; ++j)
			if (e[b[j]] - e[a[j]] == c[j])
				res += d[j];
//		cout << res << endl;
		ans = max(ans, res);
		return;
	}

	for (int x = e[i - 1]; x <= m; ++x) {
		e[i] = x;
		rec(i + 1);
	}	
}

main () {
	cin >> n >> m >> q;
	for (int i = 1; i <= q; ++i)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	e[1] = 1;
	rec();

	cout << ans << endl;	
}




Measured memory_bytes: 3628
(let* ((n (read))
       (m (read)))
  (format t "~f" (coerce (* (/ 1 n)
                               (loop :for k :from 1 :upto n :sum(if (< k m)
                                                                    (expt (/ 1 2) (ceiling (log (/ m k) 2)))
                                                                    1))) 'double-float)))

Measured memory_bytes: 14692
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int N,M,ans = 0;
map<string,int> a;

int main() {
	string s;
	
	cin >> N;
	REP(i, 0, N) cin >> s, a[s]++;

	cin >> M;
	REP(i, 0, M) cin >> s,a[s]--;
	
	for(auto itr = a.begin(); itr != a.end(); ++itr) {
		ans = MAX(ans, itr->second);
    }
	
	cout << ans;

	return 0;
}


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

int main(){
    int n;
    cin >>n;
    int p[n];
    rep(i,n) cin >>p[i];
    int ans=0;
    int mi=INT_MAX;
    for(int i=0;i<n;i++){
        mi=min(mi,p[i]);
        if(mi==p[i]) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
N,Y =  map(int,input().split())	
a = 0
b = 0
c  = 0
for i in range(N+1):
    for j in range(N-i+1):
            if 10000*i+5000*j+1000*(N-i-j) == Y:
                    a=i
                    b=j
                    c=N-i-j
        
if(a>0)|(b>0)|(c>0):
    print(a,b,c)
elif (a==0)&(b ==0)&(c == 0):
    print(-1,-1,-1)

Measured memory_bytes: 3064
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let A = xs[0];
   let B = xs[1];
   let C = xs[2];
   let ans = Math.floor(B/A);
  
   if(C<=ans){
      console.log(C);
   }else{
      console.log(ans);
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n);
	std::vector<std::vector<uint32>> G(n);
	for (uint32 i = 1;i < n;++i) {
		std::cin >> a[i];
		--a[i];
		G[a[i]].push_back(i);
	}
	std::function<uint32(uint32)> dfs = [&](uint32 v)->uint32 {
		if (G[v].size() == 0) return 0;
		std::vector<uint32> dp;
		for (uint32 i = 0;i < G[v].size();++i) {
			dp.push_back(dfs(G[v][i]));
		}
		std::sort(dp.begin(), dp.end());
		uint32 ret = 0;
		for (uint32 i = 0;i < dp.size();++i) {
			ret = std::max(ret + 1, dp[i] + 1);
		}
		return ret;
	};
	std::cout << dfs(0) << "\n";
	return 0;
}

Measured memory_bytes: 14336
S = input()
S_list = list(S)
T = input()
T_list = list(T)
count = 0
if(S==T):
  print("0")
  exit()
for i in range(len(S_list)):
  if(S_list[i]!=T_list[i]):
    count += 1
    
    
print(count)

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

using namespace std;

map<int, int> hsh;

vector<int> primes{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

void divs(int x) {
  while (x>1) {
    for (auto &p : primes) {
      if (x%p == 0) { 
        hsh[p]++;
        x /= p;
      }
    }
  }
}

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

  int n;
  cin >> n;
  int mod = 1e9+7;
  
  for (int i = 1; i <= n; ++i) divs(i);

  long long res = 1;
  for (auto &h : hsh) {
    res = (res * (h.second+1))%mod;
  }

  cout << res << endl;
  
  return 0;
}



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

int main(void) {
	int n, l;
	cin >> n >> l;
	string s[101];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	sort(s, s + n);
	
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i=1,n;
    long int ans=0;
    scanf("%d",&n);

    while(i<=n){
        if( (i%3!=0) && (i%5!=0) ){
            ans += (long int)i;
        }
        i++;
    }

    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 1712
#include <cstdio>
#include <algorithm>
using namespace std;

int a[4];
int res;

int main()
{
	int i;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	sort(a, a+3);
	res = 1;
	for(i=0; i<2; i++){
		if(a[i] != a[i+1])
			res ++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>

int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    auto bucket = std::array<bool, 26>({false});
    for(char c: in_str)
    {
        bucket[c - 'a'] = true;
    }

    for(int i=0; i<26; ++i)
    {
        auto a = bucket[i];
        if(!a)
        {
            std::cout << (char)('a' + i) << std::endl;
            return 0;
        }
    }

    std::cout << "None" << std::endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	string s;
	cin >> s;
	for ( int i = 0 ; i < s.length()-1 ; i++ ) {
		if ( s[i] == s[i+1] ) {
			cout << i + 1 << ' ' << i + 2;
			return 0;
		}
		else if ( s[i] == s[i+2] ) {
			cout << i + 1 << ' ' << i + 3;
			return 0;
		}
	}
	cout << -1 << ' ' << -1;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>

using namespace std;

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

    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
from operator import attrgetter


class City:
    def __init__(self, p, y):
        self.p = p
        self.y = y

    def set_num(self, n):
        p = str(self.p)
        _p = list(p)
        l_p = len(_p)
        if l_p < 6:
            num = 6 - l_p
            for i in range(num):
                p = "0" + p

        n = str(n)
        _n = list(n)
        l_n = len(_n)
        if l_n < 6:
            num = 6 - l_n
            for i in range(num):
                n = "0" + n
        self.n = p+n


N, M = map(int, input().split())
cities = []
for _ in range(M):
    p, y = map(int, input().split())
    cities.append(City(p, y))

pref_map = {}
for city in cities:
    if city.p in pref_map:
        pref_map[city.p].append(city)
    else:
        pref_map[city.p] = [city]

for v in pref_map.values():
    _cities = sorted(v, key=attrgetter("y"))
    cnt = 1
    for _city in _cities:
        _city.set_num(cnt)
        cnt += 1

for city in cities:
    print(city.n)


Measured memory_bytes: 50076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  vector<int> a(3);
  rep(i,3){
    cin>>a[i];
  }
  sort(ALL(a));
  reverse(ALL(a));
  int res=a[0]*10+a[1]+a[2];
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
numbers :: [Int]
numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

main :: IO ()
main = do
  k <- readLn
  print $ numbers !! (k-1)


Measured memory_bytes: 508
# ABC156c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    n = int(input())
    x = list(map(int, input().split()))
    import math
    cost = 10 ** 11
    for i in range(min(x), max(x) + 1):

        t = 0
        for j in x:
            t += (j - i) ** 2

        cost = min(cost, t)
        #print(i, cost)
    print(cost)


if __name__ == '__main__':
    main()


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

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

  int x[n], y[n];
  set<int> s_x, s_y;
  for (int i=0; i<n; i++) {
    cin>>x[i]>>y[i];
    s_x.insert(x[i]);
    s_y.insert(y[i]);
  }
  vector<long long> v_x(s_x.begin(), s_x.end());
  vector<long long> v_y(s_y.begin(), s_y.end());
  sort(v_x.begin(), v_x.end());
  sort(v_y.begin(), v_y.end());
  int w = v_x.size();
  int h = v_y.size();
  pair<int, int> c_p[n];
  for (int i=0; i<n; i++) {
    int c_x = find(v_x.begin(), v_x.end(), x[i]) - v_x.begin();
    int c_y = find(v_y.begin(), v_y.end(), y[i]) - v_y.begin();
    c_p[i] = make_pair(c_x, c_y);
  }
  sort(c_p, c_p + n);

  long long ans = 1e18 * 4;
  for (int x1=0; x1<w; x1++) {
    for (int y1=0; y1<h; y1++) {
      for (int x2=x1+1; x2<w; x2++) {
        for (int y2=y1+1; y2<h; y2++) {
          int start = lower_bound(c_p, c_p + n, make_pair(x1, 0)) - c_p;
          int cnt = 0;
          for (int i=start; i<n; i++) {
            int xi = c_p[i].first;
            int yi = c_p[i].second;
            if (xi >= x1 && xi <= x2 && yi >= y1 && yi <= y2) {
              ++cnt;
            }
          }
          if (cnt >= k) {
            ans = min(ans, (v_x[x2] - v_x[x1]) * (v_y[y2] - v_y[y1]));
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) ll t;cin>>t; while(t--)

int main()
{
  
ll i,n,s=0, k,flag=0;cin>>n>>k;
   ll a[n];
   for(i=0;i<n;i++)
  {
  cin>>a[i];
  }

sort(a,a+n);

 for(i=0;i<k;i++)
  {
    s+=a[i];
   }
   
    
cout<<s<<endl;
}

Measured memory_bytes: 3644
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;

mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x : a){
        cin >> x;
    }
    sort(ALL(a));
    reverse(ALL(a));
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i & 1){
            sum -= a[i];
        }else{
            sum += a[i];
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5],b,c,sum=0;
  string s;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a +3);
  cout<<a[0]+a[1]<<'\n';
  return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a1 := make([]int, n)
	for i := range a1 {
		fmt.Scan(&a1[i])
		if i > 0 {
			a1[i] += a1[i-1]
		}
	}
	a2 := make([]int, n)
	for i := range a2 {
		fmt.Scan(&a2[i])
	}
	for i := len(a2) - 1; i >= 0; i-- {
		if i < len(a2)-1 {
			a2[i] += a2[i+1]
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if v := a1[i] + a2[i]; v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong(), b = sc.nextLong(), k = sc.nextLong();

		if(a + b <= k) {
			a = b = 0;
		} else if(a <= k && k < a + b) {
			b = a + b - k;
			a = 0;
		} else {
			a = a - k;
		}

		System.out.println(a + " " + b);
	}
}


Measured memory_bytes: 38744
N, K = map(int, input().split())
A = [int(x)-1 for x in input().split()]

def solve(k, A, N):
    p = 0
    k0 = k
    while k:
        if k&1 ==1:
            p = A[p]
        A = [A[A[x]] for x in range(N)]
        k = k >> 1
        #print("k=%d"%k0, "p=%d"%(p+1))
    #print()
    return p + 1

#for k in range(0, K): print(k, "p=%d"%solve(k, A, N))
print(solve(K, A, N))


Measured memory_bytes: 32332
n=int(input())
F=[int(input().replace(" ",""),2) for _ in range(n)]
P=[list(map(int,input().split())) for _ in range(n)]
ans=[]
for i in range(1,1024):
  p=0
  for j in range(n):
    p+=P[j][bin(i&F[j]).count("1")]
  ans.append(p)
print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
/* calculate n^p mod M. O(log(p)) */ long long modpow(long long n, long long p,
                                                      long long M) {
  long long ans = 1;
  while (p > 0) {
    if (p & 1) ans = (ans * n) % M;
    n = (n * n) % M;
    p >>= 1;
  }
  return ans;
}
LL M = 998244353;

int main() {
  LL N;
  cin >> N;
  VEC<LL> D(N);
  VEC<LL> C(N, 0);
  REP(i, 0, N) {
    cin >> D[i];
    C[D[i]]++;
  }
  if (D[0] != 0 || C[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  LL ans = 1;
  REP(i, 1, N) {
    ans = (ans * modpow(C[i - 1], C[i], M)) % M;
    // DUMP(ans, C[i-1], C[i], modpow(C[i-1], C[i], M));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

int32_t main() {
    fio
    int x;
    cin>>x;
    int years=0;
    for (int i = 100; i < x;) {
        i = i + (i/100);
        years++;
    }
    cout << years << endl;

}






Measured memory_bytes: 3660
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n,a[maxn];

int sgn(int x){
  return x<0?-1:(x==0?0:1);
}

int main() {
 // freopen("in.cpp","r",stdin);
  cin>>n;
  int ret=0;
  for(int i=0; i<n; i++)cin>>a[i];
  for(int i=0; i<n; i++) {
    int d=0;
    int k=i;
    for(int j=i+1;j<n;j++){
      if(a[j]!=a[j-1]){
        if(d==0)d=sgn(a[j]-a[j-1]);
        else if(d!=sgn(a[j]-a[j-1])){
          break;
        }
      }
      k=j;
    }
    ret++;
    i=k;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    from math import sqrt
    N=int(input())
    sqrtN=int(sqrt(N))
    div=[d for d in range(1,sqrtN+1) if N%d==0]
    ans=100
    for d in div:
        e=0
        for e in range(12):
            if (N//d)<10**e:
                ans=min(ans,e)
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 9172
import sys
#input = sys.stdin.readline
from itertools import chain

H, W = map(int, input().split())
grid = [input() for _ in range(H)]
initial = sum(row.count("#") for row in grid)
dire = [(1,0),(0,1),(-1,0),(0,-1)]

def out(y, x):
    return y < 0 or y >= H or x < 0 or x >= W

def wall(y, x):
    return grid[y][x] == "#"

def succs(explored):
    def succs_(point):
        y = point[0]
        x = point[1]
        return [(y+h, x+w) for h, w in dire if not (out(y+h, x+w) or wall(y+h, x+w) or (y+h, x+w) in explored)]
    return succs_

def bfs(frontier, explored, count):
    if not frontier:
        return -1

    if any(map(lambda point: point == (H-1, W-1), frontier)):
        return count
    
    frontier_ = set(chain(*map(succs(explored), frontier)))
    return bfs(frontier_, explored | frontier_, count+1)
    
def main():
    path_count = bfs([(0, 0)], set([(0, 0)]), 1)
    if path_count == -1:
        print(-1)
    else:
        print(H*W - path_count - initial)

main()

Measured memory_bytes: 9460
#include <iostream>
#include <algorithm>
using namespace std;
long long solve(long long a, long long b) {
	if (a == b) return a;
	if (a < b) swap(a, b);
	if (a % b == 0) return 2 * a - b;
	return a / b * b * 2 + solve(b, a % b);
}
int main() {
	long long N, X;
	cin >> N >> X;
	cout << N + solve(X, N - X) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long combination(int n, int r) {
	long ans;
	int i;

	for(i = 0, ans = 1; i < r; i++)
		ans = ans * (n - i) / (i + 1);

	return ans;
}

int main() {
	int n;
	int shou1, shou2, shou3;
	int amari2, amari3;
	int temp_all;
	long day_sum;

	do {
		scanf("%d", &n);
		if(!n)
			break;

		day_sum = 0;
		/* 3段 */
		for(shou3 = n / 3, amari3 = n % 3; shou3 >= 0; shou3--, amari3 += 3) {
			/* 2段 */
			for(shou2 = amari3 / 2, amari2 = amari3 % 2; shou2 >= 0; shou2--, amari2 += 2) {
				/* 1段(amari2) */
				temp_all = shou3 + shou2 + amari2;
				day_sum += combination(temp_all, shou3) * combination(temp_all - shou3, shou2);
			}
		}

		if(day_sum % 3650)
			printf("%ld\n", day_sum / 3650 + 1);
		else
			printf("%ld\n", day_sum / 3650);

	} while(1);

	return 0;
}

Measured memory_bytes: 600
# ABC080
# C. Shopping Street

n = gets.chomp.to_i

f_ = []
n.times do 
  f_ << gets.chomp.split(" ").map(&:to_i)
end

p_ = []
n.times do 
  p_ << gets.chomp.split(" ").map(&:to_i)
end

res = -(1 << 30)
1.upto((1<<10) - 1) do |b|
  prft = 0
  n.times do |i|
    # Store
    c = 0
    10.times do |j|
      # Time
      if (((b >> j) & 1) & f_[i][j]) == 1 then
        c += 1
      end
    end
    prft += p_[i][c]
  end
  res = prft if prft > res
end

puts res

Measured memory_bytes: 1788
/*
T(i, j) 前 i 个小朋友消费了 j 个糖果的方案数
则 T(n, k) 为最终答案

T(i, j) = Sum{T(i-1, j) + T(i-1, j-1) + ... + T(i-1, j-a[i]) } 
= rangeSum([j-a[i], j]) = rangeSum([j-a[i], j+1))
*/
package main

import "fmt"

const N = 105
const K = 1e5+5
const MOD = 1e9+7
var a [N]int
var prefixSum [K]int

func rangeSum (i, j int) int {
  return (prefixSum[j] - prefixSum[i] + MOD) % MOD
}

func max(a, b int) int {
  if a > b {
    return a
  } else {
    return b
  }
}

func main() {
  var n, k int
  fmt.Scanf("%d %d", &n, &k)
  for i := 1; i <= n; i++ {
    fmt.Scanf("%d", &a[i])
  }
  current := make([]int, k+1)
  current[0] = 1
  
  for i := 1; i <= n; i++ {
    for i := 0; i <= k; i++ {
      prefixSum[i+1] = (prefixSum[i] + current[i]) % MOD
    }
    next := make([]int, k+1)
    for j := 0; j <= k; j++ {
      next[j] = rangeSum(max(0, j - a[i]), j+1)
    }
    current = next
  }
  fmt.Println(current[k])
}

Measured memory_bytes: 7744
n,m = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(n)]
e.sort()
#print(n,m,e)

total=0
for i in range(n):
    if m > 0:
      total+=e[i][0]*min(e[i][1],m)
    m-=e[i][1]
    
print(total)

Measured memory_bytes: 21604
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}



int main(void){
   
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2;

scanf("%lld%lld",&a,&b);
m=abs(a-b)/2;
if(a>b){
  
     
       if(a-m==b+m){
           printf("%lld",b+m);
       }else{
           printf("IMPOSSIBLE");
       }
  
}else{
     
    if(a+m==b-m){
           printf("%lld",a+m);
       }else{
           printf("IMPOSSIBLE");
       }

}
return 0;
}


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

const int maxn = 2e5+10;

int p[maxn];
ll sum[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i=1; i<=n; i++) {
        scanf("%d", &p[i]);
        p[i]++;
        sum[i] = sum[i-1]+p[i];
    }
    ll ans = 0;
    for(int i=k; i<=n; i++) {
        ans = max(ans, sum[i]-sum[i-k]);
    }
    printf("%.8f\n", (double)ans/2);
    return 0;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S, std::string T) {
  ll cnt = 0;
  rep(i, 3) {
    if (S.at(i) == T.at(i)) cnt++;
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

int wari(int k, int l){
    if (k > l){
        l += k;
        k = l-k;
        l -= k;
    }
    if ((l % k) == 0){
        return k;
    }else{
        return wari(k, l%k);
    }
}

int main()
{
    int n;
    cin >> n;
    int a[n],nn = 0;
    rep(i,n) cin >> a[i];
    nn = a[0];
    rep(i,n-1){
        nn = wari(nn, a[i+1]);
    }
    cout << nn;
}

Measured memory_bytes: 640
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	unordered_map<ll, ll> F;
	ll sum = 0;
	for(int i = 0; i < n; i++){
		ll x; cin >>x;
		F[x] += 1;
		sum += x;
	}
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int b, c;
		cin >> b >> c;
		sum -= F[b]*b;
		sum += F[b]*c;
		F[c] += F[b];
		F[b] = 0;
		cout << sum << endl;
	}

}

Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    ll N,D;
    cin>>N>>D;
    int ans=0;
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        if(a*a+b*b<=D*D)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
package main

import (
	//"bufio"
	"fmt"
	//"os"
	//"strconv"
	//"strings"
)

func main() {
	var a, h int
	fmt.Scanf("%d %d", &h, &a)
	if (4*h-a)%2 == 0 && 4*h >= a && 2*h <= a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1816
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#define INF 1<<29
#define LL long long
#define WY()(putchar('Y'),putchar('e'),putchar('s'),putchar('\n'))
#define WN()(putchar('N'),putchar('o'),putchar('\n'))
#define Max(x,y)(x>y? x:y)
#define Min(x,y)(x<y? x:y)
#define ek()(putchar('\n'))
#define sk()(putchar(' '))
#define MAXN 405
#define MAXM 100005
using namespace std;
inline int Read(){
	int X=0,flag=1;char ch=0;
	while (ch<'0'||ch>'9'){
		if (ch=='-') flag=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9')
	  X=(X<<1)+(X<<3)+ch-48,ch=getchar();
	return X*flag;
}
inline void Write(int x){
	if (x<0) x=-x,putchar('-');
	if (x>9) Write(x/10);
	putchar(x%10+48);
}
int n,m;
bitset<MAXN> alive[MAXN];
int x[MAXM],y[MAXM];
bool ok[MAXN];
int main(){
	n=Read(),m=Read();
	for (int i=1;i<=m;i++) x[i]=Read(),y[i]=Read();
	for (int i=1;i<=n;i++) ok[i]=alive[i][i]=1;
	for (int i=1;i<=n;i++)
	  for (int j=m;j;j--){
	  	int xx=x[j],yy=y[j];
	  	if (!alive[i][xx]&&!alive[i][yy]) continue;
	  	if (alive[i][xx]&&alive[i][yy]){
	  		ok[i]=0;
	  		break;
		}
		alive[i][xx]=alive[i][yy]=1;
	  }
	int ans=0;
	for (int i=1;i<=n;i++)
	  for (int j=i+1;j<=n;j++)
	    if (ok[i]&&ok[j]&&(alive[i]&alive[j]).none())
	      ans++;
	Write(ans);ek();
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(void)
{
	int w[10], k[10];
	int i, sumw, sumk;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &w[i]);
	}
	for (i = 0; i < 10; i++){
		scanf("%d", &k[i]);
	}
	sort(k, k + 10);
	sort(w, w + 10);
	sumk = 0;
	sumw = 0;
	
	for (i = 0; i < 3; i++){
		sumk += k[i + 7];
		sumw += w[i + 7];
	}
	printf("%d %d\n", sumw, sumk);
	
	return (0);
}

Measured memory_bytes: 1040
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	char S[101];
	scanf("%s", S);
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == S[N / 2 + i]) {
			count++;
		}
	}
	
	if (N % 2 != 0) {
		printf("No");
	}else if(count==N/2){
		printf("Yes");
	}else {
		printf("No");
	}

	return 0;
}
	

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const int inf = 1145141919810931;
typedef pair<int, int> P;
typedef pair<P, int>PP;
typedef pair<int, char>PC;
struct edge { int to, cost; };

double euc(double xa, double ya, double xb, double yb) {
	int dx = xb - xa, dy = yb - ya;
	return sqrt(dx*dx + dy*dy);
}

signed main() {
	double xa, xb, xc, ya, yb, yc;
	cin >> xa >> ya >> xb >> yb >> xc >> yc;
	double al = euc(xa, ya, xb, yb), bl = euc(xb, yb, xc, yc), cl = euc(xc, yc, xa, ya);
	double bca = acos((bl*bl + cl*cl - al*al) /( 2 * bl*cl));
	double abc = acos((al*al + bl*bl - cl*cl) / (2 * al*bl));
	double cab = acos((cl*cl + al*al - bl*bl) / (2 * al*cl));
	double lb = 0, ub = 1000000000;
	bca /= 2.0; abc /= 2.0; cab /= 2.0;
	rep(i, 300) {
		double mi = (ub + lb) / 2;
		double nal = al - mi / tan(abc) - mi / tan(cab);
		double nbl = bl - mi / tan(abc) - mi / tan(bca);
		double ncl = cl - mi / tan(bca) - mi / tan(cab);
		int cnt = 0;
		if (nal - 2 * mi >= 0)cnt++;
		if (nbl - 2 * mi >= 0)cnt++;
		if (ncl - 2 * mi >= 0)cnt++;
		if (cnt >= 1) {
			lb = mi;
		}
		else ub = mi;
	}
	cout << setprecision(14) << lb << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.solve();
        m.show();
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int A;
    int B;
    int K;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        A = sc.nextInt();
        B = sc.nextInt();
        K = sc.nextInt();
    }
    
    //解答処理
    private void solve() {
    	for (int i=1; i<=K; i++) {//高橋君か青木君の操作で1回
    		if (i % 2 == 1) {	//高橋君の操作
    			if (A % 2 == 1) {
    				A--;
    			}
    			A = A/2;
    			B += A;
    		} else {	//青木君の操作
    			if (B % 2 == 1) {
    				B--;
    			}
    			B = B/2;
    			A += B;
    		}
    		
    	}
    	
    }
    
    //出力
    public void show() {
    	System.out.println(A + " " + B);
    }
}


Measured memory_bytes: 38612
using System;

class Program
{
    static void Main(string[] args)
    {
        int n, k, i = 0, q, j;
        int[] m, x = new int[4], y = new int[4], p = new int[] { 10, 50, 100, 500 };

        while (true)
        {
            n = int.Parse(Console.ReadLine());
            if (n==0) { break; }
            if (i!=0) { Console.WriteLine(); }
            i++;
            k = 0;
            m = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);
            for (j = 3; j >= 0; j--)
            {
                k += m[j] * p[j];
            }
            q = k - n;
            for (j = 3; j >= 0; j--)
            {
                x[j] = q / p[j]; q -= x[j] * p[j];
                y[j] = Math.Max(0, m[j] - x[j]);
            }

            for (j = 0; j < 4; j++)
            {
                if (y[j]!=0) { Console.WriteLine("{0} {1}", p[j], y[j]); }
            }
        }
    }
}


Measured memory_bytes: 9380
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String S = scanner.next();
		// N == S.length();
		int black = 0;
		int white = 0;
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == '.') {
				white++;
			}
		}
		int min = white;
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == '#') {
				black++;
			}else {
				white--;
			}
			min=Math.min(min, black+white);
		}
		System.out.println(min);
		
		scanner.close();
	}
}


Measured memory_bytes: 27944
#include <iostream>

using namespace std;

int main() {
  for (int i = 0; i < 3; i++) {
    int hb, he, mb, me, sb, se;
    cin >> hb >> mb >> sb >> he >> me >> se;
    int s = se - sb, m = me - mb, h = he - hb;
    if (s < 0) {
      s += 60;
      m--;
    }
    if (m < 0) {
      m += 60;
      h--;
    }
    cout << h << ' ' << m << ' ' << s << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=1000001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    int h, w, m;
    cin>>h>>w>>m;

    ll row[h + 1], col[w + 1];

    rep(i, h+1) row[i] = 0;
    rep(i, w+1) col[i] = 0;

    vector<pair<int, int> > v;

    rep(i, m)
    {
        int a, b;
        cin>>a>>b;
        row[a]++;
        col[b]++;
        v.pb(mp(a, b));
    }


    ll mx_row = LLONG_MIN, mx_col = LLONG_MIN;


    for(int i = 1; i <= h; i++)
    {
        mx_row = max(mx_row, row[i]);
    }

    for(int i = 1; i <= w; i++)
    {
        mx_col = max(mx_col, col[i]);
    }

    ll ans = mx_col + mx_row - 1;

    set<int> rows, cols;

    for(int i = 1; i <= h; i++)
    {
        if(row[i] == mx_row)
        {
            rows.insert(i);
        }
    }

    for(int i = 1; i <= w; i++)
    {
        if(col[i] == mx_col)
        {
            cols.insert(i);
        }
    }

    ll combi = rows.size() * cols.size();

    ll run = 0;

    rep(i, m)
    {
        int a = v[i].F, b = v[i].S;

        if(rows.find(a) != rows.end() && cols.find(b) != cols.end())
        {
            run++;
        }
    }

    // cout<<ans<<endl;

    if(run == combi)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<ans+1<<endl;
    }

}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 61908
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<math.h>
#include <set>
#include<map>
#include<queue> 
#include<algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=1e5+10;
int a;
int n;
int main ()
{
	
	while (scanf ("%d",&n)!=EOF){
		map<int,int>mp;
		int first=-1,second=-1;
		for (int i=0;i<n;i++){
			scanf ("%d",&a);
			if (mp.find(a)!=mp.end()){
				mp[a]++;
				if (a>first){
					if (mp[a]>=2){
						second=first;
						first=a;
						mp[a]=mp[a]-2;
					}
				}
				if (a>second) {
					if (mp[a]>=2){
						second=a;
						mp[a]=mp[a]-2;
					}
				}
			}else {
				mp[a]=1;
			}
		}
		
		if (first!=-1&&second!=-1){
			printf ("%lld\n",(ll)first*second);
		}else {
			printf ("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		for(int i=0; i<n; i++){
			System.out.println(196470-days(scanner.nextInt(), scanner.nextInt(), scanner.nextInt()));
		}
		scanner.close();
	}

	private static int days(int y, int m, int d){
		/* ?????????????±??????? */
		y--;
		m--;
		d--;

		int result=0;

		int y3=y/3;  /* 3??´?????¨???????????° */
		result+=y3*590;
		result+=(y%3)*195;

		if((y+1)%3==0){ /* ?????´???3????????°??´ */
			result+=m*20;

		}else{  /* ?????´???3????????°??´??§?????? */
			if(m%2==0){  /* ??¶??°????????? */
				result+=39*m/2;
			}else{  /* ?\???°????????? */
				result+=39*(m-1)/2+20;
			}
		}
		return result+d;
	}

}

Measured memory_bytes: 26712
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

bool cmp(pair<int,int> &a,pair<int,int> &b){
	return a.F<b.F;
}

void solve(int test_case) {//233
	int n;
	cin>>n;
	vi arr(n),b(n);
	REP(i,0,n-1) {
		int val;
		cin>>val;
		arr[i]=val;
		b[i]=val;
	}
	sort(arr.begin(),arr.end());
	int cnt = 0;
	REP(i,0,n-1) {
		if(arr[i]!=b[i])cnt++;
	}
	if(cnt==0||cnt==2)cout<<"YES";
	else cout<<"NO";
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int A, B, T;
    cin >> A >> B >> T;
    int x =  (T / A) * B;
    cout << x << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
    ll n;
    cin>>n;
    ld head[n+1];
    fo(i,1,n+1)cin>>head[i];
    ld ans[n+1][n+1];
    memset(ans,0, sizeof(ans));
    ans[0][0]=1;
    for(ll i=1;i<=n;i++)ans[0][i]=0;
    ld sum=1;
    for(ll i=1;i<=n;i++){
        sum*=(1-head[i]);
        ans[i][0]=sum;
    }

    for(ll i=1;i<=n;i++){

        for(ll j=1;j<=i;j++){
            ans[i][j]=(1-head[i])*ans[i-1][j]+(head[i])*ans[i-1][j-1];

        }



    }

    ld temp=0;

    for(ll i=n/2+1;i<=n;i++){
        temp+=ans[n][i];
    }
    cout<<fixed<<setprecision(100)<<temp<<endl;



}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 144456