akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static final int INF = (int)Math.pow(10, 9);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }
        if (!p.contains(X)) {
            System.out.println(X);
        } else {
            int dif = 1;
            while (p.contains(X + dif) && p.contains(X - dif)) {
                dif++;
            }
            int opt1 = INF;
            if (!p.contains(X + dif)) {
                opt1 = X + dif;
            }
            int opt2 = INF;
            if (!p.contains(X - dif)) {
                opt2 = X - dif;
            }
            System.out.println(Math.min(opt1, opt2));
        }
        sc.close();
    }
}

Measured memory_bytes: 35920
h, w = map(int, input().split())
mp = [input() for _ in range(h)]

points = {}
for y in range(h):
  for x in range(w):
    c = mp[y][x]
    if c != ".":
      if c not in points:
        points[c] = [(x, y)]
      else:
        points[c].append((x, y))

keys = []
preventer = {}
for c, ps in points.items():
  keys.append(c)
  p1, p2 = ps
  x1, y1 = p1
  x2, y2 = p2
  if x1 == x2:
    s = set()
    for y in range(y1 + 1, y2):
      s.add(mp[y][x1])
    preventer[c] = [s]
    continue

  if y1 == y2:
    s = set()
    for x in range(x1 + 1, x2):
      s.add(mp[y1][x])
    preventer[c] = [s]
    continue

  s1 = set()
  s2 = set()
  if x1 < x2:
    for x in range(x1 + 1, x2):
      s1.add(mp[y1][x])
    for y in range(y1, y2):
      s1.add(mp[y][x2])
    for x in range(x1, x2):
      s2.add(mp[y2][x])
    for y in range(y1 + 1, y2):
      s2.add(mp[y][x1])

  else:
    for x in range(x2, x1):
      s1.add(mp[y1][x])
    for y in range(y1 + 1, y2):
      s1.add(mp[y][x2])
    for x in range(x2 + 1, x1):
      s2.add(mp[y2][x])
    for y in range(y1 + 1, y2 + 1):
      s2.add(mp[y][x1])
  preventer[c] = [s1, s2]

removal = {".":True}
for key in keys:
  removal[key] = False
ans = 0
while True:
  remove_lst = []
  for key in keys:
    for s in preventer[key]:
      if not s:
        break
      
      for c in s:
        if not removal[c]:
          break
      else:
        removal[key] = True
        remove_lst.append(key)
        ans += 2
        break
  
  if not remove_lst:
    break

  for rem in remove_lst:
    keys.remove(rem)

print(ans)


Measured memory_bytes: 5904
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;

LL n,d;
LL col[2][500005] = {0};
LL v[4][500005],cnt[4] = {0};

LL id(LL x,LL y){ return x * n + y + 1; } // (x,y) -> id
LL getx(LL x){ return (x - 1) / n; } // id(x,y) -> x
LL gety(LL y){ return (y - 1) % n; } // id(x,y) -> y

void dfs(LL u,LL idd){
	LL tx = getx(u),ty = gety(u);
	for(LL dy,dx = 0;dx <= n;dx ++){
		if(dx * dx > d) continue;
		dy = sqrt(d - dx * dx);
		if(dx * dx + dy * dy != d) continue;
		
		if(tx + dx < n && ty + dy < n)
			if(col[idd][id(tx + dx,ty + dy)] == -1) { col[idd][id(tx + dx,ty + dy)] = 1 - col[idd][u]; dfs(id(tx + dx,ty + dy),idd); }
		if(tx + dx < n && ty - dy >= 0)
			if(col[idd][id(tx + dx,ty - dy)] == -1) { col[idd][id(tx + dx,ty - dy)] = 1 - col[idd][u]; dfs(id(tx + dx,ty - dy),idd); }
		if(tx - dx >= 0 && ty + dy < n)
			if(col[idd][id(tx - dx,ty + dy)] == -1) { col[idd][id(tx - dx,ty + dy)] = 1 - col[idd][u]; dfs(id(tx - dx,ty + dy),idd); }
		if(tx - dx >= 0 && ty - dy >= 0)
			if(col[idd][id(tx - dx,ty - dy)] == -1) { col[idd][id(tx - dx,ty - dy)] = 1 - col[idd][u]; dfs(id(tx - dx,ty - dy),idd); }
	}
}

