akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, S, E, cnt, ans;
arr fir, sum, fa, deep, dep, to;
struct
{
	int to, last;
} e[Maxn << 1];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
}
int DFS(int x)
{
	if (x == S)
		to[x] = x;
	for (int next = fir[x], nx; next; next = e[next].last)
	{
		nx = e[next].to;
		if (nx == fa[x])
			continue;
		dep[nx] = dep[x] + 1;
		fa[nx] = x;
		if (DFS(nx))
			to[x] = nx;
		deep[x] = max(deep[x], deep[nx] + 1);
	}
	return to[x];
}
int main()
{
	rg int a, b;
	cin >> n >> S >> E;
	for (int i = 1; i < n; i++)
	{
		a = read();
		b = read();
		con(a, b);
		con(b, a);
	}
	DFS(E);
	while (dep[S] - dep[E] > 2)
	{
		S = fa[S];
		E = to[E];
		ans++;
	}
	ans += dep[S] - dep[E] - 1;
	cout << ans + deep[S] << '\n';
	return 0;
}

Measured memory_bytes: 7552
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute15_1();
	}
	
	private static void execute15_1() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int [] a = new int[n];
			int max = 1000009;
			
			int[] cannt = new int[max];
			
			for(int i=0;i<max;i++) {
				cannt[i]=0;
			}
			for(int i=0; i<n; i++) {
				 a[i] = sc.nextInt();
				int c = 1;
				if(cannt[a[i]] != 0) {
					cannt[a[i]]++;
					continue;
				}
				while(a[i]*c<max) {
					cannt[a[i]*c]++;
					c++;
				}
			}
			
			int ans =n;
			
			for(int i=0; i<n; i++) {
				if(cannt[a[i]]>0) {
					if(cannt[a[i]]==1) continue;
					ans--;
				}
			}
			
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 53784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	VecS s(n);
	rep(i, n) cin >> s[i];

	ll cnt = 0;
	rep(i, n){
		rep(j, s[i].size() - 1) if (s[i].substr(j, 2) == "AB") ++cnt;
	}
	// co(cnt);

	ll a = 0, b = 0, c = 0;
	rep(i, n){
		if (s[i].front() == 'B') ++b;
		if (s[i].back() == 'A') ++a;
		if (s[i].front() == 'B' || s[i].back() == 'A') ++c;
	}

	// co({a, b, c});
	cnt += min({a, b, max(c - 1, 0LL)});
	co(cnt);

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<deque>//(push/pop)_(front/back)/fornt/back/insert/
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
const long long inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18

#define ll long long
int main(){
vector<int> cnt(50000+5,0);
cnt[1]=1;cnt[2]=1;
for(int i=13;i<100000;i+=12){
    bool flag=1;
  int g=(i+1)/2;
    for (int j=2;j<=sqrt(i);j++){if (i%j==0||(j<g&&g%j==0)){flag=0;break;}}
    if (flag) cnt[i/2]=1;
}
for(int ind=1;ind<=50001;ind++){cnt[ind]+=cnt[ind-1];}int q;cin>>q;
rep(i,q){int l,r;cin>>l>>r;l/=2;r/=2;int ret=cnt[r];
if (l){ret-=cnt[l-1];}print(ret);
}
}

Measured memory_bytes: 768
n = gets.to_i
as = gets.split.map(&:to_i)
avg0 = as.inject(:+) / n
avg1 = avg0 + 1

ans = [0, 0]
as.each do |a|
  ans[0] += (a-avg0)**2
  ans[1] += (a-avg1)**2
end

puts ans.min

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	cout << s[0] << (s.size()-2) << s.back();
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());

  int max = 1000;
  int result = 0;
  for (int i = 0; i < N; i++) {
    if(mochi.at(i) < max) {
      result++;
      max = mochi.at(i);
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split(' ');

            int ans = 0;

            for(int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    ans += int.Parse(array[i]) * int.Parse(array[j]);
                }
            }

            Console.WriteLine(ans);
        }

        

    }
}

