akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	printf("%s", (a+b==c||b+c==a||c+a==b)?"Yes":"No");
}

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

ll dp[110][15][1010];

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

	int n, s;
	while(cin >> n >> s, n | s) {
		memset(dp, 0, sizeof dp);
		dp[0][0][0] = 1;
		for(int i = 0; i <= 100; i++) {
			for(int j = 0; j <= n; j++) {
				for(int k = 0; k <= s; k++) {
					if(dp[i][j][k] == 0) continue;
					dp[i + 1][j][k] += dp[i][j][k];
					if(k + i <= s) {
						dp[i + 1][j + 1][k + i] += dp[i][j][k];
					}
				}
			}
		}

		cout << dp[101][n][s] << endl;
	}


}

Measured memory_bytes: 16164
import java.util.Scanner;

/**
 * A - Remaining Balls
 * 文字列 S の書かれたボールが A 個、文字列 T の書かれたボールが B 個あります。
 * 高橋君は、文字列 U の書かれたボールを 1 個選んで捨てました。
 * 文字列 S,T の書かれたボールがそれぞれ何個残っているか求めてください。
 */
public class Main {

    public static void main( String[] args ) {

        // 入力値
        Scanner sc = new Scanner( System.in );
        String s = sc.next();   // ボールに書かれた文字列
        String t = sc.next();   // ボールに書かれた文字列
        int a = sc.nextInt();   // sと書かれたボールの数
        int b = sc.nextInt();   // tと書かれたボールの数
        String u = sc.next();   // 捨てるボールに書かれた文字列

        if( s.equals( u ) ) --a;
        else --b;

        System.out.println( a + " " + b );

        sc.close();
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1 && B == 2) cout << 3 << "\n";
  if (A == 1 && B == 3) cout << 2 << "\n";
  if (A == 2 && B == 1) cout << 3 << "\n";
  if (A == 2 && B == 3) cout << 1 << "\n";
  if (A == 3 && B == 1) cout << 2 << "\n";
  if (A == 3 && B == 2) cout << 1 << "\n";
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let  s : String = read!();
    let s = s.chars().collect::<Vec<char>>();
    let f = s.iter().position(|c| *c=='A').unwrap();
    let e = s.len() - s.iter().rev().position(|c| *c=='Z').unwrap();

    println!("{}", e-f);
}


Measured memory_bytes: 3124
def answer(n, a)
  count = 0
  n.times do |nn|
    next if a[nn] != nn + 1
    a[nn], a[nn + 1] = a[nn + 1], a[nn]
    count += 1
  end
  count
end

n = gets.to_i
a = gets.split.map(&:to_i)
puts answer(n, a)

Measured memory_bytes: 8068
import bisect
import collections
def f(n):
  return n.bit_length()
n=int(input())
A=[int(i) for i in input().split()]
D=dict(collections.Counter(A))
C=sorted(list(D.keys()))
ans=0
for i in range(len(C)):
  pair=2**f(C[-(i+1)])-C[-(i+1)]
  k=bisect.bisect_left(C,pair)
  if C[k]==pair:
    if k==len(C)-(i+1):
      ans+=D[pair]//2
      D[pair]%=2
    else:
      aa=min(D[pair],D[C[-(i+1)]])
      ans+=aa
      D[pair]-=aa
      D[C[-(i+1)]]-=aa
print(ans)

Measured memory_bytes: 39356
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
void solve(){
 
    string strs[] = { "SAFE", "SUSPICIOUS" };
 
    int h, w;
    cin >> h >> w;
 
    vector< string > screen( h );
    vector< int > maxx( 26, 0 );
    vector< int > maxy( 26, 0 );
    vector< int > minx( 26, w );
    vector< int > miny( 26, h );
 
    for( int i = 0; i < h; i++ )
        cin >> screen[ i ];
     
    bool fig = true;
 
    for( int x = 0; x < w; x++ )
        for( int y = 0; y < h; y++ )
            if( screen[y][x] != '.' ) {
                int i = screen[y][x] - 'A';
                maxx[i] = max( maxx[i], x );
                minx[i] = min( minx[i], x );
                maxy[i] = max( maxy[i], y );
                miny[i] = min( miny[i], y );
            }
 
 
    while( fig ) {
 
        fig = false;
 
        for( int x = 0; x < w; x++ ) {
            for( int y = 0; y < h; y++ ) {
 
                    char ch = screen[ y ][ x ];
                    if( ch == '.' || ch == '*' ) continue;
                    int i = ch - 'A';
 
                    bool fflg = true;
                    for( int tx = minx[i]; tx <= maxx[i] && fflg; tx ++ )
                        for( int ty = miny[i]; ty <= maxy[i] && fflg; ty ++ )
                            fflg &= ( screen[ ty ][ tx ] == ch || screen[ ty ][ tx ] == '*' );
                     
                    fig |= fflg;
                    if( !fflg ) continue;
 
                    for( int tx = minx[i]; tx <= maxx[i]; tx ++ )
                        for( int ty = miny[i]; ty <= maxy[i]; ty ++ ) 
                            screen[ ty ][ tx ] = '*';
 
                }
            }
        }
     
 
    bool b = false;
    for( int x = 0; x < w; x++ )
        for( int y = 0; y < h; y++ )
            b |= ( screen[ y ][ x ] != '.' && screen[ y ][ x ] != '*' );
    cout << strs[ b ] << endl;
 
}
 
