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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

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

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  rep(i, 4) cout << s[i];
  cout << " ";
  REP(i, 4, s.size()) cout << s[i];
  cout << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    cin>>N;

    cout <<(N-1)/2<<endl;

    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline

n = int(input())
l_dim = []
for _ in range(n):
    row, col = map(int, input().split())
    l_dim.append([row, col])
# print(l_dim)

# dp[i][j]: M_i M_{i+1} ... M_jのスカラー乗算回数の最小値
# M_i M_jのスカラー乗算回数 = row_i * col_j * col_i
# 行列 M_i ... M_k と行列 M_{k+1} ... M_j の積を考え、最小値を更新していく
# dp[i][j]: min(dp[i][j], dp[M_i][M_k] + dp[M_{k+1}][M_j] + row_i * col_j * col_k)
# ただし、i <= k <= j

dp = [[-1 for j in range(n)] for i in range(n)]


def rec_dp(left, right):
    if dp[left][right] >= 0:
        # 既に最小値が決まっている
        return dp[left][right]
    if left == right:
        # dp[i][i] = 0
        return 0

    row_left = l_dim[left][0]
    col_right = l_dim[right][1]
    res = float("inf")
    for k in range(left, right):
        col_k = l_dim[k][1]
        num = row_left * col_right * col_k
        res = min(res, rec_dp(left, k) + rec_dp(k + 1, right) + num)
    dp[left][right] = res

    return dp[left][right]


print(rec_dp(0, n - 1))



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  int a, b;
  cin >> a >> b;

  if (b <= 1) {
    cout << 0 << endl;
  } else if (b <= a) {
    cout << 1 << endl;
  } else {
    cout << ((b - a) + (a - 2))/(a - 1) + 1 << endl;
  }
  return 0;
}


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

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

	if (n<1000)
	{
		a = "C";
	}
	else {
		a = "D";
	}
	cout << "AB" << a << endl;
	

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
 
 
 
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))
 
 
#define MOD 1000000007
 
typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

ll n,a,b;
ll v[55];

ll dp[55][55];

ll comb(ll n, ll k){
	if(dp[n][k]>=1)
		return dp[n][k];
	if(n==k)
		return 1;
	if(k==0)
		return 1;
	return dp[n][k] =  comb(n-1,k-1)+comb(n-1,k);
}

