akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)

int main(int argc, char* argv[])
{
    ZOOM
    //freopen("in.txt","r",stdin);

    ll A,B,M,mn,mn1,mn2;
    mn1 = mn2 = mn =2e9;
    cin>>A>>B>>M;
    vector<ll> a(A),b(B);

    for(ll i=0;i<A;++i)
    {
        cin>>a[i];
        mn1 = min(mn1,a[i]);
    }
    for(ll i=0;i<B;++i)
    {
        cin>>b[i];
        mn2 = min(mn2,b[i]);
    }


    mn = mn1+mn2;
    for(ll i=0;i<M;++i)
    {
        int a1,b1,c;
        cin>>a1>>b1>>c;
        mn = min(mn , a[a1-1]+b[b1-1]-c);
    }

    cout<<mn;



    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {
    
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n)    cin>>h[i];

    sort(all(h));

    ll sum=0;

    rep(i,n-k) {
        sum+=(ll)h[i];
    }

    if(sum<0)   sum=0;

    cout<<sum<<endl;

 return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}



int n,a[5555],b[5555];
ll d[2525],c[5555];
bool pos[2][2525];
vector<int> g[2][2525];

void dfs(int v, int k){
	int i;
	if(pos[k][v]){
		return;
	}
	pos[k][v] = true;
	for(i=0; i<g[k][v].l_ength(); ++i){
		dfs(g[k][v][i],k);
	}
}

int main(void){
	int m,i,cnt=0,j;
	bool update,loop = false;
	ll p;
	fill(d,d+2525,INFLL);
	d[1] = 0ll;
	cin >> n >> m >> p;
	for(i=0; i<m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		c[i] = p - c[i];
		g[0][a[i]].push_back(b[i]);
		g[1][b[i]].push_back(a[i]);
	}
	dfs(1,0); dfs(n,1);
	for(i=0; i<n; ++i){
		pos[0][i] &= pos[1][i];
	}
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			if(d[b[i]]>d[a[i]]+c[i]){
				update = true;
				d[b[i]] = d[a[i]]+c[i];
			}
		}
		if(!update){
			break;
		}
		if(cnt > n){
			break;
		}
		++cnt;
	}
	for(j=0; j<n; ++j){
		for(i=0; i<m; ++i){
			if(d[b[i]]>d[a[i]]+c[i]){
				d[b[i]] = d[a[i]]+c[i];
				if(pos[0][b[i]]){
					loop = true;
				}
			}
		}
	}
	if(loop){
		cout << -1 << endl;
		return 0;
	}
	cout << max(-d[n],0ll) << endl;
	return 0;
}


Measured memory_bytes: 768
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
#define endline "\n"
#define in(x) scanf("%d",&x);
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
int main() {
	fastIO;
	int test = 1 , j = 1;
	//cin >> test;
	while (test--) {
		string s, t;
		cin >> s >> t;
		int res = s.length();
		int len = s.length() - t.length();
		for (int i = 0; i <= len; i++) {
			int mini = 0;
			for (int j = 0; j < t.length(); j++) {
				if (s[i + j] != t[j]) mini++;
			}
			res = min(mini , res);
		}
		cout << res << endl;

	}
	return 0;
}





Measured memory_bytes: 3640
#include <iostream>
#define Q 100005
using namespace std;
typedef long long ll;
int n,q,t[Q],p[Q];
bool marked[Q];
char c[Q];
ll ans;

int find(int x){
  if(marked[x]) return x;
  return p[x]=find(p[x]);
}