int main( void ) {
    int n;
    cin >> n;
    for( int i = 0; i < n; i++ )
        solve();
    return 0;
}

Measured memory_bytes: 3172
mod = 10**9 + 7
n = int(input())
c = list(map(int,input().split()))
c.sort(reverse = True)
ans = 0
for i in range(n):
    ans += c[i]*(i+2) 
    ans %= mod
ans *= pow(4,n-1,mod)
ans %= mod
print(ans)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string S; cin >> S;
    int Q; cin >> Q;
    int rev = 0;

    string hs, bs; // 先頭に入る文字
    rep(i, Q) {
        int T; cin >> T;
        // cout << T << endl;
        if (T == 1) {
            // 反転
            rev ^= 1;
        } else {
            int F; string C; cin >> F >> C;
            // F = 1で先頭, 2で末尾にCを追加
            if (rev) {
                // 反転していれば、追加する場所を変更
                if (F == 1) {
                    F = 2;
                } else {
                    F = 1;
                }
            }

            // 追加
            if (F == 1) {
                // 逆向きに入る
                hs.append(C);
            } else {
                bs.append(C);
            }
        }
    }
    if (rev) {
        reverse(S.begin(), S.end());
        reverse(bs.begin(), bs.end());
        cout << (bs + S + hs) << endl;
    } else {
        reverse(hs.begin(), hs.end());
        cout << (hs + S + bs) << endl;
    }
    return 0;
    
}

Measured memory_bytes: 1348
import math
i = 0
k = 0
q = 0
while k == 0 :
    N = int(input())
    if N == 0 :
        k = k + 1
    else :
        S = list(map(float, input().split()))        
        while k ==0 and i < N :
            m = sum(S) / N
            q = q + ((S[i] - m)**2)
            i = i + 1
        print(math.sqrt(q / N))
        q = 0
        i = 0



Measured memory_bytes: 5776
import numpy as np

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = [0] * (N+1)
for a, b in zip(A, B):
    count[a] += 1
    count[b] += 1

for i in range(N+1):
    if count[i] > N:
        print('No')
        quit()

diff = 0
checked = set()
ida = 0
for i, b in enumerate(B):
    if b in checked:
        continue
    checked.add(b)
    while ida < N and A[ida] <= b:
        ida += 1
    diff = max(diff, ida - i)


idx = (np.arange(N) - diff) % N
print('Yes')
print(*np.array(B)[idx])

Measured memory_bytes: 66360
#include<bits/stdc++.h>
using namespace std;
string s,t,sol;
//int ind=INT_MAX;
int dp[3001][3001];
int solve(int a,int b){
	if(a==0 || b==0)
	return 0;
	if(dp[a][b]!=-1)
	return dp[a][b];
	int ans;
	if(s[a-1]==t[b-1]){
		ans=solve(a-1,b-1)+1;
	}
	else{
		ans=max(solve(a,b-1),solve(a-1,b));
	}
	dp[a][b]=ans;
	return ans;
}
int main(){
	cin>>s;
	cin>>t;
	//int ans;
	for(int i=0;i<=s.length();i++){
		for(int j=0;j<=t.length();j++){
			dp[i][j]=-1;
		}
	}
	solve(s.length(),t.length());
	int a=s.length();
	int b=t.length();
	sol.clear();
	int k=0;
	for(int i=a,j=b;i>=1 && j>=1;){
		if(s[i-1]==t[j-1]){
			//cout<<s[i-1]<<" ";
			sol+=s[i-1];
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1]){
				i--;
			}
			else
			j--;
		}
	}
	reverse(sol.begin(),sol.end());
	cout<<sol;
	//reverse(vect.begin(),vect.end());
	//for(int i=0;i,vect.size();i++)
	//cout<<vect[i].first;
	return 0;
}

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