int main() {
	scanf("%lld %lld %lld ",&n,&a,&b);
	rep(i,n){
		rep(j,n){
			dp[i][j]=-1LL;
		}
	}
	rep(i,n){
		scanf("%lld ",&v[i]);
	}
	sort(v,v+n,greater<ll>());

	ll ans=0LL;

	double sum=0;
	rep(i,a){
		sum+=v[i];
	}
	ll x=0,y=0;
	rep(i,n){
		if(v[i]==v[a-1]){
			x++;
			if(i<a)
				y++;
		}
	}
	cout.precision(7);
	cout << fixed << sum/a << endl;
	if(v[0]==v[a-1]){
		for(ll i=a; i<= min(b,x); i++)
			ans+=comb(x, i);
		cout << ans << endl;
	}
	else{
		cout << comb(x,y) << endl;
	}
	
	return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 5e5 + 5;
int r, c, n;
vector < pair <int, int> > Gu, Gr, Gd, Gl;
int a[MAXN], stk[MAXN], top, vis[MAXN];

inline void In(int x, int y, int i) {
  if (x == 0 && y != c) Gu.push_back(make_pair(y, i));
  else if (y == c && x != r) Gr.push_back(make_pair(x, i));
  else if (x == r && y != 0) Gd.push_back(make_pair(c - y, i));
  else if (y == 0 && x != 0) Gl.push_back(make_pair(r - x, i));
}
inline bool Edge(int x, int y) { return x == 0 || y == 0 || x == r || y == c; }

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  read(r), read(c), read(n);
  for (RI i = 1, x, y, xx, yy; i <= n; ++i) {
    read(x), read(y), read(xx), read(yy);
    if (Edge(x, y) && Edge(xx, yy))
      In(x, y, i), In(xx, yy, i);
  }
  sort(Gu.begin(), Gu.end());
  sort(Gr.begin(), Gr.end());
  sort(Gd.begin(), Gd.end());
  sort(Gl.begin(), Gl.end());
  int cnt = 0;
  for (auto i : Gu) a[++cnt] = i.second;
  for (auto i : Gr) a[++cnt] = i.second;
  for (auto i : Gd) a[++cnt] = i.second;
  for (auto i : Gl) a[++cnt] = i.second;
  for (RI i = 1; i <= cnt; ++i)
    if (!vis[a[i]]) stk[++top] = a[i], vis[a[i]] = 1;
    else {
      if (stk[top] == a[i]) --top;
      else return puts("NO"), 0;
    }
  puts("YES");

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 7448
from collections import deque

def main():
    N = list(input())
    Nq = deque(N)
    anstmp = []
    ans = 0

    for bit in range(2**(len(N) - 1)):
        for i in range(len(N)):
            anstmp.append(str(Nq.popleft()))
            if ((bit >> i) & 1): 
                anstmp.append("+")
        # print("".join(anstmp))
        ans += eval("".join(anstmp))

        Nq = deque(N) 
        anstmp = []  

    print(ans)
    
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 9340
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll h, m, n; string s;
const ll MOD= 1000000007;
const ld PI = acos(-1);
ll sum = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n; vector<int> b(n,0),w(n,0);
    string c;
    cin >> c;
    rep(i, n) {
        if (c[i] != '#') {
            sum++;
        }
    }ll ans = sum;
    rep(i, n) {
        if (c[i] == '.') sum--;
        else sum++;
        ans = min(ans, sum);
    }cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
int n;
char s[100010];
int cnt[30];
const int md = (int)1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> (s + 1);
  for (int i = 1; i <= n; ++i) ++cnt[s[i] - 'a' + 1];
  long long ans = 1;
  for (int i = 1; i <= 26; ++i)
    ans = ans * (cnt[i] + 1) % md;
  cout << (ans - 1 + md) % md;
  return 0;
}

Measured memory_bytes: 384
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

N=int(input())
c=0
for i in range(1,N+1):
    a=N//i
    c+=i*a*(a+1)//2
print(c)


Measured memory_bytes: 72904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    ll n,a,b,ab;
    cin >> n >> a >> b;
    ab = a + b;
    
    ll set,amari;
    set = n / ab;
    amari = n % ab;
    
    if(amari > a){
        cout << set*a+a << endl;
    }
    else{
        cout << set*a+amari << endl;
    }
    

    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() 
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    {
        while(k--)
        {
            if(b<=a)
            {   
                b*=2;
            }
            else if(c<=b)
            {   
                c*=2;
            }
            // cout<<k<<" is k value"<<endl;
            // cout<<"a ="<<a<<endl;
            // cout<<"b ="<<b<<endl;
            // cout<<"c ="<<c<<endl;
            if(c>b && b>a)
                break;

        }
    }
    if(c>b && b>a)
	    cout<<"Yes"<<'\n';
    else 
        cout<<"No"<<'\n';
	
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc=1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 3644
N, M = map(int, input().split())
# print("N:", N, "M:", M)
s = [list(map(int, input().split())) for _ in range(M)]
# print(s)

c = []
for i in range(N):
    c.append(0)
flg = True
for i in s:
    if i[0] - 1 == 0 and i[1] == 0 and N != 1:
        flg = False
        break
    if (c[i[0] - 1] != 0) and c[i[0] - 1] != i[1]:
        flg = False
        break
    c[i[0] - 1] = i[1]

c = map(str, c)
d = ''.join(c)

if flg == False:
    print("-1")
elif (d[:1] == "0") and (N != 1):
    print("1" + d[1:])
