akhauriyash/Code-Regression huggingface dataset:
import collections

n = int(input())
s = []
for _ in range(n):
    s.append(input())

l=collections.Counter(s).most_common()
i=0
ans=[l[0][0]]
if len(l)>2:
    while i<len(l)-1 and l[i][1]==l[i+1][1]:
        ans.append(l[i+1][0])
        i+=1
ll=sorted(ans)
for i in range(len(ll)):
    print(ll[i])

Measured memory_bytes: 45044
import numpy as np
data = input()
a = np.int64(data.split(' ')[0])
b = np.int64(data.split(' ')[1])
k = np.int64(data.split(' ')[2])

a1 = np.max([0,a-k])
b1 = np.max([b - max((k-a),0),0])

print(str(a1) + ' ' + str(b1))

Measured memory_bytes: 21512
#include<stdio.h>

#define MAX 100
char farm[MAX][MAX];

void divide(int i, int j, int H, int W, char moji)
{
    if( farm[i][j] == moji ){
        farm[i][j] = '+';
        if( j + 1 < W ) divide(i, j + 1, H, W, moji);
        if( i + 1 < H ) divide(i + 1, j, H, W, moji);
        if( j - 1 >= 0 )divide(i, j - 1, H, W, moji);
        if( i - 1 >= 0 )divide(i - 1, j, H, W, moji);
    }
}

int main()
{
    int H, W, i, j, cnt;
    while(1){
        cnt = 0;
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;

        for(i = 0; i < H; i++){
            scanf("%s", farm[i]);
        }
        for(i = 0; i < H; i++ ){
            for(j = 0; j < W; j++){
                if(farm[i][j] == '+') continue;
                cnt++;
                divide(i, j, H, W, farm[i][j]);
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 2160
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    int a = read(), b = read(), c = read();
    cout << max(c - (a - b), 0);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	int r, d, x; cin >> r >> d >> x;
	ll ans = x;
	rep(i, 10) {
		ans = ans * r - d;
		cout << ans << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) {
            System.out.println("Yes");
        } else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10) && (y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  int n, q;
  map<int, int> a;
  cin >> n;
  ll sum = 0;
  rep(i, n)
  {
    int x;
    cin >> x;
    a[x]++;
    sum += x;
  }
  cin >> q;

  rep(i, q)
  {
    int b, c;
    cin >> b >> c;

    int b_count = a[b];
    sum += (c - b) * b_count;
    cout << sum << endl;
    a[b] = 0;
    a[c] += b_count;
  }
  return 0;
}


Measured memory_bytes: 7960
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 200005
using namespace std;
int n,a[MN],b[MN],ans,x[30][MN],y[MN];
long long sa[MN][30],sb[MN][30];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)for(int j=27;j>=0;j--)if(a[i]&(1<<j))sa[j][1]++;
	for(int i=1;i<=n;i++)for(int j=27;j>=0;j--)if(b[i]&(1<<j))sb[j][1]++;
	for(int j=0;j<=27;j++)sa[j][0]=n-sa[j][1],sb[j][0]=n-sb[j][1];
	for(int j=0;j<=27;j++)if((sa[j][1]*sb[j][0]+sa[j][0]*sb[j][1])%2==1)ans^=(1<<j);
	for(int j=0;j<=27;j++)for(int i=1;i<=n;i++)x[j][i]=a[i]&((1<<(j+1))-1);
	for(int i=0;i<=27;i++)sort(x[i]+1,x[i]+n+1);
	for(int j=1;j<=28;j++){
        for(int i=1;i<=n;i++){
            y[i]^=(1<<(j-1))&b[i];
            int t=lower_bound(x[j-1]+1,x[j-1]+n+1,(1<<j)-y[i])-x[j-1];
            ans^=(((n-t+1)%2)<<j);
        }
	}printf("%d\n",ans);
}


Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
int n;
const int N = 1e5;
int a[N];
int dp[N];
int main(int argc, char const *argv[])
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; ++i)
	{
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) {
    if(b==0) return a;
    else return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class CMarch {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;in>>n;
        vector<ll> cnt(5);
        rep(i,n){
            string s;
            in>>s;
            if(s[0]=='M') ++cnt[0];
            else if (s[0]=='A') ++cnt[1];
            else if (s[0]=='R') ++cnt[2];
            else if (s[0]=='C') ++cnt[3];
            else if (s[0]=='H') ++cnt[4];
        }
        ll ans=0;
        for(int i=0; i<5; ++i){
            for(int j=i+1; j<5; ++j){
                for(int k=j+1; k<5; ++k){
                    ans+=cnt[i]*cnt[j]*cnt[k];
                }
            }
        }
        out<<ans<<endl;
	}
};