Measured memory_bytes: 27532
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int S;

	cin >> S;

	int month = S % 100;
	int year = S / 100;

	if (month == 0 && year > 12 || year == 0 && month > 12)cout << "NA";
	else if (month == 0 && year == 0)cout << "NA";
	else if (month == 0 && year <= 12)cout << "MMYY";
	else if (year == 0 && month <= 12)cout << "YYMM";
	else if (month <= 12 && year <= 12)cout << "AMBIGUOUS";
	else if (month <= 12)cout << "YYMM";
	else if (year <= 12)cout << "MMYY";
	else cout << "NA";
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  ll N;
  cin >> N;
  set<ll> st;

  ll A;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(st.find(A) != st.end()){
      st.erase(A);
    }else{
      st.insert(A);
    }
  }
  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(10000000)


def main():
    N, M = map(int, input().split())
    A = [int(c) for c in input().split()]
    import numpy as np
    sum_ = np.sum(A)
    if N - sum_ < 0:
        print(-1)
    else:
        print(N - sum_)


if __name__ == '__main__':
    main()



Measured memory_bytes: 27372
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->N = $a[0];
    $key->M = $a[1];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->XY[]=$a;
  }
}
$key->R[0]=1;
$key->W[0]=1;
for($i=1;$i<$key->N;$i++) {
  $key->R[$i]=0;
  $key->W[$i]=1;
}
foreach($key->XY as $m) {
$m[0]=$m[0]-1;
$m[1]=$m[1]-1;
  //なくなった
  if (($key->R[$m[0]]==1) && ($key->W[$m[0]] == 1)){
    $key->R[$m[0]]=0;
    $key->R[$m[1]]=1;
    $key->W[$m[0]]-=1;
    $key->W[$m[1]]+=1;
    continue;
  }
  //赤白両方ある
  if (($key->R[$m[0]]==1) && ($key->W[$m[0]] > 1)){
    $key->R[$m[1]]=1;
    $key->W[$m[0]]-=1;
    $key->W[$m[1]]+=1;
    continue;
  }
  //城だけ
  if ($key->R[$m[0]]==0 && $key->W[$m[0]]>0) {
    $key->W[$m[0]]-=1;
    $key->W[$m[1]]+=1;
    continue;
  }
}
$res = 0;
foreach($key->R as $r) {
  if ($r == 1) $res++;
}
printf("%d\n",$res);


