akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	// "sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

// sort 済み配列からとりあえず一致した要素のindexを返す
func BinarySearch(list []int, key int, compare func(int, int) int) int {
	// func
	// lhs > rhs -> positive
	// lhs < rhs -> negative
	return BinarySearchProc(list, 0, len(list) -1, key, compare)
}

func BinarySearchProc(list []int, begin int, end int, key int, compare func(int, int) int) int {
	cur := (end - begin) / 2 + begin
	// fmt.Printf("b:%d, c: %d, e:%d\n", begin, cur, end)
	cmp := compare(key, list[cur])
	if cmp == 0 {
		return cur
	// to left
	}
	// range check
	if cur == end || end < begin {
		return -1
	}
	// to left
	if 0 < cmp {
		return BinarySearchProc(list, cur + 1, end, key, compare)
	// to right
	} else {
		return BinarySearchProc(list, begin, cur - 1, key, compare)
	}
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}


func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)

	list := make([]int, n)
	lines, _ := ReadLongLines(1)

	elements := strings.Split(lines[0], " ")
	for i := range elements{
		x, _ := strconv.Atoi(elements[i])
		list[i] = x
	}

	var q int
	fmt.Scanf("%d", &q)
	lines, _ = ReadLongLines(1)

	args := strings.Split(lines[0], " ")
	for j := range args {
		x, _ := strconv.Atoi(args[j])
		res := BinarySearch(list, x, func(lhs, rhs int) int {
			if lhs == rhs {
				return 0
			} else if lhs > rhs {
				// fmt.Printf("%d %d +\n", lhs, rhs)
				return 1
			} else {
				// fmt.Printf("%d %d -\n", lhs, rhs)
				return -1
			}
		})

		if res == -1 {
			con.Println("0")
			return
		}
	}
	con.Println("1")
	
}


Measured memory_bytes: 12880
#include <stdio.h>
int main(void){
  int a;
  scanf("%d",&a);
  if(a<1200){
    printf("ABC");
  }else if(a>=1200,a<2800){
      printf("ARC");
  }else if(a>=2800){
        printf("AGC");
  }
  return 0;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] tmpArray = br.readLine().split(" ");
		int[] numbers = new int[n];
		
		for(int i = 0; i < n;i++){
			numbers[i] = Integer.parseInt(tmpArray[i]);
		}
		
		System.out.println(solve(numbers));
	}
	
	static int solve(int[] numbers){
		int n = numbers.length;
		
		int bestNum = -1;
		for(int i = 0; i < n - 1; i++){
			for(int j = i + 1; j < n; j++){
				int tmp = numbers[i]*numbers[j];
				
				if(increasing(tmp) && bestNum < tmp){
					bestNum = tmp;
				}
			}
		}
		
		return bestNum;
	}
	
	static boolean increasing(int n){
		char[] num = Integer.toString(n).toCharArray();
		
		for(int i = 1; i < num.length; i++){
			if(num[i] != num[i - 1] + 1){
				return false;
			}
		}
		
		return true;
	}

}

Measured memory_bytes: 58968
#include <cstdio>
#include <vector>
using namespace std;
int n;
int arr[3005];
bool parity[3005];
vector<int> al[3005];

bool dfs(int i){
    bool win=parity[i];
    
    for (auto &it:al[i]){
        if (arr[it]>=arr[i]) continue;
        
        parity[it]=parity[i]^true;
        if (parity[i]) win&=dfs(it);
        else win|=dfs(it);
    }
    
    return win;
}

int main(){
    scanf("%d",&n);
    for (int x=1;x<=n;x++) scanf("%d",&arr[x]);
    
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }
    
    for (int x=1;x<=n;x++){
        parity[x]=false;
        if (dfs(x)) printf("%d ",x);
    }
}

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

int main(){
  int A,B,C,X,Y,cost1,cost2,cost3;
  cin >> A >> B >> C >> X >> Y;
  
  cost1=A*X+B*Y;
  cost2=2*C*max(X,Y);
  if(X<=Y){
    cost3=2*C*X+B*(Y-X);
  }
  else{
    cost3=2*C*Y+A*(X-Y);
  }
  cout << min({cost1,cost2,cost3}) << endl;
} 

