akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n;
vector<vector<int>> a;
ll memo[23][1 << 23];
 
ll dp(int i, int bit){
    if(i == n){
        if(bit == (1 << n) - 1) return 1;
    }
    if(memo[i][bit] != -1) return memo[i][bit];
    
    ll res = 0;
    for(int j = 0; j < n; j++){
        if(bit & (1 << j)) continue;
        if(!a[i][j]) continue;
        int nbit = bit | (1 << j);
        res += dp(i + 1, nbit);
        res %= MOD;
    }
 
    return memo[i][bit] = res;
 
}
 
int main(void){
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++){
        a[i].resize(n);
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
 
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= (1 << n); j++){
            memo[i][j] = -1;
        }
    }
 
    cout << dp(0, 0) << endl;
}

Measured memory_bytes: 405760
#include<bits/stdc++.h>
#define ll long long
#define N 200010
#define mo 1000000007
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll b,w,gb,gw,jie[N],nj[N];
long double dp[1010][1010];
ll c(ll x,ll y){if (x<y) return 0;return (jie[x]*nj[y]%mo)*nj[x-y]%mo;}
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
int main(){
	read(b);read(w);
	gb=0;gw=0;
	jie[0]=1;
	for (int i=1;i<=b+w;i++) jie[i]=jie[i-1]*i%mo;
	nj[b+w]=po(jie[b+w],mo-2);for (int i=b+w-1;i>=0;i--) nj[i]=nj[i+1]*(i+1)%mo;
	for (int i=1;i<=b+w;i++){
		printf("%d\n",((1-gb+gw+mo+mo)*po(2,mo-2))%mo);
		gb=(gb+c(i-1,b-1)*po(2,1ll*i*(mo-2)))%mo;
		gw=(gw+c(i-1,w-1)*po(2,1ll*i*(mo-2)))%mo;
	}
	return 0;
}

Measured memory_bytes: 6912
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())

if c7-c4==c8-c5==c9-c6 and c4-c1==c5-c2==c6-c3 and c3-c2==c6-c5==c9-c8 and c2-c1==c5-c4==c8-c7:
    print("Yes")
else:
    print("No")
    

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

using namespace std;

const int N = 1e2+7;

int n;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    int l = 0, r = n;
    while (l < r) {
        int mid = (l+r)>>1;
        if (mid*108/100 >= n) r = mid;
        else l = mid+1;
    }
    if (l*108/100 == n) cout << l << endl;
    else cout << ":(" << endl;
    return 0;
}



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

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

int n;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}



void solve(){
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(i%2==1){
            if(s[i]=='R'){
                cout<<"No"<<endl;
                return;
            }
        }else{
            if(s[i]=='L'){
                cout<<"No"<<endl;
                return;
            }
        }
        if(i==s.size()-1){
            cout<<"Yes"<<endl;
            return;
        }
    }
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int a[]=new int[4];
	int b[]=new int[4];
	int s=0,t=0;
	for(int i=0;i<4;i++){
		a[i]=sc.nextInt();
		s+=a[i];
	}
	for(int i=0;i<4;i++){
		b[i]=sc.nextInt();
		t+=b[i];
	}
	if(s>=t)System.out.println(s);
	else System.out.println(t);
	}
}

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

