akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define N 55
using namespace std;
typedef long long ll;
int n,p;
int a[N];
ll ans[N][2];
int main(){
	scanf("%d%d",&n,&p);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	ans[0][0]=1;
	for (int i=1;i<=n;++i){
		ans[i][1] = ans[i-1][1];	//Not Choose
		ans[i][0] = ans[i-1][0];
		if (a[i]&1){
			//Choose
			ans[i][1] += ans[i-1][0];
			ans[i][0] += ans[i-1][1];
		}
		else{
			//Choose
			ans[i][1] += ans[i-1][1];
			ans[i][0] += ans[i-1][0];
		}
	}
	cout << ans[n][p] << endl;
	return 0;
}

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

using namespace std;

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

#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define F0R(i, a) for(ll i = 0; i < a; i++)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //

int main() {
  ios:: sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  string out = (x >= 30)? "Yes" : "No";
  cout << out << "\n";
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();
	vector<ll> a(n, 0);

	char c = 'x';
	int cnt = 1;
	for(int i = n - 1; i >= 0; i--){
		if(c == s[i]){
			cnt++;
		} else{
			cnt = 1;
			c = s[i];
		}
		a[i] = cnt;
	}

	ll ans = 0;
	ll tmp = 0;
	if(s[0] == '<'){
		ans += 0;
	}else{
		tmp = a[0];
		ans += tmp;
	}

	rep(i, n){
		if(i < n - 1 && s[i] == '<' && s[i+1] == '>'){
			tmp = max(tmp + 1, a[i+1]);
		}else if(i > 0 && s[i-1] == '<' && s[i] == '>'){
			tmp = min(tmp - 1, a[i] - 1);
		}else if(s[i] == '<'){
			tmp++;
		}else if(s[i] == '>'){
			tmp--;
		}
		// cout << tmp << " ";
		ans += tmp;
	}
	// cout << endl;

	cout << ans << endl;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll H1, M1, H2, M2, K;

    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll m1 = H1*60 + M1;
    ll m2 = H2*60 + M2;
    ll m = m2 - m1;
    cout << (m-K) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

string S;

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

    cin>>S;
    int N= SZ(S);
    int cn=0;
    FOR(i,0,N-1)cn+=( S[i]=='o' );
    cn+=( 15-N );
    if(cn<8)cout<<"NO\n";
    else cout<<"YES\n";

    return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

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

  int ret{N % 1000};
  if ( ret == 0 )
    cout << ret;
  else
    cout << 1000 - ret;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int a,b;

int main()
{
	scanf("%d %d",&a,&b);
	if(a<=0 && b>=0)
		puts("Zero");
	else if(a>0 && b>0)
		puts("Positive");
	else
		puts((b-a)&1?"Positive":"Negative");
	return 0;
}

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

using namespace std;

int main(){
    int n,ans = 0;
    cin >> n;
    vector<int> a(n),b(n-1);
    for(int i = 0;i < n-1;i++)cin >> b[i];
    a[0] = b[0];a[n-1] = b[n-2];
    for(int i = 1;i < n-1;i++){
        a[i] = min(b[i-1],b[i]);
    }
    for(auto aa : a)ans += aa;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector<pair<string, int>> vec(N);
	rep(i,0,N){
		string input;
		int input_a;
		cin >> input >> input_a;
		vec[i] = make_pair(input, input_a);
	}
	string wake;
	cin >> wake;
	int cnt = 0;
	rep_d(i,N,0){
		if (vec[i].first == wake){
			cout << cnt << endl;
			return 0;
		}
		cnt += vec[i].second;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> seen(N);
    for (int i=0; i<N; i++){
        int a;
        cin >> a;
        a--;
        A[i] = a;
        seen[i] = 0;
    }
    int cnt = 1;
    int cur = 0;
    seen[0] = 1;
    while(1){
        int next = A[cur];
        if (next == 1){
            break;
        }
        if (seen[next] == 1){
            cnt = -1;
            break;
        }
        seen[next] = 1;
        cnt++;
        cur = next;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,K,i;
  cin>>N;
  string S,T;
  cin>>S;
  cin>>K;
  T=S.at(K-1);
 for(i=0;i<N;i++){
   
 if(S.at(i)!=T.at(0)){
 S.replace(i,1,"*");
 }
 }

  cout<<S<<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin >> H>> W;
        if(H==0&&W==0)break;
        for( int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i==0||i==H-1||j==0||j==W-1){
                cout << "#";
            }   else {
                cout << ".";
            }
        }
        cout << "\n";
        }
        cout << endl;
    }
    return 0;
}



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


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


    sort(d.begin(), d.end());
    int m = N/2;
    cout << d[m]-d[m-1] << endl;

    return 0;
}

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

