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

using ll=long long;
#define int ll
#define upto(a,b,i) for(int i=(a),b_=(b);i<=b_;++i)
#define uptil(a,b,i) for(int i=(a),b_=(b);i<b_;++i)
#define downto(a,b,i) for(int i=(a),b_=(b);i>=b_;--i)
#define downtil(a,b,i) for(int i=(a),b_=(b);i>b_;--i)
#define times(n,i) uptil(0,n,i)
#define rtimes(n,i) downto((n)-1,0,i)
#define sp << " "
#define ln << endl

void solve() {
  int N,L; cin >> N >> L;
  int sum = 0, mn = 1e9;
  times(N, i) {
    sum += L + i;
    if(abs(mn) > abs(L+ i)) mn = L + i;
  }
  cout << sum - mn ln;
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(10);
  solve();
return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto k = modpow(t, N);
        ans += (k + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - k;
    }
    cout << ans % MOD << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

void print(vector<int> &v){
    cout << v[0];
    rep(i,v.size()-1) cout << " " << v[i+1];
    cout << endl;
}

signed main(){
    string s;
    cin >> s;
    int n = (int) s.length();
    s.push_back('R');
    vector<int> square(n,0);
    
    int L = 0, R = 0, left_index = 0, right_index = 0;
    rep(i,n){
        (s[i]=='R' ? R : L)++;
        if(s.substr(i,2)=="RL"){
            right_index = i;
            left_index = i+1;
        }else if(s.substr(i,2)=="LR"){
            square[right_index] = ceil(R/2.0) + floor(L/2.0);
            square[left_index]  = ceil(L/2.0) + floor(R/2.0);
            R = 0; L = 0;
        }
    }
    
    print(square);
}

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

int main(){
    int n;
    long long ans=1; cin>>n;
    string s; cin>>s;
    map<char,int> check;
    for(int i=0; i<n; i++) {
        if(check.count(s[i])) check[s[i]]+=1;
        else{
            check[s[i]]=1;
        }
    }
    for(auto a:check){
        int val=a.second;
        ans = ans*(val+1)%1000000007;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int l,r,d;
    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<endl;
    return 0;
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w;
	cin >> h >>w;
	vector<string> s(h+2);
	rep(i,h){
		string p; cin >>p;
		s[i+1]= "#"+p+"#";
	}
	s[0]=s[h+1]=string(w+2,'#');
	for(auto x: s) cout << x <<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

struct UnionFind {
    vector<ll> parent;

    UnionFind(ll N) {
        parent.resize(N, -1);
    }

    ll find(ll x) {
        // 自身が根っこの場合
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = find(parent[x]);
    }
    ll size(ll x) {
        return -parent[find(x)];
    }

    void unite(ll x, ll y) {
        ll root_x = find(x);
        ll root_y = find(y);
        // 同じ素集合にいたら何もしない
        if (root_x == root_y) return;
        if (size(root_x) < size(root_y))
            swap(root_x, root_y);
        parent[root_x] += parent[root_y];
        parent[root_y] = root_x;
    }
};

int main() {
    ll n, m; cin >> n >> m;
    vector<vector<ll>> G(n);
    ll a, b;

    UnionFind uf(n);

    for (int i = 0; i < m; ++i) {
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        uf.unite(a, b);
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, uf.size(i));
    }

    cout << ans << endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  ll n, k, x, y; cin >> n >> k >> x >> y;

  ll ans = 0;
  ans += min(n, k) * x;
  ans += max(0ll, n-k) * y;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int A,B;
char a[105][105];
int main(){
	//freopen("b.out","w",stdout);
	scanf("%d%d",&A,&B);
	puts("100 100");
	if(A<=B+1){
	for(int i=0;i<100;++i){
		for(int j=0;j<100;++j){
			a[i][j]='.';
		}
	}
	for(int i=0;i<B;++i){
		int xx=i/25*4,yy=i%25*4;
		for(int j=xx;j<=xx+2;++j){
			for(int k=yy;k<=yy+2;++k){
				a[j][k]='#';
			}
		}
	}
	for(int i=0;i<A-1;++i){
		a[i/25*4+1][i%25*4+1]='.';
	}
	for(int i=0;i<100;++i){
		for(int j=0;j<100;++j){
			putchar(a[i][j]);
		}
		puts("");
	}}
	
	
	
	else{
		for(int i=0;i<100;++i){
		for(int j=0;j<100;++j){
			a[i][j]='#';
		}
	}
	for(int i=0;i<A;++i){
		int xx=i/25*4,yy=i%25*4;
		for(int j=xx;j<=xx+2;++j){
			for(int k=yy;k<=yy+2;++k){
				a[j][k]='.';
			}
		}
	}
	for(int i=0;i<B-1;++i){
		a[i/25*4+1][i%25*4+1]='#';
	}
	for(int i=0;i<100;++i){
		for(int j=0;j<100;++j){
			putchar(a[i][j]);
		}
		puts("");
	}
	}
	return 0;
}

Measured memory_bytes: 128
def main():
    a, b = map(int, input().split())
    common_divisors = set(get_divisors(a)) & set(get_divisors(b))
    number_of_prime_common_divisor = sum([is_prime(i) for i in common_divisors])
    print(number_of_prime_common_divisor+1)

def get_divisors(n):
    out = []
    if n < 1:
        return out
    m = int(n**0.5)
    for i in range(1, m+1):
        if not n%i:
            out.append(i)
            if n != i**2:
                out.append(n//i)
    return out

def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    for i in range(3, int(x**0.5)+1, 2):
        if x%i == 0:
            return False
    return True

if __name__ == "__main__":
    main()

Measured memory_bytes: 5112
#include<stdio.h>
int main(void)
{
	int x[3000],y[3000],i,j,a;
	i=j;
	i=1;
	while(1){
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]>y[i]){
			a=x[i];
			x[i]=y[i];
			y[i]=a;
		}
		if(x[i]==0 && y[i]==0){
			break;
		}
		i++;
		j++;
	}
	i=1;
	while(i<=j){
		if(x[i]==0 && y[i]==0){
			break;
		}
		else{
			printf("%d %d\n",x[i],y[i]);
			i++;
		}
	}
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    ll N, M;
    cin >> N >> M;

    ll ans;
    if (N == 1 && M == 1) ans = 1;
    else if (N == 1) ans = M - 2;
    else if (M == 1) ans = N - 2;
    else ans = (N * M) - (N * 2 + (M - 2) * 2);

    cout << max(ans, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

  int N,d;
  
  long long ans = 0;

  cin >> N;

  int A[N];

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

  for(int i = 1;i < N;i++){
    if(A[i] < A[i-1]){
      d = A[i-1]-A[i];
      ans += d;
      A[i] += d;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4264
A, B, C, X, Y = map(int, input().split())

r = []

# Cピザを使わない
t1 = A * X + B * Y
r.append(t1)

# Cピザをmin(A*2, B*2)まで買う
x = min(X, Y)
ab = 2 * x
t2 = ab * C + (X - x) * A + (Y - x) * B
r.append(t2)

# Cピザで賄う
x = max(X, Y)
ab = 2 * x
t3 = ab * C
r.append(t3)

print(min(r))

Measured memory_bytes: 3064
d,n=map(int,input().split())
t=[int(input()) for _ in [0]*d]
abc=[list(map(int,input().split())) for _ in [0]*n]

memo=[-1]*101

t_list=[set() for _ in [0]*61]

for a,b,c in abc:
    for j in range(a,b+1):
        t_list[j].add(c)
        
for i in t_list[t[0]]:
    memo[i]=0
    
for i in t[1:]:
    memo2=[-1]*101
    temp=[j for j in t_list[i]]
    for j,k in enumerate(memo):
        if k!=-1:
            for l in temp:
                memo2[l]=max(memo2[l],k+abs(j-l))
    memo=memo2
    
print(max(memo))


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

int main(void){
    int a,b,c,d,e,f,g,h;

    cin>>a>>b>>c>>d;

    e=b-d+c;
    f=c-a+d;


    g=b-d+a;
    h=c-a+b;

    cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;    
    
    

    return 0;
}

Measured memory_bytes: 256
main(){
	int H,W,i,j;
	scanf("%d%d",&H,&W);getchar();
	for(i=0;i<H;i++){
		int p=-1;
		for(j=0;j<W;j++){
			int c=getchar();
			if(c=='c')p=0;
			else if(p>=0)p++;
			printf(j<W-1?"%d ":"%d\n",p);
		}
		getchar();
	}
	return 0;
}

Measured memory_bytes: 600
using System;
class Program
{
    static int[] reqTimes = new int[3];

    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < 3; i++)
        {
            reqTimes[i] = int.Parse(input[i]);
        }
        //出力
        Console.WriteLine(logic());
    }

    static string logic()
    {
        // 入力はすべて static 変数に入っているものを用いる
        int result = Utils.sum(reqTimes) - Utils.max(reqTimes);
        return result.ToString();
    }
}

class Utils
{
    public static int max(int[] values)
    {
        int result = 0;
        foreach(int value in values)
        {
            if (result < value)
            {
                result = value;
            }
        }
        return result;
    }

    public static int sum(int[] values)
    {
        int result = 0;
        foreach(int value in values)
        {
            result += value;
        }
        return result;
    }
}

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

long long N, X;
vector<long long> L;

int main(){
	cin >> N >> X;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		L.push_back(tmp);
	}

	long long cur = 0;
	long long ans = 0;
	for(long long i = 1; i <= N; i++){
		if(cur <= X){
			ans++;
		}
		cur = cur + L[i-1];
	}

	if(cur <= X){
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long mod_inv(long long a, long long mod = MOD) {
  a %= mod;
  if (__gcd(a, mod) != 1) return -1;
  long long b = mod, x = 1, y = 0;
  while (b > 0) {
    long long tmp = a / b;
    a -= tmp * b;
    swap(a, b);
    x -= tmp * y;
    swap(x, y);
  }
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int num = MAX, long long mod = MOD) {
  fact[0] = 1;
  FOR(i, 1, num + 1) fact[i] = fact[i - 1] * i % mod;
  fact_inv[num] = mod_inv(fact[num], mod);
  for (int i = num; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

inline long long nCk(int n, int k, long long mod = MOD) {
  if (n < 0 || n < k || k < 0) return 0;
  return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int b, w; cin >> b >> w;
  nCk_init(b + w);
  long long half = mod_inv(2), p = 0, q = 0, memo = 1;
  cout << half << '\n';
  FOR(i, 1, b + w) {
    (memo *= half) %= MOD;
    (p += nCk(i - 1, b - 1) * memo % MOD) %= MOD;
    (q += nCk(i - 1, w - 1) * memo % MOD) %= MOD;
    long long ans = (half - p * half % MOD + q * half % MOD) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
const int mod=2019;
const int inf=0x3f3f3f3f;
int l,r;
int least=inf;
int main()
{
    cin>>l>>r;
    if(r-l>=mod)
    {
        cout<<"0";
        return 0;
    }
    l%=mod;
    r%=mod;
    if(l<r)
    {
        for(int i=l;i<r;i++)
        {
            for(int j=i+1;j<=r;j++)
            {
                least=min(least,i*j%mod);
            }
        }
        cout<<least;
    }
    else
    {
        cout<<"0";
    }
    return 0;
}

Measured memory_bytes: 256
from math import floor

while True:
    r = input().split()
    a = int(r[0])
    op = str(r[1])
    b = int(r[2])
    if op == "?":
        break
    elif op == "+":
        print("%d"%(a + b))
    elif op == "-":
        print("%d"%(a - b))
    elif op == "*":
        print("%d"%(a * b))
    elif op == "/":
        print("%d"%(floor(a / b)))

Measured memory_bytes: 7732
#include <iostream>
#include <string>
#include <stdlib.h>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <queue>
#include <utility>
#define llint long long
#define inf 1e9
#define eps 1e-8

using namespace std;

int n;
llint r[1005], w[1005];
bool dp[1005][1005];

int main(void)
{

  while(1){
    cin >> n;
    if(n == 0) break;

    for(int i = 1; i <= n; i++){
      cin >> r[i] >> w[i];
    }
    llint rsum = 0, wsum = 0;
    for(int i = 1; i <= n; i++) rsum += r[i], wsum += w[i];;

    bool flag = false;
    for(int i = 1; i <= n; i++){
      if(r[i] * 2 > rsum) flag = true;
    }
    if(!flag){
      cout << rsum + wsum << endl;
      continue;
    }

    llint mx = 0, mx_i, delay;
    for(int i = 1; i <= n; i++){
      if(mx < r[i]){
        mx = r[i];
        mx_i = i;
      }
    }
    delay = mx - (rsum-mx);

    for(int i = 0; i <= n; i++){
      for(int j = 0; j <= delay; j++){
        dp[i][j] = false;
      }
    }
    dp[0][0] = true;

    for(int i = 0; i < n; i++){
      for(int j = 0; j <= delay; j++){
        if(!dp[i][j]) continue;
        dp[i+1][j] = true;
        if(i+1 != mx_i) dp[i+1][j+w[i+1]] = true;
      }
    }

    llint ans = 0;
    for(llint i = 0; i <= delay; i++){
      if(dp[n][i]) ans = max(ans, i);
    }
    cout << rsum + wsum + (delay-ans) << endl;
  }

  return 0;
}



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

int main() {
	int S[4];
	int x;
	cin>>x;
	for(int i=3;i>=0;i--)
	{ 
		S[i]=x%10;
		x=int(x/10);
		
	}
	int a=10*S[0]+S[1];
	int b=10*S[2]+S[3];
	if(((12<a && a<99)||a==0) && 0<b && b<=12)
	cout<<"YYMM";
	else if(0<a && a<=12 && ((12<b && b<=99)||b==0))
	cout<<"MMYY";
	else if(0<a && a<=12 && 0<b && b<=12)
	cout<<"AMBIGUOUS";
	else
	cout<<"NA";
	
	return 0;
}

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

ans = [0] * m
for i in range(n):
    a = list(map(int, input().split()))
    k = a[0]
    a = a[1:]
    for j in range(k):
        ans[a[j]-1] += 1

count = 0
for i in ans:
    if i == n:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b, c;
	cin >> c;
	b = c % 100;
	a = c / 100;
	bool YYMM = (1 <= b && b <= 12);
	bool MMYY = (1 <= a && a <= 12);
	if(YYMM){
		if(MMYY){
			cout << "AMBIGUOUS" << endl;
		}
		else{
			cout << "YYMM" << endl;
		}
	}
	else if(MMYY){
		if(YYMM){
			cout << "AMBIGUOUS" << endl;
		}
		else{
			cout << "MMYY" << endl;
		}
	}
	else{
		cout << "NA" << 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++)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,y;
    cin >> x >> y;

    ll cnt = 0;
    while(true){
        if(x > y) break;
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import itertools
n, k = map(int, input().split())
d = [0]*k
a = [0]*k
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))
a = list(set(list(itertools.chain.from_iterable(a))))
ans = 0
for i in range(1, n+1):
    if i in a:
        continue
    else:
        ans += 1

print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<vector<int>> adj;
vector<bool> passed;

int dfs(int n, int to, int p=-1) {
  passed[n] = true;
  ll result = 0;
  for (auto x: adj[n]) {
    if (x==p||passed[x]) continue;
    if (x==to) result++;
    else result += dfs(x,to,n);
  }
  return result;
}

int main() {
  int N, M; cin >> N >> M;
  adj.resize(N);
  rep(i,M) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  bool ok = true, to6 = false;
  vector<int> to4;
  rep(i,N) {
    if (adj[i].size()%2) ok = false; 
    if (adj[i].size()==4) to4.push_back(i); 
    if (adj[i].size()>=6) to6 = true;
  }

  string result = "No";
  if (ok) {
    if (to6||to4.size()>=3) result = "Yes";
    else if (to4.size()==2) {
      passed.resize(N,false);
      if (dfs(to4[0],to4[1])==2) result = "Yes";
    }
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s);
  int cnt = 0;
  bool ok = false;
  REP(i, s.size() - 1) {
    if (s[i] == s[i + 1]) cnt++;
    else cnt = 0;
    if (cnt >= 2) ok = true;
  }
  OK(ok);

  return 0;
}



Measured memory_bytes: 256
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1000000007
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int n;cin>>n;
  string s;cin>>s;
  int res=INF;

  int a=0;
  int b=0;
  rep(i, n){
    if (s[i]=='#') a++;
    else b++;
  }
  chmin(res, min(a, b));

  int p=0;
  int q=0;
  rep(i, n){
    if (s[i]=='#') p++;
    else q++;
    chmin(res, p+(b-q));
  }

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

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
bool vis[N];
int h[N];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &h[i]);
    }
    for(int i = 0, u, v; i < m; i++) {
        scanf("%d%d", &u, &v);
        if(h[u] <= h[v]) vis[u] = true;
        if(h[v] <= h[u]) vis[v] = true;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4316
#include <stdio.h>

int main(void){
  
  int H, W, N, ans;

  scanf("%d%d%d", &H, &W, &N);
  if(H > W){
    ans = (double)N / (double)H + 0.999999;
  }
    else
    {
    ans = (double)N / (double)W + 0.999999;
    }
    printf("%d", ans);
    
    return(0);
    }    
    

Measured memory_bytes: 128
n = int(input())
w = list(map(int, input().split()))

total = sum(w)
dif = 10**5
point = 0

for i in w:
    point += i
    if abs(total-2*point) < dif:
        dif = abs(total-2*point)
    else:
        continue
print(dif)

Measured memory_bytes: 9180
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
if(A == 1){
A = 14;
}
if(B == 1){
B = 14;
}
if(A == B){
System.out.println("Draw");
}else if(A > B){
System.out.println("Alice");
}else{
System.out.println("Bob");
}

}
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
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 LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

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

const int maxn = 200000+10;
int seen[maxn],N,M;
vi graph[maxn];

int dfs(int u){
	seen[u] = 1;
	int res = 1;
	for(auto &v : graph[u]){
		if(seen[v])continue;
		res += dfs(v);
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	forn(i,0,M){
		int u,v; cin >> u >> v; u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	int res = 0;
	forn(i,0,N){
		if(seen[i])continue;
		res = max(res,dfs(i));
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 24756
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    rep(i,5){
        int x;
        cin>>x;
        if(x==0) cout<<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for (int i=0;i<3;i++)if (s.charAt(i)==t.charAt(i))ans++;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35344
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) { par = vector<int>(N, -1); }

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

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

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

int main() {
    int N, M;
    cin >> N >> M;

    UnionFind tree(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        tree.unite(a, b);
    }

    int output = 0;
    for (int i = 0; i < N; i++) {
        if (tree.size(i + 1) > output) {
            output = tree.size(i + 1);
        }
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <vector>
 
#define ll long long
using namespace std;
 
int main(){
	ll n,k;
	cin >> n >> k;
	ll ans = k;
	for(ll i = 0; i < n -1; i++){
		ans *= (k-1);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string s1,s2;
	cin>>s1;
	cin>>s2;
	string s3;
	int len=(int)s2.length()-1;
	while (len>=0){
		s3+=s2[len];
		len--;
	}
	if (!s1.compare(s3)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
const int MAXN=2010;
const int MOD=924844033;
int n,k,a[MAXN],cnt,vis[MAXN];
long long fac[MAXN],f[MAXN][MAXN][2][2];
signed main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%lld%lld",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%MOD;
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		for(int j=i;j<=n;j+=k)
			a[++cnt]=j,vis[j]=1;
	}
	f[0][0][0][0]=1;
	a[0]=-MAXN;
	for(int i=1;i<=n;i++)
	{
		f[i][0][0][0]=1;
		for(int j=1;j<=i;j++)
		{
			f[i][j][0][0]=(f[i-1][j][0][0]+f[i-1][j][1][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%MOD;
			f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][0]+f[i-1][j-1][1][0])%MOD;
			f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%MOD;
			f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%MOD;
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%MOD;
		if(i&1)(ans+=MOD-sum*fac[n-i]%MOD)%=MOD;
		else
			(ans+=sum*fac[n-i]%MOD)%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 124032
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a[1000000]={},b[1000000]={};
  int x[300100],y[300100],q,z=0,rt=0,nk=0,baka=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>x[i]>>y[i];
  }
  sort(b,b+(n+1));
  for(int i=1;i<=n;i++){
    if(a[i]!=b[i]) break;
    z++;
  }
  if(z==n){
    cout<<"0\n";
  }
  else{
    for(int i=0;i<q;i++){
      swap(a[x[i]],a[y[i]]);
      rt++;
      z=0;
      if(baka==0){
        for(int j=1;j<=n;j++){
          if(a[j]!=b[j]){
            z++; break;
          }
          if(a[n+1-j]!=b[n+1-j]){
            z++;  break;
          }
        }
        if(z==0){
          nk=rt;
          baka++;
        }
      }
    }
    if(nk>=1) cout<<nk<<'\n';
    else  cout<<-1<<'\n';
  }
  return 0;
}



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

int main(){
	int m[10000], f[10000], r[10000], i, j;
	
	for(i = 0; i <= 9999; i++){
		cin >> m[i] >> f[i] >> r[i];
		if((m[i] == -1) and (f[i] == -1) and (r[i] == -1)){
			break;
		}
	}
	
	for(j = 0; j < i; j++){
		if((m[j] == -1) or (f[j] == -1) or (m[j]+f[j] < 30)){
			cout << 'F' << endl;
			continue;
		}
		else if(m[j]+f[j] >= 80){
			cout << 'A' << endl;
			continue;
		}
		else if((m[j]+f[j] >= 65) and (m[j]+f[j] < 80)){
			cout << 'B' << endl;
			continue;
		}
		else if(((m[j]+f[j] >= 50) and (m[j]+f[j] < 65)) or ((m[j]+f[j] >= 30) and (m[j]+f[j] < 50) and (r[j] >= 50))){
			cout << 'C' << endl;
			continue;
		}
		else if((m[j]+f[j] >= 30) and (m[j]+f[j] < 50)){
			cout << 'D' << endl;
			continue;
		}
	}
	
	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    int N,D;
    cin >>N>>D;

    vector<vector<int>> X(N,vector<int>(D));
    vector<int> sq;
    rep(i,N)rep(k,D) cin >> X[i][k];
    int t=1,tt=1;
    while(tt<=16000){
        tt=t*t;
        sq.push_back(tt);
        t++;
    }
    //-----------------------------------
    int bb,ans=0,x;
    rep(i,N){
        repd(k,i,N){
            bb=0;
            rep(l,D){
                x=X[i][l]-X[k][l];
                bb+= x*x;
            }
            rep(l,sq.size()){
                if(sq[l]==bb)ans++;
                if(bb<=sq[l])break;
            }
        }
    }

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

Measured memory_bytes: 256
// author : Kartikey Tewari
// date: 2020-02-09   20:47:19
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

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

    ll n,k;
    cin >> n >> k;

    ll arr[n];
    for (ll i=0;i<=n-1;i++)
    {
        cin >> arr[i];
        arr[i]=arr[i]+1;
    }

    ll sum=0;
    for (ll i=0;i<=k-1;i++)
    {
        sum=sum+arr[i];
    }

    ll max_sum=sum;
    for (ll i=0;i<=n-k-1;i++)
    {
        sum=sum-arr[i]+arr[i+k];
        max_sum=max(max_sum,sum);
    }

    cout << ((float)max_sum/2) << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

int main() {
  size_t h, w, a, b;
  scanf("%zu %zu %zu %zu", &h, &w, &a, &b);

  std::vector<std::string> res(h, std::string(w, '0'));
  for (size_t i = 0; i < b; ++i)
    for (size_t j = 0; j < a; ++j)
      res[i][j] = '1';

  for (size_t i = b; i < h; ++i)
    for (size_t j = a; j < w; ++j)
      res[i][j] = '1';

  for (auto const& s: res)
    printf("%s\n", s.c_str());
}


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

int main(){
  long long mod = 1e9 + 7;
  int x,y;cin >> x >> y;
  long long n = 1;
  if(x==y){
    n = 2;
    for(int i = 1;i<=x;i++){
      n = (n*i)%mod;
      n = (n*i)%mod;
    }
    cout<< n << endl;
  }else if(x+1==y or x==y+1){
    for(int i = 1;i<=x;i++){
      n = (n*i)%mod;
    }
    for(int i = 1;i<=y;i++){
      n = (n*i)%mod;
    }
    cout << n << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i<=a; i--)
#define INF 1e9

double dp[1 << 8][31];
int main()
{
	int n, m, p, a, b;
	while (cin >> n >> m >> p >> a >> b, n || m || p || a || b) {
		a--;
		b--;
		int t[9];
		double dist[31][31];

		REP(i, 0, n) {
			cin >> t[i];
		}
		REP(i, 0, 31) REP(j, 0, 31) {
			dist[i][j] = -1.0;
		}
		REP(i, 0, p) {
			int x, y, z;
			cin >> x >> y >> z;
			x--;
			y--;
			dist[x][y] = z;
			dist[y][x] = z;
		}

		REP(mask, 0, 1 << n) REP(i, 0, m) {
			dp[mask][i] = INF;
		}
		dp[0][a] = 0.0;

		REP(mask, 0, 1 << n) {
			REP(i, 0, m) {
				if (dp[mask][i] == INF) continue;

				REP(j, 0, n) {
					if (mask&(1 << j)) continue;

					REP(k, 0, m) {
						if (dist[i][k] != -1.0) {
							dp[mask | (1 << j)][k] = min(dp[mask | (1 << j)][k], dp[mask][i] + dist[i][k] / t[j]);
						}
					}
				}
			}
		}

		double ans = INF;
		REP(mask, 0, 1 << n) ans = min(ans, dp[mask][b]);
		if (ans == INF) printf("Impossible\n");
		else printf("%.3lf\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3220
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 5100
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
const double PI = acos(-1);

int main(){
    int N,a[110000],A=0,B=110000;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        A=max(A,a[i]);
        B=min(B,a[i]);
    }
    if(A-B>=2){
        cout<<"No"<<endl;
        return 0;
    }
    if(A==B){
        if(A==N-1 || A*2<=N) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }
    int numA=0,numB=0;
    for(int i=0;i<N;i++){
        if(a[i]==A) numA++;
        else numB++;
    }
    if(numB+1<=A && A<=numB+numA/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int G;cin>>G;
  int A=G/1000;
  int B=(G/100)%10;
  int C=(G/10)%10;
  int D=G%10;
  if(A+B+C+D==7){
    cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
  }
  else if(A+B+C-D==7){
    cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
  }
  else if(A+B-C+D==7){
    cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
  }
  else if(A+B-C-D==7){
    cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
  }
  else if(A-B+C+D==7){
    cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<'='<<7<<endl;
  }
  else if(A-B+C-D==7){
    cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<'='<<7<<endl;
  }
  else if(A-B-C+D==7){
    cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<'='<<7<<endl;
  }
  else if(A-B-C-D==7){
    cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<'='<<7<<endl;
  }
}


Measured memory_bytes: 3640
def main():
    MOD = 998244353
    N, S = list(map(int, input().split()))
    A = list(map(int, input().split()))
    dp = [[0] * (S + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i, a in enumerate(A):
        n = i + 1
        for s in range(S + 1):
            dp[n][s] += 2 * dp[n - 1][s]
            if s - a >= 0:
                dp[n][s] += dp[n - 1][s - a]
            dp[n][s] %= MOD
    print(dp[N][S])


if __name__ == '__main__':
    main()


Measured memory_bytes: 132300
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#define N_ 3010000
using namespace std;
int n, m;
map<vector<int>, int>Map;
long long F[N_], InvF[N_], Mod = 998244353;
long long T[N_];
vector<int>TP;
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r * a%Mod;
		a = a * a%Mod; b >>= 1;
	}
	return r;
}
long long Comb(long long a, long long b) {
	if (a < b || b < 0)return 0ll;
	return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
long long H(int a, int b) {
	if (a == 0 && b == 0)return 1ll;
	if (a == 0)return 0ll;
	return F[a + b - 1] * InvF[b] % Mod * InvF[a - 1] % Mod;
}
int r2 = 0;
void DFS(int a) {
	if (a == 0) {
		if (Map.count(TP))return;
		Map[TP] = 1;
		r2++;
		return;
	}
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i != j) {
				TP[i]++;
				TP[j] += 2;
				DFS(a - 1);
				TP[i]--;
				TP[j] -= 2;
			}
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	int i;
	F[0] = 1;
	for (i = 1; i < N_; i++) F[i] = F[i - 1] * i%Mod;
	InvF[N_ - 1] = Pow(F[N_ - 1], Mod - 2);
	for (i = N_ - 1; i >= 1; i--)InvF[i - 1] = InvF[i] * i%Mod;
	long long res = H(n, 3 * m);
	res = (res - n * H(n, m - 1) % Mod + Mod) % Mod;
	long long ss = 0;
	for (i = m + 1; i <= 3 * m; i++) {
		if (i > n || 3*m%2!=i%2)continue;
		long long t = Comb(n, i) * H(n, (3 * m - i)/2) % Mod;
		res = (res - t + Mod) % Mod;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 48256
#include <bits/stdc++.h>
using namespace std; 
#define endl '\n'
#define ll long long int
     
int main()
{
  int x;
  int n;
  cin>>n;
  int count=0;
  for (int i = 1; i <= n; ++i)
  {
    cin>>x;
    if (i%2!=0 && x%2!=0)
    {
      count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) cout << 0;
	else {
		ll x = 1;
		for (int i = 2 ; i <= n ; i++) x = x * i % 1000000007;
		for (int i = 2 ; i <= m ; i++) x = x * i % 1000000007;
		if (n - m) cout << x % 1000000007;
		else cout << x * 2 % 1000000007;
	}
}

Measured memory_bytes: 256
#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

using namespace std;

int main()
{
	string S;
	int N;
	cin >> N >> S;
	bool F;
	F = false;
	if (N % 2 != 0) F = true;
	for (int i = 0;i < N / 2;i++) {
		if (S.at(i) != S.at(i + N / 2)) F = true;
	}
	if (F) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

// using ll = long long;
// using P = pair<int, int>;
// using minpq = priority_queue<int, vector<int>, greater<int> >;

int main() {
    while (true) {
        string s1, s2;
        cin >> s1;
        if (s1 == ".") break;
        cin >> s2;
        size_t i=0, j=0, len = s1.size(), len2 = s2.size();
        int cnt = 0;
        while (true) {
            if (s1[i] == '"' && s2[j] == '"') {
                i++; j++;
                size_t starti = i, startj = j;
                while (s1[i] != '"') i++;
                while (s2[j] != '"') j++;
                if (s1.substr(starti, i - starti) != s2.substr(startj, j - startj)) {
                    cnt++;
                    if (cnt > 1) break;
                }
            } else if (s1[i] != s2[j]) {
                cnt = 2;
                break;
            }
            i++; j++;
            if (i == len || j == len2) {
                if ((i == len) != (j == len2)) {
                    cnt = 2;
                }
                break;
            }
        }
        if (cnt == 0) {
            cout << "IDENTICAL\n";
        } else if (cnt == 1) {
            cout << "CLOSE\n";
        } else {
            cout << "DIFFERENT\n";
        }

    }
    return 0;
}



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

using namespace std;

int n,m;
char a[120][120];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=100;++i){
		if (i&1) a[i][1]=1;
		else
			for (int j=1;j<100;++j)
				a[i][j]=1;
	}
	--n; --m;
	int x=1,y=3;
	puts("100 100");
	while (n--){
		a[x][y]=1;
		y+=2;
		if (y>100){x+=2; y=3;}
	}
	x=100,y=98;
	while (m--){
		a[x][y]=0;
		y-=2;
		if (y<1){x-=2; y=98;}
	}
	for (int i=1;i<=100;++i){
		for (int j=1;j<=100;++j)
			putchar(a[i][j]?'#':'.');
		puts("");
	}
	
	return 0;
}
			

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC129C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NM = CIN.LongArray();
            long[] A = new long[NM[1]];
            for (int i = 0; i < NM[1]; i++)
            {
                A[i] = CIN.Long();
            }

            Dictionary<long, bool> AI = new Dictionary<long, bool>();
            foreach (long l in A)
            {
                AI.Add(l, true);
            }

            long[] dp = new long[NM[0] + 1];
            dp[0] = 1;
            for (int i = 1; i <= NM[0]; i++)
            {
                if (AI.ContainsKey(i))
                {
                    dp[i] = 0;
                    continue;
                }

                dp[i] = dp[i - 1];
                if (i > 1)
                {
                    dp[i] = (dp[i] + dp[i - 2]) % 1000000007;
                }
            }

            Console.WriteLine(dp[NM[0]]);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 24928