akhauriyash/Code-Regression huggingface dataset:
import collections
n = int(input())
a = [int(x) for x in input().split()]

c = collections.Counter(a)
max_counts = 0

for i in c.keys():
    #count = sum([v for k, v in c.items() if abs(k-i) <= 1])
    count = c[i] + c[i-1] + c[i+1]
    max_counts = count if count > max_counts else max_counts

print(max_counts)

Measured memory_bytes: 14564
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL
int n,m;
//vector<int> a,b;
vector<int> gidx;
vector<set<int>> g;

void g_merge(int a, int b) {
//printf("merge(%d, %d)\n", a, b);
  int ga = gidx[a];
  int gb = gidx[b];
//printf("ga = %d, gb = %d\n", ga, gb);
  if (ga == gb) return;

  if (g[ga].size() > g[gb].size()) {
    for (auto it=g[gb].begin(); it!=g[gb].end(); it++) {
//printf("gidx[%d] = %d\n", *it , gidx[a]);
      gidx[*it] = ga;
//printf("g[gidx[%d]].insert(%d)\n", a, *it);
      g[ga].insert(*it);
    }
    g[gb].clear();
  } else {
    for (auto it=g[ga].begin(); it!=g[ga].end(); it++) {
//printf("gidx[%d] = %d\n", *it , gidx[a]);
      gidx[*it] = gb;
//printf("g[gidx[%d]].insert(%d)\n", a, *it);
      g[gb].insert(*it);
    }
    g[ga].clear();
  }
}

int main()
{
  int a,b;
  ll ans;

  cin >> n >> m;

  g.resize(n+1);
  gidx.resize(n+1);
  for (int i=1; i<=n; i++) {
    set<int> gx;
    gx.insert(i);
    g[i] = gx;
    gidx[i] = i;
  }
  for (int i=0; i<m; i++) {
    cin >> a >> b;
    g_merge(a, b);
  }

  ans=0;
  for (auto it=g.begin(); it!=g.end(); it++) {
    if (ans<(ll)it->size()) ans = it->size();
  }

  cout << ans << endl;
  return 0;
}
/*
  {1,2,3,4}

  {1,3,4}{5,9}{2,6}
  */