int main(){
  while(1){
    cin>>n>>q;
    if(!n&&!q) break;
    for(int i=1;i<=n;i++) marked[i]=false;
    for(int i=2;i<=n;i++) cin>>p[i];
    marked[1]=true;
    for(int i=0;i<q;i++){
      cin>>c[i]>>t[i];
      if(c[i]=='M'){
	if(marked[t[i]]) c[i]='E';
	marked[t[i]]=true;
      }
    }
    ans=0;
    for(int i=q-1;i>=0;i--){
      if(c[i]=='E') continue;
      if(c[i]=='M') marked[t[i]]=false;
      else ans+=find(t[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2288
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	string s,t;
	cin>>s>>t;
	int n=s.length(),m=t.length();
	s='x'+s;
	t='x'+t;
	vector<vector<int>> dp(n+1,vector<int> (m+1,0));
	vector<vector<int>> path(n+1,vector<int> (m+1));
	rep(i,1,n+1){
		rep(j,1,m+1){
			if(s[i]==t[j]){
				dp[i][j]=dp[i-1][j-1]+1;
				path[i][j]=1;
			}
			if(dp[i-1][j]>dp[i][j]){
				dp[i][j]=dp[i-1][j];
				path[i][j]=0;
			}
			if(dp[i][j-1]>dp[i][j]){
				dp[i][j]=dp[i][j-1];
				path[i][j]=2;
			}
		}
	}

	string ans="";
	int i=n,j=m;
	while(ans.length()<dp[n][m]){
		if(path[i][j]==1){
			ans.pb(s[i]);
			i--;
			j--;
		}
		else if(path[i][j]==0){
			i--;
		}
		else{
			j--;
		}
	}

	reverse(all(ans));

	cout<<ans;
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 144140
A,B,K = map(int,input().split())
if K >= (B - A + 1)/2:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B -K +1,B+1):
        print(i)

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int dp[101][101];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    string s;
    cin >> s;

    set<char> ss(s.begin(),s.end());

    for(int i = 0; i < 26; i++)
    {
      char ch = 'a' + i;
      if(!ss.count(ch))
      {
        cout << ch;
        return 0;
      }
    }

    cout << "None";
    return 0;   
}


Measured memory_bytes: 3684
n,k=map(int, input().split())
s=input()
st=[0]
for i in range(1,n):
    if(s[i]!=s[i-1]):
        st.append(i)
st.append(n)
a=len(st)-1
if(s[0]=="0"):
    ans=st[min(2*k,a)]
    for i in range(1,a+1,2):
        ans=max(ans,st[min(2*k+1+i,a)]-st[i])
elif(s[0]=="1"):
    ans=0
    for i in range(0,a+1,2):
        ans=max(ans,st[min(2*k+1+i,a)]-st[i])
print(ans)

Measured memory_bytes: 7112
INF = float('inf')
def f_dp(x, a, b, c):
    dp = [[0] * (x + 1) for i in range(3)]
    dp[0][0] = a[0]
    dp[1][0] = b[0]
    dp[2][0] = c[0]

    for i in range(1, x):
        dp[0][i] = max(dp[1][i -1] + a[i], dp[2][i -1] + a[i])
        dp[1][i] = max(dp[0][i -1] + b[i], dp[2][i -1] + b[i])
        dp[2][i] = max(dp[0][i -1] + c[i], dp[1][i -1] + c[i])

    return dp

if __name__ == "__main__":
    n = int(input())
    abc = [map(int, input().split()) for _ in range(n)]
    a, b, c = [list(i) for i in zip(*abc)]
    dp = f_dp(n, a, b, c)

    print(max(dp[0][n-1], dp[1][n-1], dp[2][n-1]))
    


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

struct Node
{
    long long x, y;
    bool operator < (const Node &b)const
	{
        return x<b.x;
    }
}pt[100];

int k, n;

int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%lld%lld",&pt[i].x, &pt[i].y);
    sort(pt+1,pt+1+n);
    long long area =0x3f3f3f3f3f3f3f3f;
    for (int i=1;i<=n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            long long miny=min(pt[i].y, pt[j].y);
            long long maxy=max(pt[i].y, pt[j].y);
            for (int q=1;q<=n;q++)
            {
                if (pt[q].y>maxy||pt[q].y<miny) continue;
                int tot=0;
                for (int z=q;z<=n;z++)
                {
                    if (pt[z].y>maxy||pt[z].y<miny) continue;
                    tot++;
                    if (tot>=k)
                        area=min(area, (maxy-miny)*(pt[z].x-pt[q].x));
                }
            }
        }
    }
    printf("%lld\n",area);
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  bool ans = true;
  
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, 0, h) {
    rep(j, 0, w) {
      cin >> a.at(i).at(j);
    }
  }
  
  rep(i, 0, h) {
    rep(j, 0, w) {
      if(a.at(i).at(j) == '#') {
        if(i != 0 and a.at(i-1).at(j) == '#')//上
          continue;
        if(j != 0 and a.at(i).at(j-1) == '#')//左
          continue;
        if(i != h-1 and a.at(i+1).at(j) == '#')//下
          continue;
        if(j != w-1 and a.at(i).at(j+1) == '#')//右
          continue;
        ans = false;
        break;
      }        
    }
  }
  
  cout << (ans ?"Yes" :"No") << "\n";
  
}


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

