akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int64_t ans = 0;

    auto is_bc = [&](int index) {
        return 0 <= index && line[index] == 'B' && line[index + 1] == 'C';
    };

    std::vector<int64_t> left_a(line.size(), 0);

    for (int i = 0; i < line.size() - 1; i++)
    {
        if (is_bc(i))
        {
            int counter = 0;
            int idx = i - 1;
            while (idx >= 0 && line[idx] == 'A')
            {
                counter++;
                idx--;
            }
            if (is_bc(idx - 1))
            {
                counter += left_a[idx - 1];
            }
            left_a[i] = counter;
            ans += counter;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2180
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
#define N 1005
#define M 30005
#define ll long long 
#define INF 0x3f3f3f3f
#define MOD 10000000
inline int rd()
{
	int f=1ll,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-f;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
int a,b;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
	a=rd(),b=rd();
	if(a>=1&&a<=9&&b>=1&&b<=9)
		printf("%d\n",a*b);
	else puts("-1");
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;


int main(){
    ll N;
    cin >> N;
    vector<ll> T(N), A(N), S(N), SS(N);
    rep(i,N) cin >> T[i];
    rep(i,N) cin >> A[i];
    ll cur = 0;
    rep(i,N){
        if(cur < T[i]){
            cur = T[i];
            S[i] = cur;
        }
    }
    cur = 0;
    rep(i,N){
        if(cur < A[N-1-i]){
            cur = A[N-1-i];
            SS[N-1-i] = cur;
        }
    }
    rep(i,N){
        if(S[i] > 0 && SS[i] > 0){
            if(S[i] != SS[i]){
                cout << 0 << endl;
                return 0;
            }
        }else if(S[i] > 0 && SS[i] == 0){
            if(!(T[i] <= A[i])){
                cout << 0 << endl;
                return 0;
            }
        }else if(S[i] == 0 && SS[i] > 0){
            if(!(A[i] <= T[i])){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    /*if(T[N-1] != A[0]){
        cout << 0 << endl;
        return 0;
    }*/
    ll ans = 1;
    rep(i,N){
        if(S[i] > 0 || SS[i] > 0){
            continue;
        }else{
            ans *= min(T[i],A[i]);
            ans %= mo;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6396
#include <stdio.h>

long long int gcd(long long int a,long long int b);
long long int findlcm(long long int a, long long int b);

int main(){
    long long int a,b,n,arr[101],g,l,max=0;
    int i,count=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&arr[i]);
    }
    l=arr[0];
    for(i=1;i<n;i++){
        l=findlcm(l,arr[i]);
    }
    printf("%lld\n",l);
    return 0;
}

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

long long int findlcm(long long int a, long long int b)
{
    long long int lcm;
    lcm=a/gcd(a,b)*b;
    return lcm;
}


Measured memory_bytes: 128
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()



// vector<bool> visited;
// vector<vl> v;
// ll cnt[2];

// void dfs(ll pnt, ll col) {
// 	visited[pnt] = true;
// 	cnt[col]++;
// 	fr(i, 0, v[pnt].size()) {
// 		if (!visited[v[pnt][i]])dfs(v[pnt][i], !col);
// 	}
// }



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





void solve() {
	ll n, s = 0; cin >> n;
	fr(i, 1, n) {
		ll d = n / i;
		s += d;
		if (n % i == 0)s--;
	}
	cout << s;
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	//precompute();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main()
{
  int s;
  cin >> s;
  int h, m;
  m = s / 60;
  s = s % 60;
  h = m / 60;
  m = m % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


void solve() {
}

int main() {
    int a[3];
    REP(i, 3)cin >> a[i];
    sort(a, a + 3);
    cout << a[2] * 10 + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll> sumA(n+1), sumB(m+1);
    for(int i = 1; i <= n; i++) sumA[i] = sumA[i-1] + a[i-1];
    for(int i = 1; i <= m; i++) sumB[i] = sumB[i-1] + b[i-1];
    ll ans = 0, j = m;
    for(int i = 0; i <= n; i++){
        if (sumA[i] > k) break;
        while(sumB[j] > k - sumA[i]){
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9596
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := iScan(), iScan()
	ch, cw := iScan()+1, iScan()+1
	dh, dw := iScan()+1, iScan()+1
	s := make([]string, h+4)
	s[0] = strings.Repeat("#", w+4)
	s[1] = strings.Repeat("#", w+4)
	s[h+2] = strings.Repeat("#", w+4)
	s[h+3] = strings.Repeat("#", w+4)
	for i := 2; i <= h+1; i++ {
		s[i] = "##" + Scan() + "##"
	}
	x := []int{-2, -1, 0, 1, 2}
	zero := make(map[[2]int]struct{})
	zero[[2]int{ch, cw}] = struct{}{}
	cost := make([][]int, h+4)
	for i := 0; i < h+4; i++ {
		cost[i] = make([]int, w+4)
		for j := 0; j < w+4; j++ {
			cost[i][j] = mod * mod
		}
	}
	cost[ch][cw] = 0
	for len(zero) != 0 {
		one := make(map[[2]int]struct{})
		for len(zero) != 0 {
			i, j := -1, -1
			for k, _ := range zero {
				i = k[0]
				j = k[1]
				break
			}
			delete(zero, [2]int{i, j})
			for _, a := range x {
				for _, b := range x {
					if abs(a)+abs(b) == 1 {
						if string(s[i+a][j+b]) == "." && cost[i+a][j+b] > cost[i][j] {
							zero[[2]int{i + a, j + b}] = struct{}{}
							cost[i+a][j+b] = cost[i][j]
							delete(one, [2]int{i + a, i + b})
						}
					} else if abs(a)+abs(b) > 1 {
						if string(s[i+a][j+b]) == "." && cost[i+a][j+b] > cost[i][j]+1 {
							one[[2]int{i + a, j + b}] = struct{}{}
							cost[i+a][j+b] = cost[i][j] + 1
						}
					}
				}
			}
		}
		for k, _ := range one {
			zero[k] = struct{}{}
		}
	}
	if cost[dh][dw] != mod*mod {
		fmt.Println(cost[dh][dw])
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 23692
# frozen_string_literal: true

n = gets.to_i
w = []
n.times { w << gets.chomp }

w.each_cons(2) do |i|
  if i[0][-1] != i[1][0]
    puts :No
    exit
  end
end

puts w.uniq.size == n ? :Yes : :No

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  int i,n;
  scanf("%d",&n);
  int h[n+100],cnt=0,max=0;
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
    if(i==0)
      continue;
    if(h[i-1] >= h[i])
      cnt++;
    if(h[i-1] < h[i] || i==n-1){
      if(max < cnt)
        max = cnt;
      cnt=0;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        sc.close();
        long ret = x;
        while (true) {
            if (isPrime(ret)) {
                break;
            }
            ret++;
        }
        System.out.println(ret);
    }

    public static boolean isPrime(long x) {
        if (x == 1 || x == 2) {
            return true;
        }

        if (x % 2 == 0) {
            return false;
        }

        boolean ret = false;
        for (long i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                ret = false;
                break;
            }
            ret = true;
        }
        return ret;
    }

}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		switch (X / 100) {
			case 4:
			case 5:
				System.out.println(8);
				break;
			case 6:
			case 7:
				System.out.println(7);
				break;
			case 8:
			case 9:
				System.out.println(6);
				break;				
			case 10:
			case 11:
				System.out.println(5);
				break;				
			case 12:
			case 13:
				System.out.println(4);
				break;				
			case 14:
			case 15:
				System.out.println(3);
				break;				
			case 16:
			case 17:
				System.out.println(2);
				break;				
			case 18:
			case 19:
				System.out.println(1);
				break;				
		}

	}

}


Measured memory_bytes: 35644
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS =1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}

void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

void solve(){
	int n,t,a,b,tt;
    while(cin>>t,t){
	    cin>>n;
tt=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			tt+=b-a;
		}
		if(t<=tt) cout<<"OK"<<endl;
		else cout<<t-tt<<endl;
	}
}

int main(){
solve();
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int n,m,h,k,a[100100],b[100100];
int p[1000];
int main(){
	while(1){
		scanf("%d%d%d%d",&n,&m,&h,&k);
		if(n==0&&m==0&&h==0&&k==0)break;
		vector<int>V[1010];
		REP(i,n)scanf("%d",&p[i]);
		REP(i,m){
			scanf("%d%d",&a[i],&b[i]);a[i]--;
			V[b[i]].PB(a[i]);
		}
		REP(i,n)sort(ALL(V[i]));
		int up[1010][1010];
		int down[1010][1010];
		REP(i,n)up[0][i]=down[h][i]=i;
		for(int i=1;i<h;i++){
			REP(j,n)up[i][j]=up[i-1][j];
			REP(j,V[i].size()){
				swap(up[i][V[i][j]],up[i][V[i][j]+1]);
			}
		}
		for(int i=h-1;i>=1;i--){
			REP(j,n)down[i][j]=down[i+1][j];
			REP(j,V[i].size()){
				swap(down[i][V[i][j]],down[i][V[i][j]+1]);
			}
		}
		int ans=0,ori=0;
		REP(i,k)ori+=p[down[1][i]];
		ans=ori;
		REP(i,m){
			int cnt=0;
			if(up[b[i]][a[i]]<k){
				if(up[b[i]][a[i]+1]<k)continue;
				int bet=-p[down[b[i]+1][a[i]]]+p[down[b[i]+1][a[i]+1]];
				ans=min(ori+bet,ans);
			}else if(up[b[i]][a[i]+1]<k){
				int bet=p[down[b[i]+1][a[i]]]-p[down[b[i]+1][a[i]+1]];
				ans=min(ori+bet,ans);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 10532
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, m;
    cin >> n >> m;
    if(n > m) swap(n, m);
    if(n >= 2 && m >= 2) cout << (n-2)*(m-2);
    else if(n == 1 && m == 1) cout << 1;
    else if(n == 1) cout << m-2;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>

#include <cstdint>

constexpr bool parity64(std::uint_fast64_t c) noexcept {
  c ^= c >> 1;
  c ^= c >> 2;
  return ((c & 0x1111111111111111) * 0x1111111111111111 >> 60 & 0x1) != 0;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int>> t(n);
  for (int i = 0; i != n - 1; i += 1) {
    int a, b;
    std::cin >> a >> b;
    a -= 1;
    b -= 1;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int m;
  std::cin >> m;
  const int s = 1 << m;
  std::vector<int> z(s, 0);
  {
    std::vector<int> x(n, 0);
    for (int i = 0; i != m; i += 1) {
      int u, v;
      std::cin >> u >> v;
      u -= 1;
      v -= 1;
      x[u] ^= 1 << i;
      x[v] ^= 1 << i;
    }
    std::function<void(int, int)> dfs = [&](int v, int p) {
      for (int e : t[v]) {
        if (e == p)
          continue;
        dfs(e, v);
        z[x[e]] += 1;
        x[v] ^= x[e];
      }
    };
    dfs(0, n);
  }
  for (int w = 1; w != s; w <<= 1) {
    for (int i = 0; i != s; i += w << 1) {
      const int end = i + w;
      for (int j = i; j != end; j += 1) {
        z[j + w] += z[j];
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i != 1 << m; i += 1) {
    auto res = 1LL << z[s - 1 ^ i];
    if (parity64(i))
      res = -res;
    ans += res;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  ll D, G;
  cin >> D >> G;
  vector<ll> p(D), c(D);

  REP(i, D) {
    cin >> p[i] >> c[i];
  }

  ll ans = accumulate(p.begin(), p.end(), 0LL);

  ll tmp, amp, cmp;
  REP(i, pow(2, D)) {
    vector<int> use;
    for(int j = 0, tmp = i; j < D; j++) {
      use.push_back(tmp % 2);
      tmp /= 2;
    }
    //for (int i = 0; i < use.size(); i++) cout << use[i];
    //cout << endl;

    tmp = 0;
    amp = 0;
    REP(j, D) {
      tmp += use[j] * (p[j] * (j + 1) * 100 + c[j]);
      amp += use[j] * p[j];
    }
    //cout << tmp << " " << amp << endl;
    if (tmp == G) {
      ans = min(ans, amp);
    }else if (tmp < G) {
      ll l = D - 1;
      while(true) {
        if (use[l] == 0) break;
        l--;
      }
      //cout << l << endl;
      ll k = 0;
      while (k <= p[l]) {
        tmp += 100 * (l + 1);
        amp++;
        k++;
        //cout << tmp << endl;
        if (tmp >= G) {
          ans = min(ans, amp);
          break;
        }
      }
    } else {
      ans = min(ans, amp);
    }

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int i,num,N,min=1000000000,max=-1000000000,min_num;
    
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&num);
        if(num - min > max && i>=1){
            max = num-min;
        }
        if(min > num){
            min = num;
        }
    }
    printf("%d\n",max);
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll n, w[101], ans;

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

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		if (i != 0)
		{
			w[i] += w[i - 1];
		}
	}
	ans = 10000000000;
	for (int i = 0; i < n; i++)
	{
		ans = min(ans, abs(w[n - 1] - w[i] - w[i]));
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = k;
  rep(i, n-1)
    ans *= k-1;
  cout << ans << endl;
  return 0;
}

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

int getLISLength(vector<int>& num) {
    int length = num.size();
    vector<pair<int,int>> ivec;
    for (int i = 0; i < length; ++i) {
        if (ivec.size() == 0 || ivec.back() < make_pair(num[i],i))
            ivec.push_back({num[i],i});
        else {
            int pos = lower_bound(ivec.begin(),ivec.end(),make_pair(num[i],i)) - ivec.begin();
            ivec[pos] = {num[i],i};
        }
    }
    return ivec.size();
}
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    reverse(a.begin(),a.end());
    cout<<getLISLength(a);
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    ll flag=n/k;
    n-=flag*k;
    if(n%k==0){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=0;i<1e17;++i){
        if((abs(n-k))<n){
            n=abs(n-k);
        }else{
            break;
        }
    }
    cout<<abs(n)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int nearPow2(int n){
  if (n <= 0) return 0;
  if ((n & (n - 1)) == 0) return (uint)n;
  uint ret = 1;
  while (n > 0) { ret <<= 1; n >>= 1; }
  return ret;
}
int main(){
  int n,ans=0;
  cin >> n;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    mp[a]++;
  }
  auto itr=mp.end();
  itr--;
  for(;itr!=mp.begin();itr--){
    int pw=nearPow2((*itr).first);
    if(pw == (*itr).first){
      ans += (*itr).second/2;
    }
    else{
      int q = min((*itr).second,mp[pw-(*itr).first]);
      ans += q;
      mp[pw-(*itr).first] -= q;
    }
  }
  int pw=nearPow2((*itr).first);
  if(pw == (*itr).first){
    ans += (*itr).second/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 67476
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int t[100100], x[100100], y[100100];

int dist(int x0, int y0, int x1, int y1) {
    return abs(x0 - x1) + abs(y0 - y1);
}

bool solve() {
    int X = 0, Y = 0, T = 0;
    for (int i = 0; i < n; i++) {
        int d = dist(X, Y, x[i], y[i]);
        if (t[i] - T < d || (t[i] - T - d) % 2) return false;
    }
    return true;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> t[i] >> x[i] >> y[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

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


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    /*int a=1;
    cout<<(a<<3)<<endl;
    out: 8
    */

   int n,m,ans=0;
   cin>>n>>m;
   int s[11][11],p[m],k[m];
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];s[i][j]--;
        }
    }
    for(int i=0;i<m;i++)
    cin>>p[i];
    bool flag;
    for(int i=0;i<(1<<n);i++){
        flag=true;
        for(int j=0;j<m;j++){
            int c=0;
            for(int h=0;h<k[j];h++){
                if(((1<<s[j][h])&i)>0)
                c++;
            }
            if(c%2!=p[j]){
                flag=false;
            }
        }
        if(flag)
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;

	deque<int> sei;
	deque<int> hu;
	int tmp;

	rep(i, n)
	{
		cin >> tmp;
		if (tmp < 0)
		{
			hu.push_back(tmp);
		}
		else
		{
			sei.push_back(tmp);
		}
	}

	sort(sei.begin(), sei.end());
	sort(hu.begin(), hu.end(), greater<int>());


	vector<pair<int, int>> ans;

	for (int i = 0; i < n - 1; i++)
	{
		pair<int, int> tmpP;

		if (sei.size() > hu.size() && hu.size() > 0 && sei.size()>0)
		{
			tmpP.first = hu.at(hu.size() - 1);
			tmpP.second = sei.at(sei.size() - 1);
			ans.push_back(tmpP);

			hu.at(hu.size() - 1) = hu.at(hu.size() - 1) - sei.at(sei.size() - 1);
			sei.pop_back();
		}
		else if (sei.size() > 0 && hu.size()>0)
		{
			tmpP.first = sei.at(sei.size() - 1);
			tmpP.second = hu.at(hu.size() - 1);
			ans.push_back(tmpP);

			sei.at(sei.size() - 1) = sei.at(sei.size() - 1) - hu.at(hu.size() - 1);
			hu.pop_back();
		}
		else if (hu.size() == 0)
		{
			tmpP.first = sei.at(0);
			tmpP.second = sei.at(sei.size() - 1);
			ans.push_back(tmpP);

			hu.push_back(sei[0] - sei[sei.size() - 1]);
			sei.pop_back();
			sei.pop_front();
		}
		else if (sei.size() == 0)
		{
			tmpP.first = hu.at(0);
			tmpP.second = hu.at(hu.size() - 1);
			ans.push_back(tmpP);

			sei.push_back(hu[0] - hu[hu.size() - 1]);
			hu.pop_back();
			hu.pop_front();
		}

	}

	cout << sei[0] << endl;
	rep(i, n - 1)
	{
		cout << ans[i].first << " " << ans[i].second << endl;
	}

}

Measured memory_bytes: 3188
import numpy as np

a, b, h, m = map(int, input().split())
thetaH = np.deg2rad(360/12*h + 360/(12*60)*m)
thetaM = np.deg2rad(360/60*m)
thetaDiff = thetaH - thetaM

x0 = a
y0 = 0

x1 = b*np.cos(thetaDiff)
y1 = b*np.sin(thetaDiff)

ans = np.sqrt((x0-x1)**2 + (y0-y1)**2)
print(ans)

Measured memory_bytes: 27252
#include<iostream>
#include<math.h>
using namespace std;
long long a,b,c,ans;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0) 
		cout<<0<<endl;
	else 
	{
		ans=min(a*c,min(a*b,b*c));
		cout<<ans<<endl;
	} 
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    string s;
    cin>>s;
    bool ch=true;
    rep(i,s.size()){
        if(i%2==1){
            if(s[i]=='R')ch=false;
        } else {
            if(s[i]=='L')ch=false;
        }
    }
    if(ch)fin("Yes");
    else fin("No");


//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 256
N = int(input())
dp = [[0 for i in range(3)] for i in range(N+1)]
for i in range(1,N+1):
    a,b,c = map(int,input().split())
    dp[i][0] = max(dp[i-1][1] + a,dp[i-1][2] + a)
    dp[i][1] = max(dp[i-1][2] + b,dp[i-1][0] + b)
    dp[i][2] = max(dp[i-1][0] + c,dp[i-1][1] + c)
ans = max(dp[N][0],dp[N][1],dp[N][2])
print(ans)

Measured memory_bytes: 62044
#include <bits/stdc++.h>
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 rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  string a,b;
  cin>>a>>b;
  sort(all(a));
  sort(all(b));
  reverse(all(b));
  if(a<b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n,k,*h=map(int,open(0).read().split())
a=[0]*n
for i in range(1,n):
    j=max(0,i-k)
    e=h[i]
    a[i]=min(A+abs(e-H) for A,H in zip(a[j:i],h[j:i]))
print(a[-1])


Measured memory_bytes: 13876
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	for i := 'a'; i <= 'z'; i++ {
		has := false
		for _, v := range S {
			if v == i {
				has = true
				continue
			}
		}
		if !has {
			fmt.Println(string(i))
			return
		}
	}

	fmt.Println("None")
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
ll const N=1e6+5;
struct node{
	ll x,h;
};
bool comp(node a,node b){
	return a.x<b.x;
}
ll getSum(ll BITree[], ll index) 
{ 
    ll sum = 0; // Iniialize result 
  
    // index in BITree[] is 1 more than the index in arr[] 
    index = index + 1; 
  
    // Traverse ancestors of BITree[index] 
    while (index>0) 
    { 
        // Add current element of BITree to sum 
        sum += BITree[index]; 
  
        // Move index to parent node in getSum View 
        index -= index & (-index); 
    } 
    return sum; 
} 
void updateBIT(ll BITree[], ll n, ll index, ll val) 
{ 
    index = index + 1; 
  
    // Traverse all ancestors and add 'val' 
    while (index <= n) 
    { 
    // Add 'val' to current node of BI Tree 
    BITree[index] += val; 
  
    // Update index to that of parent in update View 
    index += index & (-index); 
    } 
} 
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
   		ll ans=0;
   		ll n,d,a;cin>>n>>d>>a;
   		node arr[n];
   		ll xx[n];
   		rep(i,n){
   			cin>>arr[i].x>>arr[i].h;
   			xx[i]=arr[i].x;
   		}
   		sort(arr,arr+n,comp);
   		sort(xx,xx+n);
   		ll BITtree[n+1]={0};
   		ll s=0;
   		rep(i,n){
   			updateBIT(BITtree,n,i,arr[i].h-s);
   			s=arr[i].h;
   		}
   		for(int i=0;i<n;i++){
   			ll x=arr[i].x;
   			ll h=getSum(BITtree,i);
   			// cout<<h<<endl;
   			if(h<=0)continue;
   			ll t=((h+a-1)/a);
   			ans=ans+t;
   			ll l=i,r=i;
   			r=upper_bound (xx, xx+n, x+2*d)-xx;
   			updateBIT(BITtree,n,l,-t*a);
   			updateBIT(BITtree,n,r,t*a);
   		}
   		cout<<ans<<endl;
    }
    return 0;   
}
 


Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    double N,K;
    cin >> N >> K;
    double total_pr = 0;
    for(int i=1; i<=N; i++){
        if(i>=K)
            total_pr += 1 / N;
        else{
            int time = ceil(log2(K) - log2(i));
            double pr = pow(0.5,time)/N;
            total_pr += pr;
        }
    }
    cout << setprecision(10) << total_pr << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    if S.count('R') == 0:
        print(0)
        exit()
    cnt = 1
    for i in range(2):
        if S[i] == 'R' and S[i+1] == 'R':
            cnt += 1 

    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 61648
a = input()
b = int(753)
c = int(len(a))
d = int(0)

for i in range(c - 2):
  d = 100 * int(a[i]) + 10 * int(a[i+1]) + int(a[i+2])
  e = abs(int(d) - 753)
  if int(b) > int(e):
    b = e
  else:
    pass

print(b)
  

Measured memory_bytes: 9172
#include <atcoder/dsu>
#include <iostream>

using namespace std;
using namespace atcoder;

int main(void){
    int N, Q;
    cin >> N >> Q;
    dsu uf(N);
    while (Q--){
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) (void)uf.merge(u, v);
        else cout << (uf.same(u, v)) << endl;
    }    
    return 0;
}

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

using namespace std;

int main (){

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


	cin.tie(0);
	ios::sync_with_stdio(false);

	string x;
	cin>>x;

	x[3]='8';

	cout<<x<<endl;
		
}

Measured memory_bytes: 3652
counter = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    #print(L)
    #print(R)
    L.append(float('inf'))
    R.append(float('inf'))
    i=j=0
    global counter
    for k in range(left,right):
        counter = counter+1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A, left, right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
l = list(map(int,input().split()))
mergeSort(l,0,n)
print(*l)
print(counter)

Measured memory_bytes: 63704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_6_A_CountingSort
{
    class Program
    {
        const int MAX = 2000010;
        const int VMAX = 10010;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var A = new int[MAX];
            var B = new int[MAX];
            var C = new int[VMAX+1];

            var input = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(input[i]);
                C[A[i]]++;  //Aの要素がCの要素のインデックスに対応する
            }

            for (int i = 0; i < VMAX; i++) //Cを累積和にする
            {
                C[i + 1] += C[i];
            }

            for (int i = n - 1; i >= 0; i--)
            {
                B[C[A[i]]] = A[i];
                C[A[i]]--;
            }
            Console.WriteLine(string.Join(" ",B.Skip(1).Take(n)));
        }
    }
}



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

#define For(x,y) for(int x=0;x<=y;++x)

const int N = 101;
int pw[N][N*N], fac[N], inv[N];
int f[N][N], g[N][N], coe[N][N];
int n, m, K, p;

inline int qpow(int A, int B) {
	int r = 1; while(B) {
		if(B&1) r = (ll)r * A%p;
		A = (ll)A * A%p, B >>= 1;
	} return r;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &K, &p);
	
	for(int i = 0; i <= K; ++ i)
		for(int j = pw[i][0] = 1; j <= n * m; ++ j)
			pw[i][j] = (ll)pw[i][j-1] * i%p;
	
	int t = n; if(n < m) t = m;
	for(int i = fac[0] = 1; i <= t; ++ i) fac[i] = (ll)fac[i-1] * i%p;
	inv[t] = qpow(fac[t], p-2);
	for(int i = t; i; -- i) inv[i-1] = (ll)inv[i] * i%p;
	
	g[0][0] = 1;
	for(int t = 1; t <= K; ++ t) {
		swap(f, g);
		For(i, n) For(j, m)
			coe[i][j] = (ll)pw[t][i*(m-j)] * pw[K-t+1][i*j]%p * inv[i]%p;
		For(i, n) For(j, m) {
			int&v = g[i][j]; v = 0;
			For(k, i) v = (v + (ll)f[i-k][j] * coe[k][j])%p;
		}
		/* definited row*/
		
		swap(f, g);
		For(i, n) For(j, m)
			coe[i][j] = (ll)pw[t][j*(n-i)] * pw[K-t+1][i*j]%p * inv[j]%p;
		For(i, n) For(j, m) {
			int&v = g[i][j]; v = 0;
			For(k, j) v = (v + (ll)f[i][j-k] * coe[i][k])%p;
		}
		/* definited column */
		
		swap(f, g);
		For(i, n) For(j, m) {
			coe[i][j] = (ll)pw[t][i*(m-j)] * pw[K-t][i*j]%p * inv[i]%p;
			if(i&1) coe[i][j] = (ll)coe[i][j] * (p-1)%p;
		}
		For(i, n) For(j, m) {
			int&v = g[i][j]; v = 0;
			For(k, i) v = (v + (ll)f[i-k][j] * coe[k][j])%p;
		}
		/* in-exclusive row */
		
		swap(f, g);
		For(i, n) For(j, m) {
			coe[i][j] = (ll)pw[t][j*(n-i)] * pw[K-t][i*j]%p * inv[j]%p;
			if(j&1) coe[i][j] = (ll)coe[i][j] * (p-1)%p;
		}
		For(i, n) For(j, m) {
			int&v = g[i][j]; v = 0;
			For(k, j) v = (v + (ll)f[i][j-k] * coe[i][k])%p;
		}
		/* in-exclusive column */
	}
	
	printf("%lld\n", (ll)f[n][m] * fac[n]%p * fac[m]%p);
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c;
int absx(int x){
	if (x>=0) return x; else return -x;
}
int main(){
	scanf("%d%d%d",&a,&b,&c);printf("%d\n",max(absx(a-b),max(absx(a-c),absx(b-c))));return 0;
}

Measured memory_bytes: 256
var fs = require('fs')
var contents = fs.readFileSync('/dev/stdin', 'utf-8');

var watch = function(str) {
    var n = parseInt(str);
    var h = Math.floor(n / 3600);
    var m = Math.floor((n - 3600 * h) / 60);
    var s = n % 60;
    return h + ":" + m + ":" + s;
}

console.log(watch(contents));

Measured memory_bytes: 15568
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {


    int h,w;

    
    while(1){
        cin >> h >> w;
        
        if(h==0 && w==0)
            break;
        
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
    
}



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

int main() {
   int n;cin>>n;
   n--;
   int arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   map<int,int>m;
   for(int i=0;i<n;i++)
   {
       m[arr[i]]++;
   }
   for(int i=0;i<n;i++)
   {
       cout<<m[i+1]<<"\n";
   }
   cout<<"0";
  
   
	return 0;
}

Measured memory_bytes: 13788
a, b, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = as.min + bs.min
m.times do 
  s, y, c = gets.split.map(&:to_i)
  ans = [ans, as[s-1] + bs[y-1] - c].min
end
puts ans

Measured memory_bytes: 18588
#include <stdio.h>
#include<string.h>
int main(){
    int i,sum[26];
    char s;
    
    for(i=0;i<26;i++){
        
        sum[i]=0;
    }
    while(scanf("%c",&s)!=EOF){
        
        if(s>='a'&&s<='z')
        sum[s%'a']++;
        
        else if(s>='A'&&s<='Z')
        sum[s%'A']++;
        
    }
    
    for(i=0;i<26;i++){
        
        printf("%c : %d\n",'a'+i,sum[i]);
        
    }
    return(0);
    
}



Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	n--,k--;
	if(!n){cout<<"0"<<endl;return 0;}
	long long ans=1,plus;
	for(int i=1;i<n;i++){
		plus=ans/k+1;
		ans+=plus;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int md = 1e9+7;
// const int sz = 1e5;
// int A[sz+1];
// int F[sz+1];

// int A[sz+1];


void solve(){
	int n;cin>>n;
	if(n<3){
		cout<<"0"<<endl;
		return;
	}

	vector<int> v(n+1,1);
	v[0] = 0;
	v[1] = 0;
	v[2] = 0;
	// v[3] = 1;
	for(int i=4;i<=n;i++){
		for(int j=i-3;j>=0;j--){
			v[i] = (v[i]+v[j])%md;
		}
	}
	cout<<v[n]<<endl;

return;
}



int32_t main()
{
    IOS;
    // A[0] = 0;
    // F[0] = 1;

    // for (int i = 1; i <= sz; ++i)
    // {
    // 	A[i] = A[i-1]+i;
    // 	F[i] = F[i-1]*i;
    // }

    // for(int i=0;i<10;i++){
    // 	cout<<A[i]<<" ";
    // }
    // cout<<endl;
    // for(int i=0;i<10;i++){
    // 	cout<<F[i]<<" ";
    // }
    // cout<<endl;    
    // coust<<"A and F is filled"<<endl;
    // int t;
    // cin >> t;
    // while (t--) 
        solve();
    return 0;
        

    
}



Measured memory_bytes: 3652
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (wrds toInt) >>= print

solve :: [Int] -> Int
solve [n,k] = k * (k-1) ^ (n-1)

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 508
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int fiveHundred = sc.nextInt();
    int oneHundred = sc.nextInt();
    int fifty = sc.nextInt();
    int price = sc.nextInt();
    int count = 0;
    for (int i = 0; i <= fiveHundred; i++) {
      for (int j = 0; j <= oneHundred; j++) {
        for (int k = 0; k <= fifty; k++) {
          if ((500 * i + 100 * j + 50 * k) == price) {
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 1000000007;
const int N_MAX = 100000;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long inverse[N_MAX+1];
long long factorial[N_MAX+1];
long long factorial_inverse[N_MAX+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}

int main() {
	long long n, k;
	cin >> n >> k;
	calc(n);
	vector<long long> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A.begin(), A.end());
	long long ans = 0;
	for (int i = k-1; i < n; i++) {
		long long x = comb(i, k-1);
		ans = mod(ans + x * A[i] % MOD);
	}
	for (int i = 0; i <= n-k; i++) {
		long long x = comb(n-i-1, k-1);
		ans = mod(ans - x * A[i] % MOD);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

string s;
string r = "NO";

void dfs(int i){
    if(i == s.length()){
        r="YES";
    }
    if(s.substr(i, 5) == "dream" || s.substr(i, 5) == "erase"){
        dfs(i+5);
    }
    if(s.substr(i, 7) == "dreamer"){
        dfs(i+7);
    }
    if(s.substr(i, 6) == "eraser"){
        dfs(i+6);
    }
}

int main(){
    cin>>s;
    dfs(0);
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <map>
using namespace std;


const int N = 10000;

int arr[N];

bool func(string str, int *arr, int k);

int main()
{
	string str;
	int n, k;

	cin >> n >> k;

	for (int i = 0; i < k; i++) {
		cin >> arr[i];
	}

	str = to_string(n);

	while(func(str, arr, k)){
		n++;
		str = to_string(n);
	}

	cout << str << endl;
	return 0;
}

bool func(string str, int *arr, int k)
{
	for (int i = 0; i < k; i++) {
		if (str.find(to_string(arr[i])) != -1) {
			return true;
		}
	}

	return false;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int main(void){
  int i,j, n, cnt;
  char s[100];
  cin >> n >> s;
  
  //文字数が奇数の時Noで終了
  if (n % 2 != 0){
    cout << "No";
    return 0;
  }
  for(i=0; i<n; ++i){
    cnt = 0;
    //cout << s[i] << endl;
    for(j=0; j<n; ++j){
      if (s[j] == s[i])
        ++cnt;
    }
    if (cnt % 2 != 0){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

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

    vector<int> ans(n + 1, 0);
    for (int x = 1; x <= sqrt(n); ++x)
    {
        int x2 = x * x;
        for (int y = 1; y <= sqrt(n); ++y)
        {
            int y2 = y * y;
            for (int z = 1; z <= sqrt(n); ++z)
            {
                if (x2 + y2 + z * z + x * y + y * z + z * x <= n)
                    ans[x2 + y2 + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[2000];
int c[2000];
int dp[5000];
int main(){
    int n,m;
    int b;
    int cc;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d",&a[i]);
        scanf("%d",&b);
        for(int j=0;j<b;j++){
            scanf("%d",&cc);
            c[i]|=(1<<(cc-1));
        }
    }
    for(int i=0;i<(1<<n);i++)dp[i]=1000000000;
    dp[0]=0;
    for(int i=1;i<=m;i++){
        for(int j=0;j<(1<<n);j++){
            dp[j|c[i]]=min(dp[j|c[i]],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==1000000000)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "first" << endl; else cout << "second" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec a(N); readv(a);

    bool ans = false;
    REP(i, N) if(a[i] % 2 == 1) ans = true;
    ANS(ans);
    
    return 0;
}

Measured memory_bytes: 1024