int main(){
	memset(col,-1,sizeof(col));
	cin >> n; n <<= 1;
	cin >> d;
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			if(col[0][id(i,j)] == -1){ col[0][id(i,j)] = 1; dfs(id(i,j),0); }
	cin >> d;
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			if(col[1][id(i,j)] == -1){ col[1][id(i,j)] = 1; dfs(id(i,j),1); }
	/*
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			cout << col[0][id(i,j)] << (j == n - 1 ? '\n' : ' ');
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			cout << col[1][id(i,j)] << (j == n - 1 ? '\n' : ' ');
	*/
	for(LL i = 1;i <= id(n - 1,n - 1);i ++){
		LL co = col[0][i] + col[1][i] * 2;
		v[co][++ cnt[co]] = i;
	}
	for(LL i = 0;i < 4;i ++){
		if(cnt[i] >= n * n / 4){
			for(LL j = 1;j <= n * n / 4;j ++) cout << getx(v[i][j]) << ' ' << gety(v[i][j]) << '\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 56704
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    ll N;
    cin >> N;
    ll a = 1;
    ll b = N;

    ll i = 1;
    ll ans = LLONG_MAX;
    while(i<=sqrt(N)){
        if(N % i == 0){
            ll b = N / i;
            ll step = (b-1) + (i-1);
            if(step<ans){
                ans = step;
            }
        }
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  if(n >= 64)cout << 64 << endl;
  else if(n >= 32)cout << 32 << endl;
  else if(n >= 16)cout << 16 << endl;
  else if(n >= 8)cout << 8 << endl;
  else if(n >= 4)cout << 4 << endl;
  else if(n >= 2)cout << 2 << endl;
  else cout << 1 << endl;
}

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

int main(){
    int n;
    cin >> n;
    bool result = false;
    while(n > 0){
        if(n%10 == 7){
            result = true;
            break;
        }
        else{
            n/=10;
        }
    }
    if(result)
        cout << "Yes" << "\n";
    else{
        cout << "No" << "\n";
    }
    return 0;
}   

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<ll> A(n);
	for(int i = 0; i < n;i++){
		cin>>A[i];
	}
	
	ll sum = 0;
	ll sum1 = A[0] + A[1];
	ll sum2 = -A[0] - A[1];
	for(int i = 2; i < n; i++){
		ll temp1 = sum1;
		ll temp2 = sum2;
		sum1 = max(temp1 + A[i],temp2 + A[i]);
		sum2 = max(temp1 - 2*A[i-1] - A[i],temp2 + 2*A[i-1] - A[i]);
		//cout<<i<<" "<<sum1<<" "<<sum2<<endl;
	}
	sum = max(sum1,sum2);
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto i = (m).begin(); i != (m).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> 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(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  vector<ll> A;
  cin >> N;
  REP(i, N) {
    ll p = 0;
    cin >> p;
    A.push_back(p);
  }
  sort(ALL(A));
  ll s = 0;
  REP(i, N - 1) { s += A[i]; }
  s += A[N - 1] / 2;
  cout << s << endl;

  return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

vector<int>E[2000];
int d[2000][2000];
int prv[2000][2000];

void bfs(int v){
	d[v][v]=0;
	prv[v][v]=-1;
	queue<int>que;
	que.push(v);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int u:E[p]){
			if(d[v][u]==-1){
				d[v][u]=d[v][p]+1;
				prv[v][u]=p;
				que.push(u);
			}
		}
	}
}
int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
	}
	memset(d,-1,sizeof(d));
	rep(i,n)bfs(i);
	int idx=-1,idy=-1;
	int Min=INF;
	rep(i,n)rep(j,n){
		if(i==j)continue;
		if(d[i][j]!=-1&&d[j][i]!=-1&&Min>d[i][j]+d[j][i]){
			Min=d[i][j]+d[j][i];
			idx=i;
			idy=j;
		}
	}
	if(Min==INF){
		puts("-1");return 0;
	}
	int x=idy;
	vector<int>v{idy};
	while(x!=idx){
		x=prv[idx][x];
		v.push_back(x);
	}
	while(x!=idy){
		x=prv[idy][x];
		if(x!=idy)v.push_back(x);
	}
	cout<<v.size()<<endl;
	reverse(v.begin(),v.end());
	for(int i:v){
		printf("%d\n",i+1);
	}
}