int main() {
  long long a, b;
  cin >> a >> b;
  long long i = 1;
  while(true) {
    if (a * i / b > 0 && a * i % b == 0) {
      break;
    } else {
      i++;
    }
  }
  cout << a * i << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll sum(ll x) {
    ll temp = x * (x + 1) / 2;
    return temp % MOD;
}

int main(void) {
    ll N, K;
    vector<ll> A;
    ll prev = 0, next = 0;
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    rep(i, N) {
        rep(j, N) {
            if(A[i] > A[j]) {
                if(j > i) {
                    next++;
                    next %= MOD;
                }
                prev++;
                prev %= MOD;
            } 
        }
    }
    cout << (next * K % MOD + prev * sum(K - 1) % MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int MOD = 1000000007;
		
		// 計算
		long result = 0;
		Combination comb = new Combination(n);
		for(int i = 0; i <= min(k, n-1); i++){
		    long temp = 0;
		    temp += comb.combination(n, i);
		    temp %= MOD;
		    temp *= comb.combination(n-1, n-i-1);
		    temp %= MOD;
		    result += temp;
		    result %= MOD;
		}

		// 出力
		System.out.println(result);
	}
}

class Combination {
    static final int MOD = 1000000007;
    long[] fact;
    long[] invFact;
    long[] inv;
    
    public Combination (int n) {
        fact = new long[n+1];
        invFact = new long[n+1];
        inv = new long[n+1];
        fact[0] = 1;
        fact[1] = 1;
        invFact[0] = 1;
        invFact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n+1; i++) {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            invFact[i] = invFact[i - 1] * inv[i] % MOD;
        }
    }
    
    public long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) {
            return 0;
        }
        return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
    }
}


