akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0 && w == 0){
            break;
        }
        int i;
        for(i=0;i<h;i++){
            if(i % 2 == 0){
                int j;
                for(j=0;j<w;j++){
                    if(j % 2 == 0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
            }else{
                int j;
                for(j=0;j<w;j++){
                    if(j%2 == 0){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<long> Solve(int Q, int[][] V)
        {
            var list = new List<long>();
            for (int i = 0; i < Q; ++i)
            {
                int A = Math.Min(V[i][0], V[i][1]);
                int B = Math.Max(V[i][0], V[i][1]); ;
                if (B - A <= 1)
                {
                    list.Add((A - 1) * 2);
                }
                else
                {
                    long N = Math.BigMul(A, B);
                    long n = (long)Math.Ceiling(Math.Sqrt(N) - 1.0);
                    list.Add((n * (n + 1) < N) ? n * 2 - 1 : n * 2 - 2);
                }
            }
            return list;
        }
        static void Main(string[] args)
        {
            int Q = ReadInt();
            var V = new int[Q][];
            for (int i = 0; i < Q; ++i) { V[i] = ReadInts(); }
            foreach (long ans in Solve(Q, V))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

const LLI mod = 1e9+7;

LLI dp[50][1<<18];

// a ⊆ b
bool is_included_in(int a, int b){
  return (a&(~b)) == 0;
}

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

  int n,x,y,z;
  while(cin >> n >> x >> y >> z){

    int m = x+y+z;
    int p = bit(x+y+z-1) | bit(y+z-1) | bit(z-1);

    LLI ans = 1;
    REP(i,n) (ans *= 10) %= mod;
    
    fill_array(dp, 0);
    dp[0][0] = 1;

    REP(i,n){
      REP(j,1<<m){
        FORE(k,1,10){
          int t = ((j << k) | bit(k-1)) & ((1<<m)-1);
          if(not is_included_in(p,t)){
            (dp[i+1][t] += dp[i][j]) %= mod;
          }
        }
      }
    }

    REP(i,1<<m) ans = (ans - dp[n][i] + mod) % mod;

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


Measured memory_bytes: 102784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  /*
  int n, i, j;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  */
  int n, r;
  cin >> r;
  cout << r*r << endl; 
}


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

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int N,H,W,ans=0;
    cin >> H >> W >> N;
    while(N>0){
        N -= max(H,W);
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 892
N = int(input())
P = list(map(int, input().split()))
res = 0
for i in range(N - 2):
    p = P[i:i + 3]
    if p[0] <= p[1] <= p[2] or p[2] <= p[1] <= p[0]:
        res += 1
print(res)

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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;

const int N = 51;
const ll inf = (ll)1e18 + 10;

ll dis[N][N];

ll get(int i, int j) {
  if (i == j) return 0;
  for (int t = 1; t < N; ++t) {
    if (i % t == j) return 1ll << t;
  }
  return inf;
}

void init() {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= i; ++j) {
      dis[i][j] = get(i, j);
    }
    for (int j = i + 1; j < N; ++j) dis[i][j] = inf;
  }

  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        mini(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  /*
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      printf("%lld ", dis[i][j]);
    }
    puts("");
  }*/
}

int n;
vector <int> a, b;
vector < vector <int> > all;

void run() {
  init();
  cin >> n;
  a.resize(n);
  b.resize(n);
  all.resize(n, vector <int>(N, 0));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }

  for (int i = 0; i < n; ++i) {
    if (dis[a[i]][b[i]] >= inf) {
      puts("-1");
      return;
    }
  }

  for (int i = 0; i < n; ++i) {
    all[i][a[i]] = 1;
  }

  ll ans = 0;
  for (int i = 50; i >= 1; --i) {
    bool ok = 0;
    for (int j = 0; j < n; ++j) {
      ll mn = inf, who = -1;
      for (int k = 0; k < N; ++k) if (all[j][k]) {
        if (mn > dis[k][b[j]]) {
          mn = dis[k][b[j]];
          who = k;
        }
      }

      assert(mn != inf);
      if (mn >> i & 1) {
        ans |= dis[who][b[j]];
        ok = 1;
      }
    }
    debug(i, a);
    if (ok) {
      for (int j = 0; j < n; ++j) {
        for (int k = 0; k < N; ++k) if (all[j][k]) {
          all[j][k % i] = 1;
        }
      }
    }
  }

  cout << ans << endl;
}

int main() {
  run();
  return 0;
}


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

int main(){
  long long N;
  cin>>N;
  
  int count=1;
  long long tmp_sum=0, ret=N-1;
  while(1){
    tmp_sum+=pow(26,count);
    if(N<=tmp_sum){
      break;
    }
    ret=N-tmp_sum-1;
    count++;
  }
  
  vector<long long> vl(count);
  rep(i, count){
    vl.at(i)=ret%26;
    ret/=26;
  }
  map<int, char> m;
  m[0]='a', m[1]='b', m[2]='c', m[3]='d', m[4]='e', m[5]='f';
  m[6]='g', m[7]='h', m[8]='i', m[9]='j', m[10]='k',m[11]='l';
  m[12]='m',m[13]='n',m[14]='o',m[15]='p',m[16]='q',m[17]='r';
  m[18]='s',m[19]='t',m[20]='u',m[21]='v',m[22]='w',m[23]='x';
  m[24]='y',m[25]='z';
  for(int i=count-1;i>=0;i--){
    cout<<m.at(vl.at(i));
  }
  cout<<endl;
}

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

int main(){
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    long long p[A],q[B],r[C];
    for(int i=0;i<A;i++) cin >> p[i];
    for(int i=0;i<B;i++) cin >> q[i];
    for(int i=0;i<C;i++) cin >> r[i];

    priority_queue<long long,vector<long long>,greater<long long> > que;

    sort(p,p+A,greater<long long>());
    sort(q,q+B,greater<long long>());
    sort(r,r+C,greater<long long>());

    long long ans=0;

    for(int i=0;i<X;i++){
        que.push(p[i]);
        ans+=p[i];
    }
    for(int i=0;i<Y;i++){
        que.push(q[i]);
        ans+=q[i];
    }

    for(int i=0;i<C;i++){
        long long tmp=que.top(); que.pop();
        if(r[i]>tmp){
            ans-=tmp;
            ans+=r[i];
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4724
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        SegmentTree[] segs = new SegmentTree[26];
        for (int i = 0; i < 26; i++) {
            segs[i] = new SegmentTree(d.length);
        }
        for (int i = 0; i < d.length; i++) {
            segs[(int) d[i]-'a'].update(i, 1);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int type = scan.nextInt();
            if (type == 1) {
                int index = scan.nextInt()-1;
                char old_c = d[index];
                char new_c = scan.next().toCharArray()[0];
                if (old_c == new_c) {
                    continue;
                }
                segs[(int)old_c-'a'].update(index, 0);
                segs[(int)new_c-'a'].update(index, 1);
                d[index] = new_c;
                continue;
            }
            int l = scan.nextInt()-1;
            int r = scan.nextInt();
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                ans += segs[j].query(l, r);
            }
            System.out.println(ans);
        }
    }
    class SegmentTree {
        int size;
        int[] data;
        SegmentTree(int N) {
            int size = 1;
            while (size < N) {
                size *= 2;
            }
            int[] data = new int[size * 2];
            Arrays.fill(data, 0);
            this.size = size;
            this.data = data;
        }
        void update(int k, int a) {
            k += this.size - 1;
            this.data[k] = a;
            while (0 < k) {
                k = (k - 1) / 2;
                this.data[k] = Math.max(data[k * 2 + 1], data[k * 2 + 2]);
            }
        }
        int query(int a, int b) {
            return query(a, b, 0, 0, this.size);
        }
        int query(int a, int b, int k, int l, int r) {
            if (r <= a || b <= l) {
                return 0;
            }
            if (a <= l && r <= b) {
                return this.data[k];
            }
            int value_left = query(a, b, k * 2 + 1, l, (l+r)/2);
            int value_right = query(a, b, k * 2 + 2, (l+r)/2, r);
            return Math.max(value_left, value_right);
        }
    }
}


Measured memory_bytes: 222392
/**
 *    author:  math2do
 *    created: 05.09.2020 14:31:48
**/

#include <bits/stdc++.h>

using namespace std;

const int mod = (int) (1e9 + 7);

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  } 
  vector <int> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector <int> temp(k + 1);
    for (int c = k; c >= 0; c--) {
      int from = c + 1;
      int to = c + min(arr[i], k - c);
      if (from <= to) {
        add(temp[from], dp[c]);
        if (to + 1 <= k) {
          sub(temp[to + 1], dp[c]);
        }
      } 
    }
    int pre = 0; 
    for (int j = 0; j <= k; j++) {
      add(pre, temp[j]);
      add(dp[j], pre);
    } 
  } 

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

Measured memory_bytes: 4032
def bs(a, key):
    left = -1
    right = len(a)

    while right - left > 1:
        mid = left + (right - left) // 2

        if a[mid] >= key:
            right = mid
        else:
            left = mid

    return a[right] == key


n = int(input())
S = sorted(list(map(int, input().split())))
q = int(input())
T = list(map(int, input().split()))

print(sum([bs(S, t) for t in T]))



Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back 
#define endl '\n'
#define INF 0x3f3f3f3f
#define MOD 1000000007

#define bug(x) cout << #x << " = " << x << '\n'
const int MAXN = 200050;

bool check(int n)
{
	for(int i = 2; i*i <= n; i++)
		if(n%i == 0) return 0;
		
	return 1;
}

int32_t main()
{
	int n, t , a, resp = 0;
	int mx = INT_MAX;
	cin >> n >> t >> a;
	for(int i = 0; i < n; i++)
	{
		int h; cin >> h;
		int aux = abs(a*1000 - (1000*t - h*6));
		if(aux < mx) mx = aux, resp = i;
	}
	cout << resp + 1;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<ll , ll>m;
int main()
{
  ll n, w;
  cin >> n >> w;

  ll a[n+1];
  ll v[n+1];

  for(ll i = 1;i <= n ; i++)
  {
      cin >> a[i] >> v[i];
  }

  ll dp[w+1][n+1];
  memset(dp , 0 , sizeof(dp));
  for(ll i = 1 ; i <= w ; i++)
  {
      for(ll j = 1 ; j <= n ; j++)
      {
          if(a[j] > i)
          dp[i][j]  = dp[i][j-1];
          else if(a[j] <= i)
          dp[i][j] = max(dp[i-a[j]][j-1]+v[j] , dp[i][j-1]);
      }
  }

 /*  for(ll i = 1 ; i <= w ; i++)
   {
       for(ll j = 1 ; j <= n ; j++)
       cout << dp[i][j] << " ";
       cout << endl;
   }
*/
  cout << dp[w][n] ;

}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define pii pair<int, int>
#define mkpii make_pair
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;
const int maxn = 1e6 + 7;
struct node
{
	int v, w, next;
	node(int v, int w) : v(v), w(w) {}
	node(){}
	bool operator < (const node &rhs) const 
	{
		return w > rhs.w;
	}
}e[maxn << 1];
map<pii, int> mp;
int n, m;
int head[maxn], tot = 0;
void add(int u, int v, int w)
{
	++tot; 
	e[tot].v = v; e[tot].w = w; 
	e[tot].next = head[u]; head[u] = tot;
}
int getid(int x, int y)
{
	pii tmp = mkpii(x, y);
	if (!mp.count(tmp)) mp[tmp] = ++n;
	return mp[tmp];
}
priority_queue<node>q;
int dis[maxn], vis[maxn];
int dijkstra(int s, int t)
{
	MEM(dis, 0x3f3f3f3f);
	q.push(node(s, 0)); dis[s] = 0;
	while (!q.empty())
	{
		int u = q.top().v; q.pop();
		if (vis[u]) continue; vis[u] = 1;
		for (int i = head[u]; i; i = e[i].next)
		{
			int v = e[i].v;
			if (dis[v] > dis[u] + e[i].w)
			{
				dis[v] = dis[u] + e[i].w;
				q.push(node(v, dis[v]));
			}
		}
	}
	return dis[t] >= 0x3f3f3f3f ? -1 : dis[t] / 2;
}
int main()
{
	scanf("%d%d", &n, &m);
	int s = 1, t = n;
	while (m--)
	{
		int u, v, c; scanf("%d%d%d", &u, &v, &c);
		int uc = getid(u, c), vc = getid(v, c);
		add(u , uc, 1); add(uc, u, 1);
		add(uc, vc, 0); add(vc, uc, 0);
		add(vc, v, 1); add(v, vc, 1);
	}
	printf("%d\n", dijkstra(s, t));
	return 0;
}

Measured memory_bytes: 54900
#include<bits/stdc++.h>
using namespace std;
int n,x,a[200001];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string l, r;
  if (n % 2 == 0) {
    l = s.substr(0, n / 2);
    r = s.substr(n / 2, n / 2);
  }
  else {
    l = s.substr(0, n / 2);
    r = s.substr((n + 1) / 2, n / 2);
  }
  reverse(r.begin(), r.end());
  int res = 0;
  int m = l.size();
  for (int i = 0; i < m; i++) {
    if (l.at(i) != r.at(i)) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int M = sc.nextInt();
  long num[][] = new long[4][N];
  int d[] = { -1, 1 };
  for (int i = 0; i < N; i++) {
    long x = sc.nextLong();
    long y = sc.nextLong();
    long z = sc.nextLong();
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        num[2 * j + k][i] = x + y * d[j] + z * d[k];
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    Arrays.sort(num[i]);
  }
  long ans = 0, sum;
  for (int i = 0; i < 4; i++) {
    sum = 0;
    for (int j = 0; j < M; j++) {
      sum += -num[i][j];
    }
    ans = Math.max(ans, sum);
    sum = 0;
    for (int j = N - 1; j > N - 1 - M; j--) {
      sum += num[i][j];
    }
    ans = Math.max(ans, sum);
  }
  System.out.println(ans);
}}

Measured memory_bytes: 26072
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    if(b%a==0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>


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


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

class employee {
public:
	int id;
	vector<int> children;
	int salary;
	
	employee(int _id) {
		id = _id;
		children = {};
		salary = -1;
	}



};





int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> line(100000,0);
	ll temp1, temp2;
	rep(i, 0, N) {
		cin >> temp1 >> temp2;
		line[temp1 - 1] += temp2;
	}
	ll sum = 0;
	rep(i, 0, 100000) {
		sum += line[i];
		if (sum >= K) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  int N;
  ll A[200005];
  cin >> N;
  for (int i=0; i < N; i++) cin >> A[i];
  ll out=0;
  ll su=0;
  for(int i=0; i < N; i++) {
      if (i>0) su = (su + A[i-1]) % (1000000007);
      out = (out+(A[i]*su)) % (1000000007);
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#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 ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long

signed main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    int a[505][505]={0};
    rep(i,M){
        int L,R;
        cin>>L>>R;
        a[L][R]++;
    }
    ll A[505][505];
    rep1(i,N+1){
        rep1(j,N+1){
            a[i][j] += a[i][j-1];
        }
    }
    rep1(i,N+1){
    rep1(j,N+1){
        a[i][j] += a[i-1][j];
    }
    }

    rep(i,Q){
        int L,R;cin>>L>>R;
        cout<< a[R][R] - a[R][L-1]-a[L-1][R]+a[L-1][L-1]<<endl;

    }
    return 0;
}


Measured memory_bytes: 1920
import numpy as np
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
A = np.sort(list(map(int,input().split())))
F = np.sort(list(map(int,input().split())))[::-1]
mul = A*F
if K >= np.sum(A)*N:
    print(0)
    exit()

ma = A[-1]*F[0]
mi = 0
while ma != mi:
    tgt = (ma + mi)//2
    tmp = np.ceil((mul-tgt)/F)
    num = np.sum(tmp[tmp>0])
    if num <= K:
        ma = (ma + mi)//2
    else:
        mi = (ma + mi)//2+1
print(ma)


Measured memory_bytes: 37236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){


 
  
  ll n,k;
  cin>>n>>k;
   if(  (n+1) / 2 >= k )
   cout<<"YES\n";
   else
   cout<<"NO\n";
    
  


return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3596
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      
      // 判定
      int countAC = 0;
      int countWA = 0;
      int countTLE = 0;
      int countRE = 0;
      for(int i = 0; i < N; i++){
        String ans = sc.next();
        if(ans.equals("AC")){
          countAC++;
        }
        else if(ans.equals("WA")){
          countWA++;
        }
        else if(ans.equals("TLE")){
          countTLE++;
        }
        else if(ans.equals("RE")){
          countRE++;
        }
      }
      
      
      // 出力
      System.out.println("AC x " + countAC);
      System.out.println("WA x " + countWA);
      System.out.println("TLE x " + countTLE);
      System.out.println("RE x " + countRE);
    }

}

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

using namespace std;

int main()
{
    long long n, x;
    cin >> n;
    long long ans = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> x;
        ans ^= x;
    }
    if(ans==0)
        puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func kaibun(s string) bool {
	i := 0
	j := len(s) - 1
	for i < len(s)/2 {
		if s[i] != s[j] {
			return false
		}
		i = i + 1
		j = j - 1
	}

	return true
}

func check(s string) bool {
	if len(s)%2 == 0 {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2:]) == false {
			return false
		}
	} else {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2+1:]) == false {
			return false
		}
	}
	return true
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	L := sc.nextInt()

	fmt.Printf("%.12f\n", float64(L*L*L)/27.0)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define EPS 1e-10
typedef complex<double> P;

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_intersect(P a1, P a2, P b1, P b2) {
  return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS) &&
    (cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < EPS);
}

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  char d;
  while (cin >> xa >> d >> ya >> d >> xb >> d >> yb >> d >> xc >> d >> yc >> d >> xd >> d >> yd) {
    P a(xa, ya), b(xb, yb), c(xc, yc), d(xd, yd);
    if (is_intersect(a, c, b, d)) cout << "YES\n";
    else cout << "NO\n";
  }
}


Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{
	int N, D;
	cin >> N >> D;

	int ans = 0;
	int L = D;
	int R = D + N - 1;
	int eat;
	if (R <= 0)
	{
		eat = R;
	}
	else if (L >= 0)
	{
		eat = L;
	}
	else
	{
		eat = 0;
	}
	ans = (R + L) * N / 2 - eat;
		cout << ans << endl;
	
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    int n,ans = 0;
    ll l[100];
    cin >> n;
    rep(i, n)cin >> l[i];
    rep(i, n - 2){
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] != l[j] && l[i] != l[k] && l[k] != l[j]) {
                    ll h = max(l[i], l[k]);
                    h = max(l[j], h);
                    if (h < (l[i] + l[k] + l[j] - h))ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3164
s1 = input()
s2 = input()
x = [[0 for i in range(len(s2))]for j in range(len(s1))]

def g(i,j):
    if i == 0 or j == 0:
        if s1[i] == s2[j]:
            x[i][j] = abs(i-j)
        else:
            if i == 0:
                x[i][j] = x[i][j-1] + 1
            else:
                x[i][j] = x[i-1][j] + 1
    elif s1[i] == s2[j]:
        x[i][j] = min(x[i-1][j-1],x[i][j-1]+1,x[i-1][j]+1)
    else:
        x[i][j] = min(x[i-1][j-1]+1,x[i][j-1]+1,x[i-1][j]+1)
        

for i in range(len(s1)):
    for j in range(len(s2)):
        g(i,j)

print(x[len(s1)-1][len(s2)-1])


Measured memory_bytes: 42848
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, t, s;
    cin >> n >> t >> s;
    t -= s;
    auto dp1 = make_v(n+1, s+1, 0ll);
    auto dp2 = make_v(n+1, t+1, 0ll);
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= s; ++j) {
            chmax(dp1[i][j], dp1[i][j-1]);
            chmax(dp1[i+1][j], dp1[i][j]);
        }
        for (int j = 0; j <= s; ++j) {
            if(j+b[i] > s) break;
            chmax(dp1[i+1][j+b[i]], dp1[i][j]+a[i]);
        }
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= t; ++j) {
            chmax(dp2[i][j], dp2[i][j-1]);
            chmax(dp2[i+1][j], dp2[i][j]);
        }
        for (int j = 0; j <= t; ++j) {
            if(j+b[i] > t) break;
            chmax(dp2[i+1][j+b[i]], dp2[i][j]+a[i]);
        }
    }
    reverse(dp2.begin(), dp2.end());
    ll ans = 0;
    for (int i = 0; i <= n+1; ++i) {
        ll x = 0;
        if(i) x += dp1[i-1][s];
        if(i <= n) x += dp2[i][t];
        chmax(ans, x);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 73696
n=int(input())
a=[int(x) for x in input().split()]
if n==2:
    print(abs(a[0]-a[1]))
else:
    l=[0]*(n)
    l[0]=0
    l[1]=abs(a[0]-a[1])
    for i in range(2,n):
        l[i]=min(l[i-2]+abs(a[i-2]-a[i]),l[i-1]+abs(a[i-1]-a[i]))
    print(l[n-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define sz 150010
const int mod=1000000007;

int main(){
    BeatMeScanf;
    int l;
    cin>>l;
    string a,b,ans;
    cin>>a>>b;

    for(int i=0;i<l;i++){
        ans.push_back(a[i]);
        ans.push_back(b[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
xy = gets.chomp.split
x = xy[0].to_i
y = xy[1].to_i

result = false
if y.even? && y <= x * 4
    (0..x).each do |i|
        j = x - i
        if i * 2 + j * 4 == y
            result = true
            break
        end
    end
end

puts result ? "Yes" : "No"


Measured memory_bytes: 14316
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    a[i] = a[i] - (i + 1)

a.sort()

b = a[n // 2]

ret = 0

for i in range(n):
    ret += abs(a[i] - b)

print(ret)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  vector<int> A(N);
  bool ok = true;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  long long ans = 1;
  if (N % 2 == 1) {
    if (A[0] == 0) {
      for (int i = 1; i < N; i++) {
        if (A[i] != i + i % 2) {
          ok = false;
          break;
        }
      }
    } else {
      ok = false;
    }
  } else {
    for (int i = 0; i < N; i++) {
      if (A[i] != i + (i + 1) % 2) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    for (int i = 0; i < N / 2; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<math.h>

int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	int check=C%B;
	int i,flag=0;
	for(i=0;i<5000;i++)
	{
		if(A*i%B==check)
		{
			flag=1;
			break;
		}
		
	}
	if(flag==1)
		printf("YES");
	else
		printf("NO");
	
	return 0;
}

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

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

    rep(i,k) {
        if (a >= b) {
            b *= 2;
        }
        else if (b >= c) {
            c *= 2;
        }
        if (b > a && c > b) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a, b;
    std::cin >> a >> b;
    std::string s(b, '0' + a), t(a, '0' + b);
    std::cout << (s < t ? s : t) << std::endl;

    return 0;
}


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

static const int MAX=100;
static const long long INFTY=(1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            if(d[i][k]==INFTY)continue;
            for(int j=0;j<n;j++){
                if(d[k][j]==INFTY)continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int e,u,v,c;
    cin>>n>>e;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=((i==j)?0:INFTY);
        }
    }
    for(int i=0;i<e;i++){
        cin>>u>>v>>c;
        d[u][v]=c;
    }
    
    floyd();
    
    bool negative=false;
    for(int i=0;i<n;i++)if(d[i][i]<0)negative=true;
    
    if(negative){
        cout<<"NEGATIVE CYCLE"<<endl;
    }else{
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(j)cout<<" ";
                if(d[i][j]==INFTY)cout<<"INF";
                else cout<<d[i][j];
                
            }
            cout<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3176
#include<iostream>

using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;

	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				int total = 500 * a + 100 * b + 50 * c;
				if (total == X)res++;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define re() pop_back()
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(a) a.begin(),a.end()
#define msort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

const int N= 5e5+ 4;
int dat[N],last[N],c[N],ans[N];
vector<int> qi[N], qs[N];
void update(int i,int val){
    while(i<N){
        dat[i]+=val;
        i+=i&-i;
    }
}

int sum(int i){
    int sum=0;
    while(i){
        sum+=dat[i];
        i-=i&-i;
    }
    return sum;
}

int rangesum(int l,int r) {
    return sum(r)-sum(l-1);
}


void sol()
{
    int n,q;
    cin>>n>>q;
    for (int i = 1; i < n+1; i++)
    {
        cin>>c[i];
    }

    for (int i = 0; i <q; i++)
    {
        int x,y;
        cin>>x>>y;
        qi[y].eb(i);
        qs[y].eb(x);
    }
    
    for (int i = 1; i < n+1; i++)
    {
        if(last[c[i]]>0) {
            update(last[c[i]],-1);
        }
        update(i,1);
        last[c[i]]=i;
        for (int j = 0; j< sz(qs[i]); j++)
        {
            ans[qi[i][j]]=rangesum(qs[i][j],i);
        }
        
    }
    
    for (int i = 0; i < q; i++)
    {
        cout<<ans[i]<<endl;
    }
}

int main()
{
    IOS;
    ll t=1;// cin>>t;
    while (t--)
    {
        sol();
    }
}

Measured memory_bytes: 52996
N = int(input())
A, B = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
count = [0, 0, 0]
for i in range(N):
    if P[i] <= A:
        count[0] += 1
    elif P[i] <= B:
        count[1] += 1
    else:
        count[2] += 1
print(min(count))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
 	
  	int vec[N][2];
	for (int i = 0; i < N; i++) {
	    cin >> vec[i][0] >>vec[i][1]; 
	}
  
  	int i = 0;
  int cnt = 0;
  	for(;i<N;i++){
    	if(vec[i][0]==vec[i][1])
        {
        	cnt+=1;
        }
      else{
       cnt=0;
      }
      if(cnt==3){
        break;
      }
    }
      if(cnt==3){
      	cout <<"Yes" << endl;
      }
  else{cout <<"No"<< endl;}
    return 0;
}

Measured memory_bytes: 3632
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int k, t, mx = 0, a[100];
	cin >> k >> t;

	lp(t) {
		cin >> a[i];
		mx = max(a[i], mx);
	}
	cout << max(0, 2 * mx-k-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	string a,b,c;cin>>a>>b;
	int x,y;cin>>x>>y;
	cin>>c;
	if(a==c)x--;
	if(b==c)y--;
	cout << x<<" "<<y<<endl;
}


Measured memory_bytes: 256
import * as fs from 'fs';

const main = (input: string) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let sum = 0;
  let maxTime = 0;
  let w: number[] = [];

  lines.forEach((time) => {
    if (time % 10 !== 0) {
      w.push(10 - time % 10)
    }

    sum += (Math.ceil(time / 10) * 10)
  });

  if (w.length > 0) {
    maxTime = w.reduce((a, b) => Math.max(a, b))
  }

  console.log(sum - maxTime);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 1000000007LL;
stack<P> card;
vector<P> cut(int x) {
	vector<P> ret;
	int sum = 0;
	while (!card.empty() && sum + (card.top().second - card.top().first + 1) <= x) {
		sum += (card.top().second - card.top().first + 1);
		ret.push_back(card.top());
		card.pop();
	}
	if (sum < x) {
		ret.emplace_back(card.top().first, card.top().first + x - sum - 1);
		card.top().first += x - sum;
	}
	return ret;
}
int main() {
	int n;
	while (cin >> n, n) {
		int m;
		cin >> m;
		int p, q, r;
		cin >> p >> q >> r;
		while (!card.empty()) card.pop();
		card.push(P(1, n));
		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			vector<P> A = cut(x);
			vector<P> B = cut(y - x);
			vector<P> C = cut(n - y);
			for (int j = A.size() - 1; j >= 0; j--) card.push(A[j]);
			for (int j = B.size() - 1; j >= 0; j--) card.push(B[j]);
			for (int j = C.size() - 1; j >= 0; j--) card.push(C[j]);
		}
		cut(p - 1);
		vector<P> v = cut(q - p + 1);
		int ans = 0;
		for (int i = 0; i < v.size(); i++) {
			if (v[i].first <= r) ans += min(v[i].second, r) - v[i].first + 1;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
  unsigned int N;
  std::cin >> N;
  std::vector<unsigned int> A_array;
  for (unsigned int i = 0; i < N; ++i) {
    unsigned int a;
    std::cin >> a;
    A_array.push_back(a);
  }

  std::vector<unsigned int> min_val;
  min_val.push_back(A_array.at(N - 1));

  for (unsigned int i = N - 1; i >= 1; --i) {
    const unsigned int& a = A_array.at(i - 1);
    std::vector<unsigned int>::iterator itr = std::upper_bound(min_val.begin(), min_val.end(), a);
    if (itr == min_val.end()) {
      min_val.push_back(a);
    } else {
      *itr = a;
    }
  }

  std::cout << min_val.size() << std::endl;

  return 0;
}


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    int x,n;
    cin>>x>>n;
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    int l=x,r=x;
    while(true){
        if(!binary_search(p.begin(),p.end(),l)){
            cout<<l<<endl;
            return 0;
        }
        if(!binary_search(p.begin(),p.end(),r)){
            cout<<r<<endl;
            return 0;
        }
        l--;
        r++;
    }
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long M;
    vector<vector<unsigned long>> path;
    {
        vector<vector<unsigned long>> edge(N);
        vector<unsigned long> queries(N);
        --N;
        vector<unsigned long> edges(N);
        for(unsigned long i{0}, a, b; i < N; ++i){
            cin >> a >> b;
            edge[--a].push_back(i);
            edge[--b].push_back(i);
            edges[i] = a ^ b;
        }
        cin >> M;
        path.resize(M);
        for(unsigned long i{1}, u, v; i < 1UL << M; i <<= 1){
            cin >> u >> v;
            queries[--u] ^= i;
            queries[--v] ^= i;
        }
        [rec_impl = [&path, &edge, &edges, &queries, &M](auto f, unsigned long now, unsigned long prev) -> unsigned long {
            unsigned long mask{queries[now]};
            for(const auto& i : edge[now])if((edges[i] ^ now) != prev){
                auto t = f(f, edges[i] ^ now, now);
                for(unsigned long j{0}; j < M; ++j)if(1 & (t >> j))path[j].push_back(i);
                mask ^= t;
            }
            return mask;
        }]{rec_impl(rec_impl, 0, 0);}();
    }
    vector<unsigned long> cnt(N), used(M);
    unsigned long ans{1UL << N}, cntr{N};
    const auto& check = [&cnt, &used, &path, &cntr, &M](unsigned long i){
        if(used[i] ^= 1)for(const auto& e : path[i])cntr -= !(cnt[e]++);
        else for(const auto& e : path[i])cntr += !(--cnt[e]);
    };
    for(unsigned long i{1}; i < 1UL << M; ++i){
        check(__builtin_ctzl(i));
        ans += (i & 1 ? -1 : 1) * (1UL << cntr);
    }
    cout << ans << endl;
    return 0;
}

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

int sum(long long x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main() {
	int k; cin >> k;
	long long num = 1, add = 1;
	while (k--) {
		cout << num << endl;
		while (double(num + add) / sum(num + add) > double(num + 2 * add) / sum(num + 2 * add))add *= 10;
		num += add;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        s: Chars,
        t: Chars
    };

    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = dp[i + 1][j + 1].max(dp[i + 1][j]).max(dp[i][j + 1]);
            }
        }
    }
    let mut res = VecDeque::new();
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if dp[i][j] == dp[i - 1][j] {
            i -= 1;
        } else if dp[i][j] == dp[i][j - 1] {
            j -= 1;
        } else {
            res.push_front(s[i - 1]);
            i -= 1;
            j -= 1;
        }
    }
    println!("{}", res.into_iter().join(""));
}


Measured memory_bytes: 37360
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	ll n,m,c=0,pen=0; cin>>n>>m;
	ml mp;
	vl a(100005,0);
	while(m--){
		ll p; cin>>p;
		string s; cin>>s;
		if(s == "WA" && mp[p]!=1) {
			a[p]++;
		}
		else mp[p]=1;
	}
	lp(i,1,n+1){
		if(mp[i]){
			c++;
			pen+=a[i];
		}
	}
	cout<<c<<" "<<pen;
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 7296
import * as fs from 'fs';

namespace AtCoder.abc160 {

    export class ProgramA {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * Coffee
         * sippuu
         * out
         * yes
         */
        main(): void {
            const s = this.args[0];


            if (s[2]===s[3] && s[4]===s[5])
            {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }

}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc160.ProgramA(args);
prg.main();




Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    cin >> n;
    int m = n/2;

    int v[n];
    rep(i, n) {
        cin >> v[i];
    }

    int o[m], e[m];     //v[n]の奇数番目(1-index)の項がo[m],偶数番目(1-index)の項がe[m]
    rep(i, m) {
        o[i] = v[2*i];
        e[i] = v[2*i+1];
    }
    sort(o, o+m);
    sort(e, e+m);

    int t1 = o[0];
    int k1 = 0;
    vector<int> co(m);
    rep(i, m) {
        if(t1 < o[i]) {
            t1 = o[i];
            k1++;
            co[k1]++;
        } 
        else {
            co[k1]++;
        }
    }

    int t2 = e[0];
    int k2 = 0;
    vector<int> ce(m);
    rep(i, m) {
        if(t2 < e[i]) {
            t2 = e[i];
            k2++;
            ce[k2]++;
        } 
        else {
            ce[k2]++;
        }
    }

    sort(co.begin(), co.end());
    sort(ce.begin(), ce.end());

    int a1 = o[0];
    int b1 = 0;
    rep(i, m) {
        if(a1 < o[i]) {
            if(b1 == co[m-1]) {
                break;
            }
            a1 = o[i];
            b1 = 0;
        }
        b1++;
    }
    
    int a2 = e[0];
    int b2 = 0;
    rep(i, m) {
        if(a2 < e[i]) {
            if(b2 == ce[m-1]) {
                break;
            }
            a2 = e[i];
            b2 = 0;
        }
        b2++;
    }

    int ans;
    if(a1 != a2) {
        ans = n - (co[m-1] + ce[m-1]);
    }
    else {
        int u = co[m-1] + ce[m-2];
        int v = co[m-2] + ce[m-1];
        ans = n - max(u, v);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408