akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	
	int a,b,c;
	cin>>a>>b>>c;
	if(b<a)swap(a,b);
	if(a<=c&&c<=b)fin("Yes");
	else fin("No");
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}







Measured memory_bytes: 256
n=int(input())
sosu=[2]
def bunkai(num):
    flag=True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            flag=False
            break
    return flag
for i in range(3,n+1): #素数を見つける
    f=bunkai(i)
    if f:
        sosu.append(i)
#print(sosu)
count=[]
for i in range(len(sosu)):
    s=sosu[i]
    count_=0
    for j in range(2,n+1):
        flag2=True
        while flag2:
            if j%s==0:
                count_+=1
                j=j//s
            else:
                flag2=False
    count.append(count_)
mod=10**9+7
ans=1
for i in range(len(count)):
    ans=ans*(count[i]+1)
    ans=ans%mod
#print(count)
print(ans)

Measured memory_bytes: 39792
#include<iostream>
using namespace std;
int main(void){
	int n;
	cin>>n;
	int a[100];
	for(int i(0);i<n;i++){
		cin>>a[i];
	}
	int average_int;
	double average_double;
	int sum(0);
	for(int i(0);i<n;i++){
		sum += a[i];
	}
	average_int = sum/n;
	average_double = (double)sum/n;
	if((average_double - average_int)*10 >= 5)average_int++;
	int ans(0);
	for(int i(0);i<n;i++){
		ans += (a[i]-average_int)*(a[i]-average_int);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, m;
  cin>>n>>m;
  int h[n];
  for (int i=0; i<n; i++) cin>>h[i];
  vector<int> g[n];
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(h[b]);
    g[b].push_back(h[a]);
  }
  int cnt = 0;
  for (int i=0; i<n; i++) {
    sort(g[i].begin(), g[i].end());
    reverse(g[i].begin(), g[i].end());
    if (g[i].size() == 0 || g[i][0] < h[i]) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{

    int n, m;
    while (cin >> n, n)
    {
        cin >> m;
        int M[n][n];
        rep(i, n) rep(j, n) M[i][j] = 1e7;
        rep(i, m)
        {
            char dot;
            int a, b, c;
            cin >> a >> dot >> b >> dot >> c;
            M[a][b] = c;
            M[b][a] = c;
        }

        int d[n], sum = 0;
        rep(i, n) d[i] = 1e7;

        d[0] = 0;
        bool used[n] = {};

        while (1)
        {
            int u = -1, minv = 1e7;

            rep(i, n)
            {
                if (!used[i] && d[i] < minv)
                {
                    minv = d[i];
                    u = i;
                }
            }
            if (u == -1)
                break;
            used[u] = true;

            sum += minv;
            rep(i, n)
            {
                if (!used[i] && M[u][i] != 1e7 && d[i] > M[u][i])
                    d[i] = M[u][i];
            }
        }
        OP(sum / 100 - (n - 1));
    }

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>

using namespace std;
long long int N, W;
long long int v[108], w[108];

long long int dp[108][108000];

//大きいほうを返す関数	
long long int mx(long long int a, long long int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	cin >> N >> W;
	for(long long int i = 0;i < N;i++){
		cin >> w[i] >> v[i];
	}
	
	for(long long int i = 0;i < N;i++){
		for(long long int j = 0;j <= W;j++){
			if(i == 0){
				if(j >= w[0]){
					dp[i][j] = v[i];
				}
				else{
					dp[i][j] = 0;
				}
			}
			else if(j - w[i] < 0){
				dp[i][j] = dp[i-1][j];
			}
			else{
				dp[i][j] = 
		 mx(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
			}
		}
	}
	cout << dp[N-1][W] << endl;
}

Measured memory_bytes: 86144
list = []

n = gets.to_i
n.times{
    cmd, x = gets.split
    x = x.to_i
    case cmd
    when "insert"
        list.unshift(x)
    when "delete"
        idx = list.index(x)
        list.delete_at(idx) if idx
    when "deleteFirst"
        list.shift
    when "deleteLast"
        list.pop
    end
}
puts list.join(' ')


Measured memory_bytes: 21272
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
   ll a, b;
   cin >> a >> b;
   auto g = gcd(a, b);

   cout << a * b / g << "\n";


}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		StringBuffer sb = new StringBuffer();
		while(true){
			String input = br.readLine();
			
			if(input == null){
				break;
			}
			
			sb.append(input);
		}
		
		String seq = sb.toString();
		seq = seq.replaceAll(" ", "");
		
//		System.out.println(seq);
		
		//??¢?´¢????§?
		for(int i = 0; i < Integer.MAX_VALUE; i++){
			String intStr = Integer.toString(i);
			
			if(!seq.contains(intStr)){
				System.out.println(i);
				return;
			}
		}
	}

}

Measured memory_bytes: 26104
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, H = MI()
    A = [0] * N
    B = [0] * N
    amax = 0
    for i in range(N):
        a, b = MI()
        A[i] = a
        B[i] = b
        amax = max(amax, a)

    B_left = []
    for b in B:
        if amax < b:
            B_left.append(b)

    B_left = sorted(B_left, reverse=True)
    if len(B_left) > 0:
        ans = 0
        for i, b in enumerate(B_left):
            if H > 0:
                H -= b
                ans += 1
            else:
                break
        if H > 0:
            ans += ceil(H / amax)
    else:
        ans = ceil(H / amax)
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 18564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,C; cin >> N >> C;
    int X[N],V[N];
    rep(i,N) cin >> X[i] >> V[i];
    int A[N+1],B[N+1];
    A[0]=B[0]=0;
    rep(i,N){
        A[i+1]=A[i]+V[i];
    }
    rep(i,N){
        B[i+1]=B[i]+V[N-i-1];
    }
    int MA[N+1],MB[N+1];
    MA[0]=MB[0]=0;
    rep(i,N){
        MA[i+1]=max(MA[i],A[i+1]-X[i]);
    }
    rep(i,N){
        MB[i+1]=max(MB[i],B[i+1]-(C-X[N-i-1]));
    }
    int ans=0;
    rep(i,N+1){
        ans=max(ans,A[i]+MB[N-i]-(!i ? 0:X[i-1]*2));
        ans=max(ans,B[i]+MA[N-i]-(!i ? 0:(C-X[N-i])*2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll long long
#define mod 1000000007

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N; cin >> N;
	string str; cin >> str;
	stack<char> left, right;

	string ret = "";

	for (int i = 0; i < N; i++)
	{
		if (str[i] == '(')
		{
			left.push('(');
		}
		else
		{
			if (!left.empty() && left.top() == '(')
			{
				left.pop();
			}
			else
			{
				right.push(')');
			}
		}
	}
	for (int i = 0; i < right.size(); i++)
		cout << '(';
	cout << str;
	for (int i = 0; i < left.size(); i++)
		cout << ')';
	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
antena=[a,b,c,d,e]
for i in antena:
  for j in antena:
    if abs(i-j)>k:
      print(':(')
      exit()
print('Yay!')

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

#define int long long

int32_t main()
{

    int num;
    cin >> num;


    vector<int> arr(num);
    for (int i = 0; i < num; i++)
    {
        cin >> arr[i];
    }


    int temp = arr[0];
    int ans = 0;
    for (int i = 1; i < num; i++)
    {
        if (temp < arr[i])
        {
            temp = arr[i];
        }

        else if (temp > arr[i])
        {
            ans += (temp - arr[i]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<stack>
#include<algorithm>

using namespace std;

struct data{
	int x,i;
	data():x(0),i(0){}
	data(int y,int j):x(y),i(j){}
	friend bool operator<(const data &dt1,const data &dt2){return dt1.x<dt2.x;}
};

stack<int> s;
int n,x[80001],idx,tot,id[80001],low[80001],dfn[80001],scc,cid[80001];
vector<data> vec;
vector<int> point[80001];

void build(int o,int l,int r){
	id[o]=++tot;
	if(o>1)point[id[o>>1]].push_back(tot);
	if(l==r){int v=vec[l-1].i;point[id[o]].push_back(v<=n?v+n:v-n);return;}
	int m=l+r>>1;
	build(o<<1,l,m),build(o<<1|1,m+1,r);
}

void update(int o,int l,int r,int a,int b,int x){
	if(a>b)return;
	if(l==a&&r==b){point[x].push_back(id[o]);return;}
	int m=l+r>>1;
	if(m>=b)update(o<<1,l,m,a,b,x);else if(m<a)update(o<<1|1,m+1,r,a,b,x);else update(o<<1,l,m,a,m,x),update(o<<1|1,m+1,r,m+1,b,x);
}

pair<int,int> get(int i,int m){
	pair<int,int> res;int l=1,r=i,mid;
	while(l<=r)if(vec[i-1].x-vec[(mid=l+r>>1)-1].x>=m)l=mid+1;else r=mid-1;
	res.first=r+1,l=i,r=n<<1;
	while(l<=r)if(vec[(mid=l+r>>1)-1].x-vec[i-1].x<m)l=mid+1;else r=mid-1;
	res.second=l-1;
	return res;
}

void dfs(int u){
	low[u]=dfn[u]=++idx;s.push(u);
	for(int v:point[u])if(!dfn[v]){dfs(v);low[u]=min(low[u],low[v]);}else if(dfn[v]>0)low[u]=min(low[u],dfn[v]);
	if(low[u]==dfn[u]){int x;++scc;while(x!=u)x=s.top(),s.pop(),dfn[x]=-dfn[x],cid[x]=scc;}
}

bool check(int m){
	memset(low,scc=idx=0,sizeof(low)),memset(dfn,0,sizeof(dfn));for(int i=1;i<=80000;++i)point[i].clear();
	build(1,1,tot=n<<1);
	for(int i=1;i<=n<<1;++i){int r=vec[i-1].i;pair<int,int> pr=get(i,m);update(1,1,n<<1,pr.first,i-1,r),update(1,1,n<<1,i+1,pr.second,r);}
	for(int i=1;i<=n<<1;++i)if(!dfn[i])dfs(i);
	for(int i=1;i<=n;++i)if(cid[i]==cid[i+n])return false;
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d%d",x+i,x+n+i),vec.push_back(data(x[i],i)),vec.push_back(data(x[i+n],i+n));
	sort(vec.begin(),vec.end());
	int l=0,r=1000000000,m;while(l<=r)if(check(m=l+r>>1))l=m+1;else r=m-1;
	printf("%d",l-1);
}

Measured memory_bytes: 12652
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
using namespace std;
ll n,a[200000],b[200000];
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
}
sort(b,b+n);
if(b[n-2]!=b[n-1]){
    for(ll i=0;i<n;i++)
    if(a[i]!=b[n-1]){
        cout<<b[n-1]<<' ';
    }else cout<<b[n-2]<<' ';
}else {
for(ll i=0;i<n;i++)
    cout<<b[n-1]<<' ';
}
}


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

#define int long long

using namespace std;


int dp[100005];


signed main(){
    int q=1;
    // cin>>q;
    while(q--){
        int n;
        cin>>n;
        int i,j;
        i=0;
        j=n-1;
        char arr[n];
        int count=0;
        for(int i=0;i<n;i++) cin>>arr[i];
        while(i<j){
            if(arr[i]=='W'){
                if(arr[j]=='R'){
                    count++;
                    arr[i]='R';
                    arr[j]='W';
                    i++;
                    j--;
                }
                else{
                    j--;
                }
            }
            else{
                i++;
            }
        }
        cout<<count<<"\n";
    }
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 998244353
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pll a, pll b)//true for a before b
{
	if(a.F*b.S < b.F*a.S)
		return 1;
	if(a.F*b.S > b.F*a.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;



void solve()
{
	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	if(k % 2LL == 0LL)
		cout << (a-b) << '\n';
	else
		cout << (b-a) << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;


int main(void){
	ios::sync_with_stdio(false);
	int N, D, i, j, k, count;
	cin >> N >> D;
	double X[N][D], dist;
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	count = 0;

	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			dist = 0.0;
			for (k = 0; k < D; k++) {
				dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			dist = sqrt(dist);
			if ((double)((int)dist) == dist) {
				count += 1;
			}
		}

	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

//ABC122 B

string s;

int main(){
	cin>>s;
	int res=0,n=s.size();
	for(int i=0;i<n;i++) for(int j=1;j<n-i+1;j++){
		string t=s.substr(i,j);
		int cnt=0;
		for(auto c:t){
			if(c=='A'||c=='T'||c=='G'||c=='C') cnt++;
			else cnt=-inf;
		}
		res=max(res,cnt);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N, i, ans;
   int a[100];
  ans = 0;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++){ 
    scanf("%d", &a[i]);
  }
 for(i = 0; i < N; i++){ 
  if((i+1) %2 == 1 && a[i] %2 == 1){
    ans = ans + 1;
  }
}
 printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1700
class Info:
    def __init__(self,arg_start,arg_end,arg_S):
        self.start = arg_start
        self.end = arg_end
        self.S = arg_S

POOL = []
LOC = []
cnt = 0
sum_S = 0

line = input()

for c in line:
    if c == "\\":
        LOC.append(cnt)
    elif c == "/":
        if len(LOC) == 0:
            continue
        tmp_start = LOC.pop()
        tmp_end = cnt
        tmp_S = tmp_end - tmp_start
        sum_S += tmp_S
        while len(POOL) > 0:
            if POOL[-1].start > tmp_start and POOL[-1].end < tmp_end:
                tmp_S += POOL[-1].S
                POOL.pop()
            else:
                break
        POOL.append(Info(tmp_start,tmp_end,tmp_S))
    else:
        pass
    cnt += 1

lst = [len(POOL)]
for i in range(len(POOL)):
    lst.append(POOL[i].S)
print(sum_S)
print(*lst)


Measured memory_bytes: 6660
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  hw <- getl $ map read . words
  solve <$> replicateM (head hw) getLine >>= mapM_ putStrLn

solve :: [String] -> [String]
solve xs = xs >>= replicate 2

getl :: (String -> a) -> IO a
getl f = f <$> getLine


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

int main(){
    using namespace std;
    size_t N, K;
    cin >> N >> K;
    vector<size_t> p(N + 1), n(N + 1);
    for(size_t i = 1; i <= N; ++i){
        long a;
        cin >> a;
        (a > 0 ? p : n)[i] = abs(a);
    }
    partial_sum(p.begin(), p.end(), p.begin());
    partial_sum(n.begin(), n.end(), n.begin());
    size_t ans{numeric_limits<size_t>::max()};
    for(size_t i = K; i <= N; ++i)ans = min(ans, p[i] - p[i - K]);
    for(size_t i = K; i <= N; ++i)ans = min(ans, n[i] - n[i - K]);
    cout << p.back() - ans << endl;
    return 0;
}

Measured memory_bytes: 1920
yoho = list(input())
tenki = list(input())
ans = 0
if yoho[0] == tenki[0]:
    ans += 1
if yoho[1] == tenki[1]:
    ans += 1
if yoho[2] == tenki[2]:
    ans += 1

#print(yoho)
#print(tenki)
print(ans)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
 
int n,a[2005];
 
int32_t main(){
   int n,s=0,x,m;
   cin>>n>>m;
   for(int i=0;i<m;i++){
     cin>>x;
     s += x;
   }
   if(n>=s){cout<<n-s;}
   else{cout<<-1;}
 
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >>a>>b;
    if(a>b){
        cout<<"a > b" <<endl;
    }else if(a<b){
        cout<<"a < b" <<endl;
    }else{
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int d; cin >> d;
    if(d==25){
        cout << "Christmas";
    }else{
        cout << "Christmas";
        for(int i=d; i<25; i++){
            cout << " Eve";
        }
    }
    cout  << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n,m,l=0,c=0;
    vector<pair<int,int>> p(100000);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>p[i].second>>p[i].first;
    }
    sort(p.begin(),p.begin()+m);
    for(int i=0;i<m;i++){
        if(p[i].second>=l){
            l=p[i].first;
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int p=0;
	char s[1000000];
	scanf("%[^\n]s",s);
	for(int i=1;s[i]!='\0';i++)
	{
		if(s[i]==s[i-1])
		{
			printf("Bad\n");
			p=1;
			break;
		}
	}
	if(p==0)
	{
		printf("Good\n");
	}
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect
from bisect import bisect_left

n = int(input())
l = input()
l = sorted(list(map(int, l.split())))
count = 0

for i in range(n):
	for j in range(i+1, n):
		c = l[i]+l[j]
		count += bisect_left(l,c) - (j+1)

print(count)


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <queue>
#include <stack>
#include <cassert>
#include <tuple>
using namespace std;

using ii = pair < int, int >;
using lint = long long;
using ti = tuple < int, int, int >;

const int N = 100005;
lint a[N];

bool go(lint &tl, lint &th, lint x) {
	lint a, b;
	b = th-(th%x);
	if(tl%x==0) {
		a = tl;
	}
	else {
		a = tl+x;
		a = a-(a%x);
	}
	assert(tl<1e18);
	assert(th<1e18);
	if(a>b)return false;
	tl = a;
	th = b+(x-1);

	return true;
}

int main() {
	int k;
	scanf("%d", &k);
	bool ok = true;
	lint tl = 2, th = 2;
	for(int i=0; i<k; i++) {
		scanf("%lld", a+i);
	}
	for(int i=0; i<k; i++) {
		lint x;
		x = a[k-1-i];
		if(!go(tl, th, x)) {
			ok = false;
			break;
		}
	}
	if(!ok) {
		puts("-1");
	}
	else {
		printf("%lld %lld\n", tl, th);
	}
	return 0;
}

Measured memory_bytes: 1024
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int m , n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    int ans = n*(n - 1)/2 + m*(m - 1)/2;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+14
#define int long long
using namespace std;

struct line{ double a,b,c; };
typedef pair<double,int> P;

class BIT{
	vector<int> bit;
public:
	BIT(int siz){
		bit.resize(siz + 1,0);
	}
	void add(int i,int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum(int i){
		int s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

int n;

int calc(vector<P> vec){
	int ans = 0;
	BIT bit(n);
	for(int i = 0;i < n;i++){
		ans += i - bit.sum(vec[i].second + 1);
		bit.add(vec[i].second + 1,1);
	}
	return ans;
}

signed main(){
	vector<line> ls;
	double ans[2];
	cin >> n;
	for(int i = 0;i < n;i++){
		double a,b,c;
		cin >> a >> b >> c;
		ls.push_back({a,b,c});
	}
	for(int t = 0;t < 2;t++){
		double low = -INF,up = INF;
		sort(ls.begin(),ls.end(),[](const line l1,const line l2){
			return (l1.c - l1.a * -INF) / l1.b < (l2.c - l2.a * -INF) / l2.b;
		});
		for(int i = 0;i < 100;i++){
			double mid = (low + up) / 2;
			vector<P> vec;
			for(int j = 0;j < n;j++) vec.push_back(P((ls[j].c - ls[j].a * mid) / ls[j].b,j));
			sort(vec.begin(),vec.end());
			if(calc(vec) >= (n * (n - 1) / 2 + 1) / 2) up = mid;
			else low = mid;
		}
		ans[t] = low;
		for(int i = 0;i < n;i++) swap(ls[i].a,ls[i].b);
	}
	printf("%.9lf %.9lf\n",ans[0],ans[1]);
	return 0;
}

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

int *par, *ranks;
int N;
struct P {int n, x, y;};
struct PATH {int v1, v2, cost;};

void init()
{
  for (int i = 0; i < N; i++) {
    par[i] = i;
    ranks[i] = 0;
  }
}

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

void unite(int x, int y)
{
  x = find(x); y = find(y);
  if (x == y) return;

  if (ranks[x] < ranks[y]) par[x] = par[y];
  else {
    par[y] = par[x];
    if (ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y)
{
  return find(x) == find(y);
}

bool comp_x(P p1, P p2)
{
  return p1.x < p2.x;
}
bool comp_y(P p1, P p2)
{
  return p1.y < p2.y;
}

bool comp_cost(PATH path1, PATH path2)
{
  return path1.cost < path2.cost;
}

int main()
{
  cin >> N;
  P p[N];
  par = new int[N];
  ranks = new int[N];
  for (int i = 0; i < N; i++) {
    p[i].n = i;
    cin >> p[i].x >> p[i].y;
  }
  init();
  vector<PATH> pathes;
  sort(p, p + N, comp_x);
  for (int i = 0; i < N-1; i++) {
    PATH tmp;
    tmp.v1 = p[i].n; tmp.v2 = p[i+1].n;
    tmp.cost = p[i+1].x - p[i].x;
    pathes.push_back(tmp);
  }
  sort(p, p + N, comp_y);
  for (int i = 0; i < N-1; i++) {
    PATH tmp;
    tmp.v1 = p[i].n; tmp.v2 = p[i+1].n;
    tmp.cost = p[i+1].y - p[i].y;
    pathes.push_back(tmp);
  }

  sort(pathes.begin(), pathes.end(), comp_cost);
  int lim = pathes.size(), ans = 0;
  for (int i = 0; i < lim; i++) {
    PATH path = pathes[i];
    if (same(path.v1, path.v2)) continue;
    unite(path.v1, path.v2);
    ans += path.cost;
  }

  cout << ans << endl;
  delete [] par;
  delete [] ranks;
}


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	vi vec(n);
	queue<int> t;
	rep(i,0,n){
		int a; cin>>a;
		--a;
		vec[i]=a;
		if(a==i){
			t.push(a);
		}
	}
	int cnt=0;
	while(!t.empty()){
		int c=t.front(); t.pop();
		int d=t.front();
		if(c+1==d) t.pop();
		cnt++;
	}
	cout<<cnt;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

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

using namespace std;

struct plant{
	double cost;//?????????????????????
	string name;//??????
	plant(string _n,double _c){
		cost=_c;name=_n;
	}
	bool operator<(const plant &p) const {
		if(cost != p.cost) return cost > p.cost;
		return name < p.name;
	}
};

int main(){
	int N;	
	while(cin >> N, N) {
		string L;
		double P,A,B,C,D,E,F,S,M;
		vector<plant> plants;
		rep(nth, N) {	
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			double time_all=A+B+C+D+E;
			double time_n=D+E;
			rep(i,M-1){
				time_all +=time_n;	
			}
			plants.push_back(plant(L,((F*S*M)-P)/time_all));
		}
		sort(plants.begin(), plants.end());
		rep(i, N) {
			cout << plants[i].name << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>

class A {
public:
	void solve(std::istream& in, std::ostream& out) {
		std::string s;
		in >> s;
		for (int i = 0; i < s.size(); i++) {
			for (int j = i + 1; j < s.size(); j++) {
				if (s[i] == 'C' && s[j] == 'F') {
					out << "Yes" << "\n";
					return;
				}
			}
		}
		out << "No" << "\n";
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int n, p_a = 0, p_b = 0;
    cin >> n;
    string a, b;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        cin >> b;
        if (a > b)
        {
            p_a += 3;
        }
        else if (a == b)
        {
            p_a += 1;
            p_b += 1;
        }
        else
        {
            p_b += 3;
        }
    }
    cout << p_a << ' ' << p_b << endl;
    return 0;
}


Measured memory_bytes: 3216
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    string N;
    cin >> N;
    int num;
    ll ans=0;
    bool flag=false;
    REP(i,N.size()){
        num=N[N.size()-1-i]-'0';
        if(flag){
            num++;
            flag=false;
        }
        if(num>5){
            flag=true;
            ans+=(10-num);
        }else if(num==5){
            if(N[N.size()-1-i-1]-'0'<=4){
                flag=false;
            }else{
                flag=true;
            }
            ans+=5;
        }else{
            ans+=num;
        } 
    }
    if(flag) ans++;
    cout << ans <<endl;
}

Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for(int i = 0; i < K; i++) cin >> D[i];
    vector<int> use;
    for(int i = 0 ; i < 10; i++){
        int flag = 0;
        for(int j = 0; j < K; j++){
            if(i == D[j]) flag = 1;
        }
        if(flag == 0) use.push_back(i);
    }
    queue<int> q;
    for(int i = 0; i < use.size(); i++){
        if(use[i] != 0) q.push(use[i]);
    }
    int ans = 0;
    while(!q.empty()){
        int t = q.front();
        if(t >= N){
            ans = t;
            break;
        }
        q.pop();
        for(int i = 0; i < use.size(); i++){
            q.push(t*10 + use[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void solve(){
    ll n; cin >> n;
    vector<ll> a(n); for(auto& in:a) cin >> in;
    sort(a.begin(),a.end());
    ll dif = -1;
    ll l = -1,r = -1;
    for(int i = 1; i < n;i++){
        auto it = lower_bound(a.begin(), a.end(), a[i]/2) - a.begin();
        for(int j = -1; j <= 1; j++){
            if(it+j<0) continue;
            if(it+j>=i) continue;
            ll x = a[it+j];
            if(a[i]-x>x) x = a[i]-x;
            if(a[i]-x >= dif){
                dif = a[i]-x;
                l = a[i]; r = a[it+j];
            }
        }
    }
    cout << l << " " << r << endl;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main() {
    int n; string s; cin >> n >> s;
    int count=0;
    rep(i, s.size()-1) {
        if(s[i] != s[i+1]) count++;
    }
    cout << count + 1 << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int main(){

  int n; cin >> n;
  if(n < 1000)cout <<"ABC" << endl;
  else cout << "ABD" << endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int L;
    cin >> L;
    double an;
    long double ans;
    an = L * 1000000 / 3;
    ans = an * an * an / 1000000000000000000;
    cout <<fixed << setprecision(8) << ans <<endl;
}

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

int divide(int count, bool even, vector<int> &A){
  
  if(even == false){
    return count;
  }
  
  for(int i = 0; i < A.size(); i++){
    if( (A.at(i) % 2) != 0 ){
      even = false;
      break;
    } else {
      even = true;
    }
  }
  
  if(even == true){
    for(int i = 0; i < A.size(); i++){
      A.at(i) = A.at(i)/2;
    }
    count += 1;
  }

  return divide(count, even, A);
  
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);

  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  bool even = true; // 偶数があればtrueにする
  int count = 0;
 
  count = divide(count, even, A);
  cout << count << endl;
  
  return 0;
}




Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let w: f64 = sc.read();
    let h: f64 = sc.read();
    let x: f64 = sc.read();
    let y: f64 = sc.read();
    let s = w * h;
    println!(
        "{} {}",
        s / 2.0,
        if x * 2.0 == w && y * 2.0 == h { 1 } else { 0 }
    );
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
str = gets
num = str.split(" ")
W = num[0].to_i
H = num[1].to_i
x = num[2].to_i
y = num[3].to_i 
r = num[4].to_i

if 0<r && r<=x && r<=y && 0<x+r && x+r<=W && 0<y+r && y+r<=H then
  puts "Yes"
  elsif
    puts "No"
end

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

int main()
{
    int n, m; cin>>n>>m;
    set<int> s, t;
    while (m--) {
        int a, b; cin>>a>>b;
        if (a>b) swap(a, b);
        if (a==1) s.insert(b);
        if (b==n) t.insert(a);
    }
    string res="IMPOSSIBLE";
    for(int x: s) if (t.count(x)) res="POSSIBLE";
    cout<<res<<endl;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		string s,t;
		cin >> s >> t;
		int n = 0;
		for(int i=0; i < 3; i++){
			if(s[i] == t[i])n++;
		}
		cout << n << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 23.05.2020 16:38:59       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string alpha;
  for (char c = 'a'; c <= 'z'; c++) {
    alpha += c;
  }
  for (char c = 'A'; c <= 'Z'; c++) {
    alpha += c;
  }
  for (char c = '0'; c <= '9'; c++) {
    alpha += c;
  }
  const int L = 128;
  auto Ask = [&](string s) {
    cout << "? " << s << endl;
    int ret;
    cin >> ret;
    return ret;
  };
  set<pair<int, string>> s;
  int len = 0;
  for (char c : alpha) {
    int x = Ask(string(L, c));
    int cnt = L - x;
    if (cnt > 0) {
      s.emplace(cnt, string(cnt, c));
      len += cnt;
    }
  }
  while (s.size() > 1) {
    auto p = s.begin()->second;
    s.erase(s.begin());
    auto q = s.begin()->second;
    s.erase(s.begin());
    int nq = (int) q.size();
    int ptr = 0;
    for (int i = 0; i < nq; i++) {
      if (ptr == (int) p.size()) {
        p.insert(p.begin() + ptr, q[i]);
        ++ptr;
        continue;
      }
      auto test = p;
      test.insert(test.begin() + ptr, q[i]);
      int x = Ask(test);
      if (x == len - (int) test.size()) {
        p = test;
      } else {
        --i;
      }
      ++ptr;
    }
    s.emplace((int) p.size(), p);
  }
  cout << "! " << s.begin()->second << endl;
  return 0;
}


Measured memory_bytes: 3804
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n = int(input().strip())
	v = [0] * n
	for i in range(n):
		v[i] = input().strip()
	if len(set(v)) != n:
		print('No')
		return
	for i in range(n-1):
		if v[i][-1] != v[i+1][0]:
			print('No')
			return
	print('Yes')

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2 + 2], R[MAX/2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right -mid;
  for(i=0; i<n1; i++) L[i] = A[left+i];
  for(i=0; i<n2; i++) R[i] = A[mid+i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p < r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for(i=0; i<n; i++){
    if(A[i].suit != B[i].suit) stable = 0;
  }

    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0; i<n; i++){
      printf("%c %d\n", B[i].suit, B[i].value);
    }

    return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
int main(){
  int a, b, c;
  while(scanf("%d%d%d",&a,&b,&c)==3){
    if(b)
    if(b/a>c) printf("%d\n", c);
    else if(b/a<c) printf("%d\n", b/a);
    else printf("%d\n",c);
  }
  return 0;
}


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

int main(void) {
    i64 n, m, ans = 0, now = 0;
    cin >> n >> m;
    vector<i64> a(n);
    vector<pair<i64, i64>> o(m);
    for (i64 i = 0; i < n; i++) cin >> a[i];
    for (i64 i = 0; i < m; i++) cin >> o[i].second >> o[i].first;
    sort(a.begin(), a.end());
    sort(o.begin(), o.end(), greater<pair<i64, i64>>());
    for (i64 i = 0; i < n; i++) {
        if (now < o.size() && a[i] < o[now].first) {
            a[i] = o[now].first;
            o[now].second--;
            if (o[now].second == 0) now++;
        }
    }
    cout << accumulate(a.begin(), a.end(), 0LL) << endl;
}

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

namespace ABC169
{

  class B
  {
  public:
    B() = default;
    ~B() = default;

    void Run()
    {
      int N;
      long long A[100001];
      std::cin >> N;

      bool over = false;
      long long accm = 1;
      for (int i = 0; i < N; ++i)
      {
        std::cin >> A[i];

        if (A[i] == 0)
        {
          over = false;
          accm = 0;
          break;
        }
        if (over) continue;

        int ten_count = 0;
        long long v = A[i];
        while (v >= 10)
        {
          v /= 10;
          ten_count++;
        }

        int accm_ten_count = 0;
        long long accm_v = accm;
        while (accm_v >= 10)
        {
          accm_v /= 10;
          accm_ten_count++;
        }

        if (ten_count + accm_ten_count > 18)
        {
          over = true;
        }
        else if (ten_count + accm_ten_count == 18)
        {
          auto v1 = accm;
          auto v2 = A[i];
          if (v1*v2 != 1000000000000000000)
          {
            over = true;
          }
        }

        accm *= A[i];
      }

      over |= (accm > 1000000000000000000);

      std::cout << (over ? -1 : accm) << std::endl;
    }
  };

}
int main()
{

  ABC169::B prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
const int N=305;
int f[N][N][N],n,K;char s[N];
int main(){
  scanf("%s%d",s+1,&K);n=strlen(s+1);
  for(int i=1;i<=n;i++)
      for(int k=0;k<=K;k++)f[i][i][k]=1;
  for(int len=2;len<=n;len++){
      for(int i=1;i+len-1<=n;i++){
          int j=i+len-1;
          for(int k=0;k<=K;k++){
              f[i][j][k]=max(f[i+1][j][k],f[i][j-1][k]);
              if(s[i]==s[j])f[i][j][k]=max(f[i][j][k],f[i+1][j-1][k]+2);
              if(k)f[i][j][k]=max(f[i][j][k],f[i+1][j-1][k-1]+2);
          }
      }
  }
  cout<<f[1][n][K]<<endl;
  return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, m, k;
  cin >> n >> m >> k;

  vector<int> x(n + 1, 0), y(m + 1, 0), a(m + 1, 0);

  rep(i, 1, n + 1) cin >> x[i];
  rep(i, 1, m + 1) {
    cin >> y[i];
    a[i] += a[i - 1] + y[i];
  }

  int ans = 0;
  int cnt = 0;
  rep(i, 0, n + 1) {
    cnt += x[i];
    auto it = upper_bound(a.begin(), a.end(), k - cnt) - a.begin();
    if (k - cnt >= 0) chmax(ans, it + i - 1);
  }

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

Measured memory_bytes: 7892