akhauriyash/Code-Regression huggingface dataset:
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int l,r;
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<enl;

    return 0;
}


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

using namespace std;

int func(int x, int n, int k, int s){
	int ret = 0;
	if(s < 0) return 0;
	if(k < 0) return 0;
	if(n < 0) return 0;
	if(s == 0 && k==0) return 1;
	for(int i=min(n,s);i>=0;i--){
		//for(int j=0;j<x;j++) cout << " ";
		//cout << i << endl;
		ret += func(x+1, i-1,k-1,s-i);
	}
	return ret;
}

int main(){
	int n,k,s;
	while(cin >> n >> k >> s, n){
		cout << func(0, n, k, s) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2960
(defparameter N (read))
(defparameter lst (loop repeat N collect (read)))

(defun check (lst)
  (let ((len1 (length (remove-duplicates lst)))
        (len2 (length lst)))
       (if (= len1 len2)
           "YES"
           "NO")))

(format t "~A" (check lst))


Measured memory_bytes: 61800
def main():
    n=list(input())
    if n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1]=='9':
        print('hon')
    elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
        print('pon')
    else:
        print('bon')

if __name__=='__main__':
    main()

Measured memory_bytes: 61708
n,m = [int(x) for x in input().split()]
xy = []
for _ in range(m):
    tmp = [int(x)-1 for x in input().split()]
    xy.append(tmp)

box = {x: 1 for x in range(n)}
red = {x: False for x in range(n)}
red[0] = True

for x,y in xy:
    box[x] -= 1
    box[y] += 1
    if red[x]:
        red[y] = True
    if box[x] == 0:
        red[x] = False

print(len([1 for x in red.values() if x]))

Measured memory_bytes: 45456
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<char> S(N);
	string ans = "Three";
	for (int i = 0;i < N;++i) {
		cin >> S[i];
		if (S[i] == 'Y') {
			ans = "Four";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
int N;
cin >> N;
long long sum = 0;
vector <int>Fizzbuzz(N);
for (int i = 0;i < N; i++){
Fizzbuzz.at(i) = i+1;
if (Fizzbuzz.at(i) % 3 != 0 && Fizzbuzz.at(i) % 5 != 0) {
sum = sum + Fizzbuzz.at(i);
}
}
cout << sum;
return 0;
}

Measured memory_bytes: 7100
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

class UnionFind {
private:
    int n;
    vector<int> a;
public:
    UnionFind(int n) : n(n), a(n, -1) {}
    int find(int x) { return a[x] < 0 ? x : (a[x] = find(a[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    bool same(ii& p) { return same(p.first, p.second); }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (a[x] > a[y]) swap(x, y);
        a[x] += a[y];
        a[y] = x;
        n--;
        return true;
    }
    bool unite(ii& p) { return unite(p.first, p.second); }
    int size() const { return n; }
    int size(int x) { return -a[find(x)]; }
};

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

	vector<int> p(n);
	rep(i, n) cin >> p[i];

    UnionFind uf(n + 1);

    rep(i, m) {
        int x, y;
        cin >> x >> y;

        uf.unite(x, y);
    }

    int ans = 0;
    rep(i, n) {
        if (uf.same(i + 1, p[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/**
*    created: 14.05.2020 00:13:40
**/
#include <bits/stdc++.h>
#define int long long
#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++)
using namespace std;

signed main() {

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

    int n; cin >> n;
    if (n % 2 != 0) cout << 0 << endl;
    else {
        int ans = 0;
        int div = 5;
        while (div <= n) {
            int tmp = n / div;
            ans += tmp / 2;
            div *= 5;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using LL = long long int;
#define int LL

LL get_times(LL min_val, const std::vector<int>& v) {
    LL sum = 0;
    for (int i=0; i<v.size(); ++i) {
        sum += v.end() - lower_bound(v.begin(), v.end(), min_val-v[i]);
    }

    return sum;
}

LL score(LL min_val, const std::vector<int>& v, const LL& m) {
    LL used = 0;
    std::vector<LL> rui(v.size()+1,0);
    for (int i=v.size()-1; i>=0; --i) {
        rui[i] = rui[i+1] + v[i];
    }
    LL sum = 0;
    for (int i=0; i<v.size(); ++i) {
        int l = lower_bound(v.begin(), v.end(), min_val-v[i]) - v.begin();
        int num = v.end() - lower_bound(v.begin(), v.end(), min_val-v[i]);
        sum += rui[l] + v[i]*num;
        used += num;
    }
    assert(used>=m);
    return sum -(used - m)*min_val;
}

signed main(){
    LL n,m;
    std::cin>>n>>m;
    std::vector<int> v;

    for (int i=0; i<n; ++i) {
        int tmp;
        std::cin >> tmp;
        v.emplace_back(tmp);
    }

    std::sort(v.begin(), v.end());

    LL l = 0, r = 300000;
    while( r-l>1 ){
        LL mid = (r+l)/2;

        LL times = get_times(mid, v);
        if (times < m) {
            r = mid;
        }else{
            l = mid;
        }
    }

    std::cout << score(l, v, m) << std::endl;

}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    int f[3] ;
    cin>>a>>b>>c;
    f[0] = a;
    f[1] = b;
    f[2] = c;
    sort(f,f+3);
    cout<<f[0]<<" "<<f[1]<<" "<<f[2]<<endl;
    return 0;
}



Measured memory_bytes: 3164
import collections

n = int(input())
a = list(input().split())
q = int(input())
bc = [list(input().split()) for _ in range(q)]

d = collections.Counter(a)
s = 0
for k, v in d.items():
    s += int(k) * v

for i in range(q):
    b, c = bc[i]
    s += (int(c) - int(b)) * d[b]
    print(s)
    if c in d.keys():
        d[c] += d[b]
        d[b] = 0
    else:
        d[c] = d[b]
        d[b] = 0

Measured memory_bytes: 115164
#include <stdio.h>
#include <stdlib.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

void DFS(int);
void visit(int,int);

int t,G[105][105],u,v;
int color[105],d[105],f[105];

int main()
{
  int n,i,j,k;

  scanf("%d",&n);
  if(n<1 || n>100) exit(1);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1] = 1;
    }
  }

  DFS(n); //深さ検索
      
  return 0;
}

void DFS(int n)
{
  int u;
  
  for(u=0;u<n;u++) color[u] = WHITE; //初期化
  t = 0;

  for(u=0;u<n;u++)
    if(color[u] == WHITE) visit(u,n); //白なら訪問する

  for(u=0;u<n;u++)
    printf("%d %d %d\n",u+1,d[u],f[u]);
}

void visit(int u,int n)
{
  int i,v;
  
  color[u] = GRAY; //訪問したらグレーにする
  d[u] = ++t; //訪問の時間を記録

  for(v=0;v<n;v++){
    if(G[u][v] == 0) continue; //行列にない部分は飛ばす
    if(color[v] == WHITE) visit(v,n); //白なら再起的に訪問
  }
  color[u] = BLACK; //訪問が終わったら黒にする
  f[u] = ++t; //訪問完了の時間を記録
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll n;
    int k;
    cin>>n>>k;
    int sum=0;
    while(n)
    {
        n/=k;
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}


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

#define MAX_N 100

int main() {
	int N;
	int A[MAX_N] = {0};
	int sumA = 0, sumB = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	sort(A, A+N, [](int o1, int o2) { return o1 > o2; });
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)
			sumA += A[i];
		else
			sumB += A[i];
	}
	cout << sumA - sumB << endl;
}


Measured memory_bytes: 256
S = input()
pre = "X"
B, W = 0, 0
for s in S:
    if s != pre:
        if s == "B":
            B += 1
        else:
            W += 1
        pre = s

if B == 0 or W == 0:
    print(0)
elif B == W:
    print(B * 2 - 1)
else:
    x, y = min(B, W), max(B, W)
    print(x * 2)

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111



int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  flag = false;
  vll x;
  x.pb(a);
  x.pb(b);
  x.pb(c);
  sort(ALL(x));
  FOR(i, 0, 3) {
	if (x[i] % 2 == 0) {
	  cout << "0" << endl;
	  return 0;
	}
  }
  cout << x[0] * x[1] << endl;

  return 0;
}

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

string S;

int main(){
	int alt = 0;	
	cin >> S;
	for(int i = 1; i < S.length(); i++)
	       if(S[i - 1] != S[i]) alt++;
	printf("%d\n", alt);	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 200005
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
const long long Mod=1e9+7;
long long F[N],Inv[N];
long long Quick_Pow(long long X,long long K)
{
	long long Ans=1;
	while(K)
	{
		if(K&1)Ans=Ans*X%Mod;
		K>>=1;
		X=X*X%Mod;
	}
	return Ans;
}
long long Get_Inv(long long X)
{
	return Quick_Pow(X,Mod-2);
}
long long C(long long n,long long m)//ÇóC(n,m) 
{
	return F[n]*(Inv[m]*Inv[n-m]%Mod)%Mod;
}
int main()
{
	int i;
	long long n,m,A,B,Maxx;
	scanf("%lld%lld%lld%lld",&n,&m,&A,&B);
	Maxx=n+m;
	F[0]=1;Inv[0]=1;
	for(i=1;i<=Maxx;i++)
	{
		F[i]=F[i-1]*i%Mod;
		Inv[i]=Get_Inv(F[i]);
	}//ÌáÇ°´æ´¢ºÃiµÄ½×³ËºÍ¶ÔÓ¦µÄÄæÔª 
	long long Ans=0;
	for(i=1;i<=n-A;i++)//(1,1)->(i,B)->(i,B+1)->(n,m) 
	{
		Ans=(Ans+C(i+B-2,B-1)*C(n-i+m-B-1,m-B-1)%Mod)%Mod;
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = 2 * a + 2 * b;
		System.out.println(area + " " + length);
	}

}

Measured memory_bytes: 25988
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int A, B, C;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B >> C;

  if (A * C <= B) {
    cout << C << endl;
  } else {
    cout << B / A << endl;
  }

  return 0;
}

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

int main() {
    int n, k;
    cin >> n;
    k = 0;

    for (int i = 0; i < n; i++) {
        char si;
        cin >> si;
        if(si == 'Y') k++;
    }
    if(k != 0) cout << "Four" << endl;
    else cout << "Three" << endl;
}

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

#define ll long long
#define int ll
#define endl "\n"

signed main () {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;
	int current = 0;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') {
			current++;
			ans = max(ans, current);
		}
		else current = 0;
	}
	cout << ans << endl;

	return 0;

}


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

string JoinWithSpace(int *array, int size);

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

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

	int swap_count = 0;
	for (int i = 0; i < n -1; i++) {

		int min = i;
		for (int j = i; j < n; j++) {
			if (array[j] < array[min]) {
				min = j;
			}
		}

		if (i != min) {
			swap(array[i], array[min]);
			swap_count++;
		}
	}

	cout << JoinWithSpace(array, n) << endl;
	cout << swap_count << endl;
	return 0;
}

string JoinWithSpace(int *array, int size) {
	ostringstream oss;
	for (int i = 0; i < size - 1; i++) {
		oss << array[i] << " ";
	}
	oss << array[size - 1];
	return oss.str();
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 入力受付
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int array[] = new int[n];
		for(int i = 0; i < n; i++){
			array[i] = scan.nextInt();
		}

		int counter = 0;

		for(int num: array){
			if(num >= k){
				counter++;
			}
		}

		System.out.println(counter);

	}
}

Measured memory_bytes: 51308
x,n = map(int,input().split())
plist = list(map(int,input().split()))
plist.sort()

if x not in plist:
    print(x)
    exit()
i = +1
while True:
    if x-i not in plist:
        print(x-i)
        exit()
    if x+i not in plist:
        print(x+i)
        exit()
    i += 1

Measured memory_bytes: 61892
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;
 
typedef long long LL;
typedef pair < int, int > pa;
 
const int N = 100010;
 
int n, y[N], x[N], w[N], L, T;
LL cur;
 
int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%d", &n, &L, &T );
	for( int i = 0 ; i < n ; i++ )
	{
		scanf( "%d%d", &x[ i ], &w[ i ] );
		if( w[ i ] == 1 )
		{
			y[ i ] = ( x[ i ] + T ) % L;
			cur += ( x[ i ] + T ) / L;
		}
		else
		{
			y[ i ] = ( x[ i ] - T ) % L;
			cur += ( x[ i ] - T ) / L;
			if( y[ i ] < 0 ) y[ i ] += L, cur--;
		}
	}
	cur = ( cur % n + n ) % n;
	sort( y, y + n );
	for( int i = cur ; i < n ; i++ ) printf( "%d\n", y[ i ] );
	for( int i = 0 ; i < cur ; i++ ) printf( "%d\n", y[ i ] );
}

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

#define CO const
#define IN inline
typedef long long LL;
typedef long double LD;

template<class T> T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int mod=1e9+7;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (LL)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
IN void cadd(int&a,int b){
	a=add(a,b);
}
IN void cmul(int&a,int b){
	a=mul(a,b);
}

CO int N=20,S=65536+10;
int a[N];
int fac[S],ifac[S],dp[N][S];

IN int binom(int n,int m){
	return mul(fac[n],mul(ifac[m],ifac[n-m]));
}
int main(){
	int n=read<int>(),m=read<int>();
	for(int i=m;i>=1;--i) read(a[i]);
	int all=1<<n;
	fac[0]=1;
	for(int i=1;i<=all;++i) fac[i]=mul(fac[i-1],i);
	ifac[all]=fpow(fac[all],mod-2);
	for(int i=all-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	dp[0][0]=1;
	for(int i=1;i<=m;++i)for(int s=0;s<all;++s){
		int left=all-a[i]+1-s;
		cadd(dp[i][s],dp[i-1][s]);
		for(int j=0;j<n;++j)if(~s>>j&1){
			if(left<1<<j) break;
			cadd(dp[i][s|1<<j],mul(dp[i-1][s],
				 mul(binom(left-1,(1<<j)-1),fac[1<<j])));
		}
	}
	int ans=fac[all-1];
	for(int s=1;s<all;++s){
		int sum=mul(dp[m][s],fac[all-1-s]);
		cadd(ans,__builtin_popcount(s)&1?mod-sum:sum);
	}
	cmul(ans,all);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4864
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long int ll;
ll n,a,ans;
int main(){
	scanf("%lld",&n);ans=-n;
	while(n--){
		scanf("%lld",&a);
		ans+=a;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,a[N];
ll f[N],sum[N];
ll inv(ll x){return x<=1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    f[0]=1;
    for(int i=1;i<N;i++) f[i]=f[i-1]*i%mod;
    scanf("%d",&n);
    for(int i=1;i<N;i++) sum[i]=(sum[i-1]+f[n-1]*inv((ll)i*(i+1)%mod)%mod)%mod;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0;
    /*
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
        if(j==n)
        ans=(ans+(a[j]-a[i])*f[n-1]%mod*inv(j-i)%mod)%mod;
        else ans=(ans+(a[j]-a[i])*f[n-1]%mod*inv((ll)(j-i)*(j-i+1)%mod)%mod)%mod;
    */
    for(int i=1;i<n;i++)
    {
        ans=(ans-a[i]*(sum[n-1-i])%mod)%mod;
        ans=(ans-a[i]*f[n-1]%mod*inv(n-i)%mod)%mod;
    }
    ans=(ans+mod)%mod;
    for(int i=2;i<n;i++)
        ans=(ans+a[i]*sum[i-1]%mod)%mod;;
    for(int i=1;i<n;i++)
        ans=(ans+a[n]*f[n-1]%mod*inv(n-i)%mod)%mod;
    printf("%lld\n",ans);
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; ++i)
    {
        cin >> S[i];
    }
    vector<string> ans(H, "");
    for (int i = 0; i < H; ++i)
    {
        string s = S[i];
        for (int j = 0; j < W; ++j)
        {
            int bomb = 0;
            if (s[j] == '.')
            {
                if (j - 1 >= 0)
                {
                    if (s[j - 1] == '#')
                    {
                        ++bomb;
                    }
                }
                if (j + 1 <= W - 1)
                {
                    if (s[j + 1] == '#')
                    {
                        ++bomb;
                    }
                }
                if (i - 1 >= 0)
                {
                    string sa = S[i - 1];
                    if (j - 1 >= 0)
                    {
                        if (sa[j - 1] == '#')
                        {
                            ++bomb;
                        }
                    }
                    if (sa[j] == '#')
                    {
                        ++bomb;
                    }
                    if (j + 1 <= W - 1)
                    {
                        if (sa[j + 1] == '#')
                        {
                            ++bomb;
                        }
                    }
                }
                if (i + 1 <= H - 1)
                {
                    string sa = S[i + 1];
                    if (j - 1 >= 0)
                    {
                        if (sa[j - 1] == '#')
                        {
                            ++bomb;
                        }
                    }
                    if (sa[j] == '#')
                    {
                        ++bomb;
                    }
                    if (j + 1 <= W - 1)
                    {
                        if (sa[j + 1] == '#')
                        {
                            ++bomb;
                        }
                    }
                }
                S[i].replace(j, 1, to_string(bomb));
            }
        }
    }
    for (int i = 0; i < H; ++i)
    {
        cout << S[i] << endl;
    }
}

Measured memory_bytes: 3660
// https://atcoder.jp/contests/abc150/tasks/abc150_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    unordered_set<int> st;
    // 最小公倍数を求める
    int ans = 1;
    REP(i, N) {
        uint64_t t;
        cin >> t;
        st.insert(__builtin_ctzll(t));
        if (st.size() >= 2) {
            cout << "0\n";
            return 0;
        }
        ans = lcm(ans, t / 2);
    }
    // M以下となる「最小公倍数 * 奇数倍」の数
    cout << (M / ans + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    string s,t ;
    cin >> s >> t ;

    int cnt = 0 ;

    for (int i = 0; i < s.size(); i++){
        if(s[i]!=t[i]) cnt++ ;
    } 

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

Measured memory_bytes: 3916
#include <iostream>
using namespace std;
int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    ans = ans + 1 + (D-1)/A;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
#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 n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q) {
          if(A[b[i]]-A[a[i]] == c[i])
            now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i]; 
    }
    dfs(vector<int>(1,1));
    cout << ans <<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
using namespace std;
	

int main() {
	int long long n,a,b;
	cin >> n;
	for (int i = 1; i <= sqrt(n) ; i++) {
		if ( n % i == 0) {
			a = i;
			b = n / i;
		}
	}
	
	int long long ans=0;
	ans = (a - 1) + (b - 1);
	cout << ans;
		return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  double k, mn = 1e9;
  vector<int> h(n);
  rep(i, n)
  {
    cin >> h[i];
  }
  int ans;
  rep(i, n)
  {
    k = t - h[i] * 0.006;
    mn = min(mn, abs(k - a));
    if (mn == abs(k - a))
      ans = i;
  }
  cout<< ans + 1 << endl;
}

Measured memory_bytes: 256
#C - Coloring Colorfully

s = list(input())

cost_0, cost_1 = 0, 0

for i in s[::2]:
	if i == "1":
		cost_0 += 1
for i in s[1::2]:
	if i == "0":
		cost_0 += 1

for i in s[::2]:
	if i == "0":
		cost_1 += 1
for i in s[1::2]:
	if i == "1":
		cost_1 += 1
		 
print(min(cost_0, cost_1))

Measured memory_bytes: 4268
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000007
using namespace std;

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

	ll a, b, c, k, ans = 0;
	cin >> a >> b >> c >> k;

	if(k >= a){
		ans += a;
		k -= a;
	}
	else{
		ans += k;
		cout << ans;
		return 0;
	}
	if(k >= b){
		k -= b;
	}
	else{
		cout << ans;
		return 0;
	}
	if(k >= c){
		ans -= c;
	}
	else ans -= k;
	cout << ans;

	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#define MAX_SIZE 256
#define INF 2000000001

int FindParent(int *tree, int i){
    if(i==1) return INF;
    return tree[i/2];
}

int Left(int *tree, int i,int size){
    if(i>(size/2) || (i*2)>size) return INF;
    return tree[i*2];
}

int Right(int *tree, int i, int size){
    if(i>(size/2) || (i*2+1)>size) return INF;
    return tree[i*2+1];
}

int main(){
    int tree[MAX_SIZE];
    int num,i,parent,left,right;

    scanf("%d",&num);
    for(i=1;i<=num;i++){
        scanf("%d",&tree[i]);
    }

    for(i=1;i<=num;i++){
        printf("node %d: key = %d,",i,tree[i]);
        parent = FindParent(tree,i);
        left = Left(tree,i,num);
        right = Right(tree,i,num);
        if(parent != INF) printf(" parent key = %d,",parent);
        if(left != INF) printf(" left key = %d,",left);
        if(right != INF)printf(" right key = %d,",right);
        printf(" \n");
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

string s;

int main() {
  cin >> s;
  char h = s[0];
  int ans = 0;
  for (int i=1; i<s.length(); i++) {
    if (s[i] != h) {
      h = s[i];
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    string sd,t;
    cin>>sd>>t;

    string ans = "UNRESTORABLE";
    if(sd.length() < t.length()){
        cout<<ans<<endl;
        return 0;
    }

    for(int i=0;i<=sd.length()-t.length();i++){
        string s;
        bool ok=true;
        for(int j=0;j<i;j++){
            if(sd[j]=='?') s+='a';
            else s+=sd[j];
        }
        for(int j=i;j<i+t.length();j++){
            if(sd[j]=='?') continue;
            else if(sd[j] != t[j-i]) ok=false;
        }
        if(!ok) continue;
        s += t;
        for(int j=i+t.length();j<sd.length();j++){
            if(sd[j]=='?') s += 'a';
            else s+=sd[j];
        }
        for(int j=0;j<sd.length();j++){
            if(sd[j]=='?') continue;
            if(sd[j]!=s[j]){
                ok=false;
                break;
            }
        }
        if(ok) ans = s;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A;
    cin >> A;
    if(A == 0){
        cout << 0 << endl;
        return 0;
    }
    /*
    while(1){
        int a;
        cin >> a;
        cout << a << "=" << a / (-2) << "*-2+" << a % (-2) << endl;
    }
    */
    string ans;
    while(A != 0){
        int a = A / (-2);
        int b = A % (-2);
        if(b < 0){
            a++;
            b+=2;
        }
        //cout << b << endl;
        ans = string() + (char)(b + '0') + ans;
        A = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
    IOS;
    int n;
    string s;
    cin >> n >> s;
    using ps = pair<string,string>;
    map<ps,int> mp1,mp2;
    int t = 1<<n;
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s1.push_back(s[j]);
            }else{
                s2.push_back(s[j]);
            }
            k/=2;
        }
        mp1[ps(s1,s2)]++;
    }
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s2.push_back(s[j+n]);
            }else{
                s1.push_back(s[j+n]);
            }
            k/=2;
        }
        reverse(all(s1));
        reverse(all(s2));
        mp2[ps(s1,s2)]++;
    }
    ll res = 0;
    for(auto p:mp1){
        ll temp = (ll)p.second*mp2[p.first];
        res += temp;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 103424
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

G = [[] for j in range(n + 1)]

for a, b in edges:
    G[a].append(b)
    G[b].append(a)

for b in G[1]:
    if n in G[b]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 55840
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
  ans = 0
  A = list(map(int,input().split()))
  for j in range(M):
    ans += A[j]*B[j]
  ans += C
  if ans>0:
    count+=1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

void merge(int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    /* create temp arrays */
    int L[n1], R[n2]; 
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    /* Copy the remaining elements of L[], if there 
       are any */
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    /* Copy the remaining elements of R[], if there 
       are any */
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
  
/* l is for left index and r is right index of the 
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        // Same as (l+r)/2, but avoids overflow for 
        // large l and h 
        int m = l+(r-l)/2; 
  
        // Sort first and second halves 
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 


int main()
{
    int i , numOfMons, numOfSpecMoves; 
    unsigned int *monsHealth; 
    long long accHealth = 0;
    
    scanf("%d %d", &numOfMons, &numOfSpecMoves);

    monsHealth = (int*) calloc (numOfMons, sizeof(int));
    
    for (i=0; i<numOfMons ; i++)
    {
        scanf("%u", &monsHealth[i]);
        accHealth += monsHealth[i];
    }
    
    mergeSort(monsHealth, 0, numOfMons-1); 
//  quickSort(monsHealth, 0, numOfMons-1); 
    for (i=numOfMons-1; numOfSpecMoves>0 && i>=0; numOfSpecMoves--,i--)
    {
        accHealth -= monsHealth[i];
    }
    printf("%lli",accHealth);
    free(monsHealth);
    
	return 0;
}


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

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

    sort(A, A + n);
    cout << A[n - 1] - A[0] << endl;

    return 0;
}


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

int csum[1000005][3];
int C[1000005];

signed main() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    int k[q]; rep (i, q) cin >> k[i];
    rep (i, n) {
        rep (j, 3) csum[i + 1][j] = csum[i][j];
        C[i + 1] = C[i];
        if (s[i] == 'D') {
            csum[i + 1][0]++;
        }
        if (s[i] == 'M') {
            csum[i + 1][1]++;
        }
        if (s[i] == 'C') {
            csum[i + 1][2]++;
            C[i + 1] += csum[i + 1][1];
        }
    }
    rep (j, q) {
        int K = k[j] - 1;
        int ans = 0;
        rep (i, n) {
            int to = i + K;
            if (to >= n) to = n - 1;
            if (s[i] == 'D') {
                ans += C[to + 1] - C[i] - (csum[to + 1][2] - csum[i][2]) * csum[i][1];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 32644
#include<stdio.h>  
#include<algorithm>  
#include<string.h>  
#include<queue>  
using namespace std;  
   
int vis[100009];  
typedef pair<int, int> P;  
   
   
int main()  
{  
    int k;  
    scanf("%d", &k);  
    deque<P> q;  
    memset(vis, 0, sizeof(vis));  
    q.push_back(make_pair(1, 1));  
    while(!q.empty())  
    {  
        P x = q.front(); q.pop_front();  
        if(vis[x.first]) continue;  
        vis[x.first] = 1;  
        if(x.first == 0)  
        {  
            printf("%d\n", x.second);  
            break;  
        }  
        q.push_front(make_pair(x.first*10 % k, x.second));  
        q.push_back(make_pair((x.first+1) % k, x.second+1));  
   
    }  
    return 0;  
}  //看看怎么回事

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  vector<vector<int>> s(2, vector<int>(N));
  rep(i, 2){
    rep(j, N){
      cin >> s[i][j];
    }
  }
  int max = 0;
  int row = 0;
  rep(ii, N){
    int cnt = 0;
    row = 0;
    rep(i, N){
      cnt += s[row][i];
      if(i == ii){
        row = 1;
        cnt += s[row][i];
      }
      if(max < cnt) max = cnt;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
        #include<string.h>
        #include<stdlib.h>
        #include<math.h>
         
        int main(void) {
         
        	int N;
          	long long K; 
        	int a, b;
        	int i;
        	long long count[100000] = { 0 };
        	long long sum=0;
         
        	scanf("%d %lld", &N, &K);
        	for (i = 0; i < N; i++) {
        		scanf("%d %d", &a, &b);
        		count[a-1] += b;
        	}
         
        	for (i = 0; i < 100000; i++) {
        		sum += count[i];
        		if (sum >= K) {
        			printf("%d\n", i+1);
        			break;
        		}
        	}
        }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,ans,bns;
int main(){
    cin>>a>>b>>x;
    if(a%x==0) ans=a/x;
    else ans=a/x+1;
    bns=b/x;
    cout<<bns-ans+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

const int MAX = 200200;
int A[MAX], B[MAX];
int p[MAX], sz[MAX];

void init(int N) {
	REP(i, N + 1) {
		p[i] = i;
		sz[i] = 1;
	}
}

int getS(int u) {
	return (u == p[u] ? u : (p[u] = getS(p[u])));
}

void join(int u, int v) {
	u = getS(u);
	v = getS(v);
	if(u == v) return;
	p[u] = v;
	sz[v] += sz[u];
}


int main() {
	int N, M; scanf("%d %d", &N, &M);
	init(N);
	REP(i, M) {
		scanf("%d %d", A + i, B + i);
		join(A[i], B[i]);
	}
	int ans = 0;
	for(int i = 1; i <= N; i++) {
		ans = max(ans, sz[getS(i)]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 13080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n;
  cin >> n;  
  vector<int> a(n);
  rep (i, n) a[i] = i + 1;
  string s1 = "";
  string s2 = "";
  rep (i, n) {
    int a;
    cin >> a;
    s1 += to_string(a);
  }
  rep (i, n) {
    int a;
    cin >> a;
    s2 += to_string(a);
  }
  
  vector<string> strs;
  do {
    string s = "";
    for (auto v : a) {
      s += to_string(v);
    }
    strs.push_back(s);
  } while (next_permutation(a.begin(), a.end()));

  int dis1 = find(strs.begin(), strs.end(), s1) - strs.begin();
  int dis2 = find(strs.begin(), strs.end(), s2) - strs.begin();
  cout << abs(dis1 - dis2) << endl;

  return 0;
}


Measured memory_bytes: 5384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main()
{
    fast;
    vector<ll> g[5];
    ll c1=0,c2=0;
    for(int i=0;i<3;i++)
    {
        ll x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(int i=1;i<=4;i++)
    {
      //  cout<<g[i].size()<<" ";
        if(g[i].size()==2)
        {
            c1++;
        }
        else if(g[i].size()==1)
        {
            c2++;
        }
        else
        {
            cout<<"NO";;
            return 0;
        }
    }
    if(c1==2 && c2==2)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a);
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++)
     roll[j][i]=b=b*N+im[j][i]-im[j][i-p]*g;
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)im[i][j*6+a]=t%2,t/=2;
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
       int t=D[s[j]],a=6;
	while(a--)pa[i][j*6+a]=t%2,t/=2;
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 10060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for(int i=0;i<5;i++) {
			sum += Math.max(40, sc.nextInt());
		}
		System.out.println(sum/5);
	}

}

Measured memory_bytes: 17300
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(int a, int b, int c, int d)
{
  for (;;) {
    c -= b;
    if (c <= 0) return "Yes";
    a -= d;
    if (a <= 0) return "No";
  }
}

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

  std::cout << std::setprecision(20);
  std::cout << solve(a, b, c, d) << std::endl;
}


Measured memory_bytes: 3632