Measured memory_bytes: 116216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int N, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    ll sm = 0;
    int x = 0;
    rep(i, 0, N) {
        sm += abs(x - A[i]);
        x = A[i];
    }
    sm += abs(x);

    rep(i, 0, N) {
        int a = 0;
        if (i) a = A[i - 1];

        int b = A[i];

        int c = 0;
        if (i != N - 1) c = A[i + 1];

        ll ans = sm;
        ans -= abs(a - b);
        ans -= abs(b - c);
        ans += abs(a - c);

        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 1664
import sys

import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    x = prime_factorization(N)

    c = collections.Counter(x)

    ans = 0
    for k in c.keys() :
        for i in range(1, 10 ** 5):
            if c[k] >= i:
                c[k] -= i
                ans += 1


    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9468
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>

int main(){
    int  N;
    cin >> N;
    long long int a[N];
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    int ac_res=0;
    for(int i=0; i<N;++i){
        while(a[i]%2==0){
            a[i]=a[i]/2;
            ++ac_res;
        }
        }
    cout << ac_res<<endl;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int gcd(int a,int b){
    if(b!=0){
        return gcd(b,a%b);
    }else{
        return a;
    }
}
int main(){
    int n,x;
    cin >> n >> x;
    vi a(n),b(n);
    rp(i,n){
        cin >> a.at(i);
        b.at(i)=abs(x-a.at(i));
    }
    int ans=b.at(0);
    rp(i,n){
        ans=gcd(ans,b.at(i));
    }
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}
int main(void)
{ 
 ll h, w, k, ans = 0, count=0;
 cin >> h >> w >> k;
 vector<vector<char>> C(h, vector<char>(w));
 RAP(i,h){
   RAP(j,w){
     cin >> C[i][j];
   }
 }
 for(ll i=0;i<(1<<h);i++){
   for(ll j=0;j<(1<<w);j++){
     count = 0;
     RAP(y,h){
       RAP(x,w){
         if((i&(1<<y) || j&(1<<x)) == 0){
           if(C[y][x]=='#'){
             count++;
           }
         }
       }
     }
     if(count == k){
      ans++;
     }
   }
 }
 
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 3612
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}int main() {
    ll M, N, O, P, L;//M->0.25 N->0.5 O->1 P->2
    cin >> M >> N >> O >> P >> L;
    ll cheap = min(min(M * 4, N * 2), O);
    if (cheap * 2 <= P) {
        cout << L * cheap << endl;
    }
    else {
        cout << L / 2 * P + L % 2 * cheap << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  REP(i, H) cin >> a[i];
  set<int> row, col;
  REP(j, W){
    if(a[0][j] == '.'){
      bool f = true;
      REP(i, H) if(a[i][j] == '#') f = false;
      if(f) col.insert(j);
    }
  }
  REP(i, H){
    if(a[i][0] == '.'){
      bool f = true;
      REP(j, W) if(a[i][j] == '#') f = false;
      if(f) row.insert(i);
    }
  }
  vector<string> ans;
  REP(i, H){
    if(row.count(i)) continue;
    string s;
    REP(j, W){
      if(col.count(j)) continue;
      s += a[i][j];
    }
    if(!s.empty()) ans.emplace_back(s);
  }
  REP(i, ans.size()) cout << ans[i] << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.rbegin(), b.rend());
  
  for(int i=0; i<n; i++) {
    if(a[i]<b[0]) cout << b[0] << endl;
    else if(a[i]==b[0]) cout << b[1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main (){
  int N;
  cin >>N;
  ll M=0,A=0,R=0,C=0,H=0;
  ll ans=0;
  string s;
  for(int i=1;i<=N;i++){
    cin >> s;
    if(s[0]=='M')M++;
    if(s[0]=='A')A++;
    if(s[0]=='R')R++;
    if(s[0]=='C')C++;
    if(s[0]=='H')H++;
  }
    ans=(M*A*R)+(M*A*C)+(M*A*H)+(A*R*C)+(A*C*H)+
    (R*C*H)+(M*R*H)+(A*R*H)+(C*H*M)+(C*R*M);
    cout << ans;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
A = [int(i) for i in input().split()]

A.sort()
A = deque(A)

B = sum(abs(a) for a in A)

if A[0] * A[-1] <= 0:
    print(B)
    if A[0] == 0:
        for i in range(n - 1, 1, -1):
            print(A[0], A[i])
            A[0] -= A[-1]
            deque.pop(A)
        print(A[1], A[0])
    elif A[-1] == 0:
        for i in range(n - 1):
            print(A[-1], A[i])
            A[-1] -= A[i]

    else:
        L = A.popleft()
        R = A.pop()
        while A:
            if A[-1] >= 0:
                print(L, A[-1])
                L -= A[-1]
            else:
                print(R, A[-1])
                R -= A[-1]
            A.pop()
        print(R, L)

else:
    if A[0] > 0:
        print(B - A[0] * 2)
        for i in range(n - 1, 1, -1):
            print(A[0], A[i])
            A[0] -= A[-1]
            deque.pop(A)
        print(A[1], A[0])
    else:
        print(B + A[-1] * 2)
        while len(A) != 1:
            print(A[-1], A[0])
            A[-1] -= A.popleft()



Measured memory_bytes: 63060
# https://atcoder.jp/contests/abc149/tasks/abc149_e

# すべての握手の組み合わせN**2を列挙しソートしM番目までを足し合わせればOK
# だけど制約からこれを行うことは困難
# すべてを列挙しなくともM番目の値を知ることは二分探索で可能(参考:億マス計算)
# Aの累積和を保持しておけば、M番目の値の探索中にMまでの値の合計もついでに計算できる
# 以下reverseでソート済みだと仮定
# XがM番目の数→X以上である数はM個以上(cntとする)→cntがM個以上の条件を満たすうちの最大となるXがM番目の値
# そのあと余分な分を引く処理とか必要

from bisect import bisect_right, bisect_left
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


class cumsum1d:
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        # もとの配列lsにおける[i,j)の中合計
        return self.ls_accum[j] - self.ls_accum[i]


N, M = read_ints()
A = read_ints()
A.sort()  # bisectを使う都合上 reverseは抜き
A_reversed = list(reversed(A))
A_rev_acc = cumsum1d(A_reversed)


def is_ok(X):
    # M番目の数はXである→X以上の個数>=M となるうちで最大のX(もっとも左の方のX)
    # X以上の個数>=Mを返す
    # X以下の個数はai+aj>=Xを満たす個数
    cnt = 0
    ans = 0
    for a in A:
        aa = X - a
        idx_reverse = N - bisect_left(A, aa)  # 大きい方からだと何番目か
        # これはbisect_right(A_reversed,aa)に等しい
        cnt += idx_reverse
        ans += A_rev_acc.total(0, idx_reverse) + idx_reverse * a
    return cnt >= M, ans, cnt


def meguru_bisect(ng, ok):
    '''
    define is_okと
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        flg, ans, cnt = is_ok(mid)
        if flg:
            ok = mid
            ans_true = ans  # さいごにokとなる状態がans
            cnt_true = cnt
        else:
            ng = mid
    return ans_true, ok, cnt_true


ans_tmp, M_th_num, M_plus_alpha_th = \
    meguru_bisect(2 * 10 ** 5 + 1, 0)
# print(ans_tmp, M_th_num, M_plus_alpha_th)
print(ans_tmp - (M_plus_alpha_th - M) * M_th_num)


Measured memory_bytes: 60064
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int A,B,val[11][11], mn[11][11];
vector<pair<pi,string>> ed;

void edge(int x, int y, string z) {
    ed.pb({{x,y},z});
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> A >> B;
    FOR(i,1,A+1) FOR(j,1,B+1) {
        cin >> val[i][j];
        mn[i][j] = MOD;
    }
    F0R(i,100) edge(i+1,i+2,"X"); // 1 to 101 
    F0R(i,100) edge(i+102,i+103,"Y"); // 102 to 202
    F0R(x,101) F0R(y,101) {
        int z = 0;
        FOR(i,1,A+1) FOR(j,1,B+1) z = max(z,val[i][j]-x*i-y*j);
        FOR(i,1,A+1) FOR(j,1,B+1) mn[i][j] = min(mn[i][j],z+x*i+y*j);
        edge(1+x,202-y,to_string(z));
    }
    FOR(i,1,A+1) FOR(j,1,B+1) if (mn[i][j] != val[i][j]) {
        cout << "Impossible";
        exit(0);
    }
    cout << "Possible\n";
    cout << "202 " << sz(ed) << "\n";
    for (auto a: ed) cout << a.f.f << " " << a.f.s << " " << a.s << "\n";
    cout << "1 202";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 1020
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t[i] = map(str, input().split())
    t[i] = int(t[i])
x = input()
ans = 0
flag = False
for i, v in zip(s, t):
    if i == x:
        flag = True
        continue
    if flag:
        ans += v
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main() {


	//B
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;

	long long int x[4];
	x[0] = a * c;
	x[1] = a * d;
	x[2] = b * c;
	x[3] = b * d;
	sort(x, x + 4);
	
	/*if (x[0] >= x[1] && x[0] >= x[2] && x[0] >= x[3]) {
		cout << x[0] << endl;
	}
	else if (x[1] >= x[0] && x[1] >= x[2] && x[1] >= x[3]) {
		cout << x[1] << endl;
	}
	else if (x[2] >= x[0] && x[2] >= x[1] && x[2] >= x[3]) {
		cout << x[2] << endl;
	}
	else {
		cout << x[3] << endl;

	}*/
	
	cout << x[3] << endl;

	return 0;
	

	//A
	/*int x;
	cin >> x;
	if (x == 1) {
		cout << 0;
	}
	else {
		cout << 1;
	}
	cout << endl;
	return 0;
	*/

}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main()
{
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if (k <= a){
    cout << k << endl; 
  }else if (k <= a + b){
  	cout << a << endl; 
  }else{
  	cout << a - (k - a - b)  << endl;   
  }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, s, e) for(int i=s; i<e; i++)
#define print(i) cout << i << endl;

int const NMAX = 8;
vector<int> v[NMAX];
int cnt = 0;
int n;
bool used[NMAX];

void dfs(int k, int done, int& cnt){

    // cout << " " << k+1 << " " << done <<  endl;

    done++;
    if(done == n){
        cnt++;
        return;
    }
    
    if(v[k].empty()){
        return;
    }
    else{
        for(auto x : v[k]){
            if(!used[x]){
                // cout << k << "->" << x << endl;
                used[x] = true;
                dfs(x, done, cnt);
                used[x] = false;
            }
        }
    }
}

int main(){

    int m; cin >> n >> m;

    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;

        v[a].push_back(b);
        v[b].push_back(a);
    }

    fill(used, used+NMAX, false);
    used[0] = true;
    dfs(0, 0, cnt);

    cout << cnt;

    return 0;
}

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

int main()
{
    ll N; cin >> N;
    ll tmp = N / 111;
//    cout << tmp << endl;
    if (N % 111) {
        tmp++;
    }
    cout << tmp << tmp << tmp << endl;



}


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

namespace Volume0_0018
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine
            (
                string.Join
                (
                    " ",
                    Console
                        .ReadLine()
                        .Split(' ')
                        .Select(s => Convert.ToInt32(s))
                        .OrderByDescending(i => i)
                        .Select(i => i.ToString())
                        .ToArray()
                )
            );
        }
    }
}

Measured memory_bytes: 10068
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    int n; cin >> n;
    string s; cin >> s;
    if(sz(s) % 2 == 1)  { cout << "No" << endl; return 0; }
    for(int i = 0, j = sz(s)/2; j < sz(s); i++, j++) {
        if(s[i] != s[j]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main()
{
	int A, B;
	char c;
	while(cin >> A >> c >> B && c != '?')
	{
		int ans = 0;
		switch(c)
		{
			case '+':
				ans = A + B;
				break;
			case '-':
				ans = A - B;
				break;
			case '*':
				ans = A * B;
				break;
			case '/':
				ans = A / B;
				break;
		}
		
		cout << ans << endl;
	}

    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'
int n,m;
char ch[1001][1001];
int vis[1001][1001];
int dist[1001][1001];
int a[4]={0,0,1,-1};
int b[4]={1,-1,0,0};
int32_t main()
{
    cin>>n>>m;
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    x1--;
    y1--;
    x2--;
    y2--;
    for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++)
    		cin>>ch[i][j];
    for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++)
    		dist[i][j]=1e9;
    dist[x1][y1]=0;
    set<pair<int,pair<int,int> > > q;
    q.insert({0,{x1,y1}});
    while(!q.empty())
    {
    	pair<int,pair<int,int> > p=*(q.begin());
    	q.erase(q.begin());
    	if(vis[p.second.first][p.second.second])
    		continue;
    	vis[p.second.first][p.second.second]=1;
    	for(int i=0;i<4;i++)
    	{
    		int cx=p.second.first+a[i];
    		int cy=p.second.second+b[i];
    		if(cx<0 || cx>=n || cy<0 || cy>=m)
    			continue;
    		if(ch[cx][cy]=='#')
    			continue;
    		if(dist[cx][cy]>dist[p.second.first][p.second.second])
    		{
    			dist[cx][cy]=dist[p.second.first][p.second.second];
    			q.insert({dist[cx][cy],{cx,cy}});
    		}
    	}
    	int x=p.second.first-2;
    	int y=p.second.second-2;
    	for(int i=x;i<x+5;i++)
    	{
    		for(int j=y;j<y+5;j++)
    		{
    			int cx=i;
	    		int cy=j;
	    		if(cx<0 || cx>=n || cy<0 || cy>=m)
	    			continue;
	    		if(ch[cx][cy]=='#')
	    			continue;
	    		if(dist[cx][cy]>dist[p.second.first][p.second.second]+1)
	    		{
	    			dist[cx][cy]=dist[p.second.first][p.second.second]+1;
	    			q.insert({dist[cx][cy],{cx,cy}});
	    		}
    		}
    	}
    }
    if(dist[x2][y2]==1e9)
    	cout<<-1;
    else
    	cout<<dist[x2][y2];
}   

Measured memory_bytes: 20916
#include <stdio.h>
#include <string.h>

int main(void) {
	char data[80], ser[3][5] = {"the", "this", "that"};
	int hit, count, dlen, slen;
	int i, j;
	
	while (gets(data) != 0) {
		hit = count = 0;
		dlen = strlen(data);
		while (! hit) {
			for (i = 0; i < dlen; i++) {
				for (j = 0; j < 3; j++) {
					slen = strlen(ser[j]);
					if (i <= dlen - slen && strncmp(&data[i], ser[j], slen) == 0) hit = 1;
				}
			}
			if (hit) break;

			for (i = 0; i < dlen; i++) if( data[i] >= 'a' && data[i] <= 'z')
				data[i] = (data[i] - 'a' + 1) % 26 + 'a';

			if( ++count == 26) break;
		}
		printf("%s\n", data);
	}
	return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
using namespace std;

struct state {
	int pos, speed, prev;
	double time;
	state(int p, int pr, int s, double t):pos(p), prev(pr), speed(s), time(t){}
	bool operator>(const state& s) const {
		return time > s.time;
	}
};

struct edge {
	int to, cost, limit;
	edge(int t, int c, int l):to(t), cost(c), limit(l){}
};

vector<vector<edge> > es;

double dijkstra(int s, int t) {
	priority_queue<state, vector<state>, greater<state> > que;
	vector<vector<vector<double> > > dist(es.size(), vector<vector<double> >(es.size(), vector<double>(31, INT_MAX)));
	que.push(state(s, s, 0, 0.0));
	dist[s][s][0] = 0;

	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(dist[s.pos][s.prev][s.speed] < s.time)
			continue;

		if(s.pos == t && s.speed == 1)
			return s.time;

		for(int i = 0; i < es[s.pos].size(); ++i) {
			const edge& e = es[s.pos][i];
			if(e.to == s.prev)
				continue;

			for(int j = max(1, s.speed - 1); j <= min(e.limit, s.speed + 1); ++j) {
				const double tmp = s.time + (double)e.cost / j;
				if(dist[e.to][s.pos][j] > tmp) {
					dist[e.to][s.pos][j] = tmp;
					que.push(state(e.to, s.pos, j, tmp));
				}
			}
		}
	}

	return -1.0;
}


int main() {
	for(int n, m; scanf("%d %d", &n, &m), n;) {
		int s, g;
		scanf("%d %d", &s, &g);

		es.clear();
		es.resize(n);
		for(int i = 0; i < m; ++i) {
			int x, y, d, c;
			scanf("%d %d %d %d", &x, &y, &d, &c);
			es[x - 1].push_back(edge(y - 1, d, c));
			es[y - 1].push_back(edge(x - 1, d, c));
		}

		const double ans = dijkstra(s - 1, g - 1);
		if(ans < 0)
			puts("unreachable");
		else
			printf("%.10lf\n", ans);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1928
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c - (a - b);
    ans = max(0, ans);
    cout << ans << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll s;
int main(){ //srand((unsigned)time(NULL));
  cin >> s;
  ll h,m;
  h = s/3600; s -= h*3600;
  m = s/60; s -= m*60;
  cout << h << ':' << m << ':' << s << endl;
}



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


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

    int n;
    cin >> n;
    int d[n][2];
    rep (i, n) {
        cin >> d[i][0] >> d[i][1];
    }
    rep (i, n-2) {
        if (d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 998244353;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

class mint {
public:
    long long x;
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    //mint operator-() const{ return mint(-x);}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

};

int main(){
  int N, S; cin >> N >> S;
  vector<int> A(N); rep(i, N) cin >> A[i];

  vector<mint> f(S + 1, 0);
  f[0] = 1;
  for (int a: A){
    // f = f * (2 + x^a)
    vector<mint> next(S + 1, 0);
    rep(i, S + 1){
      next[i] += 2 * f[i].x;
      if (i + a <= S) next[i + a] += f[i];
    }
    swap(next, f);
  }
  cout << f[S].x << endl;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}



Measured memory_bytes: 3672
program ARC059C
    implicit none
    integer(8)::N,i,j
    integer(8),allocatable,dimension(:)::A
    integer(8)::result,result_min

    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=minval(A),maxval(A)
        result=0
        do j=1,N
            result=result+(i-A(j))**2
        end do

        if(i==minval(A))then
            result_min=result
        else if(result<result_min)then
            result_min=result
        end if
    end do

    print'(i0)',result_min
    
end program ARC059C

Measured memory_bytes: 256
flag = 1
while flag:
    n,x = map(int,input().split())
    
    if n==0 & x==0:
        flag = 0
    
    else:
        count = 0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i + j+ k == x:
                        count +=1
        print(count)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	ll n, m, t1 = 1900, t2 = 100;
	
	cin>>n>>m;
	
	ll p = 1LL<<m;
	
	///e = m*t1 + (n-m)*t2 + (p-1)/p*e
	ll e = (m*t1 + (n-m)*t2)*p;
	
	cout<<e<<endl;
	
	return 0;
}


Measured memory_bytes: 256
open System

let n = Console.ReadLine() |> int

let testimonies: (int * int) list list =
    [ for i in 1 .. n do
        let a = Console.ReadLine() |> int
        yield [ for j in 1 .. a do
                    let xy = Console.ReadLine().Split(' ') |> Array.map int
                    yield xy.[0] - 1, xy.[1] ] ]

let ans =
    let rec dfs is rest =
        match rest with
        | [] ->
            let set = Set is
            let mutable ok = true

            for i in is do
                for x, y in testimonies.[i] do
                    if y = 0 && set.Contains x then ok <- false
                    elif y = 1 && not (set.Contains x) then ok <- false

            if ok then List.length is else 0
        | i :: rest ->
            max (dfs is rest) (dfs (i :: is) rest)

    dfs [] [ 0 .. n - 1 ]

ans |> Console.WriteLine


Measured memory_bytes: 18500
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    string a;
    int b;
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]=='9'){
            b++;
        }
    }
    if(b>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int rcnt=0, ans=0;
    for(int i=0; i<n; i++){
        if(s[i]=='R') rcnt++;
        else rcnt--;
        if(rcnt==4){
            ans++;
            rcnt=0;
        }
        else if(rcnt==-4){
            rcnt=0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3228