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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#define dprintf(...) printf(__VA_ARGS__)
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#define dprintf(...)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

template <class T>
vec3<T> vec3_init(int n0, int n1, int n2, T x = 0) {
    return vec3<T>(n0, vec2_init(n1, n2, x));
}

/*
 *           U P
 *           - x
 *            ^
 *            |
 * LEFT -y <--+--> +y RIGHT
 *            |
 *            v
 *           + x
 *         D O W N
 */

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

enum {
    DOWN,
    RIGHT,
    UP,
    LEFT,
};

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    ll result = 0;
    int A_MAX = 0;
    REP(i, N) {
        if (A_MAX < A[i]) {
            A_MAX = A[i];
        } else {
            result += A_MAX - A[i];
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3968
#include <cstdio>
#include <algorithm>

using namespace std;

int N, W;
int w[100000];
int v[100000];
int dp[100001];

int main(){

    scanf("%d %d", &N, &W);
    for(int i = 0; i < N; i++){
        scanf("%d %d", &w[i], &v[i]);
    }

    for(int i = 0; i < 100001; i++){
        dp[i] = W + 1;
    }

    dp[0] = 0;

    for(int i = 0; i < N; i++){
        for(int j = 100000; j >= v[i]; j--){
            if(dp[j - v[i]] != -1){
                int temp = dp[j - v[i]] + w[i];
                if(temp <= dp[j]){
                    dp[j] = temp;
                }
            }
        }
    }

    for(int i = 100000; i >= 0; i--){
        if(dp[i] <= W){
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int N, P;
	char c;
	scanf("%d %d", &N, &P);
	int arr[N];
	for (int i = 1; i <= N; ++i) {
		scanf(" %c", &c);
		arr[N - i] = c - '0';
	}
	if (P == 2 || P == 5) {
		long long ans = 0;
		for (int i = 0; i < N; ++i) {
			if (arr[i] % P == 0) ans += N - i;
		}
		printf("%lld", ans);
	} else {
		int p10 = 1;
		for (int i = 0; i < N; ++i) {
			arr[i] = arr[i] * p10 % P;
			p10 = p10 * 10 % P;
		}
		int psum[N + 1];
		psum[N] = 0;
		for (int i = N - 1; i >= 0; --i) psum[i] = (psum[i + 1] + arr[i]) % P;
		long long ans = 0;
		map<int, int> cnt;
		cnt[0] = 1;
		for (int i = N - 1; i >= 0; --i) {
			ans += cnt[psum[i]];
			++cnt[psum[i]];
		}
		printf("%lld", ans);
	}
	return 0;
}

Measured memory_bytes: 2304
package main

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

var sc = bufio.NewScanner(os.Stdin)

var POS = "Positive"
var NEG = "Negative"
var ZERO = "Zero"

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	switch {
	case a <= 0 && 0 < b:
		fmt.Println(ZERO)
	case 0 < a:
		fmt.Println(POS)
	case (b-a)%2 == 0:
		fmt.Println(NEG)
	default:
		fmt.Println(POS)
	}
}

func readInput() string {
	sc.Scan()
	buf := sc.Text()
	return buf
}

func nextInt() int {
	n, err := strconv.Atoi(readInput())
	if err != nil {
		panic(err)
	}
	return n
}

func nextString() string {
	return readInput()
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {      
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int K = sc.nextInt();
      int score = 0;
      if (K < A) {
        score = K;
      } else if(K <= A + B) {
        score = A;
      } else {
        score = A - (K - A - B); 
      }
      System.out.println(score);
    }
}

Measured memory_bytes: 27036
array = []

for i in range(3):
    val = input().split()
    array.append(val)

A,B = [int(s) for s in array[1]]

if array[2][0] == array[0][0]:
    print(str(A - 1) + " " + str(B))
else:
    print(str(A) + " " + str(B - 1))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
  cin >> x;
  int a[x];
  fr(i,x){
    cin >> a[i];
  }
  int t=0;
  fr(i,x){
    if((t+1)==a[i])t++;
  }
  if(t==0)t=x+1;
  cout << x-t << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
const int N=6e5+5;
typedef long long ll;
const ll mod=1e9+7;
ll p[N],inv[N];
ll qpow(ll x,ll y) {
    ll res=1;
    for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
    return res;
}
void init() {
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*i%mod;
    inv[N-1]=qpow(p[N-1],mod-2);
    for(int i=N-2;~i;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int n,int m) {
    if(n<m) return 0;
    return p[n]*inv[m]%mod*inv[n-m]%mod;
}
ll work(int k,int n,int m) {
    ll ans=C(k+n,n),coef=C(n,m);
    for(int i=1;i<=k;i++) {
        int rem=k-m*i;
        if(rem<0) break;
        for(int j=0;j*i<=rem;j++) {
            ll tmp=C(rem-j*i+n,n)*coef%mod*C(n-m,j)%mod;
            if(j&1) ans=(ans+tmp)%mod;
            else ans=(ans-tmp+mod)%mod;
        }
        rem-=m;
        for(int j=0;j*i<=rem;j++) {
            ll tmp=C(rem-j*i+n,n)*coef%mod*C(n-m,j)%mod;
            if(j&1) ans=(ans-tmp+mod)%mod;
            else ans=(ans+tmp)%mod;
        }
    }
    return ans;
}
int main(){
    int n,m,L,R;
    init();
    scanf("%d%d%d%d",&n,&m,&L,&R);
    printf("%lld\n",(work(R,n,m)-work(L-1,n,m)+mod)%mod);
    return 0;
}


Measured memory_bytes: 10232
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

def exp(x):
    return (1+x)/2

total=sum([exp(i) for i in p[:k]])
ans=total
bk=ans
for i in range(1, n-k+1):
    start=i-1
    end=start+k
    total=bk-exp(p[start])+exp(p[end])
    ans=max(ans, total)
    bk=total
    
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------

const double EPS=1e-10;
struct circle {
    int x; int y; int r;
};
struct edge {
    int to; double cost;
};
double distance(int xa,int ya,int xb,int  yb) {
    return sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
}
double distance(const circle &c,int x,int y) {
    return max(distance(c.x,c.y,x,y)-c.r,0.0);
}
double distance(const circle &a,const circle &b) {
    return max(distance(a.x,a.y,b.x,b.y)-a.r-b.r,0.0);
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    circle s,t;
    s.r=0.0,t.r=0.0;
    cin>>s.x>>s.y>>t.x>>t.y>>N;
    vector<circle> c(N+2);
    c[0]=s,c[1]=t;
    FOR(i,2,N+2) {
        cin>>c[i].x>>c[i].y>>c[i].r;
    }

    vector<vector<edge>> g(N+2); // 0:s,1:t,2~:c
    REP(i,N+2) {
        REP(j,N+2) {
            if(i==j) continue;
            // 円同士の辺
            g[i].push_back(edge{j,distance(c[i],c[j])});
            g[j].push_back(edge{i,distance(c[i],c[j])});
        }
    }

    typedef pair<double,int> pdi;
    priority_queue<pdi,vector<pdi>,greater<pdi>> pq;
    vector<double> dist(N+2,INFLL);
    dist[0]=0.0;
    pq.push(pdi(0.0,0));
    while(!pq.empty()) {
        int v=pq.top().second; pq.pop();
        FORE(e,g[v]) {
            if(dist[e.to]-(dist[v]+e.cost)>EPS) {
                dist[e.to]=dist[v]+e.cost;
                pq.push(pdi(dist[e.to],e.to));
            }
        }
    }
    printf("%.10f\n",dist[1]);
    return 0;
}


Measured memory_bytes: 36976
#include <vector>
#include <cstdint>
#include <cstddef>
#include <string>

template<std::uint_fast64_t B = 524287>
struct rolling_hash {
	using u32 = std::uint_fast32_t;
	using u64 = std::uint_fast64_t;
	using i128 = __int128_t;
	using size_type = std::size_t;

private :
	static constexpr u64 mod = (1UL << 61) - 1;
	static constexpr u64 base = B;

	std::vector<u64> hash, pow;

	u64 mul (const i128 &a, const i128 &b) const noexcept {
		i128 value = a * b;
		value = (value >> 61) + (value & mod);
		return (value < mod ? value : value - mod);
	}

	u32 xorshift (u32 value) const noexcept {
		value ^= value << 13;
		value ^= value >> 17;
		value ^= value << 5;
		return value;
	}

public :
	rolling_hash () = default;

	rolling_hash (const std::string &str) noexcept {
		build(str);
	}

	void build (const std::string &str) noexcept {
		const std::size_t n = str.length();
		hash.assign(n + 1, 0);
		pow.assign(n + 1, 1);
		for (std::size_t i = 0; i < n; i++) {
			hash[i + 1] = mul(hash[i], base) + xorshift(str[i] + 1);
			pow[i + 1] = mul(pow[i], base);
		}
	}

	u64 get(size_type first, size_type last) const noexcept {
		if (first > last) std::swap(first, last);
		u64 value = hash[last] + mod - mul(hash[first], pow[last - first]);
		return (value < mod ? value : value - mod);
	}

};


#include <iostream>
#include <vector>
#include <string>
#include <cstdint>
#include <set>

int main() {
	int n;
	std::string s;
	std::cin >> n >> s;
	
	rolling_hash rh(s);
	
	auto f = [&] (int x) -> bool {
		std::set<std::uint_fast64_t> set;
		for (int i = n - x; i >= 0; i--) {
			if (i + x + x <= n) set.emplace(rh.get(i + x, i + x + x));
			if (set.count(rh.get(i, i + x))) return true;
		}
		return false;
	};
	
	int ok = 0, ng = n;
	while (std::abs(ok - ng) > 1) {
		int mid = (ok + ng) >> 1;
		if (f(mid)) ok = mid;
		else ng = mid;
	}
	
	std::cout << ok << '\n';
	
	return 0;
}

Measured memory_bytes: 3924
def main():
    N = int(input())
    A = list(map(int, input().split()))

    while True:
        A.sort()
        mod_max = 0
        for i in range(len(A)-1, 0, -1):
            tmp = A[i] % A[0]
            if tmp == 0:
                A.pop(i)
            else:
                A[i] = tmp
            if mod_max < tmp:
                mod_max = tmp
        if mod_max == 0:
            print(A[0])
            exit()
        elif mod_max == 1:
            print(1)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define $(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define V vector
#define pb push_back
using namespace std;
void MI(int &a, int v) {a = min(a,v);}
void MA(int &a, int v) {a = max(a,v);}

signed main() {
    int x,y; cin>>x>>y;
    if (abs(x-y) <= 1)
        P("Brown");
    else
        P("Alice");
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int left=b-a+1;
    for(int i=left;i<=b+a-1;i++)
    {
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
(let ((str nil)
      (a (concatenate 'list (read-line)))
      (b (concatenate 'list (read-line))))
  (mapcar (lambda (an bn) (push an str) (push bn str)) a b)
  (unless (= (length a) (length b))
    (push (car (last a)) str)
    nil)
  (format t "~A" (concatenate 'string (reverse str))))


Measured memory_bytes: 11488
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){

	int data[50100+1];
	int state=0;
	//素数表の作成
	for(int i=1;i<=50100;i++){
		data[i]=0;
		state = 0;
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				state=1;
				break;
			}
		}
		if(state==0){
			data[i]=1;
		}
	}
	int num;

	while(cin>>num){
		int ans0,ans1;

		for(ans0=num-1;;ans0--){
			if(data[ans0]==1){
				break;
			}
		}
		for(ans1 = num+1;;ans1++){
			if(data[ans1]==1){
				break;
			}
		}
		cout<<ans0<<" "<<ans1<<endl;
	}
	return 0;

}

/*
Sample Input
19
3517
Output for the Sample Input
17 23
3511 3527
*/

Measured memory_bytes: 1352
#include <iostream>
using namespace std;
int main(){
	int H = 0;
	int W = 0;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		for (int i = 0; i<W; i++){
			cout << "#";
		}
		cout << endl;
		for (int i = 0; i < H- 2; i++){
			cout << "#";
			for (int i = 0; i < W - 2; i++){
				cout << ".";
			}
			cout << "#";
			cout << endl;
		}
		for (int i = 0; i < W; i++){
			cout << "#";
		}
		cout << endl;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
n, m = map(int, input().split())

a = [0 for _ in range(m)]

for i in range(n):
    p = list(map(int, input().split()))
    k = p[0]
    for i in range(1, k+1):
        a[p[i]-1] += 1

ans = 0
for i in range(m):
    if a[i] == n:
        ans += 1

print(ans) 

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

bool IsValid(VV<long long> &G) {
    int N = G.size();
    repeat(k, N) {
        repeat(i, N) {
            repeat(j, N) {
                if (G[i][j] > G[i][k] + G[k][j]) {
                    return false;
                }
            }
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    auto A = vectors(0LL, N, N);
    repeat(i, N) {
        repeat(j, N) {
            cin >> A[i][j];
        }
    }
    if (!IsValid(A)) {
        cout << -1 << endl;
    } else {
        const int INF = 1e9 + 7;
        repeat(k, N) {
            repeat(i, N) {
                repeat(j, N) {
                    if (i == j || j == k || k == i) continue;
                    if (A[i][j] == A[i][k] + A[k][j]) {
                        A[i][j] = INF;
                    }
                }
            }
        }
        /* 
        repeat(i, N) {
            repeat(j, N) {
                if (A[i][j] == INF) {
                    cout << "INF"
                         << "\t";
                } else {
                    cout << A[i][j] << "\t";
                }
            }
            cout << endl;
        }
 */
        long long res = 0;
        repeat(i, N) {
            repeat(j, N) {
                if (A[i][j] != INF) {
                    res += A[i][j];
                }
            }
        }
        cout << res / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 4320
def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    cost = 0
    
    if n <= k:
        cost += n * x
    elif n > k:
        cost += k * x + (n - k) * y
    print(cost)
    
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 9124
n=int(input())

a=[]
b=[]

for _ in range(n):
    a_i ,b_i = map(int,input().split())

    a.append(a_i)
    b.append(b_i)

cnt=0

a=list(reversed(a))
b=list(reversed(b))


for i in range(n):
    fr = a[i]+cnt
    target =b[i]

    if fr ==0 or target==1 or fr%target ==0:
        continue

    num = abs(target -fr) // target

    if fr>target:
        target += target*(num+1)
    
    cnt += (target-fr)

print(int(cnt))
        



Measured memory_bytes: 12008
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//----------------ここからだよ-------------------

int main(){
    int r; cin>>r;
    cout<<r*r<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n,h,a[200002];
    cin>>n>>h;
    for(int i=0;i<n;i++){
        cin>>a[i]>>a[i+n];
    }
    sort(a,a+n);
    sort(a+n,a+2*n);
    int m=a[n-1];
    int ans=0,k=0;
    while(h>0){
        if(a[2*n-1-k]>m){
            h-=a[2*n-1-k];
            ans++;
            k++;
        }else{
            h-=m;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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


int main() {
  int A, B, cnt=0;
  cin >> A >> B;
  for(int i=A; i <= B; i++){
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]){
      cnt++;
    }
  }
  cout << cnt << endl;    
}

Measured memory_bytes: 256
/**
 *   author: malviyanshiv
 *   created: 11 January 2019  22:22:51
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff

typedef long long ll;
typedef pair< int, int > PII;

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector< vector<ll> > dp(21, vector<ll>(2097152, -1));
vector< vector<int> > arr(21, vector<int>(21));
int n;

ll cal(int idx, int ass){
    if( idx == -1 )
        return 1;
    ll &res = dp[idx][ass];
    if( res != -1 )
        return res;
    res = 0;
    for(int i = 0; i < n; i++){
        if( arr[idx][i] == 1 && ( (ass & 1<<i ) == 0 )){
            res = (res + cal(idx-1, ass|1<<i))%MOD;
        }
    }
    return res;
}

int main(){
    optimizeIO();

    cin >> n;

    REP(i, 0, n)
        REP(j, 0, n)
            cin >> arr[i][j];

    cout << cal(n-1, 0)%MOD << endl;
    
    return 0;
}

Measured memory_bytes: 360832
package main

import "fmt"

func main() {
	var a1, a2, a3 int
	fmt.Scan(&a1, &a2, &a3)
	sum := a1 + a2 + a3
	if sum >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007; 
long long fac[500010], inv[500010], finv[500010]; 
void COMinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < 500005; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	long long N, M; cin >> N >> M; 
	if(N > M){
		cout << 0 << endl; return 0; 
	}
	COMinit(); 
	long long ans = 0; 
	for(int i = 0; i <= N; i++){
		long long tmp1 = COM(N, i) * COM(M, N) % MOD; 
		long long tmp2 = COM(M-i, N-i) * fac[N] % MOD; 
		long long tmp3 = fac[N-i]; 
		long long tmp = tmp1 * tmp2 % MOD; 
		tmp *= tmp3; tmp %= MOD; 
		if(i % 2){
			tmp = MOD - tmp; 
		}
		ans += tmp; ans %= MOD; 
	}
	cout << ans << endl; 	
}

Measured memory_bytes: 15336
import java.util.Scanner;

public class Main {

	static int a = 0;
	static int b = 0;
	static int c = 0;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int loopNum = scanner.nextInt();
		for (int i = 0; i < loopNum; i++) {
			a = scanner.nextInt();
			b = scanner.nextInt();
			c = scanner.nextInt();

			if (isTriangle(a, b, c)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

	private static boolean isTriangle(int a, int b, int c) {
		if (a >= b && a >= c) {
			return a * a == b * b + c * c;
		} else {
			if (b >= c) {
				return b * b == a * a + c * c;
			} else {
				return c * c == a * a + b * b;
			}
		}
	}
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    long long int arr[n];
    long long int dp[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);

    for(int i=2;i<n;i++)
    {
    	dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
    	for(int j=1;j<=k;j++)
    		if(i-j>=0)
    			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val s = readLine()!!
    val a = s.count { c -> c == 'a' }
    val b = s.count { c -> c == 'b' }
    val c = s.count { c -> c == 'c' }

    val ab = Math.abs(a - b)
    val bc = Math.abs(b - c)
    val ca = Math.abs(c - a)

    if (ab in 0..1 && bc in 0..1 && ca in 0..1) {
        println("YES")
    } else {
        println("NO")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerArray() = readStringList().map(String::toInt).toIntArray()
fun readLongArray() = readStringList().map(String::toLong).toLongArray()


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

using namespace std;

#define ll long long

const int N=1e6+5,MOD=1000000007;

int n,b[N],a[N],q,m,u,v,tc,k,l,x,ans[N];

char s[N];

vector <int> loop;

int main(){ 
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;s[i];i++)
        if (s[i]=='R' && s[i+1]=='L')
            loop.push_back(i);
    int last;
    for(int i=0;s[i];i++){
        int dist;
        if (s[i]=='L'){
            dist=i-last;
            if (dist&1)
                ans[last+1]++;
            else
                ans[last]++;
        }
        else{
            int idx=loop[lower_bound(loop.begin(),loop.end(),i)-loop.begin()];
            last=i;
            dist=idx-i;
            if (dist&1)
                ans[idx+1]++;
            else
                ans[idx]++;
        }
    }
    for(int i=0;i<n;i++)
        printf("%d ",ans[i]);
    
}   


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    double d,t,s;
    cin >> d >> t >> s;
    if(d/s<=t){
        Yes;
    }else{
        No;
    }
}

Measured memory_bytes: 3704
n=input()
ans=0
355
lst=[]
def generate(n,x,count,lst):
    if 0<count<len(n)+1:
        if int(x)<=int(n):
            lst.append(x)
    elif count==0:
        pass
    else:
        return lst
    generate(n,x+'3',count+1,lst)
    generate(n,x+'5',count+1,lst)
    generate(n,x+'7',count+1,lst)
        
x=''
generate(n,x,0,lst)
ans=0
for i in lst:
    san=nana=go=False
    if '3' in i:
        san=True
    if '5' in i:
        go=True
    if '7' in i:
        nana=True
    if san==nana==go==True:
        ans+=1
print(ans)

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

const int maxn=1e6+7;
int a[maxn],b[maxn];

int main (){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int tmp=(a[n]+1)/2;
    int ans=a[1];
    int eps=0x3f3f3f3f;
    for(int i=1;i<n;i++){
        if(abs(a[i]-tmp)<eps){
            ans=a[i];
            eps=abs(a[i]-tmp);
        }
    }
    printf("%d %d\n",a[n],ans);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, a, b;
    cin >> W >> a >> b;

    cout << max(max(b-W-a, 0),a-W-b) << endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int d[N];
    int sum[110] = {0};
    int ans = 0;

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

    for (int i = 0; i < N; i++)
    {
        sum[d[i]]++;
    }

    for (int i = 1; i <= 100; i++)
    {
        if (sum[i] != 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db long double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
const int mxn=1e5+7;
int n,k;
int a[mxn],dp[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    memset(dp,0x3f,sizeof(dp));
    dp[1]=0;
    for (int i=2;i<=n;i++)
    {
        for (int j=1;j<=k;j++)
        {
            if (i-j<=0) break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 5180
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int n,ans=0; cin>>n;
	rep(i,1,n) rep(j,1,n) rep(k,1,n)
	{
		int x=__gcd(i,j); x=__gcd(x,k);
		ans+=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	static char filed[][];
	static int mx[]={-1,0,1,0};
	static int my[]={0,-1,0,1};
	static int w,h,count;
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,j,x=0,y=0;
		char ch[];
		while(true){
			count=0;
			w=sc.nextInt();
			h=sc.nextInt();
			if(w+h==0) break;
			
			filed=new char[h][w];
			ch=new char[w];
			for(i=0;i<h;i++){
				ch=sc.next().toCharArray();
				for(j=0;j<w;j++){
					filed[i][j]=ch[j];
				}
			}
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					if(filed[i][j]=='@'){
						y=i;
						x=j;
					}
				}
			}
			filed[y][x]='#';
			serch(x,y);
			System.out.println(count);
		}
	}
	static void serch(int x,int y){
		int i,nx,ny;
		count++;
		for(i=0;i<4;i++){
			nx=x+mx[i];
			ny=y+my[i];
			if(0<=nx && nx<w && 0<=ny && ny<h && filed[ny][nx]!='#'){
				filed[ny][nx]='#';
				serch(nx,ny);
			}
		}
	}
}

Measured memory_bytes: 12000
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

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

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		A[i] = 100000
	}
	for i := 0; i < n-1; i++ {
		var b int
		fmt.Fscan(read, &b)
		if A[i] > b {
			A[i] = b
		}
		if A[i+1] > b {
			A[i+1] = b
		}
	}
	sum := 0
	for i := 0; i < n; i++ {
		sum += A[i]
	}
	fmt.Fprintln(write, sum)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}


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

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

  vector<int> p(100);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    p[a - 1]++;
  }

  int alice = 0, turn = 0;
  for (int i = 99; i >= 0; i--) {
    if (p[i] == 0) continue; 

    if (turn % 2 == 0) {
      alice += i + 1;
    } else {
      alice -= i + 1;
    }

    p[i]--;
    if (p[i] > 0) i++; 

    turn++;
  }

  cout << alice << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
int main() {
    int c[3][3],d[4][3];
    rep(i,3)rep(j,3)scanf("%d",&c[i][j]);
    d[0][0]=c[0][0]-c[1][0];d[0][1]=c[0][1]-c[1][1];d[0][2]=c[0][2]-c[1][2];d[1][0]=c[1][0]-c[2][0];d[1][1]=c[1][1]-c[2][1];d[1][2]=c[1][2]-c[2][2];d[2][0]=c[0][0]-c[0][1];d[2][1]=c[1][0]-c[1][1];d[2][2]=c[2][0]-c[2][1];d[3][0]=c[0][1]-c[0][2];d[3][1]=c[1][1]-c[1][2];d[3][2]=c[2][1]-c[2][2];
	rep(i,4)rep(j,2)if(d[i][j]!=d[i][j+1]){printf("No");return 0;}
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 210;
const int maxK = 19;
char a[maxN];
int main()
{
	scanf("%s",a);
	int len = strlen(a);
	int ans = len;
	for(int p=len-1;p>=2;p--)
	{
		if(p%2!=0)
			continue;
		int x2 = p/2;
		int flag = 1;
		for(int j=0;j<x2;j++)
		{
			if(a[j] != a[j+x2])
			{
				flag = 0;
				break;
			}
		}
		if(flag)
		{
			printf("%d\n",p);
			break;
		}
	}
	return 0;
}

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

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

if A < 2 * C and Y < X:
  answer += A * (X - Y)
elif B < 2 * C and X < Y:
  answer += B * (Y - X)
else:
  answer += 2 * C * abs(X - Y)

print(answer)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<ll, string> PLS;

int ans;
string s;

map<string, int> msi;

void solve(){
	msi[s] = 0;

	queue<string> que;

	que.push(s);

	while (que.size()){
		string ret = que.front();
		que.pop();

		bool f = 0;
		REP(i, ret.size() - 1){
			if (ret[i] != ret[i + 1])break;
			if (i == ret.size() - 2)f = 1;
		}
		if (f){
			ans = min(ans, msi[ret]);
		}

		REP(i, ret.size() - 1){
			string t = ret;
			if (ret[i] != ret[i + 1]){
				if (ret[i] == 'r'&&ret[i + 1] == 'g'){
					t[i] = 'b';
					t[i + 1] = 'b';
				}
				if (ret[i] == 'g'&&ret[i + 1] == 'r'){
					t[i] = 'b';
					t[i + 1] = 'b';
				}
				if (ret[i] == 'r'&&ret[i + 1] == 'b'){
					t[i] = 'g';
					t[i + 1] = 'g';
				}
				if (ret[i] == 'b'&&ret[i + 1] == 'r'){
					t[i] = 'g';
					t[i + 1] = 'g';
				}
				if (ret[i] == 'b'&&ret[i + 1] == 'g'){
					t[i] = 'r';
					t[i + 1] = 'r';
				}
				if (ret[i] == 'g'&&ret[i + 1] == 'b'){
					t[i] = 'r';
					t[i + 1] = 'r';
				}
				if (t == ret)continue;
				if (msi.find(t) == msi.end()){
					//cout << t << endl;
					que.push(t);
				}
				msi[t] = msi[ret] + 1;
			}
		}
	}
}

int main(){
	while (cin >> s&&s != "0"){
		ans = INF;
		msi.clear();
		solve();
		if (ans == INF)cout << "NA" << endl;
		else cout << ans << endl;
	}
}

Measured memory_bytes: 5376
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

// 集計用
$sm = array();
// 答え
$ans = 0;

for ($i = 0; $i < $N; $i++) {
    $sm[$a[$i]]++;    
}

foreach ($sm as $k => $v) {
    if ($k == $v) {
        
    } elseif ($k > $v) {
        $ans += $v;
    } else {
        $ans += ($v - $k);
    }
}
echo $ans . PHP_EOL;


Measured memory_bytes: 19188
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int D;
  cin >> D;
  vector<int>les(26, 0);
  array<int, 26>c;
  for (int i = 0; i < 26; i ++) cin >> c.at(i);
  for (int i = 0; i < D; i ++) {
    array<int, 26>s;
    for (int j = 0; j < 26; j ++) {
      cin >> s.at(j);
    }
    pair<int, int>t = make_pair(0, 0);
    int t_ = -1;
    for (int j = 0; j < 26; j ++) {
      pair<int, int> kj = make_pair(s.at(j), -1 * c.at(j) * les.at(j));
      int p_ = j;
      if (t < kj) {
        t = kj;
        t_ = p_;
      }
      else if (t == kj && c.at(t_) < c.at(p_)) {
        t = kj;
        t_ = p_;
      }
    }
    cout << t_ + 1 << endl;
    for (int j = 0; j < 26; j ++) {
      if (j == t_) les.at(j) = 0;
      else les.at(j) ++;
    }
  }
}





Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll n,m;
int vis[N];
vector<int> v[N];
bool dfs(int x,int bef){
    if(vis[x]==bef)return 0;
    bef=3-bef;
    if(vis[x]==bef)return 1;
    vis[x]=bef;
    bool ok=true;
    for(auto y:v[x]){
	ok&=dfs(y,bef);
    }
    return ok;
}
int main(){
    cin>>n>>m;
    lol(i,m){
	int a,b;cin>>a>>b;a--,b--;
	v[a].push_back(b);
	v[b].push_back(a);
    }
    lol(i,n)vis[i]=0;
    ll x=0,y=0,z=0;
    lol(i,n){
	if(vis[i]==0){
	    if(v[i].size()==0)z++;
	    else{
		if(dfs(i,1))x++;
		else y++;
	    }
	}
    }
    ll ans=2*x*(x+y)+y*y;
    ans+=n*n-(n-z)*(n-z);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && (Math.abs(b - c) <= d))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
    int i,j,k,L,A,B,C,D,max;
    scanf("%d",&L);
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);

    max=(A/C >= B/D)?A/C : B/D;
    if(A/C >= B/D){
        if(A%C>0){
            max+=1;
        }
    }
    else if(A/C < B/D){
        if(B%D>0){
            max+=1;
        }
    }

    printf("%d\n",L-max);


    return 0;
}

Measured memory_bytes: 1808
#include <iostream>


int main()
{
    int t,h,m,s;
    std::cin >> t;
    h=t/3600;
    m=(t-3600*h)/60;
    s=(t-3600*h-60*m);
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

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

using namespace std;

int main(){
   int edge[3];
   for(int i=0;i<3;i++) cin >> edge[i];
   sort(edge,edge+3);
   cout << edge[0]*edge[1]/2<<endl;

   return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	char b;
	cin >> b;
	if(b == 'A'){
		cout << "T" << endl;
	}
	else if(b == 'T'){
		cout << "A" << endl;
	}
	else if(b == 'C'){
		cout << "G" << endl;
	}
	else{
		cout << "C" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    INF=10**11
    from bisect import bisect_left
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]

    for _ in range(q):
        x=int(input())
        s=bisect_left(S,x)
        t=bisect_left(T,x)
        ans=max(T[t],S[s])-x
        ans=min(ans,S[s]-T[t-1]+min(S[s]-x,x-T[t-1]))
        ans=min(ans,x-min(S[s-1],T[t-1]))
        ans=min(ans,T[t]-S[s-1]+min(T[t]-x,x-S[s-1]))
        print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 12800
n, a, b = map(int, input().split())

ans = float('inf')
if (b - a) % 2 == 0:
    ans = min(ans, (b - a) // 2)
else:
    ans = min(ans, b - 1)
    ans = min(ans, n - a)
    ans = min(ans, (b - a - 1) // 2 + n - b + 1)
    ans = min(ans, (b - a - 1) // 2 + a)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[100000];
	int n,i;
	scanf("%s",s);
	n=strlen(s);
	//printf("s=%s\n",s);
	for(i=0;i<n;i++){
		if(i%2==0){
			printf("%c",s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;

const int MAX_N=1e5+10;

int n,m,u,v,ok=1; ll s;
vector<vector<pair<int,ll>>> G(MAX_N);
vector<vector<ll>> cnt(2,vector<ll>(MAX_N,INF));

void dfs(int v,int p){
    for (auto e:G[v]){
        int u=e.first,update=0;
        if (u==p) continue;
        if (cnt[0][v]!=INF){
            ll x=e.second-cnt[0][v];
            if (cnt[1][u]!=INF&&cnt[1][u]!=x) ok=0;
            else if (cnt[1][u]==INF) cnt[1][u]=x,update=1;
        }
        if (cnt[1][v]!=INF){
            ll x=e.second-cnt[1][v];
            if (cnt[0][u]!=INF&&cnt[0][u]!=x) ok=0;
            else if (cnt[0][u]==INF) cnt[0][u]=x,update=1;
        }
        if (update) dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=0;i<m;++i){
        cin >> u >> v >> s; --u,--v;
        G[u].emplace_back(v,s);
        G[v].emplace_back(u,s);
    }
    cnt[0][0]=0;
    dfs(0,-1);
    if (!ok){cout << 0 << '\n'; return 0;}
    ll x=INF;
    for (int v=0;v<n;++v) if (cnt[0][v]!=INF&&cnt[1][v]!=INF){
        if ((cnt[1][v]-cnt[0][v])%2!=0) ok=0;
        x=(cnt[1][v]-cnt[0][v])/2; break;
    }
    if (x!=INF){
        for (int v=0;v<n;++v){
            if (cnt[0][v]!=INF&&x+cnt[0][v]<1) ok=0;
            if (cnt[1][v]!=INF&&-x+cnt[1][v]<1) ok=0;
            if (cnt[0][v]!=INF&&cnt[1][v]!=INF){
                if ((cnt[1][v]-cnt[0][v])%2!=0) ok=0;
                if (x!=(cnt[1][v]-cnt[0][v])/2) ok=0;
            }
        }
        if (!ok){cout << 0 << '\n'; return 0;}
        cout << 1 << '\n'; return 0;
    }
    ll Min=INF,Max=0;
    for (int v=0;v<n;++v){
        Min=min(Min,cnt[1][v]);
        Max=max(Max,-cnt[0][v]);
    }
    cout << max(0LL,Min-Max-1) << '\n';
}

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

int h,w,n;
int table[105][105];

P next (P now) {
    if (now.first%2 == 0) {
        if (now.second+1 < w) return make_pair(now.first, now.second+1);
        return make_pair(now.first+1, now.second);
    }
    if (0 < now.second) return make_pair(now.first, now.second-1);
    return make_pair(now.first+1, now.second);
}

int main() {
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    P now = make_pair(0,0);
    rep(i,n) {
        rep(j,a.at(i)) {
            table[now.first][now.second] = i+1;
            now = next(now);
        }
    }
    rep(i,h) {
        rep(j,w) {
            cout << table[i][j];
            if (j != w-1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		ll N; scanf("%lld", &N); if (N == 0) break;
		vector<vector<ll>> p(N);
		for (int i = 0; i < N; i++) {
			ll M; scanf("%lld", &M);
			p[i].resize(M);
			for (int j = 0; j < M; j++) scanf("%lld", &p[i][j]);
			sort(p[i].begin(), p[i].end());
		}
		vector<ll> res;
		ll K; scanf("%lld", &K);
		vector<ll> l(K); for (ll i = 0; i < K; i++) scanf("%lld", &l[i]);
		for (int i = 0; i < N; i++) {
			bool flag = true;
			for (int j = 0; j < K; j++) {
				if (!binary_search(p[i].begin(), p[i].end(), l[j])) {
					flag = false;
					break;
				}
			}
			if (flag) res.push_back(i);
		}
		if (res.size() == 1) {
			printf("%lld\n", res[0] + 1);
		}
		else {
			puts("-1");
		}
	}

	return 0;
}


Measured memory_bytes: 3356
#include<iostream>
using namespace std;
const int N=2005;
bool t[5][N][N];
int rui[5][N][N];
int s[200005];
int main(){
	int n,m,q;
	int i,j,k;
	int a,b,c,d,e,f;
	cin>>n>>m>>q;
	char ca[N];
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0;j<m;j++){
			if(ca[j]=='1')t[0][i][j]=true;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(!t[0][i][j]){
				rui[0][i+1][j+1]=rui[0][i][j+1]+rui[0][i+1][j]-rui[0][i][j];
				continue;
			}
			a=0;
			if(i!=0 && t[0][i-1][j])a++,t[1][i][j]=true;
			if(t[0][i+1][j])a++,t[1][i+1][j]=true;
			if(j!=0 && t[0][i][j-1])a++,t[2][i][j]=true;
			if(t[0][i][j+1])a++,t[2][i][j+1]=true;
			a=2-a;
			rui[0][i+1][j+1]=a+rui[0][i][j+1]+rui[0][i+1][j]-rui[0][i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			rui[1][i][j+1]=rui[1][i][j],rui[2][i+1][j]=rui[2][i][j];
			if(t[1][i][j])rui[1][i][j+1]++;
			if(t[2][i][j])rui[2][i+1][j]++;
		}
	}
	//for(i=0;i<3;i++){
		//for(j=0;j<=n;j++){
			//for(k=0;k<=m;k++){
				//cout<<rui[i][j][k]<<" ";
			//}
			//cout<<endl;
		//}
		//cout<<endl;
	//}
	
	for(i=0;i<q;i++){
		cin>>a>>b>>c>>d;
		s[i]=rui[0][c][d]-rui[0][a-1][d]-rui[0][c][b-1]+rui[0][a-1][b-1];
		s[i]+=rui[1][a-1][d]-rui[1][a-1][b-1];
		s[i]+=rui[1][c][d]-rui[1][c][b-1];
		s[i]+=rui[2][c][b-1]-rui[2][a-1][b-1];
		s[i]+=rui[2][c][d]-rui[2][a-1][d];
		s[i]/=2;
	}
	for(i=0;i<q;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
		
	


Measured memory_bytes: 65024
#include <iostream>

using namespace std;

int A, B;

int main(void)
{
	cin >> A >> B;
	
	if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> ns(3, 0);
  for(int i = 0; i < s.size(); ++i) {
    ns[s[i] - 'a']++;
  }
  for(auto n : ns) {
    if(n != 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define fo(i, t) for(int i = 0; i < t; i++)
#define rfo(i, t) for(int i = n - 1; i > 0; i--)
#define pb push_back

/*typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> mi;*/

using namespace std;

int main()
{
	int t = 1;
	string s;	
	for(int i = 0; i < t; i++)
	{
		cin >> s;
		if(s[s.length() - 1] != 's')
			s.push_back('s');
		else
		{
			s.push_back('e');
			s.push_back('s');	
		}
	}
	cout << s;
}

Measured memory_bytes: 3612