Measured memory_bytes: 3628
/*
 * 
 * 
         _Likhon_
 *
 * 
 */ 
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned short int a,cnt1,cnt2,res=0;
    cin>>a;
    cnt1 = a*1;
    cnt2 = a*a+cnt1;
    res = (a*a*a) + cnt2;
    cout<<res<<"\n";
    return 0;
}






Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    ll n;
    ll ans = LLINF;
    cin >> n;

    for(ll i = 1;i*i <= n;i++){
        if(n % i == 0){
            if( i + n/i - 2 < ans){
                ans = i + n/i - 2;
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<int, int>;

bool check(const vector<int>& A, int m) {
  vector<P> ps;
  for (int i = 1; i < A.size(); i++) {
    if (A[i - 1] < A[i]) {
      continue;
    }
    while (!ps.empty() && A[i] < ps.back().fst) {
      ps.pop_back();
    }
    if (ps.empty()) {
      ps.emplace_back(A[i], 2);
      continue;
    }
    int y = A[i];
    for (; y > 0; y--) {
      if (ps.empty() || ps.back().fst < y) {
        ps.emplace_back(y, 2);
        break;
      }
      if (ps.back().fst == y && ps.back().snd < m) {
        ++ps.back().snd;
        break;
      }
      ps.pop_back();
    }
    if (y <= 0) return false;
  }
  return true;
}

int main() {
  int N;
  while (cin >> N) {
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    bool up = true;
    for (int i = 1; i < N; i++) up &= A[i - 1] < A[i];
    if (up) {
      cout << 1 << endl;
      continue;
    }
    int ng = 1, ok = 200010;
    while (ok - ng > 1) {
      int m = (ng + ok) / 2;
      if (check(A, m)) {
        ok = m;
      } else {
        ng = m;
      }
    }
    cout << ok << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdbool.h>

int main(){
    int i, j, n;
    char mark;
    char marks[4]={'S', 'H', 'C', 'D'};
    int num;
    bool cards[4][13]={false};

    scanf("%d ", &n);
    for(i=0;i<n;i++){
        scanf("%c %d ", &mark, &num);
        for(j=0;j<4;j++){
            if(mark==marks[j]){
                cards[j][num-1]=true;
                break;
            }
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(!cards[i][j]){
                printf("%c %d\n", marks[i], j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2048
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int ans = sc.nextInt();
                for (int i = 0; i < N - 1; i++) {
                        ans = gcd(ans, sc.nextInt());
                }
                for (int i = 1; i <= ans; i++) {
                        if (ans % i == 0) {
                                System.out.println(i);
                        }
                }
        }

        public static int gcd(int a, int b) {
                if (a < b) {
                        return gcd(b, a);
                }
                if (b == 0) {
                        return a;
                }
                return gcd(b, a%b);
        }
}

Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V up(n), down(n);
	rep(i, n) {
		cin >> up[i];
	}
	rep(i, n) {
		cin >> down[i];
	}
	int ans = 0;
	int sum = 0;
	rep(i, n) {
		sum += up[i];
		int tmp = 0;
		REP(j, i, n) {
			tmp += down[j];
		}
		chmax(ans, sum + tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 55;

int n, m;
int s[maxN];
char c[maxN];

int digitCnt(int x){
    int cnt = 0;

    if(x == 0){
        return 1;
    }

    while(x){
        cnt++;
        x /= 10;
    }

    return cnt;
}

string toNum(int i){
    if(i == 0){
        return "0";
    }

    string s = "";

    while(i){
        s += (char)((i % 10) + '0');
        i /= 10;
    }

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

    return s;
}

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

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }

    for(int i = 0; i < 1000; i++){
        if(digitCnt(i) == n){
            string num = toNum(i);

            num = ' ' + num;

            bool flag = true;
            for(int i = 0; i < m; i++){
                if(num[s[i]] != c[i]){
                    flag = false;
                    break;
                }
            }

            if(flag){
                cout << i << '\n';
                return 0;
            }
        }
    }

    cout << "-1\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  ll N; cin>>N;
  
  ll ans=N;
  
  ll x=sqrt(N);
  
  for(ll i=x; i>0; i--){
    if(N%i==0){
      cout<<i+(N/i)-2<<endl;
      break;
    }
  }
    
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int tate,yoko;
    int menseki,syuu;
    scanf("%d%d\n",&tate,&yoko);
    menseki=tate*yoko;
    syuu=2*(tate+yoko);
    printf("%d %d\n",menseki,syuu);
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct in {
    int n; in() {} in(int n_) : n(n_){}
    template <class T> operator T() { T ret; cin >> ret; return ret; }
    template <class T> operator vector<T>() { vector<T> ret(n); for (int i = 0; i < n; i++) cin >> ret[i]; return ret; }
};
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jan 18 21:00:12 JST 2020
 **/

signed main() {
    Int n = in(), K = in(), S = in();
    vector<Int> a(n);
    REP(i, K) a[i] = S;
    REP(i, K, n) a[i] = S == (Int)1e9 ? 1 : (S + 1);
    for (Int x : a) cout << x << " ";
    cout << endl;
}


Measured memory_bytes: 2176
k,x=map(int, input().split())

result=''

for i in reversed(range(k)):
  result+=str(x-i) + ' ' 

for j in range(1, k):
  if j==k-1:
    result+=str(x+j)
  else:
    result+=str(x+j) + ' ' 
  
print(result)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){

    int x[10000];
    int i=0;
    int j;
    
    while(1){
        i++;
        scanf("%d",&x[i]);
        
        if(x[i]==0){
            break;
        }
    }
    
    for(j=1;j<i;j++){
        printf("Case %d: %d\n",j,x[j]);
    }
    return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)



signed main(){
	IOS();
	int N, Q;
	cin >> N >> Q;
	vector<int>c(N);
	cin >> c;
	REP(i, N) c[i]--;
	vector<int>l(Q), r(Q);
	REP(i, Q) {
		cin >> l[i] >> r[i];
		--l[i];
	}

	const int sq = 1000;
	vector<int>idx(Q);
	iota(ALL(idx), 0ll);
	sort(ALL(idx), [&](int a, int b) {
		if(l[a] / sq != l[b] / sq) return l[a] < l[b];
		else return r[a] < r[b];
	});

	vector<int>cnt(N);
	int sum = 0;
	auto add = [&](int x) {
		if(cnt[c[x]] == 0) ++sum;
		++cnt[c[x]];
	};
	auto del = [&](int x) {
		if(cnt[c[x]] == 1) --sum;
		--cnt[c[x]];
	};
	int nl = 0, nr = 0;
	vector<int>ans(Q);
	for(auto i: idx) {
		while(nl > l[i]) {
			--nl;
			add(nl);
		}
		while(nr < r[i]) {
			add(nr);
			++nr;
		}
		while(nl < l[i]) {
			del(nl);
			++nl;
		}
		while(nr > r[i]) {
			--nr;
			del(nr);
		}
		ans[i] = sum;
	}
	for(auto e: ans) out(e);
}

Measured memory_bytes: 27164
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	vector<int> v1(26, 0), v2(26, 0);
	for(int i = 0; i < s.length(); i++) {
		v1[s[i] - 'a']++;
		v2[t[i] - 'a']++;
	}
	for(int i = 0; i < s.length(); i++) {
		if(v1[s[i] - 'a'] != v2[t[i] - 'a']) {
			cout << "No";
			exit(0);
		}
	}
	cout << "Yes";
	return 0;
}


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

using ll = long long;

int main() {
    int n, x, y;
    cin >> n >> x >> y;

    int ans[200005] = {0};
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            ans[min(j-i, abs(x-i) + abs(y-j) + 1)]++;
        }
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<P>p;
vector<int> G[10010];
vector<int>c;
bool visited[10010];
bool leaf[10010];
void dfs(int n) {
	int cnt = 0;
	visited[n] = true;
	for (auto x : G[n]) {
		cnt++;
	}
	p.push_back(make_pair(cnt, n));
	for (auto x : G[n]) {
		if (!visited[x]) {
			dfs(x);
		}
	}
}
int ans[10010];
int res = 0;
void dfs2(int n) {
	visited[n] = true;
	for (auto x : G[n]) {
		if (!visited[x]) {
			res += min(ans[n], ans[x]);
			dfs2(x);
		}
	}
}
set<int>rem;
vector<int>v;
void dfs3(int n) {
	visited[n] = true;
	bool found = 0;
	for (auto x : G[n]) {
		if (!visited[x]) {
			if (!leaf[x]) {
				found = true;
				dfs3(x);
			}
		}
	}
	if (!found) {
		v.pb(n);
		leaf[n] = true;
		auto itr = rem.erase(n);
	}
}
signed main() {
	int N;
	cin >> N;
	REP(i, N-1) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	REP(i, N) {
		rem.insert(i);
		int C; cin >> C;
		c.pb(C);
	}
	VSORT(c);
	m0(visited);
	bool ok = false;
	while (rem.size()!=0) {
		m0(visited);
		auto itr = rem.begin();
		dfs3(*itr);
	}
	REP(i, N) {
		ans[v[i]] = c[i];
	}

	//VSORT(c);// VREVERSE(c);
	//m0(visited);
	//dfs(0);
	//VSORT(p);
	//REP(i, N) {
	//	ans[p[i].second] = c[i];
	//}
	m0(visited);
	dfs2(0);
	print(res);
	REP(i, N) {
		pe(ans[i]);
	}cout << endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int INF = 1e9 + 7;

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

char s[60][60];

int main() {
	int h, w;
	cin >> h >> w;

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (s[i][j] == '#') {

				if (s[i][j - 1] == '#' || s[i + 1][j] == '#' || s[i][j + 1] == '#' || s[i - 1][j] == '#') {
					continue;
				}

				else {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#define mp make_pair
using namespace std;
int a[101000];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 2 * n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n * 2);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i * 2];
    }
    printf("%d\n", ans);
}


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

void solve(long long N, long long M, vector<string> A, vector<string> B){
	for (int x = 0; x <= N - M; x++) {
    for (int y = 0; y <= N - M; y++) {
      bool matched = true;
      for (int j = 0; j < M; j++) {
        for (int k = 0; k < M; k++) {
          if (A[x+j][y+k] != B[j][k]) {
            matched = false;
            break;
          }
        }
        if (!matched) break;
      }

      if (matched) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	vector<string> A(N-1+1);
	scanf("%lld",&M);
	vector<string> B(M-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> A[i];
	}
	for(int i = 0 ; i <= M-1 ; i++){
		cin >> B[i];
	}
	solve(N, M, A, B);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
/*Aをmod2の配列Bに変換 Bのうち1と0の個数をカウント
*/


int main() {
 string s;
 cin >> s;
 int ans = 200;

 for(char c = 'a' ; c<='z' ; c++){
    //bool flag1 = false
    int count = 0;//各文字の操作回数
    string t = s;
     while(t.size() > 0){
        
         bool flag2 = true;//sが全て単一の文字cからなるか
         for(int i =0;i<t.size();i++){
            if(t[i] != c){
              flag2 = false;
              break;
            }
         }
         if(flag2){
             //flag1 =true;
              ans = min(ans,count);
              break;
          }

       for(int i = 0;i<t.size()-1;i++){
           if(t[i] == c || t[i+1] == c) t[i] = c;
         }
         t.pop_back();
         count++;//各文字の操作回数
     }
 }
  cout << ans << endl;
 }

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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const ll MOD = 1000000007;

int main() {
  int N, M; cin >> N >> M;
  vector<bool> ng(N+1,false);
  rep(i,M) {int a; cin >> a; ng[a]=true; }

  ll r[N+1] = {};
  r[0] = 1; r[1] = (ng[1]) ? 0 : 1;
  for(int i=2; i<=N; i++) {
    if (ng[i]) continue;
    r[i] = (r[i-1]+r[i-2]) % MOD;
  }
  cout << r[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
int diff(string a,string b){
	int res=0;
	for(int i=0;i<a.length();i++){
		if(a[i]!=b[i])res++;
	}
	return res;	
}
int main(){
	FASTIO
	int ans=9999;
	string s,t;
	cin>>s;
	cin>>t;
	for(int i=0;i<=s.length()-t.length();i++){
		string temp=s.substr(i,t.length());
		ans=min(ans,diff(temp,t));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3628
A = [0] * 5 
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())

B = [0] * 5
for i in range(5):
	B[i] = ((A[i] - 1) // 10 + 1) * 10

print(sum(B) - max(b - a for a, b in zip(A, B)))

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i = 1; i <= N; i++) cin >> A[i];
    int cnt = 0;

    for(int i = 1; i <= N; i++){
        if ( (i % 2 == 1) && (A[i] % 2 == 1) ){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int m[10],i,b[3]={0};
	for(i=0;i<10;i++)
	{
		scanf("%d",&m[i]);
		if(m[i] > b[0])
		{
			b[2]=b[1];
			b[1]=b[0];
			b[0]=m[i];
		}
		else if(m[i] > b[1])
		{
			b[2]=b[1];
			b[1]=m[i];
		}
		else if(m[i] > b[2])
			b[2]=m[i];
	}
	printf("%d\n%d\n%d\n",b[0],b[1],b[2]);
	return 0;
}

Measured memory_bytes: 0
import sys 
n=int(input())
l=list(map(int,input().split()))
if n==0:
    if l[0]==1:
        print(1)
    else:
        print(-1)
    sys.exit()
w=[1-l[0]]*(n+1)
for i in range(1,n+1):
    w[i]=w[i-1]*2-l[i]
if min(w)<0:
    print(-1)
    sys.exit()
for i in range(1,n+1):
    w[i]+=l[i]
for i in range(n-1,-1,-1):
    l[i]+=l[i+1]
ans=0 
for i in range(n+1):
    ans+=min(l[i],w[i])
#print(w,w1)
print(ans)

Measured memory_bytes: 675888
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

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

    map<char, long long> T;
    for(long long i = 0; i < s.size(); i++){
        if(T.find(s[i]) == T.end()) T[s[i]] = 1;
        else T[s[i]]++;
    }

    map<char, long long>::iterator it;
    long long ans = 0;
    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= 2) ans += it->second*(it->second-1)/2;
    }

    cout << 1+s.size()*(s.size()-1)/2 - ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll fac[1100000];
ll finv[1100000];
ll inv[1100000];

void compre() {
  fac[0] = fac[1] = 1LL;
  finv[0] = finv[1] = 1LL;
  inv[1] = 1LL;
  for(ll i = 2LL; i<1000000; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

long long modcom(long long n, long long k) {
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
  ll x, y;
  cin >> x >> y;
  if((x+y)%3!=0 || x>2*y || y>2*x) {
    cout << 0 << endl;
    return 0;
  }
  ll n = (x+y)/3;
  ll k = 2*n-x;
  compre();
  cout << modcom(n,k) << endl;
  return 0;
}

Measured memory_bytes: 25216
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,c,d=intLine()
    println("$(c-d+b) $(d+c-a) $(a-d+b) $(b+c-a)")
end
main()

Measured memory_bytes: 175172
while True:
    a, op, b = input().split()
    if op == "?":
        break
    a, b = int(a), int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        print("error")


Measured memory_bytes: 5600
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}


int main() {
	ll N;
	cin >> N;
	ll ans = 0;

	vi A(N);
	vi B(N-1);

	rep(i, N-1) {
		cin >> B[i];
	}

	A[0] = B[0];
	A[N - 1] = B[N - 2];
	repa(i, 1, N-1) {
		A[i] = min(B[i - 1], B[i]);
	}
	rep(i, N) {
		ans += A[i];
	}

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

Measured memory_bytes: 256
def main():
    N = int(input())
    T, A = list(map(int, input().split()))
    H = list(map(int, input().split()))
    m = []
    for h in H:
        m.append(abs(A - (T - h * 0.006)))
    print(m.index(min(m)) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define X first
#define Y second
#define R real()
#define I imag()
#define pb push_back
#define eb emplace_back

#define rep(X,Y) for(int (X) = 0; (X) < (Y) ; ++(X))
#define rrep(i,j) for(int i=(j)-1;i>=0;i--)
#define all(X) (X).begin(),(X).end()
#define reps(i,j,k) for(inti=(j); i <= (k); ++(i))
#define sz size()
#define in(i,j,k) ((i) >= (j) && (i) <= (k))
#define out(i,j,k) ((i)<= (j) && (i) >= (k))
using namespace std;

template<class S,class T>ostream& operator<<(ostream &os,const pair<S,T> &t){return os<<"("<<t.X<<","<<t.Y<<")";}

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<int> ci;

bool f;
int w,h;
int ind[61][10];
int id;
string input[61];

ci dfs(int x,int y){
	if(ind[y][x]>=0)return ci(0,0);
	id++;
	int block=0,gp=0;
	char c = input[y][x];
	queue<pii> q;
	q.push(pii(x,y));
	vector<pii> t;
	int left=100, right=-1;
	while(!q.empty()){
		int px,py;
		tie(px,py) = q.front();
		q.pop();
		if(ind[py][px]>=0)continue;
		block++;
		gp+=px*2+1;
		//cout << id << " " << px << endl;
		if(py==0 || ind[py-1][px]>=0 && ind[py-1][px]!=id){
			left = min(left,px);
			right = max(right,px+1);
		}
		if(py+1<h&&input[py+1][px] != c && input[py+1][px]!='.'){
			t.eb(px,py+1);
			
		}
		ind[py][px] = id;
		rep(i,4){
			int cx = dx[i] + px;
			int cy = dy[i] + py;
			if(!in(cx,0,w-1)||!in(cy,0,h-1)) continue;
			if(input[cy][cx]!=c || ind[cy][cx] == id){
				continue;
			}

			q.push(pii(cx,cy));
		}
	}
	gp/=2;
	ci ret = ci(block,gp);
	rep(i,t.sz){
		ret += dfs(t[i].X,t[i].Y);
	}

	block = ret.R;
	gp = ret.I;
	//cout << c << " " << pii(x,y) << pii(block,gp) << (left * block >= gp || right * block <= gp) << endl;
	if( left * block >= gp || right * block <= gp) f = false;

	return ret;
}

int main(){
    while(cin >> w >> h&&w){
		fill_n(ind[0],sizeof(ind)/sizeof(**ind),-1);
        rrep(i,h) cin >> input[i];
		id = 0;
		
		f = true;

		rep(i,w){
			if(input[0][i]!='.'){
				dfs(i,0);
				break;
			}
		}
		/*
		rrep(i,h){
			rep(j,w) printf("%2d",ind[i][j]>=0?ind[i][j]:0);
			cout << endl;
		}
		*/
        cout << (f?"STABLE":"UNSTABLE") << endl;

    }
    return 0;
}

Measured memory_bytes: 1240
h,w,a,b = map(int, input().split())
for i in range(h):
  ans = []
  for j in range(w):
    if i <= b-1:
      if j <=a-1:
        ans.append(0)
      else:
        ans.append(1)
    else:
      if j <=a-1:
        ans.append(1)
      else:
        ans.append(0)
  for x in range(w):
    print(ans[x], end='')
  print()

Measured memory_bytes: 6900
n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]
point = [0]*n
ans = ["No"]*n
for i in range(q):
    point[a[i]-1] += 1
for i in range(n):
    if (point[i]+k > q):
        ans[i] = "Yes"
print(*ans, sep='\n')

Measured memory_bytes: 11016
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int n,k,ans=0;
   cin>>n>>k;
   vector<int> h(n);
   rep(i,n){
     cin>>h.at(i);
     if(h.at(i)>=k)ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
struct UnionFind{
vector<int> par,depth;
UnionFind(int n){
par.resize(n); depth.resize(n);
for(int i=0; i<n; i++){
par[i]=i;
depth[i]=0;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
return par[x]=find(par[x]);
}
}
bool same(int x, int y){
return find(x)==find(y);
}
void unite(int x, int y){
x=find(x); y=find(y);
if(x==y) return;
if(depth[x]<depth[y]) swap(x,y);
if(depth[x]==depth[y]) depth[x]++;
par[y]=x;
}
};
struct Side{
    int from,to,cost;
    bool operator<(const Side &s) const {
        return (cost<s.cost);
    }
};
int main(){
    int n;cin >> n;
    vector<l_l> xx(n),yy(n);
    for(ll i=0; i<n; i++){
        ll x,y;cin >> x >> y;
        xx[i]=l_l(x,i);
        yy[i]=l_l(y,i);
    }
    sort(xx.begin(),xx.end());
    sort(yy.begin(),yy.end());
    ll m=2*n-2;
    vector<Side> s(m);
    for(ll i=0; i<n-1; i++){
        s[i].from=xx[i].second;
        s[i].to=xx[i+1].second;
        s[i].cost=xx[i+1].first-xx[i].first;
    }
    for(ll i=0; i<n-1; i++){
        s[n-1+i].from=yy[i].second;
        s[n-1+i].to=yy[i+1].second;
        s[n-1+i].cost=yy[i+1].first-yy[i].first;
    }
    sort(s.begin(),s.end());
    UnionFind uf(n);
    ll min_cost=0;
    for(ll i=0; i<m; i++){
        if(!uf.same(s[i].from,s[i].to)){
            uf.unite(s[i].from,s[i].to);
            min_cost+=s[i].cost;
        }
    }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;

  int cnt = 0;  
  int cnt_A = 0;
  int cnt_B = 0;
  int common = 0;
  for(int i = 0;i < N;i++){
    string s;
    cin >> s;
    for(int i = 0;i < s.size() - 1;i++){
      if(s[i] == 'A' && s[i+1] == 'B')cnt++;
    }
    
    if(s[0] == 'B' && s[s.size()-1] == 'A')common++;
    else if(s[0] == 'B')cnt_B++;
    else if(s[s.size()-1] == 'A')cnt_A++;
  }

  
  if(common == 0){
    cout << cnt + min(cnt_A,cnt_B) << endl;
  }else{
    int ans = common-1;
    if(cnt_A > 0)ans += 1,cnt_A--;
    if(cnt_B > 0)ans += 1,cnt_B--;

    cout << ans + min(cnt_A,cnt_B) + cnt << endl; 
  } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if (s.back()=='s') cout<<s<<"es";
	else cout<<s<<"s"<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int util(int A){
	while(A%10!=0)
		A++;
	return A;
}
int main(){
	vector<int>A(5);
	for(int i=0;i<5;i++)
		cin>>A[i];
	int res=INT_MAX;
	// int count=0;
	for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
			if(i!=j){
				for(int k=0;k<5;k++){
					if(k!=j && k!=i){
						for(int l=0;l<5;l++){
							if(l!=k && l!=j && l!=i){
								for(int m=0;m<5;m++){
									if(m!=l && m!=k && m!=j && m!=i){
										int temp=util(A[i])+util(A[j])+util(A[k])+util(A[l])+A[m];
										res=min(res,temp);
										// count++;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> g(m);
  rep(i,m) cin >> g[i].first >> g[i].second;
  int l,r;
  l = 0; r = 100005;
  rep(i,m) {
    l = max(g[i].first,l);
    r = min(g[i].second,r);
  }
  if(l > r) {
    cout << 0 << endl;
    return 0;
  }
  cout << r-l+1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string a, b;
  cin >> a >> b;
  if(a[0] == b[2] && a[2] == b[0] && a[1] == b[1]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!


ll _distance(vll &arr,ll hom){
    ll sum=0;
    for(int i=0;i<arr.size();i++){
        sum+=(hom-arr[i])*(hom-arr[i]);
    }
    return sum;
}
void solve(){
    ll n;
    cin>>n;
    
    ll l=101,r=-1;
    vector<ll> arr(n,0);
    if(n==0){cout<<"0";return ;}
    
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        l=min(l,arr[i]);
        r=max(r,arr[i]);
        
    }
    // cout<<l<<" "<<r<<endl;
    ll ans=INT_MAX;
    for(ll k=l;k<=r;k++){
        ll d=_distance(arr,k);
        ans=min(ans,d);
    }
    cout<<ans<<endl;
}
 
int main() {
    faster;
    int t=1;
    // cin>>t;
    
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int X, N;
    cin >> X >> N;
    vector<int> a(102, 0);
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        a[p] = 1;
    }
    pii ans(INF, -1);
    for (int i = 0; i < 102; i++) {
        if (a[i] == 1) continue;
        int dif = abs(X - i);
        ans = min(ans, pii(dif, i));
    }
    cout << ans.second << '\n';
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main() {
  ll x;
  cin >> x;

  ll p, r;
  p = x / 11;
  r = x % 11;

  if (r == 0) {
    cout << 2 * p << endl;
  } else if (r <= 6) {
    cout << 2 * p + 1 << endl;
  } else {
    cout << 2 * p + 2 << endl;
  }

  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll n;
    ll a, b;
    cin >> n >> a >> b;

    ll x = n / (a + b);
    ll ans = x * a;
    ll y = n % (a + b);
    if (y <= a)
        ans += y;
    else {
        ans += a;
    }

    cout << ans << endl;
}

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

using namespace std;
#define pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "yes" << endl 
#define no cout << "no" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
        }
void solve(){ 
	   int a,b,i;
    cin >> a >> b;
    if(a>b){
       for(i=1; i<=a; i++)
         cout << b;
    }
    else{
       for(i=1; i<=b; i++)
         cout << a;
    }
         cout << endl;
}
    
    
int main(){
    booster;
    solve();
    _terminated;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 #include <math.h>
 #include <iostream>
 #include <iomanip>
 using namespace std;
 
 int main(){
    int N;
    string S;
    int i;
    char prepre='X';
    char pre='X';
    int ans = 0;

    cin >> N >> S;

    for (i=0; i<N; i++){
        if (prepre=='A' && pre=='B' && S[i]=='C')
            ans++;

            prepre = pre;
            pre = S[i];
        }
    if (prepre=='A' && pre=='B' && S[i]=='C')
        ans++;

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bool myComp(pair<double, string> a, pair<double, string> b) {
    if (a.first - b.first > EPS) return true;
    else if (a.first - b.first < -EPS) return false;
    else {
        if (a.second < b.second) return true;
        else return false;
    }
}

vector<pair<double, string>> solve(int N) {
    vector<pair<double, string>> crops;
    for (int i = 0; i < N; i++) {
        cin.ignore();
        string l;
        int p, a, b, c, d, e, f, s, m;
        getline(cin, l, ' ');
        cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
        int totalPrice = f*s*m - p;
        int totalTime = a+b+c+(d+e)*m;
        double pricePerTime = (double)totalPrice/totalTime;
        crops.push_back({pricePerTime, l});
    }
    sort(crops.begin(), crops.end(), myComp);
    return crops;
}

int main(void) {
    int N;
    vector<vector<pair<double, string>>> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &vec : ans) {
        for (auto &p : vec) {
            cout << p.second << endl;
        }
        cout << "#" << endl;
    }
}   


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

using namespace std;

int main () {
    int a, b; cin >> a >> b;
    if (a == 1 && b == 2 || a == 2 && b == 1) cout << 3;
    else if (a == 1 && b == 3 || a == 3 && b == 1) cout << 2;
    else cout << 1;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(L);
    LL(R);

    if(R-L >= 2020){
        cout << 0 << endl;
        return 0;
    } else {
        ll ans = 2018;
        for(ll i = L; i <=R; ++i){
            for(ll j = i+1; j <= R; ++j){
                ll tmp = i*j%2019;
                ans = min(ans,tmp);
            }
        }
        cout << ans << endl;
    }

}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

double dist(double s, double t){ return sqrt(s*s + t*t );}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI x(n), y(n), sq(n);
	rep(i, n) cin >>x[i] >>y[i];
	iota(all(sq), 0);
	double sm = 0; int cnt= 0;
	do {
		rep(i,n-1){
			sm += dist(x[sq[i]]-x[sq[i+1]], y[sq[i]]-y[sq[i+1]]);
		}
		cnt++;
	} while ( next_permutation(all(sq)) );

	printf("%.14f\n", sm/cnt);
	return 0;
}


Measured memory_bytes: 256