Measured memory_bytes: 25472
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  long long ans = 0;
  cin >> N;

  vector<vector<int>> a(N, vector<int>(26));
  vector<string> s(N);
  for(int i = 0; i < N; i++){
    cin >> s[i];

    //どの英字が何回使われているかカウント
    for(int j =0 ; j < s[i].size(); j++){
      a[i][s[i][j] + 'A'- 162]++;
    }
  }

  sort(a.begin(), a.end());
    // for(int j =0 ; j < s[0].size(); j++){
    //   cout << a[0][j] << ", " << a[1][j] 
    //     << ", " << a[2][j]
    //     << ", " << a[3][j]
    //     << ", " << a[4][j]
    //     << endl;
    // }
    long long cntn = 0;
  for(int i = 1; i < N; i++){
    if(a[i-1] == a[i]){
      // ans++;
      cntn ++;
    }else{
      if(cntn>0){
        if(cntn == 1){
          ans++;
        } else{
          ans += (cntn*(cntn+1))/2;
        }
      }
      cntn = 0;
    }
  }
  
  if(cntn == 1){
    ans++;
  } else{
    ans += (cntn*(cntn+1))/2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 20608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N, K;
        int[] A;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            K = in.nextInt();
            A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            for (int i = 0; i < K; i++) {
                int[] imos = new int[N + 2];
                for (int j = 0; j < N; j++) {
                    imos[Math.max(0, j + 1 - A[j])] += 1;
                    imos[Math.min(N + 1, j + 2 + A[j])] -= 1;
                }
                int v = 0;
                for (int j = 0; j < N + 2; j++) {
                    v += imos[j];
                    if (j >= 1 && j <= N) {
                        A[j - 1] = v;
                    }
                }

                boolean flag = true;
                for (int j = 0; j < N; j++) {
                    if (A[j] != N) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    break;
                }
            }

            for (int i = 0; i < N; i++) {
                if (i != 0) {
                    out.print(" ");
                }
                out.print(A[i]);
            }
            out.println();
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

using namespace std;

int gcd( int x, int y){
if(x==0) return y;
return gcd(y%x, x);
}

int main(){
  int n;
  int  mae=0;
    cin>>n;
  int a[n];
 
    for(int i=0;i<n;i++){
      cin>>a[i];}
  for(int i=0;i<n-1;i++){
    if(i==0){mae=a[i];}   
   mae= gcd(mae,a[i+1]);}
  
  cout<<mae<<endl;
      
 
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
const ll mod = 1e9+7;
using modint = ModInt< mod >;


int N;
string S;
void input(){
  #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N >> S;
}

modint dp[3010][3010];
modint acc[3010][3010];

int solve(){
  memset(dp,0,sizeof(dp));
  memset(acc,0,sizeof(acc));
  for (int i = 0; i < N; i++)
  {
    dp[0][i] = 1;
  }
  // dp[0][0] = 1;
  for (int i = 0; i < N-1; i++)
  {
    for (int j = 0; j < N; j++) if(N-j+1>0) acc[i][j+1] += acc[i][j]+dp[i][j];
    if(S[i]=='<'){
     // 累積和にする。
      for (int j = 0; j < N-i; j++) dp[i+1][j] += (acc[i][j+1]);
    }
    else{
      for (int j = N-i-1; j >= 1; j--) dp[i+1][j-1] += dp[i+1][j]+dp[i][j];
    }
  }
  // modint ans=0;
  // for (int i = 0; i < N; i++)
  // {
  //   ans += dp[N][i];
  //   DBG(dp[N][i])
  // }
  cout << dp[N-1][0] << endl;

  return 0;
}

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


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;cin.ignore();
    map<string,int>mp;
    while (n--){
        string a;
        cin>>a;
        mp[a]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"];


}

Measured memory_bytes: 3596
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List


-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine


solver :: String -> Int
solver ls = div (length $ filter (\ (a,b) ->a/=b) $ zip ls $ reverse ls) 2


main::IO()
main = print.solver =<< getLine

Measured memory_bytes: 3696
n = int(input())
a = [int(input()) for i in range(n)]
c = sorted(a,reverse=True)
b = max(a)
if a.count(b)>1:
    for i in range(n):
        print(b)
    exit()
for i in a:
    if i==b:
        print(c[1])
    else:
        print(b)
    

    

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

int n;
ll k;
vector<ll> a, f;

bool chk(ll mid)
{
  ll count = 0;
  rep(i, n)
  {
    ll t = a[i] * f[i];
    if (mid < t)
    {
      count += (t - mid + f[i] - 1) / f[i];
      if (count > k)
        return false;
    }
  }
  return true;
}

int main()
{
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  rep(i, n)
    cin >> a[i];
  rep(i, n)
    cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.begin(), f.end());
  reverse(f.begin(), f.end());
  ll l = -1, r = 1e12;
  while (l + 1 < r)
  {
    ll mid = (l + r) / 2;
    if (chk(mid))
      r = mid;
    else
      l = mid;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9+7;
int main()
{
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    int dp[n+1][n+1][k+1];
    for(int i = 0; i <= n; i++)
    {
      for(int j = 0; j <= n; j++)
      {
        for(int x = 0; x <= k; x++) dp[i][j][x] = 0;
      }
    }
  
    for(int i = 0; i < n; i++)
    {
        dp[i][i][k] = 1;
        if(i+1 < n && s[i] == s[i+1]) dp[i][i+1][k] = 2;
        else dp[i][i+1][k] = 1;
        if(k) dp[i][i+1][k-1] = 2;
    }

    for(int i = 0; i < n; i++)
    {
        for(int l = 0; l+i < n; l++)
        {
            int r = l+i;
            for(int x = 0; x <= k; x++)
            {
                if(l > 0) dp[l-1][r][x] = max(dp[l-1][r][x], dp[l][r][x]);
                if(r+1 < n) dp[l][r+1][x] = max(dp[l][r+1][x], dp[l][r][x]);
                if(l > 0 && r+1 < n)
                {
                    if(s[l-1] == s[r+1]) dp[l-1][r+1][x] = max(dp[l-1][r+1][x], dp[l][r][x] + 2);
                    if(x) dp[l-1][r+1][x-1] = max(dp[l-1][r+1][x-1], dp[l][r][x] + 2);
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= k; i++)
    {
        ans = max(ans, dp[0][n-1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int X;
    cin >> X;

    int dt = X/100;
    if(dt == 0) {
        cout << 0 << endl;
        return 0;
    }

    int rem = X-(dt*100);
    if(rem==0) {
        cout << 1 << endl;
        return 0;
    }
    for(int i=5; i>0; i--) {
        int t = rem/i;
        if(t) {
            dt -= t;
            rem -= t*i;
            if(rem && dt <= 0) {
                cout << 0 << endl;
                return 0;
            } else if(dt < 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
 
int main(){
     int N;
     cin >> N;
     int d = N%10;
     N/=10;
     int v = 12;
     for(int i=1;i<=3;i+=1){
          if(N%10==d){
               cout << "Bad";
               v = 123;
               break;
               // exit(1);
          }
          d = N%10;
          N/=10;
     }
     if(v==12){
     cout<< "Good";
     }
}

Measured memory_bytes: 3568
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

score = sum(B)

for i in range(N-1):
    if A[i]+1 == A[i+1]:
        score += C[A[i]-1]

print(score)

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

#define ll              long long
#define ull             unsigned long long
#define mx              1000000
#define mod             1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.length();
  int a=0, b=0;
  for(int i=0; i<n; i++){
    if(s[i]=='A') break;
    a++;
  }

  for(int i=n-1; i>=0; i--){
    if(s[i]=='Z') break;
    b++;
  }
  cout << n-b-a << endl;
  
  return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 9
for i in range(len(a) - K + 1):
  l = a[i]
  r = a[i+K-1]
  ans = min(ans, abs(l) + abs(r - l), abs(r) + abs(l - r))
print(ans)

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


int main(){
    int N, M;
    cin >> N >> M;
    int height[N];
    bool H[N];
    rep(i, N){
        cin >> height[i];
    }
    rep(i, N){
        H[i] = true;
    }
    int k, j;
    rep(i,M){
        cin >> k >> j;
        if(height[k-1] < height[j-1]){
            H[k-1] = false;
        } else if(height[k-1] == height[j-1]){
            H[k-1] = false;
            H[j-1] = false;
        } else {
            H[j-1] = false;
        }
    }
    int cnt = 0;
    rep(i, N){
        if(H[i] == true){
            cnt++;
        }
    }
    cout << cnt << endl;

}

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

int main(){
	int j,i,n,k,temp;
  cin>>n>>k;
  int arr[n];
  for(i=0;i<n;i++)
    cin>>arr[i];
  int res[k+1];
  res[0]=0;
  for(i=1;i<=k;i++){
  	temp=0;
    for(j=0;j<n;j++)
      if(i-arr[j]>=0 && (res[i-arr[j]]==0 || i-arr[j]==0)){
      	temp=1;
        break;
      }
    res[i]=temp;
  }
  if(res[k]==1)cout<<"First\n";
  else cout<<"Second\n";
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define ll long long
#define to_mod 1000000007

int main(){
    int n;
    cin >> n;
    char a_int = 'a';
    ll alphs[26];
    for(int i = 0; i < 26; i++) alphs[i] = 1;
    for(int i = 0; i < n; i++){
        char inp;
        cin >> inp;
        // cout << int(inp) - int(a_int) << endl;
        alphs[int(inp) - int(a_int)]++;
    }
    ll comb = 1;
    for(int i = 0; i < 26; i++) {comb *= alphs[i]; comb = (comb + to_mod) % to_mod;}
    cout << comb - 1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>
#include <climits>

using namespace std;

int main()
{
    int X, Y;
    scanf("%d %d\n", &X, &Y);
    int result = INT_MAX;
    auto assign = [&](int coeff){if (coeff > 0) result = min(coeff, result);};
    if (X <= Y) assign(Y - X);
    if (-X <= Y) assign(Y - -X + 1);
    if (X <= -Y) assign(-Y - X + 1);
    if (-X <= -Y) assign(-Y - -X + 2);
    printf("%d\n", result);
}


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

class K
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var M = 1000000007;

		var f = new long[n + 1];
		f[0] = 1;
		for (int i = 0; i < n; i++)
			f[i + 1] = f[i] * (i + 1) % M;

		var r = 0L;
		var st = new SegmentTree(n + 1);
		for (int i = 0; i < n; i++)
		{
			var c = st.Sum(0, a[i]);
			r = (r + (a[i] - c - 1) * f[n - i - 1]) % M;
			st.Add(a[i], 1);
		}
        var Pnum = r + 1;
      
        a = Console.ReadLine().Split().Select(int.Parse).ToArray();
       	f = new long[n + 1];
		f[0] = 1;
		for (int i = 0; i < n; i++)
			f[i + 1] = f[i] * (i + 1) % M;

		r = 0L;
		st = new SegmentTree(n + 1);
		for (int i = 0; i < n; i++)
		{
			var c = st.Sum(0, a[i]);
			r = (r + (a[i] - c - 1) * f[n - i - 1]) % M;
			st.Add(a[i], 1);
		}
        var Qnum = r + 1;
		Console.WriteLine(Math.Abs(Qnum-Pnum));
	}
}

class SegmentTree
{
	static int[] p2 = Enumerable.Range(0, 30).Select(i => (int)Math.Pow(2, i)).ToArray();
	static Dictionary<int, int> p2_ = Enumerable.Range(0, 30).ToDictionary(i => p2[i], i => i);

	static int LogFloor(int v)
	{
		for (int i = 1; ; i++) if (p2[i] > v) return i - 1;
	}

	int n2, logn;
	int[] a;
	public SegmentTree(int n)
	{
		logn = (int)Math.Ceiling(Math.Log(n, 2));
		n2 = p2[logn];
		a = new int[2 * n2];
	}

	public void Add(int i, int v)
	{
		for (i += n2; i > 0; i /= 2) a[i] += v;
	}

	// 簡易実装
	public int Sum(int start, int count)
	{
		if (p2_.ContainsKey(count))
		{
			return a[(start + n2) / count];
		}
		else
		{
			var c2 = p2[LogFloor(count)];
			return Sum(start, c2) + Sum(start + c2, count - c2);
		}
	}
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n,m;
	cin>>n>>m;
	if((m-1)%(n-1)==0)cout<<(m-1)/(n-1)<<endl;
	else cout<<(m-1)/(n-1)+1<<endl;
	return 0; 
}/*『你强归你强，我永不示弱』*/


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

int main() {
    int n, q, sum = 0;
    queue<pair<string, int> > que;
    cin >> n >> q;
    for(int i=0;i<n;i++){
        string s;
        int t;
        cin >> s >> t;
        que.push({s,t});
    }
    while(!que.empty()){
        auto task = que.front();
        que.pop();
        if(task.second > q){
            sum += q;
            task.second -= q;
            que.push(task);
        }
        else{
            sum += task.second;
            cout << task.first << " " << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6316
import sys
import heapq

s = sys.stdin.readlines()
n,m = map(int,s[0].split())
a = []
b = []
l = []
ans = 0
count = 0

for i in range(1,n+1):
	a_dash,b_dash = map(int,s[i].split())
	a.append(-a_dash)
	b.append(-b_dash)

c = zip(a,b)
c = sorted(c,reverse=True)
a,b = zip(*c)
a_length = len(a)

for i in reversed(range(m)):
	for j in range(count,a_length):
		if -a[j] + i == m:
			heapq.heappush(l,b[j])
			count += 1
		else:
			break
	if len(l) != 0:
		maximum = heapq.heappop(l)
		ans += maximum

print(-ans)


Measured memory_bytes: 91228
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
cnt = 0
mod = 10**9+7
for i in range(k,n+2):
    sum_min = i*(i-1) // 2
    sum_max = i*(2*n-i+1) // 2
    #print((sum_max - sum_min + 1))
    cnt = (cnt +  sum_max - sum_min + 1)%mod
print(cnt)

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

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

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

const long long INF = 1LL << 60;

long long dp[100010];

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

    long long h[100010];
    for (int i = 0; i < n; i++) cin >> h[i];

    for (int i = 0; i < 100010; i++) dp[i] = INF;

    dp[0] = 0;

    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 5096
val map = ArrayList<ArrayList<Int>>()
var ans = 0

fun main(){
    val h = readInt()
    val w = readInt()
    val k = readInt()

    for (i in 1..h){
        val line = read().toCharArray().map{if(it == '#') 1 else 0}
        map.add(line as ArrayList<Int>)
    }

    for (i in 1..1.shl(h+w)){
        var count = 0
        for (mx in 0 until w){
            for (my in 0 until h){
                if((i.and(1.shl(mx)) > 0) and (i.and(1.shl(w+my)) > 0)){
                    count += map[my][mx]
                }
            }
        }
        if(count == k) ans++
    }

    println(ans)
}

private val inputQue = ArrayList<String>()

private fun myReadLine(){
    inputQue.addAll(readLine()!!.split(' '))
}

fun read() : String {
    if(inputQue.isEmpty()) myReadLine()
    return inputQue.removeAt(0)
}

fun readInt() = read().toInt()

fun readLong() = read().toLong()

fun readDouble() = read().toDouble()


Measured memory_bytes: 37400
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
	cout << "Bad" << endl;
    } else {
	cout << "Good" << endl;
    }
    return 0;
}
 


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


using namespace std;
using ll = long long;

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define trav(a, x) for(auto& a: x)

int main () {

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

    int n; cin>> n;
    int d; cin >> d;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
      double a, b; cin>> a >> b;
      if (sqrt(a * a + b * b) <= d) ans++;
    }

    cout << ans << '\n';

    return 0;
}




Measured memory_bytes: 3860
from collections import defaultdict

N = int(input())
a = [int(input())-1 for x in range(N)]

d = defaultdict(int)
c = 0
b = 0
while True:
    if b == 1:
        print(c)
        exit()
    if d[b] == 1:
        print(-1)
        exit()
    else:
        d[b] = 1
    b = a[b]
    c += 1

Measured memory_bytes: 16632
#include<cstdio>
#include<string>
#include<algorithm>

#pragma GCC optimize ("O0")
using namespace std;
int h[100000];
 
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 0;i<n;i++){
		scanf("%d",&h[i]);
	}
	k--;
	sort(h,h+n);
	int min = h[k] - h[0];
	for(int i = 1;i<n-k;i++){
		int t = h[k+i] - h[i];
		if(t<min)min = t;
	}
	printf("%d\n",min);
	
}

Measured memory_bytes: 512
// https://atcoder.jp/contests/abc134/tasks/abc134_e

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
#define DUMP2D(a) REP(_i, a.size()) DUMP(a[_i]); cout << endl

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;

int N;
vector<int> A;

int main() {
  cin >> N;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  multiset<int> st;
  REP(i, N) {
    auto it = st.lower_bound(A[i]);
    if (it != st.begin()) st.erase(--it);
    st.insert(A[i]);
  }

  int ans = st.size();
  cout << ans << endl;
}


Measured memory_bytes: 5376
#coding utf-8

from collections import Counter

N = int(input())
a = list(map(int, input().split()))

aaa = list()

for i in a:
    aaa.append(i - 1)
    aaa.append(i)
    aaa.append(i + 1)

c = Counter(aaa)
mode = c.most_common(1)

print(mode[0][1])


Measured memory_bytes: 27360
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N,M;
  cin>>N>>M;
  if((M/2)<=N)
    cout<<M/2<<endl;
  else{
  int64_t ans=(N+(M/2))/2;
    cout<<ans<<endl;
  
  }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) \
  for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int a[100005];
int c[100005];

int main() {
  int N, Q;
  cin >> N >> Q;
  int x, y;
  bool fy = false;
  bool fx = true;
  a[1] = 1;
  for (int n = 1; n <= N; ++n) {
    c[n] = 1;
  }
  while (Q--) {
    scanf("%d%d", &x, &y);
    if (a[x]) a[y] = 1;
    --c[x];
    ++c[y];
    if (c[x] == 0) {
      a[x] = 0;
    }
  }
  int res = 0;
  for (int n = 1; n <= N; ++n) {
    if (a[n]) ++res;
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    string str;
    cin >> str;
    if(str.at(2) == str.at(3) && str.at(4) == str.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if(N.at(0) == N.at(1)||N.at(2) == N.at(3)){
    if(N.at(2) == N.at(1)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        for(int h=0;h<H;h++){
        	String line = sc.next();
        	System.out.println(line);
        	System.out.println(line);
        }
    }
}

Measured memory_bytes: 22612
#include<stdio.h>

int search(int A[], int n, int key){
    int i=0;
    A[n] = key;
    while(A[i] != key ) i++;
    return i != n;
}

int main (){
    int i,n, A[10000+1],q,key,sum=0;
    
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &A[i]);
    
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d", &key);
        if( search(A,n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 2800
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
out.println(ir.nextBigInteger().modPow(ir.nextBigInteger(),BigInteger.valueOf(1000000007)));
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24740
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    long long int i,j,a,b,n,x,y,z,t,k,sum,sum1;
    vector<long long int> v,v1;
    string s,s1;
    unordered_map<long long int,long long int> m,m1;
    unordered_map<long long int,vector<long long int>> m3;
    t=1;
    cin>>n>>t;
    while(t--)
    {
        cin>>k;
        for(i=0;i<k;i++)
        {
           cin>>j;
           m[j]=1;
        }
    }
    cout<<n-m.size()<<endl;
}











Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>

using namespace std;

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

	int n, m, x, y;
	cin >> n >> m >> x >> y;
	
	vector<int> a, b;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;

		a.push_back(t);
	}
	for (int i = 0; i < m; i++)
	{
		int t;
		cin >> t;

		b.push_back(t);
	}

	a.push_back(x);
	b.push_back(y);

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int mini = a.back();
	int maxi = b[0];
	mini++;

	if (maxi - mini >= 0)
	{
		cout << "No War\n";
	}
	else
	{
		cout << "War\n";
	}

}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    L,R,d = map(int, readline().split())

    ans = 0
    for i in range(L,R+1):
        if i % d == 0:
            ans += 1
    
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0&&y==0)break;
        if(y>=x){
            cout << x << " " << y << endl;
            
        }else{
            cout << y << " " << x << endl;
        }
    }
}


Measured memory_bytes: 3068
#include<iostream>
using namespace std;
 main()
{
    string x;

    cin>>x;

   if(x == "Sunny")
   {
       cout<<"Cloudy";
   }

   else if( x == "Cloudy")
   {
    cout<<"Rainy";
   }
   else if( x == "Rainy")
   {
   cout<<"Sunny";
   }
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, s, t;
int u, v; ll a, b;

using Graph = vector<vector<pli>>;

void dijkstra(const Graph &g, int root, vector<ll> &dist) {
    rep(i, n+1) dist[i] = LLINF;
    dist[root] = 0;
    priority_queue<pli, vector<pli>, greater<pli>> q;
    q.emplace(0, root);

    while (!q.empty()) {
        auto top = q.top(); q.pop();
        int u = top.second;
        for (const auto &e: g[u]) {
            int v = e.second;
            ll cost = e.first;
            if (chmin(dist[v], dist[u] + cost)) {
                q.emplace(dist[v], v);
            }
        }
    }
}

// RMQを考える
struct SegmentTree {
    private:
        int n; // セグ木のサイズ
        vector<ll> node; // セグ木を表す配列

    public:
        // 元配列vをセグ木で表現する
        SegmentTree(vector<ll> v) {
            int sz = v.size();
            n = 1;
            while (n < sz) n *= 2; // n は元のサイズ以上になる最小の2冪
            node.resize(2*n - 1, INF);

            // 最下段に値をいれる
            for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
            // ノードkの子は2k+1, 2k+2
            for (int i = n-2; i >= 0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
        }

        void update(int x, int val) {
            // 最下段のノードにアクセスする
            x += (n - 1);

            // 最下段のノードを更新したら、親に登って更新
            node[x] = val;
            while (x > 0) {
                x = (x - 1) / 2;
                node[x] = min(node[2*x+1], node[2*x+2]);
            }
        }

        // 要求区間 [a, b) 中の要素の最小値を答える
        // k := 自分がいるノードのインデックス
        // 対象区間は [l, r)
        ll getMin(int a, int b, int k=0, int l=0, int r=-1) {
            // 最初に呼び出されたときの対象区間は [0, n)
            if (r < 0) r = n;

            // 要求区間と対象区間が交わらない
            if (r <= a || b <= l) return LLINF;

            // 要求区画が対象区間を完全に被覆
            if (a <= l && r <= b) return node[k];

            ll vl = getMin(a, b, 2*k+1, l, (l+r)/2);
            ll vr = getMin(a, b, 2*k+2, (l+r)/2, r);
            return min(vl, vr);
        }
};

int main() {
    cin >> n >> m >> s >> t;

    // g1: 円   g2: スヌーク
    Graph g1(n+1), g2(n+1);
    rep(i, m) {
        cin >> u >> v >> a >> b;
        g1[u].emplace_back(a, v);
        g1[v].emplace_back(a, u);
        g2[u].emplace_back(b, v);
        g2[v].emplace_back(b, u);
    }

    vector<ll> ds(n+1), dt(n+1);
    dijkstra(g1, s, ds);
    dijkstra(g2, t, dt);
    rep(i, n+1) ds[i] += dt[i];

    SegmentTree segt(ds);
    ll x = 1e15;
    rep(i, n) {
        cout << x - segt.getMin(i+1, n+1) << endl;
    }
}


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


int main() {

vector<long> a(5);
for(int i=0;i<5;i++) cin>>a[i];

for(int i=0;i<5;i++){
  if(a[i]==0){
    cout<<i+1<<endl;
  }

}

}


Measured memory_bytes: 3620