else:
    print(d)

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long x = sc.NextLong();

        long[] counts = new long[n + 1];
        long[] pCounts = new long[n + 1];
        counts[0] = 1;
        pCounts[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            counts[i] = counts[i - 1] * 2 + 3;
            pCounts[i] = pCounts[i - 1] * 2 + 1;
        }

        long answer = dfs(x, n, counts, pCounts);

        Console.WriteLine(answer);
    }

    private static long dfs(long x, long level, long[] counts, long[] pCounts)
    {
        if (x <= 0)
        {
            return 0;
        }

        if (level == 0)
        {
            return 1;
        }

        if (x == counts[level])
        {
            return pCounts[level];
        }

        long mid = (counts[level] + 1) / 2;
        if (x >= mid)
        {
            return dfs(x - mid, level - 1, counts, pCounts) + 1 + pCounts[level - 1];
        }
        else
        {
            return dfs(x - 1, level - 1, counts, pCounts);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int mod = 1e9 + 7;
int binpow(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
            res %= mod;
        }
        a = a * a;
        a %= mod;
        b >>= 1;
        b %= mod;
    }
    return res;
}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";

#define deb(x) cerr << #x << "=" << x << " ";
#define int long long
#define R(n) for (int i = 0; i < n; i++)
#define Rj(n) for (int j = 0; j < n; j++)
#define F(i, a, n) for (int i = a; i <= n; i++)
int n, k, m, tc, x;


main(){
    int     n;
    cin>>n;
int cnt=0;
    R(n){
        cin>>x;
        
        if((i+1)&1 && x&1)cnt++;    
    }
    cout<<cnt;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
int a, b ;
cin >> a >> b ;
cout << a*b <<" "<<2*(a+b) <<endl ;

  return 0 ;
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> A(210);
  for(int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  
  int res = 0;
  while(true)
  {
    bool exist_odd = false;
    for(int i = 0; i < N; i++)
    {
      if(A.at(i) % 2 != 0) exist_odd = true;
    }
    
    if(exist_odd) break;
    
    for(int i = 0; i < N; i++)
    {
      A.at(i) /= 2;
    }
    res++;
      
  }
  cout << res << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



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

	if (a % k == 0) {
		printf("OK");
	} else {
		int div = a / k;
		//printf("[%d,%d,%d]\n", div, div * k + k, b);
		if (b >= div * k + k) {
			printf("OK");
		} else {
			printf("NG");
		}
	}

	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=3300;
char a[MAXN], b[MAXN], c[MAXN];
int f[MAXN][MAXN];
struct State
{
	int x, y;
	State(int a=0, int b=0): x(a), y(b) {}
} p[MAXN][MAXN];
int main()
{
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);
	scanf("%s%s", a+1, b+1);
	int n=strlen(a+1), m=strlen(b+1), k=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
		{
			if (a[i]==b[j])
				f[i][j]=f[i-1][j-1]+1, p[i][j]=State(i-1, j-1);
			else if (f[i-1][j]>f[i][j-1])
				f[i][j]=f[i-1][j], p[i][j]=State(i-1, j);
			else f[i][j]=f[i][j-1], p[i][j]=State(i, j-1);
		}
	for (State s=State(n, m), t; s.x>0&&s.y>0; s=t)
	{
		t=p[s.x][s.y];
		if (t.x!=s.x&&t.y!=s.y) c[++k]=a[s.x];
	}
	for (int i=k; i>=1; i--) putchar(c[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 125056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Pair of Primes
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			boolean[] primes = primeB(N);

			int count = 0;

			for (int i = 1, j = N; i <= N; i++, j--) {
				if (primes[i] && primes[j]) count++;
			}

			System.out.println(count);
		}
	}

	static boolean[] primeB(int n) {

		boolean[] ret = new boolean[n + 1];
		int _n = (int) Math.sqrt(ret.length);

		//2..
		Arrays.fill(ret, 2, ret.length, true);

		for (int i = 2; i <= _n; i++) {
			if (ret[i]) {
				for (int j = i + i; j < ret.length; j += i) {
					if (ret[j]) ret[j] = false;
				}
			}
		}
		return ret;
	}
}

Measured memory_bytes: 29464
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <vector>

#define rep(i, s, N) for(int i = s; i < N; i++)
#define YesNo(result) do {if (result) std::cout << "Yes" << '\n'; else std::cout << "No" << '\n';} while(0)
#define resetarr(arr, val) for(int i = 0; i < sizeof(arr) / 4; i++){ arr[i] = val; }

int main(int argc, char const *argv[]) {
  int A,B,C,X,Y;
  std::cin >> A >> B >> C >> X >> Y;
  long long int each = 0;
  each = A * X + B * Y;
  long long int aa = C * X * 2 + ((Y-X) > 0 ? (Y-X):0) * B;
  long long int bb = C * Y * 2 + ((X-Y) > 0 ? (X-Y):0) * A;
  std::cout << std::min(each, std::min(aa, bb)) << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    int N ,K;
    cin >> N >> K;
    int digits = 0;
    while(N >= pow(K,digits)){
        digits++;
    }
    cout << digits << endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int M = 1000005;
    vector<int> a;
    vector<int> cnt(M);
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        if (cnt[ai] == 0) {
            for (size_t j = ai; j < M; j+=ai) {
                cnt[j] += 1;
            }
        } else {
            cnt[ai] = 2;
        }
    }

    int counter = 0;
    for (size_t i = 0; i < n; i++) {
        if (cnt[a[i]] == 1) {
            counter++;
        }
    }

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


Measured memory_bytes: 8228
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string S, T;
    cin >> S >> T;
    ll N = S.size(), n = T.size();
    ll ans = 1e9;
    loop(i, N - n + 1)
    {
        string Ssub = S.substr(i, n);
        ll count = 0;
        loop(j, n) if (Ssub[j] != T[j]) count++;
        ans = min(ans, count);
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include <math.h>
#include<iomanip>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int main(){

    double L; 
    cin >> L;

    // double ans = 0;
    // for(double i = 1;i < L-1; i += 0.5){
    //     for(double j = 1; j < L-i; j+= 0.5){
    //         ans = max(ans,i*j* (L-i-j) );
    //     }
    // }
    cout << fixed << setprecision(7) << (L/3)*(L/3)*(L/3) << endl;

    return 0;

}

Measured memory_bytes: 256
n, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)] #n行にmつずつ入力される整数
ans_li = [0]*n
for i, j in li:
    ans_li[i-1] += 1
    ans_li[j-1] += 1