Measured memory_bytes: 27860
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  string s;
  cin>>s;
  if (s=="Sunny") cout << "Cloudy" << endl;
  else if(s=="Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int w , h , n ;
  cin >> w >> h >> n ;
  int x1 , x2 ,y1 , y2 ;
  x1 = 0;
  x2 = w;
  y1 = 0;
  y2 = h;
  for(int i = 0 ; i < n ; i++){
    int x , y , a;
    cin >> x >> y >> a;
    if( a == 1 && x1 < x ){
      x1 = x;
    }
    if( a== 2 && x2 > x){
      x2 = x;
    }
    if( a == 3 && y1 < y){
      y1 = y;
    }
    if( a == 4 && y2 > y){
      y2 = y;
    }
  }
  if( (x2 - x1) > 0 &&  (y2 - y1) > 0){
  cout << (x2 - x1) * (y2 - y1) << endl;
  }
  else
  {
    cout << 0 << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

ll a,b,c,d;
mint fact[2500000];


mint comb(ll x, ll y){
    return fact[x] / fact[y] / fact[x-y];
}

mint g(ll x, ll y){
    return comb(x+y+2,y+1) - mint(1);
}

int main(){
    cin >> a >> b >> c >> d;
    fact[0] = mint(1);
    for(int i=1;i<2500000;i++) fact[i] = mint(i) * fact[i-1];
    cout << g(c,d) - g(c,b-1) - g(a-1,d) + g(a-1,b-1) << endl;
    return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll l, r;
	cin >> l >> r;
	if(abs(r-l) >= 2019){
		cout << 0 << endl;
		return 0;
	}
	l %= 2019;
	r %= 2019;
	if(l >= r)r += 2019;
	ll ans = INF;
	for(int i = l; i <= r; ++i){
		for(int j = i + 1; j <= r; ++j){
			ans = min(ans, (i*j)%2019LL);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
import sys

N = int(input())

arr = []

arr.append(input())

for i in range(1,N):
    s = input()
    if s in arr:
        print("No")
        sys.exit()
    else:
        if arr[i-1][-1:] != s[0]:
            print("No")
            sys.exit()

        arr.append(s)

print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, q, op, x, y, res, p2[30], arb[2000002];
char ch;
string s;
inline void Build(int node, int st, int dr) {
    if (st == dr) {
        arb[node] = p2[s[st - 1] - 'a'];
        return;
    }
    int mid = (st + dr) / 2;
    Build(2 * node, st, mid);
    Build(2 * node + 1, mid + 1, dr);
    arb[node] = (arb[2 * node] | arb[2 * node + 1]);
}
inline void Update(int node, int st, int dr, int pos, int val) {
    if (st == dr) {
        arb[node] = val;
        return;
    }
    int mid = (st + dr) / 2;
    if (pos <= mid)
        Update(2 * node, st, mid, pos, val);
    else Update(2 * node + 1, mid + 1, dr, pos, val);
    arb[node] = (arb[2 * node] | arb[2 * node + 1]);
}
inline int Query(int node, int st, int dr, int l, int r) {
    if (l <= st && dr <= r)
        return arb[node];
    int mid = (st + dr) / 2, r1(0), r2(0);
    if (l <= mid)
        r1 = Query(2 * node, st, mid, l, r);
    if (mid < r)
        r2 = Query(2 * node + 1, mid + 1, dr, l, r);
    return (r1 | r2);
}
int main() {
    DAU
    p2[0] = 1;
    for (int i = 1; i < 30; ++i)
        p2[i] = p2[i - 1] * 2;
    cin >> n >> s >> q;
    Build(1, 1, n);
    for (int i = 1; i <= q; ++i) {
        cin >> op >> x;
        if (op == 1) {
            cin >> ch;
            Update(1, 1, n, x, p2[ch - 'a']);
        }
        else {
            cin >> y;
            cout << __builtin_popcount(Query(1, 1, n, x, y)) << '\n';
        }
    }
    PLEC
}


Measured memory_bytes: 7068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int		main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

int main()
{
	int S;
	scanf("%d", &S);
	char ans[4][16]{"AMBIGUOUS", "YYMM", "MMYY", "NA"};
	int index{};
	if (S / 100 == 0 || S / 100 >= 13)
		index++;
	if (S % 100 == 0 || S % 100 >= 13)
		index += 2;
	
	printf("%s\n", ans[index]);

	return 0;
}

Measured memory_bytes: 384
N, W = map(int, input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
for j in range(1, N+1):
        w, v = map(int, input().split())
        for k in range(1, W+1):
                if k < w:
                        dp[j][k] = dp[j-1][k]
                else:
                        dp[j][k] = max(dp[j-1][k-w]+v, dp[j-1][k])
print(dp[N][W])

Measured memory_bytes: 119916
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_V 10005
#define MAX_E 10000000
using namespace std;

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

int main(){
	int a, b;
	while(~scanf("%d%d", &a, &b)){
		int c = gcd(a, b);
		printf("%d %d\n", c, a * (b / c));
	}
	return 0;
}




Measured memory_bytes: 2612
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
vector<vector<ll>>adj(1e5 + 1);
vector<ll>used(1e5 + 1, 0), sub(1e5 + 1, 0);
void dfs(ll s, ll p)
{

    sub[s] = 1;
    for (auto v : adj[s])
    {
        if (v != p)
        {
            dfs(v, s);
            sub[s] += sub[v];
        }
    }
    return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key, l, r, n, m, t, k;
    ll a, b, c;
    ll t2, t3, t4, t1;
    ll x1, x2, y1, y2;
    string s;
    cin >> n;
    ll arr[n];
    ll ans = 0;
    for (i = 0; i < n; i++)
        cin >> arr[i];
    for (i = 1; i < (n); i++)
    {
        if (arr[i] < arr[i - 1])
        {
            ans += (arr[i - 1] - arr[i]);
            arr[i] = arr[i - 1];
        }

    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 8724
use std::io;

fn main() {
    let mut num = String::new();
    io::stdin().read_line(&mut num).unwrap();
    let num: i32 = num.trim().parse().unwrap();
    call(num);
}

fn call(n: i32) {
    for x in 1..n+1 {
        if x % 3 == 0 {
            print!(" {}", x);
            continue;
        }
        for y in (0u32..).map(|i| x / 10i32.pow(i)).take_while(|&y| y > 0) {
            if y % 10 == 3 {
                print!(" {}", x);
                break;
            }
        }
    }
    println!("");
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
 
#define f(i,a,b) for (int i = a; i < b; i++)
using vi = vector<int>;
#define pb push_back
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> m >> n;
	int a[n];
	f(i,0,n) cin>>a[i];
	int cnt = 0;
	f(i,0,n) cnt += a[i]&1;
	if (n == 1) {
		cout << a[0] << endl;
		if (a[0] == 1) cout << 1 << endl << 1 << endl;
		else cout << 2 << endl << a[0]-1 << " " << 1 << endl;
		return 0;
	}
	if (cnt>2) {
		cout << "Impossible" << endl;
		return 0;
	}
	f(i,0,n) if (a[i]&1) swap(a[i],a[0]);
	f(i,1,n) if (a[i]&1) swap(a[i],a[n-1]);
	vi ans;
	f(i,0,n) if (!i && a[i]-1) ans.pb(a[i]-1);
		else if (i) ans.pb(a[i] + (i==n-1));
	stringstream ss;
	f(i,0,n) ss << a[i] << " ";
	ss << endl << ans.size() << endl;
	for (int x : ans) ss << x << " ";
	cout << ss.str() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> sum(2100100,0);
int main() {
  int n,a[21],q,m;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int p=0;p<1<<n;p++){
    for(int b=0;b<n;b++) if(p&1<<b) sum[p]+=a[b];
  }
  sort(sum.begin(),sum.end());
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m;
    cout<<(find(sum.begin(),sum.end(),m)!=sum.end()?"yes":"no")<<endl;
  }
}


Measured memory_bytes: 10844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
const int SIZE_FACT = 200010;
vector<ll> fact, invfact;
ll modpow(ll n, int k) {
	ll r = 1;
	while (k > 0) {
		if (k&1) (r *= n) %= mod;
		(n *= n) %= mod;
		k >>= 1;
	}
	return r;
}
ll comb(int n, int k) {
	return fact[n] * invfact[k] % mod * invfact[n-k] % mod;
}
int f(int n, int m, int k) {
	return m * modpow(m-1, n-k-1) % mod * comb(n-1, k) % mod;
}
int main() {
	fact.resize(SIZE_FACT);
	invfact.resize(SIZE_FACT);
	fact[0] = invfact[0] = 1;
	for (int i = 1; i < SIZE_FACT; ++ i) {
		fact[i] = fact[i-1] * i % mod;
		invfact[i] = modpow(fact[i], mod-2);
	}

	int N, M, K;
	cin >> N >> M >> K;
	ll res = 0;
	for (int i = 0; i <= K; ++ i) {
		(res += f(N, M, i)) %= mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 6284
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
const int N = 1e5 + 10;
int p;

ll sum[N][3];
int main() {
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<P> pq;
	rep(i,a) {
		cin >> p;
		pq.push({p,0});
	}
	rep(i,b) {
		cin >> p;
		pq.push({p,1});
	}
	rep(i,c) {
		cin >> p;
		pq.push({p,2});
	}
	int red = 0, green = 0, cless = 0;
	rep(i,x+y) {
		P pp = pq.top(); pq.pop();
		p = pp.first;
		int idx = pp.second;
		if (idx == 0) {
			sum[red+1][0] = sum[red][0] + p; 
			red++;
		}
		else if (idx == 1) {
			sum[green+1][1] = sum[green][1] + p;
			green++;
		} else {
			sum[cless+1][2] = sum[cless][2] + p;
			cless++;
		}
	}
	ll ans;
	if (red <= x && green <= y) {
		ans = sum[red][0] + sum[green][1] + sum[cless][2];
	} else if (red > x) {
		ans = sum[x][0] + sum[green][1] + sum[cless][2];
		while (green + cless < y)
		{
			P pp = pq.top(); pq.pop();
			if (pp.second == 0) continue;
			ans += pp.first;
			green++;
		}
	} else {
		ans = sum[red][0] + sum[y][1] + sum[cless][2];
		while (red + cless < x)
		{
			P pp = pq.top(); pq.pop();
			if (pp.second == 1) continue;
			ans += pp.first;
			red++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7848
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n, m;
    scanf("%d %d\n", &n, &m);
	vector< pair<int, int> > vc(n);
    for(int i=0; i<n; i++) {
        int a, b;
        scanf("%d %d\n", &a, &b);
        vc[i] = make_pair(a, b);
    }
    sort(vc.begin(), vc.end());
    long long money = 0;
    for(int i=0; i<n; i++) {
        if (m <= vc[i].second){
            money += (long long)vc[i].first * m;
            break;
        }
        m -= vc[i].second;
        money += (long long)vc[i].first * vc[i].second;
    }
    printf("%lld\n", money);
    return 0;
}


Measured memory_bytes: 1152
import           Control.Arrow         (second)
import           Data.Char             (isSpace)
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BSC8
import           Data.List             (sort, unfoldr)
import           Data.Vector.Unboxed   (Vector)
import qualified Data.Vector.Unboxed   as UV

getIL :: IO [Int]
getIL = unfoldr f <$> BSC8.getLine
  where
    -- f :: ByteString -> Maybe (Int, ByteString)
    f s = do
      (n, s') <- BSC8.readInt s
      return (n, BSC8.dropWhile isSpace s')

main :: IO ()
main = do
  (_:k:_) <- getIL
  ps <- getIL
  print $ sum . take k . sort $ ps


Measured memory_bytes: 4360
#include <iostream>

using namespace std;

int main()
{
    
    while(1)
    {
        int a, b; 
        
        cin >> a >> b;
        
        if(a == 0 && b == 0)
        { break; }
        
        for(int j = 0; j < b; ++j)
        { cout << "#"; }
        cout << endl;
        
        for(int i = 1; i < a - 1; ++i)
        {
            for(int j = 0; j < b; ++j)
            {
               if(j == 0 || j == b - 1)
               { cout << "#"; }
               else 
               { cout << "."; }
             }
            cout << endl;
        }
        
        for(int j = 0; j < b; ++j)
        { cout << "#"; }
        cout << endl;
        
        cout << endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {
   string s;
   cin >> s;
   ll n = size(s);
   ll f = 0;
   for(int i = 0; i < n; i++) {
        ll d = s[i] - '0';
        f = (f+d)%9;
   }

   if(f == 0) {
      cout << "Yes" << endl;
   }
   else {
    cout <<"No" << endl;
   }
}

Measured memory_bytes: 3720
from copy import deepcopy
n = int(input())
INF = 10**12

A = []
for i in range(n):
  A.append(list(map(int,input().split())))

B = [[1]*n for _ in range(n)]
G = deepcopy(A)

for k in range(n):
  for i in range(n):
    for j in range(n):
      G[i][j] = min(G[i][j], G[i][k]+G[k][j])
      if not (i==j or j==k or k==i):
        if G[i][j] == G[i][k]+G[k][j]:
          B[i][j] = 0
      
if A==G:
  ans = 0
  for i in range(n):
    for j in range(i+1,n):      
      ans += G[i][j] * B[i][j]
  print(ans)
else:
  print(-1)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int N;

bool isPowerOf2(ll n) {
    while ((n&1) == 0) n >>= 1;
    return n == 1;
}

inline bool include(set<int> s, int x) {
    return s.find(x) != s.end();
}

ii split(int n) {
    int k = 1;
    while (k < n) k <<= 1;
    k >>= 1;
    assert((k^n) != 0);
    return MP(k, (k^n)+1);
}

void solve() {
    if (isPowerOf2(N)) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";

    set<int> nextTo1;
    vii ans;
    for (int i = 2; i < N; i += 2) {
        ans.PB(MP(1, i));
        ans.PB(MP(i, i+1));
        ans.PB(MP(1, N+i+1));
        ans.PB(MP(N+i+1, N+i));

        nextTo1.insert(i);
        nextTo1.insert(N+i+1);
    }
    ans.PB(MP(3, N+1));
    
    /*
    FOR (i, 2, N)
        assert(include(nextTo1, i) ^ include(nextTo1, N+i));
    */

    if (N%2 == 1) {
        assert(include(nextTo1, N) ^ include(nextTo1, 2*N));
    } else {
        ii m = split(N);
        int a = m.first, b = m.second;
        if (!include(nextTo1, a)) {
            if (a > N) a -= N;
            else a += N;
        }
        if (!include(nextTo1, b)) {
            if (b > N) b -= N;
            else b += N;
        }
        // assert(include(nextTo1, a));
        // assert(include(nextTo1, b));
        ans.PB(MP(a, N));
        ans.PB(MP(b, 2*N));
    }
    FORE (x, ans) {
        cout << x.first << " " << x.second << "\n";
    }
}

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

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

int main() {
	string station;
	cin >> station;
	if (station.at(0) == 'A') {
		for (int i = 1; i < 3; i++) {
			if (station.at(i) == 'B') {
				cout << "Yes" << endl;
				break;
			}
			else if(i == 2) {
				cout << "No" << endl;
				break;
			}
		}
	}
	if (station.at(0) == 'B') {
		for (int j = 1; j < 3; j++) {
			if (station.at(j) == 'A') {
				cout << "Yes" << endl;
				break;
			}
			else if(j == 2){
				cout << "No" << endl;
				break;
			}
		}
	}
}

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

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

    if (a == 'H') {
        if (b == 'H') {
            cout << 'H' << endl;
        } else {
            cout << 'D' << endl;
        }
    } else {
        if (b == 'H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
    cin>>a>>b;
	if (a==b) cout<<"Draw"<<endl;
  	else if (a==1 or (a>b and b!=1)) cout<<"Alice"<<endl;
  	else cout<<"Bob"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int ans = 0;
 
void a(int count){
    if (count > ans){
        ans = count;
    }
}
 
int main(){
    char str[12];
    
    scanf("%s", str);
    
    int idx = 0;
    
    int count = 0;
 
    while(str[idx] != '\0'){
        switch(str[idx]){
            case 'A':
            case 'C':
            case 'T':
            case 'G':
                count++;
                break;
            default:
                a(count);
                count = 0;
        }
        idx++;
    }
    
    if (count > ans){
        ans = count;
    }
    
    printf("%d", ans);
        
    return 0;
}

Measured memory_bytes: 128
D, G = map(int, input().split())
P = []
C = []
for i in range(D):
  p, c = map(int, input().split())
  P.append(p)
  C.append(c)

ans = 1e9
for mask in range(2**D):
  score = 0
  num = 0
  rest_max = -1

  for i in range(D):
    if (mask >> i) & 1:
      score += 100 * (i+1) * P[i] + C[i]
      num += P[i]
    else:
      rest_max = i

  if score < G:
    scr1 = 100 * (rest_max + 1)
    need = (G - score + scr1 - 1) // scr1
    if need >= P[rest_max]:
      continue
    num += need

  ans = min(ans, num)

print(ans)

Measured memory_bytes: 3064
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

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

int const N = 5e5 + 20 ;
int n , k , a[N] , res[N] ;
int fen[N] ;

struct node {
	int mn , lazy ;
} seg[N << 2] ;

inline void add_fen (int p , int d) {
	for (; p ; p -= p & -p) fen[p] += d ;
}

inline int get_fen (int p) {
	int ret = 0 ;
	for (p ++ ; p < N ; p += p & -p) ret += fen[p] ;
	return ret ;
}

inline void add_node (int v , int d) {
	seg[v].lazy += d ;
	seg[v].mn += d ;
}

inline void shift (int v) {
	int lc = v << 1 , rc = lc | 1 ;
	add_node(lc , seg[v].lazy) ;
	add_node(rc , seg[v].lazy) ;
	seg[v].lazy = 0 ;
}

void add (int l , int r , int val , int v = 1 , int s = 0 , int e = n) {
	if (s >= r || e <= l) return ;
	if (s >= l && e <= r) {
		add_node(v , val) ;
		return ;
	}

	shift(v) ;

	int mid = (s + e) >> 1 , lc = v << 1 , rc = lc | 1 ;

	add(l , r , val , lc , s , mid) ;
	add(l , r , val , rc , mid , e) ;

	seg[v].mn = min(seg[lc].mn , seg[rc].mn) ;
}

int get (int v = 1 , int s = 0 , int e = n) {
	if (s + 1 == e) return s ;

	shift(v) ;

	int lc = v << 1 , rc = lc | 1 , mid = (s + e) >> 1 ;

	if (seg[v].mn == seg[rc].mn) return get(rc , mid , e) ;
	return get(lc , s , mid) ;
}

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

	cin >> n >> k ;

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

	memset(fen , 0 , sizeof fen) ;
	for (int i = 0 ; i < n ; i ++) {
		add_fen(a[i] , 1) ;
		if (i - k >= 0) add_fen(a[i - k] , -1) ;
		add(i , i + 1 , get_fen(a[i])) ;
	}

	memset(fen , 0 , sizeof fen) ;
	for (int i = n - 1 ; i >= 0 ; i --) {
		add_fen(a[i] , 1) ;
		if (i + k < n) add_fen(a[i + k] , -1) ;
		add(i , i + 1 , get_fen(a[i])) ;
	}

	for (int i = 0 ; i < n ; i ++) {
		int index = get() ;
		add(index , index + 1 , n + 5) ;
		add(max(0 , index - k + 1) , min(n , index + k) , -1) ;
		
		res[index] = n - i ;
	}

	for (int i = 0 ; i < n ; i ++) cout << res[i] << '\n' ;
}


Measured memory_bytes: 20992
#include <stdio.h>
#include <stdint.h>

int main() {
  int w, h, x, y;
  double w1, h1, a;
  scanf("%d %d %d %d", &w, &h, &x, &y);
  w1 = w; h1 = h; a = w1 * h1 / 2;
  printf("%f %d", a, ((w==x*2)&&(h==y*2))?1:0);
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<double, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v, int idx)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        if (i == idx)
        {
            cout << "[" << v[i] << "]"
                 << " \n"[i == sz - 1];
            continue;
        }
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct Node
{
    Node *right;
    Node *left;
    Node *par;
    int key;

    Node(int v) : key(v)
    {
        right = left = par = NULL;
    }
};

struct BinarySearchTree
{
    Node *root;
    BinarySearchTree()
    {
        root = NULL;
    }
    void insert(int z)
    {
        insert(new Node(z));
    }
    void insert(Node *z)
    {
        Node *y = NULL, *x = root;
        while (x != NULL)
        {
            y = x;
            if (z->key < x->key)
            {
                x = x->left;
            }
            else
            {
                x = x->right;
            }
        }
        z->par = y;

        if (y == NULL)
        {
            root = z;
        }
        else if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
    void preorder(Node *cur)
    {
        if (cur == NULL)
            return;
        cout << " " << cur->key;
        preorder(cur->left);
        preorder(cur->right);
    }
    void inorder(Node *cur)
    {
        if (cur == NULL)
            return;
        inorder(cur->left);
        cout << " " << cur->key;
        inorder(cur->right);
    }
    void print()
    {
        inorder(root);
        cout << endl;
        preorder(root);
        cout << endl;
    }
    bool find(int v)
    {
        bool f = false;
        Node *x = root;
        while (x != NULL)
        {
            if (x->key == v)
            {
                f = true;
                break;
            }
            if (v < x->key)
            {
                x = x->left;
            }
            else
            {
                x = x->right;
            }
        }
        return f;
    }
};

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

    int m;
    cin >> m;
    BinarySearchTree bst = BinarySearchTree();
    for (int i = 0; i < m; i++)
    {
        string s;
        cin >> s;
        if (s == "insert")
        {
            int key;
            cin >> key;
            bst.insert(key);
        }
        else if (s == "find")
        {
            int key;
            cin >> key;
            cout << (bst.find(key) ? "yes" : "no") << endl;
        }
        else
        {
            bst.print();
        }
    }
}


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

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

    int ans = 0;

    if (s.size()%2 == 0) {
        rep(i, s.size()/2) if (s[i] != s[s.size()-i-1]) {
            ans++;
        }
    } else {
        rep(i, s.size()/2) if (s[i] != s[s.size()-i-1]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    int a[n];

    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());

    int A=0,B=0;
    for (int i=0;i<n;i++){
        if (i%2==0) A += a[i];
        else B += a[i];
    }
    cout << A - B << endl;
}

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

using namespace std;
using ll = long long;
int main () {

    int n;
    long long k;
    cin >> n >> k;
    vector<int> ports(n+1);
    for (int i = 1; i < n+1; ++i) {
        cin >> ports[i];
    }
    int tor =  ports[1];
    int hare = ports[ports[1]];
    while (true) {
        tor = ports[tor];
        hare = ports[ports[hare]];
        if (tor == hare) {
            break;
        }
    }
    tor = 1;
    int head = 0;
    while (tor != hare) {
        tor = ports[tor];
        hare = ports[hare];

        head++;
    }
    // cycle length
    tor = ports[tor];
    int cycle = 1;
    while (tor != hare) {
        tor = ports[tor];
        cycle++;
    }
    tor = 1;
    while (k > 0 && head > 0) {
        tor = ports[tor];
        k--;
        head--;
    }
    k = k % (ll)cycle;
    while (k > 0) {
        tor = ports[tor];
        k--;
    }
    cout << tor << endl;
    return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    int res = (a*3 + b)/2;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-19 14:35:01
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    long ans = 0;
    if (n*m == 1) {
        ans = 1;
    } else if (n == 1 || m == 1) {
        ans = n*m - 2;
    } else {
        ans = (n - 2)*(m - 2);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int h, w;
    cin >> h >> w;
    int a, b;
    cin >> a >> b;
    rep(i,h){
        rep(j,w){
            if(i < h - b){
                if(j < a){
                    cout << 1;
                }else{
                    cout << 0;
                }
            }else{
                if(j < a){
                    cout << 0;
                }else{
                    cout << 1;
                }
            }
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1280
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		long index[] = new long[100];
		index[0] = 1;
		for (int i = 1; i < 11; i++) {
			index[i] = index[i-1] + (long)Math.pow(26, i);
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 10; i >= 0 ; i--) {
			int w = (int)(n/index[i]);
			if (w > 0) {
				long temp = (long)Math.pow(26, i);
				int x = (int)(((n-index[i])/temp));
				sb.append((char)(x + 'a'));
				n= n - (x+1)*temp;
			}
		}
		System.out.println(sb.toString());
	}

}



Measured memory_bytes: 35828
#include<stdio.h>
int main()
{
	int a,b,x;
	scanf("%d%d",&a,&b);
	if((a+b)%2==0){
		printf("%d",(a+b)/2);
	}else if((a+b)%2!=0){
		printf("%d",(a+b)/2+1);
	}
}

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

int main(void) {
    int n, ans = 0;
    vector<int> l;
    cin >> n;
    l.resize(n * 2);
    for (int i = 0; i < n * 2; i++) cin >> l[i];
    sort(l.begin(), l.end());
    for (int i = 0; i < l.size(); i++) if (!(i % 2)) ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int N, m; cin >> N >> m;
    int sum = 0;
    vi A(N); rep (i, N) {
        cin >> A[i];
        sum += A[i];
    }

    // int m4 = sum / (4 * m);

    int cnt = 0;
    rep (i, N) {
        if (sum <=  A[i] * 4 *m) cnt++;
    }

    if (m <= cnt) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

llint n, k;
llint h[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1;i <= n; i++) cin >> h[i];
	
	llint ans = 0;
	for(int i = 1;i <= n; i++) if(h[i] >= k) ans++;
	cout<< ans << endl;
	
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,D;
int X[101010];
int Y[101010];

int A[2][2110][2110];
int S[2][2110][2110];
int num[2020][2020];

int sum(int type,int x,int y,int d) {
	return S[type][x+d][y+d]-S[type][x+d][y]-S[type][x][y+d]+S[type][x][y];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>D;
	int R=0;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		num[X[i]%D][Y[i]%D]++;
		R=max(R,num[X[i]%D][Y[i]%D]);
	}
	
	x=1;
	while(x*x<R) x++;
	R=x;
	
	FOR(x,D) FOR(y,D) {
		if(num[x][y]<=(R-1)*(R-1)) {
			continue;
		}
		else if(num[x][y]<=R*(R-1)) {
			A[1][x][y]=1;
		}
		else {
			A[0][x][y]=1;
		}
	}
	FOR(i,2) FOR(x,2*D+1) FOR(y,2*D+1) {
		if(x) S[i][x][y]+=S[i][x-1][y];
		if(y) S[i][x][y]+=S[i][x][y-1];
		if(x&&y) {
			S[i][x][y]-=S[i][x-1][y-1];
			S[i][x][y]+=A[i][(x-1)%D][(y-1)%D];
		}
	}
	
	int mi=101010;
	FOR(x,D) FOR(y,D) {
		int cur=D;
		for(i=10;i>=0;i--) if(cur-(1<<i)>=1) {
			j=cur-(1<<i);
			if(sum(0,x,y,D)!=sum(0,x,y,j)) continue;
			if(sum(1,x+j,y+j,D-j)) continue;
			cur-=1<<i;
		}
		
		mi=min(mi,cur);
	}
	
	
	
	
	cout<<mi-1+(R-1)*D<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 57984