Measured memory_bytes: 24208
#create date: 2020-06-28 12:09

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    d = [0] * (10**6+1)
    for ai in a:
        if d[ai] < 2:
            for i in range(1, (10**6//ai)+1):
                d[ai*i] += 1
    ans = 0
    for ai in a:
        if d[ai] == 1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 104260
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second

ll n, seg[maxn], a[maxn], h[maxn], st[maxn];
bool vis[maxn];
vector<ll> g[maxn];

void upd(ll id, ll s, ll e, ll l, ll r, ll x){
    if(r <= s || e <= l) return;
    if(l <= s && e <= r){
        seg[id] = x;
        return;
    }
    ll mid = (s + e) / 2;
    upd(id * 2, s, mid, l, r, x);
    upd(id * 2 + 1, mid, e, l, r, x);
    seg[id] = max(seg[id * 2], seg[id * 2 + 1]);
    return;
}
ll get(ll id, ll s, ll e, ll l, ll r){
    if(r <= s || e <= l) return 0;
    if(l <= s && e <= r) return seg[id];
    ll mid = (s + e) / 2;
    return max(get(id * 2, s, mid, l, r), get(id * 2 + 1, mid, e, l, r));
}

void dfs(ll v){
    vis[v] = 1;
    upd(1, 0, n, h[v], h[v] + 1, v);
    st[h[v]] = v;
    if(v != 1){
        ll u = get(1, 0, n, 0, h[v] + 1);
        if(u == v){
            a[v]++;
        }
        else{
            ll x1 = get(1, 0, n, 0, h[u]);
            ll x2 = get(1, 0, n, h[u] + 1, h[v] + 1);
            if(x1 > x2){
                a[u]++;
            }
            else{
                a[st[h[u] + 1]]++;
            }
        }
    }
    for(ll u : g[v]){
        if(!vis[u]){
            h[u] = h[v] + 1;
            dfs(u);
        }
    }
    return;
}
void solve(ll v){
    for(ll u : g[v]){
        if(h[u] > h[v]){
            a[u] += a[v];
            solve(u);
        }
    }
    return;
}

int main(){
    fast_io;

    cin >> n;
    for(ll i = 1; i < n; i++){
        ll v, u;
        cin >> v >> u;
        g[v].pb(u);
        g[u].pb(v);
    }
    dfs(1);
    solve(1);
    for(ll i = 2; i <= n; i++){
        cout << a[i] << " ";
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
   ll takahasi,aoki;
   ll n;cin >>n;
   V t(n),a(n);
   rep(i,n){
    cin >>t[i]>>a[i];
    }
    takahasi=t[0];
    aoki=a[0];
    rep(i,n){
        if(i==0)continue;
        ll k;
        k=(takahasi-1)/t[i]+1;
        k=max(k,(aoki-1)/a[i]+1);
        takahasi=k*t[i];
        aoki=k*a[i];
    }
    cout <<takahasi+aoki<< endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=[0]*n
for x in range(1,101):
  for y in range(1,101):
    if x*x+y*y>n:
      break
    for z in range(1,101):
      if x*x+y*y+z*z+x*y+x*z+y*z>n:
        break
      ans[x*x+y*y+z*z+x*y+x*z+y*z-1]+=1
for i in range(n):
  print(ans[i])

Measured memory_bytes: 69632
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> T(N), A(N);
  for (int i = 0; i < N; i++)
    cin >> T[i] >> A[i];
  ll a = 0, b = 0;
  for (int i = 0; i < N; i++)
  {
    if (a <= T[i] && b <= A[i])
      a = T[i], b = A[i];
    else if (a > T[i] && b <= A[i])
    {
      a = ((a + T[i] - 1) / T[i]) * T[i];
      ll mul = a / T[i];
      b = A[i] * mul;
    }
    else if (a <= T[i] && b > A[i])
    {
      b = ((b + A[i] - 1) / A[i]) * A[i];
      ll mul = b / A[i];
      a = T[i] * mul;
    }
    else
    {
      ll mula = ((a + T[i] - 1) / T[i]) * T[i] / T[i];
      ll mulb = ((b + A[i] - 1) / A[i]) * A[i] / A[i];
      a = max(mula, mulb) * T[i], b = max(mula, mulb) * A[i];
    }
  }
  cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int prime[60000],i,j,x;
  
  for(i=0;i<60000;i++)
    prime[i]=0;
  prime[0]=1;
  prime[1]=1;
  
  
  for(i=2;i*i<60000;i++){
    if(prime[i]==0){
      for(j=i*2;j<60000;j+=i){
	prime[j]=1;
      }
    }
  }
  
  while(scanf("%d",&x)!=EOF){
    for(i=x-1;i>=2;i--){
      if(prime[i]==0){
	printf("%d ",i);
	break;
      }
    }
    
    for(i=x+1;i<60000;i++){
      if(prime[i]==0){
	printf("%d\n",i);
	break;
      } 
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

main()
{
  int x, top = 0;
  int stack[100];
  char s[100];
  
  while(scanf("%s", s) != EOF)
    {
      if(s[0] == '+')
	{
	  stack[top - 2] = stack[top - 2] + stack[top - 1];
	  top--;
	}
      else if(s[0] == '-')
	{
	  stack[top - 2] = stack[top - 2] - stack[top - 1];
	  top--;
	}
      else if(s[0] == '*')
	{
	  stack[top - 2] = stack[top - 2] * stack[top - 1];
	  top--;
	}
      else
	{
	  x = atoi(s);
	  stack[top] = x;
	  top++;
	}
    }
  printf("%d\n", stack[top - 1]);
  return 0;
}

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

Lmax = 1
Rmin = N

for i in range(M):
    L, R = map(int, input().split())
    if(Lmax<L):
        Lmax = L
    if(R<Rmin):
        Rmin = R

if (Lmax<=Rmin):
    print(Rmin-Lmax+1)
else:
    print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N, K;
    cin >> N >> K;
    ll i;
    ll x[MAX];
    
    for(i=0; i<N; i++) {
        cin >> x[i];
    }
    
    ll ans=INF;
    for(i=0; i<=N-K; i++) {
        ll l=x[i];
        ll r=x[i+K-1];
        
        if(l>=0) chmin(ans, r);
        else if(r<=0) chmin(ans, -l);
        else chmin(ans, (-l+r)*2-max(-l, r));
    }
    
    pt(ans);
}





Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]

edge = [set() for _ in range(N)]
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge[i1].add((i2,d))
    
# csr形式に直す
indptr = []
indrow = []
value = []
ptr = 0
for i in range(N):
  indptr.append(ptr)
  for j,v in edge[i]:
    indrow.append(j)
    value.append(v)
    ptr += 1
indptr.append(ptr)
value = np.array(value,dtype=int)
graph = csr_matrix((value,indrow,indptr),shape=(N,N))

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
answer = tree.sum()
print(answer)

Measured memory_bytes: 88804
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

for($j = 2; $j <= $M; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $j--;
    }
}
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
echo $product;

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    static $memo;
    if(!isset($memo[$a][$b])){
        $memo[$a][$b] = mulm($a, powerm($b, MOD - 2));
    }
    return $memo[$a][$b];
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    if(!isset($memo[$a])){
        $memo[$a] = factorialm($a - 1) * $a % MOD;
    }
    return $memo[$a];
}
//順列
function nPm($n, $m){
    static $memo;
    if($m == 0)return 1;
    if(!isset($memo[$n][$m])){
        $memo[$n][$m] = nPm($n, $m - 1) * ($n - $m + 1) % MOD;
    }
    return $memo[$n][$m];
}
//組み合わせ
function nCm($n, $m){
    static $memo;
    if(!isset($memo[$n][$m])){
        $m = min($m, $n-$m);
        $memo[$n][$m] = divm(nPm($n, $m), factorialm($m));
    }
    return $memo[$n][$m];
}

Measured memory_bytes: 4604
import java.util.Scanner;

class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		//int N = scanner.nextInt();
		long A = scanner.nextLong();
		long B = scanner.nextLong();
		int sum = 1;
		long sub = A;

		while(true){
			sub *= 2;
			if(sub > B ){
				break;
			}
			sum++;
		}

		System.out.println(sum);

	}
}



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

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


