akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int k,a,b; cin>>k>>a>>b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

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

    ll l,r;
    cin >> l >> r;
    ll ans = inf;
    if((r-l)<2019){
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){ 
                ans = min(ans,(i*j)%2019);
            }
        }
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read

N,C, *XV = map(int, read().split())#全部
X=XV[::2]
V=XV[1::2]

m1=[0]
m2=[0]

s=0
ans=0
for x,v in zip(X,V):
    s+=v
    ans=max(ans,s-x)
    m1.append(max(m1[-1],s-x))
    m2.append(max(m2[-1],s-2*x))
s=0
i=0
for x,v in reversed(list(zip(X,V))):
    s+=v
    x=C-x
    ans=max(ans,s-2*x+m1[-2-i],s-x+m2[-2-i])
    i+=1
print(ans)

Measured memory_bytes: 28308
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
   lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

//lld fac[100001]; 
/*
void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
*/
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;
//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}
*/

void solve()
{
    lld n,m,k;
    cin>>n>>k;
    lld a[n];
    for(i=0;i<n;i++)
        a[i]=1;
    for(i=0;i<k;i++)
    {
        cin>>x;
        for(j=0;j<x;j++)
        {
            cin>>y;
            a[y-1]=0;
        }
    }
    ans=0;
    for(i=0;i<n;i++)
    {
        ans+=a[i];
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
 //   cin>>t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
    //    cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>

int main(){
  int x, a, b;
  std::cin >> x >> a >> b;
  if(abs(x - a) > abs(x - b))
    std::cout << "B" << std::endl;
  else
    std::cout << "A" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int n, m;
	cin >> n >> m;
	int s[m];
	char c[m];
	rep (i, m) cin >> s[i] >> c[i];

	for (int i = 0; i < 1000; i++) {
		if (to_string(i).size() != n) continue;
		string S = to_string(i);
		bool ok = true;
		rep (j, m) {
			if (S[s[j] - 1] != c[j]) ok = false;
		}
		if (ok) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int n;
vector<int> x, y;
int l[50], t[50], r[50], b[50];
int used[500][500];

void solve(){
	x.clear(); y.clear();
	rep(i,500) rep(j,500) used[i][j] = 0;
	rep(i,n){
		cin >> l[i] >> t[i] >> r[i] >> b[i];
		x.push_back(l[i]); x.push_back(r[i]);
		y.push_back(t[i]); y.push_back(b[i]);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());
	rep(i,n){
		rep(j,x.size()){
			if(l[i] == x[j]){
				l[i] = j;
				break;
			}
		}
		rep(j,x.size()){
			if(r[i] == x[j]){
				r[i] = j;
				break;
			}
		}
		rep(j,y.size()){
			if(t[i] == y[j]){
				t[i] = j;
				break;
			}
		}
		rep(j,y.size()){
			if(b[i] == y[j]){
				b[i] = j;
				break;
			}
		}
	}
	rep(i,n){
		l[i] *= 2; l[i] += 10;
		r[i] *= 2; r[i] += 10;
		t[i] *= 2; t[i] += 10;
		b[i] *= 2; b[i] += 10;
		for(int j = l[i]; j <= r[i]; j++) used[j][t[i]] = -1;
		for(int j = l[i]; j <= r[i]; j++) used[j][b[i]] = -1;
		for(int j = b[i]; j <= t[i]; j++) used[l[i]][j] = -1;
		for(int j = b[i]; j <= t[i]; j++) used[r[i]][j] = -1;
	}
	int cnt = 0;
	queue<P> que;
	rep(i,500) rep(j,500){
		if(used[i][j] != 0) continue;
		cnt++;
		used[i][j] = cnt;
		que.push(P(i,j));
		while(true){
			if(que.size() == 0) break;
			P q = que.front();
			que.pop();
			rep(k,4){
				if(0>q.first+dx[k]||q.first+dx[k]>=500) continue;
				if(0>q.second+dy[k]||q.second+dy[k]>=500) continue;
				if(used[q.first+dx[k]][q.second+dy[k]] != 0) continue;
				used[q.first+dx[k]][q.second+dy[k]] = cnt;
				que.push(P(q.first+dx[k],q.second+dy[k]));
			}
		}
	}
	/*
	rep(i,100){
		rep(j,100){
			if(used[i][j] == -1) cout << "Z";
			else cout << used[i][j];
		}
		cout << endl;
	}
	*/
	cout << cnt << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 2204
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll val1 = a*c;
    ll val2 = a*d;
    ll val3 = b*c;
    ll val4 = b*d;
    ll ans = maxl(val1,maxl(val2,maxl(val3,val4)));
    cout << ans << "\n";
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  rep(i, n){
    int in;
    cin >> in;
    mp[in]++;
  }
  rep(i, m){
    int b, c;
    cin >> b >> c;
    mp[c] += b;
  }

  ll ans = 0, co = 0;
  rrepit(itr, mp){
    if(co + itr->second < n){
      ans += (ll)itr->first * itr->second;
      co += itr->second;
    }else{
      ans += (ll)itr->first * (n-co);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12936
#include <cstdio>
int map[10][10],m,n;
int solve(int x,int y,int left) {
	bool house=false;
	if(left<0) return 0;
	if(map[x][y]==1) {
		house=true;
		map[x][y]=0;
	}
	int res=0;
	for(int i=x-1;i>=0;i--) {
		if(map[i][y]==1) {
			res+=solve(i,y,left-1);
			break;
		}else if(map[i][y]==2&&left==0) {
			res++;
			if(house)map[x][y]=1;
			return res;
		}
	}
	for(int i=x+1;i<m;i++) {
		if(map[i][y]==1) {
			res+=solve(i,y,left-1);
			break;
		}else if(map[i][y]==2&&left==0) {
			res++;
			if(house)map[x][y]=1;
			return res;
		}else if(map[i][y]==3) {
			break;
		}
	}
	for(int i=y-1;i>=0;i--) {
		if(map[x][i]==1) {
			res+=solve(x,i,left-1);
			break;
		}else if(map[x][i]==2&&left==0) {
			res++;
			if(house)map[x][y]=1;
			return res;
		}
	}
	for(int i=y+1;i<n;i++) {
		if(map[x][i]==1) {
			res+=solve(x,i,left-1);
			break;
		}else if(map[x][i]==2&&left==0) {
			res++;
			if(house)map[x][y]=1;
			return res;
		}
	}
	if(house)map[x][y]=1;
	return res;
}
int main() {
	int x,y,house;
	while(scanf("%d %d",&m,&n),m) {
		house=0;
		for(int i=0;i<n;i++)for(int j=0;j<m;j++) {
			scanf("%d",&map[j][i]);
			if(map[j][i]==1)house++;
			if(map[j][i]==2)x=j,y=i;
		}
		printf("%d\n",solve(x,y,house));
	}
}

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

int main () {
	int n, k, w, p, tr, c, m, pmax = 0, pmin = 0;
	list<int> wlist;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> w;
		wlist.push_front(w);
		if ( pmin < w)
			pmin = w;
		pmax += w;
	}
	(pmin < pmax / k) && (pmin = pmax / k);
	list<int>::iterator itwlist = wlist.begin();
	while (pmin <= pmax) {
		m = (pmin + pmax) / 2;
		tr = 0;
		c = 0;
		p = m;
		itwlist = wlist.begin();
		while (c < n) {
			while (p >= 0) {
				p = p - *itwlist;
				c++;
				itwlist++;
			}
			tr++;
			if (tr > k) {
				pmin = m + 1;
				break;
			}
			itwlist--;
			c--;
			p = m;
		}
		if (tr <= k)
			pmax = m - 1;
	}
	cout << pmin << endl;	
	return 0;
}

Measured memory_bytes: 6216
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(n2 - 1, 0, -1):
                if n1 + n2 + n3 == x:
                    ans += 1
                    break
    return ans


data = []
while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        data.append(0)
        # print(0)
    else:
        data.append(get_num(n, x))
        # print(get_num(n, x))

for n in data:
    print(n)

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;
ll fac[MAX], finv[MAX], inv[MAX];

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    cin >> N;
    COMinit();
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        a -= tmp;
        if(i) A.push_back(a);
        tmp = a+tmp;
    }
    ll s = 0;
    for(int i=1;i<N;i++) {
        s += fac[N-1]*modinv(i,MOD);
        s %= MOD;
        ans += s*A[i-1];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8976
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<limits>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

template <class T>
class Dijkstra {
    private:
        struct edge {
            T to, cost;
        };
        T inf;
        T node_num;
        vector<vector<edge> > graph;
        vector<T> dist;
    public:
        Dijkstra(T n) {
            inf = numeric_limits<T>::max();  // please pay attention to overflow
            node_num = n;
            graph.resize(node_num);
            dist.resize(node_num);
            fill(dist.begin(), dist.end(), inf);
        }
        void add_edge(T from, T to, T cost) {
            edge e1 = {to, cost};
            graph[from].push_back(edge(e1));
        }
        void calc_shortest_path(T start) {
            priority_queue<P, vector<P>, greater<P> > PQ;
            dist[start] = 0;
            PQ.push(P(0, start));
            while (!PQ.empty()) {
                P now = PQ.top();
                PQ.pop();
                T now_u = now.second;
                if (dist[now_u] < now.first) continue;
                for (T i = 0; i < graph[now_u].size(); i++) {
                    edge e = graph[now_u][i];
                    if (dist[e.to] > dist[now_u] + e.cost) {
                        dist[e.to] = dist[now_u] + e.cost;
                        PQ.push(P(dist[e.to], e.to));
                    }
                }
            }
        }
        T get_dist(T u) {
            return dist[u];
        }
};

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--, T--;
    Dijkstra<ll> en(N), snuke(N);
    int u, v, a, b;
    for (int i = 0; i < M; i++) {
        cin >> u >> v >> a >> b;
        u--, v--;
        en.add_edge(u, v, a);
        en.add_edge(v, u, a);
        snuke.add_edge(u, v, b);
        snuke.add_edge(v, u, b);
    }
    en.calc_shortest_path(S);
    snuke.calc_shortest_path(T);
    vector<ll> ans(N);
    ll min_cost = INF;
    for (int i = N - 1; i >= 0; i--) {
        ll now_cost = en.get_dist(i) + snuke.get_dist(i);
        min_cost = min(min_cost, now_cost);
        ans[i] = 1e15 - min_cost;
    }
    for (int i = 0; i < N; i++) cout << ans[i] << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

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

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  if (n < 10) 
  {
    cout << 0;
    return;
  }

  map<int, int> primes;
  for(int i = 1; i <= n; ++i)
  {
    int n = i;
    for(int p = 2; p <= i; ++p)
    {
      while(n % p == 0)
      {
        primes[p]++;
        n /= p;
      }
    }
  }

  int ans = 0;
  int over75 = 0;
  int over25 = 0;
  int over15 = 0;
  int over5 = 0;
  int over3 = 0;
  for(const auto& p : primes)
  {
    if (p.second >= 74) over75++;
    if (p.second >= 24) over25++;
    if (p.second >= 14) over15++;
    if (p.second >=  4) over5++;
    if (p.second >=  2) over3++;
  }

  ans += over75;
  ans += over25 * (over3 - 1);
  ans += over15 * (over5 - 1);
  ans += over5 * (over5 - 1) * (over3 - 2) / 2;

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3624
import itertools
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ls = [A,B,C,D,E]
ls2 = []
for i in itertools.permutations(ls, 5):
  ls2.append(list(i))
minimum = 10**9+7
for i in range(120):
  ls3 = ls2[i]
  now = 0
  for j in range(5):
    if j == 0:
      now += ls3[j]
    else:
      if now%10 == 0:
        now += ls3[j]
      else:
        now = 10*(now//10+1)
        now += ls3[j]
  if now < minimum:
    minimum = now
print(minimum)
    

Measured memory_bytes: 9072
#include<bits/stdc++.h>
#define int long long  
#define mod 1000000007
#define endl "\n"
#define VI vector<int>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fb(i,a,b) for(int i=a ;i>=b;i--)
#define pb push_back
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std;
 int32_t main(){
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
int n;
cin>>n;
map<string,int>m;
fo(i,0,n){
    string s;
    cin>>s;
    m[s]++;
}
cout<<"AC x "<<m["AC"]<<"\n";
cout<<"WA x "<<m["WA"]<<"\n";
cout<<"TLE x "<<m["TLE"]<<"\n";
cout<<"RE x "<<m["RE"]<<"\n";

 return 0;
 }

Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		long sum=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		long nsum=(long)n*(long)(n+1)/2;
		if(sum%nsum!=0){
			System.out.println("NO");
			return;
		}
		
		long k=sum/nsum;
		
		int[] d=new int[n];
		for(int i=0;i<n;i++){
			if(i==n-1)d[i]=a[0]-a[n-1];
			else d[i]=a[i+1]-a[i];
			
			d[i]-=k;
		}
		
		for(int t=0;t<k;t++){
			for(int i=0;i<n;i++){
				if(d[i]!=0){
					d[i]+=n;
					break;
				}
			}
		}
		
		for(int i=0;i<n;i++){
			if(d[i]!=0){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		
	}

}


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


int main(void){
	int X, N, p, res = 0, minabs = 1000;
	std::cin >> X >> N;
	if(N == 0){
		std::cout << X << std::endl;
		return 0;
	}
	std::vector<int> abs(102, 0);
	for(int i = 0; i < N; i++){
	       	std::cin >> p;
		abs[p] = -1;
	}
	if(abs[X] == 0){
		std::cout << X << std::endl;
		return 0;
	}

	for(int i = X+1; i <= 101; i++){
		if(abs[i] == 0){
			minabs = i - X;
			res = i;
			break;
		}
	}
	for(int i = X-1; i >= 0; i--){
		if(abs[i] == 0){
			if(minabs >= (X - i)){
				std::cout << i << std::endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 3580
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n,k;
ll h[N],s;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>k;
	for (int i=0;i<n;++i) cin>>h[i];
	sort(h,h+n);
	for (int i=0;i<n-k;++i) s+=h[i];
	cout<<s;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
//////////////////////////////////////////////////////////////////////

const int N = 100100;
vector<pair<int,ll> > t[N];
ll dp[N];

void dfs(int x,int p=0,ll dpt=0){
  dp[x] = dpt;
  for(auto&it:t[x])
    if(it.ff!=p){
      dfs(it.ff,x,dpt+it.ss);
    }
}

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

  int n;cin>>n;
  for(int i=1;i<n;i++){
    int a,b;ll c;
    cin>>a>>b>>c;
    t[a].emplace_back(b,c);
    t[b].emplace_back(a,c);
  }
  
  int q,k;cin>>q>>k;
  dfs(k);
  
  while(q--){
    int u,v;cin>>u>>v;
    cout<<dp[u]+dp[v]<<nl;
  }
  
  return 0;
}


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

int main(){
string s;
cin >> s;
for (int i = 0;i < 3;i++){
  if (s.at(i) == '1'){
    s.at(i) = '9';
  }
  else{
    s.at(i) = '1';
  }
}
cout << s << endl;
}


Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 164 C - gacha
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/07
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <string>
#include <map>
using namespace std;

int n;
map<string, int> items;

void solve() {
    int num = items.size();
    printf("%d\n", num);
}

int main() {

    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        char s[10];
        scanf("%s", s);
        items[(string)s]++;
    }

    solve();
}

Measured memory_bytes: 18704
#include<iostream>
#include<numeric>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int calclate_above(int index, const bool a[], int n){
    int sum = 0;
    for(int i = 2 * (index + 1) - 1; i < n; i += (index+1) ){
        sum += a[i];
    }
    return sum;
}

int main(void){
    int n;
    cin >> n;
    bool a[n];
    rep(i,n){
        cin >> a[i];
    }
    bool box[n];
    for(int i = n-1; i>n/2;i--){
        box[i] = a[i];
    }
    for(int i=n/2; i>=0;i--){
        if(calclate_above(i, box, n) % 2 == a[i]){
            box[i] = false;
        }else{
            box[i] = true;
        }
    }
    int M = accumulate(box, box + SIZE_OF_ARRAY(box), 0);
    if(M%2 == a[0]){
        cout << M << endl;
        rep(i, n){
            if(box[i]){
                if(i)   cout << " ";
                cout << i + 1;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

struct node_t {
	int id;
	int parent;
	int sibling;
	int degree;
	int depth;
	int childs[2];
	int height;
	const char *type;
};
typedef struct node_t Node;

int calc_depth(Node *data, int index) {
	int cidx, h, height = 0, i;

	for (i = 0; i < 2; i++) {
		cidx = data[index].childs[i];
		if (cidx >= 0) {
			data[cidx].depth += 1;
			data[cidx].sibling = data[index].childs[1-i];
			h = calc_depth(data, cidx);
			height = height > h ? height : h;
		}
	}
	if (data[index].type[0] == 'l') {
		data[index].height = 0;
	} else {
		data[index].height = height;
	}
	return data[index].height + 1;
}

void print_node(Node *p) {
	printf("node %d: parent = %d, ", p->id, p->parent);
	printf("sibling = %d, degree = %d, ", p->sibling, p->degree);
	printf("depth = %d, height = %d, %s\n", p->depth, p->height, p->type);
}

int main(void) {
	int n, i, j, id;
	Node *p;

	scanf("%d ", &n);

	Node data[n];

	for (i = 0; i < n; i++) {
		data[i].parent = -1;
		data[i].sibling = -1;
		data[i].degree = 0;
		data[i].depth = 0;
		data[i].height = 0;
	}

	for (i = 0; i < n; i++) {
		scanf("%d ", &id);
		p = &data[id];
		p->id = id;
		scanf("%d %d ", &p->childs[0], &p->childs[1]);
		for (j = 0; j < 2; j++) {
			if (p->childs[j] >= 0) {
				data[p->childs[j]].parent = id;
				(p->degree)++;
			}
		}
		p->type = p->degree ? "internal node" : "leaf";
	}

	for (i = 0; i < n; i++) {
		calc_depth(data, i);
	}

	for (i = 0; i < n; i++) {
		if (data[i].parent == -1) {
			data[i].type = "root";
		}
		print_node(data+i);
	}
	return 0;
}

Measured memory_bytes: 604
MODULE qSortMod
      implicit none
      interface qSort
        module procedure :: i16qSort
        module procedure :: i4qSort
      end interface
      contains
      
      pure recursive function i16qSort( a ) result( r )
          !ref
          !https://t.doujin-constant.net/
          !post/143374686394/fortranをより使いこなしたquick-sort
          !
          !left is Bigger!
        implicit none
        integer(16),intent(in) :: a(:)
        integer(16) :: r( size(a) )
        !integer(16),allocatable :: r(:) !is OK
        
        if( size(a)>1 )then
          r = [ qSort( pack( a(:),a(:)> a(1) ) ), &
                       pack( a(:),a(:)==a(1) )  , &
                qSort( pack( a(:),a(:)< a(1) ) ) ]
        else
          r = a
        end if
      end function i16qSort
      
      pure recursive function i4qSort( a ) result( r )
        implicit none
        integer(4),intent(in) :: a(:)
        integer(4) :: r( size(a) )
        
        if( size(a)>1 )then
          r=[qSort(pack(a,a>a(1))),pack(a,a==a(1)),qSort(pack(a,a<a(1)))]
        else
          r = a
        end if
      end function i4qSort
      END MODULE qSortMod
      
      
      PROGRAM piyo
      USE qSortMod
      IMPLICIT NONE
      INTEGER(16) :: n
      integer(16),allocatable :: a(:)
      integer(16) :: i
      
      read*,n
      allocate( a(n) )
      read*,a(:)
      
      a = qSort( a )
      
      
      do i = 1,n-1
        if( a(i)==a(i+1) )then
          print*,'NO'
          STOP
        end if
      end do
      
      print*,'YES'
      
      END PROGRAM
      

Measured memory_bytes: 21808
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N; scanf("%d", &N);
	int v[1001];
	for (int i = 0; i < N; i++){
		scanf("%d", v + i);
	}

	sort(v, v + N);

	float ret = (float)(v[0] + v[1]) / pow(2.0f,N-1);
	for (int i = 2; i < N; i++){
		ret += (float)v[i] / pow(2.0f, N - i);
	}
	printf("%f", ret);

	return 0;
}

Measured memory_bytes: 128
A, B = map(int, input().split())
if A > B:
    if A != 1 and B == 1:
        print('Bob')
    else:
        print('Alice')
elif A < B:
    if A == 1 and B != 1:
        print('Alice')
    else:
        print('Bob')
else:
    print('Draw')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 #define len length

using namespace std;
typedef long long ll;

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

  int n,m,a,b;
  cin>>n>>m;
  ll sum=0;
  int arr[m];
  for(int i=0;i<m;i++)
  {
      cin>>arr[i];
      sum+=arr[i];
  }
  if(sum>n) cout<<-1;
  else cout<<(n-sum);

 return 0;
}




Measured memory_bytes: 3640
import math
PI = math.pi
EPS = 0.0000000001

a, b, x = map(int, input().split())

def f(a, b, theta):
    if theta > PI / 2 - EPS:
        return 0.0
    ret = 0
    if a * math.tan(theta) <= b:
        return a * a * b - a * a * a * math.tan(theta) / 2
    else:
        return b * b / math.tan(theta) * a / 2


def solve():
    ok = PI / 2
    ng = 0.0
    for _ in range(100000):
        mid = (ok+ng) / 2
        if f(a, b, mid) < x:
            ok = mid
        else:
            ng = mid
    print(ok/PI*180)    

solve()

Measured memory_bytes: 38768
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	
	int n,i;
	cin >>n;
	
	int l[n],longl=0,longno=-1;
	for (i=0 ; i<n ; i++) {
		cin >>l[i];
		if (l[i]>=longl) {
			longl=l[i];
			longno=i;
		}
	}
	
	int kei=0;
	for (i=0 ; i<n ; i++) {
		if (i!=longno) kei+=l[i];
	}
	
	if (longl<kei) {
		cout <<"Yes" <<endl;
	} else {
		cout <<"No" <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
num= int(input())
OFFSET =25
for _ in range(num):
    T = [None] * (25+1+25)
    s = input()
    t = list(s[0::3])
    d = list(s[2::3])

    for i in range(len(t)):
        if i == 0:
            p = 0
        else:
            if d[i-1] == ">":
                p += 1
            else:
                p -= 1
        T[p+OFFSET] = t[i]
    for i in T:
        if i:
            print(i,end="")
    print()



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;

map<string,int> mp;
int main()
{
	int n;
	string s;
	cin>>n;
	bool flag=1;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	int res=0;
	vector<string> ans;
	for(auto it:mp)
	{
		if(it.second>res)
		{
			res=it.second;
			ans.clear();
			ans.push_back(it.first);
		}
		else if(it.second==res)
		{
			ans.push_back(it.first);
		}
	}
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<endl;
	return 0;
 } 

Measured memory_bytes: 28916
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

uint64_t x,q,r;


void solve(){
        q=int(x/100);
        r=int(x%100);

        if(q*5>=r) {
                cout<<1<<endl;
        }else{
                cout<<0<<endl;
        }


}

int main(){
        cin >>x;

        solve();
        return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll x, a, b;

  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) cout << "A" << endl;
  else cout << "B" << endl;

  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int N;
vector<LL> line;

bool check(int x){
	LL sum = line[x];
	REP(i, N){
		if(x==i)continue;
		if(sum*2 < line[i])return false;
		sum += line[i];
	}
	return true;
}

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> time(N, INF);
	vector<vector<int>> use(N);
	vector<vector<int>> user(M);
	REP(i, N){
		int K;
		cin >> K;
		REP(j, K){
			int d;
			cin >> d;
			--d;
			user[d].push_back(i);
			use[i].push_back(d);
		}
	}

	time[0] = 0;
	queue<PII> que;
	//pos time
	que.push({0, 0});
	while(!que.empty()){
		PII d = que.front();
		que.pop();
		foreach(i, use[d.first]){
			foreach(j, user[i]){
				int nt = d.second + 1;
				if(nt < time[j]){
					time[j] = nt;
					que.push({j, nt});
				}
			}
			user[i].clear();
		}
		use[d.first].clear();
	}

	foreach(i, time){
		if(i == INF){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;


	return 0;
}


Measured memory_bytes: 9720
#include<iostream>
using namespace std;
int main()
{
  int ans,cnt;
  string s,t;
  while(cin>>s>>t){
    ans=0;
    for(int i=0;i<s.size();i++){
      cnt=0;
      for(int j=0;j<s.size()-i;j++){
	if(s[j+i]==t[j]){
	  cnt++;
	  ans=max(ans,cnt);
	}else{
	  cnt=0;
	}
      }
    }
    for(int i=0;i<t.size();i++){
      cnt=0;
      for(int j=0;j<t.size()-i;j++){
	if(t[i+j]==s[j]){
	  cnt++;
	  ans=max(ans,cnt);
	}else{
	  cnt=0;
	}
      }
    }
    cout<<ans<<endl;
  }
}

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

// main.cpp

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;
  std::array<std::int_fast64_t, 200000> buckets = {0};
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a_i;
    std::cin >> a_i;
    ++buckets[a_i - 1];
  }
  std::sort(buckets.begin(), buckets.end());
  std::cout << std::accumulate(buckets.begin(), buckets.begin() + (200000 - k), static_cast<std::int_fast64_t>(0)) << std::endl;
  return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>p(n);
  for(i=0;i<n;i++)cin>>p[i];
  for(i=0;i<n-1;i++){
    if(p[i]==i+1){
      p[i]=0;
      p[i+1]=0;
      res1++;
    }
  }
  if(p[n-1]==n)res1++;
  cout<<res1<<endl;
  


  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
#define TIME (chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
const int lim = 3033;
const int mod = 998244353;
void solve(){

    int n,s;cin >> n >> s;
    vi in(n);
    FOR(i, n)cin >> in[i];


    vector<int> dp(lim), prev(lim);
    int ans = 0;
    FOR(i, n){
        fill(all(dp), 0);
        dp[in[i]] = i +1;
        for(int sum = in[i] + 1; sum <= s; sum++){
            dp[sum] = prev[sum - in[i]];
        }
        ans +=  dp[s] * (n - i);
        //debug(ans);
        ans %= mod;
        FOR(j, s+1){
            dp[j] += prev[j];
            dp[j] %= mod;
        }
        swap(dp, prev);
    }
    cout << ans;
}

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

    int t = 1;
    //    cin >> t;
    while(t--)solve();
}




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

int main()
{
	int n, k, x, dis=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin>>x;
		dis+=min(x, k-x);
	}
	cout << 2*dis << endl;
}

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

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> v(n+1);
    for(int i=0; i<n-1; i++) v[i+1] += v[i] + (s.substr(i, 2) == "AC");


    for(int Q=0; Q<q; Q++){
        int l, r;
        cin >> l >> r;
        cout << v[r-1] - v[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e12;
const ll MOD = 1000000000 + 7;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define mii map<int, int>
#define mci map<char, int>
#define mll map<ll, ll>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  vector<map<char, int>> vmp;
  rep(i, n) {
    string tmp;
    cin >> tmp;
    map<char, int> mp;
    rep(j, size(tmp)) mp[tmp[j]]++;
    vmp.pb(mp);
  }
  string ans;
  for (auto i : vmp[0]) {
    int x = i.se;
    rep2(j, 1, n) chmin(x, vmp[j][i.fi]);
    rep(j, x) ans += i.fi;
  }
  out(ans);
}
int main(void) { solve(); }


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	cin>>s;
	for(int i=0;i<s.size();++i){
		if(i&1)continue;
		cout<<s.at(i);
	}
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long 
#define rep(n,i) for (int (i)=0;(i)<(n);(i)++)
#define repi (n,k) for (int i=(k);i<(n);i++)
#define inrep (n,i) for (int (i)=(n)-1;(i)<0;(i)--)
#define pb push_back
#define vcs(x) x.begin(),x.end()
#define sz(x) x.size()
using namespace std;
main (){
	int n; cin>>n;
	int a,b; cin>>a>>b;
	if (n*a>b) cout<<b<<endl;
	else cout<<n*a<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
	int n,p,q,r,a;
	for(;scanf("%d",&n),n;)
	for(;n--;)
	{
		scanf("%d%d%d",&p,&q,&r);
		a=(p+q+r)/3;
		if(p==100||q==100||r==100||p+q>=180||a>=80)
			puts("A");
		else if(a>=70||(a>=50&&(p>=80||q>=80)))
			puts("B");
		else
			puts("C");
	}
}

Measured memory_bytes: 584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and S[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(const RollingHash &T, int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != T.get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    string S; cin >> S;

    RollingHash rh(S);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int lcp = rh.getLCP(i, j);
            lcp = min(j - i, lcp);
            ans = max(ans, lcp);
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


int main() {
    int k, s;
    cin >> k >> s;
    int m = s - k;
    int x = 3 * k - s;
    ll res;
    if (s <= k) res = (s + 1) * (s + 2) / 2;
    else if (s < 2 * k) res = ((s + 1) * (s + 2) / 2) - (3 * m * (m + 1) / 2);
    else if (s <= 3 * k) res = (x + 1) * (x + 2) / 2;
    else res = 0;
    cout << res << endl;
    return 0;
}

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

#define ll long long int
#define hell 1000000007
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

ll helper(vi &a,ll st,ll k,vector < vi > &dp)
{
    if(st==a.size()-1&&k<=a[st])
        return 1;
    if(st>=a.size())
        return 0;
    if(dp[st][k]!=-1)
        return dp[st][k];
    ll ans=0;
    rep(i,0,a[st]+1)
    {
        if(i<=k)
            ans=(ans+helper(a,st+1,k-i,dp))%hell;
        else
            break;
    }
    return dp[st][k]=ans;
}

void solve()
{
    ll n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,0,n)
        cin>>a[i];
    vector < vi > dp(n+1,vi (k+1,0));
    rep(i,0,n+1)
    {
        ll p=0;
        rep(j,0,k+1)
        {
            if(i>=1)
                p=(p+dp[i-1][j])%hell;
            if(i==0&&j==0)
                dp[i][j]=1;
            else if(i==0)
                dp[i][j]=0;
            else if(j==0)
                dp[i][j]=1;
            else
                dp[i][j]=p;
            if(i>0&&j>=a[i-1])
                p=(p-dp[i-1][j-a[i-1]]+hell)%hell;
           // cout<<dp[i][j]<<" ";
        }
        //cout<<"\n";
    }
    cout<<dp[n][k];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 80256