akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define gcd(x,y) __gcd(x,y) 
#define Gput(a,b) G[a].push_back(b)
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*(y/z);
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
vector<bool> seen;
void dfs(const Graph &G,ll v){
    seen[v]=true;
    for(auto nextv:G[v]){ 
        if(seen[nextv])continue;
        dfs(G,nextv);
    }
}
int main() {
  cout << fixed << setprecision(16);
  ll n,m;
  cin>>n>>m;
  Graph G(n);
  vec a(m);
  vec b(m);
  loop(i,m){
    cin>>a[i]>>b[i];
    ll x=a[i]-1,y=b[i]-1;
    Gput(x,y);
    Gput(y,x);
  }
  ll ans=0;
  loop(i,m){
  ll x=a[i]-1,y=b[i]-1;
    G[x].erase(find(all(G[x]),y));
    G[y].erase(find(all(G[y]),x));
    seen.assign(n, false);
    dfs(G,0);
    loop(k,n){
      if(seen[k]==false){
        ans++;
        break;
      }
    }
    Gput(a[i]-1,b[i]-1);
    Gput(b[i]-1,a[i]-1);
  }
  putout(ans);
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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


//
int main(){
	int N,X;cin>>N>>X;
	vector<int> x(N+1);
	REP(i,N)cin>>x[i];
	x[N]=X;

	sort(ALL(x));

	ll ans = x[1]-x[0];
	REPS(i,1,N){
		ans = gcd(ans,x[i+1]-x[i]);
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 640
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n,k] = stdin.split('\n')[0].split(' ')
const s = stdin.split('\n')[1].split('')

const ans = _ => {
  return s.map((e,i)=>{
    if(i === k - 1){
      return e.toLocaleLowerCase()
    }
    return e
  })
}

console.log(ans().join(''))


Measured memory_bytes: 7372
#include<stdio.h>
int main(void)
{
	int N;
	int count1=0;
	int count2=0;
	scanf("%d", &N);
	int ary[N+1];for(int i=1;i<=N;i++){scanf("%d", &ary[i]);}
	int bry[N+1];for(int i=1;i<=N;i++){scanf("%d", &bry[i]);}
	int cry[N+1];for(int i=1;i<N;i++){scanf("%d", &cry[i]);}
	for(int i=1;i<=N;i++){count1 = count1+bry[i];}
	for(int i=1;i<=N;i++){
		if(ary[i+1]-ary[i]==1){count2=count2+cry[ary[i]];}
		else count2= count2+0;
		}
	printf("%d", count1+count2);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		int all = 0;
		for(int i = 0 ;i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
			all += a[i];
		}
		
		double limit = (double)all / (4*m) ;
		int cnt = 0 ;
		for(int i = 0 ; i < n ;i++) {
			if(limit <=  a[i]) {
				cnt++;
			}
		}
		
		if(cnt >= m) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		

	}

}


Measured memory_bytes: 24916
#include <iostream>

using namespace std;

void check(int i){
  int t=i;
  while(t!=0){
    if(t%10==3){
      cout << " " <<i;
      return;
    }
    t/=10;
  }
}

void call(int n){
  for(int i=1;i<=n;i++){
    if(i%3==0) cout << " " << i;
    else check(i);
  }
}

int main(){
  int x;
  cin >> x;
  call(x);
  cout << '\n';
}

Measured memory_bytes: 3096
#include <iostream>
typedef long long ll;
using namespace std;
ll C[500];
ll S[500];
ll F[500];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for( int i=0; i<N-1; i++ ){
    cin >> C[i] >> S[i] >> F[i];
  }
  for( int i=0; i<N-1; i++ ){
    ll t = 0;
    for( int j=i; j<N-1; j++ ){
      // t <= S + nF
      ll n = (t-S[j]) / F[j];
      if( n < 0 ) n = 0;
      if( S[j] + n*F[j] < t ) n++;
      t = S[j] + n*F[j];
      t += C[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


x1, y1, x2, y2 = inpl()

diff_y = y2 - y1
diff_x = x2 - x1
ans1 = [x2 - diff_y, y2 + diff_x]
ans2 = [ans1[0] - diff_x, ans1[1] - diff_y]
ans = ans1 + ans2
ans = ' '.join(map(str, ans))
print(ans)

Measured memory_bytes: 3064
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int r;
    double pi = 3.14159;
    cin >> r;
    cout << r * 2 * pi;
}

Measured memory_bytes: 3772
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n - 1);
	//for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	a[0] = a[1] = b[0];
	for (int i = 1; i < n - 1; i++) {
		if (a[i] > b[i]) a[i] = b[i];
		a[i + 1] = b[i];
	}
	ll sum = 0;
	for (int& i : a) sum += i;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

N = int(input())
pp = list(map(int, input().split()))
qq = list(map(int, input().split()))

a = 1
b = 1
a_left = [i+1 for i in range(N)]
b_left = [i+1 for i in range(N)]
for i in range(N-1):
	num = math.factorial(N-i-1)
	a += (num)*(a_left.index(pp[i]))
	a_left.remove(pp[i])
	b += (num)*(b_left.index(qq[i]))
	b_left.remove(qq[i])

print(abs(a-b))

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

int main(){
    int N;
    int a[100010];

    cin >> N;

    for(int i = 0;i < N;i++){
        cin >> a[i];
        a[i]--;
    }

    int x = 0;
    for(int i = 0;i < 100010;i++){
        if(x == 1){
            cout << i << endl;
            return 0;
        }
        x = a[x];
    }

    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 640
ex=["01","02","03","04","05","06","07","08","09","10","11","12"]
S=input()
if S[:2] in ex:
    if S[2:] in ex:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if S[2:] in ex:
        print("YYMM")
    else:
        print("NA")

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

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

    const int M = 28; // a, b < pow(2, 28)
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    int result = 0;
    REP(j, M + 1) {
        int mask = (1 << j) - 1;
        vector<int> masked_b(N);
        REP(i, N) {
            masked_b[i] = b[i] & mask;
        }
        sort(all(masked_b));
        if (N % 2 == 1) {
            REP(i, N) {
                result ^= a[i] & 1 << j;
                result ^= b[i] & 1 << j;
            }
        }
        ll carry = 0;
        REP(i, N) {
            int not_a = (~a[i]) & mask;
            carry += distance(lower_bound(all(masked_b), not_a + 1), masked_b.end());
        }
        if (carry % 2 == 1) {
            result ^= 1 << j;
        }
    }
    cout << result << endl;
    return 0;
}

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

using namespace std;
long long n,m,i,rez,dif;

int main()
{
    cin>>n>>m;
    dif=n-m;
    if(dif<0) dif=-dif;
    if(dif>1)
    {
        cout<<0<<'\n';
    }
    else
    {
        rez=1;
        for(i=1;i<=n;i++)
        {
            rez=rez*i;
            rez=rez%1000000007;
        }
        for(i=1;i<=m;i++)
        {
            rez=rez*i;
            rez=rez%1000000007;
        }
        if(m==n) cout<<2*rez%1000000007<<'\n';
        else cout<<rez<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int num;

	while(cin>>num)
	{
		int flag=0;
		
		for (int i = 1; i < 10; ++i)
		{
			for (int j = 1; j < 10; ++j)
			{
				if (i*j == num)
				{
					cout<<"Yes"<<endl;
					flag=1;
					break;
				}
			}
			if (flag==1)
				break;
		}
			if(flag==0)
				cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<int> Hmax(N);
	int maxim = 0;
	for (int i = 0; i < N; i++) {
		
		if (H[i] > maxim) {
			maxim = H[i];
		}
		Hmax[i] = maxim;
	}
	


	int count = 0;
	for (int i = 0; i < N; i++) {
		if (H[i] == Hmax[i]) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long c = cin.Long();
			long k = cin.Long();
			long[] t = new long[n];
			for (int i = 0; i < n; i++) {
				t[i] = cin.Long();
			}

			Array.Sort(t);
			long ans = 0;
			long count = 1;
			long start = t[0];
			for (int i = 1; i < n; i++) {
				if (count + 1 > c || t[i] > start + k) {
					++ans;
					start = t[i];
					count = 1;
				} else {
					++count;
				}
			}

			++ans;

			Console.WriteLine(ans);
		}

		public static bool IsPrime(long value)
		{
			for (int i = 2; i * i <= value; i++) {
				if (value % i == 0) {
					return false;
				}
			}

			return true;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

int main () {
    long long n; cin >> n;

    long long a[n], b[n];
    for (long long i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    long long ans = 0;
    for (long long i = n - 1; i > -1; i--) {
        // if ((a[i] + ans) != 0)
            ans += (b[i] - ((a[i] + ans) % b[i])) % b[i];
        // else 
        //     ans += b[i];
    }
    cout << ans;

}

Measured memory_bytes: 5156
import sys
from bisect import bisect_left

n,q = map(int, input().split())
lines = sys.stdin.readlines()
c = []
for line in lines[:n]:
    s,t,x = map(int, line.split())
    c.append((x,s,t))
c.sort()
d = list(map(int,lines[n:]))

ans = [-1] * q
skip = [-1] * q
for x,s,t in c:
    ss = bisect_left(d,s-x)
    tt = bisect_left(d,t-x)
    while ss < tt:
        if skip[ss] == -1:
            ans[ss] = x
            skip[ss] = tt
            ss += 1
        else:
            ss = skip[ss]
print(*ans,sep='\n')


Measured memory_bytes: 138716
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
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 (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int ans = 0;
	int k = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'B')break;
		k++;
	}
	rep(i, k, s.size()) {
		if (s[i] == 'W') {
			ans += i - k;
			k++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;


namespace templete
{
    class BinarySearch
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] num_n = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int q = int.Parse(Console.ReadLine());
            int[] num_q = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count=0;
            for(int i=0; i<q; i++){
                int key = num_q[i];
                if(Search(num_n,key))count++;
            }
            Console.WriteLine(count);
        }

        static bool Search(int[] num, int key){
            int left=0;
            int right=num.Length;

            while(left<right){
                int mid = (left+right)/2;
                if(num[mid] == key){
                    return true;
                }else if(num[mid] < key){
                    left = mid+1;
                }else{
                    right = mid;
                }
            }
            return false;
        }
    }
}


Measured memory_bytes: 22960
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int y=scan.nextInt();
        
        while(!(x==0&&y==0)){
            for(int i=0; i<x; i++){
                for(int j=0; j<y; j++){
                    if(i==0||i==x-1||j==0||j==y-1)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
            
        x=scan.nextInt();
        y=scan.nextInt();
        }
    }
}


Measured memory_bytes: 37376
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define bk back()
#define pb push_back

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(x,a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0;
}
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0;
}

// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
    // cin.exceptions(cin.failbit);
    // throws exception when do smth illegal
    // ex. try to read letter into int
    if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int f(int n, int x) {
    return n/x;
}

int32_t main() {

    setIO();

    int L,R,x; cin >> L >> R >> x;

    cout << f(R,x)-f(L-1,x) << "\n";

}   

Measured memory_bytes: 3604
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     string a,b,c;
     cin>>a>>b>>c;
     a[0]+='A'-'a';
     b[0]+='A'-'a';
     c[0]+='A'-'a';
     cout<<a[0]<<b[0]<<c[0]<<endl;
}

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

const int maxn = 100010;
int a[maxn];

int main()
{
	int i, j, X, K, Q;
	cin >> X >> K;
	for (i = 1; i <= K; i++)
		cin >> a[i];
	int L, R = X;
	int cnt = 0, k = 0, s = -1, x = 0, ans, num;
	int t, A;
	cin >> Q;
	for (i = 1; i <= Q; i++)
	{
		cin >> t >> A;
		while (k < K && a[k + 1] <= t)
		{
			ans = s * (a[k + 1] - cnt);
			L = max(0, min(X, L + ans));
			R = max(0, min(X, R + ans));
			cnt = a[k + 1];
			s = -s;
			x += ans;
			k++;
		}
		num = t - cnt;
		A = max(L, min(R, A + x));
		A = max(0, min(X, A + s * num));
		cout << A << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#define INF 1111111
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int main(){
   int n,m,q;
  cin >> n>> m >> q;
  int map[n+2][n+2] = {};
  int l,r;
  int P,Q;
  int a[n+2][n+2] = {};
  
  for(int i=0;i<m;i++){
    scanf("%d %d",&l,&r);
    map[l][r]++;
  }
    
  for(int j=1; j<=n; j++){
     for(int k=j; k<=n; k++){
       a[j][k] = a[j][k-1];
       for(int l=j; l<=k; l++){
        a[j][k] += map[l][k];
       }
     }
  }
  int ans = 0;
  for(int i=0; i<q; i++){   
    scanf("%d %d",&P,&Q);
    ans = a[P][Q];
    cout << ans << endl;
  }
}


Measured memory_bytes: 2944
#include<stdio.h>

#define N1 100000
#define N2 50000

int main(){
  int S[N1+1];
  int T[N2+1];
  int n,q,i,j,left,right,mid,key;
  int count=0;
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ) scanf("%d", &S[i]);
  scanf("%d", &q);
  for( i = 0; i < q; i++ ) scanf("%d", &T[i]);

  for(i=0;i<q;i++){
    key=T[i];
    left=0;
    right=n;

    while(left<right){
      mid=(left+right)/2;

      if(key==S[mid]){
	count++;
	break;
      }

      if(key>S[mid]){
	left=mid+1;
      }

      if(key<S[mid]){
	right=mid;
      }

    }
  }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	
fast;

int n;
cin>>n;

vector<int> a(n),b(n);
for(int i=0;i<n;i++)
cin>>a[i];

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

reverse(b.begin(),b.end());

int l=-1,r=-1;
for(int i=0;i<n;i++)
{
	if(a[i]!=b[i])continue;
	else
	{
		l=i;
		while(i<n and a[i]==b[i])
			i++;
		r=i-1;
		break;
	}
}

 if(l==-1)
{
	cout<<"Yes"<<endl;
	for(auto i:b)
		cout<<i<<" ";
}

else
{
	int i1=l-1,i2=r+1;
	bool f=1;

	for(int i=l;i<=r and (i1>-1 or i2<n);i++)
	{
		while(i1>-1 and (b[i1]==b[r] or a[i1]==b[r])) i1--;
		while(i2<n and (b[i2]==b[r] or a[i2]==b[r]))i2++;

		if(i1>-1)
			swap(b[i1],b[i]),i1--;
		else if(i2<n)
			swap(b[i2],b[i]),i2++;

		else 
		break;
	}

	
		for(int i=0;i<n;i++)
			if(a[i]==b[i])
			{
				cout<<"No"<<endl;
				return 0;
			}
			
		cout<<"Yes"<<endl;
		for(auto i:b) cout<<i<<" ";

}

}


Measured memory_bytes: 4740
#include <cstdio>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
using namespace std;
struct edge {
    int to, cost;
    edge(int _to, int _cost) { to=_to; cost=_cost; }
};
typedef pair<int, int> P;
typedef long long ll;
void solve(int f, int t, vector<edge> *G, int n) {
    priority_queue<P, vector<P>, greater<P> > que;
    ll d[n];
    fill(d, d+n, LLONG_MAX);
    d[f-1]=0;
    que.push(P(0,f-1));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e=G[v][i];
            if (d[e.to]>d[v]+e.cost) {
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    if (d[t-1]==LLONG_MAX) puts("-1");
    else printf("%lld\n",d[t-1]);
}
int main() {
    int n, k;
    while (scanf("%d%d",&n,&k)) {
        if (!n&&!k) break;
        vector<edge> G[n];
        for (int i=0; i<k; i++) {
            int s; scanf("%d",&s);
            if (s) {
                int x, y, cost;
                scanf("%d%d%d",&x,&y,&cost);
                G[x-1].push_back(edge(y-1,cost));
                G[y-1].push_back(edge(x-1,cost));
            } else {
                int f, t; scanf("%d%d",&f,&t);
                solve(f,t,G,n);
            }
        }
    }
}

Measured memory_bytes: 860
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for(int i=0;i<(int)(n);i++)
    #define ll long long
    #define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
    int gcd(int a, int b){
        if(a%b == 0){
            return b;
        }else{
        return gcd(b, a%b);
        }
    }
     
    int main(){
        int n,m,c,count=0;
        cin >> n >> m >> c;
        vector<int> b(m);
        vector<vector<int>> a(n,vector<int>(m));
        rep(i,m) cin >> b[i];
        rep(i,n){
            rep(j,m){
                cin >> a[i][j];
            }
        }
        rep(i,n){
            ll sum=0;
            rep(j,m){
                sum+=b[j]*a[i][j];
            }
            sum+=c;
            if(sum>0) count++; 
        }
        cout << count << endl;
        return 0;
    }

Measured memory_bytes: 3592
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>x>>a>>b;
    x-=a;
    x%=b;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3532
n, k = map(int, input().split())

mx = int((n - 1) * (n - 2) / 2)
if mx < k:
    print(-1)
    exit()

ans = []
for i in range(n - 1):
    ans.append([i + 1, n])

edge = []
add = int(mx - k)
for i in range(n - 1):
    for j in range(i):
        edge.append([i + 1, j + 1])

for i in range(add):
    ans.append(edge[i])

print(len(ans))
for i in range(len(ans)):
    print(ans[i][0], ans[i][1])


Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const int MOD = 1e9 + 7;
 
string S;
ll dp[100001][13];

 
int main() {  
  cin >> S;
  int n = S.size();
  int mul = 1;


  dp[0][0] = 1;

  REP(i,n) {
    char c = S[n-i-1];

    if ( c == '?') {
      REP(mod, 13) {
        REP(d, 10) {
          int j = (d * mul + mod) % 13;
          dp[i+1][j] += dp[i][mod];
          dp[i+1][j] %= MOD;
        }
      }

    } else {
      int num = c - '0';

      REP(mod,13) {
        // cout << mod << endl;
        int j = (num * mul + mod) % 13;
        dp[i+1][j] += dp[i][mod];
        dp[i+1][j] %= MOD;
      }
    }
    mul *= 10;
    mul %= 13;
  }

  cout << dp[n][5] % MOD << endl;

}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,a[200001];
	bool b1[200001],b2[200001];
	cin>>n>>m;
	memset(b1,1,sizeof(b1));
	memset(b2,1,sizeof(b2));
	for (int i=1;i<=m;i++){
		cin>>a[i];
		b1[a[i]]=false;
	}
	for(int i=m;i>=1;i--){
		if (b2[a[i]]==true){
			cout<<a[i]<<endl;
			b2[a[i]]=0;
		}
	}
	for(int i=1;i<=n;i++){
		if (b1[i]==true) cout<<i<<endl;
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int arr[200005];
int Size[200005];
int n,m;
void init()
{
    for(int i=0;i<=n;i++)
    {
        arr[i] = i;
        Size[i] = 1;
    }
}
int root(int i)
{
    while(arr[i]!=i)
    {
        i = arr[arr[i]];
        i = arr[i];
    }
    return i;
}
void w_union(int a,int b)
{
    int root_a = root(a);
    int root_b = root(b);
    if(root_a==root_b) return;
    if(Size[root_a]<Size[root_b])
    {
        arr[root_a] = arr[root_b];
        Size[root_b] += Size[root_a];
    }
    else
    {
        arr[root_b] = arr[root_a];
        Size[root_a] += Size[root_b];
    }
}
signed main()
{
    IOS
    cin>>n>>m;
    init();
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        w_union(a,b);
    }
    int maxx=0;
    for(int i=1;i<=n;i++){
        int rooti=root(i);
        maxx=max(maxx,(ll)Size[rooti]);
    }
    cout << maxx << endl;
    return 0;
}
///Alhamdulillah


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;
    vector<ll> A(N+1);
    for (ll i = 2; i <=N; i++) {
        cin>> A.at(i);
    }

    vector<ll> vec(N+1);
    for (ll i = 2; i <= N; i++)
    {
        vec.at(A.at(i))++;
    }

    REPS(i,N){
        cout << vec.at(i) << endl;
    }
}


Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, int>;

const ll INF = LLONG_MAX;

struct edge {
	int to;
	ll cost;
	edge(int t, ll c) : to(t), cost(c) {}
};

using graph = vector<vector<edge>>;

int main()
{
	int N, M;
	cin >> N >> M;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D; L--, R--;
		G[L].emplace_back(R, D);
		G[R].emplace_back(L, -D);
	}
	bool ok = true;
	vector<ll> d(N, INF);
	priority_queue<pii, vector<pii>, greater<>> pq;
	for (int i = 0; i < N; i++) {
		if (d[i] != INF) continue;
		pq.emplace(0, i);
		while (!pq.empty()) {
			auto p = pq.top(); pq.pop();
			int v = p.second, dist = p.first;
			if (d[v] != INF) {
				if (d[v] != dist) {
					ok = false;
					break;
				}
				continue;
			}
			d[v] = dist;
			for (auto e : G[v]) {
				pq.emplace(dist + e.cost, e.to);
			}
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 19832
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int a, b, c;
  cin >> a >> b >> c;

  int m = max(a, max(b, c));
  int ans = m * 10 + (a + b + c - m);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, p, a[110];
long long dp[100][2];

signed main() {
	cin >> n >> p;
	rep(i, n)cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] % 2 == 0) {
			dp[i][0] = dp[i - 1][0] * 2;
			dp[i][1] = dp[i - 1][1] * 2;
		}
		else {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
		}
	}
	cout << dp[n][p] << endl;
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	cin>>n;
	a=n%10;
	if(a==2 || a==4 || a==5 || a==7 || a==9){
		cout<<"hon"<<endl;
	}
	else if(a==3){
		cout<<"bon"<<endl;
	}
	else{
		cout<<"pon"<<endl;
	}
  return(0);
}

Measured memory_bytes: 3588
import math
a, b, h, m = map(int, input().split())
theta = (360*(h+m/60)/12 - 360*m//60) % 360
theta = theta if theta<=180 else 360-theta
theta = theta * math.pi /180
ans = (a**2+b**2-2*a*b*math.cos(theta))**0.5
print(ans)

Measured memory_bytes: 9516
H,W,N=map(int,input().split())
z={}
for _ in range(N):
    x,y=map(int,input().split())
    if z.get(x,10**6) > y:
        z[x] = y
length=1
for x in range(1,H):
    if z.get(x+1,10**6) <= length:
        print(x)
        exit()
    elif z.get(x+1,10**6) == length+1:
        continue
    length+=1
print(H)

Measured memory_bytes: 32604
/* C */
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	ll a = A[1];
	repk(i,2, N) {
		a ^= A[i];
	}
	rep(i, N) {
		cout << ((A[0] ^ A[i]) ^ a) << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#define XOX
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int long long

signed main()
{
    int n, d;
    cin >> n >> d;
    int ans = 0;
    while (n--) {
        int x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << '\n';
}


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

int main(){
    int N,M,X,Y,A,B,C,D;
    cin >> A >> B;
    if(A <= 2 * B){
        cout << 0 << endl;
    }else{
        cout << A - 2*B << endl;
    }
   
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

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

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

int main()
{
	FAST;
	ull n,a,b,c,d,e;

	cin >> n >> a >> b >> c >> d >> e;

	ull m = min({a,b,c,d,e});
	if(m >= n)
		cout << "5";
	else
		cout << ((n-1)/m) + 5;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <cstdio>
#include <iostream>
#include <fstream>

using namespace std;

#define NMAX 200010

int a[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

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

int min(int a, int b) {
    if(a > b) return b;
    else return a;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int itr = 0; itr < k; itr++) {
        int f = 0;
        reset(n+1);
        for(int i = 0; i < n; i++){
            f = (a[i] != n);
            imos[max(0, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        if(!f) break;
    }

    for(int i = 0; i < n; i++) printf("%d\n", a[i]);
    return 0;
}


Measured memory_bytes: 5348
#include<stdio.h>
#define K 100000

int A[K];

int partition(int p,int r){
  int x,i,j,v;
  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++){
    if(A[j] <= x){
      i = i + 1;
      v = A[i];
      A[i] = A[j];
      A[j] = v;
    }
  }
  v = A[i + 1];
  A[i + 1] = A[r];
  A[r] = v;
  return i+1;
}

int main(){
  int n,i,q;

  scanf("%d",&n);

  for(i = 0;i < n;i++) scanf("%d",&A[i]);

  q = partition(0,n-1);

  for(i = 0;i < n;i++){
    if(i > 0) printf(" ");
    if(i == q) printf("[");
    printf("%d",A[i]);
    if(i == q) printf("]");
  } printf("\n");
  return 0;
}



Measured memory_bytes: 2184
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	var sum int
	for _, char := range n {
		num, _ := strconv.Atoi(string(char))
		sum += num
	}

	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3184
// Code for D - String Formation
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;

int main() {
	string front="",back="",s;
	unsigned long qnum;
	stack<string> qstack;
	string void_;
	int reverse = 0;
	cin >> s;
	cin >> qnum;
	std::getline(cin,void_);
	for(uint i=0;i<qnum;i++){
		string tmp;
		std::getline(cin,tmp);
		//cout <<"tmp: "<< tmp << endl;
		qstack.push(tmp);
	}
	for(uint i=0;i<qnum;i++){
		string qstr = qstack.top();
		//cout <<"qstr: "<< qstr << endl;
		qstack.pop();
		if(qstr.size() == 1 && qstr[0] == '1') reverse ^=1;
		else if (qstr.size() >= 4 ){
			const char adddir = qstr[2];
			int dir = (atoi(&adddir) >> 1) ^ reverse;
			string addstr = qstr.substr(4, qstr.size()-4);
			if(reverse)std::reverse(addstr.begin(), addstr.end());
			if(dir == 0)front += addstr;
			else back = addstr + back;
		}
		//cout << front << "," << back << endl;
	}
	if(reverse)std::reverse(s.begin(), s.end());
	cout << front << s << back;
	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

int32_t main()
{
    int n, w;
    cin >> n >> w;
    int wt[n + 1], val[n + 1];
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> wt[i] >> val[i];
        sum += val[i];
    }
    int dp[n + 1][sum + 1];
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= sum; j++)
            dp[i][j] = INT_MAX;

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

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= sum; j++)
        {
            if (val[i] <= j)
            {
                dp[i][j] = min(wt[i] + dp[i - 1][j - val[i]], dp[i - 1][j]);
            }
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    int ans = 0;
    for (int i = 0; i <= sum; i++)
        if (dp[n][i] <= w)
            ans = i;
    cout << ans << endl;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int d[10];
    for (int i = 1; i <= 4; i++) {
        d[i] = 0;
    }
    for (int i = 0; i < 6; i++) {
        int z;
        scanf("%d", &z);
        d[z]++;
    }
    if (d[1] <= 2 && d[2] <= 2 && d[3] <= 2 && d[4] <= 2) {
        printf("YES\n"); 
    }
    else {
        printf("NO\n"); 
    }
}

Measured memory_bytes: 128
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
constexpr ll dx[]={1,0,-1,0,1,1,-1,-1};
constexpr ll dy[]={0,1,0,-1,1,-1,1,-1};
constexpr ll ddx[] = {2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr ll ddy[] = {0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
using T3 = tuple<ll,ll,ll>;
using T4 = tuple<ll,ll,ll,ll>;
signed main(){

  int h,w;
  cin>>h>>w;
  int ch,cw;
  cin>>ch>>cw;
  int dh,dw;
  cin>>dh>>dw;
  auto s = vec<char>(h,w);
  cin>>s;
  ch--;cw--;dh--;dw--;

  auto dist = vec<ll>(h,w);
  for(auto& di:dist)for(auto& dij:di)dij=INF;
  priority_queue<T3,vector<T3>,greater<>> que;
  que.emplace(0,ch,cw);
  while(!que.empty()){
    auto [cost,y,x] = que.top();
    que.pop();
    if(!chmin(dist[y][x],cost))continue;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      //if(dist[ny][nx]!=INF)continue;
      que.emplace(cost,ny,nx);
    }
    rep(j,4){
      int ny = y+dy[j+4];
      int nx = x+dx[j+4];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      //if(dist[ny][nx]!=INF)continue;
      que.emplace(cost+1,ny,nx);
    }
    rep(k,16){
      int ny = y+ddy[k];
      int nx = x+ddx[k];
      if(ny<0||nx<0||ny>=h||nx>=w)continue;
      if(s[ny][nx]=='#')continue;
      //if(dist[ny][nx]!=INF)continue;
      que.emplace(cost+1,ny,nx);
    }
  }
  cout<<(dist[dh][dw]==INF?-1:dist[dh][dw])<<endl;

}


Measured memory_bytes: 15120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#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 all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1);
  ll sum = 0;
  rep(i,n+1){
    cin >> vec[i];
    sum += vec[i];
  }
  sum -= 1;
  //cout << sum << endl;
  ll piv = 1;
  ll ans = 1;
  bool can = true;
  if(vec[0] != 0){
    can = false;
  }
  rep(i,n){
    if(piv <= 0){
      can = false;
    }
    if(piv <= sum){
      sum -= piv;
      piv *= 2;
    }else{
      piv += sum;
      sum = 0;
    }
    ans += piv;
    //cout << sum << endl;
    piv -= vec[i+1];
  }
  if(piv != 0){
    can = false;
  }
  if(n == 0 && vec[0] == 1){
    can = true;
    ans = 1;
  }
  if(can){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 4020
import heapq as hq
N,M = map(int, input().split())
A =[-x for x in map(int, input().split())]

hq.heapify(A)
for i in range(M):
    m = A[0]
    hq.heappushpop(A, -((-m)//2))
print(-sum(A))


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long a,b,c,d,total = 0;
  cin >> a >> b >> c >> d;
	long a1 = (a - 1) / c,a2 = (a - 1) / d;
  long b1 = b / c,b2 = b / d;
  long r,cr = c,dr = d;
  if(cr < dr){
    swap(cr,dr);
  }
  
  r = cr % dr;
  
  while(r > 0){
    cr = dr;
    dr = r; //最大公約数
    r = cr % dr;
  }
  
  r = c* d / dr; //最小公倍数
  total = -a1 + b1 - a2 + b2  -( b / r - (a - 1) / r);
  cout << b - (a - 1) - total << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair

/*
a ^ b + a ^ c = a ^ (b+c)
*/

signed main(){
  string s;
  int res=0;
  cin>>s;
  for(int i=0;i<s.size()/2;++i){
    if(s[i]!=s[s.size()-1-i])++res;
  }
  cout<<res;
}

Measured memory_bytes: 256
///*
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {

	string input;

	//===連想配列(mapの作成)
	map<string, string> Helix;
	Helix["A"] = "T";
	Helix["T"] = "A";
	Helix["C"] = "G";
	Helix["G"] = "C";

	//===input output

	cin >> input;
	cout << Helix[input] << endl;

	return 0;

}
//*/

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


int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else
		cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    SC = [list(map(int, input().split())) for i in range(M)]

    for i in range(10**N):
        result = str(i)
        if len(result) != N:
            continue
        if all(result[s - 1] == str(c) for s, c in SC):
            print(result)
            exit()

    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.Scanner

var N:Int=0;
var A:Int=0;
var B:Int=0;
val sc=Scanner(System.`in`)
fun main(args:Array<String>){
    N=sc.nextInt()
    A=sc.nextInt()
    B=sc.nextInt()
    println(Math.min(A*N,B))
}


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

using namespace std;

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

    int H;
    int H_before;
    int c = 0;
    int c_max = 0;
    cin >> H_before;
    for (int i = 1; i < N; i++) {
        cin >> H;
        if (H <= H_before) c++;
        else c = 0;
        c_max = max(c, c_max);
        H_before = H;
    }

    cout << c_max << endl;
}

Measured memory_bytes: 256