akhauriyash/Code-Regression huggingface dataset:
/*
 * @Autor: valk
 * @Date: 2020-07-17 16:50:40
 * @LastEditTime: 2020-09-19 20:27:28
 * @Description: 如果邪恶  是华丽残酷的乐章 它的终场 我会亲手写上 晨曦的光 风干最后一行忧伤 黑色的墨 染上安详
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#define emplace_back push_back
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int seed = 12289;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;

int arr[N];

int main()
{
    int n;
    scanf("%d", &n);
    ll sum = 0, rel = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
    }
    for (int i = 1; i <= n; i++) {
        rel += 1LL * (sum -= arr[i]) % mod * arr[i] % mod;
        rel %= mod;
    }
    printf("%lld\n", rel);
    return 0;
}

Measured memory_bytes: 4000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int sum = 0;
    for(int i = 0;i < n;i ++){
        sum += a.at(i);
    }

    int snk = 0,ari = sum;
    int ans = 1000000000000000;

    for(int i = 0;i < n-1;i ++){
        snk += a.at(i);
        ari -= a.at(i);
        ans = min(ans,abs(snk - ari));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

MAX=10**9+7
n = int(input())
res = 0
a = 1
b = 1
c = 1
for i in range(n):
    a *= 10
    a %= MAX
    b *= 9
    b %= MAX
    c *= 8
    c %= MAX
res += a - 2 * b + c
res %= MAX

print(res)



Measured memory_bytes: 9172
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;

void main(){
    auto nw=readln.split.array;
    auto W=nw[1].to!long;
    long[][]wvs;
    foreach(i;0..nw[0].to!int){
        auto wv=readln.split.map!(to!long).array;
        wvs~=wv;
    }
    auto w1=wvs[0][0];
    auto v0s=wvs.filter!(wv=>wv[0]==w1  ).map!(wv=>wv[1]).array;
    auto v1s=wvs.filter!(wv=>wv[0]==w1+1).map!(wv=>wv[1]).array;
    auto v2s=wvs.filter!(wv=>wv[0]==w1+2).map!(wv=>wv[1]).array;
    auto v3s=wvs.filter!(wv=>wv[0]==w1+3).map!(wv=>wv[1]).array;
    v0s.sort!"a>b"();
    v1s.sort!"a>b"();
    v2s.sort!"a>b"();
    v3s.sort!"a>b"();
    long result=0;
    foreach(i0;0..v0s.length+1)
    foreach(i1;0..v1s.length+1)
    foreach(i2;0..v2s.length+1)
    foreach(i3;0..v3s.length+1)
    {
        if(w1*i0+(w1+1)*i1+(w1+2)*i2+(w1+3)*i3>W)continue;
        auto chosen=v0s[0..i0]~v1s[0..i1]~v2s[0..i2]~v3s[0..i3];
        auto res=chosen.sum;
        result=max(result,res);
    }
    writeln(result);
}


Measured memory_bytes: 1276
from fractions import gcd  # if python3.5~, use math.gcd


def f(x, a):
    return sum([x % aa for aa in a])


def main():
    N = int(input())
    a = list(map(int, input().split(' ')))
    gcd_a = a[0]
    for i in range(1, N):
        gcd_a = gcd(gcd_a, a[i])
    lcm_a = a[0]
    for i in range(1, N):
        lcm_a *= a[i] // gcd_a
    print(f(lcm_a - 1, a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5368
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N, M, Q;
long long L;
long long INF = 1e18;

void warshall_floyd(vector<vector<long long>>& dist) {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    cin >> N >> M >> L;
    vector<vector<long long>> dist(N, vector<long long>(N, INF));
    for (int i = 0; i < N; i++) {
        dist[i][i] = 0;
    }
    int a, b;
    long long c;
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        --a; --b;
        if (c > L) continue;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    cin >> Q;
    vector<int> s(Q), t(Q);
    for (int i = 0; i < Q; i++) {
        cin >> s[i] >> t[i];
    }
    warshall_floyd(dist);
    vector<vector<long long>> count(N, vector<long long>(N, INF));
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (dist[i][j] > L) continue;
            count[i][j] = 1;
            count[j][i] = 1;
        }
    }
    warshall_floyd(count);
    for (int i = 0; i < Q; i++) {
        if (i) cout << endl;
        cout << (count[s[i] - 1][t[i] - 1] > N? -1 : count[s[i] - 1][t[i] - 1] - 1);
    }
}


Measured memory_bytes: 2688
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			ArrayList<Stack<Integer>> S = new ArrayList<>();
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				S.add(new Stack<Integer>());
			}
			int qn = sc.nextInt();
			for(int i = 0; i < qn; i++) {
				int q = sc.nextInt();
				switch(q) {  // 文字列に対し switch を使って良い
				case 0 /* enqueue(t)*/: {
					int t = sc.nextInt();
					int x = sc.nextInt();
					S.get(t).add(x);
					break;  /* break を忘れない */
				}
				case 1 /* front(t) */: {
					int t = sc.nextInt();
					if(!S.get(t).isEmpty()) {
						System.out.println(S.get(t).peek());
					}
					break;  /* break を忘れない */
				}
				case 2: /* dequeue(t) */ {
					int t = sc.nextInt();
					if(!S.get(t).isEmpty()) {
						S.get(t).pop();
					}
					break;  /* break を忘れない */
				}
				}
			}
		}
	}
}