template <class T> T up(T a, T div) { return (a + div - 1) / div; }

int main() {
    int N;
    cin >> N;
    vector<long long> T(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i] >> A[i];
    }
    long long a = A[0], t = T[0];
    for (int i = 1; i < N; i++) {
        long long n = max(up(a, A[i]), up(t, T[i]));
        t     = n * T[i];
        a     = n * A[i];
    }
    cout << t + a << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    len_s=len(s)
    t=input()
    len_t=len(t)
    dp=[[0]*(len_t+1) for _ in range(len_s+1)] # sのi文字目までについて，jを使うときに
    for i in range(1,len_s+1):
        for j in range(1,len_t+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
    len_ans=dp[len_s][len_t]
    i,j=len_s,len_t
    ans=""
    while len_ans:
        if s[i-1]==t[j-1]:
            ans+=s[i-1]
            i-=1
            j-=1
            len_ans-=1
        elif dp[i][j]==dp[i-1][j]:
            i-=1
        else:
            j-=1
    print(ans[::-1])
if __name__=='__main__':
    main()

Measured memory_bytes: 111580
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j;
	for(;;){
	cin>>H>>W;
	if(H==0&&W==0){
	break;
	}
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			if(i==1||i==H){
				cout<<"#";
			}
			else if(j==1||j==W){
				cout<<"#";
			}
			else{
			cout<<".";
			}
		}
		cout<<endl;
	}
	cout<<endl;
	}
return 0;
}

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

