akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	long n,a=0,b=0,sim=0;
	cin>>n;
	vector<long>vec(n);
	for(int i=0;i<n;++i)cin>>vec.at(i);
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	for(int i=1;i<n;i++){
		if(vec.at(i)==vec.at(i-1)){
		       	
		       	
		       		a=vec.at(i);
		       		i++;
		       		sim++;
		       		if(sim==2){
		       			break;
		       		}
		       	
		       	
		       		
		b=a; 
		a=0;
		}
		
	}
	if(a*b==0){
		cout<<0<<endl;
	}
	else{
		cout<<a*b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        std::string s;
        std::string p;
    cin>>s;
    cin>>p;
        s+=s;
        int loc=s.find(p,0);
        if(loc!=string::npos)
                cout<<"Yes"<<endl;
        else
                cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 1192
K = int(input())
A, B = map(int, input().split())

if A % K == 0:
  print('OK')
elif B % K == 0:
  print('OK')
elif A <= K and K <= B:
  print('OK')
elif K * ((A // K) + 1) <= B:
  print('OK')
else:
  print('NG')

Measured memory_bytes: 9124
#include <stdio.h>

int main(void){
	char str[21] = {0};
	char temp;
	int x = 1;
	int i = 0;
	
	scanf("%s", str);
	while(str[x]){
		x++;
	}
	while(x - i > i){
		temp = str[i];
		str[i] = str[x-1 - i];
		str[x-1 - i] = temp;
		
		i++;
	}



	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N;
char s[101], t[101];
bool f = true, ff = true;

int main(){
	/*
	cin.tie(0);
	ios::sync_with_stdio(false);
	*/
	cin >> N;
	cin >> s >> t;
	for(int i = 0; i < N && ff; i++){
		for(int j = 0; j < N-i && f; j++){
			if(s[i+j] != t[j]) f = false;
		}
		if(f){
			ff = false;
			cout << N+i;
		}
		f = true;
	}
	if(ff){
		cout << N*2;
	}

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#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 endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,x,ans=mod,c[15],a[15][15],p,q;
map<ll,ll>cnt;
int32_t main(){
CODE_START;
cin>>n>>m>>x;
p=(1<<n);
for(ll i=0;i<n;i++){
        cin>>c[i];
    for(ll j=0;j<m;j++)
{
    cin>>a[i][j];
}
}
for(int mask=0;mask<p;mask++){
        cnt.clear();
ll s=0;
    for(int j=0;j<n;j++){
if((mask&(1<<j))!=0){
for(ll u=0;u<m;u++)
cnt[u]=cnt[u]+a[j][u];
s=s+c[j];
}
    }
    for(ll j=0;j<m;j++)
    {
        if(cnt[j]<x){
            s=mod;
        }
    }
    ans=min(ans,s);
}
if(ans==mod){
    ans=-1;
}
cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define read(x) scanf("%d",&x)
using namespace std;
int main() {
    string s;
    cin>>s;
    if(s[0]=='9')s[0]='1';
    else if(s[0]=='1')s[0]='9';
//    cout<<s<<endl;
    if(s[1]=='9')s[1]='1';
    else if(s[1]=='1')s[1]='9';

    if(s[2]=='9')s[2]='1';
    else if(s[2]=='1')s[2]='9';

    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; ++i)
        cin >> H[i];

    vector<bool> isgood(N, true);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        if (H[A] <= H[B])
            isgood[A] = false;
        if (H[B] <= H[A])
            isgood[B] = false;
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i)
        cnt += isgood[i];
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3724
//
// Created by yamunaku on 2020/06/27.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s,t ;
    cin >> s >> t;
    int x = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) x++;
    }
    cout << x<< endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int k,x;
    cin>>k>>x;
    if(k*500>=x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {

  int a,b,c;
  cin>>a>>b>>c;
  cout<<a*b/2;
  return 0;
}







Measured memory_bytes: 256
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
b = 0
for i in range(h):
    a = list(ns())
    b += a.count('#')

ans = 'Possible' if b == (h+w-1) else 'Impossible'
print(ans)

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

int main() {
	int n; std::cin >> n;
	for (int i = 1; i <= n; ++i) {
		int tmp; std::cin >> tmp;
		if (tmp & 1) continue;
		if (tmp % 3 > 0 && tmp % 5 > 0) {
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     // static int dx[]={1,-1,0,0};
     //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

    //  int n=sc.nextInt();  
    int n=sc.nextInt();  
    int c[] = new int[3*n];
    long right[] = new long[3*n];
    long left[] = new long[3*n];
    int tn=3*n;
    PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 

    for( int i=0; i<n*3; i++ ){
        c[i] = sc.nextInt();
    }
    
    
    for( int i=0; i<2*n; i++ ){
        que.add(c[i]);
        left[i] = c[i];
        if(i>0) left[i] += left[i-1];
        if(i >= n){
            left[i] -= que.poll();
        }
    }
    que.clear();
    for( int i=0; i<2*n; i++ ){
        int t = 3*n - i - 1;
        que.add(-c[t]);
        right[t] = c[t];
        if(i>0) right[t] += right[t+1];
        if(i >= n){
            right[t] += que.poll();
        }
    }
    long ans=left[n-1]-right[n];
    for( int i=n; i<2*n; i++ ){
        ans = max(ans, left[i] - right[i+1]);
    }

    out.println(ans);
    out.flush();
}

static void rep(int x, long d){

}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}


class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 63072
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const double eps = 1e-11;

struct node{double x, y; node(double ax = 0.0, double ay = 0.0){x = ax; y = ay;}};
int n;
node pt[MAXN];
node o = pt[1]; double r = 0.0;

double dis(node a, node b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}
void dt(node p1, node p2, node p3){
	double a, b, c, d, e, f;
    a = p2.y - p1.y;
    b = p3.y - p1.y;
    c = p2.x - p1.x;
    d = p3.x - p1.x;
    f = p3.x * p3.x + p3.y * p3.y - p1.x * p1.x - p1.y * p1.y;
    e = p2.x * p2.x + p2.y * p2.y - p1.x * p1.x - p1.y * p1.y;
    o.x = (a * f - b * e) / (2 * a * d - 2 * b * c);
    o.y = (d * e - c * f) / (2 * a * d - 2 * b * c);
    r = dis(o, p1);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lf %lf", &pt[i].x, &pt[i].y);
	random_shuffle(pt + 1, pt + n + 1);
	for(int i = 2; i <= n; i++){
		if(dis(pt[i], o) > r + eps){
			o = pt[i]; r = 0.0;
			for(int j = 1; j <= i - 1; j++){
				if(dis(o, pt[j]) > r + eps){
					o.x = (pt[i].x + pt[j].x) / 2.0;
					o.y = (pt[i].y + pt[j].y) / 2.0;
					r = dis(o, pt[j]);
					for(int k = 1; k <= j - 1; k++){
						if(dis(o, pt[k]) > r + eps){
							dt(pt[i], pt[j], pt[k]);
						}
					}
				}
			}
		}
	}
	printf("%.10lf\n", r);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	x := make([]int, M)
	y := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&x[i], &y[i])
	}
	for i := 0; i < M; i++ {
		x[i]--
		y[i]--
	}
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		nums[i] = 1
	}
	red := make([]bool, N)
	for i := 0; i < N; i++ {
		red[i] = false
	}
	red[0] = true
	for i := 0; i < M; i++ {
		if red[x[i]] {
			red[y[i]] = true
		}
		nums[x[i]]--
		nums[y[i]]++
		if nums[x[i]] == 0 {
			red[x[i]] = false
		}
	}

	var count int
	for i := 0; i < N; i++ {
		if red[i] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 5504
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

struct Line{
    std::complex<double> base_point;
    std::complex<double> direct;
    Line(){}
    Line(const std::complex<double> &_base_point, const std::complex<double> &_direct):base_point(_base_point){
        assert(abs(_direct) != 0);
        direct = _direct/abs(_direct);
    }
};

std::complex<double> reflection(const std::complex<double> &p, const Line &l){
    std::complex<double> ret = (p-l.base_point)/l.direct;
    ret.imag(-ret.imag());
    return ret*l.direct + l.base_point;
}

int main(){
    double x1,y1,x2,y2; std::cin >> x1 >> y1 >> x2 >> y2;
    std::complex<double> x(x1, y1), y(x2, y2);
    Line l(x, x-y);
    int n; std::cin >> n;
    std::vector<std::complex<double>> da(n);
    rip(i,n,0){
        double xx, yy; std::cin >> xx >> yy;
        da[i] = reflection(std::complex<double>(xx, yy), l);
    }
    rip(i,n,0){
        std::printf("%.08f %.08f\n",da[i].real(), da[i].imag());
    }
}


Measured memory_bytes: 3288
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>
#include <stack>
#include <queue>
#include <list>

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
//#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
    //???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif


//void deleteX(list<uint64_t> &list, int x) {
//    for(auto itr=list.begin(); itr!=list.end(); itr++ ) {
//        if(*itr==x) {
//            list.erase(itr);
//            break;
//        }
//    }
//}


int main(void) {
    list<uint64_t> list;
    uint64_t n;
    
    cin >> n;
    string order;
    uint64_t x;
    
    for(size_t i=1; i<=n; i++) {
        
        if( !(cin >> order) ) break;
        
//        dout << order << " " << x << endl;
        
        if(order[0]=='i') {
            cin >> x;
            list.insert(list.begin(),x);
//            list.push_front(x);
            continue;
        }
         if(order.size()==6) {
            cin >> x;
//            deleteX(list, x);
            auto it=find(list.begin(), list.end(), x);
            if(it!= list.end())list.erase(it);
            continue;
        }
         if(order.size()==11) {
            list.pop_front();
            continue;
        }
         if(order.size()==10) {
            list.pop_back();
            continue;
        }
    }
    
    
    
    
    
    //display list
//    dout << "---- display list ---- \n";
    for(auto itr=list.begin(); itr!=list.end(); itr++ ) {
        if(itr==list.begin()) {
            cout << *itr;
        } else {
            cout << " " << *itr;
        }
    }
    cout << endl;
    
    return 0;
}

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

using namespace std;

bool True_array(vector<int>& s,int k){
  for(auto i=s.begin();i<s.end();i++){
    if((*i)%k!=0) return false;
  }
  return true;
}

int main(){
  int n,x;cin >> n >> x;
  vector<int> y(n);
  for(int i=0;i<n;i++){
    cin >> y[i];y[i]=abs(y[i]-x);
  }
  sort(y.begin(),y.end());
  int l=y[0];
  for(int i=0;i<l;i++){
    if(True_array(y,l-i)){
      cout << l-i << endl;
      break;
    }
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
using namespace std;

int main(void){
    int N;
    cin>>N;
    double A[N];
    for(int i=0;i<N;i++){
         cin>>A[i];
     }

     double S1,S2;
     double ans;
     S1=0;
     S2=0;
     for(int j=0;j<N;j++){
         S2+=A[j];
     }
     ans=abs(S2-S1);

    for(int k=0;k<N;k++){
         S1+=A[k];
         S2-=A[k];
         if(ans>abs(S2-S1)){
             ans=abs(S2-S1);
         }

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

Measured memory_bytes: 256
function main(input) {
  const inputs =input.split('\n')
  const [N, K] = inputs[0].split(' ').map(Number)
  const p = inputs[1].split(' ').map(Number)
  p.sort((a,b) => a > b ? 1 : -1)
  console.log(
    p.slice(0, K).reduce((h, e) => {
      return h + e
    }, 0)
  )
}

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


Measured memory_bytes: 29752
#include <iostream>

using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[10005][105][2];

int main(int argc, char *argv[])
{
	string K;
	ll D;

	cin >> K >> D;
	int n = K.length();

	dp[0][0][0] = 1;
	for (int dgt = 0; dgt < n; dgt++) {
		for (int d = 0; d < D; d++) {
			for (int smaller = 0; smaller < 2; smaller++) {
				int c = K[dgt] - '0';
				for (int next = 0; next < 10; next++) {
					if (next < c) {
						dp[dgt + 1][(d + next) % D][1] += dp[dgt][d][smaller];
						dp[dgt + 1][(d + next) % D][1] %= mod;
					} else if (next == c) {
						dp[dgt + 1][(d + next) % D][smaller] += dp[dgt][d][smaller];
						dp[dgt + 1][(d + next) % D][smaller] %= mod;
					} else {
						if (smaller) {
							dp[dgt + 1][(d + next) % D][smaller] += dp[dgt][d][smaller];
							dp[dgt + 1][(d + next) % D][smaller] %= mod;
						}
					}
				}
			}
		}
	}

	cout << (mod + ((dp[n][0][0] + dp[n][0][1]) % mod - 1)) % mod << endl;

	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Mplus(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,a,b;
  string s;
  cin>>n>>a>>b;
  cin>>s;
  int sab=0,sb=0;
  rep(i,n){
    if(s[i]=='a'){
      if(sab<a+b){
        Yes(true);
        sab++;
      }else{
        Yes(false);
      }
    }else if(s[i]=='b'){
      if(sab<a+b&&sb<b){
        Yes(true);
        sab++;
        sb++;
      }else {
        Yes(false);
      }
    }else{
      Yes(false);
    }
  }


}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k;
string s;
void solve(){
	cin >> n >> k >> s;
	
	int ans = 0;
	int start = 1;
	while(s[start-1] == s[start]){start++; ans++;}
	bool bef = 0;
	for(int i = start; i < n; i++){
		if(s[i-1] == s[i] || (s[i]==s[0] && bef)) ans++;
		else{
			bef = 0;
			if(k){
				k--;
				ans++;
				bef = 1;
			}
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 512
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int n,k;
  cin >> n>>k;
  int l[n];
  rep(i,n)cin >> l[i];
  sort(l, l+n, greater<int>());
  int c=0;
  rep(i,k) c+=l[i];
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    int alice[100]={},bob[100]={};
    for(int i=A;i<B;i++){
        alice[i] = 1;
    }
    for(int i=C;i<D;i++){
        bob[i] = 1;
    }
    int ans = 0;
    for(int i=0;i<100;i++){
        if(alice[i] == 1 && bob[i] == 1){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int M;
    cin >> M;
    vector<pair<int, long long>> dc(M);
    long long d, c;
    for(int i = 0; i < M; i++){
        cin >> d >> c;
        dc[i] = make_pair(d, c);
    }

    long long sum = 0;
    long long digitSum = 0;
    for(auto temp: dc){
        digitSum += temp.second;
        sum += temp.first * temp.second;
    }

    long long ans = (digitSum - 1) + (sum - 1) / 9;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<char, int, bool> judge = (c, i) => i % 2 == 0 ? c != 'L' : c != 'R';
            var ans = Console.ReadLine().Select((c, i) => new { c, i }).All(x => judge(x.c, x.i)) ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
num = int(input())
lists = list(map(int, list(input().split())))
sets = list(set(lists))
lensets = len(sets)

total = 0

for i in range(lensets):
  for j in range(i+1, lensets):
    for k in range(j+1, lensets):
      
      
      if (sets[i] + sets[j] > sets[k]) and (sets[j] + sets[k] > sets[i]) and (sets[k] + sets[i] > sets[j]):
        
        
        number = lists.count(sets[i]) * lists.count(sets[j]) * lists.count(sets[k])
        
        total += number
print(total)

Measured memory_bytes: 9212
import sys
input = sys.stdin.readline
from heapq import heappush, heappop

N = int(input())
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}

# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく

U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
    L = 1 << (i-1)
    sp.append([x if x < y else y for x,y in zip(sp[-1][:-L], sp[-1][L:])])

def RMQ(x,y):
    # x番目から偶数番目だけ見て[x,y]での最小値を返す
    d = y - x
    if d <= 1:
        return A[x]
    n = d.bit_length()
    arr = sp[n-1]
    ax = arr[x]
    ay = arr[y+2-(1<<(n-1))]
    return ax if ax < ay else ay

def F(x,y):
    # 辞書式で最小の2つ組をとる
    # そのあと、今後調べないといけない区間の一覧を返す
    x1 = RMQ(x,y-1)
    i1 = a_to_i[x1]
    x2 = RMQ(i1+1,y)
    i2 = a_to_i[x2]
    task = ((x,y) for x,y in ((x,i1-1), (i1+1,i2-1), (i2+1,y)) if y > x)
    return x1,x2,task

q = [(None,None,((0,N-1),))]
answer = []
while q:
    x,y,task = heappop(q)
    answer.append(x)
    answer.append(y)
    for left,right in task:
        heappush(q,F(left,right))

print(' '.join(map(str,answer[2:])))

Measured memory_bytes: 108152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N,Q;cin>>N>>Q;
    vector<vector<int> > G(N);
    int a,b;
    REP(i,N-1){
        cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> cnt(N,0);
    int p;ll x;
    REP(i,Q){
        cin>>p>>x;p--;
        cnt[p]+=x;
    }
    vector<bool> checked(N,false);
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();que.pop();
        checked[v]=true;
        for (int w:G[v]){
            if(!checked[w]){cnt[w]+=cnt[v];
            que.push(w);}
        }
    }
    REP(i,N){if(i)cout<<" ";cout<<cnt[i];}
  cout<<endl;
    return 0;
}

Measured memory_bytes: 16372
n, m = map(int, input().split())

class Image:
    def __init__(self, n):
        self.matrix = [list(input()) for _ in range(n)]
        self.n = n

    def isIncluded(self, a):
        for i in range(a.n-self.n+1):
            for j in range(a.n-self.n+1):
                template = [row[j:j+self.n] for row in a.matrix[i:i+self.n]]
                if template == self.matrix:
                    return True
        return False


a = Image(n)
b = Image(m)

print("Yes" if b.isIncluded(a) else "No")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += -sc.nextInt() + sc.nextInt() + 1;
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 27236
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int H, W;
    cin >> H >> W;
    vector< string > S(H);
    rep (i, H)
    {
        cin >> S[i];
    }

    bool flag = true;
    for (int i = 0; i < H && flag; ++i)
    {
        for (int j = 0; j < W && flag; ++j)
        {
            bool u = true, d = true, l = true, r = true;
            if (S[i][j] == '.') continue;
            if (i > 0 && S[i - 1][j] == '.') u = false;
            if (i < H - 1 && S[i + 1][j]  == '.') d = false;
            if (j > 0 && S[i][j - 1] == '.') l = false;
            if (j < W - 1 && S[i][j + 1] == '.') r = false;
            flag = u || d || l || r;
        }
    }

    cout << (flag ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;

map<ll, ll> decompositPrime(ll n) {
  map<ll, ll> res;
  ll a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      n /= a;
      if (res.count(a) == 0) res[a] = 0;
      res[a]++;
    } else {
      a++;
    }
  }
  if (n > 1) {
    if (res.count(n) == 0) res[n] = 0;
    res[n]++;
  }

  return res;
}
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n);
  set<ll> b;
  set<ll> c;
  rep(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll dpsize = a[n - 1] + 1;
  vector<bool> dp(dpsize, true);
  vector<ll> cnt(dpsize, 0);
  rep(i, n) {
    cnt[a[i]]++;
    if (!dp[a[i]]) continue;
    for (ll j = a[i] * 2; j < dpsize; j += a[i]) {
      dp[j] = false;
    }
  }
  ll res = 0;
  rep(i, n) {
    if (cnt[a[i]] == 1) res += dp[a[i]];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 12676
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> d;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    d.push_back(x);
  }
  sort(d.begin(), d.end());
  //for(int i = 0; i < d.size(); i++) cout << d[i] << " ";
  //cout << endl;
  cout << d[d.size() / 2] - d[d.size() / 2 - 1] << endl;


  return;
}

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


Measured memory_bytes: 892
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main(){
	stack<int> st;
	int r,l,k,num;
	string str;
	while(cin>>str){
		if('0'<=str[0]&&str[0]<='9'){
			k=1,num=0;
			for(int i=str.size()-1;i>=0;--i){
				num+=k*(str[i]-'0');
				k*=10;
			}
			st.push(num);
		}
		else{
			r=st.top();
			st.pop();
			l=st.top();
			st.pop();
			if(str[0]=='+')st.push(l+r);
			else if(str[0]=='-')st.push(l-r);
			else if(str[0]=='*')st.push(l*r);
		}
	}
	cout<<st.top()<<endl;

	return 0;
}


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

//#define int long long

using namespace std;
#define REP(i, s, n) for(signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()

typedef pair<int, int> P;
typedef unsigned long long LL;

#ifdef int
const long long INF = 1ll << 61ll;
#else
const signed INF = 1 << 29;
#endif

template<typename T = int>
vector<vector<T>> vvector(int h, int w, T def = T()) { return move(vector<vector<T>>(h, vector<T>(w, def))); }


signed main() {

	int n, k;
	while (cin >> n >> k && n)
	{
		n++;
		vector<int> dp(n + 2);
		bool white = false;
		rep(i, k) {
			int x; cin >> x;
			if(x) dp[x] = 1;
			else white = true;
		}
		rep(i, n) if (dp[i + 1]) dp[i + 1] = dp[i + 1] + dp[i];
		rep(i, n) if (dp[n - i]) dp[n - i] = max(dp[n - i], dp[n - i + 1]);
		int ans = 0;
		rep(i, n - 1) ans = max(ans, (white && !dp[i + 1] ? dp[i] + dp[i + 1] + dp[i + 2] + 1 : dp[i + 1]));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1524
# Time limit Exceeded
n, largeT = map(int, input().split())
c = []
t = []
ans = []
for i in range(n):
    c, t = map(int, input().split())
    if t <= largeT:
        ans.append(c)
try:
    print(min(ans))
except ValueError:
    print('TLE')


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )

using namespace std;

typedef long long Lint;
typedef long double db;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair<db,db> dd;
typedef pair<int,string> is;

const int maxn = 120;
const int K = 60;
const int MOd = 998244353;

int a, b;
char ar[maxn][maxn];
int used[maxn][maxn];
int yol[4][2] = {{0,1},{1,0}};

int solve(  ) {
	scanf("%d %d",&a,&b);
	for(int i=1;i<=a;i++)
		scanf(" %s",ar[i]+1);

	priority_queue<iii> q;
	q.push( iii( -1*(ar[1][1] == '#'), ii( 1, 1 ) ) );
	while( !q.empty() ) {
		int x = q.top().se.fi;
		int y = q.top().se.se;
		int mal = -q.top().fi;
		q.pop();
		if( used[x][y] ) continue;
		used[x][y] = 1;
		if( x == a && y == b ) {
			printf("%d\n",mal);
			return 0;
		}
		for(int i=0;i<2;i++) {
			int x1 = x + yol[i][0];
			int y1 = y + yol[i][1];
			if( !y1 || !x1 || x1 >a || y1 > b ) continue;
			int h = 0;
			if( ar[x][y] == '.' && ar[x1][y1] == '#' ) h = 1;
			q.push( iii( -(mal+h), ii( x1, y1 ) ) );
		}
	}
	printf("-1\n");
	return 0;
}

int main(  ) {
	int n = 1;
	//scanf("%d",&n);
	for(int i=1;i<=n;i++) solve(  );
	return 0;
}


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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N, K; cin >> N >> K;

	int ans = 0;
	if(K == 1) ans = 0;
	else{
		ans = N-(K-1) - 1;

	}
		
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    int count = 0;
    cin >> S;
    S[0] == '+' ? ++count : --count;
    S[1] == '+' ? ++count : --count;
    S[2] == '+' ? ++count : --count;
    S[3] == '+' ? ++count : --count;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
int main(){
	int a = read(), b = read();
	printf("%d", std :: max(std :: max(a + b, a - b), a * b));
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long mod = 1000000007;
        long shi = 1L, jiu = 1L, ba = 1L;
        for (int i = 1; i <= n; i++) {
            shi = shi * 10 % mod;
            jiu = jiu * 9 % mod;
            ba = ba * 8 % mod;
        }
        long ans = ((shi - jiu - jiu + ba) % mod + mod) % mod;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35704
#include<iostream>
#include<cstring>
#include<cctype>

using namespace std;

string toUpper( string s){
    string t=s;
    for( int i=0; i<s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string target, source;
    
    cin>>target;
    target = toUpper(target);
    
    int cnt=0;
    
    while(1){
        cin >> source;
        if(source=="END_OF_TEXT")break;
        source=toUpper(source);
        if( target==source) cnt++;    
        
    }
    
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 3180
#!/usr/bin/env python3
class SegTree:
    def __init__(self, segfunc, e, v, init_val = None):
        """
        segfunc: function 区間にしたい操作\n
        e: Any 単位元\n
        v: int or List 要素数か格納する配列\n
        init_val: Any 初期値
        """
        self.segfunc = segfunc
        self.e = e
        self.init_val = init_val if init_val != None else e
        if isinstance(v, int):
            v = [self.init_val] * v
        self.n = len(v)
        self.log = (self.n).bit_length()
        self.size = 1 << self.log
        self.tree = [e] * 2 * self.size
        # 1-indexedなのでtree[1:self.size]がN-1要素
        # tree[self.size:self.size + N]が配列
        self.tree[self.size:self.size + self.n] = v
        for i in range(self.size - 1, 0, -1):
            self._update(i)

    def set(self, k, x) -> None:
        """
        k番目の値をxに更新\n
        k: index(0-indexed)\n
        x: update value
        """
        k += self.size
        self.tree[k] = x
        for i in range(1, self.log + 1):
            self._update(k >> i)

    def get(self, k):
        """
        a[k]を返す\n
        k: index(0-indexed)
        """
        assert 0 <= k < self.size
        return self.tree[k + self.size]

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る\n
        l: index(0-indexed)\n
        r: index(0-indexed)
        """
        res = self.e
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

    def all_query(self):
        """
        全範囲にsegfuncしたものを得る
        """
        return self.tree[1]

    # 二分探索実装、いる？

    def _update(self, k):
        self.tree[k] = self.segfunc(self.tree[k * 2], self.tree[k * 2 + 1])

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

MAX_A = 300005

dp = SegTree(max, 0, MAX_A, 0)
for i in range(N):
    x = A[i]
    now = dp.query(max(0, x - K), min(x + K + 1, MAX_A)) + 1
    dp.set(x, now)

ans = dp.all_query()
print(ans)


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

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

    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        FOR(i, 0, k) {
            cout << s[i];
        }
        cout << "...\n";
    } else {
        cout << s << "\n";
    }
    return 0;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

int n, a[N];
ll dp[N][3];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		dp[i][0] = dp[i][1] = dp[i][2] = -inf;
	}

	dp[1][0] = a[1] / 2;
	if (a[1]) dp[1][1] = (a[1] - 1) / 2;
	if (a[1] >= 2) dp[1][2] = (a[1] - 2) / 2;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= 2; j++) {
			for (int k = 0; k <= 2; k++) {
				for (int x = 0; x <= 2; x++) {
					if (k + x <= a[i] && !((a[i] - k - x) & 1))
						dp[i][k] = max(dp[i][k], dp[i - 1][j] + (a[i] - k - x) / 2 + min(j, x));
				}
			}
		}
	}

	printf("%lld", max({dp[n][0], dp[n][1], dp[n][2]}));
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cEdges=vector<vector<int>>;

int main() {
	long long N,x;
	cin>>N>>x;
	vector<int> arr(N);
	for(auto& val:arr)
		cin>>val;

	long long ans=0;
	vector<int> dp(N);
	for(int i=0;i<N;++i){
		dp[i]=arr[i];
		ans+=dp[i];
	}

	for(int i=1;i<N;++i){
		long long tmp=0;
		for(int j=0;j<N;++j){
			int index=(j-i>=0?j-i:N-(i-j));
			dp[j]=min(dp[j],arr[index]);
			tmp+=dp[j];
		}
		tmp+=x*static_cast<long long>(i);
		ans=min(ans,tmp);
	}

	cout<<ans<<endl;
	//system("pause");
	return 0;
}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<pair<ll, ll>> tree[101010];
ll dist[101010] = {};

void DFS(int A, int B){
  for(auto X: tree[A]){
    if(X.first==B) continue;
    if(dist[X.first]!=0) continue;
    dist[X.first] = dist[A] + X.second;
    DFS(X.first, A);
  }
}

int main(){
  int N; cin >> N;
  rep(i, N-1){
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }
  int Q, K; cin >> Q >> K; DFS(K-1, -1);
  rep(i, Q){
    int x, y; cin >> x >> y;
    x--; y--;
    cout << dist[x]+dist[y] << endl;
  }
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n, wm;
  cin >> n >> wm;
  vl w(n), v(n);
  rep (i, n) {
    cin >> w[i] >> v[i];
  }
  vll dp(n + 1, vl(wm + 1, -INF));
  dp[0][0] = 0;
  rep (i, n) {
    rep (j, wm + 1) {
      chmax(dp[i + 1][j], dp[i][j]);
      if (j + w[i] > wm) continue;
      chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }
  ll ans = -INF;
  rep (i, wm + 1) {
    chmax(ans, dp[n][i]);
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 80256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<math.h>
int main()
{
	int a, b,i=0;
	char ai[10], bi[10];
	scanf("%d %d", &a, &b);
	for (i = 0; i < b; i++)
	{
		ai[i] = a + 48;
	}
	ai[i] = '\0';
	for (i = 0; i < a; i++)
	{
		bi[i] = b + 48;
	}
	bi[i] = '\0';
	printf("%s", strcmp(ai, bi) < 0 ? ai : bi);
}

Measured memory_bytes: 128