akhauriyash/Code-Regression huggingface dataset:
/*
 *	
 *	Created by Ziyi Tang
 *
 */

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
#define INF (int)1E9
#define INFL (long)1E18
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

ll fw[110][110];
int main(){
	int v,e;
	cin >> v >> e;
	for (int i = 0; i < v; i++){
		for (int j = 0; j < v; j++){
			fw[i][j] = i == j ? 0 : INFL;
		}
	}
	for (int i = 0; i < e; i++){
		ll a,b,c;
		cin >> a >> b >> c;
		fw[a][b] = c;
	}
	for (int k = 0; k < v; k++){
		for (int i = 0; i < v; i++){
			for (int j = 0; j < v; j++){
				if (fw[i][k] == INFL || fw[k][j] == INFL)
					continue;
				fw[i][j] = min(fw[i][j], fw[i][k] + fw[k][j]);
			}
		}
	}
	int neg = 0;
	for (int i = 0; i < v; i++){
		if (fw[i][i] < 0){
			neg = 1;
			break;
		}
	}
	if (neg == 1){
		cout << "NEGATIVE CYCLE" << endl;
	}
	else{
		for (int i = 0; i < v; i++){
			for (int j = 0; j < v; j++){
				if (j != 0)
					cout << " ";
				if (fw[i][j] == INFL){
					cout << "INF";
				}
				else{
					cout << fw[i][j];
				}
			}
			cout << endl;
		}
	}




	return 0;
}

Measured memory_bytes: 1248
/////////////==========================
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define nl cout << '\n'
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