int main(){
    string s,t;
    cin >> s;
    int num=0;
    int ans=999;
    
    for(int i=0; i<s.size()-2; i++){
        num=100*(s.at(i)-'0')+10*(s.at(i+1)-'0')+(s.at(i+2)-'0');
        ans=min(ans,abs(753-num));
        num=0;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3580
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();

        int[] K = new int[N];

        for(int i=0; i<N; i++){
            K[nextInt()-1] = i;
        }

        for(int i=0; i<N; i++){
            print(K[i]+1 + " ");
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 354960
#include <stdio.h>
  
int main(void)
  {
   int i,n;
   scanf("%d",&n);
   for(i=0;i<n;i++){
       int y,m,d,total=0;
       scanf("%d %d %d",&y,&m,&d);
       if(y%3 ==0){
          total +=(999-y)/3*590;
          total += (10-m)*20;
          total += 21-d;
      }
      else if(y%3 ==1){
          total +=(997-y)/3*590+395;
            if(m%2==1){
               total += 19+(9-m)/2*39;
               total += 21-d;
            }
            else if(m%2 ==0){
               total += (10-m)/2*39;
               total += 20-d;
            }
      }else if(y%3 ==2){
          total +=(998-y)/3*590+200;
            if(m%2==1){
               total += 19+(9-m)/2*39;
               total += 21-d;
            }
            else if(m%2 ==0){
               total += (10-m)/2*39;
               total += 20-d;
            }
       }
       printf("%d\n",total);
    }
  return 0;
}

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

int main() {
	int sum = 1 ^ 2 ^ 3 ^ 4 ^ 5;
	for (int i=0; i<5; i++) {
		int a; cin >> a;
		sum ^= a;
	}
	cout << sum;	
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a;
	for(Int i=2; i*i<=n; ++i){
		if(n % i == 0){
			Int c = 1;
			n /= i;
			while(n % i == 0){
				++c;
				n /= i;
			}
			a.push_back(c);
		}
	}
	Int ans = 0;
	if(n > 1) ans = 1;
	for(auto i:a){
		for(Int j=1; j<=i; ++j){
			++ans;
			i -= j;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BKagamiMochi {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    set<int> d;
	    int din;
	    for(int i=0; i<n; i++){
	        in >> din;
	        d.insert(din);
	    }

	    out << d.size() << endl;
	}
};


int main() {
	BKagamiMochi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
colormap=[0]*8
free=0
for A in a:
  if A>=3200:
    free+=1
  elif A>=2800:
    colormap[7]=1
  elif A>=2400:
    colormap[6]=1
  elif A>=2000:
    colormap[5]=1
  elif A>=1600:
    colormap[4]=1
  elif A>=1200:
    colormap[3]=1
  elif A>=800:
    colormap[2]=1
  elif A>=400:
    colormap[1]=1
  else:
    colormap[0]=1
c=0
for i in range(8):
  if colormap[i]==1:
    c+=1
mi=max(c,1)
ma=c+free
print(mi,ma)

Measured memory_bytes: 3064
//ABC125C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int num;
	vector <long long int> a(n), l(n), r(n);
	for(long long int i=0;i<n;i++){
		cin >> a.at(i);
	}
	l.at(0) = a.at(0);
	r.at(n-1) = a.at(n-1);
	for(long long int i=0;i<n-1;i++){
		l.at(i+1) = __gcd(l.at(i),a.at(i+1));
	}
	for(long long int i=n-2;i>=0;i--){
		r.at(i) = __gcd(r.at(i+1),a.at(i));
	}
	vector <long long int> ans(n);
	ans.at(0) = r.at(1);
	ans.at(n-1) = l.at(n-2);
	for(long long int i=1;i<n-1;i++){
		ans.at(i) = __gcd(l.at(i-1),r.at(i+1));
	}
	sort(ans.begin(),ans.end());
	cout << ans.at(n-1) << endl;
	return 0;
}

Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    //let s: String = read();
    //println!("{}", s.chars().filter(|&c| c == '1').count());

    let s: Vec<char> = read::<String>().chars().collect();
    let mut cnt = 0;
    for v in s {
        if v == '1' {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ListeningTo ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
using namespace std;

int main() {
    ListeningTo // Those Days - ZUHAIR/RINI | youtu.be/jaRbqJvpOR4		

    int a, b;
    cin >> a >> b;
    cout << a*b;
}	


Measured memory_bytes: 3660
n,m = map(int,input().split())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

xsum = 0

up = 1
down = n-1

for i in range(n-1):

    xsum += (x[i+1] - x[i]) * up * down
    xsum %= (10 ** 9 + 7)

    up += 1
    down -= 1

left = 1
right = m-1

ans = 0

for i in range(m-1):

    ans += (y[i+1] - y[i]) * left * right * xsum
    ans %= (10 ** 9 + 7)

    left += 1
    right -= 1

print (ans)
        


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

int main()
{
    //A
    int a,b;
    cin>>a>>b;
    if(a-2*b>0)
    cout<<a-2*b<<endl;
    else
    {
        cout<<0<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = list(tuple(map(int, input().split())) for i in range(N)) #改行行列

    s=heapify(S)
    q=[]
    tot=0
    for i in range(1,M+1):
        while S and S[0][0]<=i:
            a,b=heappop(S)
            heappush(q,-b)
        if q:
            tot+=-heappop(q)
    print(tot)


if __name__ == "__main__":
    main()

Measured memory_bytes: 97268
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    bool check = true;
    for(int i = 0; i < N; i++) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) {
                check = false;
            }
        }
    }

    if(check) {
        cout << "APPROVED" << endl;
    } else  {
        cout << "DENIED" << endl;
    }

    return 0;
}

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

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	ll n,k;
	cin >> n >> k;

	n = n % k;

	while (1) {
		ll a = abs(n-k);
		if (a >= n) {
			cout << n << endl;
			return 0;
		}
		n = a;
	}

	
	return 0;
}

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

void solve(long long A, long long B)
{
    if (A - B * 2 <= 0)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << A - B * 2 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============ford_fulkerson============================
ll MAX_V = 2510;
struct edge {ll to, cap, rev;};
vector<vector<edge>> G(MAX_V);
vector<bool> used(MAX_V, false);

void reset() {
  G = vector<vector<edge>>(MAX_V);
  used = vector<bool>(MAX_V, false);
}

void add_edge(ll from, ll to, ll cap) {
  G.at(from).push_back((edge){to, cap, (ll)G.at(to).size()});
  G.at(to).push_back((edge){from, 0ll, (ll)G.at(from).size() - 1});
}

ll dfs(ll v, ll t, ll f) {
  if (v == t) {
    return f;
  }
  used.at(v) = true;
  for (ll i = 0; i < G.at(v).size(); ++i) {
    edge &e = G.at(v).at(i);
    if (!used.at(e.to) && e.cap > 0) {
      ll d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G.at(e.to).at(e.rev).cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s, ll t) {
  ll flow = 0;
  while (true) {
    used = vector<bool>(MAX_V, false);
    ll f = dfs(s, t, INF);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}
//=================================================


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while (true) {
    ll m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) {
      break;
    }
    reset();
    vector<ll> b(m), r(n);
    for (ll i = 0; i < m; ++i) {
      cin >> b.at(i);
      add_edge(0, i + 2, 1);
    }
    for (ll i = 0; i < n; ++i) {
      cin >> r.at(i);
      add_edge(i + m + 2, 1, 1);
    }
    for (ll i = 0; i < m; ++i) {
      for (ll j = 0; j < n; ++j) {
        if (__gcd(b.at(i), r.at(j)) != 1) {
          add_edge(i + 2, j + m + 2, 1);
        }
      }
    }
    cout << max_flow(0, 1) << "\n";
  }
}



Measured memory_bytes: 11784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // input
        String  S = sc.next();

        //replace all 2017 to 2018
        String editedS = S.replace("2017", "2018");

        System.out.println(editedS);
    }

}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	string a, b; cin >> a >> b;
	if (a.size() > b.size()) {
		puts("GREATER");
	}
	else if (a.size() < b.size()) {
		puts("LESS");
	}
	else {
		if (a > b)puts("GREATER");
		else if (a < b)puts("LESS");
		else puts("EQUAL");
	}

	return 0;
}

Measured memory_bytes: 256
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

mint dp[100005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<bool> broken(n + 5, false);
	rep(i, m) {
		int a;
		cin >> a;
		broken[a] = true;
	}
	dp[0] = 1;
	rep(i, n) {
		if (!broken[i + 1]) dp[i + 1] += dp[i];
		if (!broken[i + 2]) dp[i + 2] += dp[i];
	}
	printf("%d\n", dp[n]);
	return 0;
}


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

using namespace std;

class Fibonacci{
private:
 vector< long > FN;
 long current;
public:
 Fibonacci( long num_0 = 1, long num_1 = 1, long max = 100 ) : current( 1 ), FN( max, 0 ){
  FN[ 0 ] = num_0;
  FN[ 1 ] = num_1;
 };

 void calculate( long num ){

  while( current < num ){
   ++current;
   FN[ current ] = FN[ current-2 ] + FN[ current-1 ];
  }
 };

 long get( long num ){
  if( current < num ) calculate( num );

  return FN[ num ];
 }

 void display(){
  for(long i = 0; i <= current; ++i)
   cout << FN[i] << " ";
  cout << endl;
 };

};

int main(){
 Fibonacci fn;

 long n = 0; cin >> n;

 long num = fn.get( n );

 cout << num << endl;

 return 0;
};

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

#define MAX_P  100000
#define Q_size 100001

typedef struct{
  char name[10];
  int  time;
}Process;

Process Queue[Q_size];
int     head, tail;

void push(Process p){
  Queue[tail++%Q_size]=p;
}

Process pop(){
  return Queue[head++%Q_size];
}

int main(){
  int     i, n, p_time, total=0;
  Process p;
  
  scanf("%d %d", &n, &p_time);
  
  for(i=0; i<n; i++){
    scanf("%s %d", p.name, &p.time);
    push(p);
  }
  
  while(head != tail){
    p=pop();
    
    if(p.time<=p_time){
      total+=p.time;
      printf("%s %d\n", p.name, total);
    }
    else{
      total+=p_time;
      p.time-=p_time;
      push(p);
    }
  }
  
  return 0;
}



Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=2e3+5,mod=1e9+7;
int n,ans;
int fac[maxn<<2],ifac[maxn<<2];
int cnt[maxn][maxn],f[maxn<<1][maxn<<1];
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
void upd(int &x,int y){x=add(x,y);}
int C(int x,int y){
	return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
int main(){
	fac[0]=1;rep(i,1,8e3)fac[i]=1ll*fac[i-1]*i%mod;
	rep(i,0,8e3)ifac[i]=power(fac[i],mod-2,mod);
	read(n);
	rep(i,1,n){
		int x,y;read(x);read(y);
		ans=sub(ans,C(x+x+y+y,x+x));
		cnt[x][y]++;
	}
	rep(i,-2000,2000)rep(j,-2000,2000){
		if(i<0&&j<0)upd(f[i+2001][j+2001],cnt[-i][-j]);
		upd(f[i+2001][j+2001],f[i-1+2001][j+2001]);
		upd(f[i+2001][j+2001],f[i+2001][j-1+2001]);
		if(i>0&&j>0)upd(ans,1ll*f[i+2001][j+2001]*cnt[i][j]%mod);
	}
	ans=1ll*ans*power(2,mod-2,mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 78848
def main():
    import math
    from functools import reduce
    k = int(input())
    ans = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772,10813692]
    print(ans[k-1])
     
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 9580
#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;

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

    bool flag_a = false;
    bool flag_b = false;
    bool flag_c = false;

    string S_start = S;
    string S_end = S;

    reverse(all(S_end));

    if(S_start == S_end) {
        flag_c = true;
    }

    // 前半
    string res_a = "";
    string res_b = "";

    int start = (S.size() - 1) / 2;
    REP(i, start) {
        res_a += S[i];
    }
    res_b = res_a;
    reverse(all(res_b));

    if(res_a == res_b) {
        flag_a = true;
    }

    // 後半
    string res_c = "";
    string res_d = "";
    int start_b = (S.size() + 3) / 2;
    for(int i = start_b - 1; i < S.size(); ++i) {
        res_c += S[i];
    }

    res_d = res_c;
    reverse(all(res_d));

    if(res_c == res_d) {
        flag_b = true;
    }

    // cout <<res_a << " " << res_b << " " << res_c << " " << res_d << endl;

    if(flag_a && flag_b && flag_c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	int N,R;
	cin >> N >> R;
	if (N>=10) {
		cout << R;
	} else {
		cout << R+(100*(10-N));
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
#include<stdio.h>

typedef struct box { int val; box *prev, *next; } box_t;

box_t* init()
{
    box_t* head = new box_t;
    head->val = -1;
    head->next = NULL;
    head->prev = NULL;
    return head;
}

box_t* make_tail(box_t* head)
{
    box_t* tail = new box_t;
    tail->val = -1;
    head->next = tail;
    tail->next = NULL;
    tail->prev = head;
    return tail;
}

bool isEmpty(box_t* head, box_t* tail)
{
    return (head->next == tail ? true : false);
}

box_t* f_insert(box_t* head, int data)
{
    box_t* box = new box_t;
    box->val = data;
    box->next = head->next;
    box->prev = head;
    head->next->prev = box;
    head->next = box;
    return box;
}

int b_pop(box_t* tail)
{
    if(!(tail->prev->prev)) return -1;
    box_t* box = tail->prev;
    int val;
    val = tail->prev->val;
    tail->prev = box->prev;
    box->prev->next = tail;
    delete box;
    return val;
}

int main()
{
    int G[101][102];
    int dist[101];

    box_t* head = init();
    box_t* tail = make_tail(head);

    int n, i, j, a, b, e, v1, v2;
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        for(j = 0; j <= n + 1; j++){ G[i][j] = 0; } }

    for(i = 1; i <= n; i++){
        scanf("%d %d", &a, &e);
		G[i][0] = e;  // number of edge.
        for(j = 1; j <= e; j++){
            scanf("%d", &b); G[a][j] = b; } }  // adjacent representation.

    for(i = 1; i <= n; i++) dist[i] = -1;
    f_insert(head, 1);
    dist[1] = 0;

    while(1){
        v1 = b_pop(tail);
		e = G[v1][0];
        for(i = 1; i <= e; i++){
            v2 = G[v1][i];
            if(dist[v2] < 0){
                dist[v2] = dist[v1] + 1;
                f_insert(head, v2);
            }
        }
        if(isEmpty(head, tail)) break;
    };

    for(i = 1; i <= n; i++){ printf("%d %d\n", i, dist[i]); }

    return 0;
}

Measured memory_bytes: 1228
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int a,b,k;
cin>>a>>b>>k;
if(2*k>=(b-a+1))
for(int i=a;i<=b;i++)
cout<<i<<endl;
else
{for(int i=0;i<k;i++)
cout<<a+i<<endl;
for(int i=k-1;i>=0;i--)
cout<<b-i<<endl;}
system("pause");
return 0;
}

 

Measured memory_bytes: 504
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        String S=sc.next(),T=sc.next();
        long res=S.length();
        for(int i=0;i<=S.length()-T.length();i++){
            long count=0;
            for(int j=0;j<T.length();j++){
                if(S.charAt(i+j)!=T.charAt(j)){
                    count++;
                }
            }
            res=Math.min(res,count);
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 35568
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
#define MAXN 100006
#define int long long
int A[MAXN];
int p[63][MAXN] , ans[MAXN] , Ans[MAXN] , d[MAXN];
int n , m; long long k;
main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%lld",&A[i]) , d[i] = A[i] - A[i-1];
    cin >> m >> k;
    for( int i = 1 ; i <= n ; ++ i ) p[0][i] = i , Ans[i] = i;
    for( int i = 1 ; i <= m ; ++ i ) {
        scanf("%lld",&A[i]);
        swap( p[0][A[i]] , p[0][A[i]+1] );
    }
    for( int t = 1 ; t < 63 ; ++ t )
        for( int i = 1 ; i <= n ; ++ i ) 
            p[t][i] = p[t-1][p[t-1][i]];
    int c = k;
    for( int k = 62 ; k >= 0 ; -- k ) if( ( 1LL << k ) <= c ) {
        c -= ( 1LL << k );
        for( int i = 1 ; i <= n ; ++ i )
            Ans[i] = p[k][Ans[i]];
    }
    for( int i = 1 ; i <= n ; ++ i )
        ans[i] = d[Ans[i]];
    int as = 0;
    for( int i = 1 ; i <= n ; ++ i ) as += ans[i] , printf("%lld\n",as);
}
/*
5
1 3 6 10 15
2
10
3 4
*/

Measured memory_bytes: 53632
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main(){
	daman
	int l,r,d,count = 0;
	
	cin>>l>>r>>d;
	
	for(int i=l;i<=r;i++)
		if(i%d == 0)
			count++;
	
	cout<<count<<"\n";
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <vector>
using namespace std;

int main() {
	int x;
	cin>>x;
	vector<int> v2;
	for (int i=1; i<=31; ++i) v2.push_back(i*i);
	vector<int> v3={1,8,27,64,125,216,343,512,729,1000};
	vector<int> v4={1,16,81,256,625};
	vector<int> v5={1,32,243};
	vector<int> v6={1,64,729};
	vector<int> v7={1,128};
	vector<int> v8={1,256};
	vector<int> v9={1,512};
	auto i2=upper_bound(v2.begin(), v2.end(), x);
	int ans=*(i2-1);
	for (int i=0; i<v3.size(); ++i)
		if (v3[i]>=ans && v3[i]<=x) ans=v3[i];
	for (int i=0; i<v4.size(); ++i)
		if (v4[i]>=ans && v4[i]<=x) ans=v4[i];
	for (int i=0; i<v5.size(); ++i)
		if (v5[i]>=ans && v5[i]<=x) ans=v5[i];
	for (int i=0; i<v6.size(); ++i)
		if (v6[i]>=ans && v6[i]<=x) ans=v6[i];
	for (int i=0; i<v7.size(); ++i)
		if (v7[i]>=ans && v7[i]<=x) ans=v7[i];
	for (int i=0; i<v8.size(); ++i)
		if (v8[i]>=ans && v8[i]<=x) ans=v8[i];
	for (int i=0; i<v9.size(); ++i)
		if (v9[i]>=ans && v9[i]<=x) ans=v9[i];
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

g = [] * 201

def gcd(a, b):
    while b > 0:
        c = a % b
        a = b
        b = c
    return a

for i in range(201):
    g.append([])
    for j in range(201):
        g[-1].append(gcd(i, j))

n = ni()
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        u = g[i][j]
        for k in range(1,n+1):
            ans += g[u][k]
print(ans)


Measured memory_bytes: 68276
A, B, K = map(int, input().split())

if B - A + 1 < 2 * K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)

Measured memory_bytes: 3060
use proconio::input;

fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }

    for distance in a..(b + 1) {
        if distance % k == 0 {
            println!("OK");
            return;
        }
    }

    println!("NG");
}


Measured memory_bytes: 2148
import sys
sys.setrecursionlimit(200000)
from collections import deque

N, Q = map(int, input().split())

connection = [[] for i in range(N)]
for i in range(N-1):
    a,b =  map(int, input().split())
    connection[a-1].append(b)
    connection[b-1].append(a)

operations = [0] * N
for i in range(Q):
    p,q =  map(int, input().split())
    operations[p-1] += q

ans = [0] * N

stack = deque([1])
while len(stack)>0:
    node = stack.pop()
    ans[node-1] += operations[node-1]
    for node_c in connection[node-1]:
        connection[node_c-1].remove(node)
        ans[node_c-1] += ans[node-1]
        stack.append(node_c)

print(' '.join(map(str, ans)))


            





Measured memory_bytes: 67208
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 384
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int s[5], k;
	REP(i,5) cin >> s[i];
	cin >> k;
	REP(i, 4){
		for(int j= i+1; j < 5; j++){
			if(abs(s[i]-s[j]) > k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
    cout << "Yay!" << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    for(int i=1; i<(int)sqrt(N)+1; i++) {
        if(N%i==0) {
            if(i<10 && (N/i)<10) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;

    return 0;
    
}

Measured memory_bytes: 256
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日，0-indexed:1-indexed
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    return score


def evaluate(D, C, S, T, k):
    """
    d日目終了時点での満足度を計算し，
    d + k日目終了時点での満足度の減少も考慮する
    """
    score = 0
    last = [0]*26
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]

    for d in range(len(T), min(len(T) + k, D)):
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
    return score


def greedy(D, C, S):
    Ts = []
    for k in range(5, 13):
        T = []  # 0-indexed
        max_score = -INF
        for d in range(D):
            # d+k日目終了時点で満足度が一番高くなるようなコンテストiを開催する
            max_score = -INF
            best_i = 0
            for i in range(26):
                T.append(i)
                score = evaluate(D, C, S, T, k)
                if max_score < score:
                    max_score = score
                    best_i = i
                T.pop()
            T.append(best_i)
        Ts.append((max_score, T))
    return max(Ts, key=lambda pair: pair[0])


def local_search(D, C, S, score, T):
    for k in range(4000):
        ct = randint(0, D-1)
        ci = randint(0, 25)
        ori = T[ct]
        T[ct] = ci
        new_score = calc_score(D, C, S, T)
        # 差分更新がバグってそう
        if score < new_score:
            score = new_score
        else:
            T[ct] = ori
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    init_score, T = greedy(D, C, S)
    T = local_search(D, C, S, init_score, T)
    for t in T:
        print(t+1)


Measured memory_bytes: 85928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  long W;
  cin >> N >> W;
  vector<long> w(N);
  vector<long> v(N);
  for(int i=0; i<N; i++)cin >> w[i] >> v[i];
  long w_sum=100010;
  vector<vector <long>> dp(N+1,vector<long>(w_sum,0));
  
  for(int i=1; i<=N; i++){
    for(int j=0; j<w_sum; j++){
      if(w[i-1]<=j)dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i][j]);
      dp[i][j]=max(dp[i][j],dp[i-1][j]);
    }
  }
  cout<<dp[N][W]<<endl;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

int bit[300005][64];

signed main() {
	int n, ans = 0;
	cin >> n;
	int a[300005], b[300005];
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
		int now = 0;
		while (a[i] > 0) {
			bit[i][now] = a[i] % 2;
			a[i] /= 2;
			now++;
		}
	}
	int bou = 1;
	rep(i, 61) {
		int zero = 0, one = 0;
		rep(j, n) {
			if (bit[j][i]) one++;
			else zero++;
		}
		ans += bou * (one * zero % MOD) % MOD;
		ans %= MOD;
		bou *= 2;
		bou %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 152576
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value


void solve() {

	int A, P;
	cin >> A >> P;

	P += A * 3;
	cout << P / 2 << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256