int main()
{
  int n, w;
  cin >> n >> w;
  vector<ll> weight(n), value(n);
  rep(i, n)
    cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
  rep(i, n)
    rep(j, w + 1)
    {
      if (j == 0)
        dp[i+1][j] = dp[i][j];
      else
        chmax(dp[i+1][j], max(dp[i+1][j-1], dp[i][j]));
      if (j + weight[i] <= w)
        chmax(dp[i+1][j+weight[i]], dp[i][j] + value[i]);
    }
  // rep(i, n+1)
  // {
  //   rep(j, w+1)
  //     printf("%lld,", dp[i][j]);
  //   cout << endl;
  // }
  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 80256
#include <iostream>
using namespace std;
int main(){
  int a, b, k, ans;
  cin >> a >> b >> k;
  for(int i=min(a, b); k>0; i--){
    if(a%i==0&&b%i==0){
      ans = i;
      k--;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <math.h>

using namespace std;

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

	long long cnt = 0;
	for (int i = 1; i < sqrt(n); i++)
	{
		if (n % i == 0)
		{
			if (i != 1)
			{
				if (n / (i - 1) == n % (i - 1))
					cnt += i - 1;
			}
			if (n / (n / i - 1) == n % (n / i - 1))
				cnt += n/i - 1;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
int main() {
  int a, b; cin >> a >> b;
  int p = a+b;
  int x = a*b;
  int m = a-b;
  int l = max (p,x);
  int ans = max (l,m);
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;

bool check(vector<P> v){
    int h = 0;
    for(P p : v){
        int b = h + p.first;
        if(b<0) return false;
        h = h + p.second;
    }
    return true;
}


int main() {
    ll n;
    cin >> n;
    vector<P> ls;
    vector<P> rs;
    int total=0;

    rep(i,n){
        int b=0,h=0;
        string s;
        cin >> s;
        for(char c : s){
            if(c=='(') ++h; else --h;
            b = min(b,h);
        }
        if(h>0) ls.emplace_back(b,h);
        else rs.emplace_back(b-h,-h);
        total += h;
    }

    sort(ls.rbegin(),ls.rend());
    sort(rs.rbegin(),rs.rend());

    if(check(ls) && check(rs) && total==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 18940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;


int main(){
    string A, B, C;
    int N; cin >> N >> A >> B >> C;
    int cnt=0;
    for(int i = 0; i < N; i++){
        if(A[i] == B[i] && B[i] == C[i] && C[i] == A[i]) continue;
        else if(A[i] == B[i] && B[i] != C[i] && C[i] != A[i]) cnt++;
        else if(A[i] != B[i] && B[i] == C[i] && C[i] != A[i]) cnt++;
        else if(A[i] != B[i] && B[i] != C[i] && C[i] == A[i]) cnt++;
        else if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) cnt+=2;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter

N, M = list(map(int, input().split()))
max_l = 1
min_r = N
for _ in range(M):
    l, r = list(map(int, input().split()))
    if max_l < l:
        max_l = l
    if min_r > r:
        min_r = r

print(min_r - max_l + 1 if min_r - max_l >= 0 else 0)


Measured memory_bytes: 3444
a, b, c = map(int, input().split())
 
if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")  
elif a == 7 and b == 5 and c == 5:
  print("YES") 
else:
  print("NO") 

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans=a/__gcd(a,b)*b;
    cout << ans << endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double a,b,x;
	cin>>a>>b>>x;
	cout<<fixed<<setprecision(10);
	long double cry=(a*a*b)/2.0;
	if(x>=cry)
	{
	    long double temp=(a*a*b-x);
	    temp*=2.0;
	    long double den=a*a*a;
	    temp/=den;
	    long double ans=atan(temp);
	    ans*=(180.0/PI);
	    cout<<ans;
	}
	else
	{
	    long double temp1=(2.0*x)/(a*b*b);
	    long double ans=atan(temp1);
	    ans*=(180.0/PI);
	    cout<<(90.0-ans);
	}
	
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
     lint N,M;
     cin>>N>>M;
     if(N==1&&M==1)cout<<1;
     else if(N==1||M==1)cout<<max(N,M)-2;
     else cout<<N*M-N*2-2*M+4;
  }
     
  


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1010;
int main()
{
    int x;
    cin>>x;
    vector<pair<int,int> > v;
    for(int i=0;i<x;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
     cout<<v[i].first<<" "<<v[i].second<<endl;   
    }
}


Measured memory_bytes: 3884
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import math


x = int(input())
tmp = int(math.ceil(x / 11.0 * 2.0))
# print(11 * tmp // 2)
# print(tmp)
if (11 * tmp) // 2 - 5 >= x:
    print(tmp-1)
else:
    print(tmp)


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=12){
        if(a<=5){
            cout << 0 << endl;
        }else{
            cout << b/2 << endl;
        }
    }else{
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    auto x = (h2 * 60 + m2) - (h1 * 60 + m1);
    if (x < 0)
        x += 24 * 60;

    cout << (x - k) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#define MAX 105
using namespace std;

int main()
{
	int n, k, d,b;
	int count = 0;
	int a[MAX] = { 0 };
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			cin >> b;
			a[b]++;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == 0)
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> N(4);
    for(int i=0;i<4;i++){
        cin>>N.at(i);
    }sort(N.begin(),N.end());
    if(N.at(0)==1&&N.at(1)==4&&N.at(2)==7&&N.at(3)==9){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	string s, t;
	cin >> s >> t;
	int cnt = 0, n = s.length();
	for(int i = 0; i < n; ++i) {
		if(s[i] != t[i]) ++cnt;
	}
	cout << cnt;

	return 0;
}


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

def g1(n, p):
    if n == 0:
        return 0
    else:
        return n // p + g1(n // p, p)

def g2(n, p):
    res = 0
    if n % 2 == 1:
        return g1(n, p) - g2(n - 1, p)
    else:
        res = g1(n // 2, p)
        if p == 2:
            res += n // 2
        return res


ans = min(g2(n, 2), g2(n, 5))
print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

#define Mod 1000000007

int factorize(int n, int p[], int m[])
{
	int i, k;
	for (i = 2, k = 0; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[k] = i;
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

long long pow_mod(int n, int k)
{
	if (k == 0 || n == 1) return 1;
	
	int i;
	long long N;
	for (i = 1, N = n; i * 2 <= k; i *= 2) N = N * N % Mod;
	return N * pow_mod(n, k - i) % Mod;
}

int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	int i, j, k, n, p[100], m[100], l[100], tmp;
	long long add[100001] = {0, 1}, ans = pow_mod(K, N);
	for (n = 2; n <= K; n++) {
		k = factorize(n, p, m);
		for (i = 0, l[k] = 1; i < k; i++) l[i] = m[i];
		add[n] = n;
		tmp = n;
		while (1) {
			for (i = 0; i < k; i++) if (l[i] > 0) break;
			if (i == k) break;
			for (l[i]--, tmp /= p[i--]; i >= 0; i--) {
				for (j = 0; j < m[i]; j++) tmp *= p[i];
				l[i] = m[i];
			}
			add[n] -= add[tmp];
		}
		ans = (ans + pow_mod(K / n, N) * add[n]) % Mod;
	}
	
	printf("%lld\n", (ans + Mod) % Mod);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2468
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n,W;
    cin>>n>>W;
    ll w[n];
    int v[n];

    ll SumValue=0;

    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        SumValue+=v[i];
    }
    vector<ll>dp(SumValue+1);
    for(int i=0;i<=SumValue;i++)dp[i]=1000000000000LL;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int val=SumValue-v[i];val>=0;val--){

            dp[val+v[i]]= min(dp[val+v[i]],dp[val]+w[i]);
        }
    }
    ll ans =0;
    for(int i=0;i<=SumValue;i++){
        //cout<<dp[i]<<"\n";
        if(dp[i]<=W)ans = i;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1024
/*'''''''''''''''
 ----------------
 Md. Tarek Hossain Tusher
  Cumilla University
  Dept. of CSE

 ----------------
 ''''''''''''''''
 */
#include<stdio.h>
#include<string.h>
int main()
{
   int a,p;
   scanf("%d  %d",&a,&p);
   int tt;
   tt=a*3+p;
   if(tt%2==0)printf("%d\n",tt/2);
   else printf("%d\n",(tt-1)/2);
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  string s;
  cin >> s;

  if(s.size()%2 ==1){
    if(s[0] == s[s.size()-1])
      cout << "Second" << endl;
    else
      cout << "First" << endl;
  }
  else{
    if(s[0] != s[s.size()-1])
      cout << "Second" << endl;
    else
      cout << "First" << endl;    

  }
    
  return 0;
}



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

a = []
b = 0
c = 0
d = 0

for i in range(N):
    a.append(int(input()))
    if b < a[i]:
        b = a[i]
        c = i
    d += a[i]
print(int(d - a[c] + a[c]/2) )
    

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile("\\s");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

string s;
lli red,blue;
lli ans;

int main(){
  cin >> s;
  for(lli i = 0;i < s.size();i++){
    if(s[i] == '0'){
      if(blue){
        blue--;
        ans += 2;
      }else{
        red++;
      }
    }else{
      if(red){
        red--;
        ans += 2;
      }else{
        blue++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
n, m, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
brr = gets.chomp.split.map(&:to_i)
1.upto(n - 1) do |i|
	arr[i] += arr[i-1]
end
1.upto(m - 1) do |i|
	brr[i] += brr[i-1]
end
arr = [0] + arr 
brr = [0] + brr 
# p arr 
# p brr


bind = brr.index{|v| v > k}
bind = m if bind == nil
max = [bind - 1, 0].max 
(n+1).times do |i|
	while arr[i] + brr[bind] > k 
		bind -= 1
		if bind < 0
			puts max 
			exit 
		end
	end
	if max < i + bind 
		max = i + bind
		#puts "i:#{i} bind:#{bind}"
	end
end

puts max



Measured memory_bytes: 49236
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e6;
unordered_map<int,vector<int>> sieve;



int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int n;cin>>n;int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  sort(arr,arr+n);unordered_map<int,int> cnt;int count=0;
  for(int i:arr) cnt[i]++;
  if(cnt.count(1)) 
  {
    if(cnt[1]>1) cout<<0;
    else cout<<1;
    return 0;
  }
  for(int i:arr)
  {
    if(cnt[i]>1) continue;
    bool st=false;
    for (int j=2; j<=sqrt(i); j++) 
    {
        if (i%j==0 && (cnt.count(j) || cnt.count(i/j)))
        {
          st=true;break;
        }
    } 
    if(!st) count++;
  }
  cout<<count<<endl;
  return 0;
}
      

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

using namespace std;

int main () {
  string str;
  cin >> str;
  if(str[2]==str[3] && str[4]==str[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

#define llong long long 
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define ii pair<int, int>

#define maxn 100
int n;
int a[maxn];

vector<ii> ans;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n;
  rep1(i, n) cin >> a[i];
  llong t = max_element(a + 1, a + n + 1, [](int u, int v) { return abs(u) < abs(v); }) - a;
  if (a[t] == 0) {
    cout << 0;
    return 0;
  }
  ans.push_back({t, t});
  ans.push_back({t, t});
  if (a[t] < 0) {
    ans.push_back({t, 1});
    for (int i = n - 1; i > 1; i--) {
      ans.push_back({1, 1});
      ans.push_back({1, i});
    }
    ans.push_back({1, 1});
  } else {
    ans.push_back({t, n});
    for (int i = 2; i < n; ++i) {
      ans.push_back({n, n});
      ans.push_back({n, i});
    }
    ans.push_back({n, n});
  }
  cout << len(ans) << '\n';
  for (auto i: ans) cout << i.xx << ' ' << i.yy << '\n';

  return 0;
}


Measured memory_bytes: 256
import math

N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
R=[]
#print(A)
for i in range(N-1):
    for j in range(i+1,N):
        #print(i,j)
        x=A[i][0]
        y=A[i][1]
        a=A[j][0]
        b=A[j][1]
        tmp=((x-a)**2+(y-b)**2)**0.5
        R.append(tmp)

x=math.factorial(N)
a=(N-1)*x/(len(R))
c=sum(R)
print(c*a/x)

Measured memory_bytes: 38512
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
using namespace std;
 
const double PI = 3.14159265358979;
const double EPS = 1e-9;
 
class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};
 
class Wind {
public:
    double w, a;
};
 
bool include(double angle, double low, double high) {
    if(low < 0 + EPS) {
        double l = low + 2.0 * PI;
        if(l <= angle + EPS) return true;
    }
    if(high > 2.0 * PI + EPS) {
        double h = high - 2.0 * PI;
        if(angle <= h + EPS) return true;
    }
    return low <= angle + EPS && angle <= high + EPS;
}
 
bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0) angle = angle + 2 * PI;
        if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}
 
double toRadian(double d) {
    return d * PI / 180.0;
}
 
int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;
 
        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;
 
        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);
 
        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;
 
        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);
 
        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;
 
        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);
 
                if(!ok || ng) continue;
 
                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }
 
        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

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

int main()
{
  int n;
  string i,j,k;
  n=97-65;
  cin>>i>>j>>k;
  cout<<char(i[0]-n)<<char(j[0]-n)<<char(k[0]-n);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
		for(;;)
		{
			int y1=in.nextInt(),m1=in.nextInt(),d1=in.nextInt();
			int y2=in.nextInt(),m2=in.nextInt(),d2=in.nextInt();
			int cnt1=0;
			int cnt2=0;
			if(y1<0)
				break;
			for(int i=1;i<y1;i++)
			{
				if(year(i))
					cnt1+=366;
				else
					cnt1+=365;
			}
			for(int i=1;i<m1;i++)
			{
				if(i==2&&year(y1))
					cnt1+=month[i]+1;
				else
					cnt1+=month[i];
			}
			cnt1+=d1;
			for(int i=1;i<y2;i++)
			{
				if(year(i))
					cnt2+=366;
				else
					cnt2+=365;
			}
			for(int i=1;i<m2;i++)
			{
				if(i==2&&year(y2))
					cnt2+=month[i]+1;
				else
					cnt2+=month[i];
			}
			cnt2+=d2;
			System.out.println(cnt2-cnt1);
		}
	}

	static boolean year(int y)
	{
		if(y%4==0&&(y%100!=0||y%400==0))
			return true; else	
				return false;
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 21060
x,y,a,b,c  = map(int,input().split())
p=[int(x) for x in input().rstrip().split()]
q=[int(x) for x in input().rstrip().split()]
r=[int(x) for x in input().rstrip().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:x]
q=q[:y]
pq=p+q
pqr=pq+r
pqr.sort(reverse=True)
print(sum(pqr[:x+y]))

Measured memory_bytes: 29600
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;cin>>n;long long sums=0;
  	for(long long int i=1;i<=n;i++){if(i%3==0 || i%5==0){continue;}else{sums+=i;}}
  cout<<sums;
}

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

const int INF=2e9+7;

int N,K;

int as[100005];
int dp[100005];

int main(){
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  dp[0]=0;
  for(int i=1;i<N;i++){
    dp[i]=INF;
    for(int k=1;k<=std::min(K,i);k++){
      dp[i]=std::min(dp[i],dp[i-k]+std::abs(as[i]-as[i-k]));
    }
  }
  printf("%d\n",dp[N-1]);
  return 0;
}


Measured memory_bytes: 896
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int sum = 0;
        for (int i=1; i<=N; i++) {
            int n = i;
            int digSum = 0;
            while (n > 0) {
                digSum += n % 10;
                n /= 10;
            }
            if (digSum >= A && digSum <=B)
                sum += i;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>
#include <climits>
#include <cstring>

typedef long long ll;

using namespace std;

void solve(){
    int n, m, l;
    cin >> n >> m >> l;
    int a[n][m], b[m][l];
    ll c[n][l];
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            c[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            for(int k = 0; k < l; k++){
                c[i][k] += a[i][j]*b[j][k];
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            cout << c[i][j];
            if(j != l-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}

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

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 3e5 + 10, Mod = 998244353;

int Pow(int x, int e) {
	int ret = 1;
	while (e) {
		if (e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int n, A, B;
long long k;

int fac[N], rfac[N];

int C(int n, int m) {
	return 1ll * fac[n] * rfac[m] % Mod * rfac[n - m] % Mod;
}

int main() {

	scanf("%d%d%d%lld", &n, &A, &B, &k);

	fac[0] = 1;
	For(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % Mod;
	rfac[n] = Pow(fac[n], Mod - 2);
	Forr(i, n, 1) rfac[i - 1] = 1ll * rfac[i] * i % Mod;

	int ans = 0;
	For(i, 0, n) if (1ll * i * A <= k && (k - 1ll * i * A) % B == 0) {
		long long b = (k - 1ll * i * A) / B;
		if (b > n) continue;
		ans = (ans + 1ll * C(n, i) * C(n, b)) % Mod;
	}
	printf("%d\n", ans);

	return 0;
}

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

int m[1000001];

int main(){
  int s;

  cin >> s; m[s] = 1;

  long long f, a = s, cnt = 1;
  while(++cnt){
    if(a % 2 == 1) f = 3*a + 1;
    else f = a / 2;

    //cout << f << endl;
    if(m[f] == 1) break;

    ++m[f];
    a = f;
  }

  
  cout << cnt << endl;
}


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


int main(){
  int num,day;
  char c;
  string s;
  int j = 0;
  map<int,int> data[2];
  while(getline(cin,s),!cin.eof()){
    if(s.size()==0){
      j++;
      continue;
    }
    stringstream ss(s);
    ss>>num>>c>>day;
    data[j][num]++;
  }
  for(auto i:data[0]){
    if(data[1][i.first]>0){
      cout<<i.first<<" "<<i.second+data[1][i.first]<<endl;
    }
  }
  return 0;

}

Measured memory_bytes: 1220
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)-1


mid=a[N]
resu=[0,N,n-2]
while resu[2]-resu[0]>1:
    if mid-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1])/2)
        resu[1]=N
        mid=a[N]
    elif mid==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2])/2)
        resu[1]=N
        mid=a[N]
if resu[2]-resu[0]==1:
    if a[resu[0]]+a[resu[2]]-max_a>0:
        resu[1]=resu[0]
    else:
        resu[1]=resu[2]
       
print(max_a,a[resu[1]])

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
ll a_power_b(ll a, ll b){
	ll ret = 1;
	while(b){
		if(b&1){
			ret *= a;
			ret %= mod;
			b--;
		}
		else{
			a *= a;
			a %= mod;
			b >>= 1;
		}
	}
	return ret;
}
ll mil(int l, int r){
	ll ret = 1;
	for(ll i = l; i<= r; ++i){
		ret *= i;
		ret %= mod;
	}
	return ret;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	ll n, a, b;
	cin >> n >> a >> b;
	ll Xa = mil(n - a + 1, n), Ya = mil(1, a);
	ll Xb = mil(n - b + 1, n), Yb = mil(1, b);
	ll Ca = Xa * a_power_b(Ya, 1e9 + 5);// (Xa / Ya) % mod = Xa * (Ya)^(1e9 + 7 - 2)
	ll Cb = Xb * a_power_b(Yb, 1e9 + 5);
	Ca %= mod;
	Cb %= mod;
	ll ans = a_power_b(2,n) - 1  - Ca;
	if(ans < 0) ans += mod;
	ans -= Cb;
	if(ans < 0) ans += mod;
	cout << ans;
}




Measured memory_bytes: 256
def main(): #なんか早くなるおまじない
    import sys
    from collections import defaultdict
    dic = defaultdict(int)

    input = sys.stdin.readline #早くなるおまじない

    s = str(input().rstrip())
    m = 0

    for i in range(1, len(s) + 1):
        m_1 = pow(10, i-1,2019)
        m_add = (int(s[-i]) * m_1) % 2019
        m = (m_add + m) % 2019
        dic[m] += 1

    ans1 = 0

    for x in dic.values():
        if x > 1:
            ans1 += x * (x - 1) // 2
    ans2 = dic[0]

    print(ans1 + ans2)

if __name__ == "__main__":
    main()

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

#define ll long long
#define ld double

using namespace std;


int main()
{
	ll x, y; cin >> x >> y;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			if (2 * i + 4 * j == y && i + j == x) {
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,ans=1;
    scanf("%d %d",&n,&k);
    ans*=k;
    for (int i=0;i<n-1;i++) ans*=k-1;
    printf("%d\n",ans);
    return 0;
}

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

map<int, int> mp;
int n, r;

int main(){
	scanf("%d", &n);
    for(int x; n--; ){
        scanf("%d", &x);
        mp[x]++;
    }
    for(auto &i : mp) r += (i.second >= i.first ? i.second - i.first : i.second);
    printf("%d\n", r);
}

Measured memory_bytes: 4736
class SegmentTree:
    def __init__(self, N, f, e=None):
        self.N = 1<<(N-1).bit_length()
        self.seg = [e] * (self.N*2)
        self.e = e
        self.f = f

    def build(self, A):
        for i,a in enumerate(A):
            self.seg[i+self.N] = a
        for i in range(self.N-1,0,-1):
            self.seg[i] = self.f(self.seg[i<<1], self.seg[i<<1|1])

    def update(self, i, x): # a_i += x
        i += self.N
        self.seg[i] = x
        while i > 1:
            self.seg[i>>1] = self.f(self.seg[i], self.seg[i^1])
            i >>= 1

    def query(self, a, b): # f [a, b)
        L = R = self.e
        a += self.N
        b += self.N
        while a < b:
            if a&1:
                L = self.f(L, self.seg[a])
                a += 1
            if b&1:
                b -= 1
                R = self.f(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.f(L, R)

from collections import Counter
def main():
    N,K,*P=map(int, open(0).read().split())
    Mseg=SegmentTree(N, max, 0)
    mseg=SegmentTree(N, min, float("inf"))
    Mseg.build(P)
    mseg.build(P)
    D=Counter(P[:K])
    ans=1
    als=1
    for i in range(1,K):
        als=als+1 if P[i]>P[i-1] else 1
    iss=als==K
    for i in range(N-K):
        als=als+1 if P[i+K]>P[i+K-1] else 1
        mp=mseg.query(i, i+K)
        Mp=Mseg.query(i+1,i+K+1)
        if not (mp==P[i] and Mp==P[i+K]) and not (iss and als==K):
            ans+=1
        iss|=als==K
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 118588
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b, t;
  cin >> a >> b >> t;

  double T = t + 0.5;

  cout << b*floor(T/a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
void solve(){
	char x,y;
	cin>>x>>y;
	if(x==y)cout<<"="<<endl;
	if(x>y)cout<<">"<<endl;
	if(x<y)cout<<"<"<<endl;	
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int c;
		scanf("%d", &c);
		if (c == cnt+1)
			cnt++;
	}

	if (!cnt)
		puts("-1");
	else
		printf("%d\n", n-cnt);
}


Measured memory_bytes: 128
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
int b[N];
int tong[N];
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



bool check (int x) {
	/*ordered_set < pair < int, int > > q;
	ll ans = 0;
	q.insert({0, 0});
	for (int i = 1; i <= n; ++i) {
		b[i] = b[i-1];
		if (a[i] >= x) b[i]++;
		else b[i]--;
		ans += q.order_of_key({b[i], n+1});
  		q.insert({b[i], i});
	}*/
	memset(tong,0,sizeof(tong));
	int dq=n,dd=1; ll ans=0;
	tong[n]=1; 
	for(int i=1;i<=n;i++){
		if(a[i]>=x){
			dq++; dd+=tong[dq];
		}else{
			dd-=tong[dq]; dq--;
		}
		ans+=dd; tong[dq]++; dd++;
	}
	ll overall = n * (ll)(n+1) / 2;

	return ans * 2 >= overall;
}

int main () {
	scanf("%d", &n);
	vector < int > val;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		val.pb(a[i]);
	}
	sort(every(val));
	val.resize(unique(every(val)) - val.begin());

	int l = 0, r = sz(val);
	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (check(val[md])) {
			l = md;
		} else {
			r = md;
		} 
	}

	printf("%d\n", val[l]);

	return Accepted;
}

// B...a

Measured memory_bytes: 6904