Measured memory_bytes: 168856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;

//import org.junit.Test;

public class Main {
//	@Test
//	public void testName() throws Exception {
//		main(null);
//	}

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

			new Main().solution(br);
		}
	}

	private void solution(BufferedReader br) throws IOException {
		for (String line = br.readLine(); Objects.nonNull(line); line = br
				.readLine()) {
			// String line = br.readLine();
			String[] strList = line.split(" ", 0);

			int num1 = Integer.parseInt(strList[0]);
			int num2 = Integer.parseInt(strList[1]);

			// char char1 = str.charAt(1);
			// char char2 = str.charAt(3);
			// int num1 = Integer.parseInt("" + char1);
			// int num2 = Integer.parseInt("" + char2);

			if (num1 == 0 && num2 == 0) {

			} else if (num1 > num2) {
				System.out.println(num2 + " " + num1);
			} else {
				System.out.println(num1 + " " + num2);
			}

		}
	}

}

Measured memory_bytes: 27072
/**
*	created: 10.08.2020 14:57:14
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x,y);
        par[x] += par[y]; par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);}
    int size(int x) {return -par[root(x)];}
};

signed main() {

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

    vector<int> dir(MAX);
    int n, m, k; cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        dir[a]++; dir[b]++;
        uf.unite(a,b);
    }
    vector<int> to[MAX];
    rep(i,k) {
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n) {
        int ans = uf.size(i) - 1 - dir[i];
        for (int p : to[i]) if (uf.same(i,p)) ans--;
        if (i == 0) cout << ans;
        else cout << ' ' << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 69936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int K; cin >> K;
  ll ans = 0;
  rep(i,K){
    rep(j,K){
      rep(k,K){
        int ii = i+1;
        int jj = j+1;
        int kk = k+1;
        ans += gcd(kk,gcd(ii,jj));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
from itertools import*
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
lst=list(combinations(a,2))
for d,e in lst:
 for i in range(6):
  m=('012345','152043','215304','302541','410352','514320')[i]
  f=[d[int(k)]for k in m]
  if f[0]==e[0]and f[5]==e[5]:
   f=f[1:5]*2
   for j in range(4):
    if f[j:j+4]==e[1:5]:t=1
print(('Yes','No')[t==1])


Measured memory_bytes: 5992
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int n;
    int flag;
    while(cin>>n)
    {
        flag=0;
        for(int i=0; i<26; i++)
        {
            for(int j=0; j<15; j++)
            {
                if(i*4+j*7 == n)
                {
                    flag=1;
                    printf("Yes\n");
                    break;
                }
            }
            if(flag)
                break;
        }
        if(!flag)
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

const int N = 2E6 + 5;
const int mod = 1E9 + 7;

int Add(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}
int Sub(int a, int b) {
	return (a -= b) < 0 ? a + mod : a;
}
int Mul(int a, int b) {
	return (long long) a * b % mod;
}
int Pow(int a, int b) {
	int r = 1;
	for(; b; b >>= 1, a = Mul(a, a))
		if(b & 1) r = Mul(r, a);
	return r;
}

int ans;
int a1, b1, c1, d1, e1, f1;
int a2, b2, c2, d2, e2, f2;
int fac[N], ifac[N];

void pre(int n = N - 1) {
	fac[0] = 1;
	for(int i = 1; i <= n; ++i)
		fac[i] = Mul(fac[i - 1], i);
	ifac[n] = Pow(fac[n], mod - 2);
	for(int i = n - 1; ~i; --i)
		ifac[i] = Mul(ifac[i + 1], i + 1);
}
int C(int n, int m) {
	if(n < m || m < 0) return 0;
	return Mul(fac[n], Mul(ifac[m], ifac[n - m]));
}
int F(int a, int b) {
	if(a < 0 || b < 0) return 0;
	return Sub(C(a + b + 2, a + 1), 1);
}
int G(int a, int b, int c, int d) { // (c, d) -> matrix (0, 0) - (a, b)
	if(c < a || d < b) return 0;
	// cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
	// cout << F(c, d) << ' ' << F(c - a - 1, d - b - 1) << ' ' << F(c - a - 1, d) << ' ' << F(c, d - b - 1) << '\n';
	return Sub(Add(F(c, d), F(c - a - 1, d - b - 1) % mod), Add(F(c - a - 1, d), F(c, d - b - 1)));
}

int main() {
	cin >> a1 >> b1 >> c1 >> d1 >> e1 >> f1;
	cin >> a2 >> b2 >> c2 >> d2 >> e2 >> f2;
	pre();
	//cout << G(1, 1, 2, 2) << '\n';
	for(int i = c1; i <= d1; ++i) {
		// (i, d2)
		ans = Add(ans, Mul(i + d2 + 1, Mul(G(b1 - a1, b2 - a2, i - a1, d2 - a2), G(f1 - e1, f2 - e2, f1 - i, f2 - (d2 + 1)))));
		// (i, c2)
		ans = Sub(ans, Mul(i + c2, Mul(G(b1 - a1, b2 - a2, i - a1, (c2 - 1) - a2), G(f1 - e1, f2 - e2, f1 - i, f2 - c2))));
	}
	for(int j = c2; j <= d2; ++j) {
		// (d1, j)
		ans = Add(ans, Mul(d1 + j + 1, Mul(G(b1 - a1, b2 - a2, d1 - a1, j - a2), G(f1 - e1, f2 - e2, f1 - (d1 + 1), f2 - j))));
		// (c1, j)
		ans = Sub(ans, Mul(c1 + j, Mul(G(b1 - a1, b2 - a2, (c1 - 1) - a1, j - a2), G(f1 - e1, f2 - e2, f1 - c1, f2 - j))));
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>


int main(){
    char s[1300];
    
    gets(s);
    for (char *p=s; *p!='\0'; p++){
        if (*p >='a' && *p <= 'z'){
            printf("%c", *p-'a'+'A');
        } else if (*p >='A' && *p <= 'Z'){
            printf("%c", *p-'A'+'a');
        } else {
            printf("%c", *p);
        }
    }
    printf("\n");   

    return 0;
}

Measured memory_bytes: 908
using System;


public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var d = int.Parse(line.Trim());
            var maxtime = 600 / d;
            var sekibunchi = 0;
            for (int i = 1; i < maxtime  ; i++)
                sekibunchi += (int)Math.Pow(d * i, 2) * d;
            Console.WriteLine(sekibunchi);
        }
    }
}

Measured memory_bytes: 9320
#include <stdio.h>
int main () {
	int N, L;
	scanf ("%d %d", &N, &L);
	int sum = N*(L-1) + N*(N+1)/2;
	if (L>=0)
		printf ("%d\n", sum-L);
	else if (N+L-1>=0)
		printf ("%d\n", sum);
	else
		printf ("%d\n", sum-(N+L-1));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n, -1){ }
    void init(int n){ par.assign(n, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};


int main(){
    ll n, m, ans = 0; cin >> n >> m;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    UnionFind uf(n);
    rep(i, m){
        ll x, y; cin >> x >> y; x--, y--;
        uf.unite(x, y);
    }

    rep(i, n) if(uf.issame(i, p[i] - 1)) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4512
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
import Control.Monad

data Counter = Counter { cD :: {-# UNPACK #-} !Int,
                         cM :: {-# UNPACK #-} !Int,
                         cDM :: {-# UNPACK #-} !Int,
                         cAcc :: {-# UNPACK #-} !Int }

query :: BS.ByteString -> Int -> Int
query str k = cAcc $ VU.foldl' update cInit padded
  where
    cInit = Counter 0 0 0 0
    padded = VU.generate (BS.length str) $ \i ->
      (BS.index str i, if i < k then ' ' else BS.index str (i-k))
    update c0 (now,old) = c2
      where
        c2 = case now of
          'D' -> c1 { cD = cD c1 + 1 }
          'M' -> c1 { cM = cM c1 + 1, cDM = cDM c1 + cD c1 }
          'C' -> c1 { cAcc = cAcc c1 + cDM c1 }
          _   -> c1
        c1 = case old of
          'D' -> c0 { cD = cD c0 - 1, cDM = cDM c0 - cM c0 }
          'M' -> c0 { cM = cM c0 - 1 }
          _   -> c0

main :: IO ()
main = do
  getLine
  str <- BS.getLine
  q <- read <$> getLine
  ks <- VU.unfoldrN q (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  VU.mapM_ (putStrLn . show . query str) ks


Measured memory_bytes: 11772
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <set>

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    std::map<int64_t, int64_t> AD;
    for (size_t n = 0; n < N; ++n)
    {
        int64_t a;
        std::cin >> a;
        A.emplace_back(a);
        ++AD[a];
    }
    
    int64_t m = AD.rbegin()->first;

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

    std::set<int64_t> R;
    for (size_t i = 0; i < A.size(); ++i)
    {
        int64_t t = A[i]*2;
        if (AD[A[i]] > 1) {
            R.insert(A[i]);
        }
        while (t <= m)
        {
            if (AD.find(t) != AD.end())
            {
                R.insert(t);
            }
            t += A[i];
        }
    }

    size_t E = 0;
    for (auto r : R)
    {
        E += AD[r];
    }

    std::cout << A.size() - E << std::endl;

    return 0;
}


Measured memory_bytes: 26388
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <queue>
 
#define fr first
#define sc second
#define mk make_pair
 
using namespace std;
 
struct st{
    int color, w, ind;
};
 
int n, x, y, dsu[1000001], kol[1000001];
long long f[1000001];
vector<st> vec[1000001];
vector<int>vc[1000001];
st ar[1000001];
 
bool cmp(st a, st b)
{
    return (a.w >= b.w) ? 0 : 1;
}
 
int get_dsu(int x)
{
    if(dsu[x] == x)
        return x;
    return dsu[x] = get_dsu(dsu[x]);
}
 
long long mod = 1e9 + 7;
 
long long binpow(long long a, long long b)
{
    if(b == 0)
        return 1;
    if(b % 2 == 1)
        return a * binpow(a, b - 1) % mod;
    else
    {
        long long h = binpow(a, b / 2);
        return h * h % mod;
    }
}
 
int main()
{
    f[0] = 1;
    for(int i = 1; i <= 1e6; i++)
    {
        dsu[i] = i;
        f[i] = f[i - 1] * i % mod;
    }
    cin >> n >> x >> y;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &ar[i].color, &ar[i].w);
        ar[i].ind = i;
        vec[ar[i].color].push_back(ar[i]);
    }
 
    for(int i = 1; i <= n; i++)
        if(vec[i].size() != 0)
        {
            sort(vec[i].begin(), vec[i].end(), &cmp);
            for(int j = 0; j < vec[i].size(); j++)
                if(vec[i][j].w + vec[i][0].w <= x)
                {
                    dsu[get_dsu(vec[i][j].ind)] = get_dsu(vec[i][0].ind);
                }
        }
 
    sort(ar + 1, ar + n, &cmp);
 
    int mn = 1e9;
    for(int i = 1; i <= n; i++)
    {
        if(ar[i].color != ar[1].color && ar[1].w + ar[i].w <= y)
        {
            dsu[get_dsu(ar[i].ind)] = get_dsu(ar[1].ind);
        }
        if(ar[i].color != ar[1].color)
            mn = min(mn, i);
    }
    if(mn != 1e9)
    for(int i = 1; i <= n; i++)
        if(ar[i].color == ar[1].color && ar[mn].w + ar[i].w <= y)
            dsu[get_dsu(ar[i].ind)] = get_dsu(ar[mn].ind);
 
    for(int i = 1; i <= n; i++)
    {
        kol[get_dsu(ar[i].ind)]++;
        vc[get_dsu(ar[i].ind)].push_back(ar[i].color);
    }
 
 
    long long ans = 1;
    for(int i = 1; i <= n; i++)
    {
        if(dsu[i] == i)
        {
            long long k = 1;
            for(long long j = 0; j < kol[i]; j++)
            {
                k *= (j + 1);
                k = k % mod;
            }
            int l = 0, r = 0;
            sort(vc[i].begin(), vc[i].end());
 
            while(vc[i].size() > l)
            {
                while(vc[i][l] == vc[i][r + 1] && r < vc[i].size() - 1)
                {
                    r++;
                }
                k = k * binpow(f[r - l + 1], mod - 2) % mod;
                l = r + 1;
            }
            //cout << i << " " << k << endl;
            ans = ans * k % mod;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 76672
package main

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

var graph [][]int
var memo []int

func main() {
	N, M := ReadInt(), ReadInt()
	graph = make([][]int, N)
	for i := 0; i < M; i++ {
		x, y := ReadInt()-1, ReadInt()-1
		graph[x] = append(graph[x], y)
	}
	memo = make([]int, N)
	for i := 0; i < N; i++ {
		memo[i] = -1
	}
	v := 0
	for i := 0; i < N; i++ {
		v = Max(v, dfs(i))
	}
	fmt.Println(v)
}

func dfs(i int) int {
	if memo[i] >= 0 {
		return memo[i]
	}
	v := 0
	for _, j := range graph[i] {
		v = Max(v, 1+dfs(j))
	}
	memo[i] = v
	return v
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 20676
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, a[2][100];
	cin >> n;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	long long sum = a[0][0], ans;
	for (int j = 0; j < n; j++) {
		sum += a[1][j];
	}

	ans = sum;
	if (n >= 2) {
		for (int i = 0; i < n-1; i++) {
			sum -= a[1][i];
			sum += a[0][i + 1];
			//cout << ans << " " << sum << endl;
			MAX(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    if(N%2==0){
        N=N/2;
    }else{
        N=N/2+1;
    }
    cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
S=input()

def ranlength(A):
    num = list(A)
    count = 1
    table = []
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
               count = count + 1
            else:
                table.append(count)
                count = 1
        except:
            table.append(count)
    return(table)

RL=ranlength(S)
a=0
for i in RL:
    a+=i-1

print(min(a+2*K,N-1))

Measured memory_bytes: 49520
n = gets.to_i
l = gets.split.map(&:to_i).sort
#p l

ans = 0
(n-2).times do |i|
    k = i + 2
    (i+1).upto(n-2) do |j|
        k += 1 while k < n && l[k] < l[i] + l[j]
        ans += k - 1 - j
        #p [ans,i,j,k]
    end
end

puts ans


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


int main(){
	int d;
	cin >> d;
	
	string s = "Christmas";
	string t = " Eve";
	
	string res = s;
	rep(i,25-d) res += t;
	
	cout << res << endl;
	return 0;
}

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

int main(void)
{
	int i,count=0;
	char s[17];
	
	scanf("%s",s);
	
	if(s[0]!='C'){
		count++;
	}
	if(s[1]!='O'){
		count++;
	}
	if(s[2]!='D'){
		count++;
	}
	if(s[3]!='E'){
		count++;
	}
	if(s[4]!='F'){
		count++;
	}
	if(s[5]!='E'){
		count++;
	}
	if(s[6]!='S'){
		count++;
	}
	if(s[7]!='T'){
		count++;
	}
	if(s[8]!='I'){
		count++;
	}
	if(s[9]!='V'){
		count++;
	}
	if(s[10]!='A'){
		count++;
	}
	if(s[11]!='L'){
		count++;
	}
	if(s[12]!='2'){
		count++;
	}
	if(s[13]!='0'){
		count++;
	}
	if(s[14]!='1'){
		count++;
	}
	if(s[15]!='6'){
		count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

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

#define endl '\n'
#define int long long

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

	const int N = 1e6 + 9;
	vector< int > facs(N, 2);
	facs[0] = 0;
	facs[1] = 1;
	for(int i = 2; i < N; i ++) {
		for(int j = 2 * i; j < N; j += i)
			facs[j] ++;
	}
	//for(int i : facs) cout << i << " ";
	int n; cin >> n;
	int ans = 0;
	for(int c = 1; c < n; c ++) {
		ans += (facs[n - c]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 11064
#include <iostream>
using namespace std;
int main(){
  int N;
  int A[200];
  int i;
  int c = 0;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> A[i];
  }
  while(1){
    for(i=0;i<N;i++){
      if(A[i] % 2 == 1){
        cout << c;
        return 0;
      }
      A[i] /= 2;
    }
    c++;
  }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    for(int i=0;i<m;i++){
        sum += a[i];
    }
    cout << max(-1,n-sum) << endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int gcd(int x, int y){
  if(x < y){
    swap(x,y);
  }
  int r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

  return y;
}



int main(){

  int n, k;
  scanf("%d %d", &n, &k);

  vector<int> v;
  SV(n,v);

  REP(i,n){
    if(k == v[i]){
      printf("POSSIBLE\n");
      return 0;
    }
  }

  int G = v[0];
  int max_n = v[0];
  FOR(i,1,n){
    G = gcd(G, v[i]);
    max_n = max(max_n, v[i]);
  }

  if(k <= max_n && k % G == 0){
    printf("POSSIBLE\n");
  }else{
    printf("IMPOSSIBLE\n");
  }

  return 0;
}



Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            string[] nm = Console.ReadLine().Split(' ');
            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);
            int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(line);
            int[] abs = new int[m - 1];
            for(int i = 0;i < m - 1; i++)
            {
                abs[i] = Math.Abs(line[i] - line[i + 1]);
            }
            Array.Sort(abs);
            int sum = 0;
            for (int j = 0; j < m - n; j++)
            {
                sum += abs[j];
            }
            Console.WriteLine(sum);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 18656
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


ll R[399];

int main() {

	int X;
	scanf("%d", &X);

	printf("%d", (int)sqrt(X)*(int)sqrt(X));



}


void  bubbleSort(char number[]) {
	for (int i = 0; i < strlen(number); i++)
		for (int j = i + 1; j < strlen(number); j++)
			if ((int)number[i] > (int)number[j]) {
				char tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    String s[] = new String[n];

    for(int i=0 ; i<n ; i++){
      s[i] = sc.next();
    }
    Arrays.sort(s);
    for(int i=0 ; i<n-1 ; i++){
      if(s[i].equals(s[i+1])){
        count++;
      }
    }
    System.out.println(n-count);
  }
}


Measured memory_bytes: 70128
#include<bits/stdc++.h>
using namespace std;
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
int main(){
  int N, M;
  cin >> N >> M;
  int A[(long)N];
  long double all=0;
  double ok;
  for(int i=0;i<N;i++){ 
    cin >> A[i];
    all+=A[i];
  }
  qsort(A , N , sizeof( int ), desc );
  ok=all/(4*M);
  for(int i=0;i<M;i++){
    if(A[i]<ok){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  
}

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

int main() {
  int N;
  cin >> N;
  int a = N%10;
  int b = (N/10)%10;
  int c = (N/100)%10;
  if (a == 7 || b == 7 || c == 7) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
struct work
{
	int a,b;
}w[250001];
bool cmp(work x,work y)
{if(x.b==y.b)
		return x.a<y.a;
	return x.b<y.b;
}
int main()
{
	int i,j,n,t=0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>w[i].a>>w[i].b;
	sort(w+1,w+n+1,cmp);
	/*for(i=1;i<=n;i++)
	{
		w[i].c=w[i].b/w[i].a;
	}*/
	/*for(i=1;i<=n-1;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(w[i].b>w[j].b)
			{
				//swap(w[i].c,w[j].c);
				swap(w[i].b,w[j].b);	
				swap(w[i].a,w[j].a);			
			}
			else if(w[i].b==w[j].b&&w[i].a>w[j].a)
			{
				//swap(w[i].c,w[j].c);
				swap(w[i].b,w[j].b);	
				swap(w[i].a,w[j].a);			
			}
			
		}
	}*/
 	/*for(i=1;i<=n;i++)
	{
		if(w[i].c==w[i+1].c&&w[i].a<w[i+1].a)
		{
			swap(w[i].c,w[i+1].c);
			swap(w[i].b,w[i+1].b);	
			swap(w[i].a,w[i+1].a);	
		}
	}*/
	for(i=1;i<=n;i++)
	{
		//cout<<w[i].a<<" "<<w[i].b<<" "<<t<<endl;
		t+=w[i].a;
		if(t>w[i].b)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;

ll gcd(ll a,ll b){
  ll x = a;
  ll y = b;
  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 return x/b * y;
}


int main(){

  int n;
  cin >> n;
  
  ll t[n];
  
  REP(i,n){
    cin >> t[i];
  }

  if(n == 1){
    cout << t[0] << endl;
    return 0;
  }
  
  ll ans = gcd(t[0],t[1]);
  
  REP(i,n-2){
    ans = gcd(ans,t[i+2]);
  }
  
  cout << ans << endl;

 return 0;
}

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

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    c_p_c();
    string str1 , str2;
    cin >> str1 >> str2;
    int n = str1.length();
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (str1[i] != str2[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;

}

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

#define pb push_back
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define beg begin()
#define en end()
#define sz size()
#define mem(a,b) memset(a,b,sizeof a)

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

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;	
	if(n%4==0||n%7==0){
		cout<<"Yes";
		return 0;
	}
	
	bool hallar=false;
	
	for(int i=4;i<=100;i+=4){
		for(int j=7; j<100;j+=7){
			if(i+j==n){
				hallar=true;
			}
		}
	}
	
	if(hallar==true){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for _ in range(n)]
if len(w) != len(set(w)):
    print("No")
    exit()
for i in range(n-1):
    if w[i+1][0] == w[i][-1]:
        continue
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

const string infstr = "infinity";

void solve(std::vector<long long> T, std::vector<long long> A, std::vector<long long> B){
    ll d1 = A.at(0) - B.at(0);
    ll d2 = A.at(1) - B.at(1);
    if(d1 < 0){
        d1 *= -1;
        d2 *= -1;
    }
    assert(d1 != 0 && d2 != 0);

    if(d2 > 0){
        cout << 0 << endl;
        return;
    }

    const ll td1 = T.at(0) * d1;
    const ll td2 = T.at(1) * d2;
    assert(td2 < 0);

    if(td1 == - td2){
        cout << infstr << endl;
    }else if(td1 > - td2){
        cout << 0 << endl;
    }else{
        const ll k = td2 / (td1 + td2);
        if(k * td1 + (k - 1) * td2 == 0){
            cout << 2 * (k - 1) << endl;
        }else{
            cout << 2 * k - 1 << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::vector<long long> T(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&T[i]);
    }
    std::vector<long long> A(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(std::move(T), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1e9+7
#define MIN -MAX
#define i(a) cin>>a
#define in(a,b) cin>>a>>b
#define o(a) cout<<a
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loop1(i,a,b) for(ll i=a;i<=b;i++)
#define v(a) vector<ll>a
#define mp(a,b) make_pair(a,b)
#define NO_OF_CHARS 256
using namespace std;
int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int power(int x,int y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
int lenOfLongIncSubArr(int arr[], int n)
{
    // 'max' to store the length of longest
    // increasing subarray
    // 'len' to store the lengths of longest
    // increasing subarray at diiferent
    // instants of time
    int max = 1, len = 1;

    // traverse the array from the 2nd element
    for (int i=1; i<n; i++)
    {
        // if current element if greater than previous
        // element, then this element helps in building
        // up the previous increasing subarray encountered
        // so far
        if (arr[i] <= arr[i-1])
            len++;
        else
        {
            // check if 'max' length is less than the length
            // of the current increasing subarray. If true,
            // then update 'max'
            if (max < len)
                max = len;

            // reset 'len' to 1 as from this element
            // again the length of the new increasing
            // subarray is being calculated
            len = 1;
        }
    }

    // comparing the length of the last
    // increasing subarray with 'max'
    if (max < len)
        max = len;

    // required maximum length
    return max;
}
//In one operation u can choose any element in an array
//and divide it by 2.The value of K is given and we can divide
//K times.We have to find the minm sum.
int main(){
    float a,b,c;
    cin>>a>>b;
    c = ceil((b-a)/(a-1));
    cout<<c+1;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $m);
$p_arr = [];
$s_arr = [];
for ($i = 0; $i < $m; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));
    $p_arr[] = $inputs[0];
    $s_arr[] = $inputs[1];
}

$questions = array_fill(0, $n, false);
$penalties = array_fill(0, $n, 0);

for ($i = 0; $i < $m; ++$i) {
    if ($questions[$p_arr[$i] - 1]) {
        continue;
    }

    if ($s_arr[$i] === 'AC') {
        $questions[$p_arr[$i] - 1] = true;
    } else {
        ++$penalties[$p_arr[$i] - 1];
    }
}

$sum_c = 0;
$sum_p = 0;
foreach ($questions as $key => $q) {
    if (!$q) {
        continue;
    }

    ++$sum_c;
    $sum_p += $penalties[$key];
}

echo $sum_c . ' ' . $sum_p;


Measured memory_bytes: 26228
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main(){
    ll n;
    cin>>n;
    V a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    V bsum(n+1);
    bsum[0]=0;
    rep(i,n){
        bsum[i+1]=n-(upper_bound(c.begin(), c.end(),b[i])-c.begin())+bsum[i];
    }
    ll ans=0;
    rep(i,n){
        ans+=bsum[n]-bsum[upper_bound(b.begin(),b.end(),a[i])-b.begin()];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
		{
			cout<<"vowel";
			return 0;
		}
		else
		{
			cout<<"consonant";
			return 0;
		}
	}

	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++)
typedef long long ll;
const long long INF = 1LL << 60; 

int main()
{
    string S; cin >> S;
    int num = S.size();
    rep(i,num)
    {
      S.at(i) = 'x';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
str = gets.split
A,B = str[0].to_i, str[1].to_i

c = A.gcd(B)
a = 1
b = 3

a = c%2 == 0 ? a+1 : a
while c % 2 == 0
    c /= 2
end
while c > 2 && b < 10**6
    a = c%b == 0 ? a+1 : a
    while c % b == 0
        c /= b
    end
    b += 2
end
if c != 1
    a += 1
end
puts a

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
char str[100];
inline int max(const int &a,const int &b){return a>b?a:b;}
inline int min(const int &a,const int &b){return a<b?a:b;}
inline void read(int &n)
{
	n=0;char c=getchar();bool b=0;
	while(c<'0'||c>'9'){if(c=='-')b=1;c=getchar();}
	while(c>='0'&&c<='9') n=(n<<3)+(n<<1)+c-48,c=getchar();
	if(b) n=-n;
}
int n;
int main()
{
	read(n);
	while(n)
	{
		if(n%10==9) return printf("Yes"),0;
		n/=10;
	}
	printf("No");
}

Measured memory_bytes: 256
def z_algorithm(s):
    N = len(s)
    A = [0]*N
    A[0] = N
    i,j = 1,0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        if j == 0:
            i += 1
            continue
        A[i] = j
        k = 1
        while i+k < N and k+A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

N = int(raw_input())
S = raw_input()

ans = 0
for i in range(N):
    s = S[i:]
    lcp = z_algorithm(s)
    for j,p in enumerate(lcp):
        t = min(j, p)
        ans = max(ans, t)

print ans

Measured memory_bytes: 36892
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
const ll M  = 100005;
vector<int> adj[M];
int visited[M];
int dp[M];
void dfs(int i)
{
    visited[i] = 1;
    rep(j, adj[i].size())
    {
        if(!visited[adj[i][j]])
            dfs(adj[i][j]);
        dp[i] = max(dp[i], dp[adj[i][j]]+1);
    }
}
 
 
int main() {
    
    fastio;
    int n, m;
    cin >> n >> m;
    
    while(m--)
    {
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
    }
    rep(i, n+1)
    dfs(i);
    int res = 0;
    rep(i, n+1)
    {
        res = max(res, dp[i]);
    }
    cout << res;
    return 0; 
}

Measured memory_bytes: 8576
n = int(input())
a = input()
b = input()
c = input()

count = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i]:
        pass
    elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        count += 2
    else:
        count += 1

print(count)


Measured memory_bytes: 3060
a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 

if b.count(m)>=2:
    for i in range(a):
        print (m)
else:
    c=b.copy()
    c.sort(reverse=True)
    m2=c[1]
    for i in range(a):
        if b[i]==m:
            print(m2)
        else:
            print (m)
            



Measured memory_bytes: 14088
#include <iostream>
#include<string>
#include <algorithm>
#include <math.h>
using namespace std;
 
int main() {
  long int N, ans = 0;
  cin >> N;
  for(int i= 1; i*i<N-1; i++){
    ans += (N-1)/i - i+1;
  }
  int fn = sqrt(N-1);
  ans = ans*2 - fn;
  if(N == 2) cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}

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

using namespace std;

int n, m;

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

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int temp;
		cin >> temp;
		n -= temp;
	}
	if (n < 0) cout << -1;
	else cout << n;

	return 0;
}


Measured memory_bytes: 3596