int main() {
	CMarch solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
    using namespace std;
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);

    for(int i=0;i<N;i++)cin >> V[i];
    for(int i=0;i<N;i++)cin >> C[i];
    int ans = 0;
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>0){
            ans += (V[i]-C[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    x, k, d = map(int, input().split())
    if x == 0:
        if k % 2 == 0:
            print(0)
        else:
            print(d)
    elif x > 0:
        minmove = x // d
        if minmove > k:
            print(x-k*d)
        else:
            if (k-minmove)%2 == 0:
                print(x-minmove*d)
            else:
                print(abs(x-(minmove+1)*d))
    else:
        minmove = abs(x)//d
        if minmove > k:
            print(abs(x+k*d))
        else:
            if (k-minmove)%2 == 0:
                print(abs(x+minmove*d))
            else:
                print(abs(x+(minmove+1)*d))
resolve()

Measured memory_bytes: 9212
N = int(input())

time = 0
visited = [0, 0]
result = []

for i in range(N):
    t, *xy = map(int, input().split())
    diff_time = t - time
    diff_dist = sum([abs(xy[i] - visited[i]) for i in range(2)])
    if (diff_dist <= diff_time) & (((diff_time - diff_dist) % 2)==0):
        result.append(True)
    else:
        result.append(False)
    time = t
    visited = xy

print("Yes") if all(result) else print("No")

Measured memory_bytes: 3916
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};
#define pb push_back 

int main(){
    int h,w; cin >> h >> w;
    vector<vector<int>> a(h+2,vector<int> (w+2));
    rep(i,h+2) rep(j,w+2) a[i][j] = -1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> a[i][j];
        }
    }

    vector<int> ansy,ansx,ansxd,ansyd;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i][j] % 2 != 0 && a[i][j] > 0){
                rep(k,2){
                    if(a[i+my2[k]][j+mx2[k]] >= 0){
                        a[i+my2[k]][j+mx2[k]]++;
                        a[i][j]--;
                        ansy.push_back(i);
                        ansx.push_back(j);
                        ansyd.push_back(i+my2[k]);
                        ansxd.push_back(j+mx2[k]);
                        break;
                    }
                }
            }
        }
    }

    int n = ansy.size();
    cout << n << endl;
    rep(i,n){
        cout << ansy[i] << " " << ansx[i] << " " << ansyd[i] << " " << ansxd[i] << endl; 
    }
}

Measured memory_bytes: 5224
#include<cstdio>
#include<cstring>
int main(){
    char s[10];
    scanf("%s",s);
    int len=strlen(s);
    if(len==2)
printf("%s\n",s);
else printf("%c%c%c\n",s[2],s[1],s[0]);
    return 0;
}

Measured memory_bytes: 128
import math

def main():
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    j = 0
    for i in range(N):
        if A[i] == 1:
            j = i
            break
    min_v = float('inf')
    for i in range(j, j-K, -1):
        v = 1 + math.ceil(max(i, 0)/(K-1)) + math.ceil(max(0, N-K-i)/(K-1))
        min_v = min(min_v, v)
    return min_v

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 13812
#include<iostream>

