akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll n,m,a[1002][1002]={0};
ll solve()
{
    if(a[0][0]==-1)
    return 0;
    
        ll i,j;
        for(i=0;i<m;i++)
        {
            if(a[0][i]==0)
            a[0][i]=1;
            else
            break;
        }
        for(i=0;i<n;i++)
        {
            if(a[i][0]>=0)
            a[i][0]=1;
            else 
            break;
        }
        for(i=1;i<n;i++)
        {
            for(j=1;j<m;j++)
            {
                if(a[i][j]==-1)
                continue;
                
                    if(a[i-1][j]>0)
                    a[i][j]=(a[i][j]%mod+a[i-1][j]%mod)%mod;
                    if(a[i][j-1]>0)
                    a[i][j]=(a[i][j]%mod+a[i][j-1]%mod)%mod;
            }
        }
    
    if(a[n-1][m-1]>0)
    return a[n-1][m-1];
    else
    return 0;
}
int main()
{
    cin>>n>>m;
    ll i,j;
    char ch;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>ch;
            if(ch=='#')
            a[i][j]=-1;
            else
            a[i][j]=0;
        }
    }
   cout<<solve()%mod<<endl;
  /* for(i=0;i<n;i++)
   {
       for(j=0;j<m;j++)
       cout<<a[i][j]<<" ";
       cout<<endl;
   }*/
}

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

