akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, a, b, c, d; cin>>n>>a>>b>>c>>d;
    string s; cin>>s;
    --a, --b, --c, --d;
    if (c<d) {
        bool ok=true;
        for(int i=b; i+1<d; ++i) if (s[i]=='#' and s[i+1]=='#') ok=false;
        for(int i=a; i+1<c; ++i) if (s[i]=='#' and s[i+1]=='#') ok=false;
        cout<<(ok ? "Yes" : "No")<<endl;
    }
    else {
        bool ok=false;
        for(int i=b-1; i+2<=d+1; ++i)
            if (s[i]=='.' and s[i+1]=='.' and s[i+2]=='.') ok=true;
        for(int i=a; i+1<c; ++i) if (s[i]=='#' and s[i+1]=='#') ok=false;
        for(int i=b; i+1<d; ++i) if (s[i]=='#' and s[i+1]=='#') ok=false;
        cout<<(ok ? "Yes" : "No")<<endl;
    }
}


Measured memory_bytes: 640
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let _ = read::<i32>();
    let aa = readv::<i32>();
    let bb = readv::<i32>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<i32>, Vec<i32>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len() as i32;
    aa.push(x);
    let mut nums: HashMap<i32, i32> = aa.iter()
        .fold(HashMap::new(), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mp = aa.iter().collect::<BTreeSet<&i32>>().into_iter().enumerate()
        .map(|(a, b)| (b, a as i32)).collect::<HashMap<&i32, i32>>();
    let a2 = aa.iter().map(|a| mp[a]).collect::<Vec<i32>>();
    let b2 = bb.iter().map(|b| mp[b]).collect::<Vec<i32>>();
    let mut dests = b2.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (*acc.entry(b).or_insert(Vec::new())).push(a as i32); acc });
    let mut q = std::iter::once(n).collect::<VecDeque<i32>>();
    let mut rems = (0..n + 1).collect::<HashSet<i32>>();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(mp, dests)", (mp, &dests));
    #[cfg(local)] println!("{}: {:?}", "(a2, b2)", (&a2, &b2));
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) {
                continue;
            }
            let s_num = a2[s_idx as usize];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 26904
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for _ in range(N)]

s = [[] for _ in range(4)]
w0 = wv[0][0]
for w, v in wv :
    s[w-w0].append(v)
for i in range(4) :
    s[i].sort(reverse=True)
    s[i] = [0] + s[i]
    for j in range(1, len(s[i])) :
        s[i][j] += s[i][j-1]

M = 0
for i0 in range(len(s[0])) :
    for i1 in range(len(s[1])) :
        for i2 in range(len(s[2])) :
            for i3 in range(len(s[3])) :
                if i0*w0+i1*(w0+1)+i2*(w0+2)+i3*(w0+3) <= W :
                    M = max(M, s[0][i0]+s[1][i1]+s[2][i2]+s[3][i3])
                    
print(M)