int main(int argc, char const *argv[]) {
  int n, t, min = 1000, flag = 0, c[1010], tt[1010];
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> tt[i];
    if(t >= tt[i]&&min >=c[i]) {
      min = c[i];
      flag = 1;
    }
  }
  if (flag == 1) {
    cout << min << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;

void main() {
  int N, DAYS;
  readf("%d %d\n", &N, &DAYS);

  uint[][uint] incomes;

  foreach(i; 0..N) {
    int income, delay;
    readf("%d %d\n", &delay, &income);
    
    if (delay in incomes)
      incomes[delay] ~= income;
    else
      incomes[delay] = [income];
  }

  uint income = 0;
  uint[] candidates = new uint[N];
  auto heap = heapify(candidates, 0);
  foreach(day; 1..DAYS+1) {
    if (day in incomes) incomes[day].each!(d => heap.insert(d));
    if (heap.empty()) continue;

    income += heap.front;
    heap.removeFront();
  }
  writeln(income);
}


Measured memory_bytes: 8572
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using System.Collections;

class P
{
    static void Main()
    {
        var ab = Console.ReadLine().Split().Select(BigInteger.Parse).ToList();
        Console.WriteLine(ab[0] * ab[1]);
    }
}


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


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

    vector<int> vec(N);

    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    double syns = (vec.at(0) + vec.at(1)) / 2.0;

    for(int i=2; i<N; i++){
        syns = (syns + vec.at(i)) / 2.0;
    }

    cout << syns << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    ans=Size(s);
    rep(i,Size(s)-1){
        if(s[i]!=s[i+1]){
            ans=min(ans,max((ll)i+1,(ll)Size(s)-i-1));
        }
    }
    Cout(ans);
    return 0;
}


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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> R(N), G(N), B(N);
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') R[i]++;
    if (S[i] == 'G') G[i]++;
    if (S[i] == 'B') B[i]++;
  }
  for (int i = 1; i < N; i++) {
    R[i] += R[i - 1];
    G[i] += G[i - 1];
    B[i] += B[i - 1];
  }
  long long ans = 0;
  for (int j = 1; j < N; j++) {
    for (int k = j + 1; k < N; k++) {
      int i = 2 * j - k;
      if ((S[j] == 'R' and S[k] == 'G') or (S[j] == 'G' and S[k] == 'R')) {
        ans += B[j - 1];
        if (i >= 0 and S[i] == 'B') ans--;
      }
      if ((S[j] == 'R' and S[k] == 'B') or (S[j] == 'B' and S[k] == 'R')) {
        ans += G[j - 1];
        if (i >= 0 and S[i] == 'G') ans--;
      }
      if ((S[j] == 'G' and S[k] == 'B') or (S[j] == 'B' and S[k] == 'G')) {
        ans += R[j - 1];
        if (i >= 0 and S[i] == 'R') ans--;
      }
    }
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3672
use std::cmp;

fn read_i64s() -> Vec<i64> {
	let mut buf = String::new();
	std::io::stdin().read_line(&mut buf).unwrap();
	buf.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main(){
	let vals = read_i64s();
	let n = vals[0] as usize;
	let m = vals[1] as usize;
	let mut vals = Vec::new();
	for _ in 0..n {
		vals.push(read_i64s());
	}
	
	let mut ans : i64 = 0;
	let mut sum = Vec::new();
	for z in 0..8 {
		sum.clear();
		for v in &vals {
			let mut s : i64 = 0;
			for i in 0..3 {
				let w = if (z >> i & 1) == 0 {1} else {-1};
				s += w * v[i];
			};
			sum.push(s);
		}
		sum.sort();
		sum.reverse();
		let mut y : i64 = 0;
		for i in 0..m {
			y += sum[i];
		}
		ans = cmp::max(ans, y);
	}
	println!("{}", ans);
}


Measured memory_bytes: 4352
w=lambda:map(int,input().split())
N,M=w()
A=sorted(w())
cb=sorted([[c,b] for b,c in [w() for _ in range(M)]], reverse=True)

t = 0
cbp = 0
for a in A:
	if len(cb) == cbp:
		t += a
	else:
		c,b=cb[cbp]
		if c > a:
			t += c
			b -= 1
			if b == 0:
				cbp += 1
			else:
				cb[cbp][1] = b
		else:
			t += a
			cbp = len(cb)

print(t)


Measured memory_bytes: 61612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
      int n = Integer.parseInt(br.readLine()); // 何次元か
      String[] x = br.readLine().split("\\s"); // x座標
      String[] y = br.readLine().split("\\s"); // y座標
      double d = 0;  // 距離
      List<Double> mdList = new ArrayList<>(); // 距離のリスト

      // マンハッタン距離（p = 1 のとき）
      for (int i = 0; i < n; i++) {
        // 絶対値の合計値
        d += Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i]));
      }
      mdList.add(d);
      d = 0;

      // ユークリッド距離（p = 2 のとき）
      for (int i = 0; i < n; i++) {
        // 絶対値を2乗した値の合計値
        d += Math.pow(Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])), 2);
      }
      // 平方根にして格納
      mdList.add(Math.sqrt(d));
      d = 0;

      // ユークリッド距離（p = 3 のとき）
      for (int i = 0; i < n; i++) {
        // 絶対値を3乗した値の合計値
        d += Math.pow(Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])), 3);
      }
      // 立方根にして格納
      mdList.add(Math.cbrt(d));
      d = 0;

      // チェビシェフ距離（p = ∞）
      for (int i = 0; i < n; i++) {
        // 最大値を算出
        d = Math.max(d, Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])));
      }
      mdList.add(d);

      // 結果を出力
      for (Double md: mdList) {
        System.out.printf("%.10f\n", md);
      }

    } catch (NumberFormatException | IOException e) {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 26344
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, b;
  scan(a, b);
  int mi = min(a, b);
  int ma = max(a, b);
  rep (i, ma) {
    printf("%d", mi);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 888
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll a, b, c, d, e,ans=0;
string s, ss, sss;
vector<ll>v;
int main() {

	cin >>a>>b>>c ;

	cout<<  yn(a+b>=c) <<endl;

	return 0;
}

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

namespace _4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse).ToList();
            long sum = num.Sum();
            long max = num.Max();
            long min = num.Min();
            Console.WriteLine("{0} {1} {2}", min, max, sum);
        }
    }
}