int main() {

  int N = 5;

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for (int i = 0; i < 5; i++) {
    if(vec.at(i) == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }


}

Measured memory_bytes: 3484
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
const ll MOD = 10007;

void chmin(ll& x, ll y) {
    if (x > y) x = y;
}

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

    int n; cin >> n;
    vll A(n); REP(i, n) cin >> A[i];

    multiset<ll> s;

    REP(i, n) {
        auto it = s.lower_bound(-A[i]);
        if (it != s.end()) {
           s.erase(it);
        }

        s.insert(-A[i] - 1);
    }

    print(s.size());
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

vi g[MAXN];

int v[MAXN];
ll dp[MAXN];

int used[MAXN];

int dfs(int s){
	used[s] = 1;
	ll dp_sum = 0, dp_mx = 0;
	REP(i, 0, SZ(g[s])){
		int to = g[s][i];
		if (!used[to]){
			if (dfs(to)){
				return 1;
			}
			dp_sum += dp[to];
			dp_mx = max(dp_mx, dp[to]);
		}
	}
	if (SZ(g[s]) > 1) {
		ll a = dp_sum - v[s];
		ll b = v[s] - a;
		if (a < 0 || b < 0 || a > dp_sum - dp_mx){
			//printf("%d %lld %lld %lld %lld\n", s, dp_sum, dp_mx, a, b);
			return 1;
		}
		dp[s] = b;
	} else {
		dp[s] = v[s];
	}
	return 0;
}

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &v[i]);
	}
	REP(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	if (n == 2){
		if (v[1] == v[2]){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
		return;
	}
	int s = 1;
	REPN(i, 1, n){
		if (SZ(g[i]) > 1){
			s = i;
		}
	}
	if (dfs(s) || dp[s]){
		printf("NO\n");
	} else {
		printf("YES\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int cnt[100000] = {};
    if(n % 2 == 1){
        REP(i,n){
            if(a[i] % 2 == 1){
                cout << 0 << endl;
                return 0;
            }
            cnt[a[i]]++;
        }
        if(cnt[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        ll ans = 1;
        for(int i = 2; i < n; i += 2){
            if(cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }else{
        REP(i,n){
            if(a[i] % 2 == 0){
                cout << 0 << endl;
                return 0;
            }
            cnt[a[i]]++;
        }
        ll ans = 1;
        for(int i = 1; i < n; i += 2){
            if(cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		System.out.println(S.matches("(hi)+") ? "Yes" : "No");
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int cnt=0;
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        while(true){
            if (a % 2 == 0) cnt++;
            else break;
            a /= 2;

        }

    }
    out(cnt);
}

Measured memory_bytes: 256
S = input()
N = len(S)
T = [0] * N
r = 0
l = 0
cnt = 1
for i in range(N - 1):
    if i == N - 2:
        if S[i] == 'R':
            T[i + 1] = 1
            T[i] = cnt
        else:
            T[l] = cnt + 1
    else:
        if S[i] == S[i + 1]:
            cnt += 1
        elif S[i] == 'R':
            l = i + 1
            T[i] = cnt
            cnt = 1
        else:
            T[l] = cnt
            cnt = 1

i = 0
while i < N-1:
    if T[i] != 0:
        t = T[i]+T[i+1]
        if t % 2 == 0:
            T[i], T[i + 1] = t//2, t//2
        elif T[i] < T[i + 1]:
            if T[i + 1] % 2 == 0:
                T[i] = t // 2 + 1
                T[i + 1] = t // 2
            else:
                T[i], T[i + 1] = t // 2, t // 2 + 1
        else:
            if T[i] % 2 == 0:
                T[i], T[i + 1] = t // 2, t // 2 + 1
            else:
                T[i], T[i + 1] = t // 2 + 1, t // 2
        i += 2
    else:
        i += 1

for t in T:
    print(t,end=' ')

Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>
 
int main()
{
  unsigned long long x,y;
  unsigned long long res;
  scanf("%llu %llu\n",&x,&y);
  res = ((log2l (y) - log2l(x)) + 1.0);
  printf("%llu\n",res);
  return 0;
}


Measured memory_bytes: 128
N,M = map(int, input().split())

town_road = [0 for _ in range(N+2)]

for i in range(M):
    a,b = map(int, input().split())
           
    town_road[a] += 1
    town_road[b] += 1
        
for i in range(1,N+1):
    print(town_road[i])

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S;
    cin >> S;
    REP(i,0,S.size()){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S;
    cin >> S;
    LL ans = 0;
    int cnt = 0;
    REP(i, S.size()) {
        if (S[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		if(as.next().equals("H")){
			System.out.println(as.next());
		}else{
			if(as.next().equals("H")){
				System.out.println("D");
			}else{
				System.out.println("H");
			}
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
	int H,W,i,j;
		
	while(1){
		scanf("%d %d",&H,&W);
	if(H==0 && W==0) break;
	for(j=0; j<H;j++){
	    for(i=0; i<W;i++){
			putchar('#');
	    }

	putchar('\n');
	}
	putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,x,y;
	cin>>n>>x>>y;
	int m=n-1;
	int ans[m+1];
	for(int i=1;i<=m;i++) {
		ans[i]=0;
	}
	int f;
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			f=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
			ans[f]++;
		}
	}
	for(int i=1;i<=m;i++) {
		cout<<ans[i]<<endl;
	}
	return 0;
}


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

// {{{
#define PI pair<int, int>
#define mk make_pair
#define reg register
#define ll long long
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)
#define per(i, a, b) for(reg int i = a; i >= b; --i)
#define MOD 1000000007
// }}}

using namespace std;

inline int min(reg int a, reg int b) { return a < b ? a : b; }
inline int max(reg int a, reg int b) { return a > b ? a : b; }
inline int read() {
  reg int s = 0; reg char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s;
}

int s[2005], t[2005];
ll f[2005][2005], g[2005][2005];

int main() {
  int n = read(), m = read();
  rep (i, 1, n) s[i] = read();
  rep (i, 1, m) t[i] = read();
  rep (i, 0, n) g[i][0] = 1;
  rep (i, 0, m) g[0][i] = 1;
  rep (i, 1, n) {
    rep (j, 1, m) {
      g[i][j] = (f[i][j] + g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + MOD) % MOD;
      if (s[i] == t[j]) {
        f[i][j] = g[i - 1][j - 1];
      }
      (g[i][j] += f[i][j]) %= MOD;
    }
  }
  cout << g[n][m] << endl;
  return 0; 
}


/*******************************************
 _________________________________________
< E.cpp is created by zrz who is weak >
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
********************************************/

Measured memory_bytes: 62848
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0] * (N+3)
B.append(0)
B.append(0)
total = 0
for i in range(N+1):
    if(A[i] <= B[i] + C[i]):
        total += A[i]
        if(A[i] <= C[i]):
            C[i+1] = B[i]
        else:
            C[i+1] = B[i] + C[i] - A[i]
    else:
        total += B[i] + C[i]



print(total)

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

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	cin >> s;

	int result = 0;
	int p = 0;

	for( auto ch : s ) {
		if( ch == 'g' ) {
			if( p > 0 ) {
				p -= 1;
				result += 1;
			}
			else {
				p += 1;
			}
		}
		else if( ch == 'p' ) {
			if( p > 0 ) {
				p -= 1;
			}
			else {
				p += 1;
				result -= 1;
			}
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 512
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int d = scanner.nextInt();
        final int g = scanner.nextInt() / 100;

        final int[] numbers = new int[d];
        final int[] bonuses = new int[d];

        for (int i = 0; i < d; i++) {
            numbers[i] = scanner.nextInt();
            bonuses[i] = scanner.nextInt() / 100;
        }

        final Set<Integer> checked = new HashSet<>();
        System.out.println(recursive(0,g,0,numbers,bonuses,checked));
    }

    private static int recursive(final int index, final int target, final int cost, final int[] numbers, final int[] bonuses, final Set<Integer> set) {
        if (index == numbers.length) {
            if (target <= 0) {
                return cost;
            }

            if (set.size() == index) {
                return Integer.MAX_VALUE;
            }

            int maxIndex = -1;
            for (int i = 0; i < index; i++) {
                if (set.contains(i)) {
                    continue;
                }

                maxIndex = Math.max(maxIndex, i);
            }

            if ((maxIndex + 1) * numbers[maxIndex] < target) {
                return Integer.MAX_VALUE;
            }

            return cost + (target + maxIndex) / (maxIndex + 1);
        }

        final Set<Integer> checked = new HashSet<>(set);
        checked.add(index);

        return Math.min(recursive(index + 1, target, cost, numbers, bonuses, set)
                , recursive(index + 1, target - (index + 1) * numbers[index] - bonuses[index], cost + numbers[index], numbers, bonuses, checked));
    }
}


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

typedef long long ll;
const int MAXN=2e5+5;

int n,k,st;
char s[MAXN];
int num[MAXN];

int main(){
    scanf("%d%d%s",&n,&k,s+1);
    for(int i=1;i<=n;i++)
        num[i]=s[i]-'A';
    st=num[1];
    int p=1,cnt=0;
    while(k--){
        if(st==0){
            st^=1;
            num[p]^=1;
        }
        else{
            cnt++;
            st=num[++p];
            st^=(cnt&1);
        }
        if(p>n) break;
    }
    if(p<=n){
        for(int i=p;i<=n;i++)
            putchar('A'+(num[i]^(cnt&1)));
        int t=p-1,c=(cnt-1)&1;
        while(t--){
            putchar('A'+c);
            c^=1;
        }
    }
    else{
        if((cnt-1)&1)
            for(int i=1;i<=n;i++)
                putchar('A'+(i&1));
        else{
            putchar('A'+(k&1));
            for(int i=1;i<n;i++)
                putchar('A'+(i&1));
        }
    }
}


Measured memory_bytes: 1280
#include<stdio.h>
#define c(t) (t-'0')
int main(){
	char s[5];
	scanf("%s", s);
	int l = c(s[0])*10+c(s[1]), r = c(s[2])*10+c(s[3]);
	if(0<l && l<13) {
		if(0<r && r<13){
			printf("AMBIGUOUS");
		} else {
			printf("MMYY");
		}
	} else if(0<r && r<13){
		printf("YYMM");
	} else {
		printf("NA");
	}
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A =sc.nextInt();
		int B =sc.nextInt();
		if(A<=9&&B<=9) {
			System.out.println(A*B);
		}else {
			System.out.println(-1);
		}
	}
}


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

int main() {
    std::size_t N;
    std::cin >> N;
    std::vector<long> D1(N), D2(N);
    for (std::size_t index = 0; index < N; ++index) {
        std::cin >> D1[index] >> D2[index];
    }

    long zoro_num = 0;
    for (std::size_t index = 0; index < N; ++index) {
        if (D1[index] == D2[index]) {
            ++zoro_num;
        } else {
            zoro_num = 0;
        }
        if (zoro_num >= 3) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3628
import math
a, b, x = map(int, input().split())

if x <= (a**2 * b)/2:
    ans = (180 * math.atan((a*b**2)/(2*x)))/(math.pi)
    print(ans)
    
else:
    ans = (180 * math.atan((2*a**2*b - 2*x)/(a**3)))/(math.pi)
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
    char s[3];
    scanf("%s",s);
    int x,y,z,f;
    x=s[0]-'a';
    y=s[1]-'a';
    z=s[2]-'a';
    if((x==0&&y==1&&z==2)||(x==1&&y==0&&z==2)||(x==2&&y==1&&z==0)||(x==0&&y==2&&z==1)||(x==1&&y==2&&z==0)||(x==2&&y==0&&z==1))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import copy

def is_increase(arr):
    for i in range(1, len(arr)):
        if arr[i] < arr[i-1]:
            return False
    return True

N = int(input())
p = list(map(int, input().split()))
for i in range(N-1):
    for j in range(i, N):
        p2 = copy.deepcopy(p)
        p2[i], p2[j] = p2[j], p2[i]
        if is_increase(p2):
            print('YES')
            exit(0)
print('NO')

Measured memory_bytes: 3444
fun main(args: Array<String>) {
        val hn = readLine()!!.split(" ").map { it.toInt() }
        val a = readLine()!!.split(" ").map { it.toInt() }.sum()

        if (hn[0] > a) {
            print("No")
        } else {
            print("Yes")
        }
}

Measured memory_bytes: 47616
s=input()
n=len(s)
for i in range(n-1):
    if s[i]==s[i+1]:
        print(i+1, i+2)
        exit()
for i in range(n-2):
    if s[i]==s[i+2]:
        print(i+1, i+3)
        exit()
print(-1, -1)



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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
int MOD = 998244353;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {x = 0;}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    bool operator == (const Mint &rhs) const{
        return x == rhs.x;
    }
    bool operator != (const Mint &rhs) const{
        return x != rhs.x;
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

void work()
{
    int a, b, c;
    cin >>a >>b >>c;
    swap(a, b);
    swap(a, c);
    cout <<a <<" " <<b <<" " <<c <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
 int a;
 scanf("%d",&a);
 string ss;
 int x;
 while(true){
  cin >> ss;
  if(ss=="=")break;
  cin >> x;
  if(ss=="+")a+=x;
  if(ss=="-")a-=x;
  if(ss=="*")a*=x;
  if(ss=="/")a/=x;
 }
 printf("%d\n",a);
 return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	long long n,a;
	cin>>n>>a;
	cout<<n*n-a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> data(2);
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++) {
      for(int k = 0; k < 2; k++) {
        for(int l = 0; l < 2; l++) data.at(l) = 0;
        data.at(i) += a;
        data.at(j) += b;
        data.at(k) += c;
        if(data.at(0) == data.at(1)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public class Action
	{
		public int Size {get;set;}
		public long Value {get;set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		
		var q = Input();
		var a = new long[n];
		for(int i = 0; i < n; i++)
		{
			a[i] = (q[i].ToLong());
		}
		Array.Sort(a);
		
		var s = new Action[m];
		for(int i = 0; i < m; i++)
		{
			var r = Input();
			s[i] = new Action(){Size = r[0].ToInt(), Value = r[1].ToLong()};
		}
		
		Array.Sort(s, (u,v)=>(int)(v.Value - u.Value));
		var b = new long[n];
		var ki = 0;
		for(int i = 0; i < n && ki < m; i++)
		{
			b[i] = s[ki].Value;
			s[ki].Size--;
			if(s[ki].Size == 0)ki++;
		}
		
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			wa += Math.Max(a[i], b[i]);
			
		}
		Console.WriteLine(wa);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 32456
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x, y, tmp;
    cin >> x >> y;
    
    
    if(2 * x > y || 4 * x < y || y % 2 == 1){
        cout << "No";
    }
    else{
        tmp = y / 2;
        if(tmp == x){
                cout << "Yes";
                return 0;
        }
        for(int i = 0;i < y / 4;i++){
            tmp--;
            if(tmp == x){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        System.out.println(isValid(s, a, b) ? "Yes" : "No");
    }

    private static boolean isValid(String s, int a, int b) {
        if (s.charAt(a) != '-') {
            return false;
        }
        for (int i = 0; i < a; i++) {
            if (!isDigit(s.charAt(i))) return false;
        }
        for (int i = a + 1; i < a + b + 1; i++) {
            if (!isDigit(s.charAt(i))) return false;
        }
        return true;
    }

    private static boolean isDigit(char c) {
        return '0' <= c && c <= '9';
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
vecl(S);
vecl(T);
int bin1( ll x, int size) {
	int l = 0, r = size;
	while (r-l>1) {
		int mid = (l + r) / 2;
		if (S[mid]>x) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	return l;
}

int bin2(ll x, int size) {
	int l = 0, r = size;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		if (T[mid] > x) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	return l;
}

int main()
{
	int A, B, Q;

	cin >> A >> B >> Q;

	fx(A) {
		vecpl(S);
	}
	fx(B) {
		vecpl(T);
	}

	fy(Q) {
		ll x;
		cin >> x;
		int i = bin1( x, A);
		int j = bin2( x, B);
		ll ans = LLONG_MAX;
		for (int w = 0; w <= 1;w++) {
			if (i+w<0||i+w>=A) {
				continue;
			}
			for (int z = 0; z <= 1; z++) {
				if (j + z < 0 || j + z >= B) {
					continue;
				}
				ll s = S[i + w] - x, t = T[j + z] - x;
				ll ss = abs(s), tt = abs(t);
				if ((s>0&&t<0) || (t > 0&& s < 0)) {
					ans = min({ ans, abs(s) * 2 + abs(t), abs(t) * 2 + abs(s) });
				}
				else {
					ans = min(ans,max(abs(s), abs(t)));
				}

			}
		}
		ce(ans)
	}

    return 0;
}



Measured memory_bytes: 3060
import numpy as np
N,Q = map(int,input().split())
S = np.array(list('_' + input()), dtype='U2')
A = (S == 'A')
C = (S == 'C')
AC = (A[:-1] & C[1:])
AC_cum = AC.cumsum()

for _ in range(Q):
  L,R = map(int,input().split())
  print(AC_cum[R-1] - AC_cum[L-1])


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

struct node {
    ll a, b, c;
};

ll solve(node *ar, ll n) {
    ll dp[n + 1][3];
    dp[1][0] = ar[1].a;
    dp[1][1] = ar[1].b;
    dp[1][2] = ar[1].c;
    for(int i = 2; i <= n; ++i) {
        dp[i][0] = ar[i].a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = ar[i].b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = ar[i].c + max(dp[i - 1][1], dp[i - 1][0]);
    }
    return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main() {
    ll n;
    cin >> n;
    node ar[n + 1];
    for(int i = 1; i <= n; ++i)
        cin >> ar[i].a >> ar[i].b >> ar[i].c;
    cout << solve(ar, n);
}


Measured memory_bytes: 8272
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    let mut f = 0;
    let mut p = n;
    for i in 0..n - 1 {
        if v[i] == v[i + 1] {
            continue;
        } else if v[i] > v[i + 1] {
            if f == 2 {
                ans += 1;
                f = 0;
                p = i;
            } else {
                f = 1;
            }
        } else {
            if f == 1 {
                ans += 1;
                f = 0;
                p = i;
            } else {
                f = 2;
            }
        }
    }
    if p != n - 1 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int depth[100100];
int par[100100];

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    void init(int n) { par.assign(n,-1);}
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};
ll N,A,B,K; ll TMP = 998244353;
ll fac[550000], finv[550000], inv[550000];
void Combination_init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < 550000; i++){
        fac[i] = (fac[i-1]*i) % TMP;
        inv[i] = TMP - inv[TMP%i] * (TMP/i) % TMP;
        finv[i] = (finv[i-1] * inv[i]) % TMP;
    }
}
ll COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%TMP)%TMP;
}

int main(){
    Combination_init();
    cin >> N >> A >> B >> K;
    ll res = 0;
    for(ll a = 0; a <= N; a++){
        ll rem = K - a*A;
        if(rem % B != 0) continue;
        ll b = rem/B;
        if(b > N) continue;
        ll tmp = COM(N,a)*COM(N,b)%TMP;
        res += tmp;
        res %= TMP;
    }
    cout << res << endl;
}


Measured memory_bytes: 13184
import numpy as np
import sys
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i4,i4[:],i4[:])',cache=True)
def precompute(n,v,w):
    dp = np.zeros((1024,10**5+1),np.int32)
    for i in range(1,min(1024,n+1)):
        vi = v[i]
        wi = w[i]
        p = i//2
        dp[i]=dp[p]
        for j in range(wi,10**5+1):
            dp[i][j] = max(dp[i][j],dp[p][j-wi]+vi)
    return dp

@njit('(i4,i4[:],i4[:],i4[:],i4[:])',cache=True)
def main(n,v,w,vq,lq):
    dp = precompute(n,v,w)
    values = np.empty(1024,np.int32)
    weights = np.empty(1024,np.int32)

    def solve(V,L,values,weights,dp):
        if V < 1024:
            return dp[V][L]
        values[0] = 0
        weights[0] = 0
        p = 0
        while V >= 1024:
            for j in range(1 << p):
                values[j + (1 << p)] = values[j]+ v[V]
                weights[j + (1 << p)] = weights[j] + w[V]
            p += 1
            V >>= 1
        ans = 0
        for i in range(1 << p):
            if weights[i] <= L:
                x = dp[V][L-weights[i]] + values[i]
                ans = max(ans,x)
        return ans
    q = len(vq)
    for i in range(q):
        x = solve(vq[i],lq[i],values,weights,dp)
        print(x)
       
n = int(readline())
stdin = np.array(read().split(),np.int32)
v = np.zeros(n+1,np.int32)
w = np.zeros(n+1,np.int32)
v[1:] = stdin[:2*n:2]
w[1:] = stdin[1:2*n:2]
query = stdin[2*n+1:]
vq = query[::2]
lq = query[1::2]

main(n,v,w,vq,lq)

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


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,dp[4010][4010],cnt[2];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    n=s.size();
    dp[0][0]=1;
    rep(i,2*n){
        if(i<n){
            if(s[i]=='0')cnt[0]+=2,cnt[1]+=0;
            if(s[i]=='1')cnt[0]+=1,cnt[1]+=1;
            if(s[i]=='2')cnt[0]+=0,cnt[1]+=2;
        }
        rep(j,cnt[0]+1){
            if(j<cnt[0]){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=998244353;
            }
            if(i+1-j<=cnt[1]){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=998244353;
            }
        }
    }
    cout<<dp[2*n][cnt[0]]<<endl;
    return 0;
}

Measured memory_bytes: 104868
import java.util.*;

public class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long d = B%2 == 0 ? (B/2) : ((B/2)+1);
    long ans = A%2 == 0 ? (A/2)*B : (A/2)*B+d;
    if(A == 1 || B == 1){
      ans = 1;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
import sys
import math




def isEnable(now, next):
    distance = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time_len = next[0] - now[0]

    if distance <= time_len and (time_len - distance) % 2 == 0:
        return True
    else:
        return False


N = int(input())

roots = []

roots.append((0, 0, 0))

for i in range(N):
    r = tuple(map(int, input().split(" ")))
    roots.append(r)

for i in range(N):
    if isEnable(roots[i], roots[i+1]):
        continue
    else:
        print('No')
        sys.exit()

print('Yes')


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

using namespace std;

int main(){
  int n;
  string s;
  std::cin >> s;
  n = s.size();
  if(s.substr(0,(n-1)/2) == s.substr(((n+3)/2) - 1,n)) cout << "Yes" << endl; 
  else cout << "No" << endl;
  return 0;
}

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

int main() {
	int S;
	cin >> S;
	int h, m, s;
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;

	cout << h << ":" << m << ":" << s << endl;

	
	return 0;
}


Measured memory_bytes: 3116
n = str(input())

flag = 0
if len(n) % 2 != 0:
    print("No")
else:
    for i in range(int(len(n)//2)):
        if n[i * 2] == "h" and n[i * 2 + 1] == "i":
            flag = 1
        else:
            flag = 0
    if flag == 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string S; cin >> S;
  long long res = 0;
  long long cntW = 0;
  for(int i=S.size()-1;i>=0;i--){
    if(S[i] == 'W') ++cntW;
    else res += cntW;
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n;
    cin>>n;
    int k[n],ans[n];
    
    for(int i=0;i<n;i++){
        cin>>k[i];
    }
    
    int now=0;
    for(int i=n-1;i>-1;i=i-2){
        ans[now]=k[i];
        now++;
    }
    
    if(n%2){
        for(int i=1;i<n;i=i+2){
        ans[now]=k[i];
        now++;
    }
    }
    else{
        for(int i=0;i<n;i=i+2){
        ans[now]=k[i];
        now++;
    }
    }
    
    for(int i=0;i<n;i++){
        cout<<ans[i];
        if(i<n-1){
            cout<<" ";
        }
    }
}


Measured memory_bytes: 3840
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=2e5+10;
int n,p[N],dp[N];
void main() {
    R(n);
    REP1(i,1,n) R(p[i]);
    int mx=0;
    REP1(i,1,n) {
        int x=p[i];
        dp[x]=dp[x-1]+1;
        chkmax(mx,dp[x]);
    }
    int ans=n-mx;
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b;

int main(){
	cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    repi(i, n, 0)
    {
        if (s[i] == '?')
        {
            s[i] = 'D';
        }
    }
    cout << s << endl;
    return 0;
}


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;
vector<int> adj[N], cc;
int res[N], n, m, k, visit[N];
vector<vector<int>> comp;
map<int, int> bro;

int dfs(int node) {
    if(visit[node])
        return 0;
    visit[node] = 1;
    cc.pb(node);
    int ret = 1;
    for(int x: adj[node]) {
        ret += dfs(x);
    }
    res[node] -= adj[node].size();
    return ret;
}

bool same(int x, int y) {
  return bro[x] == bro[y];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    cin >> n >> m >> k;
    forn(i, m) {
        int x, y; cin >> x >> y;
        --x, --y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    forn(i, N) {
        if(!visit[i]) {
            cc.clear();
            int co = dfs(i)-1;
            sort(all(cc));
            for(int x: cc) {
                bro[x] = i+1;
                res[x] += co;
            }
            comp.pb(cc);
        }
    }
    forn(i, k) {
        int x, y; cin >> x >> y;
        --x, --y;
        if(same(x, y))
            --res[x], --res[y];
    }
    forn(i, n)
        cout << res[i] << " ";
    cout << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 15024
# -*- coding: utf-8 -*-

import sys
import os
import math

def f(x):
    return x * x

for s in sys.stdin:
    d = int(s)
    num = 600 // d

    S = 0
    for i in range(num):
        x = d
        y = f(d * i)
        S += x * y
    print(S)

Measured memory_bytes: 7608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll N;
    cin>>N;
    v a(N),b(N);
    rep(i,0,N){
        cin>>a[i];
    }
    rep(i,0,N){
        cin>>b[i];
    }
    ll plus = 0, minus = 0;
    rep(i,0,N){
        if(a[i] <= b[i])plus += (b[i]-a[i])/2;
        else minus += a[i]-b[i];
    }
    YN(plus >= minus);

    return 0;
}

Measured memory_bytes: 384
n=int(input())
a=sorted(list(map(int,input().split())))

ok=n-1
ng=-1

while abs(ok-ng)>1:
 mid=(ok+ng)//2

 inx=mid
 bool=True
 sum_mid=sum(a[:mid+1])

 while bool and inx!=n-2:
  if sum_mid*2>=a[inx+1]:
   sum_mid+=a[inx+1]
   inx+=1
  else:
   bool=False

 if bool:
  ok=mid
 else:
  ng=mid

print(n-ok)

Measured memory_bytes: 14512