for x in ans_li:
    print(x)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    if((a%3==0||b%3==0)||(a+b)%3==0)
    {
        cout<<"Possible";
    }
    else
    {
        cout<<"Impossible";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if(x == 3 || x == 5 || x == 7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = (1e9)+7, MAX = (1e5)+1;

int m, n;
ll x[MAX], y[MAX], sx[MAX], sy[MAX], fx, fy;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> x[i];
		sx[i] = sx[i-1]+x[i];
		fx = (fx+x[i]*(i-1)-sx[i-1])%MOD;
	}
	for(int i = 1; i <= m; i++) {
		cin >> y[i];
		sy[i] = sy[i-1]+y[i];
		fy = (fy+y[i]*(i-1)-sy[i-1])%MOD;
	}
	cout << (fx*fy)%MOD;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, x;
  cin >> n >> x;

  if (n == 2) {
    if (x == 2) {
      cout << "Yes" << endl;
      REP(i, 4) {
        cout << i << endl;
      }
    } else {
      cout << "No" << endl;
    }
    return 0;
  }

  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }

  vb used(2 * n);
  deque<ll> ans;
  ans.push_back(x);
  used[x] = true;

  if (x == 2) {
    ans.push_front(x - 1);
    ans.push_front(x + 1);
    ans.push_back(x + 2);
    used[x - 1] = true;
    used[x + 1] = true;
    used[x + 2] = true;
  } else {
    ans.push_front(x + 1);
    ans.push_front(x - 1);
    ans.push_back(x - 2);
    used[x - 1] = true;
    used[x + 1] = true;
    used[x - 2] = true;
  }

  ll cnt = 0;
  REP(i, 2 * n) {
    if (used[i])
      continue;

    if (cnt % 2 == 0) {
      ans.push_back(i);
    } else {
      ans.push_front(i);
    }
    cnt++;
  }

  cout << "Yes" << endl;
  for (auto it : ans) {
    cout << it << endl;
  }

  return 0;
}