int main()
{
  long long int n,k;
  cin >> n >> k;
  if(n%k == 0){
    cout << 0 << endl;
    return 0;
  }
  if( n <= (k/2) ){
    cout << n << endl;
    return 0;
  }
  n = n%k;
  cout << abs(n-k) << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    std::vector<int> arr(200);
    
    for (int i = 0; i < N; i++) cin >> arr.at(i);    
    
    
    int counter = 0;
    
    while (true) {
        bool exist_odd = false;
        for (int i=0; i < N; i++) {
            if (arr.at(i) % 2 != 0) exist_odd = true;
        }
        
            
        if (exist_odd) break;
            
        for (int i=0; i < N; i++) {
            arr.at(i) /= 2;
        }
        counter++;
    }
    cout << counter <<  endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false


void insertionSort(vector<int>& A) {
	int N = A.size();
	for (int i = 1; i <= N - 1; i++) {
		//print
		cout << A[0];
		for (int i = 1; i < A.size(); i++)
			cout << " " << A[i];
		cout << endl;

		int v = A[i];
		int j;
		for (j = i - 1; j >= 0 && A[j] > v; j--) {
			A[j + 1] = A[j];
		}
		A[j + 1] = v;
	}
	//print
	cout << A[0];
	for (int i = 1; i < A.size(); i++)
		cout << " " << A[i];
	cout << endl;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	int n; cin >> n;
	vector<int> A(n);
	cin >> A;

	insertionSort(A);
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[250000],n;
bool comp(ll a,ll b)
{
    return a>b;
}

ll segment(ll i)
{
    if(i==n)
        return i-1;
    if(arr[i]!=arr[i+1])
        return i;
    return segment(i+1);
}
int main()
{
    ll tc,m,i,a=1,b,flag=0,cnt=0;
    cin>>n;

    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n,comp);
    for(i=0;i<n;i++)
    {
        ll tt=segment(i);

        if(tt-i+1>=4&&flag==0)
        {
            cout<<arr[i]*arr[i]<<endl;exit(0);
        }
       if(tt-i+1>=2)
       {
           a*=arr[i];flag=1;
        cnt++;
        if(cnt==2) {cout<<a<<endl;exit(0);}

       }
            i=tt;

    }
  cout<<0<<endl;





}


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

int main(){
  vector<char> a(26);
  string w;
  cin >> w;
  rep(i, w.length()){
    a[w[i] - 'a']++;
  }
  bool ans = true;
  rep(i, 26){
    if(a[i] % 2) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#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 n;
    string s;
    cin >> n >> s;
    int ans;
    for(int i = 0; i <= n - 3; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    vector<int> B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    ll tot = 0;
    rep(i, M) tot += B[i];

    int j = M;
    int ans = 0;
    rep(i, N+1) {
        while (j > 0 && tot > K) {
            j -= 1;
            tot -= B[j];
        }
        if (tot > K) break;
        ans = max(ans, i+j);
        if (i == N) break;
        tot += A[i];
    }
    cout << ans << endl;

}

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

int main() {
  string s;
  cin >> s;
  int size = s.size();
  int cnt  = 0;
  for (int i = 1; i < size; i++) {
    if (s[i - 1] != s[i]) {
      s.erase(i - 1, 2);
      i = i - 2;
      if (i < 0) i = 0;
      cnt += 2;
      size -= 2;
      if (s.empty() || size == 1) break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n;cin>>n;
	ll ans=0;
	if(n==2){
		ans = 1;
	}
	else{
		vector<ll> div;
		for(ll i=2;i*i<=n;i++){
			if(n%i==0){
				if(i*i!=n){
					div.push_back(i);
					div.push_back(n/i);
				}
				else{
					div.push_back(i);
				}
			}
		}
		ll arr[div.size()];
		for(ll i=0;i<div.size();i++){
			arr[i] = n;
		}
		for(ll i=0;i<div.size();i++){
			while(arr[i]%div[i]==0){
				arr[i] /= div[i];
			}
			if(arr[i]%div[i]==1){
				ans++;
			}
		}
		for(ll i=2;i*i<=n-1;i++){
			if((n-1)%i==0){
				if(i*i!=(n-1)){
					ans+=2;
				}
				else{
					ans++;
				}
			}
		}
		ans+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char b;
    cin >> b;
    if(b == 'A') {
        cout << 'T' << endl;
    } else if (b == 'T'){
        cout << 'A' << endl;
    } else if (b == 'G'){
        cout << 'C' << endl;
    } else {
        cout << 'G' << endl;
    }
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  // c_p_c();
  int n;
  cin >> n;
  int a[n],s = 0;
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
    s+=a[i];
  }
  cout<<s-n<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    unsigned long long star[26];
    string EN,EX;
    cin >> N;
    cin >> EN;
    cin >> EX;
    for(int i=0;i<26;i++){
        star[i]=0;
    }
    star[EN[0]-0x61]=1;
    for(int i=1;i<N-1;i++){
        int en=EN[i]-0x61;
        int ex=EX[i]-0x61;
        if(star[ex]>0){
            star[en]=(star[ex]+star[en]) % 1000000007;
        }
    }
    cout << star[EX[N-1]-0x61]<< endl;
}



Measured memory_bytes: 3340
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] test = br.readLine().split(" ");
            int m = Integer.parseInt(test[0]);
            int f = Integer.parseInt(test[1]);
            int r = Integer.parseInt(test[2]);
            if(m == -1 && f == -1 && r == -1)
            	break;
            
            if ((m == -1) || (f == - 1))
            	System.out.println("F");
            else
            {
            	if((m + f) >= 80)
                	System.out.println("A");
            	else if((m + f) >= 65)
                	System.out.println("B");
            	else if((m + f) >= 50)
                	System.out.println("C");
            	else if((m + f) >= 30)
            	{
            		if (r >= 50)
            			System.out.println("C");
            		else
            			System.out.println("D");
            	}
            	else if ((m + f) < 30)
                	System.out.println("F");
            }
            
        }
        
		
	}

}

Measured memory_bytes: 24268
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            String[] cs = new String[n];
            int i = 0;
            while (sc.hasNext()) {
                cs[i++] = sc.nextLine();
            }
            String[] csm = cs.clone();
            mergeSort(csm, 0, cs.length);
            quickSort(cs, 0, cs.length - 1);
            boolean isStable = true;
            for (i = 0; i < cs.length; i++) {
                if (cs[i] != csm[i]) {
                    isStable = false;
                }
            }
            if (isStable) {
                System.out.println("Stable");
            } else {
                System.out.println("Not stable");
            }
            for (int j = 0; j < cs.length; j++) {
                System.out.println(cs[j]);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static int partition(String[] cs, int p, int r) {
        int x = Integer.parseInt(cs[r].split(" ")[1]);
        int i = p - 1;
        for (int j = p; j <= r; j++) {
            if (x >= Integer.parseInt(cs[j].split(" ")[1])) {
                i = i + 1;
                String tmp = cs[i];
                cs[i] = cs[j];
                cs[j] = tmp;
            }
        }
        return i;
    }

    private static void quickSort(String[] cs, int p, int r) {
        if (p < r) {
            int q = partition(cs, p, r);
            quickSort(cs, p, q - 1);
            quickSort(cs, q + 1, r);
        }
    }

    private static void mergeSort(String[] cs, int left, int right) {
        if ((left + 1) < right) {
            int mid = (left + right) / 2;
            mergeSort(cs, left, mid);
            mergeSort(cs, mid, right);
            merge(cs, left, mid, right);
        }
    }

    private static void merge(String[] cs, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        String[] ll = new String[n1];
        String[] rl = new String[n2];
        for (int i = 0; i < n1; i++) {
            ll[i] = cs[left + i];
        }
        for (int i = 0; i < n2; i++) {
            rl[i] = cs[mid + i];
        }
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            if (i < ll.length
                    && (j >= rl.length ||
                    Integer.parseInt(ll[i].split(" ")[1])
                            <= Integer.parseInt(rl[j].split(" ")[1]))) {
                cs[k] = ll[i];
                i = i + 1;
            } else {
                cs[k] = rl[j];
                j = j + 1;
            }
        }
    }
}



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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int color[8];
    for(int i=0;i<8;i++) color[i]=0;
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]<=3199){
            color[a[i]/400]++;
        }
        else if(a[i]>=3200) count++;
    }
    int ans=0;
    for(int i=0;i<8;i++){
        if(color[i]>0) ans++;
    }
    cout << max(1,ans) << " " << ans+count << endl;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll n;
