akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

  string result;
  for (int i = 0; i < o.size() + e.size(); ++i) {
    if (i % 2 == 0) {
      result += o[i / 2];
    } else {
      result += e[(i - 1) / 2];
    }
  }

  cout << result << '\n';
  return 0;
}

Measured memory_bytes: 3584
int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A==7&&B==5&&C==5){
  printf("YES");
  }
  else if(A==5&&B==7&&C==5){
  printf("YES");
  }
  else if(A==5&&B==5&&C==7){
  printf("YES");
  }else{
  printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

signed main(){
  int H, W;
  char s[405][405];
  ll g[405][405];
  UnionFind uf(160005);

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

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '.') continue;
      for(int k = 0; k < 4; k++){
	int x = j + dx[k], y =i + dy[k];
	if(0 <= x && x < W && 0 <= y && y < H && s[y][x] == '.'){
	  for(int l = 0; l < 4; l++){
	    int xx = x + dx[l], yy = y + dy[l];
	    if(xx == j && yy == i) continue;
	    if(0 <= xx && xx < W && 0 <= yy && yy < H && s[yy][xx] == '#'){
	      uf.unite(i*W+j, yy*W+xx);
	    }
	  }
	}
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '.') continue;
      for(int k = 0; k < 4; k++){
	int x = j + dx[k], y = i + dy[k];
	if(0 <= x && x < W && 0 <= y && y < H && s[y][x] == '.'){
	  ll cnt = uf.size(i * W + j);
	  // cerr << cnt << endl;
	  g[y][x] = max(g[y][x], cnt);	  
	}
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans += g[i][j];
      // cerr << g[i][j];
    }// cerr <<endl;
  }
  cout << ans << endl;
  return 0;
}

/*

4 4
....
.#.#
....
...#

*/


Measured memory_bytes: 2304
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;

int n;
int a[MAXN];

int main()
{
	
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	int cnt = n, ans = 0;
	for (int i = 2; i <= n; ++ i)
	{
		if (a[i] == a[i-1])
		{
			ans ++;
			a[i] = ++ cnt;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
extern crate proconio;
use proconio::fastout;
use proconio::marker::Usize1;

#[fastout]
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        h: [u32; n],
        ab: [(Usize1, Usize1); m],
    }
    let mut ans = vec![true; n];
    for (a, b) in ab {
        if h[a] <= h[b] {
            ans[a] = false;
        }
        if h[a] >= h[b] {
            ans[b] = false;
        }
    }
    println!("{}", ans.into_iter().filter(|&x| x).count());
}


Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;


char mat[300][300];
int n, m;

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


int main() {
	io;
	cin >> n >> m;
	bool ok = 1;
	loop(i, 0, n - 1)
		loop(j, 0, m - 1) {
			cin >> mat[i][j];
 	}
	loop(i, 0, n - 1)
		loop(j, 0, m - 1) {
		if (mat[i][j] == '#') {
				bool ok = 0;
				loop(x, 0, 3) {
					int nx = i + dx[x];
					int ny = j + dy[x];
					if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
					if (mat[nx][ny] == '#') ok = 1;
				}
				if (!ok) {
					cout << "No";
					return 0;
				}
			}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 838627288460106
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
  fast_io
    ll a,b,j;
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t)
    cout<<"Yes"<<endl;

   else  cout<<"No"<<endl;
    return 0;
}





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

int main() {
    int N, W, v[110], w[110], dp[110][11000] = {};
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> v[i] >> w[i];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j < w[i]) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;
    
    return 0;
}