Measured memory_bytes: 41072
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N;
    ll A[200000],B[200000];
    vector<pair<ll,int>> vec;
    cin>>N;
    rep(i,N) {
        cin>>A[i]>>B[i];
        vec.push_back(make_pair(B[i],i));
    }
    sort(vec.begin(),vec.end());
    ll sum=0;
    rep(i,N){
        sum+=A[vec[i].second];
        if(sum>vec[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N; cin>>N;
  vector<ll> A(N);
  rep(i,N)cin>>A.at(i);
  sort(begin(A),end(A));
  ll res = 0;
  ll n = 0;
  ll minA = INF;
  rep(i,N){
    if(A.at(i)<=0)n++;
    minA = min(minA,(ll)fabs(A.at(i)));
    res += fabs(A.at(i));
  }
   
  if(n%2==1)res -= 2*minA;
  cout<<res<<endl;
}


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

#define err(A) cout << #A << " = " << (A) << endl

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

int main()
{
    int n;
    cin >> n;
    int a[n + 10];
    int mod = 998244353;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    if (a[0] != 0)
    {
        cout << 0;
        return 0;
    }
    sort(a, a + n);
    if (a[0] != 0)
    {
        cout << 0;
        return 0;
    }
    int zero_count = 0;
    for (int i = 0 ; i < n ; i ++)
    {
        if (a[i] < 0)
        {
            cout << 0;
            return 0;
        }
        if (a[i] == 0)
        {
            if (zero_count == 1)
            {
                cout << 0;
                return 0;
            }
            zero_count ++;
        }
    }
    int last_height = 0;
    int count = 1;
    int new_count = 1;
    long long ans = 1;
    for (int i = 1; i < n; i++)
    {
        if (a[i] - 1 == last_height)
        {
            last_height = a[i];
            count = new_count;
            new_count = 1;
        } else if (a[i] == last_height)
        {
            new_count ++;
        } else{
            ans = 0;
            break;
        }
        ans = (long long)(ans * (long long)count % mod) % mod;
    }
    cout << ans % mod;
}


Measured memory_bytes: 640
//
//  main.cpp
//  ac
//
//  Created by 胡天翼 on 2017/2/21.
//  Copyright © 2017年 胡天翼. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#define read freopen("in.txt","r",stdin)
#define maxlongint 2147483647
typedef  long long LL;
typedef  unsigned long long ULL;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fori for(int i=1;i<=n;i++)
#define forj for(int j=1;j<=m;j++)
#define fork for(int k=1;k<=n;k++)
#define FOR(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define DREP(i,a,b) for(int i=a;i>=b;i--)
#define DOWN(i,n) for(int i=n;i>=1;i--)
#define enter cout<<endl;
#define in push_back
#define out pop_back
#define sqr(x) ((x)*(x))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define offcin ios::sync_with_stdio(false)
#define s(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define sd(x,y) scanf("%d%d",&x,&y)
#define sch(s) scanf("%s",s)
#define fillfalse(v) memset(v,false,sizeof(v))
#define filltrue(v) memset(v,true,sizeof(v))
#define f0(a)    memset(a,0,sizeof(a))
#define Fillplus(a)    memset(a,-1,sizeof(a))
#define lowbit(x) x&(-x)
using namespace std;
const int maxn = 1e5+5;
const int N=1e6+5;
const int mod=1e9+7;
int i,x,y,z,n,m,k,t,l,r,mid,cc,ans,tmp,cnt;
string s;
int a[maxn];
int main()
{
    cin>>n>>m>>k;
    fori s(a[i]);
    sort(a+1,a+n+1);
    int y=0;
    int sum=1;
    int b=a[1];
    fori
    {
           if(y>=m||a[i]-b>k) {sum++; b=a[i]; y=1;}
           else y++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
rank = [0 for _ in range(n)]
is_root = [True for _ in range(n)]

for _ in range(m):
	x, y = map(int, input().split())
	edges[x-1].append(y-1)
	rank[y-1] += 1
	is_root[y-1] = False

dp = [0 for _ in range(n)]
def dfs(x):
	global dp
	for c in edges[x]:
		rank[c] -= 1
		dp[c] = max(dp[c], dp[x]+1)
		if rank[c] == 0:
			dfs(c)
	return

for i in range(n):
	if is_root[i]:
		dfs(i)

#print(dp)
print(max(dp))


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

using namespace std;
int r,g,b,n,ans;
int main()
{
    cin>>r>>g>>b>>n;
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int temp = i*r + j*g;
            if(temp<=n && (n-temp)%b==0) ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string neoword,word,x,y;
    std::cin >> word;
    int counter = 0;
    for(char z : word){
        char neoz = toupper(z);
        neoword.push_back(neoz);
    }
    while(std::cin >> x){
        if(x == "END_OF_TEXT")break;
        y.clear();
        for(char a :x){
            char b = toupper(a);
            y.push_back(b);
        }
        if(y == neoword){
            counter++;
        }
    }
        std::cout <<counter<<std::endl;
    return 0;
}

Measured memory_bytes: 3156
s=input()
sets=set(s)
ans=[]
for i in sets:
    cnt=0
    temp=list(s)
    if len(set(temp))==1:
        ans.append(0)
    else:
        while(True):
            temp2=[]
            for j in range(len(temp)-1):
                if temp[j]==i or temp[j+1]==i:
                    temp2.append(i)
                else:
                    temp2.append(None)
            cnt+=1
            if len(set(temp2))==1:
                ans.append(cnt)
                break
            temp=temp2
print(min(ans))

Measured memory_bytes: 3064
h, w, k = map(int, input().split())

memo = {}

def po(x, y):
    if y == h + 1:
        if x == k - 1:
            return 1
        else:
            return 0

    if (x, y) in memo:
        return memo[(x, y)]

    ans = 0
    for i in range(1 << w - 1):
        valid = True
        for j in range(w - 2):
            if i & (1 << j) and i & (1 << j + 1):
                valid = False
                break
        if valid:
            nx = x
            if x > 0 and i & (1 << x - 1):
                nx = x - 1
            if i & (1 << x):
                nx = x + 1
            ans += po(nx, y + 1)
            ans %= 1000000007
    
    memo[(x, y)] = ans
    return ans

print(po(0, 1))

Measured memory_bytes: 3188
// rust input macro: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
  input!{
    n: i32, m: i32,
    a: [i32; m]
  };
  
  let mut ans = n;
  for i in a.iter() {
    ans -= i; 
  }
  if ans < 0 {
    ans = -1; 
  }
  println!("{}", ans);
}


Measured memory_bytes: 2184
import sys

n = int(input())
lines = sys.stdin.readlines()
aaa = list(map(int, lines[:n]))
bbb = list(map(int, lines[n:]))
coords = [(a, 0) for a in aaa] + [(b, 1) for b in bbb]
coords.sort()
MOD = 10 ** 9 + 7

remain_type = 0
remain_count = 0
ans = 1
for x, t in coords:
    if remain_type == t:
        remain_count += 1
        continue
    if remain_count == 0:
        remain_type = t
        remain_count = 1
        continue
    ans = ans * remain_count % MOD
    remain_count -= 1
print(ans)


Measured memory_bytes: 42356
import sys
input = sys.stdin.readline


n = int(input())
A = [int(i) for i in input().split()]
_sum = 0
_xor = 0
l, r = 0, 0
ans = 0
while l < n:
    while r < n and _sum + A[r] == _xor ^ A[r]:
        _sum += A[r]
        _xor ^= A[r]
        r += 1
    ans += r - l
    _sum -= A[l]
    _xor ^= A[l]
    if l == r:
        r += 1
    l += 1

print(ans)


Measured memory_bytes: 100468
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int binary_digit_one_num[100]; //i桁目の値が1の個数;


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

    vector<long long> a(N);

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

    //10進数を2進数にして、各桁で1があるところを記録
    for(int i=0; i<N; ++i){
        long long NUM = a[i];
        int keta = 0;
        int cnt = 0;

        while( NUM > 0 ){
            if(NUM&1){
                keta = cnt;
                binary_digit_one_num[keta]++;
            } 
            NUM >>= 1;
            cnt++;
        }
    }

    int max_keta = 0;
    int cnt = 0;
    long long k = K;
    while(k > 0){
        if(k & 1) max_keta = cnt;
        k >>= 1;
        cnt++;
    }

    long long candidate = 0;
    for(int keta=max_keta; keta>=0; --keta){
        if( N %2 == 0){
            // 0が多いので1を選択
            if( binary_digit_one_num[keta] < N/2 ){
                long long tmp = candidate + pow(2, keta);
                if(tmp <= K){
                    candidate = tmp;
                }
            }
        }else{
            // 0が多いので1を選択
            if( binary_digit_one_num[keta] < N/2 + 1 ){
                long long tmp = candidate + pow(2, keta);
                if(tmp <= K){
                    candidate = tmp;
                }
            }
        }
    }

    long long ans = 0;
    for(int i=0; i<N; ++i){
        ans += candidate ^ a[i];
    }

    cout << ans << endl;
}

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

int main(void){

  int i, j;
  int N, L;
  scanf("%d%d", &N, &L);
  
  char str[N][L+1];
  for(i=0; i<N; i++){
    scanf("%s", str[i]);
  }
 
  char anstr[N*L+1];
  char tmp[L+1];
  for(i=0; i<N; i++){
    for(j=i; j<N; j++){
      if(strcmp(str[i], str[j]) > 0){
        strcpy(tmp, str[i]);
        strcpy(str[i], str[j]);
        strcpy(str[j], tmp);
      }
    }
  }
  strcpy(anstr, str[0]);
  for(i=1; i<N; i++){
    strcat(anstr, str[i]);
  }

  printf("%s\n", anstr);

  return 0;
}


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

int main() {
  int N,T;cin>>N>>T;
  int m=9999;
  for(int i=0; i<N; i++){
    int c,t;cin>>c>>t;
    if(T>=t)m=min(c,m);
  }
  if(m==9999)cout<<"TLE"<<endl;
  else cout<<m<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	int H, i, j, k, N, S, W;
	int x[110], y[110], a[110];
	char lect[110][110];
	scanf("%d%d%d", &W, &H, &N);
	for (i=0;i<N;i++) {
		scanf("%d%d%d", &x[i], &y[i], &a[i]);
	}

	memset(lect, 0, 110*110);
	for (i=0;i<N;i++) {
		switch (a[i]) {
			case 1:
				for (j=0;j<x[i];j++) for (k=0;k<H;k++) {
					lect[j][k] = 1;
				}
				break;
			case 2:
				for (j=x[i];j<W;j++) for (k=0;k<H;k++) {
					lect[j][k] = 1;
				}
				break;
			case 3:
				for (j=0;j<W;j++) for (k=0;k<y[i];k++) {
					lect[j][k] = 1;
				}
				break;
			case 4:
				for (j=0;j<W;j++) for (k=y[i];k<H;k++) {
					lect[j][k] = 1;
				}
				break;
			default:
				break;
		}
	}
	S = 0;
	for (j=0;j<W;j++) for (k=0;k<H;k++) {
		if (lect[j][k] == 0) S++;
	}
	printf("%d\n", S);

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
//constexpr long long MOD = 1000000007LL;
constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    string S; cin >> S;
    vector<vector<int>> G(N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector<bool> check(N);
    vector<ll> A(N),B(N);
    queue<int> que;
    rep(v,N) {
        check[v] = 1;
        for (auto u : G[v]) {
            if (S[u]=='A') A[v]++;
            else B[v]++;
        }
        if (A[v]*B[v]==0) {
            check[v] = 0;
            que.emplace(v);
        }
    }

    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (S[v]=='A') A[nv]--;
            else B[nv]--;
            if (A[nv]*B[nv]==0) {
                if (check[nv]) {
                    check[nv] = 0;
                    que.emplace(nv);
                }
            }
        }
    }

    rep(i,N) {
        if (check[i]) {
            cout << "Yes" << ln;
            return 0;
        }
    }

    cout << "No" << ln;
    return 0;
}

Measured memory_bytes: 13648
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define db double
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int n, m;
int a[100010];

int main()
{
	n = read();
	m = read();
	vi ji, ou;
	rep(i, 1, m)
	{
		a[i] = read();
		if (a[i] & 1) ji.pb(a[i]);
		else ou.pb(a[i]);
	}
	if (n == 1) printf("1\n1\n1\n");
	else
	{
		int jis = ji.size();
		int osz = ou.size();
		if (jis > 2) puts("Impossible");
		else
		{
			if (jis == 0)
			{
				rep(i, 0, osz - 2) printf("%d ", ou[i]);
				printf("%d\n", ou[osz - 1]);
				printf("%d\n", osz + 1);
				printf("1 ");
				rep(i, 0, osz - 2) printf("%d ", ou[i]);
				printf("%d\n", ou[osz - 1] - 1);
			}
			else if (jis == 1)
			{
				if (osz == 0)
				{
					printf("%d\n", ji[0]);
					printf("2\n");
					printf("%d %d\n", ji[0] - 1, 1);
				}
				else
				{
					printf("%d ", ji[0]);
					rep(i, 0, osz - 2) printf("%d ", ou[i]);
					printf("%d\n", ou[osz - 1]);
					printf("%d\n", m);
					printf("%d ", ji[0] + 1);
					rep(i, 0, osz - 2) printf("%d ", ou[i]);
					printf("%d\n", ou[osz - 1] - 1);
				}
			}
			else if (jis == 2)
			{
				if (osz == 0)
				{
					if (ji[0] == 1 && ji[1] == 1) printf("1 1\n1\n2\n");
					else
					{
						sort(ji.begin(), ji.end());
						printf("%d %d\n", ji[0], ji[1]);
						printf("2\n");
						printf("%d %d\n", ji[0] + 1, ji[1] - 1);
					}
				}
				else
				{
					printf("%d ", ji[0]);
					rep(i, 0, osz - 1) printf("%d ", ou[i]);
					printf("%d\n", ji[1]);
					vi r;
					r.pb(ji[0] + 1);
					rep(i, 0, osz - 1) r.pb(ou[i]);
					if (ji[1] - 1) r.pb(ji[1] - 1);
					printf("%d\n", r.size());
					int sz = r.size();
					rep(i, 0, sz - 1)
						if (i == sz - 1) printf("%d\n", r[i]);
						else printf("%d ", r[i]);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())

amari = []

while True:
    if n >1 or n<0:
        amari.append(-(n%(-2)))
        n = (n-(-(n%(-2))))//(-2)
    else:
        amari.append(n)
        break

gyaku = amari[::-1]
print(*gyaku,sep="")

Measured memory_bytes: 9172
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int n,M;
	cin>>n>>M;
	vvi out;
	rep(i,n-1)out.pb({i+1,n});
	int m=n*(n-1)/2-n+1-M;
	if(m<0){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,n-1){
		loop(j,i+1,n-1)if(m)m--,out.pb({i+1,j+1});
	}
	if(m)cout<<-1<<endl;
	else{
		cout<<out.size()<<endl;
		rep(i,out.size())cout<<out[i][0]<<" "<<out[i][1]<<endl;
	}
}


Measured memory_bytes: 640
#include <iostream>
#define INF 2000000
#define MAX 100
#define WHITE 0
#define BLACK 1

using namespace std;

int n, d[MAX], color[MAX], w[MAX][MAX];

void prim(int r){
    int u;
    for(u = 0; u < n; u++){
        d[u] = INF;
        color[u] = WHITE;
    }
    d[r] = 0;

    while(1){
        int mincost = INF;
        for(int i = 0; i < n; i++){
            if(color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INF) break;
        
        color[u] = BLACK;

        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && w[u][v] < d[v]){
                d[v] = w[u][v];
            }
        }
    }
}

int main(){
    int i, j;
    cin >> n;
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            cin >> w[i][j];
            if(w[i][j] == -1) w[i][j] = INF;
        }
    }

    prim(0);

    int sum = 0;
    for(i = 0; i < n; i++){
        sum += d[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main(){
	int i,j,x,y;
	for(i=1;i<=3;i++){
		cin>>x>>y;
		a[x-1]++;	
		a[y-1]++;	
	}
	for(i=0;i<=3;i++){
		if(a[i]>2){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int A[2017];
bool e[2017][2017];
bool b[2017];

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

vector<int> mer(const vector<int> &S , const vector<int> &T){
	vector<int> V;
	int i = 0 , j = 0;
	while(i != (int)S.size() || j != (int)T.size()){
		if(i == (int)S.size()) V.PB(T[j++]);
		else if(j == (int)T.size()) V.PB(S[i++]);
		else V.PB(A[S[i]] > A[T[j]] ? S[i++] : T[j++]);
	}
	return V;
}

vector<int> func(int k){
	vector<int> V;
	b[k] = 1;
	repp(i,0,N){
		if(!e[k][i] || b[i]) continue;
		V = mer(V,func(i));
	}
	V.insert(V.begin(),k);
	return V;
}

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , A + i);
	}
	sort(A,A+N);
	repp(i,0,N){
		repp(j,i+1,N){
			if(gcd(A[i],A[j]) > 1){
				e[i][j] = e[j][i] = 1;
			}
		}
	}
	vector<int> V;
	repp(i,0,N){
		if(b[i]) continue;
		V = mer(V,func(i));
	}
	repp(i,0,N){
		printf("%d%c" , A[V[i]] , i+1==N ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 4608
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  1005
vector<pair<ll,ll> >adj[N][N];
ll deg[N][N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,i,j,k;
        cin>>n;

        for(i=1;i<=n;i++){
            vector<pair<ll,ll> >v;
            for(j=0;j<n-1;j++){
                ll x=i,y;
                cin>>y;
                if(x>y)swap(x,y);
                v.pb(mp(x,y));
            }
            for(j=0;j<v.size()-1;j++){
                adj[v[j].F][v[j].S].pb((v[j+1]));
                deg[v[j+1].F][v[j+1].S]++;
            }
        }

    
        queue< pair< pair<ll,ll>,ll> >q;
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                if(deg[i][j]==0)q.push(mp(mp(i,j),1));
            }
        }

        if(q.empty())return cout<<-1,0;
        ll lmax=-1;
        while(!q.empty()){
            auto it=q.front();
            q.pop();
            ll x=it.F.F,y=it.F.S,lev=it.S;
            lmax=max(lmax,lev);

            for(auto i:adj[x][y]){
                deg[i.F][i.S]--;
                if(deg[i.F][i.S]==0){
                    q.push(mp(mp(i.F,i.S),lev+1));
                }
            }
        }

        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                if(deg[i][j]>0)return cout<<-1,0;
            }
        }

        cout<<lmax;

    }
    return 0;
}   

Measured memory_bytes: 57088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	int n;
	int a[100010];
	cin >> n;
	rep(i, n) cin >> a[i];
	if(n==1) cout << '1' << endl;
	else
	{
		int now, tmp=0, cnt=-1, bun=1;
		while(tmp<n-1)
		{
			now=tmp;
			repp(i, now, n-1)
			{	
				tmp++;
				if(a[i+1]!=a[i]) break;
			}
			if(a[tmp-1]<a[tmp]) cnt=1;
			now=tmp;
			repp(i, now, n-1)
			{
				tmp++;
				if(cnt*a[i]>cnt*a[i+1])
				{
					bun++, cnt=-1;
					break;
				}
			}
		}
		cout << bun << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, n) {
		if (i != 0 && a[i] == a[i - 1]) {

		}
		else {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
String str;
int xy[][]=new int[14][14];
int count=0,max=0;
while((str=input.readLine())!=null)
	{
	String str_ary[]=str.split(",");
	int x,y,size;
	x=Integer.parseInt(str_ary[0]);
	y=Integer.parseInt(str_ary[1]);
	size=Integer.parseInt(str_ary[2]);
	if(size==1)
	{
	xy[x+2][y+2]++;
	xy[x-1+2][y+2]++;
	xy[x+1+2][y+2]++;
	xy[x+2][y+1+2]++;
	xy[x+2][y-1+2]++;
	}
	if(size==2)
	{
	xy[x+2][y+2]++;
	xy[x-1+2][y+2]++;
	xy[x+1+2][y+2]++;
	xy[x+2][y+1+2]++;
	xy[x+2][y-1+2]++;
	xy[x+1+2][y+1]++;
	xy[x-1+2][y-1+2]++;
	xy[x-1+2][y+1+2]++;
	xy[x+1+2][y+1+2]++;
	}
	if(size==3)
	{
	xy[x+2][y+2]++;
	xy[x-1+2][y+2]++;
	xy[x+1+2][y+2]++;
	xy[x+2][y+1+2]++;
	xy[x+2][y-1+2]++;
	xy[x+1+2][y+1+2]++;
	xy[x+1+2][y-1+2]++;
	xy[x-1+2][y+1+2]++;
	xy[x-1+2][y-1+2]++;
	xy[x+2+2][y+2]++;
	xy[x+2][y+2+2]++;
	xy[x-2+2][y+2]++;	
	xy[x+2][y-2+2]++;
	}	
}
for(int i=2;i<12;i++)
	{
		for(int j=2;j<12;j++)
		{
		if(xy[i][j]==0)		
		count++;
		if(max<xy[i][j])max=xy[i][j];			
		}
	}	
System.out.println(count);
System.out.println(max);
}
}

Measured memory_bytes: 16924
use std::io;
use std::collections::BTreeSet;

fn main() {
    let n = read_values::<usize>()[0];
    let d = (0..n).map(|_| read_values::<usize>()[0]).collect::<BTreeSet<_>>();
    println!("{}", d.len());
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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 const INF = 1001001001;


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

ll a,b,k;
cin >> a >> b >> k;

rep(i,k) {
    if(i & 1) {
        if(b & 1) {
            --b;
        }
        a += b/2;
        b /= 2;
    } else {
        if(a & 1) {
            --a;
        }
        b += a/2;
        a /= 2;
    }
}
cout << a << ' ' << b << endl;
return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
 
int b[210000];
int c[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	bool fi=true;
	for(int i=0;i<(a+1)/2;i++){
		if(!fi)printf(" ");
		fi=false;
		printf("%d",b[a-1-i*2]);
	}
	for(int i=0;i<a-(a+1)/2;i++){
		if(!fi)printf(" ");
		fi=false;
		printf("%d",b[(a)%2+i*2]);
	}
	printf("\n");
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    if(a[i]%2 == 0){
      if(a[i]%3 != 0 && a[i]%5 != 0){
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const char* solve() {
    string s, hi = "hi";
    cin >> s;
    if (s.size() % 2 == 1) return "No";
    for (int i = 0; i < (int)s.size(); i++) if (s[i] != hi[i % 2]) return "No";
    return "Yes";
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m,v,p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll NG=-1,OK=n-1;
  ll M;
  while(abs(OK-NG)!=1){
    M=(OK+NG)/2;
    bool ok=false;
    bool sub=true;
    ll s=0;
    //a[M]で条件満たすの?
    FOR(i,M+1,n-p+1){
      if(a[M]+m-a[i]>=0){
        s +=(a[M]+m-a[i]);
      }
      else
        sub=false;
    }
    if((M+1)*m+s>=m*(v-p+1)){
      ok=true;
    }
    //にぶたん
    if(ok&&sub){
      OK=M;
    }
    else{
      NG=M;
    }
  }
  cout << n-OK << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	int A, P; cin >> A >> P;
    cout << (A*3+P)/2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007;
int main(){
    int N, ans, a, b;
    long long K, count=0;
    cin >> N >> K;
    vector<pair<int, int>> vec;
    rep(i, N) {
        cin >> a >> b;
        vec.push_back(pair<int, int>(a, b));
    }
    sort(vec.begin(), vec.end());
    rep(i, N){
        count = count + vec[i].second;
        if (count >= K){
            ans = vec[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
#define in(A, n)                                                                                                       \
    rep(i, n) {                                                                                                        \
        cin >> f;                                                                                                      \
        A.push_back(f);                                                                                                \
    }

void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vector<vl> g(MAX_N);
vl A, B;
void input() { cin >> S; }
void solve() {
    if(S.back() == 's')
        print(S + "es");
    else
        print(S + "s");
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

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

int main(){

	int x, n, t, h, a[101][101], a2[101][101];
	int r[101] = {0};

	cin >> n;
	
	for(int i=0; i<=n; i++){
		a2[0][i] = 0;
		a2[i][0] = 0;
	}
	
	for(int i=1; i<=n; i++){
		t = 0;
		for(int j=1; j<=n; j++){
			cin >> x;
			a[i][j] = x;
			t += x;
			r[j] += t;
			a2[i][j] = r[j];
		}
	}
	
	h = -10000;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=i; k<=n; k++){
				for(int l=j; l<=n; l++){
					t = a2[k][l] - a2[i-1][l] - a2[k][j-1] + a2[i-1][j-1]; 
					if(t > h) h = t;
				}
			}
		}
	}

	cout << h << endl;

	return 0;

}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N];

int main(){
    int n = in();
    for(int i = 1; i <= n; i++){
        inp[i] = in();
    }
    int ans = 0;
    for(int i = 1; i < n; i++){
        if(inp[i] == i){
            swap(inp[i], inp[i + 1]);
            ans++;
        }
    }
    if(inp[n] == n) ans++;
    printf("%d\n", ans);
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
struct edge {
  ll to, cost;
};

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

int main() {
  int N; cin >> N;
  vector<int> ans;
  for(int i = 2; i <= 55555; ++i) {
    if(IsPrime(i)) {
      if(i % 5 == 4) ans.push_back(i);
    }
    if(ans.size() == N) break;
  }
  REP(i, ans.size()) {
    cout << ans[i];
    if(i != ans.size() - 1) cout << " ";
  }
  cout << endl;
}

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

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

    int n = x;

    int fx = 0;

    while(x > 0)
    {
        fx += x % 10;
        x /= 10;
    }

    if((n % fx) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 20;
int a[maxn][maxn], c[maxn];
bool b[maxn];
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    int tmp[maxn];
    int ans = 1e9;
    for (int i = 1; i <= (1 << n) - 1; i++)
    {
        int flag = 1;
        memset(tmp, 0, sizeof tmp);
        int id = i;
        int j = 0;
        int ans_tmp = 0;
        while (id)
        {
            if (id & 1)
            {
                for (int k = 0; k < m; k++)
                {
                    tmp[k] += a[j][k];
                }
                ans_tmp += c[j];
            }
            id >>= 1;
            j++;
        }
        for (int k = 0; k < m; k++)
        {
            if (tmp[k] < x)
                flag = 0;
        }
        if (flag)
            ans = min(ans, ans_tmp);
    }
    if (ans == 1e9)
        ans = -1;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int d,g;
int res=1001;
int p[10];
int c[10];
void dfs(int depth,int num,int score,int flag)
{
  if(depth==d)
  {
    //cout<<"dfs"<<score<<" "<<num<<endl;
    int tnum=0,tscore=score;
    for(int i=d-1;i>=0;i--)
    {
      if(g<=tscore)break;
      if((flag>>i)%2)continue;
      if(g-tscore<=(p[i]-1)*(i+1)*100)
      {
        tnum+=(g-tscore-1)/((i+1)*100)+1;
        tscore+=((g-tscore-1)/((i+1)*100)+1)*(i+1)*100;
        break;
      }
      else
      {
        tnum+=p[i]-1;
        tscore+=(p[i]-1)*(i+1)*100;
      }

    }
    if(g>tscore)return;
    res=min(res,num+tnum);return;
  }
  dfs(depth+1,num+p[depth],score+p[depth]*(depth+1)*100+c[depth],flag+(1<<depth));
  dfs(depth+1,num,score,flag);
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>d>>g;
  rep(i,d)cin>>p[i]>>c[i];
  dfs(0,0,0,0);
  cout<<res;





  return 0;

}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int> > mtr(n, vector<int>(m));
    vector<int> vec(m);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> mtr[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> vec[i];
    }

    for(int i=0; i<n; i++){
        int ret=0;
        for(int j=0; j<m; j++){
            ret += mtr[i][j]*vec[j];
        }
        cout << ret << endl;
    }
    return 0;
}



Measured memory_bytes: 3172