akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long N;
    cin >> N;
    // vector<long long> A(N);

    // for (&x : A)
    // {
    //     cin >> x;
    // }

    long long front;
    long long me;
    long long sum = 0;

    cin >> front;

    for (long long i = 0; i < N-1; i++)
    {
        cin >> me;

        int sub = front - me;
        if (sub > 0)
        {
            sum += sub;
            front = me + sub;
        }
        else
        {
            front = me;
        }
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long n,x;cin>>n>>x;
    long long tempA; cin>>tempA;
    long long cnt = 0;
    if(tempA > x){
        cnt+=tempA-x;
        tempA=x;
    }
    
    for(int i = 1; i<n;++i){
        long long a; cin>>a;
        if(tempA + a > x){
            cnt+=(tempA+a)-x;
            tempA=x-tempA;
        }
        else{
            tempA=a;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC049();

int main()
{
	ABC049();
	fflush(stdout);
	return 0;
}

static void ABC049()
{
	std::string orgs;
	std::cin >> orgs;

	int nowPos = 0;
	int sLen = orgs.length();
	std::string last;
	std::string bfr;
	while(nowPos < sLen) {
		std::string tmp;
		for (int j = nowPos; (j < nowPos + 5) && (j < sLen); j++) {
			tmp += orgs[j];
		}
		if ((tmp == "dream") || (tmp == "erase")) {
			bfr = tmp;
			nowPos += 5;
		}
		else {
			if ((tmp.size() >= 2) && (tmp[0] == 'e') && (tmp[1] == 'r') && (bfr == "dream")) {
				bfr = "dreamer";
				nowPos += 2;
			}
			else if ((tmp.length() >= 1) && (tmp[0] == 'r') && (bfr == "erase")) {
				bfr = "eraser";
				nowPos += 1;
			}
			else {
				printf("NO\n");
				return;
			}
		}
	}
	printf("YES\n");
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long no[180],ans[180];
map<long long,long long> mp;
long long f(long long k)
{
    if (mp[k]) return mp[k];
    for(int i=1;i<=177;i++)
        if (k==no[i]) return mp[k]=ans[i];
    if (k%2==0) return mp[k]=(2*f(k/2-1)+f(k/2))%mod;
    return mp[k]=(f(k/2-1)+2*f(k/2))%mod;
}
int main()
{
     long long n;
     cin>>n;
     no[1]=0;no[2]=1;no[3]=2;
     ans[1]=1;ans[2]=2;ans[3]=4;
     for(int i=2;i<=59;i++)
     {
          no[3*i-2]=(1ll<<i)-2;
          no[3*i-1]=no[3*i-2]+1;
          no[3*i]=no[3*i-1]+1;
          ans[3*i-2]=(2*ans[3*i-5]+ans[3*i-4])%mod;
          ans[3*i-1]=(ans[3*i-5]+2*ans[3*i-4])%mod;
          ans[3*i]=(ans[3*i-1]+i+1)%mod;
     }
     cout<<f(n)<<endl;
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll mod = 2e18;
map<ll, ll> ma;
void de(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		while (n != i) {
			if (n%i == 0) {
				ma[i]++;
				n /= i;
			}
			else {
				break;
			}
		}
	}
	ma[n]++;
}
void solve() {
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return;
	}
	de(n);
	ll ans = 0;
	for (auto m : ma) {
		//cout << m.first << endl;
		//cout << m.second << endl;
		ans += (int)(sqrt(1 + 8 * m.second) - 1) / 2;
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3704
# dfs

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = float('inf')


def calc(mask):
    abc = [0 for _ in range(4)]
    cnt = 0
    for j in range(N):
        idx = (mask >> (2 * j)) & 3
        abc[idx] += l[j]
        if 0 <= idx < 3:
            cnt += 1
    if 0 in abc[:3]:
        return INF
    return sum(abs(x - t) for x, t in zip(abc, [A, B, C])) + (cnt - 3) * 10


def dfs(cur, mask):
    if cur == N:
        return calc(mask)

    res = INF
    for i in range(4):
        res = min(res, dfs(cur + 1, mask | i << (2 * cur)))
    return res


print(dfs(0, 0))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; 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 N; cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int cnt[100001] = {};
    int ans = 0;
    rep(i, N) {
        if(a[i] <= 100000) cnt[a[i]]++;
        else ans++;
    } 
    rep(i, 100001) {
        if (cnt[i] == 0) continue;
        if (cnt[i] < i) ans += cnt[i];
        else if (cnt[i] > i) ans += cnt[i] - i;
    }
    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>


int main(void){
    int count=0;
    int n=0;
    int R=0,G=0,B=0,N=0;
    scanf("%d %d %d %d",&R,&G,&B,&N);
    for(int i=0;i<=N;i++){
        if(i*R>N) break;
        for(int j=0;j<=N;j++){
            if(i*R+j*G>N) break;
            n=N-(i*R+j*G);
            if(n%B==0){
                count++;
            }
        }
    }
    printf("%d\n",count);  
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 1005;

int n, m, k;
char mat[N][N];
int cnt[N][N];

string bin(int x) {
  string ans;
  while (x > 0) {
    if (x & 1) {
      ans = '1' + ans;
    } else {
      ans = '0' + ans;
    }
    x >>= 1;
  }
  return ans;
}

int sum(int x1, int y1, int x2, int y2) {
  int ans = cnt[x2][y2];
  if (x1 > 0) {
    ans -= cnt[x1 - 1][y2];
  }
  if (y1 > 0) {
    ans -= cnt[x2][y1 - 1];
  }
  if (x1 > 0 && y1 > 0) {
    ans += cnt[x1 - 1][y1 - 1];
  }
  return ans;
}

int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> mat[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cnt[i][j] = (mat[i][j] == '1');
      if (i > 0) {
        cnt[i][j] += cnt[i - 1][j];
      }
      if (j > 0) {
        cnt[i][j] += cnt[i][j - 1];
      }
      if (i > 0 && j > 0) {
        cnt[i][j] -= cnt[i - 1][j - 1];
      }
    }
  }
  int res = 2e9;
  for (int mask = 0; mask < (1 << n); mask++) {
    bool bad = 0;
    vector <int> vec;
    vec.push_back(-1);
    for (int j = 0; j < n; j++) {
      if (mask & (1 << j)) {
        vec.push_back(j);
      }
    }
    if (!(mask & (1 << (n - 1)))) vec.push_back(n - 1);
    int lst = 0;
    int ce = 0;
    int ans = __builtin_popcount(mask);
    for (int j = 0; j < m; j++) {
      for (int x = 1; x < vec.size(); x++) {
        int xx = vec[x - 1] + 1;
        int yy = vec[x];
        if (sum(xx, j, yy, j) > k) {
          bad = 1;
          break;
        }
      }
    }
    if (bad) continue;
    while (ce < m) {
      bool ok = 1;
      for (int x = 1; x < vec.size(); x++) {
        int xx = vec[x - 1] + 1;
        int yy = vec[x];
        ok &= (sum(xx, lst, yy, ce) <= k);
      }
      if (!ok) {
        lst = ce;
        ans++;
      }
      ce++;
    }
    res = min(res, ans);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2304
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    H, W = read_ints()
    counter = Counter()
    for _ in range(H):
        counter += Counter(input())
    C = list(counter.values())
    fours = H//2*W//2
    twos = W//2*(H%2)+H//2*(W%2)
    ones = (H%2)*(W%2)
    for c in C:
        while c != 0:
            if c >= 4 and fours > 0:
                fours -= 1
                c -= 4
            elif c >= 2 and twos > 0:
                twos -= 1
                c -= 2
            elif c >= 1 and ones > 0:
                ones -= 1
                c -= 1
            else:
                return 'No'
    return 'Yes'


if __name__ == '__main__':
    print(solve())


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int N, A, B, C, D;
string S;

// true: ok, false: ng
bool check2(int s, int e, int o = -1)
{
    bool obstacle = false;;
    for (int i = s; i < e - 1; i++) {
        if (S[i] == '.') {
            obstacle = false;
        } else if (S[i] == '#' || i == o) {
            if (obstacle) {
                //2回連続で出現
                return false;
            } else {
                obstacle = true;
            }
        }
    }
    return true;
    
}

bool check1()
{
    //Bを移動させる
    bool b_ok = false;
    int my_B;
    for (int i = B; i <= D;) {
        if (S[i-2]=='.'&&S[i]=='.') {
            my_B = i;
            b_ok = true;
            break;
        }
        if (S[i] == '.')
            i++;
        else if (S[i+1] == '.')
            i+=2;
        else
            break;
    }
    
    return b_ok && check2(A,C,my_B) && check2(my_B, D);
}

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

    cin >> N >> A >> B >> C >> D >> S;

    bool f;

    if (D < C) {
        // A-C が B-Dを内包する場合
        f = check1();
    } else if (A < B && C < D) {
        // A-Cの一部とB-Dの一部が重なる場合
        f = check2(B, D) && check2(A, C);
    } else {
        // A-C, B-Dが重ならない場合        
        f = check2(A,C) && check2(B,D);
    }
    
    Yes(f);
}


Measured memory_bytes: 592
#include<stdio.h>
int solve(int,int);
int n,A[20];
 
int main(){
  int q,Mi,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Mi);
    if(solve(0,Mi)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}


int solve(int i,int m){
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  int res=solve(i+1 , m) ||solve(i+1 , m-A[i]);
return res;
}

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

int main() {

    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;

    return 0;
}

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

int main() {
 string S;
 cin >> S;
 bool a = false;
 sort(S.begin(),S.end());
 if(S.at(0)==S.at(1)&&S.at(1)!=S.at(2)&&S.at(2)==S.at(3)){
   a=true;
 }
 if(a){
   cout << "Yes" << endl;
 }
   else{
     cout << "No" << endl;
   }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<char> s;
    string str;
    cin >> str;
    for(int i = 0;i < (int)str.size();++i)
    {
        s.insert(str[i]);
    }
    char ans;
    if(s.size() == 26)
        cout << "None" << '\n';
    else
    {
        for(int i = 0;i < 26;i++)
        {
            auto l = s.insert('a' + i);
            if(l.second)
            {
                ans = 'a' + i;
                cout << ""s + ans << '\n';
                break;
            }
        }
    }
}


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

const int MAX_N = 1e5;

int K;
vector<int> a(MAX_N), b(MAX_N), c(MAX_N, 0);
vector<vector<int> > G(MAX_N + 1);
map<pair<int, int>, int> memo;
map<pair<int, int>, bool> used;
bool visit[MAX_N+1];

void color(int a) {
  if (visit[a])
    return;

  visit[a] = true;
  vector<bool> unused(K+1, true);
  for (int i = 0; i < G[a].size(); i++) {
    int b = G[a][i];
    unused[c[memo[{a, b}]]] = false;
  }

  for (int i = 0; i < G[a].size(); i++) {
    int b = G[a][i];
    if (!used[{a, b}]) {
      used[{a, b}] = used[{b, a}] = true;
      int col;
      for (int i = 1; i <= K; i++) {
        if (unused[i]) {
          col = i;
          unused[i] = false;
          break;
        }
      }
      c[memo[{a, b}]] = col;
    }
  }

  for (int i = 0; i < G[a].size(); i++) {
    color(G[a][i]);
  }
}

int main(void) {
  int N;
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    cin >> a[i] >> b[i];
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
    memo[{a[i], b[i]}] = memo[{b[i], a[i]}] = i;
  }

  int idx;
  for (int i = 0; i <= N; i++) {
    if (K < G[i].size()) {
      K = G[i].size();
      idx = i;
    }
  }

  for (int i = 0; i < G[idx].size(); i++) {
    int a = idx, b = G[idx][i];
    c[memo[{a, b}]] = i + 1;
    used[{a, b}] = used[{b, a}] = true;
  }

  visit[idx] = true;
  for (int i = 0; i < G[idx].size(); i++) {
    color(G[idx][i]);
  }
  
  cout << K << endl;
  for (int i = 0; i < N-1; i++)
    cout << c[i] << endl;
}

Measured memory_bytes: 34944
#include <stdio.h>

int main(void)
{
	int A,B;
	scanf("%d", &A); scanf("%d", &B);
	int C;
	C = A - 2*B;
	if (C <= 0)
		printf("%d\n", 0);

	else
		printf("%d\n", C);

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N;
    cin >> N;
    vec<lint> scores(N);
    range(i, 0, N) cin >> scores.at(i);
    sort(scores.begin(), scores.end());
    lint sum_scores = accumulate(scores.begin(), scores.end(), 0LL);
    if (sum_scores % 10 != 0) {
        cout << sum_scores << "\n";
        return 0;
    }
    for (const auto s : scores) {
        if ((sum_scores - s) % 10 != 0) {
            cout << sum_scores - s << "\n";
            return 0;
        }
    }
    cout << 0 << "\n";
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        H: usize,
        W: usize,
        c: [[i64; 10]; 10],
        A: [[i64; W]; H],
    }
    let mut dist = c;
    warchall_floyd(&mut dist);
    let mut ans = 0;
    for i in 0..H {
        for j in 0..W {
            if A[i][j] == -1 || A[i][j] == 1 {
                continue;
            }
            ans += dist[A[i][j] as usize][1];
        }
    }
    println!("{}", ans);
}

fn warchall_floyd(dist: &mut Vec<Vec<i64>>) {
    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                dist[i][j] = std::cmp::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int s; cin >> s;
  int ss = s%60;
  s = s - ss;
  int m = s/60;
  int h = m/60;
  int mm = m%(60);
  cout << h << ":" << mm << ":" << ss << endl;
}


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

int main(){
  string S,T,U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (S == U){
    cout << A - 1 << ' ' << B;
  }else{
    cout << A << ' ' << B - 1;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s1 = s.substring(0,4);
        String s2 = s.substring(4);
        System.out.println(s1 + " " + s2);
    }
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
#define INF 1000000000
#define MOD 1000000007
#define MAXN 105
#define lint long long
using namespace std;

struct ii {
	int a, b, c;
	bool operator > (ii o) const {
		return tie(a, b, c) > tie(o.a, o.b, o.c);
	}
};

struct iii {
	int a, b, c, d, e;
	bool operator > (iii o) const {
		return tie(a, b, c, d, e) > tie(o.a, o.b, o.c, o.d, o.e);
	}
};

int TC, N, M, K, Q, x, y, z, cnt, mnm, mks, ptr, ans;
priority_queue<iii, vector<iii>, greater<iii> > pq;
vector<ii> edge[MAXN];
int dist[MAXN][MAXN];

int mod(lint n) { return (n%MOD + MOD)%MOD; }

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	ios::sync_with_stdio(0);
	
	cin>>N>>M;
	edge[0].push_back({-1, -1, -1});
	for (int i = 0; i < M; i++) {
		cin>>x>>y>>z;
		edge[x].push_back({z, y, 0});
		edge[y].push_back({z, x, 0});
	}
	
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			dist[i][j] = INF;
		}
	}
	for (int i = 1; i <= N; i++) {
		//~ dist, awal, now, prev, idxVec
		pq.push({0, i, i, 0, 0});
		while (!pq.empty()) {
			iii now = pq.top(); pq.pop();
			if (now.a > dist[now.b][now.c]) continue;
			edge[now.d][now.e].c = 1;
			for (int i = 0; i < edge[now.c].size(); i++) {
				int cost = now.a+edge[now.c][i].a;
				if (cost <= dist[now.b][edge[now.c][i].b]) {
					dist[now.b][edge[now.c][i].b] = cost;
					pq.push({cost, now.b, edge[now.c][i].b, now.c, i});
				}
			}
		}
	}
	
	ans = 0;
	for (int i = 1; i <= N; i++) {
		for (ii j: edge[i]) {
			if (!j.c) ans++;
		}
	}
	ans>>=1;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF INT_MIN

#define nax 200005


void solve(){
	
	int n;
	cin>>n;
	int arr[n];

	rep(i,0,n){
		cin>>arr[i];
	}
	int zor_tot = arr[0];
	rep(i,1,n){
		zor_tot = zor_tot ^ arr[i];
	}

	rep(i,0,n){
		cout<<(arr[i] ^ zor_tot)<<" ";
	}
	cout<<endl;



	
}	

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

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

int ans[115][2][12];//二つ目の次元の0の0に数列の長さ、0の1に操作回数、1に答えの数列

int counter=0,flag=0;

void solve(){
	int n;
	cin >> n;
	if(n==0){flag=1;return;}
	ans[counter][0][0]=n;
	
	int S[12];//数列
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	
	bool check=false;//操作の有無のフラグ
	int time=0;//操作回数
	do{
		map<int,int> marker;
		for(int i=0;i<n;i++){
			marker[S[i]];
			marker[S[i]]++;
		}
		check=false;
		for(int i=0;i<n;i++){
			if(S[i]!=marker[S[i]]){
				check=true;
				S[i]=marker[S[i]];
			}
		}
		if(check) time++;
	}while(check);
	
	ans[counter][0][1]=time;
	for(int i=0;i<n;i++){
		ans[counter][1][i]=S[i];
	}
	counter++;
}

int main(){
	while(flag==0)solve();
	for(int i=0;i<counter;i++){
		cout << ans[i][0][1] << endl;
		for(int j=0;j<ans[i][0][0]-1;j++){
			cout << ans[i][1][j]<<" ";
		}
		cout << ans[i][1][ans[i][0][0]-1] << endl;
	}
}
			
	
	

Measured memory_bytes: 1208
#include<iostream>
#include<string>

int main(){
  int n,a,b;
  std::cin >> n >> a >> b;
  std::string input;
  std::cin >> input;
  int total=0;
  int around=0;
  for(int i=0;i<input.size();i++){
    if(input[i] == 'a'){
      if(total < a+b){
        total++;
        std::cout << "Yes" << std::endl;
      }else{
        std::cout << "No" << std::endl;
      }
    }


    if(input[i] == 'b'){
      if(total < a + b){
        if(around < b){
          around++;
          total++;
          std::cout << "Yes" << std::endl;
        }else{
          std::cout << "No" << std::endl;
        }
      }else{
        std::cout << "No" << std::endl;
      }
    }

    if(input[i] == 'c'){
      std::cout << "No" << std::endl;
    }


  }
  return 0;
}


Measured memory_bytes: 896
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def Base_10_to_n(X, n):
    if int(X / n):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


n, k = map(int, readline().split())
print(len(Base_10_to_n(n, k)))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct BIT{
  ll M=1;
  vector<ll> dat;
  BIT(ll N){
    while(N>M) M*=2;
    dat.resize(M*2-1, 0);
  }
  void update(ll x, ll k){
    for(int i=k+1;i<=M;i+=(i&(-i))){
      dat[i] += x;
    }
  }
  ll sum(ll r){
    ll ret = 0;
    for(int k=r;k>0;k-=(k&(-k))) ret += dat[k];
    return ret;
  }

  ll query(ll l, ll r){
    return sum(r) - sum(l);
  }
};

int main(int argc, char const *argv[]) {
  ll n, q;scanf("%lld %lld", &n, &q);
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    scanf("%lld",&c[i]);
    c[i]--;
    x[c[i]].push_back(i);
  }
  BIT seg(n+1);
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;scanf("%lld %lld", &l, &r);
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    seg.update(1, i);
    if(pre!=0) seg.update(-1, pre-1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.query(l, i+1);
    }
  }
  re(i, q) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 72024
N=int(input())
nums=list(map(int,input().split(" ")))
ap={}
co=0 
for i in nums:
	if i in ap:
		ap[i]+=1
	else:
		ap[i]=1

for i in ap:
    if ap[i]<i:
        co+=ap[i]
    else:
        co+=(ap[i]-i)
print(co)

Measured memory_bytes: 18168
#include <iostream>
#include <string> 
using namespace std;
 
typedef long long ll;
 
string op[100005];
ll a[3];
string ans;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 1; i <= n; i++)
	{
		cin >> op[i];
	}
	for (int i = 1; i <= n; i++)
	{
		int id1 = op[i][0] - 'A';
		int id2 = op[i][1] - 'A';
		if( i == n )
		{
			if( a[id1] != 0 ) ans += id2 + 'A';
			else if( a[id2] != 0 ) ans += id1 + 'A';
			else
			{
				cout << "No" << '\n';
				return 0;
			}
			continue;
		}
		if( a[id1] == a[id2] )
		{
			if( a[id1] == 0 )
			{
				cout << "No" << '\n';
				return 0;
			}else if( a[id1] == 1 )
			{
				string t = op[i+1];
				if( t[0] - 'A' == id1 || t[1] - 'A' == id1 ) 
				{
					ans += id1 + 'A';
				}else ans += id2 + 'A'; 
			}else
			{
				ans += id1 + 'A';
			}
		}else
		{
			if( a[id1] > a[id2] )
			{
				ans += id2 + 'A';
			}else ans += id1 + 'A';
		}
		char z = ans[ans.length()-1] - 'A';
		if( id1 == z )
		{
			a[id1] ++;
			a[id2] --;
		}else
		{
			a[id2] ++;
			a[id1] --;
		}
	}
	cout << "Yes" << '\n';
	for (int i = 0; i < ans.length(); i++)
	{
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 6860
s = int(input())
a = [s, ]

while True:
    m = a[-1]

    if m % 2 == 0:
        a_m = m / 2
    else:
        a_m = 3 * m + 1
        
    for index, a_n in enumerate(a):
        if a_m == a_n:
            ans = len(a) + 1
            print(ans)
            exit()

    a.append(a_m)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	x=0;
	FORR(c,S) {
		if(c=='(') {
			x++;
			T+='(';
		}
		else {
			if(x>0) {
				x--;
				T+=')';
			}
			else {
				T="("+T+")";
			}
		}
	}
	while(x) T+=")", x--;
	cout<<T<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop

def dijkstra1(V, n, source):
    # O(ElogV)

    inf = float("inf")
    dist = [inf] * (n+1)
    dist[source] = 0
    q = [(0, source)]

    while q:
        cost, u = heappop(q)
        if dist[u] < cost:
            continue
        for c, v in V[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                heappush(q, (dist[v], v))

    return dist


def solve():
    N, M = map(int, input().split())
    V = {i:[] for i in range(1, 3*N+1)}
    for _ in range(M):
        u, v = map(int, input().split())
        V[u].append((1, v+(N)))
        V[u+(N)].append((1, v+(2*N)))
        V[u+(2*N)].append((1, v))

    S, T = map(int, input().split())
    dist = dijkstra1(V, 3*N, S)[T]
    print(-1 if dist==float("inf") else dist//3)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 120160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
void solve() {
   rep(i,5){
      int x; cin >> x;
      if (!x)cout << i+1 << endl;
   }
}
int main() {
   cin.tie(nullptr); ios::sync_with_stdio(false);
   solve();
}

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

int main(){
  int n, x, cnt;
  cnt = 0;
  cin >> n >> x;
  while (n != 0 || x != 0)
  {
    for (int i = 1; i<=n; i++) for (int j = i+1; j<=n; j++) for (int k = j+1; k<=n; k++)
    {
      if (i == j || j == k || k == i) continue;
      else if (i + j + k == x) cnt ++;
    }
    cin >> n >> x;
    cout << cnt << "\n";
    cnt = 0;
  }
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100003,INF=1<<30;
struct edge{
    int h;
    int f;
    int t;
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,A;cin>>N>>M>>A;
        if(N==0) break;
        
        vector<edge> S(M);
        for(int i=0;i<M;i++){
            cin>>S[i].h>>S[i].f>>S[i].t;
        }
        sort(all(S),[](edge a,edge b){
            return a.h>b.h;
        });
        
        for(int i=0;i<M;i++){
            if(S[i].f==A){
                A=S[i].t;
            }else if(S[i].t==A){
                A=S[i].f;
            }
        }
        
        cout<<A<<endl;
    }
}




Measured memory_bytes: 3152
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;

struct Graph {
    node: usize,
    directed: bool,
    graph: Vec<Vec<(usize, i64)>>,
}

impl Graph {
    fn new(n: usize, flag: bool) -> Graph {
        Graph { node: n, directed: flag, graph: vec![vec![]; n] }
    }

    fn add_edge(&mut self, start_node: usize, end_node: usize, cost: i64) -> () {
        self.graph[start_node].push((end_node, cost));
        if !self.directed { self.graph[end_node].push((start_node, cost)); }
    }
    fn dijkstra(&self, start_node: usize) -> Vec<i64> {
        let mut dist = vec![std::i64::MAX; self.node];
        dist[start_node] = 0;

        let mut queue: BinaryHeap<(i64, usize)> = BinaryHeap::new();
        queue.push((0, start_node));

        while !queue.is_empty() {
            let (min_dist, idx) = queue.pop().unwrap();
            if dist[idx] < -min_dist {
                continue;
            }
            for &(to, weight) in &self.graph[idx] {
                let cost_cand = dist[idx] + weight;
                if dist[to] > cost_cand {
                    dist[to] = cost_cand;
                    queue.push((-cost_cand, to));
                }
            }
        }
        dist
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let mut g = Graph::new(n+1, false);
    for _ in 0..n-1 {
        let a: usize = read();
        let b: usize = read();
        let c: i64 = read();
        g.add_edge(a, b, c);
    }

    let q: usize = read();
    let k: usize = read();

    let v = g.dijkstra(k);
    for _ in 0..q {
        let x: usize = read();
        let y: usize = read();
        let ans = v[x] + v[y];
        println!("{}", ans);
    }
}


Measured memory_bytes: 20732
#include <iostream>
using namespace std;
int main(){
    int a,b;cin>>a>>b;
    int judge[14]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
    if(judge[a]>judge[b])cout<<"Alice"<<endl;
    else if(judge[a]==judge[b])cout <<"Draw"<<endl;
    else cout<<"Bob"<<endl;return 0;
}


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

namespace ABC088_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var card = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
            var sumA = 0;
            var sumB = 0;

            card.Sort((a, b) => b - a);

            for (var i = 0; i < card.Count ; i++)
            {
                if (i % 2 == 1)
                    sumB += card[i];
                else
                    sumA += card[i];
            }

            Console.WriteLine(sumA - sumB);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int A, B, C, D, E, F;
    std::cin >> A >> B >> C >> D >> E >> F;

    int totalAns = 0;
    int sugerAns = 0;

    for(int Na = 0; 100 * A * Na <= F; ++Na) {
        for(int Nb = 0; 100 * A * Na + 100 * B * Nb <= F; ++Nb) {
            int water = 100 * A * Na + 100 * B * Nb;
            for(int Nc = 0; water + C * Nc <= F; ++Nc) {
                if(water == 0 || E * water / 100 < C * Nc) break;
                for(int Nd = 0; water + C * Nc + D * Nd <= F; ++Nd) {
                    int suger = C * Nc + D * Nd;
                    if(E * water / 100 < suger) break;
                    if(totalAns == 0) {
                        totalAns = water + suger;
                        sugerAns = suger;
                    } else {
                        if(((double)sugerAns)/(totalAns) < ((double)suger)/(water + suger)) {
                            totalAns = water + suger;
                            sugerAns = suger;
                        }
                    }
                }
            }
        }
    }

    std::cout << totalAns << " " << sugerAns << std::endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io;

#[allow(unused_macros)]
macro_rules! get {
    ($i:ident) => {
        let mut $i = String::new();
        io::stdin().read_line(&mut $i).ok();
    };
}

#[allow(unused_macros)]
macro_rules! to_vec {
    ($s:ident, $t:ty) => {
        $s.split_whitespace().map(|i| i.parse().ok().unwrap()).collect::<Vec<$t>>()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($s:ident, $t:ty) => {
        $s.trim().parse::<$t>().ok().unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_mut)]
fn main() {
    get!(s);
    let v = to_vec!(s, i32);
    let a = v[0];
    let b = v[1];
    let r = vec![a + b, a - b, a * b];
    println!("{}", max!(r));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count =0;
  map<string,int> mp;
  cin >> N;
  for(int i=0;i<N;i++){
     string s;
     cin >>s;
     mp[s]++;
  }
  for(auto it: mp){
     if(it.second >=1)
	    count++;
  } 
  cout << count << endl;
  
}

Measured memory_bytes: 19228
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut map = BTreeMap::new();

    for &a_i in a.iter() {
        *map.entry(a_i).or_insert(0) += 1;
    }

    let ans = if a.iter().all(|&x| x == 0) {
        "Yes"
    } else if a.len() % 3 == 0 {
        match map.len() {
            2 => match map.get(&0) {
                Some(x) if *x == n / 3 => "Yes",
                _ => "No",
            },
            3 => {
                if map.keys().fold(0, |a, x| a ^ x) == 0 && map.values().all(|x| *x == n / 3) {
                    "Yes"
                } else {
                    "No"
                }
            }
            _ => "No",
        }
    } else {
        "No"
    };
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
N, M =map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

Match = False
for i in range(N-M+1):
    for j in range(N-M+1):
        Compare = [A[k][j:j+M] for k in range(i, i+M)]
        if Compare == B:
            Match = True
print("Yes" if Match else "No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    rep(i, m) cin >> x[i];

    if (n >= m) {
        put(0);
        return 0;
    }

    sort(all(x));

    vector<int> l(m - 1);
    rep(i, m - 1) l[i] = x[i+1] - x[i];
    sort(all(l));
    int sum = 0; 
    rep(i, m - n) sum += l[i];
    put(sum);

    return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("first\n")
#define no printf("second\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e5+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
set<lld> s;
map<lld,lld> cnt;
int main()
{
  lld i,j;
  is(n);
  up(1,n+1,i){
  	is(x);
  	cnt[x]++;
  	s.insert(x);
  }
  lld ans=0,sum=0;
  j=n;
  for(auto kk:s){
  	if(((kk-sum)%2)==1){
  		ans^=j;
  	}
  	sum=kk;
  	j-=cnt[kk];
  }
  if(ans==0){
  	no;
  }
  else
  	yes;
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,x,a[100010];
  cin >> n >> x;
  for(long long int i=0;i<n;i++){
    cin >> a[i];
  }
  long long cnt=0;
  for(long long i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      cnt+=(a[i]+a[i+1])-x;
      a[i+1]-=(a[i]+a[i+1])-x;
      if(a[i+1]<0){
        a[i+1]=0;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    map<int64_t,int> mapA;
    rep(n,0,N){
        int64_t a; cin>>a;
        mapA[-a]++;
    }

    int64_t sideX=0,sideY=0;
    for(auto A:mapA){
        if(sideX==0 && A.second>3){
            sideX=sideY=A.first;
            break;
        }
        else if(A.second>1){
            if(sideX==0) sideX=A.first;
            else{ sideY=A.first; break;}
        }
    }

    cout<<sideX*sideY<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    long long N, M, R;
    cin >> N >> M >> R;
    vector<long long> r(R), A(M), B(M), C(M);
    REP (i, R) {
        cin >> r[i];
        r[i]--;
    }
    REP (i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
    }

    vector<vector<long long> > distance(N, vector<long long>(N, INT_MAX));

    REP (i, N) {
        distance[i][i] = 0;
    }
    REP (i, M) {
        distance[A[i]][B[i]] = C[i];
        distance[B[i]][A[i]] = C[i];
    }
    REP (i, N) {
        REP (j, N) {
            REP (k, N) {
                distance[j][k] = min(distance[j][k], distance[j][i] + distance[i][k]);
            }
        }
    }
    long long ans = LLONG_MAX;
    sort(r.begin(), r.end());
    do {
        long long tmp = 0;
        REP (i, R - 1) {
            tmp += distance[r[i]][r[i + 1]];
        }
        ans = min(ans, tmp);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a, b, n;
    while(cin >> n >> a >> b)
    {
        if((b - a) % 2 ==0)cout<<"Alice"<<endl;
        else   cout<<"Borys"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int nINF = 1<<31;
typedef long long ll;
const ll INF = 0x7fffffffffffffffLL;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
vector<vector<ll>> dp(51, vector<ll>(51, INF));
ll ans = 0;

void solve(int k) {
	FORD(i, 50, 1) {
		if(dp[k][i] != INF) {
			FORD(j, i, 1) {
				int next = i % j;
				// DEBUG(i);
				// DEBUG(j);
				// DEBUG(next);
				// DEBUG(dp[k][i]);
				dp[k][next] = min(dp[k][next], (dp[k][i] | (1LL << (ll)j)) & ~ans);
				// DEBUG(dp[k][next]);
			}
		}
	}
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) {
    	cin >> a[i];
    	dp[i][a[i]] = 0;
    }
    REP(i, n) cin >> b[i];
    // DEBUG(INF);
    vector<bool> solved(n, 0);
    REP(j, n) {
	    REP(i, n) solve(i);
	    ll mx = 0, best = 0;
	    REP(i, n) {
	    	if(dp[i][b[i]] == INF) {
	    		cout << -1 << endl;
	    		exit(0);	
	    	}
	    	if(!solved[i] && dp[i][b[i]] > mx) {
	    		mx = max(mx, dp[i][b[i]]);
	    		best = i;
	    	}
	    }
	    ans |= mx;
	    solved[best] = 1;
    }
    // REP(i, n) {
    // 	FOR(j, 0, a[i]) {
    // 		cout << dp[i][j] << ' ';
    // 	}
    // 	cout << endl;
    // }
    // cout << endl;
    cout << ans << endl;



    return 0;
}

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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	bool judge = true;	int n, tmp;;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> tmp; a.push_back(tmp); }
	sort(a.begin(), a.end());

	for (int i = 0; i < n - 1; i++)
	{
		if (a[i] == a[i + 1]) { judge = false; }
	}
	if (judge) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main () {
	int a, b;
	scanf("%d %d", &a, &b);
	int flag = 0;
	char str [a+b+1];
	scanf("%s", str);
	int atr = 0;
	
	for ( int i = 0 ; i < a+b+1 ; i++) {
		if (str[i] == '-' && i == a ) {
			flag = 1;
		}
		if (str[i] >= '0' && str[i] <= '9') {
			++atr;
		}
	}
	int total = a+b; 
	if (flag == 1 && atr == total) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1632