Measured memory_bytes: 7860
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log,pi #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    R=I()
    print(pi*R*2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 83572
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

// for (int i = 0; i < l.size(); i++) {
    //     for (int j = 0; j < l.size(); j++) {
    //         for (int k = 0; k < l.size(); k++) {
    //             int disA, disB, disC;
    //             if (i == j || j == k || k == i) continue;
    //             else {
    //                 disA = abs(A-l[i]);
    //                 disB = abs(B-l[j]);
    //                 disC = abs(C-l[k]);
    //                 DIS = min(DIS, disA+disB+disC);
    //             }
    //         }
    //     }
    // }

int main() {
    int N;
    cin >> N;
    vector<int> ABC(3);
    for (int i = 0; i < 3; i++) {
        cin >> ABC[i];
    }
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    //全ての竹に対して，Aに使うかBに使うかCに使うか使わないかの四分岐
    //4進数のbit演算，2ビットを使ってやる

    int ans = INF;

    for (int bit = 0; bit < (1 << (2*N)); bit++) {
        vector<vector<int>> vec(4); 
        vector<int> cost(3); // A, B, Cに関するコスト

        for (int i = 0; i < N; i++) {
            vec[(bit >> (2*i)) & 3].push_back(l[i]);
        }

        //vec[i]のサイズが0の時continue
        bool ok = true;
        for (int i = 0; i < 3; i++) {
            if (vec[i].size() == 0) ok = false;
        }
        if (!(ok)) continue;

        //cost計算
        for (int i = 0; i < 3; i++) {
            cost[i] += 10 * (vec[i].size()-1);
            cost[i] += abs(ABC[i] - accumulate(vec[i].begin(), vec[i].end(), 0));
        }

        ans = min(ans, accumulate(cost.begin(), cost.end(), 0));
    }

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

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

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

    int k=2;
    while(k*(k-1)/2 < n) k++;
    if(k*(k-1)/2 != n){
        cout << "No" << endl;
        return 0;
    }

    int a[500][500];
    int b[500];
    for(int i=1; i<=k; i++)b[i]=0;
    int x=1;
    for(int i=1; i<=k; i++){
        for(int j=i+1; j<=k; j++){
            a[i][b[i]]=x;
            b[i]++;
            a[j][b[j]]=x;
            b[j]++;
            x++;
        }
    }

    cout << "Yes" << endl;
    cout << k << endl;

    for(int i=1; i<=k; i++){
        cout << k-1 << " ";
        for(int j=0; j<k-1; j++){
            cout << a[i][j];
            if(j==k-2) cout << endl;
            else cout << " ";
        }
    }
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	


	void solve(){


		ins(morty);
		int tmp = morty[morty.size()-1]-'0';
		if(tmp == 2 or tmp == 4 or tmp == 5 or tmp == 7 or tmp == 9)out("hon");
		else if(tmp == 3 )out("bon");
		else out("pon");
		






	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  double h,w,x,y;
  cin >> h >> w >> x >> y;
  printf("%0.9f ", (h*w)/2);
  if(2*x == h && 2*y == w){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int  a,b,c;
int main() {
cin>>a>>b>>c;
if(b-c<=a&&b-c>=-a)cout<<0<<endl; else 
if(b-c>0)cout<<b-c-a<<endl;else cout<<c-b-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
	char tango[1001];
	gets(tango);
	for (int i=0;;i++){
		if (tango[i]=='\0'){
			if (tango[i-1]=='s'){
				printf("%c",'e');
				printf("%c",'s');
			}else printf("%c",'s');
			break;
		}
		printf("%c",tango[i]);
	}
	return 0;
}

Measured memory_bytes: 1532
#include <stdio.h>
#include <string.h>
char s[200005];
int main()
{
    gets(s);
    int len = strlen(s);
    int a,b;
    for(int i = 0 ; i < len ; i++)
    {
        if(s[i] == 'A')
        {
            a = i+1;
            break;
        }
    }
    for(int i = len - 1 ; i >= 0 ; i--)
    {
        if(s[i] == 'Z')
        {
            b = i + 1;
            break;
        }
    }
    printf("%d",b-a+1);
    return 0;
}

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

using namespace std;

int main(){
  int a[3],m;

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

  m=max(max(a[0],a[1]),a[2]);

  cout << a[0]+a[1]+a[2]-m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MOD 1000000007 
                                 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

 
int main() {
   
    fastio;
    ll s;
    cin >> s;
    ll dp[s/3+1][s+1];
    int n = s/3+1;
    rep(i, n)
    {
        rep(j, s+1)
        dp[i][j] = 0;
    }
    for(int j=3;j<=s;j++)
        dp[1][j] = 1;
    for(int i=1;i<n-1;i++)
    {
        for(int j=3;j<=s;j++)
        {
            dp[i+1][j] = 0;
            for(int k=j-3;k>=3*i;k--)
            {
                dp[i+1][j] += dp[i][k];
                dp[i+1][j] %= MOD;
            }
        }
    }
    ll ans = 0;
    for(int i=1;i<n;i++)
    {
        ans += dp[i][s];
        ans %= MOD;
    }
    cout << ans;
 
    return 0; 
}

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

using namespace std;

int main() {
    int x;
    cin >> x;
    if (x >= 400 && x<= 599) {
      cout << "8" << endl;
    }
    if (x >= 600 && x<= 799) {
      cout << "7" << endl;
    }
    if (x >= 800 && x<= 999) {
      cout << "6" << endl;
    }
    if (x >= 1000 && x<= 1199) {
      cout << "5" << endl;
    }
    if (x >= 1200 && x<= 1399) {
      cout << "4" << endl;
    }
    if (x >= 1400 && x<= 1599) {
      cout << "3" << endl;
    }
    if (x >= 1600 && x<= 1799) {
      cout << "2" << endl;
    }
    if (x >= 1800 && x<= 1999) {
      cout << "1" << endl;
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  if(s == "Sunny")
    cout << "Cloudy" << endl;
  else if(s == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long double LD;
typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, nfc = 0, fc = 0, ans = 0;
	cin >> n;
	vector<vector<int>> sum(20, vector<int>(20));
	vector<int> two(n), five(n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		bool p = false;
		LL x = 0;
		for (char c : s) {
			if (c == '.') {
				p = true;
			} else {
				x = (x * 10) + c - '0';
				two[i] -= p;
				five[i] -= p;
			}
		}
		while (x % 2 == 0) {
			++two[i];
			x /= 2;
		}
		while (x % 5 == 0) {
			++five[i];
			x /= 5;
		}
		sum[min(two[i], 9) + 10][min(five[i], 9) + 10] += 1;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = -10; j < 10; ++j) {
			for (int k = -10; k < 10; ++k) {
				if (j + two[i] >= 0 && k + five[i] >= 0) {
					ans += sum[j + 10][k + 10];
				}
			}
		}
		ans -= two[i] >= 0 && five[i] >= 0;
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int a_count = 0;
    int b_count = 0;
    string S;
    cin >> S;
    int sum_passes = A + B;
    for (int i=0; i < N; i++) {
        if (S[i] == 'c') {
            cout << "No" << endl;
            continue;
        }

        if (S[i] == 'a') {
            if (a_count + b_count < sum_passes) {
                a_count += 1;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (S[i] == 'b') {
            if (a_count + b_count < sum_passes && b_count < B) {
                b_count += 1;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 896
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct
  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m <> i then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(m); t.node.(m) <- tmp;
        max_heapify m
      end in
    max_heapify 1;
    ret

  let push x t =
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      if i > 1 && M.compare t.node.(parent i) t.node.(i) < 0 then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(parent i); t.node.(parent i) <- tmp;
        doit (parent i)
      end in
    doit t.size
end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = snd x - snd y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  let rec doit () =
    if not (H.empty_p h) then begin
      let (u, x) = H.pop h in
      b.(u) <- true;
      if d.(u) >= -x then duduwa u g.(u);
      doit ()
    end
  and duduwa u = function
    | [] -> ()
    | (v, c) :: tl when b.(v) = true || d.(v) <= d.(u) + c -> duduwa u tl
    | (v, c) :: tl ->
      begin
        d.(v) <- d.(u) + c;
        H.push (v, -d.(v)) h;
        duduwa u tl
      end in
  doit ();
  d

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> exit 1

let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      match List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) with
      | u :: _ :: l -> (g.(u) <- make_pair [] l; read (i + 1))
      | _ -> exit 1
  in read 0;
  Array.iteri (fun i e -> Printf.printf "%d %d\n" i e) (dijkstra g n)

Measured memory_bytes: 5076
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
map<int,int>x;
vector<int>y;
int main(void){
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        x[a]++;
        y.push_back(a);
    }
    for(int i=0;i<n;i++){
        if(x[y[i]]!=y[i]){
            if(x[y[i]]>y[i]){
                ans+=x[y[i]]-y[i];
                
            }else{
                ans+=x[y[i]];
            }
            x[y[i]]=y[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5112
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    int p;
    vector<ll> a(n+1), b(m+1);
    rep(i,n) {
        cin >> p;
        a[i+1] = a[i]+p;
    }
    rep(i,m) {
        cin >> p;
        b[i+1] = b[i]+p;
    }
    int ans = 0;
    rep(i,n+1) {
        ll t = k-a[i];
        if(t < 0) break;
        int pos = upper_bound(b.begin(), b.end(), t) - b.begin() - 1;
        if (pos < 0) pos = 0;
        // cout << i << " " << pos << endl;
        chmax(ans, i+pos);
    }
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<char,int> pci;

string S,ans;
int N,N_;
ll K;
pci seg[800010];
int bit[200010];
const pci INF = mk('z' + 1,200010);

//BIT

void add(int i,int x)
{
    while(i <= N)
    {
        bit[i] += x;
        i += i & -i;
    }
}

int sum(int i)
{
    int ret = 0;
    while(i)
    {
        ret += bit[i];
        i -= i & -i;
    }
    return ret;
}

//SegTree

void init()
{
    N_ = 1;
    while(N >= N_)N_ *= 2;
    for(int i = 0; i < N_ * 2 - 1; i++)seg[i] = INF;
}

pci query(int a,int b,int k = 0,int l = 0,int r = N_)
{
    if(a <= l && r <= b)return seg[k];
    if(b <= l || r <= a)return INF;

    pci ret1 = query(a,b,k * 2 + 1,l,(l + r) / 2);
    pci ret2 = query(a,b,k * 2 + 2,(l + r) / 2,r);
    return min(ret1,ret2);
}

void update(int k,pci x)
{
    k += N_ - 1;
    seg[k] = x;
    while(k)
    {
        k = (k - 1) / 2;
        seg[k] = min(seg[k * 2 + 1],seg[k * 2 + 2]);
    }
}

int main()

{
    cin >> S >> K;
    N = S.size();

    for(int i = 0; i < N; i++)add(i + 1,1);

    init();
    for(int i = 0; i < N; i++)update(i,mk(S[i],i));

    int swapCount = 0;
    while(swapCount < N && K)
    {
        int l = 1,r = N + 1;
        while(r - l > 1)
        {
            int mid = (l + r) / 2;
            if(sum(mid) - 1 <= K)l = mid;
            else r = mid;
        }
        int idx = l;
        pci cmp = query(0,idx);
        swapCount++;
        if(cmp == INF)continue;
        ans += cmp.fi;
        K -= (ll)sum(cmp.se + 1) - 1;
        update(cmp.se,INF);
        add(cmp.se + 1,-1);

    }

    for(int i = 0; i < N; i++)
    {
        pci cmp = query(i,i + 1);
        if(cmp == INF)continue;
        ans += cmp.fi;
    }

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



Measured memory_bytes: 10548
#include <bits/stdc++.h>
 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
#define endll ('\n')
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b <= a + c && a + b <= b + c) {
        cout << a + b << endll;
    } else if (a + b >= a + c && c + b >= a + c) {
        cout << a + c << endll;
    } else {
        cout << b + c << endll;
    }
}

Measured memory_bytes: 3608
import java.util.Scanner;
 
public class Main{
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
        int A = scanner.nextInt();
      if(X<A){
      	System.out.println("0");
      }
      else{
      	System.out.println("10");
      }
    }
}

Measured memory_bytes: 22868
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, Q = sc.nextInt
    val S = sc.next

    var count = 0
    val sums = for (i <- 0 until N) yield {
      if (i == 0) {
        0
      } else if (S(i - 1) == 'A' && S(i) == 'C') {
        count += 1
        count
      } else {
        count
      }
    }

    for (_ <- 0 until Q) {
      val l = sc.nextInt
      val r = sc.nextInt
      println(sums(r - 1) - sums(l - 1))
    }
  }
}

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

using namespace std;

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 3e2 + 20;
ll dp[N][N], C[N][N], p[N][N], n, k, m;

ll sum(int i, int j) {
	return (p[i][k] - p[i][j] + m) % m;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k >> m;
	for (int i = 0; i < N; i++)
		C[0][i] = C[i][i] = 1;
	for (int i = 2; i < N; i++)
		for (int j = 1; j < i; j++)
			C[j][i] = (C[j - 1][i - 1] + C[j][i - 1]) % m;
	for (int i = 0; i <= k; i++)
		dp[1][i] = 1;
	p[1][0] = dp[1][0];
	for (int i = 1; i <= k; i++)
		p[1][i] = (p[1][i - 1] + dp[1][i]) % m;
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= k; j++)
			for (int x = 0; x <= i - 2; x++)
				dp[i][j] = (dp[i][j] + (((dp[i - x - 1][j] * C[x][i - 2]) % m) * sum(x + 1, j)) % m) % m;
		p[i][0] = dp[i][0];
		for (int j = 1; j <= k; j++)
			p[i][j] = (p[i][j - 1] + dp[i][j]) % m;
	}
	cout << dp[n + 1][0] << endl;
}



Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int n, i, min, max, sum, ans, p;

  while(1){
    scanf("%d", &n);
    if(n==0){
      break;
    }
    sum=0;
    for(i=0; i<n; i++){
      scanf("%d", &p);
      sum+=p;
      if(i==0){
	min=max=p;
      }else{
	if(min>p){
	  min=p;
	}
	if(max<p){
	  max=p;
	}
      }
    }
    ans=(sum-max-min)/(n-2);
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main() {
	int h, n;
	int rep = 0;
	cin >> h >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		rep += a[i];
	}
	if (h - rep <= 0) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define inf 1000000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    vector <int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=i-a[i];
        c[i]=i+a[i];
    }
    map <int,int> mp;
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=mp[b[i]];
        mp[c[i]]++;
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 30584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	n := sc.getInt()
	ans := 1000 - (n % 1000)
	if n%1000 == 0 {
		ans = 0
	}
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
n, m = map(int, input().split())

memo = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    if b != 1:
        memo[a].append(b)
    if a != 1:
        memo[b].append(a)
        
signs = [-1] * (n+1)

now = [1]
cnt = 1
while cnt < n:
    next = []
    for j in now:
        roots = memo[j]
        for k in roots:
            if signs[k] == -1:
                signs[k] = j
                next.append(k)
                cnt += 1
    now = next[:]

print("Yes")
for j in range(2, n+1):
    print(signs[j])

Measured memory_bytes: 33896
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
public struct Routes{
  public long cost;
  public long time;
  public Routes(long c, long t){
    cost = c;
    time = t;
  }
}

  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var N = temp.ElementAt(0);
    var T = temp.ElementAt(1);

    var routesList = new List<Routes>();
  
    for(var i = 0; i < N; i++){
      var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
      routesList.Add(new Routes(temp2.ElementAt(0), temp2.ElementAt(1)));
    }

    var okRoutes = routesList.Where(t => t.time <= T);
    
    var ans = okRoutes.Any() ? okRoutes.Select(c => c.cost).Min().ToString() : "TLE";

    Console.WriteLine(ans);
 
  }
  
}

Measured memory_bytes: 11348
#include <cstdio>
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>
using namespace std;
 
long long able[1000000];
 
int main()
{
    int n, m;
    cin >> n >> m;
    int t;
    for (int i = 0; i < m; i++)
    {
        cin >> t;
        able[t] = 1;
    }
 
    long long t1 = 1, t2 = 0;

    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if(able[i] == 1)
        {
            ans = 0;
        }
        else
        {
            ans = t1 + t2;
            ans %= 1000000007;
        }
        t2 = t1;
        t1 = ans;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<stdio.h>
#include <cstdio>
#include <cstring>
#include <string>


using namespace std;

#define ld long double
#define ll long long
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define mem(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int ,int >
#define pll pair<ll ,ll >
#define mp make_pair
#define vi vector<int >
#define vii vector<pii>
#define vvi vector < vi >
#define vll vector < ll >
#define vllll vector < pll >
#define vvll vector < vll >
#define forn(i,n) for(int i=0;i<(n);i++)
#define fori(i,s,e) for(int i=s,i<n;i++)
#define qi  queue <int >
#define qll  queue <ll >
#define in_r(x,y,n,m) (x>=0 && x<n && y>=0 && y<m)
#define maxn 1000009


void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
const double EPS = (1e-8);
const int OO = (int) 1e9 + 7;
const ll OOO = (ll) 1e15 + 7;
double const PI = 3.1415926535897932384626433832795;
const int mxn = 200009;
char c1, c2, c3, c4;
string s, s1, s2, s3;
ll   n, m, k, t, q, a, b, c, d, e, x, y, z; ll sol = 0;






int main(){
	fast();
	
	cin >> k;
	cin >> s;
	n = sz(s);
	if (n <= k) cout << s;
	else{
		cout << s.substr(0, k) << "...";
	}


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


Measured memory_bytes: 3620
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr; typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; } char nextChar(){ char r; ist>>r; return r;} }; Scanner sc(cin);
void ALERT(bool judgememt, const char* phrase) { if (judgememt) { puts(phrase); throw "ALERT"; } }
bool alert(bool judgememt, const char* phrase) { if (judgememt) puts("phrase"); return judgememt; }

const int MOD = 998244353;
const int N = 3005;
int n, s;
int a[N];
int dp[N];

void init() {
    scanf(II,&n,&s);
    rep (i,n) scanf(I,&a[i]);
    memset(dp, 0, sizeof(dp)); dp[0] = 1; 
}

void solve() {
    rep (i,n) repb (j,s,0) (dp[j] = dp[j] * 2 + ((j>=a[i])?dp[j-a[i]]:0)) %= MOD;
    printf(IN,dp[s]);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
#ifndef CUSTOM_MAIN
#ifdef MULTIPLE_TEST_CASES_WITH_T

int T; scanf("%d",&T); while(T--) {init(); solve();}

#else
#ifdef MULTIPLE_TEST_CASES_WITHOUT_T

while(1) {try{init(); } catch(bool t){return 0;} solve(); }

#else

init(); solve();

#endif
#endif
#endif
    return 0;
}



Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h,w;
	string s;
	cin>>h>>w;
	for(int i=0;i<w+2;i++){
		cout<<"#";
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		cout<<"#";
		cin>>s;
		cout<<s<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++){
		cout<<"#";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	long long int n , sum;
	int i;
	while(1){
		sum = 0;
		scanf("%lld" , &n);
		if(n == 0) break;
		for(;n>=5;){
			sum += n / 5;
			n /= 5;
		}
		printf("%d\n" , sum);
	}
return 0;
}

Measured memory_bytes: 0
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        inv%=k
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin >>N>>x;
  vector<int> gaki(N);
  for(int i =0; i<N; i++){
    cin>> gaki.at(i);
  }
  sort(gaki.begin(),gaki.end());
  int count=0;
  for(int i =0; i<N;i++){
    x -= gaki.at(i);
    if(x>=0 && i <N-1){
      count ++;
    }
    else if (i ==N-1 && x==0){
      count ++;
    }
    else{
      break;
    }
  }
  cout << count <<endl;
}

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

int main()
{
    bool overflow = false;
    long long INF = pow(10, 18);
    int N; cin >> N;
    long long A, result = 1;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (A == 0) {cout << 0 << endl; return 0;}
        if (A <= INF / result) result *= A;
        else { overflow = true; }
    }

    if (overflow) cout << -1 << endl;
    else cout << result << endl;
}

Measured memory_bytes: 3636
n,q = map(int, input().split())
s = input()

counts = [1 if s[i:i+2]=="AC" else 0 for i in range(n)]

cum_counts=[0]*n
for i in range(1,n):
  cum_counts[i]=cum_counts[i-1]+counts[i-1]

#print(counts)
#print(cum_counts)

for i in range(q):
  l,r = map(int, input().split())
  print(cum_counts[r-1] - cum_counts[l-1])

Measured memory_bytes: 8556
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.io.Source.stdin

object Main {

  // val solver = (_: List[String]) => ""
  lazy val solver: List[String] => String = agc002b

  def main(args: Array[String]): Unit = {
    val ans = solver(read())
    println(ans)
  }

  def read(): List[String] = {
    stdin.getLines().toList
  }

  val agc002b: List[String] => String = (args: List[String]) => {
    val opList = args.drop(1).map(op => op.split(" ").map(x => x.toInt))
    val set = mutable.Set(1)
    val cntArray = {
      val tmp = ArrayBuffer[Int]()
      tmp ++= (0 to 100000).map(_ => 1)
      tmp
    }

    for (op <- opList) {
      val from = op(0)
      val to = op(1)
      cntArray(from) -= 1
      cntArray(to) += 1
      if (set.contains(from)) {
        set += to
        if (cntArray(from) == 0) {
          set -= from
        }
      }
    }

    set.size.toString
  }
}


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

using namespace std;

const int mod = 1e9 + 7;

int mul(int a,int b)
{
    return (long long) a * b % mod;
}

int my_pow(int a,int b)
{
    int res = 1;
    while(b)
    {
        if(b % 2 == 0)
        {
            b /= 2;
            a = mul(a,a);
        }
        else
        {
            b--;
            res = mul(a,res);
        }    
    }

    return res;
}

int my_inv(int a)
{
    return my_pow(a,mod-2);
}

int main()
{  
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }

    
    unordered_map<int,int> fact;
    for(int i = 0;i<n;i++)
    {
        unordered_map<int,int> cnt;
        int x = v[i];
        for(int j = 2;j*j <= x;j++)
        {
            while(x % j == 0)
            {
                cnt[j]++;
                x /= j;
            }
        }

        if(x != 1)
        {
            cnt[x]++;
        }

        for(pair<int,int> p:cnt)
        {
            fact[p.first] = max(fact[p.first],p.second);
        }
    }

    int lcm = 1;
    
    for(pair<int,int> p:fact)
    {
        int prime = p.first;
        int times = p.second;
        for(int i = 1;i<=times;i++)
        {
            lcm = mul(lcm,prime);
        }
    }

    int sum = 0;
    for(int x:v)
    {
        sum = (sum + mul(lcm,my_inv(x))) % mod;
    }

    cout<<sum;

    return 0;
}

Measured memory_bytes: 3928
#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>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;

    ll n = s.size() + 1;
    ll a[n] = {};
    ll b[n] = {};
    ll ans[n] = {};
    
    reps(i, 1, n){
        if(s[i-1] == '<'){
            a[i] = a[i-1] + 1;
        }
    }

    reprs(i, 1, n){
        if(s[i-1] == '>'){
            b[i-1] = b[i] + 1;
        }
    }

    // rep(i, n){
    //     cout << a[i];
    // }
    // cout << endl;

    // rep(i, n){
    //     cout << b[i];
    // }
    // cout << endl;

    rep(i, n){
        ans[i] = max(a[i], b[i]);
    }

    cout << accumulate(ans, ans+n, 0ll) << endl;

    return 0;
}

Measured memory_bytes: 12572
//AtCoder ABC068 C - Cat Snuke and a Voyage
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

struct Node {
    vector<int> m_e;
};

int main() {
    ll N,M; //M,edges
    cin>>N>>M;
    vector<Node> m_node(N+1);
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        m_node[a].m_e.push_back(b);
        m_node[b].m_e.push_back(a);
    }
    //1から
    bool possible=false;
    for(const auto &id:m_node[1].m_e){//1からいけるところ
        for(const auto& g:m_node[id].m_e){
            if(g==N){
				possible = true;
                break;
			}
        }
    }
    cout<<(possible?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}

Measured memory_bytes: 12016
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<(n*n*n)/27;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){

            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}

int main(){
    IO

    ll N,ans=0;
    string s;
    cin>>s;
    ll maxx=0;
    N=s.size();
    for(ll i=0;i<N;i++){
        for(ll j=i;j<N;j++){
            ll k=i;
            for(k;k<=j;k++) if(s[k]!='A' && s[k]!='T' && s[k]!='C' && s[k]!='G') break;
            if(k==j+1) maxx=max(maxx,j-i+1);
        }

    }
    cout<<maxx;
    return(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	ll n; cin>>n;
	ll ans=1;
	ll x[100001];
	for(int i=0; i<n; i++) cin>>x[i];
	ll i=0;
	for(ll r=0; r<n; r++){
		while(1){
			if(x[i]<2*i-2*r+1) break;
			if(i==n-1) break;
			i++;
		}
		ans*=(i+1-r);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define MAX 200002
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define CLEAR(a) memset(a,0,sizeof a)
#define pii pair< int , int >
#define fr freopen("input.txt", "r", stdin)
#define fw freopen("output.txt", "w", stdout)
using namespace std;

int main()
{
    //fr;fw;
    int n;
    cin >> n;
    cout << ((n+1)*n)/2;
}


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

#define DO(n) for ( int ____n = n; ____n-->0; )
#define REP(i, n) for (int i=0;i<n;++i)
#define FOR(i, a, b) for (int i=a;i<b;++i)
#define DWN(i, b, a) for (int i=b-1;i>=a;--i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define FOR_1(i, a, b) for (int i=a;i<=b;++i)
#define DWN_1(i, b, a) for (int i=b;i>=a;--i)
#define ECH(it, A) for (__typeof(A.begin()) it = A.begin(); it != A.end(); ++it)
#define RST(A) memset(A, 0, sizeof(A))
#define FLC(A, x) memset(A, x, sizeof(A))
#define PB push_back

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

typedef double DB;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;

const int N = int(1e2) + 9, NN = 16;
int G[N][N];
int n;

int Aid[NN], A[NN], An, ans;

bool ok(int v){
    REP(i, An){
        int u = Aid[i];
        if (!G[u][v]) return false;
    }
    return true;
}

void dfs(){

    if (An > 1){
        int cur = 0; REP(i, An) cur += A[i]; checkMax(ans, cur);
    }

    int AA[NN]; REP(i, An) AA[i] = A[i];
    int st = An ? Aid[An-1]+1 : 0;

    FOR(v, st, n){

        if (!ok(v)) continue;

        A[An] = INF; REP(i, An){
            int u = Aid[i];
            checkMin(A[i], G[u][v]);
            checkMin(A[An], G[u][v]);
        }

        if (!ok) continue;
        Aid[An] = v; ++An; dfs(); --An;
        REP(i, An) A[i] = AA[i];
    }
}

int main(){

#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    int m; while (~scanf("%d%d", &n, &m)){

        RST(G); DO(m){
            int u, v, w; scanf("%d%d%d", &u, &v, &w); --u, --v;
            G[u][v] = G[v][u] = w;
        }

        ans = 0; dfs();
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 1244