Measured memory_bytes: 18336
#include <iostream>
using namespace std;
int main(void){
    string alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    string ans = "";
    for(int i = 0;i < s.size();i++){
        int idx = (s[i] - 'A' + n) % alph.size();
        ans += alph[idx];
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> digits(n, -1);
    vector<P> conditions(m);
    rep(i, m) cin >> conditions[i].first >> conditions[i].second;
    rep(i, m) conditions[i].first--;
    for (P p : conditions) {
        digits[p.first] = p.second;
    }

    if (n == 1) {
        if (digits[0] == -1) digits[0] = 0;
    } else {
        rep(i, n) {
            if (i == 0 && digits[0] == -1) digits[0] = 1;
            else if (digits[i] == -1)digits[i] = 0;
        }
    }

    for (P p : conditions) {
        if (digits[p.first] != p.second) {
            cout << -1 << endl;
            ret();
        }
    }

    if (digits.size() > 1 && *max_element(digits.begin(), digits.end()) == 0) {
        cout << -1 << endl;
        ret();
    }

    int ans = 0;
    rep(i, n) {
        ans *= 10;
        ans += digits[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    int res = 0;
    int startB_endA = 0;
    int start_B = 0;
    int end_A = 0;
    rep(i,N){
        string s; cin >> s;
        if(s[0]=='B') start_B++;
        if(s[s.length()-1]=='A') end_A++;
        if(s[0] == 'B' && s[s.length()-1]=='A') startB_endA++;
        rep(j,s.length()-1){
            if(s[j]=='A' && s[j+1]=='B') res++;
        }
    }
    if(startB_endA==start_B && startB_endA==end_A && start_B>0) res--; 
    pr(res + min(start_B,end_A));

}


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

#define rep2(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) rep2(i,0,n)
#define all(a) a.begin(),a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int a, p; cin >> a >> p;
    p += 3 * a;
    cout << p / 2 << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>

using namespace std;


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

    int count = 0;
    if (s[0] == '1') ++count;
    if (s[1] == '1') ++count;
    if (s[2] == '1') ++count;

    cout << count << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector <vector <int> > input(M, vector<int>(2));
  vector<int> output(N, 0);
  for (int i = 0; i <M; ++i){
    cin >> input.at(i).at(0) >> input.at(i).at(1);
  }
  for (int i= 0; i < N; ++i){
    for (int j = 0; j < M; ++j){
      for (int k = 0; k < 2; ++k){
        if(i+1 == input.at(j).at(k)){
          ++output.at(i);
        }
      }
    }
  }
 for (int i = 0; i < N; ++i){
   cout << output.at(i) << endl;
 }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
    using namespace std;
     
    #define pb push_back
    #define ll long long
   	#define mp make_pair

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       	char a;
        cin >> a;
        if(a >= 'a' and a <= 'z'){  
            cout << "a" << endl;
        }else{  
            cout << "A" << endl;
        }
        return 0;
    }

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int i,ans=0;
  string s,t; cin >> s >> t;
  rep(i,s.length()){
      if(s[i]!=t[i]){ans++;}
  }
  cout << ans << endl;

  return 0;
}


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

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

int main()
{
	int n; cin>>n;
	vector<string> a(n);
	rep(i,n) cin>>a[i];
	
	map<string,int> anko;
	rep(i,n) anko[a[i]]++;
	
	int m=0;
	for(auto& x:anko){	
		if(m<x.second){
			m=x.second;
		}
	}
	sort(a.begin(),a.end());
	for(auto& x:anko){
		if(m<=x.second) cout<<x.first<<endl;
	}
	return 0;
}


Measured memory_bytes: 26752
#include <iostream>

using namespace std;

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int plays[Q];
  for(int i=0; i<Q; i++){
    cin>>plays[i];
  }
  
  int scores[N];
  for(int i=0; i<N; i++){
    scores[i]=K-Q;
  }
  
  for(int i=0; i<Q; i++){
    int correct = plays[i]-1;
    scores[correct] += 1;
  }
  for(int i=0; i<N; i++){
    if(scores[i]<= 0){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }



  return 0;
}

Measured memory_bytes: 1408
from collections import defaultdict

n = int(input())
V = list(map(int, input().split()))

odds_counter = defaultdict(int)
evens_counter = defaultdict(int)

for o in V[0::2]:
    odds_counter[o] += 1
for e in V[1::2]:
    evens_counter[e] += 1

odds = sorted(odds_counter.items(), key=lambda x: x[1], reverse=True)
evens = sorted(evens_counter.items(), key=lambda x: x[1], reverse=True)

if odds[0][0] != evens[0][0]:
    ans = n - odds[0][1] - evens[0][1]
else:
    if len(odds) == 1 and len(evens) == 1:
        ans = odds[0][1]
    elif len(odds) == 1 and len(evens) != 1:
        ans = n - odds[0][1] - evens[1][1]
    elif len(odds) != 1 and len(evens) == 1:
        ans = n - odds[1][1] - evens[0][1]
    else:
        ans = min(n - odds[0][1] - evens[1][1], n - odds[1][1] - evens[0][1])
print(ans)


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



int N, M, Q;
vi L, R;
vvi imo;

void prepare() {
    imo.assign(N+1, vi(N+1, 0));

    rep(i,M){
        int from = L[i], to = R[i];
        ++imo[from][to];
    }

    for (int r=N; r>0; --r){
        rep1(c,N) {
            imo[r][c] += imo[r][c-1];
        }
        if (r < N) {
            rep(c,N+1)
                imo[r][c] += imo[r+1][c];
        }
    }
#ifdef DEBUG
    for (int r=1;r<=N;++r) {
        for (int c=1;c<=N;++c) {
            fprintf(stderr, " %2d", imo[r][c]);
        }
        fprintf(stderr, "\n");
    }
#endif
}

int query(int p, int q) {
    return imo[p][q];
}

int main() {
    cin >> N >> M >> Q;
    L.resize(M); R.resize(M);
    rep(i,M) cin >> L[i] >> R[i];

    prepare();

    rep(i,Q) {
        int p,q; cin >> p >> q;
        cout << query(p,q) << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

        int x;

        cin >> x;

        if (x == 5 || x == 7 || x == 3) {
                cout << "YES" << endl;
        } else {
                cout << "NO" << endl;
        }

        return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && b > 0) {
        c -= b;
        a -= d;
    }
    if (c <= 0) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b + c > 21) {
		printf("bust");
	} else {
		printf("win");
	}

	return 0;
}