int main(){
  using namespace std;
  long long k,x;
  cin >> k >> x;
  long long start = x - k + 1;
  long long end = x + k - 1;
  if(start < -1000000)start = -1000000;
  if(end > 1000000)end = 1000000;
  for(int index = start;index <= end;index++)
    cout << index << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll i=1,j,k,n,a,c,b,r,p,cnt=0,s=1;
    cin>>n>>k;
    vector<ll>v;
    for(i=0;i<n;i++)
    {
        cin>>c;
        v.push_back(c);
    }
    if(k>=n)
    {
        cout<<0<<endl;
        return 0;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(i=k;i<n;i++)
    {
        cnt+=v[i];
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 2420
n = int(input())
n_1000 = n // 1000
n_100 = (n // 100) % 10
n_10 = (n // 10) % 10
n_1 = n % 10
if n_1000 == n_100 == n_10 or n_100 == n_10 == n_1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import sys
s = input()
t = input()
tset = set(t)
slen = len(s)
if len(tset - set(s)) != 0:
    print(-1)
    sys.exit()
s2t = [i - ord('a') for i in (s + s).encode('ascii')]
lut = [[-1 for _ in range(slen)] for _ in range(26)]
for c in tset:
  b = ord(c) - ord('a')
  j = 0
  for i in range(slen * 2 - 1, -1, -1):
    if s2t[i] == b:
      j = 0
    else:
      j += 1
    if i < slen:
      lut[b][i] = j
p = 0
for c in t:
  b = ord(c) - ord('a')
  p += lut[b][p % slen] + 1
print(p)

Measured memory_bytes: 104684
#ifndef HOME
#pragma GCC optimize "-O3"
#endif

#include <bits/stdc++.h>

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;

pair<int, int> dir(char c) {
    if (c == 'L') {
        return {0, -1};
    } else if (c == 'R') {
        return {0, 1};
    } else if (c == 'U') {
        return {-1, 0};
    } else {
        return {1, 0};
    }
}

bool win(int n, int x, vector<pair<int, int> >& d) {
    for (int f : {-1, 1}) {
        int xx = x;
        for (const auto& g : d) {
            if (g.first == f) {
                xx += g.first;
            }
            if (xx <= 0 || xx > n) {
                return true;
            }
            if (g.second != f && xx + g.second > 0 && xx + g.second <= n) {
                xx += g.second;
            }
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    int sx, sy;
    cin >> sx >> sy;
    vector<pair<int, int> > gx, gy;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
        auto d1 = dir(s[i]), d2 = dir(t[i]);
        gx.emplace_back(d1.first, d2.first);
        gy.emplace_back(d1.second, d2.second);
    }

    if (win(h, sx, gx) || win(w, sy, gy)) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}



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

int main()
{
	int n;
	cin >> n;
	auto cnt = vector<long long int>(5);
	for(auto i = 0; i < n; ++i){
		string s;
		cin >> s;
		switch(s[0]){
			case 'M': ++cnt[0]; break;
			case 'A': ++cnt[1]; break;
			case 'R': ++cnt[2]; break;
			case 'C': ++cnt[3]; break;
			case 'H': ++cnt[4]; break;
		}
	}
	long long int ans = 0;
	auto calc = [&cnt, &ans](auto calc, int l, int m, long long int a) -> void {
		if(l == 3){
			ans += a;
			return;
		}
		for(auto i = m; i < 5; ++i){
			calc(calc, l + 1, i + 1, a * cnt[i]);
		}
	};
	calc(calc, 0, 0, 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



ll dp[3010][3010];
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 101010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 101010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------

void add(ll &a, ll b)
{
    a = (a+b)%MOD;
}

int main()
{
    init();
    int n;
    cin >> n;
    map<int, int> m;
    int l, r;
    for(int i = 0; i <= n; i++)
    {
        int a;
        cin >> a;
        if(m.count(a) == 0)
        {
            m.insert(make_pair(a, i));
        }
        else
        {
            l = m[a];
            r = n - i;
        }
    }
    for(int k = 1; k <= n+1; k++)
    {
        ll ans = C(n+1, k);
        ans = ans - C(l+r, k-1);

        cout << (ans+MOD) % MOD << endl;
    }
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

bool travel(ll dt, ll dx, ll dy){
  if(dt >= dx + dy)if((dt - dx - dy) % 2 == 0) return true;
  return false;
}

int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  ll odd = 0;
  vrep(i, a) if(i % 2 == 1) odd++;
  cout << (odd % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1024
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

void solve(){
    int x,n,a;
    cin>>x>>n;
    mi m;
    for(int i=0;i<n;i++) cin>>a, m[a]++;
    int mn = inf, val = -11;
    for(int i=-10;i<=110;i++){
        if(m.count(i)) continue;
        if(abs(i-x) < mn){
            mn = abs(i-x);
            val = i;
        }
    }
    cout<<val<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int price;
int coins[4];
int amounts[4] = {10, 50, 100, 500};

int calc_coins(int x) {
    int ret = 0;
    for (int j = 3; j >= 0; --j) {
        ret += x / amounts[j];
        x %= amounts[j];
    }
    return ret;
}

void solve() {
    int ans[4];
    int min_coins = 1 << 29;
    int init_coins = coins[0] + coins[1] + coins[2] + coins[3];
    for (int j = 0; j <= 20; ++j) if (j <= coins[0]) {
        for (int k = 0; k <= 20; ++k) if (k <= coins[1]) {
            for (int l = 0; l <= 20; ++l) if (l <= coins[2]) {
                for (int m = 0; m <= 20; ++m) if (m <= coins[3]) {
                    int pay_coins = j + k + l + m;
                    int pay = j * amounts[0] + k * amounts[1] + l * amounts[2] + m * amounts[3];
                    if (pay >= price) {
                        int change = pay - price;
                        int change_coins = calc_coins(change);

                        if (init_coins - pay_coins + change_coins < min_coins) {
                            min_coins = init_coins - pay_coins + change_coins;
                            ans[0] = j; ans[1] = k; ans[2] = l; ans[3] = m;
                        }
                    }
                }
            }
        }
    }

    for (int j = 0; j < 4; ++j) {
        if (ans[j] > 0) {
            cout << amounts[j] << ' ' << ans[j] << endl;
        }
    }
}

int main() {
    bool first = true;
    while (true) {
        cin >> price;
        if (price == 0) return 0;
        if (!first) cout << endl;
        for (int j = 0; j < 4; ++j) cin >> coins[j];
        solve();
        first = false;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll h,w,m;
    cin>>h>>w>>m;
    vector<ll> t_rows(h + 1, 0);
    vector<ll> t_cols(w + 1, 0);
    ll maxi_r = -1, maxi_c = -1;
    map< pi, int>dict;
    for (ll i = 0; i < m; i++)
    {
        ll a,b;
        cin>>a>>b;
        t_rows[a]++;
        maxi_r = max(maxi_r, t_rows[a]);
        t_cols[b]++;
        maxi_c = max(maxi_c, t_cols[b]);
        dict[make_pair(a,b)] = 1;
    }
    vector<ll> r,c;
    for(ll i=1; i<=w; i++)
    {
        if(t_cols[i] == maxi_c)
            c.push_back(i);
    }
    for(ll i=1; i<=h; i++)
    {
        if(t_rows[i] == maxi_r)
            r.push_back(i);
    }
    ll ans = maxi_c + maxi_r;
    for(ll i=0; i<r.size(); i++)
    {
        for (ll j = 0; j < c.size(); j++)
        {
            if(!dict[make_pair(r[i], c[j])])
            {
                cout<<ans<<'\n';
                return 0;
            }
        }    
    }
    cout<<ans - 1<<'\n';
}

Measured memory_bytes: 35036
x, n = map(int, input().split())
p = list(map(int, input().split()))

nearest = x
sub = 0

if p:
    dets = [i == x for i in p]
    hit = any(dets)
    sub += 1
    while hit:
        nearest = x - sub
        dets = [i == nearest for i in p]
        hit = any(dets)
        if not hit:
            break
        nearest += 2 * sub
        dets = [i == nearest for i in p]
        hit = any(dets)
        if not hit:
            break
        sub += 1

print(nearest)


Measured memory_bytes: 9208
from collections import Counter
n = int(input())
judges = [input() for _ in range(n)]
c_judges = Counter(judges)
print('AC x ' + str(c_judges['AC']))
print('WA x ' + str(c_judges['WA']))
print('TLE x ' + str(c_judges['TLE']))
print('RE x ' + str(c_judges['RE']))


Measured memory_bytes: 16612
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

x,y = readInts()

for i in range(0,x+1):
	t = i
	k = x-i
	if t*2+k*4==y:
		print("Yes")
		exit()

print("No")

Measured memory_bytes: 9652
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    s64 n, d;
    cin >> n >> d;
    vector<s64> x(n);
    vector<s64> y(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }

    s64 count = 0;
    for(int i = 0; i < n; i++)
    {
        if(x[i] * x[i] + y[i] * y[i] <= d * d)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 6424
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)

for i in range(n, 0, -1):
    x = 0
    for j in range(i, n + 1, i):
        x ^= b[j]
    if x != a[i]:
        b[i] = 1

print(sum(b))
for i in range(1, n + 1):
    if b[i] == 1:
        print(i)

Measured memory_bytes: 7088
/*
*         ****FOX****
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <utility>
#include <list>
#include <cstdio>
#include<forward_list>
#include<algorithm>
#include<string>
#define Omar_Hafez ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main()
{
    Omar_Hafez
    int n, k,x,sum=0; cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); }
    sort(v.begin(), v.end());
    for (int i = 0; i < k; i++)  sum += v[i];
    return cout<<sum,0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,y=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    if(A.at(i)!=i+1){
      y++;
    }
  }
  if(y<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A.sort()
B.sort()

if n%2 == 1:
    ans = B[n//2]-A[n//2]+1
else:
    ans = B[n//2-1]+B[n//2]-(A[n//2-1]+A[n//2])+1
print(ans)


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


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

  vl cnt(26);
  rep (i, n) {
    cnt[s[i] - 'a']++;
  }

  ll ans = 1;
  rep (i, 26) {
    ans = ans * (cnt[i] + 1) % MOD;
  }
  cout << (ans - 1 + MOD) % MOD << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
 
    int main(){
     
		int a,b,c,d,e;

		b=0;
		d=0;
		e=0;

		for(a=1;a<10;a++){

			b=a;

			for(c=1;c<10;c++){

				d=c;

				e=b*d;

				printf("%dx%d=%d\n",b,d,e);

			}
		}
		return 0;
	}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
#define N 10001
int n,a,b;

bool enough(vl c,ll t);

int main(){
	int i,j;
	cin>>n>>a>>b;
	vl h(n);
	ll sum=0;
	loop(i,0,n){
		cin>>h[i];
		sum+=h[i];
	}
	sort(h.begin(),h.end());
	reverse(h.begin(),h.end());
	ll left=1,right=inf;
	while(left<right){
		ll t=(left+right)/2;
		if(enough(h,t)){
			right=t;
		}else{
			left=t+1;
		}
	}
	cout<<left<<endl;
}

bool enough(vl c,ll t){
	int i,j;
	loop(i,0,n){
		c[i]-=t*b;
	}
	j=0;
	ll cnt=0;
	loop(i,0,n){
		if(c[i]>0){
			if(c[i]%(a-b)==0){
				cnt+=c[i]/(a-b);
			}else{
				cnt+=(c[i]/(a-b)+1);
			}
		}else{
			break;
		}
	}
	if(cnt<=t){
		return true;
	}else{
		return false;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator it
using namespace std;
map<int,int>mp;
int mx;
int main()
{
    int n;
    scanf("%d",&n);
    ff(i,1,n)
    {
        int now;
        scanf("%d",&now);
        mp[now]++;
        mp[now-1]++;
        mp[now+1]++;
        mx=max(mx,mp[now+1]);
        mx=max(mx,mp[now-1]);
        mx=max(mx,mp[now]);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005],c[100005],d[100005];
int main()
{
     ios::sync_with_stdio(false);
     int A,B,M,x,y,n;
     cin>>A>>B>>M;
     for(int i=1;i<=A;i++)
        cin>>a[i],c[i]=a[i];
     for(int i=1;i<=B;i++)
        cin>>b[i],d[i]=b[i];
     sort(c+1,c+A+1);
     sort(d+1,d+B+1);
     int sum=c[1]+d[1];
     for(int i=1;i<=M;i++)
     {
         cin>>x>>y>>n;
         sum=min(a[x]+b[y]-n,sum);
     }
     cout<<sum<<endl;
     return 0;
}


Measured memory_bytes: 1792
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	long H, N;
	std::vector<long> A;
	std::cin >> H >> N;
	A.resize(N);
	for (auto& a : A)
		std::cin >> a;
	
	long Asum = 0;
	for (auto a : A)
		Asum += a;
	if (Asum >= H)
		std::cout <<"Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int N[]={0,1,5,4},E[]={0,3,5,2},S[]={0,4,5,1},W[]={0,2,5,3},R[]={3,1,2,4};
class Dice{
public:
	int num[6];
	void turn(char key){
		for(int i=0;i<3;++i){
			if(key=='W'){
				swap(num[W[i]],num[W[i+1]]);
			}else if(key=='N'){
				swap(num[N[i]],num[N[i+1]]);
			}else if(key == 'E'){
				swap(num[E[i]],num[E[i+1]]);
			}else if(key=='S'){
				swap(num[S[i]],num[S[i+1]]);
			}else{
				swap(num[R[i]],num[R[i+1]]);
			}
		}
	}
};
bool operator==(Dice&a,Dice&b){
	for(int i=0;i<6;++i){
		if(a.num[i]!=b.num[i]){
			return false;
		}
	}
	return true;
}
bool check(Dice A,Dice B){
	for(int i=0;i<4;++i){
		if(A==B)return true;
		A.turn('R');
	}
	return false;
}
int main(){
	Dice A,B;
	for(int i=0;i<6;++i){
		cin>>A.num[i];
	}
	for(int i=0;i<6;++i){
		cin>>B.num[i];
	}
	bool flag = false;
	string str = "NNNNENNNN";
	for(int i=0;i<str.size();++i){
		flag |= check(A,B);
		A.turn(str[i]);	
	}
	cout<<(flag?"Yes":"No")<<endl;
	return 0;
}



Measured memory_bytes: 3228
# n,a,b = map(int,input().split())
# ans = 0;
# for i in range(1,n+1):
#     sum = 0;
#     x = i;
#     while x:
#         sum += int(x%10);
#         x/=10;
#     if a <= sum <= b:
#         ans+=i;
# print("%d" % (ans) );

n,a,b = map(int,input().split())
ans = 0;
for i in range(n+1):
    str_i = str(i)
    sum = 0;
    for x in str_i:
        sum += int(x)
    if a <= sum <= b:
        ans+=i;
print(ans)

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

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for(int j = 0 ; j < 3 ; j++){
      cin >> c.at(i).at(j); 
    }  
  }
  
  vector<int> a(3), b(3);
  a.at(0) = 0;
  for (int i = 0; i < 3; i++) b.at(i) = c.at(0).at(i);
  for (int i = 1; i < 3; i++) a.at(i) = c.at(i).at(0) - b.at(0);
  
  int res = 0;
  for ( int i = 0; i < 3; i++){
    for( int j = 0; j < 3; j++){
      if(a.at(i) + b.at(j) == c.at(i).at(j))res++;
    }
  } 
  if ( res == 9 ) cout << "Yes";
  else cout << "No"; 
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(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; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k;
    cin>>n>>k;
    vector<ll> freq(n+1);
    for(ll i=0;i<k;++i)
    {
        ll d;
        cin>>d;
        while(d--)
        {
            ll x;
            cin>>x;
            freq[x]++;
        }

    }
    ll co = 0;
    for(ll i=1;i<=n;++i) if(freq[i] == 0) ++co;

    cout<<co<<endl;
}

Measured memory_bytes: 3664
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

sum = 1
ok = true
for r in 0...n
    l = r - k
    next if l < 0

    if a[l] < a[r]
        puts "Yes"
    else
        puts "No"
    end
end



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

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

  if (a-b==b-c) {
    cout << "YES" << endl; 
  }
  else {
    cout << "NO" << endl;
  }
  
return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
set<int>S;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||c+b==a)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


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

template<class T = int, class U = int>
class SlideMin {
    struct Pair {
        T index;
        U value;
        Pair(){};
        Pair(T index, U value): index(index), value(value) {};
    };

    private:
        deque<Pair> que;
        T length;
    public:
        SlideMin(T length) {
            this->length = length;
        }

        Pair top() {
            return this->que.front();
        }

        void update(T index, U value) {
            while (!this->que.empty() && this->que.back().value >= value) {
                this->que.pop_back();
            }
            this->que.emplace_back(index, value);

            if(this->que.front().index == index - this->length) this->que.pop_front();
        }
};

#define FOR(i, n) for (int i = 0LL; i < int(n); i++)

long long N, X;
vector<int> A;
vector<int> B;

long long sol(long long n) {
    SlideMin<int, long long> que(n + 1);
    vector<long long> ret(N, 10000000000);

    FOR(i, 2 * N) {
        int b = B[i];
        que.update(i, b);
        ret[i % N] = min(ret[i % N], que.top().value);
    }

    long long res = 0;
    for(long long n: ret) {
        res += n;
    }
    return res + n * X;
}

int main(void) {
    cin >> N >> X;

    A.resize(N);
    B.resize(N * 2);
    FOR(i, N) {
        cin >> A[i];
        B[i] = A[i];
        B[i + N] = A[i];
    };

    long long ans = 0;
    for(int a: A) {
        ans += a;
    }

    FOR(i, N) {
        ans = min(ans, sol(i));
    }

    cout << ans << endl;

    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> dp(100010, 1e18);
  dp[0] = 0;
  for (ll i = 1; i <= 100000; ++i) {
    dp[i] = min(dp[i], dp[i-1]+1);

    ll x = 6;
    while (x <= i) {
      dp[i] = min(dp[i], dp[i-x]+1);
      x *= 6;
    }

    x = 9;
    while (x <= i) {
      dp[i] = min(dp[i], dp[i-x]+1);
      x *= 9;
    }
  }

  cout << dp[n] << endl;
   
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

vector<bool> pfs(1000001, false);

template<class T>
bool PrimeFactorization(T n) {
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) {
            if (pfs[i]) return false;
            pfs[i] = true;
        }
    }
    if (n != 1) {
        if (pfs[n]) return false;
        pfs[n] = true;
    } 
    return true;
}

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    int g = 0;
    bool pairwise = true;
    REP(i, 0, N) {
        if (!PrimeFactorization(A[i])) pairwise = false;
        g = gcd(g, A[i]);
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

ll a, b, c, d, e, f, g, h, i, k, l;
ll N, H, W;
bool r_white[100];
bool c_white[100];
char grid[100][100];

void input()
{
    cin >> H >> W;

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

void solve()
{
    bool is_white;
    for (int i = 0; i < H; i++)
    {
        is_white = true;
        for (int j = 0; j < W; j++)
        {
            if (grid[i][j] == '#')
            {
                is_white = false;
            }
        }
        if (is_white)
            r_white[i] = true;
    }

    for (int i = 0; i < W; i++)
    {
        is_white = true;
        for (int j = 0; j < H; j++)
        {
            if (grid[j][i] == '#')
            {
                is_white = false;
            }
        }
        if (is_white)
            c_white[i] = true;
    }
}

int main()
{
    input();
    solve();

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (r_white[i] || c_white[j])
            {
                continue;
            }
            cout << grid[i][j];
        }
        if (!r_white[i])
            cout << '\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int N, M;
    cin >> N >> M;
    int ans = 0;
    if (N >= 2)
    {
        ans += N * (N - 1) / 2;
    }
    if (M >= 2)
    {
        ans += M * (M - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256