akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BTrained {
  public : static void solve(std::istream & cin, std::ostream &cout){
      int N;
      cin>>N;
      vector<int> a(N);
      rep(i, N)cin>>a[i];
      int now = 1;
      int ans = 0;
      rep(i, 1000000){
        now = a[now-1];
        ans++;
        if (now == 2){
          cout<<ans<<endl;
          return;
        }
      }
      cout<<-1<<endl;
  }
};


signed main() {
  BTrained solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int main(void){
    int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else if(op=='?'){
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

int N,M,L;

int B[10],H[10],P[10],T[10];

int flow[11]; //BÌÉ]¤Ê B,F,AÉË¶A±êÈ~FAÍgíêÈ¢
double ht[11]; //tbãÌAæØçê½Ì³h

double min_double(double a,double b)
{
	return (a > b) ? b : a;
}

void Fill(int l,int r,int in,double &water)
{
	if(water == 0) return ; //ªÈ¢
	if(l != r){
		int ci = l,ch = 0; //ÌCfbNXÆ³
		for(int i = l; i < r; i++){
			if(ch < H[i]){
				ci = i; ch = H[i];
			}
		}
		if(ci >= in){
			Fill(l,ci,in,water);
			Fill(ci+1,r,in,water);
		} else {
			Fill(ci+1,r,in,water);
			Fill(l,ci,in,water);
		}
	}

	int s = ((r == N) ? 100 : B[r]) - ((l == 0) ? 0 : B[l - 1]); //êÊÏ
	double h = ht[l]; //³
	double max_high = min_double(((r == N) ? 50 * 30 : H[r]),((l == 0) ? 50 * 30 : H[l - 1]));

	////ÇÁ³êé³
	double add_h = (water > s * (max_high - h)) ? (max_high - h) : (water / (double)s);
	water -= add_h * s; //ð¸çµ
	for(int i = l; i <= r; i++) ht[i] += add_h; //Êðã°é

}

void solve()
{
	cin >> N;
	flow[0] = 0;
	for(int i = 0; i < N; i++){
		cin >> B[i] >> H[i];
		H[i] *= 30;
		flow[i+1] = 0;
	}

	int F[10],A[10];
	cin >> M;
	for(int i = 0; i < M; i++){
		cin >> F[i] >> A[i];
		for(int j = 0; j <= N; j++){
			if(j == N || F[i] < B[j]){
				flow[j] += A[i];
				break;
			}
		}
	}

	cin >> L;
	for(int i = 0; i < L; i++)
		cin >> P[i] >> T[i];
	
	for(int i = 0; i < L; i++){
		for(int j = 0; j <= N; j++){
			ht[j] = 0.0; // ³NA
		}

		//Ìã©ç¬ü
		for(int j = 0; j <= N; j++){
			if(flow[j] == 0) continue; //¬üÈµ
			double water = flow[j]*T[i];
			Fill(0,N,j,water);
		}

		int p = 0;
		while(p < N && P[i] > B[p]) p++;
		//ÅãÉ30ÅÁÄ³ðàÆÉß·
		cout << ht[p] / 30.0 << endl;
	}

}

int main()
{
	int D;
	cin >> D;
	for(int i = 0; i < D; i++)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = h * w;
    for(int i = 0; i < 2; ++i){
        for(int j = 1; j < h; ++j){
            const ll p1 = j * w;
            if(h - j > 1){
                const ll p2 = (h - j) / 2 * w;
                const ll p3 = ((h - j) - (h - j) / 2) * w;
                const ll maxp = max(max(p1, p2), p3);
                const ll minp = min(min(p1, p2), p3);
                ans = min(ans, maxp - minp);
            }
            {
                const ll p2 = (h - j) * (w / 2);
                const ll p3 = (h - j) * (w - w / 2);
                const ll maxp = max(max(p1, p2), p3);
                const ll minp = min(min(p1, p2), p3);
                ans = min(ans, maxp - minp);
            }
        }
        swap(h, w);
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int mod= 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    vector<ll> a(n);
    ll vec[62] = {};
    
    rep(i, n) cin >> a[i];
    rep(i, n){
        rep(j, 60){
            if(a[i] & (1LL << j)) vec[j]++;
        }
    }
//    rep(i, 61) cout << vec[i] << endl;

    ll res = 0;
    for( int i = 0 ; i < 60 ; i++ ) {
        res = (res+(long long)( n - vec[i])%mod* vec[i]%mod * (( 1ll << i )%mod)%mod);
	}
    cout << res%mod << endl;



    return 0;
}



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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;
bool dp[81][81][2 * 81 * 81];
int a[81][81], b[81][81];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	//setIn("in.txt");
	//setOut("out.txt");
#endif

	int h, w;
	cin >> w >> h;

	for(int i = 0; i < w; i++){
		for(int j = 0; j < h; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < w; i++){
		for(int j = 0; j < h; j++){
			cin >> b[i][j];
		}
	}

	dp[0][0][abs(a[0][0] - b[0][0])] = 1;

	/*
	for(int i = 1; i < w; i++){
		for(int k = 0; k < 2 * 81 * 81; k++) {
			dp[0][i][k] |= dp[0][i - 1][abs(k + (a[0][i] - b[0][i]))];
			dp[0][i][k] |= dp[0][i - 1][abs(k - (a[0][i] - b[0][i]))];
		}
	}
	*/

	for(int i = 0; i < w; i++){
		for(int j = 0; j < h; j++){
			for(int k = 0; k < 2 * 81 * 81; k++){
				int x = (a[i][j] - b[i][j]);
				if(i > 0) {
					dp[i][j][abs(k + x)] |= dp[i - 1][j][k];
					dp[i][j][abs(k - x)] |= dp[i - 1][j][k];
				}
				if(j > 0) {
					dp[i][j][abs(k + x)] |= dp[i][j - 1][k];
					dp[i][j][abs(k - x)] |= dp[i][j - 1][k];
				}
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < 2 * 81 * 81; i++){
		if(dp[w - 1][h - 1][i]){
			ans = i;
			break;
		}
	}

	cout << ans << endl;
}

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

typedef long long ll;

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

    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for(int i=0;i<m;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(n<sum) cout << -1 << endl;
    else cout << n-sum << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>


using namespace std;

typedef long long ll;

#ifdef DEBUG
#define dbg(arg) (printf arg)
#define LOG cout << "line:" << __LINE__ << ":" << endl;
#else
#define dbg(arg)
#define LOG
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}



Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    long long N;
    cin >> N;
    repr(i,1,3501){
        repr(j,1,3501){
            if((4*i*j - N*i - N*j > 0) && N*i*j % (4*i*j -N*i - N*j) == 0){
                long long w = N*i*j/(4*i*j - N*i - N*j);
                cout << i << " " <<  j << " " <<  w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;

int N, M;
int d[3][100010];
vector<int> G[100010];
int S, T;

signed main()
{
	cin >> N >> M;

	rep(i, M) {
		int u, v; cin >> u >> v;
		--u, --v;
		G[u].PB(v);
	}

	cin >> S >> T;
	--S, --T;

	memset(d, -1, sizeof d);
	d[0][S] = 0;

	queue<pii> q;
	q.push(pii(0, S));

	while (q.size()) {
		pii p = q.front(); q.pop();
		int state = p.fst, cur = p.scd;
		int nxtstate = (state + 1) % 3;

		for (int &nxt : G[cur]) {
			if (d[nxtstate][nxt] != -1) continue;
			d[nxtstate][nxt] = d[state][cur] + 1;
			q.push(pii(nxtstate, nxt));
		}
	}

	if (d[0][T] == -1) {
		cout << -1 << endl;
	} else {
		cout << d[0][T] / 3 << endl;
	}
}



Measured memory_bytes: 8064
#include <iostream>
#include <vector>

#define int long long int

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n + 5), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    vector<int> aa(n), bb(n);
    for (int i = 0; i < n; i++)
    {
        aa[i] = (a[i] ^ a[(i + 1) % n]);
        bb[i] = (b[i] ^ b[(i + 1) % n]);
    }

    vector<int> s;
    for (int i = 0; i < n; i++) s.push_back(bb[i]);
    s.push_back(-1);
    for (int i = 0; i < n; i++) s.push_back(aa[i]);
    for (int i = 0; i < n; i++) s.push_back(aa[i]);

    vector<int> p(s.size() + 1);
    p[0] = -1;
    for (int i = 1; i < p.size() - 1; i++)
    {
        int k = p[i - 1];
        while (k >= 0)
        {
            if (s[k] == s[i - 1])
            {
                p[i] = k + 1;
                break;
            }
            k = p[k];
        }

        if (p[i] == n)
        {
            int res1 = i - n - n - 1;
            int res2 = (b[0] ^ a[res1]);
            cout << res1 << " " << res2 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 20456
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int[] a = new int[5];
		int i;
		Scanner sc = new Scanner(System.in);
		for(i=0; i<5; i++) {
			a[i] = sc.nextInt();
		}
		int k = sc.nextInt();
		sc.close();
		sc = null;
		boolean f = true;
		LABEL:for(i=0; i<5; i++) {
			for(int j=0; j<5; j++) {
				if(Math.abs(a[i]-a[j])>k) {
					f = false;
					break LABEL;
				}
			}
		}
		if(f) System.out.println("Yay!");
		else System.out.println(":(");
	}
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void Debug(auto a);

int kyori(int jinja, int tera, int start){
    int ans_x = abs(start-tera) + abs(tera-jinja);
    int ans_y = abs(start-jinja) + abs(jinja - tera);
    int ans = min(ans_x, ans_y);
    return ans;
}


signed main(){
    int a,b,q;
    cin >> a >> b >> q;
    vec(s,a);
    vec(t,b);
    vec(x,q);
    REP(i,a){
        cin >> s[i];
    }
    REP(i,b){
        cin >> t[i];
    }
    REP(i,q){
        cin >> x[i];
    }
    Sort(s);
    Sort(t);
    int ans = 0;
    REP(i,q){
        auto itr_s = lower_bound(s.begin(),s.end(),x[i]);
        auto itr_tt = lower_bound(t.begin(),t.end(),x[i]);
        auto pos_s = distance(s.begin(), itr_s);
        auto pos_tt = distance(t.begin(), itr_tt);
        if(a==1 && b==1){
            ans= kyori(s[0],t[0],x[i]);
        }
        else if(a==1){
            ans = kyori(s[0],t[pos_tt],x[i]);
            ans = min(ans,kyori(s[0],t[pos_tt-1],x[i]));
        }
        else if(b==1){
            ans = kyori(s[pos_s],t[0],x[i]);
            ans = min(ans,kyori(s[pos_s-1],t[0],x[i]));
        }
        else{
            if(pos_s == a) pos_s--;
            if(pos_tt == b) pos_tt--;
            if(pos_s ==0) pos_s++;
            if(pos_tt == 0) pos_tt++;
            ans = kyori(s[pos_s],t[pos_tt],x[i]);
            ans = min(ans,kyori(s[pos_s],t[pos_tt-1],x[i]));
            ans = min(ans,kyori(s[pos_s-1],t[pos_tt-1],x[i]));
            ans = min(ans,kyori(s[pos_s-1],t[pos_tt],x[i]));
        }

    
        cout << ans << endl;
    }



    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


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

int main(){
	int n, p, q=0, ans=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> p;
		ans += p;
		if(p>q) q = p;
	}
	cout << ans - q/2 << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (x, y, a, b, c) = readLine()!!.split(" ").map{it.toInt()}
    var p = readLine()!!.split(" ").map{it.toLong()}
    var q = readLine()!!.split(" ").map{it.toLong()}
    var r = readLine()!!.split(" ").map{it.toLong()}
    var apple = (p.sortedBy{it*-1}.take(x) + q.sortedBy{it*-1}.take(y) + r).sortedBy{it*-1}.take(x+y)
    println(apple.sum())
}


Measured memory_bytes: 151672
#include <iostream>
#include <algorithm>
#define INF 1000000000
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,ans;
  int a[100005][5];
  int dp[100005][5]={};
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  for(int i=1;i<=n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
  }
  ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 7524
N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * N for _ in range(1 << N)]
DY = [[0] * N for _ in range(1 << N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[k][i] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[k][i] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(t)

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    dxi = DX[i]
    while 1:
        dyj = DY[j]
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(dxi[k], dyj[k])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)


print(*ANS, sep = "\n")


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

const int N = 30;
int freq[N];

long long f(long long x){
	return x * (x+1) / 2;
}

int main() {

	string s;
	cin >> s;
	long long res = f(s.size()-1) + 1;
	for(int i = 0 ; i < s.size() ; i++){
		freq[s[i]-'a']++;
	}

	for(int i = 0 ; i < N ; i++){
		res -= f(freq[i]-1);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;




int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0)
    ll n,m;
    cin>>n>>m;
    ll ar[m+1];
    map<ll,ll>mp;
    for(ll i=0; i<m; i++)
    {
        cin>>ar[i];
        mp[ar[i]]=1;
    }
    ll mn=1e18,ans=-1;
    for(ll i=0; i<200; i++)
    {
        if(mp[i])
            continue;
        if(abs(i-n)<mn)
        {
            mn=abs(i-n);
            ans=i;
        }
    }
    cout<<ans<<nn;



}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



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

int main() {
    int n; cin >> n;
    vector<pair<long long, long long>> u;
    long long ans = 0;
    multiset<long long> l1, r1, l2, r2;
    for (int i = 0; i < n; i++) {
        long long a, b; cin >> a >> b;
        u.emplace_back(b, a);
        ans = max(ans, b-a+1);
        l2.insert(a); r2.insert(b);
    }
    sort(u.begin(), u.end());
    for (int i = 0; i < n; i++) {
        auto a = u[i].second;
        auto b = u[i].first;
        l2.erase(l2.find(a));
        r2.erase(r2.find(b));
        long long tmp = b-a+1 + max(0LL, *r2.begin()-*l2.rbegin()+1);
        ans = max(ans, tmp);
        l2.insert(a); r2.insert(b);
    }
    for (int i = 0; i < n-1; i++) {
        auto a = u[i].second;
        auto b = u[i].first;
        l1.insert(a); r1.insert(b);
        l2.erase(l2.find(a)); 
        r2.erase(r2.find(b));
        long long tmp = max(0LL, *r1.begin()-*l1.rbegin()+1) + max(0LL, *r2.begin()-*l2.rbegin()+1);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11248
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    if N % 2 == 0:
        print(float(0.5))
    else:
        print(float((N // 2 + 1) / N))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=110,M=10100;
int n,m,x,used[M],vis[N],p[N],g[N][N],rp[N][N];
VI row[N],cc[N],rr[N];
int dfs(int u) {
	rep(v,0,n) if (g[u][v]&&!vis[v]) {
		vis[v]=1;
		if (p[v]==-1||dfs(p[v])) { p[v]=u; return 1;}
	}
	return 0;
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,n) rep(j,0,m) {
		scanf("%d",&x); --x;
		row[i].pb(x);
	}
	rep(col,0,m) {
		rep(i,0,n) rep(j,0,n) g[i][j]=0,rp[i][j]=-1;
		rep(i,0,n) for (auto x:row[i]) if (!used[x]) {
			g[i][x/m]=1; rp[i][x/m]=x;
		}
		rep(i,0,n) p[i]=-1;
		rep(i,0,n) {
			memset(vis,0,sizeof(vis));
			assert(dfs(i));
		}
		rep(i,0,n) {
			int x=rp[p[i]][i];
			assert(x!=-1);
			used[x]=1;
			rr[p[i]].pb(x);
			cc[col].pb(x);
		}
	}
	rep(i,0,n) rep(j,0,m) printf("%d%c",rr[i][j]+1," \n"[j==m-1]);
	rep(j,0,m) sort(all(cc[j]));
	rep(i,0,n) rep(j,0,m) printf("%d%c",cc[j][i]+1," \n"[j==m-1]);

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll A,B,C,da,db,dc,ans=0;
    cin >> A >> B >> C;
    while(A%2==0 && B%2==0 && C%2==0){
        ans++;
        dc = A/2+B/2;
        da = B/2+C/2;
        db = C/2+A/2;
        if(da==db&&db==dc&&dc==da){
            ans = -1;
            break;
        }
        A=da;
        B=db;
        C=dc;
    }

    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
 
  public static void main(String[] args) {
 
    Scanner sc = new Scanner(System.in);
 
    int n = sc.nextInt();
    long sum = 1;
    long sumtmp = 1;
    long lim = (long) Math.pow(10, 18);
    boolean flg = true;
 
    for (int i = 0; i < n; i++) {
      long tmp = sc.nextLong();
      if(tmp == 0) {
        System.out.println(0);
        return;
      }
      sum *= tmp;
      if ((sum > lim) || (sum < 0) || (sum < sumtmp)) {
        flg = false;
      }
      sumtmp = sum;
    }
 
    if(flg) {
      System.out.println(sum);
    } else {
      System.out.println(-1);
    }
 
  }
}

Measured memory_bytes: 59472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

int main()
{
    ll a,b,c;
    int n;
    cin >>a >>b >>c >>n;
    
    #define IN(x,y,z) (0<=x && x<a && 0<=y && y<b && 0<=z && z<c)
    ll ans = 2*(a*b+b*c+c*a);
    set<tuple<int,int,int>> s;
    rep(i,n)
    {
        int x,y,z;
        cin >>x >>y >>z;
        rep(j,6)
        {
            int nx = x+dx[j], ny = y+dy[j], nz = z+dz[j];
            if(IN(nx,ny,nz) && !s.count(make_tuple(nx,ny,nz))) ++ans;
            else --ans;
        }
        s.insert(make_tuple(x,y,z));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);
  ll num=0,zero=0;
  ll m=INF;
  rep(i,n){
    cin >> a[i];
    m=min(m,abs(a[i]));
    if(a[i]<0){
      num++;
    }
    if(a[i]==0)zero++;
  }
  ll ans=0;
  rep(i,n)ans+=abs(a[i]);
  if(num%2!=0 && !zero){
    ans-=2*m;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;


/* range: ± 3.27 * 10^4 */
using i16 = short int;
/* range: 0 to 65535 */
using u16 = short unsigned int;
/* range: ± 2.14 * 10^9 */
using i32 = int;
/* range: 0 to 4.29 * 10^9 */
using u32 = unsigned int;
/* range: ± 9.22 * 10^18 */
using i64 = long long int;
/* range: 0 to 1.84 * 10^19 */
using u64 = long long unsigned int;

vector<array<u64, 3>> memo;

u64 dp(const vector<array<u32, 3>>& day_happiness, u16 prev_task, u32 days,
       u32 curr_day) {
    if (curr_day == days) {
        return 0;
    }

    if (prev_task < 3 && memo[curr_day][prev_task] > 0) {
        return memo[curr_day][prev_task];
    }

    u64 res = 0;
    for (u16 task = 0; task < 3; task++) {
        if (task == prev_task) {
            continue;
        }
        res = max(res, day_happiness[curr_day][task] +
                           dp(day_happiness, task, days, curr_day + 1));
    }

    if (prev_task < 3) {
        memo[curr_day][prev_task] = res;
    }
    return res;
}

i32 main() {
    u32 num_vacations = 0;
    cin >> num_vacations;

    vector<array<u32, 3>> day_happiness(num_vacations);
    for (u32 day = 0; day < num_vacations; day++) {
        for (u16 task = 0; task < 3; task++) {
            cin >> day_happiness[day][task];
        }
    }

    memo = vector<array<u64, 3>>(num_vacations, array<u64, 3>{ 0, 0, 0 });
    cout << dp(day_happiness, 3, num_vacations, 0) << '\n';
}

Measured memory_bytes: 14156
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    string s;
    int N,K;
    cin >> N >> K;
    cin >> s;

    switch(s[K-1]){
        case 'A': s[K-1] = 'a';
            break;
        case 'B': s[K-1] = 'b';
            break;
        case 'C': s[K-1] = 'c';
            break;
    }

    cout << s << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    double R;
    cin >> R;
    cout << fixed << setprecision(5) << R * 2 * M_PI << endl;
}






// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

map<char,string> tbl1 = {
    {' ', "101"},
    {'\'', "000000"},
    {',', "000011"},
    {'-', "10010001"},
    {'.', "010001"},
    {'?', "000001"},
    {'A', "100101"},
    {'B', "10011010"},
    {'C', "0101"},
    {'D', "0001"},
    {'E', "110"},
    {'F', "01001"},
    {'G', "10011011"},
    {'H', "010000"},
    {'I', "0111"},
    {'J', "10011000"},
    {'K', "0110"},
    {'L', "00100"},
    {'M', "10011001"},
    {'N', "10011110"},
    {'O', "00101"},
    {'P', "111"},
    {'Q', "10011111"},
    {'R', "1000"},
    {'S', "00110"},
    {'T', "00111"},
    {'U', "10011100"},
    {'V', "10011101"},
    {'W', "000010"},
    {'X', "10010010"},
    {'Y', "10010011"},
    {'Z', "10010000"}
};

map<string,string> tbl2 = {
    {"00000", "A"},
    {"00001", "B"},
    {"00010", "C"},
    {"00011", "D"},
    {"00100", "E"},
    {"00101", "F"},
    {"00110", "G"},
    {"00111", "H"},
    {"01000", "I"},
    {"01001", "J"},
    {"01010", "K"},
    {"01011", "L"},
    {"01100", "M"},
    {"01101", "N"},
    {"01110", "O"},
    {"01111", "P"},
    {"10000", "Q"},
    {"10001", "R"},
    {"10010", "S"},
    {"10011", "T"},
    {"10100", "U"},
    {"10101", "V"},
    {"10110", "W"},
    {"10111", "X"},
    {"11000", "Y"},
    {"11001", "Z"},
    {"11010", " "},
    {"11011", "."},
    {"11100", ","},
    {"11101", "-"},
    {"11110", "'"},
    {"11111", "?"}
};

string encode(string s) {
    string ret = "";
    for (int i=0; i<(int)s.size(); ++i) {
        ret += tbl1[s[i]];
    }
    while ((int)ret.size() % 5 != 0) {
        ret += "0";
    }
    return ret;
}

string encode2(string s) {
    string ret = "";
    for (int i=0; i<(int)s.size(); i+=5) {
        ret += tbl2[s.substr(i, 5)];
    }
    return ret;
}

int main() {
    string s;
    while (getline(cin, s)) {
        cout << encode2(encode(s)) << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
N = int(input())

A = [int(input()) for _ in range(N)]

max1 = max(A)
max1_ind = A.index(max1)

A.remove(max1)

max2 = max(A)

for i in range(N):
    if i != max1_ind:
        print(max1)
    else:
        print(max2)



Measured memory_bytes: 16880
#include<iostream>
#include<cstdio>
using namespace std;
int x[2][100010],n,v[2],m[2],k,t,q[2];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)	
	{
		scanf("%d",&k);	t=i%2;
		x[t][k]++;
		if (m[t]<x[t][k]) {m[t]=x[t][k];v[t]=k;}		
	}	
	if (v[0]!=v[1])	
		cout<<n-m[0]-m[1]<<endl;
	else
	{
		for (int i=1;i<=100000;i++)
		{
			if (q[0]<x[0][i]&&i!=v[0]) q[0]=x[0][i];
			if (q[1]<x[1][i]&&i!=v[1]) q[1]=x[1][i];
		}
		if(m[0]-q[0]>m[1]-q[1])
			cout<<n-m[0]-q[1]<<endl;
		else			
			cout<<n-m[1]-q[0]<<endl;					
	}	
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double a,b,c;
    cin>>a;
    b=a;
    c=3.14159265358979323846;
    a+=a;
    a*=c;
    b*=b*c;
    cout<<fixed<<setprecision(6)<<(double)b<<" "<<(double)a<<endl;
}



Measured memory_bytes: 3256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main()
{
	int n;
	std::cin >> n;
	std::vector<std::pair<std::pair<std::string, int>, int> > S;
	for (int i = 0; i < n; i++)
	{
		
		std::string s;
		int p;
		std::cin >> s >> p;
		S.push_back( std::make_pair(std::make_pair(s, -p), i));
	}
	std::sort(S.begin(), S.end());
	for (std::vector<std::pair<std::pair<std::string, int>, int> >::iterator i = S.begin(); i != S.end(); i++)
	{
		std::cout << (*i).second + 1 << '\n';
	}
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
int n,a[105],cnt;
int main(){
	cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]){
			a[i]+=1e5;
			cnt++;
		}
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
    n <- readLn
    putStrLn $ show (solve n)
   
solve :: Int -> Int
solve n = (1 - 2 ^ (1 + divid n 0)) `div` (1 - 2)

divid :: Int -> Int -> Int 
divid n z = if n `div` 2 > 0 
            then  divid (n `div` 2) (z + 1)
            else  z

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+10,MAXM=2e6+10;
const int INF=INT_MAX,MOD=1e9+7;
const ll llINF=~(1ll<<63);


int main()
{
    int n,ans;
    cin>>n;
    int tmp=n/100;
    if(tmp*100<=n&&tmp*105>=n)cout<<1;
    else cout<<0;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];

    vector<long double> ex(1001);
    FOR(i, 1, 1001) REP(j, i) ex[i] += (long double)(j+1)/i;
    
    long double sum = 0, ret = 0;
    REP(i, k-1) sum += ex[p[i]];
    FOR(i, k-1, n) {
        sum += ex[p[i]];
        chmax(ret, sum);
        sum -= ex[p[i-k+1]];
    }
    cout << fixed << setprecision(9) << ret << endl;

    return 0;
}

Measured memory_bytes: 1920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BUnplannedQueries solver = new BUnplannedQueries();
        solver.solve(1, in, out);
        out.close();
    }

    static class BUnplannedQueries {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            int[] f = new int[n];
            for (int i = 0; i < m; i++) {
                f[in.nextInt() - 1]++;
                f[in.nextInt() - 1]++;
            }
            for (int i : f) {
                if (i % 2 != 0) {
                    out.println("NO");
                    return;
                }
            }
            out.println("YES");
        }

    }
}



Measured memory_bytes: 64632
# coding: utf-8
N = int(input())
l = len(str(N))
ans = 0
for i in range(1, 10):
    if N >= int("{}{}".format(i, "9"*(l-1))):
        ans = max(ans, 9*(l-1) + i)
if ans == 0:
    ans = 9 * (l-1)
print(ans)

Measured memory_bytes: 3060
// heeeyyyy Mooortyyyyyy!!
#include <bits/stdc++.h>
#include <chrono>
#include <random>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
const int N=500023;
#define PI 3.1415926535897932384626
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//DEBUGGING
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
const int LG = 20;
//__builtin_popcount(n) -> returns number of set bits in n
ll expo(ll a, ll b, ll m); // a^(b) %m
//=======================

//vector<bool> vis;vis.assign(n,false); g.assign(n,{});
//vector<vll> g;
//void ipgraph(ll m){ll  u, v;while(m--){cin>>u>>v; u--, v--;g[u].pb(v);g[v].pb(u);}}
//ll lvl[N], p[N][LG];
//ll lca(ll u,ll v){if(lvl[u]<lvl[v])swap(u,v);ll i,lg; for(lg=0;(1<<lg)<=lvl[u];lg++);lg--;for(i=lg;i>=0;i--){if(lvl[u]-(1<<i)>=lvl[v]){u=p[u][i];}}if(u==v)return v;else{for(i=lg;i>=0;i--){if(p[u][i]!=-1 && p[u][i]!=p[v][i]){u=p[u][i];v=p[v][i];}}}return p[u][0];}

void solve(){
    ll i, j, n, m,k,x,y;ll ti;
    cin>>n>>x>>ti;
    if(n%x==0){
        cout<<(n/x)*ti;
    }
    else cout<<(n/x +1)*ti;
}

int main(){
 
   ll t = 1;
   // cin >> t;
    while(t--) {
      solve();
    }
   return 0;
}


ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 

Measured memory_bytes: 3656
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Main m = new Main();
		String sec_ = br.readLine();
		int sec = Integer.parseInt(sec_);
		m.SecToTime(sec);
	}
	
	public void SecToTime(int sec){
		int h = 0,m = 0;
		
		while(sec >= 3600){
			h++;
			sec -= 3600;
		}
		
		while(sec >= 60){
			m++;
			sec -= 60;
		}
		
		System.out.println(h+":"+m+":"+sec);
	}
}

Measured memory_bytes: 16996
import sys

#+++++
		
def main():
	h, w = map(int, input().split())
	n = int(input())
	anl=list(map(int, input().split()))
	ans=[]
	cm=0
	for color, ni in enumerate(anl, start=1):
		v=ni
		while v > 0:
			cl = w - len(ans)
			if cl > v:
				ans = ans + [color] * v
				v=0
			else:
				ans = ans + [color] * cl
				v-=cl
				ans = ans
				if cm % 2 == 1:
					ans=ans[::-1]
				pp=' '.join([str(v) for v in ans])
				print(pp)
				cm+=1
				ans=[]
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const int lim = 110;
const int inf = 1e8;

int n, m, s, g1, g2;

struct edge{
    int from;
    int to;
    int cost;
};

int d[lim][lim];

void WarshallFloyd(){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    while(true){
        cin >> n >> m >> s >> g1 >> g2;
        if(n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) return 0;
        for(int i=0; i<lim; i++){
            for(int j=0; j<lim; j++) d[i][j] = inf;
        }
        for(int i=0; i<m; i++){
            int from, to, cost;
            cin >> from >> to >> cost;
            from--; to--;
            d[from][to] = cost;
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++) if(i == j) d[i][j] = 0;
        }

        WarshallFloyd();
        int ans = inf;
        for(int i=0; i<n; i++){
            ans = min(ans, d[s-1][i] + d[i][g1-1] + d[i][g2-1]);
        }
        cout << ans << endl;
    }
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class TaskA {
 public:
  void solveOne(istream &in, ostream &out) {
    int n;
    in >> n;
    vector<int64> a(n);
    for (auto& x : a) in >> x;
    string s;
    in >> s;
    vector<pair<int64, int64>> basis;
    for (int i = n - 1; i >= 0; --i) {
      int64 cur = a[i];
      for (const auto& p : basis) if (cur & p.first) cur ^= p.second;
      if (s[i] == '0') {
        if (cur != 0) {
          int64 j;
          for (j = 1;; j <<= 1) {
            if (cur & j) {
              break;
            }
          }
          basis.emplace_back(j, cur);
        }
      } else {
        if (cur != 0) {
          out << 1 << "\n";
          return;
        }
      }
    }
    out << 0 << "\n";
  }

  void solve(std::istream &in, std::ostream &out) {
    int nt;
    in >> nt;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskA solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3556
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read


def main():
    N = int(readline())
    graph = [[] for _ in range(N + 1)]

    for i in readlines():
        u, v, w = map(int, i.split())
        w %= 2
        graph[u].append((v, w))
        graph[v].append((u, w))

    stack = [1]
    parent = [0] * (N + 1)
    color = [0] * (N + 1)

    while stack:
        here = stack.pop()
        for x, w in graph[here]:
            if x == parent[here]:
                continue
            parent[x] = here
            color[x] = color[here] ^ w
            stack.append(x)

    for i in color[1:]:
        print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 41804
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;

void solve(istream& cin, ostream& cout) {
	string S;
	cin >> S;
	if(S.find('7') != -1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;

static const int SIZE = 300000;
vector<int> prime;
bool isPrime[SIZE];

void primeCalc()
{
	for(int i = 0; i < SIZE; ++i)
	{
		isPrime[i] = true;
	}
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < SIZE; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < SIZE; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}
void solve()
{
	primeCalc();
	int n;
	while(cin >> n, n)
	{
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += prime[i];
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 1636
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N,M;
	cin>>N>>M;
	ll ans=0;
	for(int i=0;i<M;i++){
		ll p;
		cin>>p;
		ll nokori=N-p;
		if(p>nokori+1)ans+=p-nokori-1;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256