Measured memory_bytes: 256
def solve(l, r, i):
    if i - l < 1:
        return 0
    return dp[i - l] - dp[max(i - r - 1, 0)]


n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
MOD = 998244353

dp = [0] * (n + 1)
dp[1] = 1

for i in range(2, n + 1):
    tmp = 0
    for l, r in lr:
        tmp += solve(l, r, i)
    tmp = tmp % MOD
    dp[i] = (dp[i - 1] + tmp) % MOD

print(tmp)

Measured memory_bytes: 16712
#include <iostream>
#include<vector>

using namespace std;


int main()
{
    int n;
    cin>>n;
    vector<int>x(n);
    int y0=0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(i&1)
            y0-=x[i];
        else
            y0+=x[i];
    }
    cout<<y0<<" ";
    for(int i=0;i<n-1;i++)
    {
        cout<<(2*x[i]-y0)<<" ";
        y0=(2*x[i]-y0);
    }
    return 0;
}


Measured memory_bytes: 1664
A_list = []
for i in range(3):
    A = list(map(int, input().split()))
    A_list.append(A)
N = int(input())
for i in range(N):
    B = int(input())
    for j in range(3):
        for k in range(3):
            if A_list[j][k]==B:
                A_list[j][k] = -1
flag = False
for i in range(3):
    if A_list[0][i] == -1 and A_list[1][i] == -1 and A_list[2][i] == -1:
        flag = True