int main(){
    int x;
    cin >> x;
    for(int i = x; i > 0; i = i/10){
        int dig = i%10;
        if(dig == 7){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    
}

Measured memory_bytes: 3636
#include <cstdio>

int main(void){
    
    int a=0,b=0,c=0;
    scanf("%d%d%d",&a,&b,&c);
    if((a<b)&&(b<c)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n;
  cin >> n;
  LL ans = 0;
  for (int i = 1; i <= n; i++) if (!(i%3 == 0 || i%5 == 0)) ans += i;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,c,k;
int t[100005] = {};

int main(){
    
    cin >> n >> c >> k;
	rep(i,0,n)cin >> t[i];

    sort(t,t+n);
    
	int ma = 1,p = 0,cnt = 0,flag = 0;
	rep(i,0,n){
        if(flag == 0){
            flag = 1;
            ma = t[i] + k;
            p = 1;
        }else{
            p++;
            if(ma < t[i] || c < p ){
                cnt++;
                flag = 0;
                i--;
            }
        }
	}
	
	P(cnt+1);
	return  0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)

const int MAXN = 1e5+10;
int A[MAXN], B[MAXN], C[MAXN];  // upper, middle, lower parts
ll preB[MAXN];                 // prefix sum of middle parts
int main() {
    int N;
    ri(N);
    FOR(i,0,N) ri(A[i]);
    FOR(i,0,N) ri(B[i]);
    FOR(i,0,N) ri(C[i]);
    // sort parts
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    ll ans=0;   // answer

    /*
        for each middle part, find number of lower parts that
        can be put below
    */
    FOR(i,0,N) {
        int b = B[i];
        // with Binary Search, find minimum lower part greater than b
        auto itr = upper_bound(C, C+N, b);
        /*
            number of lower parts that can be put below b are all greater
            or equal than minimum lower part greater than b
        */
        preB[i] = distance(itr, C+N);
        /*
            prefix_sum(i) = (# valid lower parts below B[i]) + prefix_sum(i-1)
            prefix_sum(0) = (# valid lower parts below B[0])
        */
        if (i) preB[i] += preB[i-1];
    }

    /*
        for each upper part, find middle parts that can be put below
    */
    FOR(i,0,N) {
        int a = A[i];
        // finf minimum middle part greater than a
        auto itr = upper_bound(B, B+N, a);
        int idx = distance(B, itr);
        ans += preB[N-1] - preB[idx-1];
    }

    printf("%lld\n", ans);
}


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

int main() {
    int a, b, c;
    int x, y, z;

    cin >> x >> y >> z;
    a = x;
    b = y;
    c = z;

    swap(a, b);
    swap(a, c);

    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (3000)
#define MAX 100000
int main() {
	ll N, M, sum = 0, c = 0;
	scanf("%lld%lld", &N, &M);
	vector<ll> A(N);
	rep(i, 0, N)scanf("%lld", &A[i]), sum += A[i];
	rep(i, 0, N) {
		if (sum <= A[i] * (4 * M)) {
			c++;
		}
	}
	puts(c >= M ? "Yes" : "No");
	return 0;
}


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

#define DEBUG

using namespace std;

const int N = 1e5+7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

struct DSU
{
    int fa[N], num[N];
    void init(int sz) { for (int i = 0; i <= sz; ++i) fa[i] = i, num[i] = 1; }
    int get(int s) { return s == fa[s] ? s : fa[s] = get(fa[s]); }
    int& operator [] (int i) { return fa[get(i)]; }
    bool merge(int x, int y) {
        int fx = get(x), fy = get(y);
        if (fx == fy) return false;
        if (num[fx] >= num[fy]) num[fx] += num[fy], fa[fy] = fx;
        else num[fy] += num[fx], fa[fx] = fy;
        return true;
    }
} dsu;

int n, m, k;
vector<int> fp[N], bp[N];
map<int, int> vis;

inline void solve()
{
    cin >> n >> m >> k;
    dsu.init(n);
    for (int i = 1, u, v; i <= m; ++i) {
        cin >> u >> v;
        dsu.merge(u, v);
        fp[u].emplace_back(v);
        fp[v].emplace_back(u);
    }
    for (int i = 1, u, v; i <= k; ++i) {
        cin >> u >> v;
        bp[u].emplace_back(v);
        bp[v].emplace_back(u);
    }
    for (int i = 1; i <= n; ++i) {
        int res = dsu.num[dsu[i]]-1;
        vis.clear();
        for (int j : fp[i]) {
            if (vis.count(j)) continue;
            vis.insert({j, 1});
            if (dsu[i] == dsu[j]) --res;
        }
        for (int j : bp[i]) {
            if (vis.count(j)) continue;
            vis.insert({j, 1});
            if (dsu[i] == dsu[j]) --res;
        }
        cout << res << " \n"[i==n];
    }
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 17272
import sys
n = int(sys.stdin.readline().rstrip())
m = int(sys.stdin.readline().rstrip())
l = []
for i in range(m):
    l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))
for i in range(n):
    cur = i+1
    for d in l[::-1]:
        if cur in d:
            cur = d[0] if cur == d[1] else d[1]
    print(cur)

Measured memory_bytes: 7648
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*(b//gcd(a, b))

mod = int(1e9+7)
def ext_gcd(a, b, x, y):
    if b==0:
        x[0] = 1
        y[0] = 0
        return a
    g = ext_gcd(b, a%b, y, x)
    y[0]-=a//b*x[0]
    return g

def mod_inv(a):
    x = [0]
    y = [0]
    ext_gcd(a, mod, x, y)
    return (x[0]%mod + mod)%mod;

n = int(input())
vs = list(map(int, input().split()))
l = 1
for x in vs:
    l = lcm(l, x)
l = l%mod;
ans = 0
for x in vs:
    ans = (ans + ((l*mod_inv(x))%mod))%mod
print(ans)


Measured memory_bytes: 4084
using System;
using System.Linq;

namespace ABC150
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (input[1] <= 500 * input[0]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	
	

	public static void main(String[] args)  {
		
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		
		int start = str.indexOf("A");
		int last = str.lastIndexOf("Z");
		
		
		
		System.out.println(last - start + 1);
		

	}

}


Measured memory_bytes: 14412
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 



int color[100005]; // 0:=fennic 1:=snule
vi to[100005];

int n;
vi path;

void dfs(int v, int from=-1, int len=0) {
  if (v==n-1) {
    len--;
    int f=(len-1)/2 +1 ;
    rep(i,f) if (color[path[i]] != 2) color[path[i]] = 3;
    if (path.size()>f) color[path[f]] = 4;
    return;
  }
  for (int u: to[v]) {
    if (u==from) continue;
    path.push_back(u);
    dfs(u, v, len+1);
    path.pop_back();
  }
}

int main() {
  cin >> n;
  rep(i,n-1) {
  int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  color[0] = 1;
  color[n-1] = 2;

// find where is the intersection of black and white 
  dfs(0); 

  queue<int> q;

  // fill Black region
  q.push(0);
  while (q.size()) {
    int v=q.front(); q.pop();
    for (int u: to[v]) {
      if (color[u]==1 || color[u]==4 || color[u] == 2) continue;
      color[u] = 1;
      q.push(u);
    }
  }
  // fill white region
  q.push(n-1);
  while (q.size()) {
    int v=q.front(); q.pop();
    for (int u: to[v]) {
      if (color[u]==1||color[u]==2||color[u]==3) continue;
      color[u] = 2;
      q.push(u);
    }
  }

  // count black and white 
  int F=0, S=0;
  q.push(0);
  while (q.size()) {
    int v=q.front(); q.pop();
    if (color[v] == 1) F++;  
    if (color[v] == 2) S++;
    color[v] = 0;
    for (int u:to[v]) {
      if (color[u] == 0) continue;
      q.push(u);
    }
  }
  string winner = "Fennec";
  if (F>S) winner = "Fennec";
  if (F<S) winner = "Snuke";
  if (F==S) {
    winner = "Snuke";
  }
  cout << winner << endl;
  return 0;
}

Measured memory_bytes: 15876
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for pick in range(min(K+1, N+1)):
    for right in range(pick+1):
        left = pick-right
        pick_list = V[:right]+V[N-left:]

        pick_list = sorted(pick_list)
        tmp_ans = sum(pick_list)
        rem = min(K-pick, len(pick_list))
        for i in range(rem):
            if pick_list[i] < 0:
                tmp_ans -= pick_list[i]
            else:
                break
        ans = max(tmp_ans, ans)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a[20];
int x[20][20],y[20][20];
bool b[20];
int dfs(int dep){
    if(dep==n){
        rep(i,n){
            if(b[i]){
                rep(j,a[i]){
                    if(y[i][j]==1&&b[x[i][j]-1]==false)return 0;
                    else if(y[i][j]==0&&b[x[i][j]-1]==true)return 0;
                }
            }
        }
        int cnt=0;
        rep(i,n){
            if(b[i])cnt++;
        }
        return cnt;
    }
    b[dep]=true;
    int c=dfs(dep+1);
    b[dep]=false;
    int d=dfs(dep+1);
    return max(c,d);
    
}
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans=dfs(0);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{int n,l;
string x[100];
cin>>n>>l;
for(int i=0;i<n;i++)
cin>>x[i];
sort(x,x+n);
for(int i=0;i<n;i++)
cout<<x[i];
cout<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];

    if(n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(d));

    cout << d[n/2] - d[n/2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int64_t A,B,C;
  cin>>A>>B>>C;
  if(A%2==0||B%2==0||C%2==0){
    cout<<0<<endl;
  }
  else{
    cout<<min({A*B,A*C,B*C})<<endl;
  }
  return 0;
}

Measured memory_bytes: 3596
n, k = map(int, input().split())
p = [int(pi) - 1 for pi in input().split()]
c = list(map(int, input().split()))
A = max(c)
seen = [False] * n
for i in range(n):
    if seen[i]:
        continue
    ids = []
    ccost = 0
    while not seen[i]:
        ccost += c[i]
        ids.append(i)
        seen[i] = True
        i = p[i]
    #print(ids)
    cn = len(ids)
    ccnt, m = divmod(k, cn)
    if ccnt > 0:
        ccnt -= 1
        m += cn
    ans = max(c[i] for i in ids)
    for s in ids:
        so = s
        now = 0
        for _ in range(m):
            s = p[s]
            now += c[s]
            #print(so+1, s+1, now)
            ans = max(now, ans)
    if ccost > 0:
        ans += ccnt * ccost
    A = max(A, ans)
print(A)

Measured memory_bytes: 69024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        String str = sc.next();
        
        String str1 = str.substring(0,num2 - 1);
        String str2 = str.substring(num2 - 1, num2);
        String str3 = str.substring(num2);

        System.out.println(str1 + str2.toLowerCase() + str3);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
  int n,len = 2;
  string s;
  cin >> n >> s; n = 1<<n;
  set<string> a;
  while(len<=n){
    for(int i=0;i<n;i+=len){
      if(s.substr(i,len/2) != s.substr(i+len/2,len/2))
	a.insert(s.substr(i,len));
    }
    len <<= 1;
  }
  cout << a.size() << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long
#define INF (long long)(1LL << 62)
using namespace std;

signed main(){

	llong n, T, Q;
	cin >> n >> T >> Q;

	vector<llong> a(n), d(n), q(Q);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> d[i];
	}
	for(int i = 0; i < Q; ++i){
		cin >> q[i];
	}

	vector<llong> kabe;
	kabe.push_back(-1 * INF);
	for(int i = 0; i < n - 1; ++i){
		if(d[i] == 1 && d[i+1] == 2){
			kabe.push_back((a[i] + a[i+1]) / 2);
		}
	}
	kabe.push_back(INF);

	/*
	cout << endl;
	for(auto itr = kabe.begin(); itr != kabe.end(); ++itr){
		cout << *itr << endl;
	}	
	cout << endl;
*/
	for(int i = 0; i < Q; ++i){
		int idx = q[i];
		idx--;
		if(d[idx] == 1){
			llong k = *upper_bound(kabe.begin(), kabe.end(), a[idx]);
			//cout << "debug " << k << " " << a[idx] + T << endl; 
			if(a[idx] + T >= k){
				cout << k << endl;
			}else{
				cout << a[idx] + T << endl;
			}
		}else{
			llong k = *prev(lower_bound(kabe.begin(), kabe.end(), a[idx]));
			//cout << "debug2 " << k << endl;
			if(a[idx] - T >= k){
				cout << a[idx] - T << endl;
			}else{
				cout << k << endl;
			}

		}
	}
	return 0;
}




Measured memory_bytes: 4768
#include<cstdio>
#include<iostream>
using namespace std;
const int N=3e3+10;
const int M=1e7+10;
int n,mod,ans,s[N][N],t[N],fac[N],inv[N],f[N],g[N][N],sav[M],now;
inline int MOD(int x){x-=x>=mod? mod:0;return x;}
inline int Minus(int x){x+=x<0? mod:0;return x;}
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int fas(int x,int p,int M){int res=1;while(p){if(p&1)res=1ll*res*x%M;p>>=1;x=1ll*x*x%M;}return res;}
inline void Preprocess(){
	fac[0]=1;for(register int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(register int i=2;i<=n;i++)inv[i]=(-1ll*mod/i*inv[mod%i]%mod+mod)%mod;
	for(register int i=2;i<=n;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
inline int C(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main(){
	scanf("%d%d",&n,&mod);Preprocess();
	ans=fas(2,fas(2,n,mod-1),mod);s[0][0]=1;
	for(register int i=1;i<=n+1;i++)
		for(register int j=1;j<=i;j++)
			s[i][j]=MOD(s[i-1][j-1]+1ll*j*s[i-1][j]%mod);
	for(register int i=1;i<=n;i++)f[i]=fas(2,fas(2,n-i,mod-1),mod);
	now=1;for(register int i=0;i<=n*n;i++)sav[i]=now,now=2ll*now%mod;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=i;j++)
			g[i][j]=sav[(n-i)*j];
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=n;j++)
			Add(t[i],1ll*s[i+1][j+1]*C(n,i)%mod*f[i]%mod*g[i][j]%mod);
	for(register int i=1;i<=n;i++)
		if(i&1)ans=Minus(ans-t[i]);else Add(ans,t[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 108032
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l=0,r;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(t=1;t<=n;t++)
            {
                l+=__gcd(__gcd(i,j),t);
            }
        }
    }
    cout<<l<<"\n";
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int sum = 0;
  int restore = 0;
  for (int i = 0; i < N; i++){
    cin >> d[i];
    sum += d[i];
  }
  for (int i = 0; i < N; i++){
    restore += d[i] * (sum - d[i]);
  }
  cout << restore / 2 << endl;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
point = [0 for _ in range(n)]
for i in range(q):
    a = int(input())
    point[a - 1] += 1
# print(point)
for i in range(n):
    point[i] += k - q
    if point[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 51104
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
n = int(input())
print(str.lower(num2alpha(n)))

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
const long long inf = -1e18;
const int o = (1<<18);
long long n[2*o], prop[2*o];
long long bio[200005];
vector <pair <long long, long long> > lg[200005];
void sp(int poz)
{
	n[poz*2] += prop[poz];
	prop[poz*2] += prop[poz];	
	n[poz*2+1] += prop[poz];
	prop[poz*2+1] += prop[poz];
	prop[poz] = 0;
}
void u(int l, int r, int p, int k, int poz, long long x)
{
    if(l > k || r < p)
    {
    	return;
	}
	if(l >= p && r <= k)
	{
		n[poz] += x;
		prop[poz] += x;
		return;
	}
	sp(poz);
	u(l, (l+r)/2, p, k, poz * 2, x);
	u((l+r)/2+1, r, p, k, poz * 2 + 1, x);
	n[poz] = max(n[poz*2], n[poz*2+1]);
}
long long g(int l, int r, int p, int k, int poz)
{
	if(l > k || r < p)
	{
		return inf;
	}
	if(l >= p && r <= k)
	{
		return n[poz];
	}
	sp(poz);
	return max(g(l, (l+r)/2, p, k, poz*2), g((l+r)/2+1, r, p, k, poz*2+1));
}
int main()
{
	for(int i = 0; i < 2*o; i++)
	{
		n[i] = 0;
		prop[i] = 0;
	}
	int b, q;
	cin >> b >> q;
	int p, k, d;
	long long maxb = 0;
	for(int i = 0; i < q; i++)
	{
		cin >> p >> k >> d;
		p--;
		k--;
		lg[k].push_back(make_pair(p, d));
		u(0, o-1, p, o-1, 1, -d);
	}
	for(int i = 0; i < b; i++)
	{
		bio[i] = -g(0, o-1, i, i, 1);
		bio[i] = max(bio[i], bio[i]+g(0, o-1, 0, i-1, 1));
		maxb = max(maxb, bio[i]);
		u(0, o-1, i, i, 1, bio[i]);
		if(!lg[i].empty())
		{
			for(int j = 0; j < lg[i].size(); j++)
			{
				u(0, o-1, lg[i][j].first, o-1, 1, lg[i][j].second);
			}
		}
		//cout << bio[i] << endl;
	}
	cout << maxb << endl;
	return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int occ[maxn];
int jmp[maxn];
char bc[maxn];
int dp[maxn];

int main() {
	IOS;
	string a; cin>>a; int n = a.size(); a = " " + a; a[0] = '$';
	fill(occ, occ+300, 1e7);
	for (int i = n; i >= 0; i--) {
		dp[i] = 1e7;
		for (int j = 'a'; j <= 'z'; j++) {
			int cur = 1 + ((occ[j] > n)?1:dp[occ[j]]);
			if (cur < dp[i]) { dp[i] = cur; bc[i] = j; jmp[i] = occ[j]; }
		}
		occ[a[i]] = i;
	}

	string s = ""; int cur = 0;
	while (cur < 1e7) {
		s += bc[cur];
		cur = jmp[cur];
	}
	cout<<s<<endl;
}


Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    int N; cin>>N;
    string S; cin>>S;
    int s = S.size();
    if(s<=N) Out(S);
    else{
        REP(i,N) cout<<S[i];
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    ll N,K; cin>>N>>K;
    ll A[N+1];
    for(ll i=1; i<=N; i++) cin>>A[i];
    sort(A+1, A+N+1);
    ll sum = 0;
    for(ll i=1; i<=K; i++) sum += A[i];
    cout<<sum;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    string s; cin >> s;
    map<char, ll> mp;
    ll ans = 1;
    rep(i,n){
        mp[s[i]]++;
    }
    for(auto i : mp){
        ans *= i.second+1 % MOD;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

struct edge
{
	int32_t to, cost;
};

int main()
{
	int32_t N, M;
	scanf("%d%d", &N, &M);

	bool edges_exists[100][100];
	for (int32_t i = 0; i < N; i++)
		fill(edges_exists[i], edges_exists[i] + N, false);
	vector<struct edge> edges[100];
	for (int32_t i = 0; i < M; i++) {
		int32_t a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		edges[a].push_back({b, c});
		edges[b].push_back({a, c});
		edges_exists[a][b] = true;
		edges_exists[b][a] = true;
	}

	int32_t d[100], prev[100];

	for (int32_t start = 0; start < N; start++) {
		// dijkstra
		priority_queue<pair<int32_t, int32_t>, vector<pair<int32_t, int32_t>>> pq; // pair<dist, node>
		fill(d, d + N, numeric_limits<int32_t>::max() / 2);
		fill(prev, prev + N, -1);
		d[start] = 0;
		pq.push(make_pair(d[start], start));

		while (!pq.empty()) {
			pair<int32_t, int32_t> p = pq.top(); pq.pop();
			int32_t dist = p.first;
			int32_t node = p.second;
			if (d[node] < dist)
				continue;

			for (size_t i = 0; i < edges[node].size(); i++) {
				struct edge e = edges[node][i];
				if (d[e.to] > d[node] + e.cost) {
					d[e.to] = d[node] + e.cost;
					pq.push(make_pair(d[e.to], e.to));
					prev[e.to] = node;
				}
			}
		}

		// path from end to start
		for (int32_t end = 0; end < N; end++) {
			int32_t node = end;
			while (node != start) {
				edges_exists[node][prev[node]] = false;
				edges_exists[prev[node]][node] = false;
				node = prev[node];
			}
		}
	}

	int32_t res = 0;
	for (int32_t i = 0; i < N; i++)
		for (int32_t j = 0; j < N; j++)
			if(edges_exists[i][j])
				res++;

	printf("%d\n", res / 2);

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split()) # 横に2個
XY = [list(map(int, input().split())) for _ in range(M)]

balls = [1 for _ in range(N)]
red = [False for _ in range(N)]
red[0] = True
for i in range(M):
    x, y = XY[i]
    x -= 1
    y -= 1
    if red[x]:
        red[y] = True
        if balls[x] == 1:
            red[x] = False
    balls[x] -= 1
    balls[y] += 1
print(sum(red))


Measured memory_bytes: 29080
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
#define LL long long
using namespace std;
LL sta[N],a[N],t[N],s[N],ans;
int tp,n,m;
int td(LL k,int r)
{
	int l=1,res=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(a[mid]<=k) res=mid,l=mid+1;
		else r=mid-1;
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&m);
	sta[tp=1]=n;
	for(int i=1;i<=m;i++)
	{
		LL x;scanf("%lld",&x);
		while(x<=sta[tp]) tp--;
		sta[++tp]=x;
	}
	m=tp;
	for(int i=1;i<=m;i++) a[i]=sta[i];
	t[m]=1;
	for(int i=m;i>=1;i--)
	{
		LL k=a[i];int p=td(k,i-1);
		while(p)
		{
			t[p]+=(k/a[p])*t[i];
			k%=a[p];
			p=td(k,p-1);
		}
		s[1]+=t[i];s[k+1]-=t[i];
	}
	for(int i=1;i<=n;i++) {ans+=s[i];printf("%lld\n",ans);}
	return 0;
}

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

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    int j = x - i;
    if (i * 2 + j * 4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3616
s = gets.to_s
s = s.gsub(/[\r\n]/,"")
zenhan = ((s.length-1)/2) - 1 
part1 = s[0..zenhan]
kouhan = ((s.length+3)/2) - 1
part2 = s[kouhan..s.length]


part1 = part1.gsub(/[\r\n]/,"")
part2 = part2.gsub(/[\r\n]/,"")

result = "No"

if s == s.reverse
    if part1 == part1.reverse
        if part2 == part2.reverse
            result = "Yes"
        end
    end
end

puts result

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

using namespace std;
#define LL long long

const int INF  = 0x3f3f3f3f;
const int MAXN = 512345;

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n, x;
	cin >> n >> x;

	vector <int> v (n);

	for (int i = 0; i < n; ++i) cin >> v[i];

	int cnt = 1, pos = 0;

	for (int i = 0; i < n; ++i) {
		pos += v[i];
		if (pos <= x) ++cnt;
	}

	cout << cnt << '\n';


	return 0;
}


Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;
 
    class Program
    {
    static bool LS<T>(IEnumerable<T> a,T k)
    {
    foreach (var i in a)
 
 {
 if (Object.Equals(i, k))return true;
}return false;
    }
        static void Main(string[] args)
        {
    Console.ReadLine();
var S=    Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

    Console.ReadLine();
var T=    Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int c = 0;
foreach (var s in T)
{
c += LS(S,s) ? 1 : 0;
}
Console.WriteLine(c);
}
    }


Measured memory_bytes: 24636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int N; cin >> N;
  ld x = 0;
  for (int i = 0; i < N; ++i) {
    ld a; cin >> a; x += 1.0 / a;
  }
  cout << 1.0/x << endl;
  return 0;
}


Measured memory_bytes: 3796
package main
 
import (
  "fmt"
  "math"
)
 
func main() {
  var n, m int
  fmt.Scan(&n, &m)
  a := make([]int, m)
  for i := range a {
    fmt.Scan(&a[i])
  }
  ans := 0
  for _, x := range a {
    ans += x
  }
  fmt.Println(math.Max(float64(n - ans), -1))
}

Measured memory_bytes: 2448
n = int( raw_input() )
A = [0]
p = range(1, n)
a = [ [ 0 for i in xrange(n) ] for j in xrange(n) ]
for i in xrange(n):
    a[i] = map( int,raw_input().split() )
l = 0
while p != []:
    a_min = 2001
    for i in A:
        for j in p:
            if 0 <= a[i][j] < a_min:
                a_min = a[i][j]
                add_A = j
    A.append( add_A )
    p.remove( add_A )
    l += a_min
print l

Measured memory_bytes: 6556
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n,m, a[N];

struct change{
    int b,c;
    bool operator <(const change& rhs)const{
        return c> rhs.c;
    }
};

change ch[N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    long long sum = 0;
    for (int i = 0; i < n; i++){
        cin>>a[i];
        sum += a[i];
    }
    
    for (int i = 0; i < m; i++){
        cin>>ch[i].b>>ch[i].c;
    }
    
    sort(a, a+n);
    sort(ch, ch +m);
    
    
    
    int idx = 0;
    for (int i = 0; i < m; i++){
        int changet0 = ch[i].c;
        int cnt = ch[i].b;
        while (idx<n && cnt && a[idx]< changet0) {
            sum += changet0 - a[idx];
            idx ++;
            cnt--;
        }
    }
    
    cout<<sum<<endl;
    
    
    return 0;
}



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

int main()
{
    int X, t;
    scanf("%d %d", &X, &t);
    if (X-t<=0)
    {
        printf("0");
    }
    else
    {
        printf("%d", X-t);
    }
    return 0;
}

Measured memory_bytes: 256
import queue
N = int(input())

q =  queue.Queue()
for i in range(1,10):
    q.put(i)

i = 0
while True:
    out = q.get()
    i += 1
    if i == N:
        break
    b = out*10
    if out%10 > 0:
        q.put(b+out%10-1)
    q.put(b+out%10)
    if out%10 < 9:
        q.put(b+out%10+1)
    
print(out)

Measured memory_bytes: 12488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

int main(void) {
    ll N;
    cin >> N;
    ll query = 0, last = 0;
    string res, before;
    cout << last << endl;
    cin >> before;
    if (before == "Vacant") {
        cout << last << endl;
        return 0;
    }

    query = N / 2;

    for (ll i = 1; i < 20; i++) {
        cout << query << endl;
        cin >> res;

        if (res == "Vacant") {
            return 0;
        }

        bool even = abs(query - last) % 2 == 0;
        bool equal = res == before;
        bool posi = query > last;

        ll nq;
        if ((posi && ((!even && equal) || (even && !equal))) || (!posi && ((even && equal) || (!even && !equal)))) {
            nq = query - (abs(query - last) + 1) / 2;
        } else {
            nq = (abs(query - last) + 1) / 2 + query;
        }

        last = query;
        query = nq;

        before = res;
    }
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,k;
    cin >> n >> k;
    if(k==1) {
        cout << 0 << '\n';
        return 0;
    }

    cout << n-k << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
#define mod 1000000007
#define inf (1ll<<60)
using namespace std;
bool sortit(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return a.second<b.second;
}
int main()
{
    iof;
    ll n,w; cin>>n>>w;
    vector<pair<ll,ll> >v;
    ll mx=-1;
   // v.push_back({0,0});
    for(ll i=0;i<n;i++)
    {
        ll x,y; cin>>x>>y;
        v.push_back({x,y});
        mx=max(mx,y);
    }
    sort(v.begin(),v.end(),sortit);
    ll dp[n+1][mx*n+1];
    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=mx*n;j++)
            dp[i][j]=inf;
    for(ll i=0;i<=n;i++)
        dp[i][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=mx*n;j++)
        {
            if(v[i-1].second>j)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=min(dp[i-1][j-v[i-1].second]+v[i-1].first,dp[i-1][j]);
        }
    }

    for(ll i=mx*n;i>=1;i--)
    {
        if(dp[n][i]<=w and dp[n][i]>0)
        {
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 79232
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

import qualified Data.Map.Strict as Map

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	m1 <- readMap
	m2 <- readMap
	putStrLn $ which "YES" "NO" $ Map.isSubmapOfBy (<=) m2 m1

readMap :: IO ( Map.Map Int Int )
readMap = getLine >> getList >>= return . foldr f Map.empty

f a m
	| Map.lookup a m /= Nothing = Map.adjust succ a m
	| otherwise = Map.insert a 1 m


Measured memory_bytes: 68988
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

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

int main(){
	string str;
	cin >> str;

	rep(i, str.length() - 1) {
		
		if (str.substr(i, 2) == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
		//cout << str.substr(i,2) << endl;
	}
	cout << "No" << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
char changec(int c){
    char a=char('0'+c);
    return a;
}
int change(char c){
    return int(c-'0');
}
bool check(int c){
    if(c!=-1&&c!=-2)return true;
    else return false;
}
vector<pair<int,int>> zyun(vector<pair<int,int>> v,int tens){
  vector<pair<int,int>> ret;
  int i=0;
  while(i<v.size()){
      //cout<<i<<endl;

      if(!check(v[i].second)&&v[i].first==tens-1){//vが演算子である

         if(i+1<v.size()&&check(v[i+1].second)&&v[i+1].first==tens){
             int ii=i+1;int pu=1;int c=0;
             while(true){
                 if(ii>=v.size()||v[ii].first!=tens||!check(v[ii].second)){break;}
                 else{
                     c++;
                     if(v[i].second==-2){
                         pu+=v[ii].second;
                         if(ii==i+1)pu-=1;
                     }
                     else{pu*=v[ii].second;}
                     ii++;
                 }
             }

             if(c>=2){
                 ret.push_back({tens-1,pu});
                 i=ii;
             }else{
                 ret.push_back(v[i]);
                 i++;
             }

         }else{
             ret.push_back(v[i]);
             i++;
         }
      }else{
          ret.push_back({v[i].first,v[i].second});
          i++;
      }



  }
    return ret;

}
int main() {
    int n;
    while(true) {
        cin >> n;
        if(n==0)break;
        vector<pair<int,int>> v;
        rep(i,n){
            string s;
            cin>>s;
            int ten=0;
            while(true){
                if(s[ten]!='.')break;
                ten++;
            }
            char c=s[s.size()-1];
            if(c=='*'){
                v.push_back({ten, -1});
            }else if(c=='+'){
                v.push_back({ten, -2});
            }else {
                v.push_back({ten, change(s[s.size() - 1])});
            }
        }
        int k=0;

//        rep(i,v.size()){
//            cout<<v[i].first<<v[i].second<<endl;
//        }
//        cout<<endl;
for(int i=15;i>=1;i--){

        //while(v.size()!=1){
            v=zyun(v,i);
//            if(k<2){
//                rep(i,v.size()){
//                    cout<<v[i].first<<v[i].second<<endl;
//                }
//                k++;
//            }
        }


        cout<<v[0].second<<endl;
    }




    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  ll pulas_min = n % k;
  ll minasu_min = pulas_min - k;
  if (minasu_min < 0) {
    minasu_min *= -1LL;
  }
  cout << min(pulas_min, minasu_min) << endl;
  return 0;
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int n, Asum, Bsum,a,b,i;
	while (fscanf(stdin, "%d", &n), n != 0) {
		Asum = Bsum = 0;
		for (i = 0; i < n; i++) {
			fscanf(stdin, "%d%d", &a, &b);
			if (a == b) Asum += a, Bsum += a;
			else if (a > b) Asum += (a + b);
			else Bsum += (a + b);
		}
		fprintf(stdout, "%d %d\n", Asum, Bsum);
	}
	return 0;
}

Measured memory_bytes: 604
// https://atcoder.jp/contests/abc099/tasks/abc099_b

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

void solve() {
  ll a, b;
  cin >> a >> b;
  ll diff = b - a;
  ll a_act = (diff - 1) * diff / 2;
  ll res = a_act - a;
  cout << res << endl;
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long long int a,b,x,ans1,ans2,result=0;
  char str[128];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%lld %lld %lld",&a,&b,&x);
  
  ans1 = b/x;
  ans2 = (a-1)/x;
  if(a == 0)ans2 = -1;
  
  result = ans1 - ans2;
  
  printf("%lld",result);
  
  return 0;
}

Measured memory_bytes: 128