akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll x[200000],v[200000];
ll a[200000],ma[200000];
ll b[200000],mb[200000];

signed main(){
	ll n,c;cin>>n>>c;
	rep(i,n){
		scanf("%lld%lld",&x[i],&v[i]);
	}
	ll cnt=0;
	for(int i=n-1;i>=0;i--)cnt+=v[i],a[i]=cnt-(c-x[i]);
	ma[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)ma[i]=max(ma[i+1],a[i]);
	cnt=0;
	rep(i,n)cnt+=v[i],b[i]=cnt-x[i];
	mb[0]=b[0];
	for(int i=1;i<n;i++)mb[i]=max(mb[i-1],b[i]);
	ll ans=0;
	//最初に時計回り
	cnt=0;
	rep(i,n){
		cnt+=v[i];
		ans=max(ans,cnt-x[i]);
		if(i<n-1)ans=max(ans,cnt-x[i]*2+ma[i+1]);
	}
	//反時計
	cnt=0;
	for(int i=n-1;i>=0;i--){
		cnt+=v[i];
		ans=max(ans,cnt-(c-x[i]));
		if(i)ans=max(ans,cnt-(c-x[i])*2+mb[i-1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <string>
using namespace std;


int main() {
  int N, L;
  cin >> N >> L;
  
  int taste = 0;
  for (int i = 1; i <= N; i++) {
    taste += L+i-1;
  }
  int ans = INT_MAX;
  for (int i = 1; i <= N; i++) {
    if( abs(ans) > abs(L+i-1) ) {
      ans = L+i-1;
    }
  }
  
  
  cout << taste - ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=105;
const ll inf=0x3f3f3f3f;
ll sum[maxn]={};
ll a[maxn]={};
ll as(ll a){
    return a<0?-a:a;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i],sum[i]=sum[i-1]+a[i];
    ll mi=inf;
    for(int i=1;i<n;++i){
        ll right=sum[n]-sum[i];
        ll left=sum[i]-sum[0];
        mi=min(mi,as(right-left));
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=1000000007;
ll dp[1001][1001];
string g[1001];
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h) cin>>g[i];
    rep(i,h){
        if(g[i][0]=='#') break;
        dp[i][0]=1;
    }
    rep(i,w){
        if(g[0][i]=='#') break;
        dp[0][i]=1;
    }
    FOR(i,1,h)FOR(j,1,w){
        if(g[i][j]=='#') continue;
        dp[i][j]+=dp[i-1][j]+dp[i][j-1];
        dp[i][j]%=mod;
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

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

int main(){
  int N, max_number, result;
  cin >> N;
  vector<int> vec(N);
  vector<int> count(N);
  for(int i = 0; i < N; i++){
    vec.at(i) = i + 1;
  }
  vector<int> copy1 = vec;
  for(int i = 0; i < N / 2; i++){
    for(int i = 0; i < N; i++){
      if( vec.at(i) % 2 == 0){
        vec.at(i) /= 2;
        count.at(i)++;
      }
    }
  }
  vector<int> copy = count;
  sort(count.begin(), count.end());
  reverse(count.begin(), count.end());
  max_number = count.at(0);
  for(int i = 0; i < N; i++){
    if(max_number == copy.at(i)){
      result = i;
      break;
    }
  }
  cout << copy1.at(result) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
  	int n=0;
  	cin >> n;
  	vector<double> v(n);
  	for(int i=0;i<n;i++){
  		cin >> v[i];
  	}
  	sort(v.begin(),v.end());
  	double p=v[0];
	for(int i=1;i<n;i++){
  		p=p+v[i];
		p=p/2;	
	}
	cout << p;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
P = [INT() for _ in range(N)]

cnt = [0]*(N+1)

for i in range(N):
	cnt[P[i]] = cnt[P[i]-1]+1

print(N-max(cnt))

Measured memory_bytes: 26292
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void)
{
	int a,b,c,n = 0;
	
	cin >> a >> b >> c ;
	n = a * 100 + b * 10 + c ;
	
	if(n == 110 || n == 001 )
		cout << "Open" << endl ;
	
	else 
		cout << "Close" << endl ;
	
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
// using ll = long long;
#define int long long

signed main() {
    IO;
    int n;
    cin >> n;
    vector<int> ans(10005, 0);
    for(int i = 1; i <= 100; ++i) {
        for(int j = 1; j <= 100; ++j) {
            for(int k = 1; k <= 100; ++k) {
                int x = i*i + j*j + k*k + i*j + j*k + k*i;
                if(x <= 10000) ++ans[x];
            }
        }
    }
    for(int i = 1; i <= n; ++i) cout << ans[i] << "\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC  x  " << mp["AC"] << endl;
    cout << "WA  x  " << mp["WA"] << endl;
    cout << "TLE  x  " << mp["TLE"] << endl;
    cout << "RE  x  " << mp["RE"] << endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
	int N;
	int K;
	int i;
	char a[32];

	cin >> N;
	cin >> K;
	
	for (i = 0; N > 0; i++) {
		a[i] = N % K;
		N = N / K;
	}
		
		printf("%d", i);

	return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X = int(input())

def solve(X):
    for a in range(1000):
        for b in range(-1000, 1000):
            a ** 5 - b ** 5
            if a ** 5 - b ** 5 == abs(X):
                return a, b

a,b = solve(X)
if a ** 5 - b** 5 == X:
    print(a, b)
else:
    print(b, a)

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

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

    bool Rflag=true;
    int countRL=0;
    int countLR=0;

    int Lstart=0;
    int Rend=0;
    int happy=0;

    for(int i=0; i<N; i++){
        //cout << "Rflag i S[i] " << Rflag << " " << i << " " << S[i] << endl;
        if( Rflag && ( S[i]=='L' || i==N-1 ) ){
            Rflag=false;
            countRL++;
            if( i==N-1 && S[i]!='L' ){
                Rend++;
            }else if( i==0 ){
                Lstart++;
            }
        }else if( !Rflag && S[i]=='R' ){
            Rflag=true;
            countLR++;
            if( i<N-1 && S[i+1]=='R' ){
                happy++;
            }
            if( i==N-1 ){
                Rend++;
                countRL++;
            }
        }else{
            happy++;
            if( Rflag && i<N-1 && S[i+1]=='L' ){
                happy--;
            }
        }
    }
    //cout << "Lstart Rend " << Lstart << " " << Rend << endl;
    //cout << "countRL countLR " << countRL << " " << countLR << endl;
    //cout << "first happy = " << happy << endl;

    int countRL2 = countRL - (int) (Lstart+Rend)/2;

    happy += 2*min(K,countRL2-1);
    if( !(Lstart || Rend) ){
        if( K>=countRL ){
            happy++;
        }
    }else{
        if(K>=countRL-1 && (Lstart && Rend)){
            happy++;
        }
    }

    cout << happy << endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<int>B(N);
    for (int i = 0; i < N; ++i) cin >> B[i];

    // 1. 条件を満たす並び替えが唯一つ存在するかどうかの判定
    vector<int>AC(A);
    vector<int>BC(B);
    sort(AC.begin(), AC.end());
    sort(BC.begin(), BC.end());

    // 1-1. 存在しない場合
    for (int i = 0; i < N; ++i) {
        if(AC[i] > BC[i]){
            cout << "No" << "\n";
            return 0;
        }
    }

    // 1-2. 複数存在する場合
    for (int i = 0; i < N-1; ++i) {
        if(BC[i] >= AC[i+1]){
            cout << "Yes" << "\n";
            return 0;
        }
    }

    // 2. 唯一つ存在する場合, それを実現するのが長さNの巡回置換であるか判定
    map<int, int> mpA; // ソート前のAから同じindexのBへの写像
    map<int, int> mpB; // ソート後のBから対応するAの値への写像
    for (int i = 0; i < N; ++i) {
        mpA[A[i]] = B[i];
        mpB[BC[i]] = AC[i];
    }
    int cur = BC[0];
    cur = mpB[cur];
    cur = mpA[cur];
    int cnt = 1;
    while (cur != BC[0]) {
        cur = mpB[cur];
        cur = mpA[cur];
        cnt++;
    }
    if(cnt == N){
        cout << "No" << "\n";
    } else {
        cout << "Yes" << "\n";
    }
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a, b;
    while(cin >> a >> b)
    {
        ll ans, cnt = 0;
        ans = a+b;
        while(ans)
        {
            ans /= 10;
            cnt++;
        }
        cout << cnt << "\n";
    }
    return 0 ;
}



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

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

    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (a == b and b == c) {
        cout << -1 << endl;
        return 0;
    }

    int tmp_a, tmp_b, cnt = 0;
    while (1) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
        tmp_a = b / 2 + c / 2;
        tmp_b = a / 2 + c / 2;
        c = a / 2 + b / 2;
        a = tmp_a;
        b = tmp_b;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3596
#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 EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
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) {
    int N, K, S;
    cin >> N >> K >> S;

    const int cnt = N - K + 1;

    if (S - cnt + 1 > 0) {
        REP(i, N) {
            printf("%d%c", (i % cnt == 0 ? S - cnt + 1 : 1), (i + 1 == N ? '\n' : ' '));
        }
        return 0;
    }

    REP(i, N) {
        printf("%d%c", (i < K ? S : S == INF ? S - 1 : S + 1), (i + 1 == N ? '\n' : ' '));
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const int INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100],dp1[500][500],dp2[500][500];
char field[100][100];

int main(){
  cin >> s >> t;
  string p = "";
  int x = 0,y = 0;
  rep(i,0,s.sz+t.sz){
    if(i % 2 == 0){
      if(x >= s.sz)continue;
      p += s[x++];
    }else{
      if(y >= t.sz)continue;
      p += t[y++];
    }
  }
  print(p);
  return 0;
}

Measured memory_bytes: 256
import heapq

v, e, r = map(int, input().split()) #頂点の数、辺の数、始点
edges = [[] for _ in range(v)] #始点別、終点、コスト
for i in range(e):
    s, t, d = map(int, input().split())
    edges[s].append([t,d])

def dijkstra(edges, start, num_v):
    dist = [float('INF')]*num_v #各点までの最短距離リスト、初期値無限大
    dist[start] = 0 #始点までの距離 = 0
    q = []
    heapq.heappush(q, [0,start])
    
    while q:
        _, u = heapq.heappop(q)
        for i in edges[u]:
            if dist[i[0]] > dist[u] + i[1]:
                dist[i[0]] = dist[u] + i[1]
                heapq.heappush(q, [dist[u] + i[1], i[0]])
    return dist

res = dijkstra(edges, r, v)
for i in range(v):
    if res[i] == float('inf'):
        print('INF')
    else:
        print(res[i])


Measured memory_bytes: 99272
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  // a1 > a2 < a3 > a4
  // a1 - (a2)*2 + (a3)*2 - a4
  // n:偶 n/2-1個2倍+ n/2-1個2倍- 1個1倍+ 1個1倍-
  // n:奇
  //      n/2-1個2倍+ n/2個2倍- 2個1倍+ or
  //      n/2個2倍+ n/2-1個2倍- 2個1倍-

  int n;
  rd(n);
  auto a = new long[](n);
  foreach (i; 0 .. n)
    rd(a[i]);

  sort(a);
  reverse(a);
  long mx = 0;
  if (n & 1) {
    long sub1 = 0;
    foreach (i; 0 .. n) {
      if (i < n / 2 - 1) {
        sub1 += a[i] * 2;
      } else if (i < n / 2 + 1) {
        sub1 += a[i];
      } else {
        sub1 -= a[i] * 2;
      }
    }
    long sub2 = 0;
    foreach (i; 0 .. n) {
      if (i < n / 2) {
        sub2 += a[i] * 2;
      } else if (i < n / 2 + 2) {
        sub2 -= a[i];
      } else {
        sub2 -= a[i] * 2;
      }
    }
    mx = max(sub1, sub2);
  } else {
    foreach (i; 0 .. n) {
      if (i < n / 2 - 1) {
        mx += a[i] * 2;
      } else if (i == n / 2 - 1) {
        mx += a[i];
      } else if (i == n / 2) {
        mx -= a[i];
      } else {
        mx -= a[i] * 2;
      }
    }
  }
  writeln(mx);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	string s;
	string res;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		res += s[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ll int n,k,sum=0,summ=0;
    cin>>n>>k;
    ll int arr[n],b[n];
    for(ll int i=0;i<n;i++)
    cin>>arr[i];
    long double m=0,max=0;
    for(int i=0;i<n;i++)
    {
        sum+=arr[i];
        b[i]=sum;
    }
    max=(b[k-1]+k)/2.0;
    for(ll int i=1;i<=n-k;i++)
    {
        summ=b[k+i-1]-b[i-1];
        m=(summ+k)/2.0;
        if(m>=max)
        max=m;
    }
    cout<<fixed<<setprecision(10)<<max;
    
    
    
    return 0;
}


    
    
    
    
    
    
    
    

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

bool compare(tuple<string, int, int> left, tuple<string, int,int> right){
    if(get<0>(left) != get<0>(right)){
        return get<0>(left) < get<0>(right);
    }else{
        return get<1>(left) > get<1>(right);
    }
}
int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int a, b;
    cin >> a >> b;
    if(a>=13){
        cout << b << endl;
    }else if(6<=a && a<=12){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;
const int INF = 999999999;
int dist[500][500];

int main()
{
	int n,m;
	while(cin>>n>>m, n || m){
		map<string,int> id;
		int k=0;
		string s,p,g; cin>>s>>p>>g;
		if(!id.count(s))id[s]=k++;
		if(!id.count(p))id[p]=k++;
		if(!id.count(g))id[g]=k++;
		
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				dist[i][j]=INF;
			}
			dist[i][i] = 0;
		}
		
		for(int i = 0; i < m; ++i)
		{
			string a,b; int d,t;
			cin>>a>>b>>d>>t;
			if(!id.count(a))id[a]=k++;
			if(!id.count(b))id[b]=k++;
			dist[id[a]][id[b]]=dist[id[b]][id[a]]=d/40+t;
		}
		for(int k = 0; k < n; ++k)
		{
			for(int i = 0; i < n; ++i)
			{
				for(int j = 0; j < n; ++j)
				{
					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
				}
			}
		}
		cout<<dist[id[s]][id[p]]+dist[id[p]][id[g]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i!=n;i++)

using namespace std;


int main(void){
    long long n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    n/=2;
    long long five=0;
    long long a=5;
    while(a<=n){
        five+=n/a;
        a*=5;
    }
    cout << five << endl;
}


Measured memory_bytes: 256
import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0 and k%2 ==1 :
  if zero >= 1:
    ans = 0
  else:
    minus.sort(reverse=True)
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2 == 1:
    ans *= plus[0]
    q = 1
  judge = []
  for i in range((P-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(M//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  map<ll,ll> m;
  rep(i,n){
    auto x=prime_factor(a[i]);
    for(auto e: x){
      if(m[e.first]<e.second) m[e.first]=e.second;
    }
  }
  ll mul=1;
  for(auto e: m){
    mul*=modpow(e.first,e.second);
    mul%=MOD;
  }
  
  ll ans=0;
  rep(i,n){
    ans+=mul*modpow(a[i],MOD-2);
    ans%=MOD;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e9;
 
typedef long long ll;
typedef long double ld;

ll binpow(ll a, ll b, ll m) 
{
    a %= m;
    ll res = 1;
    while (b > 0) 
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll invv(ll x)
{
	return binpow(x, MOD-2, MOD);
}
void test_case()
{
	ll n;
	cin >> n;
	ll fact[n+1], inv[n+1];
	fact[0] = inv[0] = 1;
	for(ll i = 1; i <= n; i++)
	{
		fact[i] = fact[i-1] * i % MOD;
		inv[i] = invv(fact[i]);
	}
	ll ans = 0;
	for(ll i = 2; i <= n; i+= 2)
	{
		ll res = fact[n] * inv[i] % MOD * inv[n - i] % MOD;
		res = res * binpow(9, n-i, MOD) % MOD;
		ans = (ans + res) % MOD;
	}
	ans = ans * 2ll % MOD;
	cout << ans << '\n';

	
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 19140
import sys
N, M = map(int, input().split())

MOD = 1000000007

def fib(n):
    dp_list = [0] * n
    dp_list[0] = 1
    if n == 1:
        return 1
    dp_list[1] = 2
    
    for i in range(2, n):
        dp_list[i] = dp_list[i - 1] + dp_list[i - 2]
    return dp_list[n - 1]

if M == 0:
    print(fib(N) % MOD)
    sys.exit()

a_list = [0] * M

for m in range(M):
    a_list[m] = int(input())

for m in range(M - 1):
    if a_list[m] + 1 == a_list[m + 1]:
        print(0)
        sys.exit()
    else:
        continue

range_list = [i for i in range(1, N + 1)]
new_list = [0] * (M + 1)


new_list[0] = [0] + range_list[0: a_list[0] - 1]
new_list[M] = range_list[a_list[M - 1]:]

if M - 1 >= 1:
    for m in range(1, M):
        new_list[m] = range_list[a_list[m - 1]: a_list[m] - 1]

count = 1
for item in new_list:
    if not item or len(item) == 1:
        continue
    else:
        count *= (fib(len(item) - 1) % MOD)
        count %= MOD
        #print(count)
print(count)

Measured memory_bytes: 460020
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();
		int h = sc.nextInt();
		int c =2;
		System.out.println((a+b)*h/2);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int ans = 0;
	forn1(i,n)
	{
		int p; cin>>p;
		if(i&1 && p&1) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
 
int A = 0;
int d;
short ng = 0;
 
int main(){
    scanf("%d", &A);
    int ward = 0;
    int back = 0;
    int i = -1;
    while(++i < A){
        scanf("%d", &d);
        if( ng ) continue;
        if( ward < i ){
            ng = 1;
        }
        if( ward < i + d / 10){
            ward = i + d / 10;
        }
        if( back >= i - d / 10 ){
            back = i;
        }
    }
 
    if(back != A-1){
        ng = 1;
    }
 
 
    if(ng){
        printf("no\n");
    }else{
        printf("yes\n");
    }
 
    return 0;
}



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

typedef long long ll;

int main(void){
    ll n, m;
    cin >> n >> m;
    vector<ll> sum(n+1);
    sum.at(0) = 0;
    for(int i=1; i<=n; i++){
        ll x;
        cin >> x;
        sum.at(i) = x + sum.at(i-1);
    }

    map<ll,ll> mp;
    for(int i=0; i<=n; i++){
        mp[sum.at(i)%m]++;
    }

    ll ans = 0;
    auto itr = mp.begin();
    while(itr != mp.end()){
        ll x = itr->second;
        ans += x*(x-1)/2;
        itr++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
Y, X = [A[0]], [A[-1]]
for i in range(1, N-1):
    if A[i] >= 0:
        Y.append(A[i])
    else:
        X.append(A[i])
res = []

for i in range(len(Y)-1,0,-1) :
    res.append([X[-1],Y[i]])
    X[-1] -= Y[i]

for i in range(len(X)-1,-1,-1) :
    res.append([Y[0],X[i]])
    Y[0] -= X[i]

print(Y[0])
for r in res :
    print(*r)


Measured memory_bytes: 23336
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, K, T, U, V, L;
    scanf("%d%d%d%d%d%d", &n, &K, &T, &U, &V, &L);
    bool exist[L];
    memset(exist, false, sizeof(exist));
    rep(i, n){
        int d;
        scanf("%d", &d);
        exist[d] = true;
    }

    int have = 0, rest = 0;
    double ans = 0;
    rep(i, L){
        if(rest == i) rest = 0;
        have += exist[i];
        if(have > K || (rest == 0 && have > 0)){
            --have;
            rest = i + T * V;
            ans += 1.0 / V;
        }
        else{
            if(rest == i) rest = 0;
            ans += 1.0 / (rest ? V : U);
        }
    }
    printf("%.10lf\n", ans);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

int main(){
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX_N 100001
 
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
 
void quick_sort(int *begin, int *end) {
  int n = end - begin;
  int p, i;
  if(n < 1) return;
  swap(begin, begin+rand()%n);
  p = 0;
  for(i = 1; i < n; ++i) {
    if(begin[i] < begin[0]) {
      ++p;
      swap(begin+p,begin+i);
    }
  }
  swap(begin+p, begin);
  quick_sort(begin,begin+p);
  quick_sort(begin+p+1,end);
}
 
int binarry_search(int *begin, int *end, int value) {
  int l, r, m;
  l = 0;
  r = end-begin;
  while(l < r) {
    m = (l+r)/2;
    if(begin[m] == value)
      return 1;
    else if(begin[m] < value) 
      l = m+1;
    else
      r = m;
  }
  return 0;
}
 
int main() {
  int n, q, S[MAX_N], t, num;
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", S+i);
  }
  quick_sort(S,S+n);
  num = 0;
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &t);
    if(binarry_search(S,S+n,t)) ++num;
  }
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)

LL z[N];
map<LL,int>mp;
void add(int x){
	while(x<=N){
		z[x]++;
		x+=x&-x;
	}
}
LL get(int x){
	int s=0;
	while(x)s+=z[x],x-=x&-x;
	return s;
		
}


LL n,k,a[N],s[N],d[N],p[N],b[N];
int get_num(LL x){
	return mp[x]?mp[x]:mp[x]=SZ(mp);
}
int main(){Accel
	cin>>n>>k;
	
	FOR(i,1,n){ 
		cin>>a[i];
		s[i]=s[i-1]+a[i];
		p[i]=d[i]=s[i]-k*i;
	}
	
	sort(p+1,p+n+1);
	int cur=1;
	FOR(i,1,n){
		if(i>1&&p[i]!=p[i-1])cur++;
		mp[p[i]]=cur;
	}
	FOR(i,1,n)
		b[i]=mp[d[i]];

	//FOR(i,1,n)cout<<b[i]<<" ";cout<<endl;


	LL ans=0;
	FOR(i,1,n){
		ans+=get(b[i]);
		add(b[i]);
		ans+=p[i]>=0;
	}
	cout<<ans<<endl;
	

}

/*
4 6
1
1
2
3
*/




Measured memory_bytes: 36864
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n);  // 辺の重みがすべて1のグラフ
    rep(i, m) {
        ll x, y, z;
        cin >> x >> y >> z;
        x--;  y--;
        G[x].pb(y);
        G[y].pb(x);
    }

    // BFS。計算量はO(V+E)
    vl dist(n, -1);  // dist[v] : 頂点svから頂点vへの最短距離(-1のとき未訪問)
    queue<ll> Q;
    ll renketuseibun = 0;  // 連結成分の個数
    rep(v1, n) {
        if(dist[v1] == -1) {
            dist[v1] = 0;
            Q.push(v1);
            while(!Q.empty()) {
                ll v = Q.front();
                Q.pop();
                for(auto u : G[v]) {
                    if(dist[u] == -1) {
                        dist[u] = dist[v] + 1;
                        Q.push(u);
                    }
                }
            }
            renketuseibun++;
        } 
    }
    
    out(renketuseibun);
    re0;
}

Measured memory_bytes: 8052
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = Hash.new(0)
c = []
ans = 0
for i in 1..n-1
  a[i] += a[i-1]
end
for i in 0..n-1
  b[a[i]] += 1
end
b[0] += 1
c = b.values
c.each do |i|
  ans += (i*(i-1))/2
end
puts ans

Measured memory_bytes: 32644
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	H, W, K = MAP()
	S = np.array([list(map(int, list(input()))) for _ in range(H)])

	ans = INF
	for x in product([0, 1], repeat=H-1):
		cut = np.sum(x)
		if cut >= ans:
				continue
		r = 0
		l = []
		for i in range(H-1):
			if x[i]:
				l.append(np.sum(S[r:i+1, :], axis=0))
				r = i + 1
		l.append(np.sum(S[r:, :], axis=0))
		l = np.array(l)
		if np.max(l) > K:
			continue
		tmp = np.zeros(len(l), dtype=int)
		for i in range(W):
			tmp += l[:, i]
			if np.max(tmp) > K:
				cut += 1
				tmp = l[:, i]
			if cut >= ans:
				break

		ans = ans if ans <= cut else cut

	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 15328
# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # return [all roots]
    # O(n)
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # return the number of groups
    # O(n)
    def group_count(self):
        return len(self.roots())

from sys import stdin
input = stdin.buffer.readline

def main():
    n, m = map(int, input().split())

    uf = UnionFind(n)
    for _ in range(m):
        x, y, z = map(int, input().split())
        uf.union(x-1, y-1)

    print(uf.group_count())

main()

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 5e5 + 10;

int n;
string s;
int bit[N][26];

void upd(int pos, int a, int add){
    while (pos < N){
        bit[pos][a] += add;
        pos = pos + (pos & (-pos));
    }
}

int ask(int b, int a){
    int temp[26];
    fill(temp, temp + 26, 0);
    b--;
    while (a > 0){
        for (int i=0;i<26;i++){
            temp[i] += bit[a][i];
        }
        a = a - (a & (-a));
    }
    while (b > 0){
        for (int i=0;i<26;i++){
            temp[i] -= bit[b][i];
        }
        b = b - (b & (-b));
    }
    int ret = 0;
    for (int i=0;i<26;i++) if (temp[i]) ret++;
    return ret;
}

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

    cin >> n;
    cin >> s;
    for (int i=0;i<n;i++){
        int dig = (int)s[i] - (int)'a';
        upd(i + 1, dig, 1);
    }

    int q;
    cin >> q;
    while (q--){
        int tipe;
        cin >> tipe;
        if (tipe == 1){
            int pos;
            char c;
            cin >> pos >> c;
            int dig = (int)c - (int)'a';
            int pref = (int)s[pos - 1] - (int)'a';
            s[pos - 1] = c;
            upd(pos, pref, -1);
            upd(pos, dig, 1);
        } else{
            int l, r;
            cin >> l >> r;
            cout << ask(l, r) << el;
        }
    }

    return 0;
}

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

int main(){
    int N,X,ans;
    cin >> N >> X;
    vector<int> L(N),D(N+1);
    D[0] = 0;
    ans = 0;
    rep(i,N) cin >> L[i];
    for (int i = 1; i < N+1; i++) D[i] = D[i-1] + L[i-1];
    rep(i,N+1) (D[i] <= X) && ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
ls = list(map(int, input().split()))
ls2 = []

for i in range(m):
    if ls[i] < x:
        ls2 += [ls[i]]
    else:
        break

ls1 = list(set(ls) - set(ls2))
len1 = len(ls1)
len2 = len(ls2)
if len1 <= len2:
    print(len1)
else:
    print(len2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;
const int MAX=1e5;
vector<bool> isPrime(MAX+1,false);
void piyo(){
    isPrime[2]=true;
    for(int i=3;i<=MAX;i++){
        int ic=i;
        for(int j=2;j<=sqrt(i);j++){
            while(ic%j==0)ic/=j;
        }
        if(ic==i)isPrime[i]=true;
    }
}
vector<bool> isNear2017(MAX+1,false);
void piyo2(){
    for(int i=3;i<=MAX;i++){
        if(i%2==1&&isPrime[i]&&isPrime[(i+1)/2]) isNear2017[i]=true;
    }
}
vector<int> kosuu(MAX+1,0);
void piyo3(){
    for(int i=3;i<=MAX;i++){
        kosuu[i]=kosuu[i-1];
        if(isNear2017[i])kosuu[i]++;
    }
}

signed main(){
    piyo();
    piyo2();
    piyo3();
    int Q;cin>>Q;
    REP(i,Q){
        int l,r;cin>>l>>r;
        cout<<kosuu[r]-kosuu[l-1]<<endl;
    }
}


Measured memory_bytes: 1408
a,b=map(int,input().split())
ans=[]
for i in range(100):
    if i<50:
        ans.append(["#"]*100)
    else:
        ans.append(["."]*100)

for i in range(0,49,2):
    for j in range(0,100,2):
        if a==1:
            break
        ans[i][j]="."
        a-=1
    if a==1:
        break

for i in range(51,100,2):
    for j in range(0,100,2):
        if b==1:
            break
        ans[i][j]="#"
        b-=1
    if b==1:
        break
print(100,100)
for i in ans:
    print("".join(i))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll MOD=998244353;
  ll n,m,k;
  cin>>n>>m>>k;
  if(n==1){
    cout<<m<<endl;
    return 0;
  }
  if(m==1 and k!=n-1){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  ll pow[n+1];
  ll factorial[n+1];
  pow[0]=1;factorial[0]=1;
  for(int i=1;i<=n;i++){
    pow[i]=mod(pow[i-1]*(m-1),MOD);
    factorial[i]=mod(factorial[i-1]*i,MOD);
    //cout<<pow[i]<<' '<<factorial[i]<<endl;
  }
  //cout<<factorial[n]<<endl;;
  ll inv[n+1];
  inv[n]=modpow(factorial[n],MOD-2,MOD);
  ll invs=inv[n];
  for(int i=n-1;i>=0;i--){
    invs*=i+1;
    invs%=MOD;
    inv[i]=invs;
    //cout<<inv[i]<<endl;
  }
  for(int i=0;i<=k;i++){
    //cout<<factorial[n-1]<<endl;
    //cout<<inv[i]<<' '<<inv[n-1-i]<<endl;
    //cout<<mod(mod(factorial[n-1]*mod(inv[i]*inv[n-1-i],MOD),MOD),MOD)<<endl;
    ans+=mod(mod(mod(m*pow[n-1-i],MOD)*factorial[n-1],MOD)*mod(inv[i]*inv[n-1-i],MOD),MOD);
    ans=mod(ans,MOD);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  	int mod = 1000000007;
    int n;
    cin >> n;
    vector<uint64_t> a(n);
  	rep(i,n) cin >> a[i];
    vector<uint64_t>cnt1(60,0);
    for(uint64_t a_i : a){
        int j = 0;
        while(a_i > 0){
            if(a_i%2 == 1) cnt1[j]++;
            a_i /= 2;
            j++;
        }
    }
    vector<uint64_t> ans(60);
    rep(i,60){
        uint64_t cnt1_i = cnt1[i];
        ans[i] = cnt1_i*(n-cnt1_i)%mod;
    }
    uint64_t ANS = 0;
    for(int i = 59; i >= 0; i--){
        ANS = (2*ANS+ans[i])%mod;
    }
    cout << ANS << endl;
}

Measured memory_bytes: 2560
#include <iostream>
typedef long long ll;

#include <set>

using namespace std;

int main(){
  ll x; cin >> x;

  ll ret = (x / 11) * 2;
  ll t = x % 11;
  if(t != 0){
    if(t > 6) ret += 2;
    else ret += 1;
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    ull N, M;
    cin >> N >> M;

    ull x = M / 2;
    if (N >= x) {
        cout << x << endl;
        return 0;
    }

    ull y = N * 2;
    ull z = M - y;

    cout << N + z / 4 << endl;

    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W;
char S[105][105];
int di[2] = {0,1}, dj[2] = {1,0};
bool visited[105][105];
int cnt[105][105];

int main(){
  cin >> H >> W;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }

  priority_queue < pair<int, Pii>, vector<pair <int, Pii> >, greater<pair<int, Pii> > > que;

  if (S[0][0] == '.') que.push({0, {0, 0}});
  else que.push({1, {0, 0}});

  while (!que.empty()){
    pair <int, Pii> Q = que.top(); que.pop();
    if (visited[Q.se.fi][Q.se.se]) continue;
    
    visited[Q.se.fi][Q.se.se] = true;
    cnt[Q.se.fi][Q.se.se] = Q.fi;

    for (int k = 0; k < 2; k++){
      int I = Q.se.fi + di[k], J = Q.se.se + dj[k];
      if (0 <= I && I < H && 0 <= J && J < W){
        if (visited[I][J]) continue;
        if (S[Q.se.fi][Q.se.se] == '.' && S[I][J] == '#') que.push({Q.fi + 1, {I, J}});
        else que.push({Q.fi, {I, J}});
      }
    }
  }
  cout << cnt[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 3688