ll a[3010];
ll dp_taro[3010][3010];
ll dp_jiro[3010][3010];

ll jiro(ll l, ll r);

ll taro(ll l, ll r){
	if(dp_taro[l][r]!=-1) return dp_taro[l][r];
	if(l==r) return dp_taro[l][r] = a[l];
	return dp_taro[l][r] = max(a[l]+jiro(l+1,r), a[r]+jiro(l,r-1));
}

ll jiro(ll l, ll r){
	if(dp_jiro[l][r]!=-1) return dp_jiro[l][r];
	if(l==r) return dp_jiro[l][r] = -a[l];
	return dp_jiro[l][r] = min(-a[l]+taro(l+1,r), -a[r]+taro(l,r-1));
}

void solve(){
	cin>>n;
	REP(i,n) cin>>a[i];
	memset(dp_taro,-1,sizeof(dp_taro));
	memset(dp_jiro,-1,sizeof(dp_jiro));

	cout<<taro(0,n-1)<<en;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 141952
#include <stdio.h>
#include <string.h>

int main(){
    int q, a, b, str_length, p_length;
    int i, j;
    char str[1028], get[1028], tmp[1000], command[16];

    scanf("%s%d", str, &q);
    while(q--){
        scanf("%s%d%d", command, &a, &b);
//        printf("%s%d%d\n", command, a, b);
        switch(command[2]){
            case 'i':
                for(i=a; i<=b; i++){
                    printf("%c", str[i]);
                }
                printf("\n");
                break;
            case 'v':
                for(i=0; i<a; i++){
                    tmp[i]=str[i];
                }
                for(i=b, j=a; i>=a; i--, j++){
                    tmp[j]=str[i];
                }
                for(i=b+1; i<strlen(str); i++){
                    tmp[i]=str[i];
                }
                for(i=0; i<strlen(str); i++){
                    str[i]=tmp[i];
                }
                break;
            case 'p':
                scanf("%s", get);
                for(i=0; i<a; i++){
                    tmp[i]=str[i];
                }
                for(i=a, j=0; i<=b; i++, j++){
                    tmp[i]=get[j];
                }
                for(i=b+1; i<strlen(str); i++){
                    tmp[i]=str[i];
                }
                for(i=0; i<strlen(str); i++){
                    str[i]=tmp[i];
                }
                break;
        }
    }

    return 0;
}



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

int main(){
  string a,b,c; cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
while True:
    m,f,r = map(int, input().split())
    if m == -1 and  f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

vint primeSieve(int n)
{
    vint ret;
    ret.reserve(n);
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            ret.pb(i);
            for (int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return ret;
}

void Main()
{
    int n;
    cin >> n;
    vint prime_nums = primeSieve(55555);

    vint ans;

    rep(i, 55555)
    {
        if (prime_nums[i] % 5 == 1)
        {
            ans.pb(prime_nums[i]);
        }
        if (ans.size() == n)
        {
            break;
        }
    }
    rep(i, n)
    {
        cout << ans[i] << (i == n - 1 ? "\n" : " ");
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  else {
    x = 1, y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll mod) {
  ll x, y;
  extgcd(a, mod, x, y);
  return (mod + x % mod) % mod;
}

ll modpow(ll a,ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll MAX_P = 2e5 + 10;

vector<ll> fact(MAX_P);
ll mod_fact(ll n, ll p, ll& e) {
  e = 0;
  if (n == 0) return 1;
  ll res = mod_fact(n / p, p, e);
  e += n / p;
  if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
  return res * fact[n % p] % p;
}

ll mod_comb(ll n, ll k, ll p) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll e1, e2, e3;
  ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
  if (e1 > e2 + e3) return 0;
  return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

  k = min(n - 1, k);
  fact[0] = 1;
  FOR(i, 1, MAX_P) fact[i] = fact[i - 1] * i % mod;
  ll ans = 1;
  FOR(i, 1, k + 1) {
    ll res = mod_comb(n, i, mod) * mod_comb(n - 1, n - i - 1, mod) % mod;
    ans += res;
    ans %= mod;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
int n,h[N],k;
int dp[N];

int solve(int idx){

    if(idx > n)
        return OO;
    if(idx == n-1)
        return 0;

    int& ret = dp[idx];
    if(~ret)
        return ret;

    ret = OO;
    for(int i = 1 ; i <= k ; ++i )
        ret = min(ret , solve(idx+i)+abs(h[idx]-h[idx+i]));
    return ret;
}

/*
void build(int idx){

    if(idx == n)
        return ;

    int& ret = dp[idx];
    if(ret == solve(idx+1)+abs(h[idx]-h[idx+1])){
        cout << abs(h[idx]-h[idx+1]) << " ";
        build(idx+1);
        return;
    }
    if(ret == solve(idx+2)+abs(h[idx]-h[idx+2])){
        cout << abs(h[idx]-h[idx+2]) << " ";
        build(idx+2);
        return;
    }
   // ret = min(solve(idx+1)+abs(h[idx]-h[idx+1]) , solve(idx+2)+abs(h[idx]-h[idx+2]));
    return ;
}

*/

    
int main(){
    

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);

    
    scanf("%d %d",&n,&k);
    loop(i, n) scanf("%d",h+i); 

    memset(dp ,-1 , sizeof dp);
    printf("%d\n",solve(0));
   // build(0);
    //puts("");


    


    return 0;
}

Measured memory_bytes: 8064
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n;
    cin >> n;
    int ans = inf;
    rep(i,n)
    {
        int a;
        cin >> a;
        int b = 0;
        while(a%2==0)
        {
            ++b;
            a/=2;
        }
        ans = min(ans,b);
    }
    cout << ans << endl;
}


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

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

int main()
{
    int R,G,B,N,count=0;
    
    cin >> R>>G>>B>>N;
    
    int rMax = ceil(N/R);
    int gMax = ceil(N/G);
    
    rep(r,rMax+1)
    {
        for(int g=0;g< gMax+1;g++)
        {
            double b = (double)(N-R*r-G*g)/(double)B;
            double b_ =floor(b);
            if(b_==b && b>=0 && b_>=0)
                count++;
        }
    }
    cout << count<< endl;
    return 0;
}


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

using namespace std;

int main(){
    
    int a, b, i = 1, resp = 0, k, aux;

    cin >> a >> b >> k;

    aux = min(a,b);

    for(i = aux; i > 0 && resp < k; --i){
        if(a%i == 0 && b%i == 0) resp++;
        //cout << a%i << " " << b%i << " " << resp << " " << i << endl;
    }
    


    cout << i+1 << endl;

    return 0;

}

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

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

int n, m, dp[N], used[N];
vector<vector<int>> g;

void solve(int v) {
	used[v] = true;
	for (int u : g[v]) {
		if (!used[u])
			solve(u);
		dp[v] = max(dp[v], dp[u] + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	cin >> n >> m;
	g.resize(n + 1);
	
	for (int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		g[u].push_back(v);
	}
	
	//for (int i = 1; i <= n; ++i) dp[i] = -1;

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (!used[i]) {
			solve(i);
			ans = max(ans, dp[i]);
		}
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#define ll long long 
using namespace std;

const int maxn = 1e5 + 100;
ll L[maxn]; ll R[maxn]; int nL; int nR; int K;

ll solve()
{
	for (int i = 1; i <= nL / 2; i++)
		swap(L[i], L[nL + 1 - i]);

	ll ans = 1e15;
	for (int i = 0; i <= min(nL, K); i++)
	{
		if (K - i <= nR && K - i >= 0)
			ans = min(ans, 2 * L[i] + R[K - i]);
	}

	for (int i = 0; i <= min(nR, K); i++)
	{
		if (K - i <= nL && K - i >= 0)
			ans = min(ans, 2 * R[i] + L[K - i]);
	}
	return ans;
}

int main()
{
	int N; cin >> N >> K;
	nL = 0; nR = 0;
	for (int i = 1; i <= N; i++)
	{
		ll x; cin >> x;
		if (x >= 0) R[++nR] = x;
		else L[++nL] = -x;
	}

	cout << solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a,b,c,s[3],ans;
int main(void){
    cin>>s[0]>>s[1]>>s[2];
    sort(s,s+3);
    a=s[2]-s[1];
    b=s[2]-s[0];
    b-=a;
    ans+=a;
    ans+=(b+1)/2;
    if(b%2==1)ans+=1;
    cout<<ans<<endl;
}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

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

    if(N%2 == 0) cout << N/2 -1 << endl;
    else cout << N/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	int n, t, up, down, m = 0, f = 0;
	string i, k;

	cin >> n;

	cout << 0 << endl;

	cin >> i;
	if (i == "Vacant") {
		return 0;
	}
	k = i;
	up = n - 1;
	down = 0;
	for (;;) {
		t = (up + down) / 2;
		if (m == t) {
			t++;
		}
		m = t;
		cout << t << endl;
		cin >> i;
		if (f - t < 0) {
			if (abs(f - t) % 2 == 0) {
				// cout << up << ' ' << down << " " << t << " 1" << endl;
				if (i == "Vacant") {
					return 0;
				}
				if (i == k) {
					down = t;
				}
				else {
					up = t;
				}
				// cout << up << ' ' << down << " " << t << " 1" << endl;
			}
			else {
				// cout << up << ' ' << down << " " << t << " 2" << endl;
				if (i == "Vacant") {
					return 0;
				}
				if (i != k) {
					down = t;
				}
				else {
					up = t;
				}
				// cout << up << ' ' << down << " " << t << " 2" << endl;
			}
		}
		else {
			if (abs(f - t) % 2 != 0) {
				// cout << up << ' ' << down << " " << t << " 1" << endl;
				if (i == "Vacant") {
					return 0;
				}
				if (i == k) {
					down = t;
				}
				else {
					up = t;
				}
				// cout << up << ' ' << down << " " << t << " 1" << endl;
			}
			else {
				// cout << up << ' ' << down << " " << t << " 2" << endl;
				if (i == "Vacant") {
					return 0;
				}
				if (i != k) {
					down = t;
				}
				else {
					up = t;
				}
				// cout << up << ' ' << down << " " << t << " 2" << endl;
			}
		}
		k = i;
		f = t;
	}
}

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

#define ll long long int
#define endl '\n'
#define inf 1e18
ll ar[100005];
ll dp[100005];
void testCase()
{
    
   // ll t; cin>>t; while(t--)
    {
      ll n,k;
      cin>>n>>k;
      ll ar[n];
      for(int i=1;i<=n;i++)
      cin>>ar[i];

      for(int i=1;i<=n;i++)
      dp[i]=INT_MAX;

      dp[1]=0;

      for(int i=2;i<=n;i++)
      {
          for(int j=i-1;j>=max(1LL,i-k);j--)
          {
              dp[i]=min(dp[i],dp[j]+abs(ar[j]-ar[i]));
          }
      }
    cout<<dp[n]<<endl;
    }       
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 5188
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvcha;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt ( n ) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
, z = 0, n = 0, sum = 0, i = 0, ans = 0, cnt = 0;
string s = "";

int main(void) {
	cin >> s;
	ans = s.size();
	rep(i, ans) {
		cout << "x";
	}
	cout << rt;
	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

ll N, ans;
string a;

int main(void) {
  cin >> N >> a;
  ll i = 0, j = N - 1;
  while (i < j) {
    while (i < N && a[i] == 'R')
      i++;
    while (j >= 0 && a[j] == 'W')
      j--;
    if (j < 0) {
      break;
    }
    if (i >= N) {
      break;
    }
    if (i < j) {
      ans++;
      swap(a[i], a[j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    string s;
    cin>>s;
    if(s[1]=='B')cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    map<int,int> mp;
    REP(i,n){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
        mp[tmp+1]++;
        mp[tmp-1]++;
    }
    int ans = 0;
    
    for(auto p : mp){
        ans = max(ans , p.second);
    }
    
    
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define N 100005
using namespace std;

struct kv
{
    int key, value;
};

bool cmp(kv a, kv b)
{
    return a.value > b.value;
}

int main()
{
    int n, change, a;
    struct kv even[N], odd[N];
    cin >> n;
    for (int i = 0; i < N; i++)
    {
        odd[i].key = i;
        odd[i].value = 0;
        even[i].key = i;
        even[i].value = 0;
    }

    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        if (i % 2 == 0)
        {
            even[a].value++;
        }
        else
        {
            odd[a].value++;
        }
    }

    sort(odd, odd + N, cmp);
    sort(even, even + N, cmp);

    if (odd[0].key != even[0].key)
    {
        change = n - odd[0].value - even[0].value;
    }
    else
    {
        change = min(n - odd[0].value - even[1].value, n - odd[1].value - even[0].value);
    }

    cout << change << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1)break;
        if(m==-1 || f==-1){
            cout << "F" <<endl;
        }
        else if(m+f>=80){
            cout << "A" << endl;
        }
        else if(m+f>=65){
            cout << "B" << endl;
        }else if(m+f>=50||r>=50){
            cout << "C" << endl;
        }else if(m+f>=30){
            cout << "D" <<endl;
        }else if(m+f<30){
            cout << "F" <<endl;
        }
    }
}


Measured memory_bytes: 3072