if flag!=True:
    for i in range(3):
        if A_list[i][0] == -1 and A_list[i][1] == -1 and A_list[i][2] == -1:
            flag = True
    if flag!=True:
        if (A_list[0][0] == -1 and A_list[1][1] == -1 and A_list[1][1] == -1) or (A_list[0][2] == -1 and A_list[1][1] == -1 and A_list[2][0] == -1):
            flag = True
print("Yes") if flag else print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<random>
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
 
int main(){
  int N;
  cin >> N;

  rep(i,N){
    int A;
    cin >> A;
    if(A%2 == 0){
      if(A%3 != 0 && A%5 != 0){
        cout << "DENIED" <<endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" <<endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	int n;
	//while(cin>>n,n){
		cin>>n;
		long long int ans=1;
		REP(i,1,n+1){
			ans*=i;
			ans%=1000000007;
		}
		p(ans);
	//}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> a(n + 1, 0);
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            if (x * x + y * y + x * y > n)
            {
                break;
            }
            for (int z = 1; z <= 100; z++)
            {
                if (x * x + y * y + z * z + x * y + y * z + z * x > n)
                {
                    break;
                }
                a[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
 
int main() {
    string s;
    cin >> s;
    int n = s.length();
    int m = 7;
    REP(i,m){
        int j = m - i;
        string t = s.substr(0, i);
        t += s.substr(n - j, j);
        if (t == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  double ans = 0;
  double val;
  string unit;
  for(int i = 0; i < N ; i++){
    cin >> val >> unit;
    if(unit == "JPY"){
      ans += val;
    }
    else{
      ans += (val * 380000);
    }
  }
  
  cout << ans << endl;
 
  return 0;
  
}


Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
l=[0]*n
c=0
for i in range(n):
    if s[-1-i]=="W":
        c+=1
    l[-1-i]=c
ans=0
for i in range(n):
    if s[i]=="B":
        ans+=l[i]
print(ans)

Measured memory_bytes: 67308
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int ketawa(int n){
  int sum = 0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  LL sum=0;
  REPC(i,1,n){
    int m = ketawa(i);
    if(a<=m && m<=b)sum+=i;
    //DUMP(i,m,sum);
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s;
    cin >> s;
    int maru=0;
    int batu=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='o') maru++;
        else batu++;
    }
    if(s.size()<8) puts("YES");
    else if(15-s.size()+maru>=8) puts("YES");
    else puts("NO");
    return 0;
}


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

using namespace std;

class DisjointSet{
  public:
    vector<int> p, sizes;

    DisjointSet(){}
    DisjointSet(int size){
      p.resize(size);
      sizes.resize(size, 1);
      for(int i=0 ; i<size ; ++i) makeSet(i);
    }
    ~DisjointSet(){}

    void makeSet(int x){
      p[x] = x;
    }

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

    void unite(int x, int y){
      x = findSet(x);
      y = findSet(y);

      if(x != y){
        if(sizes[x] < sizes[y]) swap(x, y);
        sizes[x] += sizes[y];
        sizes[y] = 0;//
        p[y] = x;
      }

      return;
    }

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

    int size(int x){
      return sizes[findSet(x)];
    }
};

class Edge {
public:
  int s, t;
  double w;

  // Edge(int sorce, int targer, double weight){
  //   s = sorce;
  //   t = targer;
  //   w = weight;
  // }

  bool operator <(const Edge& e) const{
    return w < e.w;
  }
};

class Graph{
public:
  int vn;
  vector<Edge> edges;

  int kruskal(){
    sort(edges.begin(), edges.end());

    //DisjointSet ds = new DisjointSet(vn);
    DisjointSet ds(vn);

    int minL = 0;

    for(int i=0 ; i<edges.size() ; ++i){
      Edge& e = edges[i];

      if(!ds.same(e.s, e.t)){
        minL += e.w;
        ds.unite(e.s, e.t);
      }

    }//---- end of for ----
    return minL;
  }//---- end of kruskal ----

};

int main(){
  Graph g;
  int en;

  cin >> g.vn >> en;
  for(int i=0 ; i<en ; ++i){
    Edge e;
    cin >> e.s >> e.t >> e.w;
    g.edges.push_back(e);
  }

  cout << g.kruskal() << endl;

  return 0;
}



Measured memory_bytes: 5040
/*
ID: 
TASK: Triangular Relationship
LANG: C++                 
*/
#define usingfile1
#include <iostream>
#include <cstdio>
int file_reopen(){
	freopen("task.in","r",stdin);
	freopen("task.out","w",stdout);
}
using namespace std;
typedef long long ll;
void main_program(){
	int n,k;
	cin>>n>>k;
	ll a,b,ans;
	a=n/k;
	if(k&1)b=0;
	else b=(n+k/2)/k;
	ans=a*a*a+b*b*b;
	printf("%lld\n",ans);
}
int main(){
	ios::sync_with_stdio(0);
	#ifdef usingfile
	file_reopen();
	main_program();
	fclose(stdin);fclose(stdout);
	#else
	main_program();
	#endif
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e18;
const ll inf=1e18;
const double eps=1e-8;
const double pi=acos(-1);

int a[102030],b[102030];

int main(){
    TB
    int aa,bb,m;
    cin>>aa>>bb>>m;
    fdd(1,aa+1) cin>>a[i];
    fdd(1,bb+1) cin>>b[i];
    int sum=1e9,flog=0;
    while(m--){
        int x,y,c;
        cin>>x>>y>>c;
        if(a[x]+b[y]-c<sum-flog){
            flog=c;sum=a[x]+b[y];//deg(sum)
        }
    }
    sort(a+1,a+aa+1);
    sort(b+1,b+1+bb);
    if(sum-flog>a[1]+b[1]){
        sum=a[1]+b[1];flog=0;
    }
    cout<<sum-flog<<'\n';
    return 0;
}



Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


int main(int argc, char const *argv[]) {
    int a,b,c;
    cin>>a>>b>>c;
    int res = min(c, a+b+1) + b;
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
k = gets.to_i

# 1, 2, 3, 4, 5, 6, 7, 8, 9,
# 10, 11, 12,
# 21, 22, 23,
# ...
# 87, 88, 89,
# 98, 99
# 100, 101,
# 110, 111, 112,
# 121, 122, 123,
# ...

queue = [[1], [2], [3], [4], [5], [6], [7], [8], [9]]
target = nil
k.times do
  target = queue.shift
  last = target[-1]
  case last
  when 0
    add2 = target.clone.push(last)
    add3 = target.clone.push(last + 1)
    queue.push(add2)
    queue.push(add3)
  when 9
    add1 = target.clone.push(last-1)
    add2 = target.clone.push(last)
    queue.push(add1)
    queue.push(add2)
  else
    add1 = target.clone.push(last-1)
    add2 = target.clone.push(last)
    add3 = target.clone.push(last + 1)
    queue.push(add1)
    queue.push(add2)
    queue.push(add3)
  end
end
puts target.join


Measured memory_bytes: 68732
def solve(string):
    ins = string.split("\n")
    h, w = map(int, ins[0].split(" "))
    a = [list(map(lambda x: int(x) % 2 == 1, _i.strip().split(" "))) for _i in ins[1:]]
    move = []
    for i in range(h):
        for j in range(w):
            if not a[i][j]:
                continue
            if j < w - 1:
                a[i][j + 1] ^= True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
            elif i < h - 1:
                a[i + 1][j] ^= True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
    move.insert(0, str(len(move)))
    return "\n".join(move)


if __name__ == '__main__':
    line = input().strip()
    h, w = map(int, line.split(" "))
    ins = [input() for _ in range(h)]
    ins.insert(0, line)
    print(solve("\n".join(ins)))


Measured memory_bytes: 17712
#include <bits/stdc++.h>
#define FOR_IMPL(i,b,e) for (common_type_t <decltype (b), decltype(e)> i = (b), i ## _end = (e); i < i ## _end; ++ i)
#define FOR(...) FOR_IMPL(__VA_ARGS__)
#define ALL(x)   begin (x), end (x)
using namespace std;
using ll = int64_t;

auto lunlun_gen ()
{
  vector <ll> res = {0};
  auto ite = back_inserter (res);
  auto impl = [&] (auto self, ll now, int keta)
  {
    if (keta > 10) return;
    * ite ++ = now;
    int z = now % 10;
    FOR (i, max (0, z - 1), min (9, z + 1) + 1)
    {
      self (self, now * 10 + i, keta + 1);
    }
  };
  FOR (i, 1, 10) impl (impl, i, 1);
  sort (ALL (res));
  return res;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  auto lunlun = lunlun_gen ();
  size_t k;
  cin >> k;
  cout << lunlun[k] << endl;
}

Measured memory_bytes: 3444
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int x;
	cin >> x;
	cout << (1 - x) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <unordered_set>

using namespace std;

int main(){
 string s;
  cin >> s;
  
  unordered_set<char> chars;
  
  for(auto ch : s){
   	chars.insert(ch); 
  }
  
  if(chars.size() == 2) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long S, h, m, s;
    scanf("%ld", &S);
    h = S / 3600;
    S = S - h * 3600;
    m = S / 60;
    S = S - m * 60;
    s = S;
    printf("%ld:%ld:%ld\n", h, m, s);
}



Measured memory_bytes: 2080
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[7]= {1,3,5,7,8,10,12};
    int b[4]= {4,6,9,11};
    int c[1]= {2};
    int x,y,i,m,n;
    while(~scanf("%d %d",&x,&y))
    {
        for(i=0; i<7; i++)
        {
            if(x==a[i])
                m=1;
            if(y==a[i])
                n=1;
        }
        for(i=0; i<4; i++)
        {
            if(x==b[i])
                m=2;
            if(y==b[i])
                n=2;
        }
        if(x==c[0])
            m=3;
        if(y==c[0])
            n=3;
        if(m==n)
        {
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    a, b, k = [int(x) for x in input().split()]
    if k > (a + b):
        a = 0
        b = 0
    elif k > a:
        b = b - (k - a)
        a = 0
    else:
        a -= k

    print(a, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
n,m=map(int,input().split())
edges=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=[int(x) for x in input().split()]
    edges[a].append(b)
    edges[b].append(a)

from collections import deque

def bfs(u): #点uからの最短距離
    memo=[0]*(n+1)
    queue=deque([u])
    d=[None]*(n+1)
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in edges[v]:
            if d[i] is None:
                d[i]=d[v]+1
                queue.append(i)
                memo[i]=v
    return d,memo
d,memo=bfs(1)
print("Yes")
for i in range(2,n+1):
    print(memo[i])


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cout.precision(20);               \
	cout << fixed;
#define pb push_back
#define endl "\n"
#define all(a) a.begin(), a.end()
#define N 500009
#define M 1000009
#define mod 1000000007
int powi(int a,int b){if (b == 0)return 1;int see = powi(a, b / 2);see *= see;see %= mod;if (b % 2)see *= a;see %= mod;return see;}

int n,k;

void pre(){
}

int32_t main()
{
	IOS;
	pre();
	cin>>n;
	pair<int,int> a[N];
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].first;
		a[i].second = i+1;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		cout<<a[i].second<<" ";
	}

	
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=1000;
int main()
{
    char str[1000];
    int flag=0;
    scanf("%s",str);
    for(int i=0;i<strlen(str);i+=2){
        if(str[i]=='L'){
            flag=1;
        }
    }
    for(int i=1;i<strlen(str);i+=2){
        if(str[i]=='R'){
            flag=1;
        }
    }
    if(!flag){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e8;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
/*
long long arr[N],n;
bool IsCover(long long d){
    long long lastcover=-1,used=0;
    for(int i=0;i<n;i++){
        if(arr[i]>lastcover){
        lastcover=arr[i]+(2*d);
        used++;
        }

    }
    return used<=3;
}
long long PS(){
    long long hi=1e5,lo=0,mid;
    while(hi-lo > 0){
        mid=(lo+hi)/2;
        if(IsCover(mid))hi=mid;
        else lo=mid+1;
    }
    return lo;
}
*/
int arr[N];
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]==',')
        s[i]=' ';
    }
    cout<<s<<endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int m = 0, ans = 0;
    for(int x : a){
        m += x;
    }
    if((m*10 / n) % 10 >= 5)m = m / n + 1;
    else m = m / n;
    for(int x : a){
        ans += pow(x - m, 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628