Measured memory_bytes: 5324
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

llong extgcd(llong a,llong b,llong& x,llong& y){
    llong d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

llong  mod_inverse(llong  a,llong m){
    long long int x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<pair <int ,int>> E;
    int n,m; cin>>n>>m;
    string ans="IMPOSSIBLE";
    REP(i,m)
    {
        int a,b; cin>>a>>b;
        a--; b--;
        E.insert({a,b});
        E.insert({b,a});
    }
    for(int i=0; i<=n-1; i++)
    {
        if(E.count({0,i})&&E.count({i,n-1})) ans="POSSIBLE";
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 19072
#include <cstdio>

int main()
{
  int ans = 0;
  int a, b;
  scanf("%d %d", &a, &b);
  for (int i = a; i <= b; ++i)
  {
    if (i <= 9)
    {
      ++ans;
    }
    else if (i <= 99)
    {
      if (i % 10 == i / 10) ++ans;
    }
    else if (i <= 999)
    {
      if (i % 10 == i / 100) ++ ans;
    }
    else if (i <= 9999)
    {
      if (i % 10 == i / 1000 && (i / 10) % 10 == (i / 100) % 10) ++ans;
    }
    if (i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,ll>pa;

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int d[300][300];
int a[10];
int n,m,r;
void floyd()
{
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            if(d[i][k]!=inf)
            for(int j=1;j<=n;j++){
                d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
            }
        }
    }
}
ll slove()
{
    ll ans=0;
     for(int i=1;i<r;i++){
     ans+=d[a[i]][a[i+1]];
   }
   return ans;
}
int main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   cin>>n>>m>>r;
   for(int i=1;i<=r;i++)
    cin>>a[i];
   memset(d,0x3f,sizeof d);
   for(int i=1;i<=m;i++){
       int a,b,c;
       cin>>a>>b>>c;
       d[a][b]=d[b][a]=c;
   }
   floyd();
   ll ans=1e18;
   sort(a+1,a+1+r);
   do{
      ans=min(ans,slove());
   }while(next_permutation(a+1,a+1+r));

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



Measured memory_bytes: 3976
#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;
using P = pair<ll, ll>;
const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  map<ll, ll> l, r;
  REP(i, n){
    ll h;
    cin >> h;
    l[i+h]++;
    r[i-h]++;
  }
  ll ans = 0;
  for(auto p : l){
    ans += p.second * r[p.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 37916
A, B, C, X, Y = map(int, input().split())
if A + B <= 2 * C:
    print(A * X + B * Y)
else:
    if X > Y:
        A, B, X, Y = B, A, Y, X
    print(2 * X * C + (Y - X) * min(B, 2 * C))


Measured memory_bytes: 3060
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   list<int>::iterator it;																								   
list<int>::iterator it1;																							   
vector<int>::iterator it2;																							   
vector<int>::iterator it3;																							   
set<int>::iterator it4;																								   
map<string, int>::iterator it5; 																					   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	double a, b;
	double t;
	cin >> a >> b >> t;
	
	t += 0.5;
  
	double ans = -b;
	double licznik = 0;
	while(licznik <= t){
		ans += b;
		//cout << "current ans: " << ans << endl;
		licznik += a;
		//cout << "current licznik: " << licznik << endl;
		if(licznik >= t){
			break;
		}
	}
	
	cout << ans << endl;
  
  
    
   
    
    
    
    
	return 0;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()

    if min(A) == 0:
        print(0)
        return
    ans = 1
    for x in A:
        ans *= x
        if ans > INF:
            print(-1)
            return
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 89868
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
int n,m;
map<string,int> t;
int c[111];
vector<int> v[111];

int solve(int k){
  int sum = 0;
  if(v[k].empty()) return c[k];
  for(int i = 0; i < (int)v[k].size(); i++){
    sum += solve(v[k][i]);
  }
  return min(sum,c[k]);
}

int main(void){
  while(cin >> n && n){
    t.clear();
    for(int i = 0; i < 111; i++) v[i].clear();
    for(int i = 0; i < n; i++){
      string s;
      int a;
      cin >> s >> a;
      t[s] = i;
      c[i] = a;
    }
    cin >> m;
    for(int j = 0; j < m; j++){
      string s;
      int a;
      cin >> s >> a;
      int id = t[s];
      for(int i = 0; i < a; i++){
	cin >> s;
	v[id].push_back(t[s]);
      }
    }
    string s;
    cin >> s;
    cout << solve(t[s]) << endl;
  }
}

Measured memory_bytes: 1244
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

fizzBuzz n
	| n `mod` 5 == 0 || n `mod` 3 == 0 = 0
	| otherwise                        = n

main :: IO ()
main = do
	n <- readLn :: IO Int
	print $ sum $ map fizzBuzz [1..n]


Measured memory_bytes: 3888
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	_, m := nextInt(), nextInt()

	l, r := 0, 100000
	for i := 0; i < m; i++ {
		ll, rr := nextInt(), nextInt()
		if l < ll {
			l = ll
		}
		if r > rr {
			r = rr
		}
	}

	if r-l+1 > 0 {
		fmt.Println(r - l + 1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 2816
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
s=input()
ans=0
for i in range(k,n):
  if s[i]==s[i-k]:
    s=s[:i]+'z'+s[i+1:]
for i in range(n):
  ans+=a['sprz'.index(s[i])]
print(ans)

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

typedef long long llt;

const int MaxN = 100000 + 5, MaxM = 100000 + 5;

int N, M;
int U[MaxM], V[MaxM];
int par[MaxN]; llt siz[MaxN];
llt Ans[MaxM];

void init() {
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= M; ++i) scanf("%d %d", &U[i], &V[i]);
  for (int i = 1; i <= N; ++i) par[i] = i, siz[i] = 1;
}

int Find(int x) { return x == par[x] ? x : Find(par[x]); }

inline void merge(int p, int q) {
  if (siz[p] > siz[q]) swap(p, q);
  siz[q] += siz[p]; siz[p] = 0; par[p] = q;
}

void solve() {
  Ans[M] = 1LL * N * (N - 1) / 2;
  for (int i = M; i >= 1; --i) {
    int u = U[i], v = V[i];
    int p = Find(u), q = Find(v);
    if (p != q) {
      Ans[i - 1] = Ans[i] - 1LL * siz[p] * siz[q];
      merge(p, q);
    } else Ans[i - 1] = Ans[i];
  }

  for (int i = 1; i <= M; ++i) printf("%lld\n", Ans[i]);
}

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

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007 
#define pb push_back
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int w=1;
	// cin>>w;
	while(w--){
		int n;
		cin>>n;
		cout<<1-n;
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
const int MAX_N = 1e5+5;
int v[MAX_N];
int ce[MAX_N], co[MAX_N];
int N;

void solve()
{
	if(N==2){
		if(v[0] != v[1]) cout << 0 << endl;
		else cout << 1 << endl;
		return;
	}
	for(int i=0;i<N;i+=2) ce[v[i]]++;
	for(int i=1;i<N;i+=2) co[v[i]]++;
	vector<pair<int,int>> ve, vo;
	for(int i=0; i<MAX_N;++i) if(ce[i]) ve.emplace_back(ce[i],i);
	for(int i=0; i<MAX_N;++i) if(co[i]) vo.emplace_back(co[i],i);
	sort(ve.begin(), ve.end(), greater<pair<int,int>>());
	sort(vo.begin(), vo.end(), greater<pair<int,int>>());
	int e=0, o=0;
	if(ve[e].second == vo[o].second){//most common
		if(ve[e].first + vo[o+1].first >= ve[e+1].first + vo[o].first){
			o++;
		}else{
			e++;
		}
	}
	int ans = N-ve[e].first-vo[o].first;
	cout << ans << endl;
}

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

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

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

int main(){
    int n;
    cin >> n;
    ll out;
    cin >> out;
    for(int i = 1; i < n; i++){
        ll a;
        cin >> a;
        out = lcm(out, a);
    }
    cout << out << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	string s;
	char sub[4];
	int i;
	int subNumber;
	int remain;
	int minRemain = 999999999;

	cin >> s;

	for (i = 0; i < s.length() - 2; i++)
	{
		sub[0] = s[i];
		sub[1] = s[i + 1];
		sub[2] = s[i + 2];
		sub[3] = 0;

		subNumber = atoi(sub);
		remain = abs(753 - subNumber);
		
		if (minRemain > remain)
			minRemain = remain;

	}

	cout << minRemain;

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n, m;
string s[1005];
int d[1005][1005];
vector<pair<int, int> > q;
int xx, yy;

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

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
        s[i] = "#" + s[i];
        for (int j = 1; j <= m; ++j) {
            d[i][j] = 1e9;
            if (s[i][j] == '#') {
                d[i][j] = 0;
                q.push_back(make_pair(i, j));
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < (int)q.size(); ++i) {
        int x = q[i].first;
        int y = q[i].second;
        if (d[x][y] > ans) ans = d[x][y];
        for (int j = 0; j < 4; ++j) {
            xx = x + dx[j];
            yy = y + dy[j];
            if (xx < 1 || xx > n || yy < 1 || yy > m) continue;
            if (d[x][y] + 1 < d[xx][yy]) {
                d[xx][yy] = d[x][y] + 1;
                q.push_back(make_pair(xx, yy));
            }
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 14700
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
using LL = long long;

LL dp[1 << 16], ndp[1 << 16];

struct guy
{
	LL cost;
	bitset<16> sch;
};

int main(void)
{
	for (;;)
	{
		int n;
		cin >> n;
		if (!n)break;
		memset(dp, 0, sizeof(dp));
		vector<guy>dat;
		for (int i = 0; i < n; ++i)
		{
			LL m, l;
			cin >> m >> l;
			bitset<16> sch;
			for (int j = 0; j < m; ++j)
			{
				int s, e;
				cin >> s >> e;
				s -= 6; e -= 6;
				for (int t = s; t < e; ++t)
				{
					sch.set(t);
				}
			}
			dat.push_back({ l,sch });
		}
		for (int i = 0; i < n; ++i)
		{
			memset(ndp, 0, sizeof(ndp));
			for (unsigned long nes = 0; nes < (1 << 16); ++nes)
			{
				ndp[nes] = dp[nes];
				if ((nes & dat[i].sch.to_ulong()) == dat[i].sch.to_ulong())
				{
					unsigned long las = nes ^ dat[i].sch.to_ulong();
					ndp[nes] = max(ndp[nes], dp[las] + dat[i].cost);
				}
			}
			for (int j = 0; j < (1 << 16); ++j)
			{
				dp[j] = ndp[j];
			}
		}
		cout << dp[(1 << 16) - 1] << endl;
	}
	return 0;
}

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

const int MAX_N=1010;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}

// dp[k][n]:n人に対して，k人以下のグループを作った場合のグループ分けの個数
ll dp[1010][1010];

int main(){
  prepare();
  int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
  dp[A][0]=1;
  for(int i=A;i<=B;i++) for(int j=0;j<=N;j++) if(dp[i][j]!=0){
    (dp[i+1][j]+=dp[i][j])%=MOD;
    ll tmp=1LL;
    int num=N-j;
    for(int k=1;j+k*i<=N&&k<=D;k++){
      (tmp*=comb(num,i))%=MOD;
      num-=i;
      if(k>=C) (dp[i+1][j+k*i]+=tmp*dp[i][j]%MOD*ifact[k]%MOD)%=MOD;
    }
  }
  cout<<dp[B+1][N]<<endl;
  return 0;
}


Measured memory_bytes: 8192